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 = uword_to_pointer (mp->reply_in_shmem, u8 *);
1001 vam->result_ready = 1;
1005 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1007 vat_main_t *vam = &vat_main;
1008 vat_json_node_t node;
1009 api_main_t *am = &api_main;
1013 vat_json_init_object (&node);
1014 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1015 vat_json_object_add_uint (&node, "reply_in_shmem",
1016 ntohl (mp->reply_in_shmem));
1017 /* Toss the shared-memory original... */
1018 pthread_mutex_lock (&am->vlib_rp->mutex);
1019 oldheap = svm_push_data_heap (am->vlib_rp);
1021 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1024 svm_pop_heap (oldheap);
1025 pthread_mutex_unlock (&am->vlib_rp->mutex);
1027 vat_json_print (vam->ofp, &node);
1028 vat_json_free (&node);
1030 vam->retval = ntohl (mp->retval);
1031 vam->result_ready = 1;
1035 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1037 vat_main_t *vam = &vat_main;
1038 i32 retval = ntohl (mp->retval);
1040 vam->retval = retval;
1041 vam->cmd_reply = mp->reply;
1042 vam->result_ready = 1;
1046 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1048 vat_main_t *vam = &vat_main;
1049 vat_json_node_t node;
1051 vat_json_init_object (&node);
1052 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1053 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1055 vat_json_print (vam->ofp, &node);
1056 vat_json_free (&node);
1058 vam->retval = ntohl (mp->retval);
1059 vam->result_ready = 1;
1062 static void vl_api_classify_add_del_table_reply_t_handler
1063 (vl_api_classify_add_del_table_reply_t * mp)
1065 vat_main_t *vam = &vat_main;
1066 i32 retval = ntohl (mp->retval);
1067 if (vam->async_mode)
1069 vam->async_errors += (retval < 0);
1073 vam->retval = retval;
1075 ((mp->new_table_index != 0xFFFFFFFF) ||
1076 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1077 (mp->match_n_vectors != 0xFFFFFFFF)))
1079 * Note: this is just barely thread-safe, depends on
1080 * the main thread spinning waiting for an answer...
1082 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1083 ntohl (mp->new_table_index),
1084 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1085 vam->result_ready = 1;
1089 static void vl_api_classify_add_del_table_reply_t_handler_json
1090 (vl_api_classify_add_del_table_reply_t * mp)
1092 vat_main_t *vam = &vat_main;
1093 vat_json_node_t node;
1095 vat_json_init_object (&node);
1096 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1097 vat_json_object_add_uint (&node, "new_table_index",
1098 ntohl (mp->new_table_index));
1099 vat_json_object_add_uint (&node, "skip_n_vectors",
1100 ntohl (mp->skip_n_vectors));
1101 vat_json_object_add_uint (&node, "match_n_vectors",
1102 ntohl (mp->match_n_vectors));
1104 vat_json_print (vam->ofp, &node);
1105 vat_json_free (&node);
1107 vam->retval = ntohl (mp->retval);
1108 vam->result_ready = 1;
1111 static void vl_api_get_node_index_reply_t_handler
1112 (vl_api_get_node_index_reply_t * mp)
1114 vat_main_t *vam = &vat_main;
1115 i32 retval = ntohl (mp->retval);
1116 if (vam->async_mode)
1118 vam->async_errors += (retval < 0);
1122 vam->retval = retval;
1124 errmsg ("node index %d", ntohl (mp->node_index));
1125 vam->result_ready = 1;
1129 static void vl_api_get_node_index_reply_t_handler_json
1130 (vl_api_get_node_index_reply_t * mp)
1132 vat_main_t *vam = &vat_main;
1133 vat_json_node_t node;
1135 vat_json_init_object (&node);
1136 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1137 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1139 vat_json_print (vam->ofp, &node);
1140 vat_json_free (&node);
1142 vam->retval = ntohl (mp->retval);
1143 vam->result_ready = 1;
1146 static void vl_api_get_next_index_reply_t_handler
1147 (vl_api_get_next_index_reply_t * mp)
1149 vat_main_t *vam = &vat_main;
1150 i32 retval = ntohl (mp->retval);
1151 if (vam->async_mode)
1153 vam->async_errors += (retval < 0);
1157 vam->retval = retval;
1159 errmsg ("next node index %d", ntohl (mp->next_index));
1160 vam->result_ready = 1;
1164 static void vl_api_get_next_index_reply_t_handler_json
1165 (vl_api_get_next_index_reply_t * mp)
1167 vat_main_t *vam = &vat_main;
1168 vat_json_node_t node;
1170 vat_json_init_object (&node);
1171 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1172 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1174 vat_json_print (vam->ofp, &node);
1175 vat_json_free (&node);
1177 vam->retval = ntohl (mp->retval);
1178 vam->result_ready = 1;
1181 static void vl_api_add_node_next_reply_t_handler
1182 (vl_api_add_node_next_reply_t * mp)
1184 vat_main_t *vam = &vat_main;
1185 i32 retval = ntohl (mp->retval);
1186 if (vam->async_mode)
1188 vam->async_errors += (retval < 0);
1192 vam->retval = retval;
1194 errmsg ("next index %d", ntohl (mp->next_index));
1195 vam->result_ready = 1;
1199 static void vl_api_add_node_next_reply_t_handler_json
1200 (vl_api_add_node_next_reply_t * mp)
1202 vat_main_t *vam = &vat_main;
1203 vat_json_node_t node;
1205 vat_json_init_object (&node);
1206 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1207 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1209 vat_json_print (vam->ofp, &node);
1210 vat_json_free (&node);
1212 vam->retval = ntohl (mp->retval);
1213 vam->result_ready = 1;
1216 static void vl_api_show_version_reply_t_handler
1217 (vl_api_show_version_reply_t * mp)
1219 vat_main_t *vam = &vat_main;
1220 i32 retval = ntohl (mp->retval);
1224 errmsg (" program: %s", mp->program);
1225 errmsg (" version: %s", mp->version);
1226 errmsg (" build date: %s", mp->build_date);
1227 errmsg ("build directory: %s", mp->build_directory);
1229 vam->retval = retval;
1230 vam->result_ready = 1;
1233 static void vl_api_show_version_reply_t_handler_json
1234 (vl_api_show_version_reply_t * mp)
1236 vat_main_t *vam = &vat_main;
1237 vat_json_node_t node;
1239 vat_json_init_object (&node);
1240 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1241 vat_json_object_add_string_copy (&node, "program", mp->program);
1242 vat_json_object_add_string_copy (&node, "version", mp->version);
1243 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1244 vat_json_object_add_string_copy (&node, "build_directory",
1245 mp->build_directory);
1247 vat_json_print (vam->ofp, &node);
1248 vat_json_free (&node);
1250 vam->retval = ntohl (mp->retval);
1251 vam->result_ready = 1;
1255 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1257 u32 sw_if_index = ntohl (mp->sw_if_index);
1258 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1259 mp->mac_ip ? "mac/ip binding" : "address resolution",
1260 ntohl (mp->pid), format_ip4_address, &mp->address,
1261 format_ethernet_address, mp->new_mac, sw_if_index);
1265 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1267 /* JSON output not supported */
1271 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1273 u32 sw_if_index = ntohl (mp->sw_if_index);
1274 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1275 mp->mac_ip ? "mac/ip binding" : "address resolution",
1276 ntohl (mp->pid), format_ip6_address, mp->address,
1277 format_ethernet_address, mp->new_mac, sw_if_index);
1281 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1283 /* JSON output not supported */
1287 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1289 u32 n_macs = ntohl (mp->n_macs);
1290 errmsg ("L2MAC event recived with pid %d cl-idx %d for %d macs: \n",
1291 ntohl (mp->pid), mp->client_index, n_macs);
1293 for (i = 0; i < n_macs; i++)
1295 vl_api_mac_entry_t *mac = &mp->mac[i];
1296 errmsg (" [%d] sw_if_index %d mac_addr %U is_del %d \n",
1297 i + 1, ntohl (mac->sw_if_index),
1298 format_ethernet_address, mac->mac_addr, mac->is_del);
1305 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1307 /* JSON output not supported */
1310 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1311 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1314 * Special-case: build the bridge domain table, maintain
1315 * the next bd id vbl.
1317 static void vl_api_bridge_domain_details_t_handler
1318 (vl_api_bridge_domain_details_t * mp)
1320 vat_main_t *vam = &vat_main;
1321 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1324 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1325 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1327 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1328 ntohl (mp->bd_id), mp->learn, mp->forward,
1329 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1333 vl_api_bridge_domain_sw_if_t *sw_ifs;
1334 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1337 sw_ifs = mp->sw_if_details;
1338 for (i = 0; i < n_sw_ifs; i++)
1344 sw_if_index = ntohl (sw_ifs->sw_if_index);
1347 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1349 if ((u32) p->value[0] == sw_if_index)
1351 sw_if_name = (u8 *)(p->key);
1356 print (vam->ofp, "%7d %3d %s", sw_if_index,
1357 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1358 "sw_if_index not found!");
1365 static void vl_api_bridge_domain_details_t_handler_json
1366 (vl_api_bridge_domain_details_t * mp)
1368 vat_main_t *vam = &vat_main;
1369 vat_json_node_t *node, *array = NULL;
1370 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1372 if (VAT_JSON_ARRAY != vam->json_tree.type)
1374 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1375 vat_json_init_array (&vam->json_tree);
1377 node = vat_json_array_add (&vam->json_tree);
1379 vat_json_init_object (node);
1380 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1381 vat_json_object_add_uint (node, "flood", mp->flood);
1382 vat_json_object_add_uint (node, "forward", mp->forward);
1383 vat_json_object_add_uint (node, "learn", mp->learn);
1384 vat_json_object_add_uint (node, "bvi_sw_if_index",
1385 ntohl (mp->bvi_sw_if_index));
1386 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1387 array = vat_json_object_add (node, "sw_if");
1388 vat_json_init_array (array);
1394 vl_api_bridge_domain_sw_if_t *sw_ifs;
1397 sw_ifs = mp->sw_if_details;
1398 for (i = 0; i < n_sw_ifs; i++)
1400 node = vat_json_array_add (array);
1401 vat_json_init_object (node);
1402 vat_json_object_add_uint (node, "sw_if_index",
1403 ntohl (sw_ifs->sw_if_index));
1404 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1410 static void vl_api_control_ping_reply_t_handler
1411 (vl_api_control_ping_reply_t * mp)
1413 vat_main_t *vam = &vat_main;
1414 i32 retval = ntohl (mp->retval);
1415 if (vam->async_mode)
1417 vam->async_errors += (retval < 0);
1421 vam->retval = retval;
1422 vam->result_ready = 1;
1426 static void vl_api_control_ping_reply_t_handler_json
1427 (vl_api_control_ping_reply_t * mp)
1429 vat_main_t *vam = &vat_main;
1430 i32 retval = ntohl (mp->retval);
1432 if (VAT_JSON_NONE != vam->json_tree.type)
1434 vat_json_print (vam->ofp, &vam->json_tree);
1435 vat_json_free (&vam->json_tree);
1436 vam->json_tree.type = VAT_JSON_NONE;
1441 vat_json_init_array (&vam->json_tree);
1442 vat_json_print (vam->ofp, &vam->json_tree);
1443 vam->json_tree.type = VAT_JSON_NONE;
1446 vam->retval = retval;
1447 vam->result_ready = 1;
1451 vl_api_bridge_domain_set_mac_age_reply_t_handler
1452 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1454 vat_main_t *vam = &vat_main;
1455 i32 retval = ntohl (mp->retval);
1456 if (vam->async_mode)
1458 vam->async_errors += (retval < 0);
1462 vam->retval = retval;
1463 vam->result_ready = 1;
1467 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1468 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1470 vat_main_t *vam = &vat_main;
1471 vat_json_node_t node;
1473 vat_json_init_object (&node);
1474 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1476 vat_json_print (vam->ofp, &node);
1477 vat_json_free (&node);
1479 vam->retval = ntohl (mp->retval);
1480 vam->result_ready = 1;
1484 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1486 vat_main_t *vam = &vat_main;
1487 i32 retval = ntohl (mp->retval);
1488 if (vam->async_mode)
1490 vam->async_errors += (retval < 0);
1494 vam->retval = retval;
1495 vam->result_ready = 1;
1499 static void vl_api_l2_flags_reply_t_handler_json
1500 (vl_api_l2_flags_reply_t * mp)
1502 vat_main_t *vam = &vat_main;
1503 vat_json_node_t node;
1505 vat_json_init_object (&node);
1506 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1507 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1508 ntohl (mp->resulting_feature_bitmap));
1510 vat_json_print (vam->ofp, &node);
1511 vat_json_free (&node);
1513 vam->retval = ntohl (mp->retval);
1514 vam->result_ready = 1;
1517 static void vl_api_bridge_flags_reply_t_handler
1518 (vl_api_bridge_flags_reply_t * mp)
1520 vat_main_t *vam = &vat_main;
1521 i32 retval = ntohl (mp->retval);
1522 if (vam->async_mode)
1524 vam->async_errors += (retval < 0);
1528 vam->retval = retval;
1529 vam->result_ready = 1;
1533 static void vl_api_bridge_flags_reply_t_handler_json
1534 (vl_api_bridge_flags_reply_t * mp)
1536 vat_main_t *vam = &vat_main;
1537 vat_json_node_t node;
1539 vat_json_init_object (&node);
1540 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1541 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1542 ntohl (mp->resulting_feature_bitmap));
1544 vat_json_print (vam->ofp, &node);
1545 vat_json_free (&node);
1547 vam->retval = ntohl (mp->retval);
1548 vam->result_ready = 1;
1551 static void vl_api_tap_connect_reply_t_handler
1552 (vl_api_tap_connect_reply_t * mp)
1554 vat_main_t *vam = &vat_main;
1555 i32 retval = ntohl (mp->retval);
1556 if (vam->async_mode)
1558 vam->async_errors += (retval < 0);
1562 vam->retval = retval;
1563 vam->sw_if_index = ntohl (mp->sw_if_index);
1564 vam->result_ready = 1;
1569 static void vl_api_tap_connect_reply_t_handler_json
1570 (vl_api_tap_connect_reply_t * mp)
1572 vat_main_t *vam = &vat_main;
1573 vat_json_node_t node;
1575 vat_json_init_object (&node);
1576 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1577 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1579 vat_json_print (vam->ofp, &node);
1580 vat_json_free (&node);
1582 vam->retval = ntohl (mp->retval);
1583 vam->result_ready = 1;
1588 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1590 vat_main_t *vam = &vat_main;
1591 i32 retval = ntohl (mp->retval);
1592 if (vam->async_mode)
1594 vam->async_errors += (retval < 0);
1598 vam->retval = retval;
1599 vam->sw_if_index = ntohl (mp->sw_if_index);
1600 vam->result_ready = 1;
1604 static void vl_api_tap_modify_reply_t_handler_json
1605 (vl_api_tap_modify_reply_t * mp)
1607 vat_main_t *vam = &vat_main;
1608 vat_json_node_t node;
1610 vat_json_init_object (&node);
1611 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1612 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1614 vat_json_print (vam->ofp, &node);
1615 vat_json_free (&node);
1617 vam->retval = ntohl (mp->retval);
1618 vam->result_ready = 1;
1622 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1624 vat_main_t *vam = &vat_main;
1625 i32 retval = ntohl (mp->retval);
1626 if (vam->async_mode)
1628 vam->async_errors += (retval < 0);
1632 vam->retval = retval;
1633 vam->result_ready = 1;
1637 static void vl_api_tap_delete_reply_t_handler_json
1638 (vl_api_tap_delete_reply_t * mp)
1640 vat_main_t *vam = &vat_main;
1641 vat_json_node_t node;
1643 vat_json_init_object (&node);
1644 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1646 vat_json_print (vam->ofp, &node);
1647 vat_json_free (&node);
1649 vam->retval = ntohl (mp->retval);
1650 vam->result_ready = 1;
1653 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1654 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1656 vat_main_t *vam = &vat_main;
1657 i32 retval = ntohl (mp->retval);
1658 if (vam->async_mode)
1660 vam->async_errors += (retval < 0);
1664 vam->retval = retval;
1665 vam->result_ready = 1;
1669 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1670 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1672 vat_main_t *vam = &vat_main;
1673 vat_json_node_t node;
1675 vat_json_init_object (&node);
1676 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1677 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1678 ntohl (mp->sw_if_index));
1680 vat_json_print (vam->ofp, &node);
1681 vat_json_free (&node);
1683 vam->retval = ntohl (mp->retval);
1684 vam->result_ready = 1;
1687 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1688 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1690 vat_main_t *vam = &vat_main;
1691 i32 retval = ntohl (mp->retval);
1692 if (vam->async_mode)
1694 vam->async_errors += (retval < 0);
1698 vam->retval = retval;
1699 vam->sw_if_index = ntohl (mp->sw_if_index);
1700 vam->result_ready = 1;
1704 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1705 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1707 vat_main_t *vam = &vat_main;
1708 vat_json_node_t node;
1710 vat_json_init_object (&node);
1711 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1712 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1714 vat_json_print (vam->ofp, &node);
1715 vat_json_free (&node);
1717 vam->retval = ntohl (mp->retval);
1718 vam->result_ready = 1;
1721 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
1722 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1724 vat_main_t *vam = &vat_main;
1725 i32 retval = ntohl (mp->retval);
1726 if (vam->async_mode)
1728 vam->async_errors += (retval < 0);
1732 vam->retval = retval;
1733 vam->result_ready = 1;
1737 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
1738 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1740 vat_main_t *vam = &vat_main;
1741 vat_json_node_t node;
1743 vat_json_init_object (&node);
1744 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1745 vat_json_object_add_uint (&node, "fwd_entry_index",
1746 clib_net_to_host_u32 (mp->fwd_entry_index));
1748 vat_json_print (vam->ofp, &node);
1749 vat_json_free (&node);
1751 vam->retval = ntohl (mp->retval);
1752 vam->result_ready = 1;
1755 static void vl_api_one_add_del_locator_set_reply_t_handler
1756 (vl_api_one_add_del_locator_set_reply_t * mp)
1758 vat_main_t *vam = &vat_main;
1759 i32 retval = ntohl (mp->retval);
1760 if (vam->async_mode)
1762 vam->async_errors += (retval < 0);
1766 vam->retval = retval;
1767 vam->result_ready = 1;
1771 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1772 (vl_api_one_add_del_locator_set_reply_t * mp)
1774 vat_main_t *vam = &vat_main;
1775 vat_json_node_t node;
1777 vat_json_init_object (&node);
1778 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1779 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1781 vat_json_print (vam->ofp, &node);
1782 vat_json_free (&node);
1784 vam->retval = ntohl (mp->retval);
1785 vam->result_ready = 1;
1788 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1789 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1791 vat_main_t *vam = &vat_main;
1792 i32 retval = ntohl (mp->retval);
1793 if (vam->async_mode)
1795 vam->async_errors += (retval < 0);
1799 vam->retval = retval;
1800 vam->sw_if_index = ntohl (mp->sw_if_index);
1801 vam->result_ready = 1;
1805 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1806 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1808 vat_main_t *vam = &vat_main;
1809 vat_json_node_t node;
1811 vat_json_init_object (&node);
1812 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1813 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1815 vat_json_print (vam->ofp, &node);
1816 vat_json_free (&node);
1818 vam->retval = ntohl (mp->retval);
1819 vam->result_ready = 1;
1822 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
1823 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1825 vat_main_t *vam = &vat_main;
1826 i32 retval = ntohl (mp->retval);
1827 if (vam->async_mode)
1829 vam->async_errors += (retval < 0);
1833 vam->retval = retval;
1834 vam->sw_if_index = ntohl (mp->sw_if_index);
1835 vam->result_ready = 1;
1839 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
1840 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1842 vat_main_t *vam = &vat_main;
1843 vat_json_node_t node;
1845 vat_json_init_object (&node);
1846 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1847 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1849 vat_json_print (vam->ofp, &node);
1850 vat_json_free (&node);
1852 vam->retval = ntohl (mp->retval);
1853 vam->result_ready = 1;
1856 static void vl_api_gre_add_del_tunnel_reply_t_handler
1857 (vl_api_gre_add_del_tunnel_reply_t * mp)
1859 vat_main_t *vam = &vat_main;
1860 i32 retval = ntohl (mp->retval);
1861 if (vam->async_mode)
1863 vam->async_errors += (retval < 0);
1867 vam->retval = retval;
1868 vam->sw_if_index = ntohl (mp->sw_if_index);
1869 vam->result_ready = 1;
1873 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1874 (vl_api_gre_add_del_tunnel_reply_t * mp)
1876 vat_main_t *vam = &vat_main;
1877 vat_json_node_t node;
1879 vat_json_init_object (&node);
1880 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1881 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1883 vat_json_print (vam->ofp, &node);
1884 vat_json_free (&node);
1886 vam->retval = ntohl (mp->retval);
1887 vam->result_ready = 1;
1890 static void vl_api_create_vhost_user_if_reply_t_handler
1891 (vl_api_create_vhost_user_if_reply_t * mp)
1893 vat_main_t *vam = &vat_main;
1894 i32 retval = ntohl (mp->retval);
1895 if (vam->async_mode)
1897 vam->async_errors += (retval < 0);
1901 vam->retval = retval;
1902 vam->sw_if_index = ntohl (mp->sw_if_index);
1903 vam->result_ready = 1;
1907 static void vl_api_create_vhost_user_if_reply_t_handler_json
1908 (vl_api_create_vhost_user_if_reply_t * mp)
1910 vat_main_t *vam = &vat_main;
1911 vat_json_node_t node;
1913 vat_json_init_object (&node);
1914 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1915 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1917 vat_json_print (vam->ofp, &node);
1918 vat_json_free (&node);
1920 vam->retval = ntohl (mp->retval);
1921 vam->result_ready = 1;
1924 static void vl_api_ip_address_details_t_handler
1925 (vl_api_ip_address_details_t * mp)
1927 vat_main_t *vam = &vat_main;
1928 static ip_address_details_t empty_ip_address_details = { {0} };
1929 ip_address_details_t *address = NULL;
1930 ip_details_t *current_ip_details = NULL;
1931 ip_details_t *details = NULL;
1933 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1935 if (!details || vam->current_sw_if_index >= vec_len (details)
1936 || !details[vam->current_sw_if_index].present)
1938 errmsg ("ip address details arrived but not stored");
1939 errmsg ("ip_dump should be called first");
1943 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1945 #define addresses (current_ip_details->addr)
1947 vec_validate_init_empty (addresses, vec_len (addresses),
1948 empty_ip_address_details);
1950 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1952 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1953 address->prefix_length = mp->prefix_length;
1957 static void vl_api_ip_address_details_t_handler_json
1958 (vl_api_ip_address_details_t * mp)
1960 vat_main_t *vam = &vat_main;
1961 vat_json_node_t *node = NULL;
1962 struct in6_addr ip6;
1965 if (VAT_JSON_ARRAY != vam->json_tree.type)
1967 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1968 vat_json_init_array (&vam->json_tree);
1970 node = vat_json_array_add (&vam->json_tree);
1972 vat_json_init_object (node);
1975 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1976 vat_json_object_add_ip6 (node, "ip", ip6);
1980 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1981 vat_json_object_add_ip4 (node, "ip", ip4);
1983 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1987 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1989 vat_main_t *vam = &vat_main;
1990 static ip_details_t empty_ip_details = { 0 };
1991 ip_details_t *ip = NULL;
1992 u32 sw_if_index = ~0;
1994 sw_if_index = ntohl (mp->sw_if_index);
1996 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1997 sw_if_index, empty_ip_details);
1999 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2006 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2008 vat_main_t *vam = &vat_main;
2010 if (VAT_JSON_ARRAY != vam->json_tree.type)
2012 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2013 vat_json_init_array (&vam->json_tree);
2015 vat_json_array_add_uint (&vam->json_tree,
2016 clib_net_to_host_u32 (mp->sw_if_index));
2019 static void vl_api_map_domain_details_t_handler_json
2020 (vl_api_map_domain_details_t * mp)
2022 vat_json_node_t *node = NULL;
2023 vat_main_t *vam = &vat_main;
2024 struct in6_addr ip6;
2027 if (VAT_JSON_ARRAY != vam->json_tree.type)
2029 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2030 vat_json_init_array (&vam->json_tree);
2033 node = vat_json_array_add (&vam->json_tree);
2034 vat_json_init_object (node);
2036 vat_json_object_add_uint (node, "domain_index",
2037 clib_net_to_host_u32 (mp->domain_index));
2038 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2039 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2040 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2041 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2042 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2043 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2044 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2045 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2046 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2047 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2048 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2049 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2050 vat_json_object_add_uint (node, "flags", mp->flags);
2051 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2052 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2055 static void vl_api_map_domain_details_t_handler
2056 (vl_api_map_domain_details_t * mp)
2058 vat_main_t *vam = &vat_main;
2060 if (mp->is_translation)
2063 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2064 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2065 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2066 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2067 clib_net_to_host_u32 (mp->domain_index));
2072 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2073 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2074 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2075 format_ip6_address, mp->ip6_src,
2076 clib_net_to_host_u32 (mp->domain_index));
2078 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2079 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2080 mp->is_translation ? "map-t" : "");
2083 static void vl_api_map_rule_details_t_handler_json
2084 (vl_api_map_rule_details_t * mp)
2086 struct in6_addr ip6;
2087 vat_json_node_t *node = NULL;
2088 vat_main_t *vam = &vat_main;
2090 if (VAT_JSON_ARRAY != vam->json_tree.type)
2092 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2093 vat_json_init_array (&vam->json_tree);
2096 node = vat_json_array_add (&vam->json_tree);
2097 vat_json_init_object (node);
2099 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2100 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2101 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2105 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2107 vat_main_t *vam = &vat_main;
2108 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2109 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2113 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2115 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2116 "router_addr %U host_mac %U",
2117 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2118 format_ip4_address, &mp->host_address,
2119 format_ip4_address, &mp->router_address,
2120 format_ethernet_address, mp->host_mac);
2123 static void vl_api_dhcp_compl_event_t_handler_json
2124 (vl_api_dhcp_compl_event_t * mp)
2126 /* JSON output not supported */
2130 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2133 vat_main_t *vam = &vat_main;
2134 static u64 default_counter = 0;
2136 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2138 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2139 sw_if_index, default_counter);
2140 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2144 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2145 interface_counter_t counter)
2147 vat_main_t *vam = &vat_main;
2148 static interface_counter_t default_counter = { 0, };
2150 vec_validate_init_empty (vam->combined_interface_counters,
2151 vnet_counter_type, NULL);
2152 vec_validate_init_empty (vam->combined_interface_counters
2153 [vnet_counter_type], sw_if_index, default_counter);
2154 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2157 static void vl_api_vnet_interface_simple_counters_t_handler
2158 (vl_api_vnet_interface_simple_counters_t * mp)
2163 static void vl_api_vnet_interface_combined_counters_t_handler
2164 (vl_api_vnet_interface_combined_counters_t * mp)
2169 static void vl_api_vnet_interface_simple_counters_t_handler_json
2170 (vl_api_vnet_interface_simple_counters_t * mp)
2175 u32 first_sw_if_index;
2178 count = ntohl (mp->count);
2179 first_sw_if_index = ntohl (mp->first_sw_if_index);
2181 v_packets = (u64 *) & mp->data;
2182 for (i = 0; i < count; i++)
2184 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2185 set_simple_interface_counter (mp->vnet_counter_type,
2186 first_sw_if_index + i, packets);
2191 static void vl_api_vnet_interface_combined_counters_t_handler_json
2192 (vl_api_vnet_interface_combined_counters_t * mp)
2194 interface_counter_t counter;
2196 u32 first_sw_if_index;
2200 count = ntohl (mp->count);
2201 first_sw_if_index = ntohl (mp->first_sw_if_index);
2203 v = (vlib_counter_t *) & mp->data;
2204 for (i = 0; i < count; i++)
2207 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2209 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2210 set_combined_interface_counter (mp->vnet_counter_type,
2211 first_sw_if_index + i, counter);
2217 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2219 vat_main_t *vam = &vat_main;
2222 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2224 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2233 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2235 vat_main_t *vam = &vat_main;
2238 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2240 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2248 static void vl_api_vnet_ip4_fib_counters_t_handler
2249 (vl_api_vnet_ip4_fib_counters_t * mp)
2254 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2255 (vl_api_vnet_ip4_fib_counters_t * mp)
2257 vat_main_t *vam = &vat_main;
2258 vl_api_ip4_fib_counter_t *v;
2259 ip4_fib_counter_t *counter;
2266 vrf_id = ntohl (mp->vrf_id);
2267 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2268 if (~0 == vrf_index)
2270 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2271 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2272 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2273 vec_validate (vam->ip4_fib_counters, vrf_index);
2274 vam->ip4_fib_counters[vrf_index] = NULL;
2277 vec_free (vam->ip4_fib_counters[vrf_index]);
2278 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2279 count = ntohl (mp->count);
2280 for (i = 0; i < count; i++)
2282 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2283 counter = &vam->ip4_fib_counters[vrf_index][i];
2284 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2285 counter->address = ip4;
2286 counter->address_length = v->address_length;
2287 counter->packets = clib_net_to_host_u64 (v->packets);
2288 counter->bytes = clib_net_to_host_u64 (v->bytes);
2293 static void vl_api_vnet_ip4_nbr_counters_t_handler
2294 (vl_api_vnet_ip4_nbr_counters_t * mp)
2299 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2300 (vl_api_vnet_ip4_nbr_counters_t * mp)
2302 vat_main_t *vam = &vat_main;
2303 vl_api_ip4_nbr_counter_t *v;
2304 ip4_nbr_counter_t *counter;
2309 sw_if_index = ntohl (mp->sw_if_index);
2310 count = ntohl (mp->count);
2311 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2314 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2316 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2317 for (i = 0; i < count; i++)
2319 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2320 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2321 counter->address.s_addr = v->address;
2322 counter->packets = clib_net_to_host_u64 (v->packets);
2323 counter->bytes = clib_net_to_host_u64 (v->bytes);
2324 counter->linkt = v->link_type;
2329 static void vl_api_vnet_ip6_fib_counters_t_handler
2330 (vl_api_vnet_ip6_fib_counters_t * mp)
2335 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2336 (vl_api_vnet_ip6_fib_counters_t * mp)
2338 vat_main_t *vam = &vat_main;
2339 vl_api_ip6_fib_counter_t *v;
2340 ip6_fib_counter_t *counter;
2341 struct in6_addr ip6;
2347 vrf_id = ntohl (mp->vrf_id);
2348 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2349 if (~0 == vrf_index)
2351 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2352 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2353 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2354 vec_validate (vam->ip6_fib_counters, vrf_index);
2355 vam->ip6_fib_counters[vrf_index] = NULL;
2358 vec_free (vam->ip6_fib_counters[vrf_index]);
2359 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2360 count = ntohl (mp->count);
2361 for (i = 0; i < count; i++)
2363 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2364 counter = &vam->ip6_fib_counters[vrf_index][i];
2365 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2366 counter->address = ip6;
2367 counter->address_length = v->address_length;
2368 counter->packets = clib_net_to_host_u64 (v->packets);
2369 counter->bytes = clib_net_to_host_u64 (v->bytes);
2374 static void vl_api_vnet_ip6_nbr_counters_t_handler
2375 (vl_api_vnet_ip6_nbr_counters_t * mp)
2380 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2381 (vl_api_vnet_ip6_nbr_counters_t * mp)
2383 vat_main_t *vam = &vat_main;
2384 vl_api_ip6_nbr_counter_t *v;
2385 ip6_nbr_counter_t *counter;
2386 struct in6_addr ip6;
2391 sw_if_index = ntohl (mp->sw_if_index);
2392 count = ntohl (mp->count);
2393 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2396 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2398 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2399 for (i = 0; i < count; i++)
2401 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2402 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2403 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2404 counter->address = ip6;
2405 counter->packets = clib_net_to_host_u64 (v->packets);
2406 counter->bytes = clib_net_to_host_u64 (v->bytes);
2411 static void vl_api_get_first_msg_id_reply_t_handler
2412 (vl_api_get_first_msg_id_reply_t * mp)
2414 vat_main_t *vam = &vat_main;
2415 i32 retval = ntohl (mp->retval);
2417 if (vam->async_mode)
2419 vam->async_errors += (retval < 0);
2423 vam->retval = retval;
2424 vam->result_ready = 1;
2428 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2432 static void vl_api_get_first_msg_id_reply_t_handler_json
2433 (vl_api_get_first_msg_id_reply_t * mp)
2435 vat_main_t *vam = &vat_main;
2436 vat_json_node_t node;
2438 vat_json_init_object (&node);
2439 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2440 vat_json_object_add_uint (&node, "first_msg_id",
2441 (uint) ntohs (mp->first_msg_id));
2443 vat_json_print (vam->ofp, &node);
2444 vat_json_free (&node);
2446 vam->retval = ntohl (mp->retval);
2447 vam->result_ready = 1;
2450 static void vl_api_get_node_graph_reply_t_handler
2451 (vl_api_get_node_graph_reply_t * mp)
2453 vat_main_t *vam = &vat_main;
2454 api_main_t *am = &api_main;
2455 i32 retval = ntohl (mp->retval);
2456 u8 *pvt_copy, *reply;
2461 if (vam->async_mode)
2463 vam->async_errors += (retval < 0);
2467 vam->retval = retval;
2468 vam->result_ready = 1;
2471 /* "Should never happen..." */
2475 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2476 pvt_copy = vec_dup (reply);
2478 /* Toss the shared-memory original... */
2479 pthread_mutex_lock (&am->vlib_rp->mutex);
2480 oldheap = svm_push_data_heap (am->vlib_rp);
2484 svm_pop_heap (oldheap);
2485 pthread_mutex_unlock (&am->vlib_rp->mutex);
2487 if (vam->graph_nodes)
2489 hash_free (vam->graph_node_index_by_name);
2491 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2493 node = vam->graph_nodes[i];
2494 vec_free (node->name);
2495 vec_free (node->next_nodes);
2498 vec_free (vam->graph_nodes);
2501 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2502 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2503 vec_free (pvt_copy);
2505 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2507 node = vam->graph_nodes[i];
2508 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2512 static void vl_api_get_node_graph_reply_t_handler_json
2513 (vl_api_get_node_graph_reply_t * mp)
2515 vat_main_t *vam = &vat_main;
2516 api_main_t *am = &api_main;
2518 vat_json_node_t node;
2521 /* $$$$ make this real? */
2522 vat_json_init_object (&node);
2523 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2524 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2526 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2528 /* Toss the shared-memory original... */
2529 pthread_mutex_lock (&am->vlib_rp->mutex);
2530 oldheap = svm_push_data_heap (am->vlib_rp);
2534 svm_pop_heap (oldheap);
2535 pthread_mutex_unlock (&am->vlib_rp->mutex);
2537 vat_json_print (vam->ofp, &node);
2538 vat_json_free (&node);
2540 vam->retval = ntohl (mp->retval);
2541 vam->result_ready = 1;
2545 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2547 vat_main_t *vam = &vat_main;
2552 s = format (s, "%=16d%=16d%=16d",
2553 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2557 s = format (s, "%=16U%=16d%=16d",
2558 mp->is_ipv6 ? format_ip6_address :
2560 mp->ip_address, mp->priority, mp->weight);
2563 print (vam->ofp, "%v", s);
2568 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2570 vat_main_t *vam = &vat_main;
2571 vat_json_node_t *node = NULL;
2572 struct in6_addr ip6;
2575 if (VAT_JSON_ARRAY != vam->json_tree.type)
2577 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2578 vat_json_init_array (&vam->json_tree);
2580 node = vat_json_array_add (&vam->json_tree);
2581 vat_json_init_object (node);
2583 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2584 vat_json_object_add_uint (node, "priority", mp->priority);
2585 vat_json_object_add_uint (node, "weight", mp->weight);
2588 vat_json_object_add_uint (node, "sw_if_index",
2589 clib_net_to_host_u32 (mp->sw_if_index));
2594 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2595 vat_json_object_add_ip6 (node, "address", ip6);
2599 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2600 vat_json_object_add_ip4 (node, "address", ip4);
2606 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2609 vat_main_t *vam = &vat_main;
2612 ls_name = format (0, "%s", mp->ls_name);
2614 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2620 vl_api_one_locator_set_details_t_handler_json
2621 (vl_api_one_locator_set_details_t * mp)
2623 vat_main_t *vam = &vat_main;
2624 vat_json_node_t *node = 0;
2627 ls_name = format (0, "%s", mp->ls_name);
2628 vec_add1 (ls_name, 0);
2630 if (VAT_JSON_ARRAY != vam->json_tree.type)
2632 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2633 vat_json_init_array (&vam->json_tree);
2635 node = vat_json_array_add (&vam->json_tree);
2637 vat_json_init_object (node);
2638 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2639 vat_json_object_add_uint (node, "ls_index",
2640 clib_net_to_host_u32 (mp->ls_index));
2648 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2651 unformat_nsh_address (unformat_input_t * input, va_list * args)
2653 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2654 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2658 format_nsh_address_vat (u8 * s, va_list * args)
2660 nsh_t *a = va_arg (*args, nsh_t *);
2661 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2665 format_lisp_flat_eid (u8 * s, va_list * args)
2667 u32 type = va_arg (*args, u32);
2668 u8 *eid = va_arg (*args, u8 *);
2669 u32 eid_len = va_arg (*args, u32);
2674 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2676 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2678 return format (s, "%U", format_ethernet_address, eid);
2680 return format (s, "%U", format_nsh_address_vat, eid);
2686 format_lisp_eid_vat (u8 * s, va_list * args)
2688 u32 type = va_arg (*args, u32);
2689 u8 *eid = va_arg (*args, u8 *);
2690 u32 eid_len = va_arg (*args, u32);
2691 u8 *seid = va_arg (*args, u8 *);
2692 u32 seid_len = va_arg (*args, u32);
2693 u32 is_src_dst = va_arg (*args, u32);
2696 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2698 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2704 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2706 vat_main_t *vam = &vat_main;
2707 u8 *s = 0, *eid = 0;
2709 if (~0 == mp->locator_set_index)
2710 s = format (0, "action: %d", mp->action);
2712 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2714 eid = format (0, "%U", format_lisp_eid_vat,
2718 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2721 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2722 clib_net_to_host_u32 (mp->vni),
2724 mp->is_local ? "local" : "remote",
2725 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2726 clib_net_to_host_u16 (mp->key_id), mp->key);
2733 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2736 vat_main_t *vam = &vat_main;
2737 vat_json_node_t *node = 0;
2740 if (VAT_JSON_ARRAY != vam->json_tree.type)
2742 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2743 vat_json_init_array (&vam->json_tree);
2745 node = vat_json_array_add (&vam->json_tree);
2747 vat_json_init_object (node);
2748 if (~0 == mp->locator_set_index)
2749 vat_json_object_add_uint (node, "action", mp->action);
2751 vat_json_object_add_uint (node, "locator_set_index",
2752 clib_net_to_host_u32 (mp->locator_set_index));
2754 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2755 if (mp->eid_type == 3)
2757 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
2758 vat_json_init_object (nsh_json);
2759 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
2760 vat_json_object_add_uint (nsh_json, "spi",
2761 clib_net_to_host_u32 (nsh->spi));
2762 vat_json_object_add_uint (nsh_json, "si", nsh->si);
2766 eid = format (0, "%U", format_lisp_eid_vat,
2770 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2772 vat_json_object_add_string_copy (node, "eid", eid);
2775 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2776 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2777 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2781 vat_json_object_add_uint (node, "key_id",
2782 clib_net_to_host_u16 (mp->key_id));
2783 vat_json_object_add_string_copy (node, "key", mp->key);
2788 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
2790 vat_main_t *vam = &vat_main;
2791 u8 *seid = 0, *deid = 0;
2792 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2794 deid = format (0, "%U", format_lisp_eid_vat,
2795 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2797 seid = format (0, "%U", format_lisp_eid_vat,
2798 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2804 format_ip_address_fcn = format_ip4_address;
2806 format_ip_address_fcn = format_ip6_address;
2809 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
2810 clib_net_to_host_u32 (mp->vni),
2812 format_ip_address_fcn, mp->lloc,
2813 format_ip_address_fcn, mp->rloc,
2814 clib_net_to_host_u32 (mp->pkt_count),
2815 clib_net_to_host_u32 (mp->bytes));
2822 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
2824 struct in6_addr ip6;
2826 vat_main_t *vam = &vat_main;
2827 vat_json_node_t *node = 0;
2828 u8 *deid = 0, *seid = 0;
2830 if (VAT_JSON_ARRAY != vam->json_tree.type)
2832 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2833 vat_json_init_array (&vam->json_tree);
2835 node = vat_json_array_add (&vam->json_tree);
2837 vat_json_init_object (node);
2838 deid = format (0, "%U", format_lisp_eid_vat,
2839 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2841 seid = format (0, "%U", format_lisp_eid_vat,
2842 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2847 vat_json_object_add_string_copy (node, "seid", seid);
2848 vat_json_object_add_string_copy (node, "deid", deid);
2849 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2853 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
2854 vat_json_object_add_ip4 (node, "lloc", ip4);
2855 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
2856 vat_json_object_add_ip4 (node, "rloc", ip4);
2860 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
2861 vat_json_object_add_ip6 (node, "lloc", ip6);
2862 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
2863 vat_json_object_add_ip6 (node, "rloc", ip6);
2865 vat_json_object_add_uint (node, "pkt_count",
2866 clib_net_to_host_u32 (mp->pkt_count));
2867 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
2874 vl_api_one_eid_table_map_details_t_handler
2875 (vl_api_one_eid_table_map_details_t * mp)
2877 vat_main_t *vam = &vat_main;
2879 u8 *line = format (0, "%=10d%=10d",
2880 clib_net_to_host_u32 (mp->vni),
2881 clib_net_to_host_u32 (mp->dp_table));
2882 print (vam->ofp, "%v", line);
2887 vl_api_one_eid_table_map_details_t_handler_json
2888 (vl_api_one_eid_table_map_details_t * mp)
2890 vat_main_t *vam = &vat_main;
2891 vat_json_node_t *node = NULL;
2893 if (VAT_JSON_ARRAY != vam->json_tree.type)
2895 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2896 vat_json_init_array (&vam->json_tree);
2898 node = vat_json_array_add (&vam->json_tree);
2899 vat_json_init_object (node);
2900 vat_json_object_add_uint (node, "dp_table",
2901 clib_net_to_host_u32 (mp->dp_table));
2902 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2906 vl_api_one_eid_table_vni_details_t_handler
2907 (vl_api_one_eid_table_vni_details_t * mp)
2909 vat_main_t *vam = &vat_main;
2911 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2912 print (vam->ofp, "%v", line);
2917 vl_api_one_eid_table_vni_details_t_handler_json
2918 (vl_api_one_eid_table_vni_details_t * mp)
2920 vat_main_t *vam = &vat_main;
2921 vat_json_node_t *node = NULL;
2923 if (VAT_JSON_ARRAY != vam->json_tree.type)
2925 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2926 vat_json_init_array (&vam->json_tree);
2928 node = vat_json_array_add (&vam->json_tree);
2929 vat_json_init_object (node);
2930 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2934 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
2935 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
2937 vat_main_t *vam = &vat_main;
2938 int retval = clib_net_to_host_u32 (mp->retval);
2940 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
2941 print (vam->ofp, "fallback threshold value: %d", mp->value);
2943 vam->retval = retval;
2944 vam->result_ready = 1;
2948 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
2949 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
2951 vat_main_t *vam = &vat_main;
2952 vat_json_node_t _node, *node = &_node;
2953 int retval = clib_net_to_host_u32 (mp->retval);
2955 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
2956 vat_json_init_object (node);
2957 vat_json_object_add_uint (node, "value", mp->value);
2959 vat_json_print (vam->ofp, node);
2960 vat_json_free (node);
2962 vam->retval = retval;
2963 vam->result_ready = 1;
2967 vl_api_show_one_map_register_state_reply_t_handler
2968 (vl_api_show_one_map_register_state_reply_t * mp)
2970 vat_main_t *vam = &vat_main;
2971 int retval = clib_net_to_host_u32 (mp->retval);
2973 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2975 vam->retval = retval;
2976 vam->result_ready = 1;
2980 vl_api_show_one_map_register_state_reply_t_handler_json
2981 (vl_api_show_one_map_register_state_reply_t * mp)
2983 vat_main_t *vam = &vat_main;
2984 vat_json_node_t _node, *node = &_node;
2985 int retval = clib_net_to_host_u32 (mp->retval);
2987 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2989 vat_json_init_object (node);
2990 vat_json_object_add_string_copy (node, "state", s);
2992 vat_json_print (vam->ofp, node);
2993 vat_json_free (node);
2995 vam->retval = retval;
2996 vam->result_ready = 1;
3001 vl_api_show_one_rloc_probe_state_reply_t_handler
3002 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3004 vat_main_t *vam = &vat_main;
3005 int retval = clib_net_to_host_u32 (mp->retval);
3010 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3012 vam->retval = retval;
3013 vam->result_ready = 1;
3017 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3018 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3020 vat_main_t *vam = &vat_main;
3021 vat_json_node_t _node, *node = &_node;
3022 int retval = clib_net_to_host_u32 (mp->retval);
3024 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3025 vat_json_init_object (node);
3026 vat_json_object_add_string_copy (node, "state", s);
3028 vat_json_print (vam->ofp, node);
3029 vat_json_free (node);
3031 vam->retval = retval;
3032 vam->result_ready = 1;
3037 vl_api_show_one_stats_enable_disable_reply_t_handler
3038 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3040 vat_main_t *vam = &vat_main;
3041 int retval = clib_net_to_host_u32 (mp->retval);
3046 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3048 vam->retval = retval;
3049 vam->result_ready = 1;
3053 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3054 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3056 vat_main_t *vam = &vat_main;
3057 vat_json_node_t _node, *node = &_node;
3058 int retval = clib_net_to_host_u32 (mp->retval);
3060 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3061 vat_json_init_object (node);
3062 vat_json_object_add_string_copy (node, "state", s);
3064 vat_json_print (vam->ofp, node);
3065 vat_json_free (node);
3067 vam->retval = retval;
3068 vam->result_ready = 1;
3073 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3075 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3076 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3077 e->vni = clib_net_to_host_u32 (e->vni);
3081 gpe_fwd_entries_get_reply_t_net_to_host
3082 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3086 mp->count = clib_net_to_host_u32 (mp->count);
3087 for (i = 0; i < mp->count; i++)
3089 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3094 format_gpe_encap_mode (u8 * s, va_list * args)
3096 u32 mode = va_arg (*args, u32);
3101 return format (s, "lisp");
3103 return format (s, "vxlan");
3109 vl_api_gpe_get_encap_mode_reply_t_handler
3110 (vl_api_gpe_get_encap_mode_reply_t * mp)
3112 vat_main_t *vam = &vat_main;
3114 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3115 vam->retval = ntohl (mp->retval);
3116 vam->result_ready = 1;
3120 vl_api_gpe_get_encap_mode_reply_t_handler_json
3121 (vl_api_gpe_get_encap_mode_reply_t * mp)
3123 vat_main_t *vam = &vat_main;
3124 vat_json_node_t node;
3126 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3127 vec_add1 (encap_mode, 0);
3129 vat_json_init_object (&node);
3130 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3132 vec_free (encap_mode);
3133 vat_json_print (vam->ofp, &node);
3134 vat_json_free (&node);
3136 vam->retval = ntohl (mp->retval);
3137 vam->result_ready = 1;
3141 vl_api_gpe_fwd_entry_path_details_t_handler
3142 (vl_api_gpe_fwd_entry_path_details_t * mp)
3144 vat_main_t *vam = &vat_main;
3145 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3147 if (mp->lcl_loc.is_ip4)
3148 format_ip_address_fcn = format_ip4_address;
3150 format_ip_address_fcn = format_ip6_address;
3152 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3153 format_ip_address_fcn, &mp->lcl_loc,
3154 format_ip_address_fcn, &mp->rmt_loc);
3158 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3160 struct in6_addr ip6;
3165 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3166 vat_json_object_add_ip4 (n, "address", ip4);
3170 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3171 vat_json_object_add_ip6 (n, "address", ip6);
3173 vat_json_object_add_uint (n, "weight", loc->weight);
3177 vl_api_gpe_fwd_entry_path_details_t_handler_json
3178 (vl_api_gpe_fwd_entry_path_details_t * mp)
3180 vat_main_t *vam = &vat_main;
3181 vat_json_node_t *node = NULL;
3182 vat_json_node_t *loc_node;
3184 if (VAT_JSON_ARRAY != vam->json_tree.type)
3186 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3187 vat_json_init_array (&vam->json_tree);
3189 node = vat_json_array_add (&vam->json_tree);
3190 vat_json_init_object (node);
3192 loc_node = vat_json_object_add (node, "local_locator");
3193 vat_json_init_object (loc_node);
3194 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3196 loc_node = vat_json_object_add (node, "remote_locator");
3197 vat_json_init_object (loc_node);
3198 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3202 vl_api_gpe_fwd_entries_get_reply_t_handler
3203 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3205 vat_main_t *vam = &vat_main;
3207 int retval = clib_net_to_host_u32 (mp->retval);
3208 vl_api_gpe_fwd_entry_t *e;
3213 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3215 for (i = 0; i < mp->count; i++)
3217 e = &mp->entries[i];
3218 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3219 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3220 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3224 vam->retval = retval;
3225 vam->result_ready = 1;
3229 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3230 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3233 vat_main_t *vam = &vat_main;
3234 vat_json_node_t *e = 0, root;
3236 int retval = clib_net_to_host_u32 (mp->retval);
3237 vl_api_gpe_fwd_entry_t *fwd;
3242 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3243 vat_json_init_array (&root);
3245 for (i = 0; i < mp->count; i++)
3247 e = vat_json_array_add (&root);
3248 fwd = &mp->entries[i];
3250 vat_json_init_object (e);
3251 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3252 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3253 vat_json_object_add_int (e, "vni", fwd->vni);
3254 vat_json_object_add_int (e, "action", fwd->action);
3256 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3257 fwd->leid_prefix_len);
3259 vat_json_object_add_string_copy (e, "leid", s);
3262 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3263 fwd->reid_prefix_len);
3265 vat_json_object_add_string_copy (e, "reid", s);
3269 vat_json_print (vam->ofp, &root);
3270 vat_json_free (&root);
3273 vam->retval = retval;
3274 vam->result_ready = 1;
3278 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3279 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3281 vat_main_t *vam = &vat_main;
3283 int retval = clib_net_to_host_u32 (mp->retval);
3284 vl_api_gpe_native_fwd_rpath_t *r;
3289 n = clib_net_to_host_u32 (mp->count);
3291 for (i = 0; i < n; i++)
3293 r = &mp->entries[i];
3294 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3295 clib_net_to_host_u32 (r->fib_index),
3296 clib_net_to_host_u32 (r->nh_sw_if_index),
3297 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3301 vam->retval = retval;
3302 vam->result_ready = 1;
3306 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3307 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3309 vat_main_t *vam = &vat_main;
3310 vat_json_node_t root, *e;
3312 int retval = clib_net_to_host_u32 (mp->retval);
3313 vl_api_gpe_native_fwd_rpath_t *r;
3319 n = clib_net_to_host_u32 (mp->count);
3320 vat_json_init_array (&root);
3322 for (i = 0; i < n; i++)
3324 e = vat_json_array_add (&root);
3325 vat_json_init_object (e);
3326 r = &mp->entries[i];
3328 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3331 vat_json_object_add_string_copy (e, "ip4", s);
3334 vat_json_object_add_uint (e, "fib_index",
3335 clib_net_to_host_u32 (r->fib_index));
3336 vat_json_object_add_uint (e, "nh_sw_if_index",
3337 clib_net_to_host_u32 (r->nh_sw_if_index));
3340 vat_json_print (vam->ofp, &root);
3341 vat_json_free (&root);
3344 vam->retval = retval;
3345 vam->result_ready = 1;
3349 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3350 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3352 vat_main_t *vam = &vat_main;
3354 int retval = clib_net_to_host_u32 (mp->retval);
3359 n = clib_net_to_host_u32 (mp->count);
3361 for (i = 0; i < n; i++)
3362 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3365 vam->retval = retval;
3366 vam->result_ready = 1;
3370 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3371 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3373 vat_main_t *vam = &vat_main;
3374 vat_json_node_t root;
3376 int retval = clib_net_to_host_u32 (mp->retval);
3381 n = clib_net_to_host_u32 (mp->count);
3382 vat_json_init_array (&root);
3384 for (i = 0; i < n; i++)
3385 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3387 vat_json_print (vam->ofp, &root);
3388 vat_json_free (&root);
3391 vam->retval = retval;
3392 vam->result_ready = 1;
3396 vl_api_one_l2_arp_entries_get_reply_t_handler
3397 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3399 vat_main_t *vam = &vat_main;
3401 int retval = clib_net_to_host_u32 (mp->retval);
3406 n = clib_net_to_host_u32 (mp->count);
3408 for (i = 0; i < n; i++)
3409 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3410 format_ethernet_address, mp->entries[i].mac);
3413 vam->retval = retval;
3414 vam->result_ready = 1;
3418 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3419 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3422 vat_main_t *vam = &vat_main;
3423 vat_json_node_t *e = 0, root;
3425 int retval = clib_net_to_host_u32 (mp->retval);
3426 vl_api_one_l2_arp_entry_t *arp_entry;
3431 n = clib_net_to_host_u32 (mp->count);
3432 vat_json_init_array (&root);
3434 for (i = 0; i < n; i++)
3436 e = vat_json_array_add (&root);
3437 arp_entry = &mp->entries[i];
3439 vat_json_init_object (e);
3440 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3443 vat_json_object_add_string_copy (e, "mac", s);
3446 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3448 vat_json_object_add_string_copy (e, "ip4", s);
3452 vat_json_print (vam->ofp, &root);
3453 vat_json_free (&root);
3456 vam->retval = retval;
3457 vam->result_ready = 1;
3461 vl_api_one_l2_arp_bd_get_reply_t_handler
3462 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3464 vat_main_t *vam = &vat_main;
3466 int retval = clib_net_to_host_u32 (mp->retval);
3471 n = clib_net_to_host_u32 (mp->count);
3473 for (i = 0; i < n; i++)
3475 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3479 vam->retval = retval;
3480 vam->result_ready = 1;
3484 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3485 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3487 vat_main_t *vam = &vat_main;
3488 vat_json_node_t root;
3490 int retval = clib_net_to_host_u32 (mp->retval);
3495 n = clib_net_to_host_u32 (mp->count);
3496 vat_json_init_array (&root);
3498 for (i = 0; i < n; i++)
3500 vat_json_array_add_uint (&root,
3501 clib_net_to_host_u32 (mp->bridge_domains[i]));
3504 vat_json_print (vam->ofp, &root);
3505 vat_json_free (&root);
3508 vam->retval = retval;
3509 vam->result_ready = 1;
3513 vl_api_one_adjacencies_get_reply_t_handler
3514 (vl_api_one_adjacencies_get_reply_t * mp)
3516 vat_main_t *vam = &vat_main;
3518 int retval = clib_net_to_host_u32 (mp->retval);
3519 vl_api_one_adjacency_t *a;
3524 n = clib_net_to_host_u32 (mp->count);
3526 for (i = 0; i < n; i++)
3528 a = &mp->adjacencies[i];
3529 print (vam->ofp, "%U %40U",
3530 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3531 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3535 vam->retval = retval;
3536 vam->result_ready = 1;
3540 vl_api_one_adjacencies_get_reply_t_handler_json
3541 (vl_api_one_adjacencies_get_reply_t * mp)
3544 vat_main_t *vam = &vat_main;
3545 vat_json_node_t *e = 0, root;
3547 int retval = clib_net_to_host_u32 (mp->retval);
3548 vl_api_one_adjacency_t *a;
3553 n = clib_net_to_host_u32 (mp->count);
3554 vat_json_init_array (&root);
3556 for (i = 0; i < n; i++)
3558 e = vat_json_array_add (&root);
3559 a = &mp->adjacencies[i];
3561 vat_json_init_object (e);
3562 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3563 a->leid_prefix_len);
3565 vat_json_object_add_string_copy (e, "leid", s);
3568 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3569 a->reid_prefix_len);
3571 vat_json_object_add_string_copy (e, "reid", s);
3575 vat_json_print (vam->ofp, &root);
3576 vat_json_free (&root);
3579 vam->retval = retval;
3580 vam->result_ready = 1;
3584 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3586 vat_main_t *vam = &vat_main;
3588 print (vam->ofp, "%=20U",
3589 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3594 vl_api_one_map_server_details_t_handler_json
3595 (vl_api_one_map_server_details_t * mp)
3597 vat_main_t *vam = &vat_main;
3598 vat_json_node_t *node = NULL;
3599 struct in6_addr ip6;
3602 if (VAT_JSON_ARRAY != vam->json_tree.type)
3604 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3605 vat_json_init_array (&vam->json_tree);
3607 node = vat_json_array_add (&vam->json_tree);
3609 vat_json_init_object (node);
3612 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3613 vat_json_object_add_ip6 (node, "map-server", ip6);
3617 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3618 vat_json_object_add_ip4 (node, "map-server", ip4);
3623 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3626 vat_main_t *vam = &vat_main;
3628 print (vam->ofp, "%=20U",
3629 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3634 vl_api_one_map_resolver_details_t_handler_json
3635 (vl_api_one_map_resolver_details_t * mp)
3637 vat_main_t *vam = &vat_main;
3638 vat_json_node_t *node = NULL;
3639 struct in6_addr ip6;
3642 if (VAT_JSON_ARRAY != vam->json_tree.type)
3644 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3645 vat_json_init_array (&vam->json_tree);
3647 node = vat_json_array_add (&vam->json_tree);
3649 vat_json_init_object (node);
3652 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3653 vat_json_object_add_ip6 (node, "map resolver", ip6);
3657 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3658 vat_json_object_add_ip4 (node, "map resolver", ip4);
3663 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3665 vat_main_t *vam = &vat_main;
3666 i32 retval = ntohl (mp->retval);
3670 print (vam->ofp, "feature: %s\ngpe: %s",
3671 mp->feature_status ? "enabled" : "disabled",
3672 mp->gpe_status ? "enabled" : "disabled");
3675 vam->retval = retval;
3676 vam->result_ready = 1;
3680 vl_api_show_one_status_reply_t_handler_json
3681 (vl_api_show_one_status_reply_t * mp)
3683 vat_main_t *vam = &vat_main;
3684 vat_json_node_t node;
3685 u8 *gpe_status = NULL;
3686 u8 *feature_status = NULL;
3688 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3689 feature_status = format (0, "%s",
3690 mp->feature_status ? "enabled" : "disabled");
3691 vec_add1 (gpe_status, 0);
3692 vec_add1 (feature_status, 0);
3694 vat_json_init_object (&node);
3695 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3696 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3698 vec_free (gpe_status);
3699 vec_free (feature_status);
3701 vat_json_print (vam->ofp, &node);
3702 vat_json_free (&node);
3704 vam->retval = ntohl (mp->retval);
3705 vam->result_ready = 1;
3709 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3710 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3712 vat_main_t *vam = &vat_main;
3713 i32 retval = ntohl (mp->retval);
3717 print (vam->ofp, "%=20s", mp->locator_set_name);
3720 vam->retval = retval;
3721 vam->result_ready = 1;
3725 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3726 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3728 vat_main_t *vam = &vat_main;
3729 vat_json_node_t *node = NULL;
3731 if (VAT_JSON_ARRAY != vam->json_tree.type)
3733 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3734 vat_json_init_array (&vam->json_tree);
3736 node = vat_json_array_add (&vam->json_tree);
3738 vat_json_init_object (node);
3739 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3741 vat_json_print (vam->ofp, node);
3742 vat_json_free (node);
3744 vam->retval = ntohl (mp->retval);
3745 vam->result_ready = 1;
3749 format_lisp_map_request_mode (u8 * s, va_list * args)
3751 u32 mode = va_arg (*args, u32);
3756 return format (0, "dst-only");
3758 return format (0, "src-dst");
3764 vl_api_show_one_map_request_mode_reply_t_handler
3765 (vl_api_show_one_map_request_mode_reply_t * mp)
3767 vat_main_t *vam = &vat_main;
3768 i32 retval = ntohl (mp->retval);
3772 u32 mode = mp->mode;
3773 print (vam->ofp, "map_request_mode: %U",
3774 format_lisp_map_request_mode, mode);
3777 vam->retval = retval;
3778 vam->result_ready = 1;
3782 vl_api_show_one_map_request_mode_reply_t_handler_json
3783 (vl_api_show_one_map_request_mode_reply_t * mp)
3785 vat_main_t *vam = &vat_main;
3786 vat_json_node_t node;
3791 s = format (0, "%U", format_lisp_map_request_mode, mode);
3794 vat_json_init_object (&node);
3795 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3796 vat_json_print (vam->ofp, &node);
3797 vat_json_free (&node);
3800 vam->retval = ntohl (mp->retval);
3801 vam->result_ready = 1;
3805 vl_api_show_one_use_petr_reply_t_handler
3806 (vl_api_show_one_use_petr_reply_t * mp)
3808 vat_main_t *vam = &vat_main;
3809 i32 retval = ntohl (mp->retval);
3813 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
3816 print (vam->ofp, "Proxy-ETR address; %U",
3817 mp->is_ip4 ? format_ip4_address : format_ip6_address,
3822 vam->retval = retval;
3823 vam->result_ready = 1;
3827 vl_api_show_one_use_petr_reply_t_handler_json
3828 (vl_api_show_one_use_petr_reply_t * mp)
3830 vat_main_t *vam = &vat_main;
3831 vat_json_node_t node;
3834 struct in6_addr ip6;
3836 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3837 vec_add1 (status, 0);
3839 vat_json_init_object (&node);
3840 vat_json_object_add_string_copy (&node, "status", status);
3845 clib_memcpy (&ip6, mp->address, sizeof (ip6));
3846 vat_json_object_add_ip6 (&node, "address", ip6);
3850 clib_memcpy (&ip4, mp->address, sizeof (ip4));
3851 vat_json_object_add_ip4 (&node, "address", ip4);
3857 vat_json_print (vam->ofp, &node);
3858 vat_json_free (&node);
3860 vam->retval = ntohl (mp->retval);
3861 vam->result_ready = 1;
3865 vl_api_show_one_nsh_mapping_reply_t_handler
3866 (vl_api_show_one_nsh_mapping_reply_t * mp)
3868 vat_main_t *vam = &vat_main;
3869 i32 retval = ntohl (mp->retval);
3873 print (vam->ofp, "%-20s%-16s",
3874 mp->is_set ? "set" : "not-set",
3875 mp->is_set ? (char *) mp->locator_set_name : "");
3878 vam->retval = retval;
3879 vam->result_ready = 1;
3883 vl_api_show_one_nsh_mapping_reply_t_handler_json
3884 (vl_api_show_one_nsh_mapping_reply_t * mp)
3886 vat_main_t *vam = &vat_main;
3887 vat_json_node_t node;
3890 status = format (0, "%s", mp->is_set ? "yes" : "no");
3891 vec_add1 (status, 0);
3893 vat_json_init_object (&node);
3894 vat_json_object_add_string_copy (&node, "is_set", status);
3897 vat_json_object_add_string_copy (&node, "locator_set",
3898 mp->locator_set_name);
3903 vat_json_print (vam->ofp, &node);
3904 vat_json_free (&node);
3906 vam->retval = ntohl (mp->retval);
3907 vam->result_ready = 1;
3911 vl_api_show_one_map_register_ttl_reply_t_handler
3912 (vl_api_show_one_map_register_ttl_reply_t * mp)
3914 vat_main_t *vam = &vat_main;
3915 i32 retval = ntohl (mp->retval);
3917 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
3921 print (vam->ofp, "ttl: %u", mp->ttl);
3924 vam->retval = retval;
3925 vam->result_ready = 1;
3929 vl_api_show_one_map_register_ttl_reply_t_handler_json
3930 (vl_api_show_one_map_register_ttl_reply_t * mp)
3932 vat_main_t *vam = &vat_main;
3933 vat_json_node_t node;
3935 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
3936 vat_json_init_object (&node);
3937 vat_json_object_add_uint (&node, "ttl", mp->ttl);
3939 vat_json_print (vam->ofp, &node);
3940 vat_json_free (&node);
3942 vam->retval = ntohl (mp->retval);
3943 vam->result_ready = 1;
3947 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3949 vat_main_t *vam = &vat_main;
3950 i32 retval = ntohl (mp->retval);
3954 print (vam->ofp, "%-20s%-16s",
3955 mp->status ? "enabled" : "disabled",
3956 mp->status ? (char *) mp->locator_set_name : "");
3959 vam->retval = retval;
3960 vam->result_ready = 1;
3964 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3966 vat_main_t *vam = &vat_main;
3967 vat_json_node_t node;
3970 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3971 vec_add1 (status, 0);
3973 vat_json_init_object (&node);
3974 vat_json_object_add_string_copy (&node, "status", status);
3977 vat_json_object_add_string_copy (&node, "locator_set",
3978 mp->locator_set_name);
3983 vat_json_print (vam->ofp, &node);
3984 vat_json_free (&node);
3986 vam->retval = ntohl (mp->retval);
3987 vam->result_ready = 1;
3991 format_policer_type (u8 * s, va_list * va)
3993 u32 i = va_arg (*va, u32);
3995 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3996 s = format (s, "1r2c");
3997 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3998 s = format (s, "1r3c");
3999 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4000 s = format (s, "2r3c-2698");
4001 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4002 s = format (s, "2r3c-4115");
4003 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4004 s = format (s, "2r3c-mef5cf1");
4006 s = format (s, "ILLEGAL");
4011 format_policer_rate_type (u8 * s, va_list * va)
4013 u32 i = va_arg (*va, u32);
4015 if (i == SSE2_QOS_RATE_KBPS)
4016 s = format (s, "kbps");
4017 else if (i == SSE2_QOS_RATE_PPS)
4018 s = format (s, "pps");
4020 s = format (s, "ILLEGAL");
4025 format_policer_round_type (u8 * s, va_list * va)
4027 u32 i = va_arg (*va, u32);
4029 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4030 s = format (s, "closest");
4031 else if (i == SSE2_QOS_ROUND_TO_UP)
4032 s = format (s, "up");
4033 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4034 s = format (s, "down");
4036 s = format (s, "ILLEGAL");
4041 format_policer_action_type (u8 * s, va_list * va)
4043 u32 i = va_arg (*va, u32);
4045 if (i == SSE2_QOS_ACTION_DROP)
4046 s = format (s, "drop");
4047 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4048 s = format (s, "transmit");
4049 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4050 s = format (s, "mark-and-transmit");
4052 s = format (s, "ILLEGAL");
4057 format_dscp (u8 * s, va_list * va)
4059 u32 i = va_arg (*va, u32);
4064 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4068 return format (s, "ILLEGAL");
4070 s = format (s, "%s", t);
4075 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4077 vat_main_t *vam = &vat_main;
4078 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4080 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4081 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4083 conform_dscp_str = format (0, "");
4085 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4086 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4088 exceed_dscp_str = format (0, "");
4090 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4091 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4093 violate_dscp_str = format (0, "");
4095 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4096 "rate type %U, round type %U, %s rate, %s color-aware, "
4097 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4098 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4099 "conform action %U%s, exceed action %U%s, violate action %U%s",
4101 format_policer_type, mp->type,
4104 clib_net_to_host_u64 (mp->cb),
4105 clib_net_to_host_u64 (mp->eb),
4106 format_policer_rate_type, mp->rate_type,
4107 format_policer_round_type, mp->round_type,
4108 mp->single_rate ? "single" : "dual",
4109 mp->color_aware ? "is" : "not",
4110 ntohl (mp->cir_tokens_per_period),
4111 ntohl (mp->pir_tokens_per_period),
4113 ntohl (mp->current_limit),
4114 ntohl (mp->current_bucket),
4115 ntohl (mp->extended_limit),
4116 ntohl (mp->extended_bucket),
4117 clib_net_to_host_u64 (mp->last_update_time),
4118 format_policer_action_type, mp->conform_action_type,
4120 format_policer_action_type, mp->exceed_action_type,
4122 format_policer_action_type, mp->violate_action_type,
4125 vec_free (conform_dscp_str);
4126 vec_free (exceed_dscp_str);
4127 vec_free (violate_dscp_str);
4130 static void vl_api_policer_details_t_handler_json
4131 (vl_api_policer_details_t * mp)
4133 vat_main_t *vam = &vat_main;
4134 vat_json_node_t *node;
4135 u8 *rate_type_str, *round_type_str, *type_str;
4136 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4138 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4140 format (0, "%U", format_policer_round_type, mp->round_type);
4141 type_str = format (0, "%U", format_policer_type, mp->type);
4142 conform_action_str = format (0, "%U", format_policer_action_type,
4143 mp->conform_action_type);
4144 exceed_action_str = format (0, "%U", format_policer_action_type,
4145 mp->exceed_action_type);
4146 violate_action_str = format (0, "%U", format_policer_action_type,
4147 mp->violate_action_type);
4149 if (VAT_JSON_ARRAY != vam->json_tree.type)
4151 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4152 vat_json_init_array (&vam->json_tree);
4154 node = vat_json_array_add (&vam->json_tree);
4156 vat_json_init_object (node);
4157 vat_json_object_add_string_copy (node, "name", mp->name);
4158 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4159 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4160 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4161 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4162 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4163 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4164 vat_json_object_add_string_copy (node, "type", type_str);
4165 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4166 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4167 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4168 vat_json_object_add_uint (node, "cir_tokens_per_period",
4169 ntohl (mp->cir_tokens_per_period));
4170 vat_json_object_add_uint (node, "eir_tokens_per_period",
4171 ntohl (mp->pir_tokens_per_period));
4172 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4173 vat_json_object_add_uint (node, "current_bucket",
4174 ntohl (mp->current_bucket));
4175 vat_json_object_add_uint (node, "extended_limit",
4176 ntohl (mp->extended_limit));
4177 vat_json_object_add_uint (node, "extended_bucket",
4178 ntohl (mp->extended_bucket));
4179 vat_json_object_add_uint (node, "last_update_time",
4180 ntohl (mp->last_update_time));
4181 vat_json_object_add_string_copy (node, "conform_action",
4182 conform_action_str);
4183 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4185 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4186 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4187 vec_free (dscp_str);
4189 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4190 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4192 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4193 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4194 vec_free (dscp_str);
4196 vat_json_object_add_string_copy (node, "violate_action",
4197 violate_action_str);
4198 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4200 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4201 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4202 vec_free (dscp_str);
4205 vec_free (rate_type_str);
4206 vec_free (round_type_str);
4207 vec_free (type_str);
4208 vec_free (conform_action_str);
4209 vec_free (exceed_action_str);
4210 vec_free (violate_action_str);
4214 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4217 vat_main_t *vam = &vat_main;
4218 int i, count = ntohl (mp->count);
4221 print (vam->ofp, "classify table ids (%d) : ", count);
4222 for (i = 0; i < count; i++)
4224 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4225 print (vam->ofp, (i < count - 1) ? "," : "");
4227 vam->retval = ntohl (mp->retval);
4228 vam->result_ready = 1;
4232 vl_api_classify_table_ids_reply_t_handler_json
4233 (vl_api_classify_table_ids_reply_t * mp)
4235 vat_main_t *vam = &vat_main;
4236 int i, count = ntohl (mp->count);
4240 vat_json_node_t node;
4242 vat_json_init_object (&node);
4243 for (i = 0; i < count; i++)
4245 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4247 vat_json_print (vam->ofp, &node);
4248 vat_json_free (&node);
4250 vam->retval = ntohl (mp->retval);
4251 vam->result_ready = 1;
4255 vl_api_classify_table_by_interface_reply_t_handler
4256 (vl_api_classify_table_by_interface_reply_t * mp)
4258 vat_main_t *vam = &vat_main;
4261 table_id = ntohl (mp->l2_table_id);
4263 print (vam->ofp, "l2 table id : %d", table_id);
4265 print (vam->ofp, "l2 table id : No input ACL tables configured");
4266 table_id = ntohl (mp->ip4_table_id);
4268 print (vam->ofp, "ip4 table id : %d", table_id);
4270 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4271 table_id = ntohl (mp->ip6_table_id);
4273 print (vam->ofp, "ip6 table id : %d", table_id);
4275 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4276 vam->retval = ntohl (mp->retval);
4277 vam->result_ready = 1;
4281 vl_api_classify_table_by_interface_reply_t_handler_json
4282 (vl_api_classify_table_by_interface_reply_t * mp)
4284 vat_main_t *vam = &vat_main;
4285 vat_json_node_t node;
4287 vat_json_init_object (&node);
4289 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4290 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4291 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4293 vat_json_print (vam->ofp, &node);
4294 vat_json_free (&node);
4296 vam->retval = ntohl (mp->retval);
4297 vam->result_ready = 1;
4300 static void vl_api_policer_add_del_reply_t_handler
4301 (vl_api_policer_add_del_reply_t * mp)
4303 vat_main_t *vam = &vat_main;
4304 i32 retval = ntohl (mp->retval);
4305 if (vam->async_mode)
4307 vam->async_errors += (retval < 0);
4311 vam->retval = retval;
4312 vam->result_ready = 1;
4313 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4315 * Note: this is just barely thread-safe, depends on
4316 * the main thread spinning waiting for an answer...
4318 errmsg ("policer index %d", ntohl (mp->policer_index));
4322 static void vl_api_policer_add_del_reply_t_handler_json
4323 (vl_api_policer_add_del_reply_t * mp)
4325 vat_main_t *vam = &vat_main;
4326 vat_json_node_t node;
4328 vat_json_init_object (&node);
4329 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4330 vat_json_object_add_uint (&node, "policer_index",
4331 ntohl (mp->policer_index));
4333 vat_json_print (vam->ofp, &node);
4334 vat_json_free (&node);
4336 vam->retval = ntohl (mp->retval);
4337 vam->result_ready = 1;
4340 /* Format hex dump. */
4342 format_hex_bytes (u8 * s, va_list * va)
4344 u8 *bytes = va_arg (*va, u8 *);
4345 int n_bytes = va_arg (*va, int);
4348 /* Print short or long form depending on byte count. */
4349 uword short_form = n_bytes <= 32;
4350 uword indent = format_get_indent (s);
4355 for (i = 0; i < n_bytes; i++)
4357 if (!short_form && (i % 32) == 0)
4358 s = format (s, "%08x: ", i);
4359 s = format (s, "%02x", bytes[i]);
4360 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4361 s = format (s, "\n%U", format_white_space, indent);
4368 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4371 vat_main_t *vam = &vat_main;
4372 i32 retval = ntohl (mp->retval);
4375 print (vam->ofp, "classify table info :");
4376 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4377 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4378 ntohl (mp->miss_next_index));
4379 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4380 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4381 ntohl (mp->match_n_vectors));
4382 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4383 ntohl (mp->mask_length));
4385 vam->retval = retval;
4386 vam->result_ready = 1;
4390 vl_api_classify_table_info_reply_t_handler_json
4391 (vl_api_classify_table_info_reply_t * mp)
4393 vat_main_t *vam = &vat_main;
4394 vat_json_node_t node;
4396 i32 retval = ntohl (mp->retval);
4399 vat_json_init_object (&node);
4401 vat_json_object_add_int (&node, "sessions",
4402 ntohl (mp->active_sessions));
4403 vat_json_object_add_int (&node, "nexttbl",
4404 ntohl (mp->next_table_index));
4405 vat_json_object_add_int (&node, "nextnode",
4406 ntohl (mp->miss_next_index));
4407 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4408 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4409 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4410 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4411 ntohl (mp->mask_length), 0);
4412 vat_json_object_add_string_copy (&node, "mask", s);
4414 vat_json_print (vam->ofp, &node);
4415 vat_json_free (&node);
4417 vam->retval = ntohl (mp->retval);
4418 vam->result_ready = 1;
4422 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4425 vat_main_t *vam = &vat_main;
4427 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4428 ntohl (mp->hit_next_index), ntohl (mp->advance),
4429 ntohl (mp->opaque_index));
4430 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4431 ntohl (mp->match_length));
4435 vl_api_classify_session_details_t_handler_json
4436 (vl_api_classify_session_details_t * mp)
4438 vat_main_t *vam = &vat_main;
4439 vat_json_node_t *node = NULL;
4441 if (VAT_JSON_ARRAY != vam->json_tree.type)
4443 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4444 vat_json_init_array (&vam->json_tree);
4446 node = vat_json_array_add (&vam->json_tree);
4448 vat_json_init_object (node);
4449 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4450 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4451 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4453 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4455 vat_json_object_add_string_copy (node, "match", s);
4458 static void vl_api_pg_create_interface_reply_t_handler
4459 (vl_api_pg_create_interface_reply_t * mp)
4461 vat_main_t *vam = &vat_main;
4463 vam->retval = ntohl (mp->retval);
4464 vam->result_ready = 1;
4467 static void vl_api_pg_create_interface_reply_t_handler_json
4468 (vl_api_pg_create_interface_reply_t * mp)
4470 vat_main_t *vam = &vat_main;
4471 vat_json_node_t node;
4473 i32 retval = ntohl (mp->retval);
4476 vat_json_init_object (&node);
4478 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4480 vat_json_print (vam->ofp, &node);
4481 vat_json_free (&node);
4483 vam->retval = ntohl (mp->retval);
4484 vam->result_ready = 1;
4487 static void vl_api_policer_classify_details_t_handler
4488 (vl_api_policer_classify_details_t * mp)
4490 vat_main_t *vam = &vat_main;
4492 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4493 ntohl (mp->table_index));
4496 static void vl_api_policer_classify_details_t_handler_json
4497 (vl_api_policer_classify_details_t * mp)
4499 vat_main_t *vam = &vat_main;
4500 vat_json_node_t *node;
4502 if (VAT_JSON_ARRAY != vam->json_tree.type)
4504 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4505 vat_json_init_array (&vam->json_tree);
4507 node = vat_json_array_add (&vam->json_tree);
4509 vat_json_init_object (node);
4510 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4511 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4514 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4515 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4517 vat_main_t *vam = &vat_main;
4518 i32 retval = ntohl (mp->retval);
4519 if (vam->async_mode)
4521 vam->async_errors += (retval < 0);
4525 vam->retval = retval;
4526 vam->sw_if_index = ntohl (mp->sw_if_index);
4527 vam->result_ready = 1;
4531 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4532 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4534 vat_main_t *vam = &vat_main;
4535 vat_json_node_t node;
4537 vat_json_init_object (&node);
4538 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4539 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4541 vat_json_print (vam->ofp, &node);
4542 vat_json_free (&node);
4544 vam->retval = ntohl (mp->retval);
4545 vam->result_ready = 1;
4548 static void vl_api_flow_classify_details_t_handler
4549 (vl_api_flow_classify_details_t * mp)
4551 vat_main_t *vam = &vat_main;
4553 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4554 ntohl (mp->table_index));
4557 static void vl_api_flow_classify_details_t_handler_json
4558 (vl_api_flow_classify_details_t * mp)
4560 vat_main_t *vam = &vat_main;
4561 vat_json_node_t *node;
4563 if (VAT_JSON_ARRAY != vam->json_tree.type)
4565 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4566 vat_json_init_array (&vam->json_tree);
4568 node = vat_json_array_add (&vam->json_tree);
4570 vat_json_init_object (node);
4571 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4572 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4575 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
4576 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
4577 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
4578 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
4579 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4580 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4581 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4582 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4583 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4584 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4585 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4586 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4587 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4588 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4589 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
4590 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
4591 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
4592 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
4595 * Generate boilerplate reply handlers, which
4596 * dig the return value out of the xxx_reply_t API message,
4597 * stick it into vam->retval, and set vam->result_ready
4599 * Could also do this by pointing N message decode slots at
4600 * a single function, but that could break in subtle ways.
4603 #define foreach_standard_reply_retval_handler \
4604 _(sw_interface_set_flags_reply) \
4605 _(sw_interface_add_del_address_reply) \
4606 _(sw_interface_set_table_reply) \
4607 _(sw_interface_set_mpls_enable_reply) \
4608 _(sw_interface_set_vpath_reply) \
4609 _(sw_interface_set_vxlan_bypass_reply) \
4610 _(sw_interface_set_vxlan_gpe_bypass_reply) \
4611 _(sw_interface_set_l2_bridge_reply) \
4612 _(bridge_domain_add_del_reply) \
4613 _(sw_interface_set_l2_xconnect_reply) \
4614 _(l2fib_add_del_reply) \
4615 _(l2fib_flush_int_reply) \
4616 _(l2fib_flush_bd_reply) \
4617 _(ip_add_del_route_reply) \
4618 _(ip_mroute_add_del_reply) \
4619 _(mpls_route_add_del_reply) \
4620 _(mpls_ip_bind_unbind_reply) \
4621 _(proxy_arp_add_del_reply) \
4622 _(proxy_arp_intfc_enable_disable_reply) \
4623 _(sw_interface_set_unnumbered_reply) \
4624 _(ip_neighbor_add_del_reply) \
4625 _(reset_vrf_reply) \
4626 _(oam_add_del_reply) \
4627 _(reset_fib_reply) \
4628 _(dhcp_proxy_config_reply) \
4629 _(dhcp_proxy_set_vss_reply) \
4630 _(dhcp_client_config_reply) \
4631 _(set_ip_flow_hash_reply) \
4632 _(sw_interface_ip6_enable_disable_reply) \
4633 _(sw_interface_ip6_set_link_local_address_reply) \
4634 _(ip6nd_proxy_add_del_reply) \
4635 _(sw_interface_ip6nd_ra_prefix_reply) \
4636 _(sw_interface_ip6nd_ra_config_reply) \
4637 _(set_arp_neighbor_limit_reply) \
4638 _(l2_patch_add_del_reply) \
4639 _(sr_policy_add_reply) \
4640 _(sr_policy_mod_reply) \
4641 _(sr_policy_del_reply) \
4642 _(sr_localsid_add_del_reply) \
4643 _(sr_steering_add_del_reply) \
4644 _(classify_add_del_session_reply) \
4645 _(classify_set_interface_ip_table_reply) \
4646 _(classify_set_interface_l2_tables_reply) \
4647 _(l2tpv3_set_tunnel_cookies_reply) \
4648 _(l2tpv3_interface_enable_disable_reply) \
4649 _(l2tpv3_set_lookup_key_reply) \
4650 _(l2_fib_clear_table_reply) \
4651 _(l2_interface_efp_filter_reply) \
4652 _(l2_interface_vlan_tag_rewrite_reply) \
4653 _(modify_vhost_user_if_reply) \
4654 _(delete_vhost_user_if_reply) \
4655 _(want_ip4_arp_events_reply) \
4656 _(want_ip6_nd_events_reply) \
4657 _(want_l2_macs_events_reply) \
4658 _(input_acl_set_interface_reply) \
4659 _(ipsec_spd_add_del_reply) \
4660 _(ipsec_interface_add_del_spd_reply) \
4661 _(ipsec_spd_add_del_entry_reply) \
4662 _(ipsec_sad_add_del_entry_reply) \
4663 _(ipsec_sa_set_key_reply) \
4664 _(ipsec_tunnel_if_add_del_reply) \
4665 _(ikev2_profile_add_del_reply) \
4666 _(ikev2_profile_set_auth_reply) \
4667 _(ikev2_profile_set_id_reply) \
4668 _(ikev2_profile_set_ts_reply) \
4669 _(ikev2_set_local_key_reply) \
4670 _(ikev2_set_responder_reply) \
4671 _(ikev2_set_ike_transforms_reply) \
4672 _(ikev2_set_esp_transforms_reply) \
4673 _(ikev2_set_sa_lifetime_reply) \
4674 _(ikev2_initiate_sa_init_reply) \
4675 _(ikev2_initiate_del_ike_sa_reply) \
4676 _(ikev2_initiate_del_child_sa_reply) \
4677 _(ikev2_initiate_rekey_child_sa_reply) \
4678 _(delete_loopback_reply) \
4679 _(bd_ip_mac_add_del_reply) \
4680 _(map_del_domain_reply) \
4681 _(map_add_del_rule_reply) \
4682 _(want_interface_events_reply) \
4683 _(want_stats_reply) \
4684 _(cop_interface_enable_disable_reply) \
4685 _(cop_whitelist_enable_disable_reply) \
4686 _(sw_interface_clear_stats_reply) \
4687 _(ioam_enable_reply) \
4688 _(ioam_disable_reply) \
4689 _(one_add_del_locator_reply) \
4690 _(one_add_del_local_eid_reply) \
4691 _(one_add_del_remote_mapping_reply) \
4692 _(one_add_del_adjacency_reply) \
4693 _(one_add_del_map_resolver_reply) \
4694 _(one_add_del_map_server_reply) \
4695 _(one_enable_disable_reply) \
4696 _(one_rloc_probe_enable_disable_reply) \
4697 _(one_map_register_enable_disable_reply) \
4698 _(one_map_register_set_ttl_reply) \
4699 _(one_map_register_fallback_threshold_reply) \
4700 _(one_pitr_set_locator_set_reply) \
4701 _(one_map_request_mode_reply) \
4702 _(one_add_del_map_request_itr_rlocs_reply) \
4703 _(one_eid_table_add_del_map_reply) \
4704 _(one_use_petr_reply) \
4705 _(one_stats_enable_disable_reply) \
4706 _(one_add_del_l2_arp_entry_reply) \
4707 _(one_stats_flush_reply) \
4708 _(gpe_enable_disable_reply) \
4709 _(gpe_set_encap_mode_reply) \
4710 _(gpe_add_del_iface_reply) \
4711 _(gpe_add_del_native_fwd_rpath_reply) \
4712 _(af_packet_delete_reply) \
4713 _(policer_classify_set_interface_reply) \
4714 _(netmap_create_reply) \
4715 _(netmap_delete_reply) \
4716 _(set_ipfix_exporter_reply) \
4717 _(set_ipfix_classify_stream_reply) \
4718 _(ipfix_classify_table_add_del_reply) \
4719 _(flow_classify_set_interface_reply) \
4720 _(sw_interface_span_enable_disable_reply) \
4721 _(pg_capture_reply) \
4722 _(pg_enable_disable_reply) \
4723 _(ip_source_and_port_range_check_add_del_reply) \
4724 _(ip_source_and_port_range_check_interface_add_del_reply)\
4725 _(delete_subif_reply) \
4726 _(l2_interface_pbb_tag_rewrite_reply) \
4728 _(feature_enable_disable_reply) \
4729 _(sw_interface_tag_add_del_reply) \
4730 _(sw_interface_set_mtu_reply) \
4731 _(p2p_ethernet_add_reply) \
4732 _(p2p_ethernet_del_reply) \
4733 _(lldp_config_reply) \
4734 _(sw_interface_set_lldp_reply)
4737 static void vl_api_##n##_t_handler \
4738 (vl_api_##n##_t * mp) \
4740 vat_main_t * vam = &vat_main; \
4741 i32 retval = ntohl(mp->retval); \
4742 if (vam->async_mode) { \
4743 vam->async_errors += (retval < 0); \
4745 vam->retval = retval; \
4746 vam->result_ready = 1; \
4749 foreach_standard_reply_retval_handler;
4753 static void vl_api_##n##_t_handler_json \
4754 (vl_api_##n##_t * mp) \
4756 vat_main_t * vam = &vat_main; \
4757 vat_json_node_t node; \
4758 vat_json_init_object(&node); \
4759 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4760 vat_json_print(vam->ofp, &node); \
4761 vam->retval = ntohl(mp->retval); \
4762 vam->result_ready = 1; \
4764 foreach_standard_reply_retval_handler;
4768 * Table of message reply handlers, must include boilerplate handlers
4772 #define foreach_vpe_api_reply_msg \
4773 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4774 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4775 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4776 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4777 _(CONTROL_PING_REPLY, control_ping_reply) \
4778 _(CLI_REPLY, cli_reply) \
4779 _(CLI_INBAND_REPLY, cli_inband_reply) \
4780 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4781 sw_interface_add_del_address_reply) \
4782 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4783 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4784 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4785 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4786 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
4787 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4788 sw_interface_set_l2_xconnect_reply) \
4789 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4790 sw_interface_set_l2_bridge_reply) \
4791 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4792 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4793 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
4794 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4795 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
4796 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
4797 _(L2_FLAGS_REPLY, l2_flags_reply) \
4798 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4799 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4800 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4801 _(TAP_DELETE_REPLY, tap_delete_reply) \
4802 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4803 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4804 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4805 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4806 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4807 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4808 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4809 proxy_arp_intfc_enable_disable_reply) \
4810 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4811 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4812 sw_interface_set_unnumbered_reply) \
4813 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4814 _(RESET_VRF_REPLY, reset_vrf_reply) \
4815 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4816 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4817 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4818 _(RESET_FIB_REPLY, reset_fib_reply) \
4819 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4820 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4821 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4822 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4823 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4824 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4825 sw_interface_ip6_enable_disable_reply) \
4826 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4827 sw_interface_ip6_set_link_local_address_reply) \
4828 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
4829 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
4830 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4831 sw_interface_ip6nd_ra_prefix_reply) \
4832 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4833 sw_interface_ip6nd_ra_config_reply) \
4834 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4835 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4836 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4837 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4838 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4839 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4840 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4841 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4842 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4843 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4844 classify_set_interface_ip_table_reply) \
4845 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4846 classify_set_interface_l2_tables_reply) \
4847 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4848 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4849 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4850 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4851 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4852 l2tpv3_interface_enable_disable_reply) \
4853 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4854 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4855 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4856 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4857 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4858 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4859 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4860 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4861 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4862 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4863 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4864 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4865 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4866 _(SHOW_VERSION_REPLY, show_version_reply) \
4867 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
4868 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4869 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4870 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4871 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4872 _(IP4_ARP_EVENT, ip4_arp_event) \
4873 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4874 _(IP6_ND_EVENT, ip6_nd_event) \
4875 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
4876 _(L2_MACS_EVENT, l2_macs_event) \
4877 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4878 _(IP_ADDRESS_DETAILS, ip_address_details) \
4879 _(IP_DETAILS, ip_details) \
4880 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4881 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4882 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4883 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4884 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4885 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
4886 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4887 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4888 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4889 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4890 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4891 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4892 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4893 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4894 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4895 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4896 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4897 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4898 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4899 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4900 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4901 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4902 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4903 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4904 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4905 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4906 _(MAP_RULE_DETAILS, map_rule_details) \
4907 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4908 _(WANT_STATS_REPLY, want_stats_reply) \
4909 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4910 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4911 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4912 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4913 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4914 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4915 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4916 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4917 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4918 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4919 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4920 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4921 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4922 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4923 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4924 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4925 one_map_register_enable_disable_reply) \
4926 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
4927 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
4928 one_map_register_fallback_threshold_reply) \
4929 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4930 one_rloc_probe_enable_disable_reply) \
4931 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4932 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
4933 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4934 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4935 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4936 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4937 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4938 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4939 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4940 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4941 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4942 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4943 _(ONE_STATS_DETAILS, one_stats_details) \
4944 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
4945 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
4946 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
4947 show_one_stats_enable_disable_reply) \
4948 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
4949 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
4950 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
4951 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4952 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4953 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4954 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4955 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4956 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
4957 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4958 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
4959 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
4960 gpe_add_del_native_fwd_rpath_reply) \
4961 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4962 gpe_fwd_entry_path_details) \
4963 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4964 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4965 one_add_del_map_request_itr_rlocs_reply) \
4966 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4967 one_get_map_request_itr_rlocs_reply) \
4968 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
4969 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4970 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
4971 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4972 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4973 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4974 show_one_map_register_state_reply) \
4975 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
4976 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
4977 show_one_map_register_fallback_threshold_reply) \
4978 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4979 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4980 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4981 _(POLICER_DETAILS, policer_details) \
4982 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4983 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4984 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4985 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4986 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4987 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4988 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4989 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4990 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4991 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4992 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4993 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4994 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4995 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4996 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4997 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4998 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4999 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5000 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5001 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5002 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5003 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5004 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5005 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5006 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5007 ip_source_and_port_range_check_add_del_reply) \
5008 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5009 ip_source_and_port_range_check_interface_add_del_reply) \
5010 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5011 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5012 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5013 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5014 _(PUNT_REPLY, punt_reply) \
5015 _(IP_FIB_DETAILS, ip_fib_details) \
5016 _(IP6_FIB_DETAILS, ip6_fib_details) \
5017 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5018 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5019 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5020 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5021 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5022 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5023 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5024 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5025 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5026 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply)
5028 #define foreach_standalone_reply_msg \
5029 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
5030 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5031 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5032 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5033 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5034 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5035 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5044 #define STR_VTR_OP_CASE(op) \
5045 case L2_VTR_ ## op: \
5049 str_vtr_op (u32 vtr_op)
5053 STR_VTR_OP_CASE (DISABLED);
5054 STR_VTR_OP_CASE (PUSH_1);
5055 STR_VTR_OP_CASE (PUSH_2);
5056 STR_VTR_OP_CASE (POP_1);
5057 STR_VTR_OP_CASE (POP_2);
5058 STR_VTR_OP_CASE (TRANSLATE_1_1);
5059 STR_VTR_OP_CASE (TRANSLATE_1_2);
5060 STR_VTR_OP_CASE (TRANSLATE_2_1);
5061 STR_VTR_OP_CASE (TRANSLATE_2_2);
5068 dump_sub_interface_table (vat_main_t * vam)
5070 const sw_interface_subif_t *sub = NULL;
5072 if (vam->json_output)
5075 ("JSON output supported only for VPE API calls and dump_stats_table");
5080 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5081 "Interface", "sw_if_index",
5082 "sub id", "dot1ad", "tags", "outer id",
5083 "inner id", "exact", "default", "outer any", "inner any");
5085 vec_foreach (sub, vam->sw_if_subif_table)
5088 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5089 sub->interface_name,
5091 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5092 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5093 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5094 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5095 if (sub->vtr_op != L2_VTR_DISABLED)
5098 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5099 "tag1: %d tag2: %d ]",
5100 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5101 sub->vtr_tag1, sub->vtr_tag2);
5109 name_sort_cmp (void *a1, void *a2)
5111 name_sort_t *n1 = a1;
5112 name_sort_t *n2 = a2;
5114 return strcmp ((char *) n1->name, (char *) n2->name);
5118 dump_interface_table (vat_main_t * vam)
5121 name_sort_t *nses = 0, *ns;
5123 if (vam->json_output)
5126 ("JSON output supported only for VPE API calls and dump_stats_table");
5131 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5133 vec_add2 (nses, ns, 1);
5134 ns->name = (u8 *)(p->key);
5135 ns->value = (u32) p->value[0];
5139 vec_sort_with_function (nses, name_sort_cmp);
5141 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5142 vec_foreach (ns, nses)
5144 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5151 dump_ip_table (vat_main_t * vam, int is_ipv6)
5153 const ip_details_t *det = NULL;
5154 const ip_address_details_t *address = NULL;
5157 print (vam->ofp, "%-12s", "sw_if_index");
5159 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5166 print (vam->ofp, "%-12d", i);
5167 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5172 vec_foreach (address, det->addr)
5176 is_ipv6 ? format_ip6_address : format_ip4_address,
5177 address->ip, address->prefix_length);
5185 dump_ipv4_table (vat_main_t * vam)
5187 if (vam->json_output)
5190 ("JSON output supported only for VPE API calls and dump_stats_table");
5194 return dump_ip_table (vam, 0);
5198 dump_ipv6_table (vat_main_t * vam)
5200 if (vam->json_output)
5203 ("JSON output supported only for VPE API calls and dump_stats_table");
5207 return dump_ip_table (vam, 1);
5211 counter_type_to_str (u8 counter_type, u8 is_combined)
5215 switch (counter_type)
5217 case VNET_INTERFACE_COUNTER_DROP:
5219 case VNET_INTERFACE_COUNTER_PUNT:
5221 case VNET_INTERFACE_COUNTER_IP4:
5223 case VNET_INTERFACE_COUNTER_IP6:
5225 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5227 case VNET_INTERFACE_COUNTER_RX_MISS:
5229 case VNET_INTERFACE_COUNTER_RX_ERROR:
5231 case VNET_INTERFACE_COUNTER_TX_ERROR:
5234 return "INVALID-COUNTER-TYPE";
5239 switch (counter_type)
5241 case VNET_INTERFACE_COUNTER_RX:
5243 case VNET_INTERFACE_COUNTER_TX:
5246 return "INVALID-COUNTER-TYPE";
5252 dump_stats_table (vat_main_t * vam)
5254 vat_json_node_t node;
5255 vat_json_node_t *msg_array;
5256 vat_json_node_t *msg;
5257 vat_json_node_t *counter_array;
5258 vat_json_node_t *counter;
5259 interface_counter_t c;
5261 ip4_fib_counter_t *c4;
5262 ip6_fib_counter_t *c6;
5263 ip4_nbr_counter_t *n4;
5264 ip6_nbr_counter_t *n6;
5267 if (!vam->json_output)
5269 clib_warning ("dump_stats_table supported only in JSON format");
5273 vat_json_init_object (&node);
5275 /* interface counters */
5276 msg_array = vat_json_object_add (&node, "interface_counters");
5277 vat_json_init_array (msg_array);
5278 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5280 msg = vat_json_array_add (msg_array);
5281 vat_json_init_object (msg);
5282 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5283 (u8 *) counter_type_to_str (i, 0));
5284 vat_json_object_add_int (msg, "is_combined", 0);
5285 counter_array = vat_json_object_add (msg, "data");
5286 vat_json_init_array (counter_array);
5287 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5289 packets = vam->simple_interface_counters[i][j];
5290 vat_json_array_add_uint (counter_array, packets);
5293 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5295 msg = vat_json_array_add (msg_array);
5296 vat_json_init_object (msg);
5297 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5298 (u8 *) counter_type_to_str (i, 1));
5299 vat_json_object_add_int (msg, "is_combined", 1);
5300 counter_array = vat_json_object_add (msg, "data");
5301 vat_json_init_array (counter_array);
5302 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5304 c = vam->combined_interface_counters[i][j];
5305 counter = vat_json_array_add (counter_array);
5306 vat_json_init_object (counter);
5307 vat_json_object_add_uint (counter, "packets", c.packets);
5308 vat_json_object_add_uint (counter, "bytes", c.bytes);
5312 /* ip4 fib counters */
5313 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5314 vat_json_init_array (msg_array);
5315 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5317 msg = vat_json_array_add (msg_array);
5318 vat_json_init_object (msg);
5319 vat_json_object_add_uint (msg, "vrf_id",
5320 vam->ip4_fib_counters_vrf_id_by_index[i]);
5321 counter_array = vat_json_object_add (msg, "c");
5322 vat_json_init_array (counter_array);
5323 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5325 counter = vat_json_array_add (counter_array);
5326 vat_json_init_object (counter);
5327 c4 = &vam->ip4_fib_counters[i][j];
5328 vat_json_object_add_ip4 (counter, "address", c4->address);
5329 vat_json_object_add_uint (counter, "address_length",
5330 c4->address_length);
5331 vat_json_object_add_uint (counter, "packets", c4->packets);
5332 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5336 /* ip6 fib counters */
5337 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5338 vat_json_init_array (msg_array);
5339 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5341 msg = vat_json_array_add (msg_array);
5342 vat_json_init_object (msg);
5343 vat_json_object_add_uint (msg, "vrf_id",
5344 vam->ip6_fib_counters_vrf_id_by_index[i]);
5345 counter_array = vat_json_object_add (msg, "c");
5346 vat_json_init_array (counter_array);
5347 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5349 counter = vat_json_array_add (counter_array);
5350 vat_json_init_object (counter);
5351 c6 = &vam->ip6_fib_counters[i][j];
5352 vat_json_object_add_ip6 (counter, "address", c6->address);
5353 vat_json_object_add_uint (counter, "address_length",
5354 c6->address_length);
5355 vat_json_object_add_uint (counter, "packets", c6->packets);
5356 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5360 /* ip4 nbr counters */
5361 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5362 vat_json_init_array (msg_array);
5363 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5365 msg = vat_json_array_add (msg_array);
5366 vat_json_init_object (msg);
5367 vat_json_object_add_uint (msg, "sw_if_index", i);
5368 counter_array = vat_json_object_add (msg, "c");
5369 vat_json_init_array (counter_array);
5370 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5372 counter = vat_json_array_add (counter_array);
5373 vat_json_init_object (counter);
5374 n4 = &vam->ip4_nbr_counters[i][j];
5375 vat_json_object_add_ip4 (counter, "address", n4->address);
5376 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5377 vat_json_object_add_uint (counter, "packets", n4->packets);
5378 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5382 /* ip6 nbr counters */
5383 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5384 vat_json_init_array (msg_array);
5385 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5387 msg = vat_json_array_add (msg_array);
5388 vat_json_init_object (msg);
5389 vat_json_object_add_uint (msg, "sw_if_index", i);
5390 counter_array = vat_json_object_add (msg, "c");
5391 vat_json_init_array (counter_array);
5392 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5394 counter = vat_json_array_add (counter_array);
5395 vat_json_init_object (counter);
5396 n6 = &vam->ip6_nbr_counters[i][j];
5397 vat_json_object_add_ip6 (counter, "address", n6->address);
5398 vat_json_object_add_uint (counter, "packets", n6->packets);
5399 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5403 vat_json_print (vam->ofp, &node);
5404 vat_json_free (&node);
5410 exec (vat_main_t * vam)
5412 api_main_t *am = &api_main;
5417 unformat_input_t *i = vam->input;
5419 if (vec_len (i->buffer) == 0)
5422 if (vam->exec_mode == 0 && unformat (i, "mode"))
5427 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5437 * Copy cmd into shared memory.
5438 * In order for the CLI command to work, it
5439 * must be a vector ending in \n, not a C-string ending
5442 pthread_mutex_lock (&am->vlib_rp->mutex);
5443 oldheap = svm_push_data_heap (am->vlib_rp);
5445 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
5446 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
5448 svm_pop_heap (oldheap);
5449 pthread_mutex_unlock (&am->vlib_rp->mutex);
5451 mp->cmd_in_shmem = pointer_to_uword (cmd);
5453 timeout = vat_time_now (vam) + 10.0;
5455 while (vat_time_now (vam) < timeout)
5457 if (vam->result_ready == 1)
5460 if (vam->shmem_result != NULL)
5461 print (vam->ofp, "%s", vam->shmem_result);
5462 pthread_mutex_lock (&am->vlib_rp->mutex);
5463 oldheap = svm_push_data_heap (am->vlib_rp);
5465 free_me = (u8 *) vam->shmem_result;
5468 svm_pop_heap (oldheap);
5469 pthread_mutex_unlock (&am->vlib_rp->mutex);
5477 * Future replacement of exec() that passes CLI buffers directly in
5478 * the API messages instead of an additional shared memory area.
5481 exec_inband (vat_main_t * vam)
5483 vl_api_cli_inband_t *mp;
5484 unformat_input_t *i = vam->input;
5487 if (vec_len (i->buffer) == 0)
5490 if (vam->exec_mode == 0 && unformat (i, "mode"))
5495 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5502 * In order for the CLI command to work, it
5503 * must be a vector ending in \n, not a C-string ending
5506 u32 len = vec_len (vam->input->buffer);
5507 M2 (CLI_INBAND, mp, len);
5508 clib_memcpy (mp->cmd, vam->input->buffer, len);
5509 mp->length = htonl (len);
5512 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
5517 api_create_loopback (vat_main_t * vam)
5519 unformat_input_t *i = vam->input;
5520 vl_api_create_loopback_t *mp;
5521 vl_api_create_loopback_instance_t *mp_lbi;
5524 u8 is_specified = 0;
5525 u32 user_instance = 0;
5528 memset (mac_address, 0, sizeof (mac_address));
5530 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5532 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5534 if (unformat (i, "instance %d", &user_instance))
5542 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5543 mp_lbi->is_specified = is_specified;
5545 mp_lbi->user_instance = htonl (user_instance);
5547 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5552 /* Construct the API message */
5553 M (CREATE_LOOPBACK, mp);
5555 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5564 api_delete_loopback (vat_main_t * vam)
5566 unformat_input_t *i = vam->input;
5567 vl_api_delete_loopback_t *mp;
5568 u32 sw_if_index = ~0;
5571 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5573 if (unformat (i, "sw_if_index %d", &sw_if_index))
5579 if (sw_if_index == ~0)
5581 errmsg ("missing sw_if_index");
5585 /* Construct the API message */
5586 M (DELETE_LOOPBACK, mp);
5587 mp->sw_if_index = ntohl (sw_if_index);
5595 api_want_stats (vat_main_t * vam)
5597 unformat_input_t *i = vam->input;
5598 vl_api_want_stats_t *mp;
5602 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5604 if (unformat (i, "enable"))
5606 else if (unformat (i, "disable"))
5614 errmsg ("missing enable|disable");
5619 mp->enable_disable = enable;
5627 api_want_interface_events (vat_main_t * vam)
5629 unformat_input_t *i = vam->input;
5630 vl_api_want_interface_events_t *mp;
5634 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5636 if (unformat (i, "enable"))
5638 else if (unformat (i, "disable"))
5646 errmsg ("missing enable|disable");
5650 M (WANT_INTERFACE_EVENTS, mp);
5651 mp->enable_disable = enable;
5653 vam->interface_event_display = enable;
5661 /* Note: non-static, called once to set up the initial intfc table */
5663 api_sw_interface_dump (vat_main_t * vam)
5665 vl_api_sw_interface_dump_t *mp;
5666 vl_api_control_ping_t *mp_ping;
5668 name_sort_t *nses = 0, *ns;
5669 sw_interface_subif_t *sub = NULL;
5672 /* Toss the old name table */
5674 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5676 vec_add2 (nses, ns, 1);
5677 ns->name = (u8 *)(p->key);
5678 ns->value = (u32) p->value[0];
5682 hash_free (vam->sw_if_index_by_interface_name);
5684 vec_foreach (ns, nses) vec_free (ns->name);
5688 vec_foreach (sub, vam->sw_if_subif_table)
5690 vec_free (sub->interface_name);
5692 vec_free (vam->sw_if_subif_table);
5694 /* recreate the interface name hash table */
5695 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5697 /* Get list of ethernets */
5698 M (SW_INTERFACE_DUMP, mp);
5699 mp->name_filter_valid = 1;
5700 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
5703 /* and local / loopback interfaces */
5704 M (SW_INTERFACE_DUMP, mp);
5705 mp->name_filter_valid = 1;
5706 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
5709 /* and packet-generator interfaces */
5710 M (SW_INTERFACE_DUMP, mp);
5711 mp->name_filter_valid = 1;
5712 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
5715 /* and vxlan-gpe tunnel interfaces */
5716 M (SW_INTERFACE_DUMP, mp);
5717 mp->name_filter_valid = 1;
5718 strncpy ((char *) mp->name_filter, "vxlan_gpe",
5719 sizeof (mp->name_filter) - 1);
5722 /* and vxlan tunnel interfaces */
5723 M (SW_INTERFACE_DUMP, mp);
5724 mp->name_filter_valid = 1;
5725 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
5728 /* and host (af_packet) interfaces */
5729 M (SW_INTERFACE_DUMP, mp);
5730 mp->name_filter_valid = 1;
5731 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
5734 /* and l2tpv3 tunnel interfaces */
5735 M (SW_INTERFACE_DUMP, mp);
5736 mp->name_filter_valid = 1;
5737 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
5738 sizeof (mp->name_filter) - 1);
5741 /* and GRE tunnel interfaces */
5742 M (SW_INTERFACE_DUMP, mp);
5743 mp->name_filter_valid = 1;
5744 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
5747 /* and LISP-GPE interfaces */
5748 M (SW_INTERFACE_DUMP, mp);
5749 mp->name_filter_valid = 1;
5750 strncpy ((char *) mp->name_filter, "lisp_gpe",
5751 sizeof (mp->name_filter) - 1);
5754 /* and IPSEC tunnel interfaces */
5755 M (SW_INTERFACE_DUMP, mp);
5756 mp->name_filter_valid = 1;
5757 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
5760 /* Use a control ping for synchronization */
5761 M (CONTROL_PING, mp_ping);
5769 api_sw_interface_set_flags (vat_main_t * vam)
5771 unformat_input_t *i = vam->input;
5772 vl_api_sw_interface_set_flags_t *mp;
5774 u8 sw_if_index_set = 0;
5775 u8 admin_up = 0, link_up = 0;
5778 /* Parse args required to build the message */
5779 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5781 if (unformat (i, "admin-up"))
5783 else if (unformat (i, "admin-down"))
5785 else if (unformat (i, "link-up"))
5787 else if (unformat (i, "link-down"))
5790 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5791 sw_if_index_set = 1;
5792 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5793 sw_if_index_set = 1;
5798 if (sw_if_index_set == 0)
5800 errmsg ("missing interface name or sw_if_index");
5804 /* Construct the API message */
5805 M (SW_INTERFACE_SET_FLAGS, mp);
5806 mp->sw_if_index = ntohl (sw_if_index);
5807 mp->admin_up_down = admin_up;
5808 mp->link_up_down = link_up;
5813 /* Wait for a reply, return the good/bad news... */
5819 api_sw_interface_clear_stats (vat_main_t * vam)
5821 unformat_input_t *i = vam->input;
5822 vl_api_sw_interface_clear_stats_t *mp;
5824 u8 sw_if_index_set = 0;
5827 /* Parse args required to build the message */
5828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5830 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5831 sw_if_index_set = 1;
5832 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5833 sw_if_index_set = 1;
5838 /* Construct the API message */
5839 M (SW_INTERFACE_CLEAR_STATS, mp);
5841 if (sw_if_index_set == 1)
5842 mp->sw_if_index = ntohl (sw_if_index);
5844 mp->sw_if_index = ~0;
5849 /* Wait for a reply, return the good/bad news... */
5855 api_sw_interface_add_del_address (vat_main_t * vam)
5857 unformat_input_t *i = vam->input;
5858 vl_api_sw_interface_add_del_address_t *mp;
5860 u8 sw_if_index_set = 0;
5861 u8 is_add = 1, del_all = 0;
5862 u32 address_length = 0;
5863 u8 v4_address_set = 0;
5864 u8 v6_address_set = 0;
5865 ip4_address_t v4address;
5866 ip6_address_t v6address;
5869 /* Parse args required to build the message */
5870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5872 if (unformat (i, "del-all"))
5874 else if (unformat (i, "del"))
5877 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5878 sw_if_index_set = 1;
5879 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5880 sw_if_index_set = 1;
5881 else if (unformat (i, "%U/%d",
5882 unformat_ip4_address, &v4address, &address_length))
5884 else if (unformat (i, "%U/%d",
5885 unformat_ip6_address, &v6address, &address_length))
5891 if (sw_if_index_set == 0)
5893 errmsg ("missing interface name or sw_if_index");
5896 if (v4_address_set && v6_address_set)
5898 errmsg ("both v4 and v6 addresses set");
5901 if (!v4_address_set && !v6_address_set && !del_all)
5903 errmsg ("no addresses set");
5907 /* Construct the API message */
5908 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5910 mp->sw_if_index = ntohl (sw_if_index);
5911 mp->is_add = is_add;
5912 mp->del_all = del_all;
5916 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5920 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5922 mp->address_length = address_length;
5927 /* Wait for a reply, return good/bad news */
5933 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5935 unformat_input_t *i = vam->input;
5936 vl_api_sw_interface_set_mpls_enable_t *mp;
5938 u8 sw_if_index_set = 0;
5942 /* Parse args required to build the message */
5943 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5945 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5946 sw_if_index_set = 1;
5947 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5948 sw_if_index_set = 1;
5949 else if (unformat (i, "disable"))
5951 else if (unformat (i, "dis"))
5957 if (sw_if_index_set == 0)
5959 errmsg ("missing interface name or sw_if_index");
5963 /* Construct the API message */
5964 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5966 mp->sw_if_index = ntohl (sw_if_index);
5967 mp->enable = enable;
5972 /* Wait for a reply... */
5978 api_sw_interface_set_table (vat_main_t * vam)
5980 unformat_input_t *i = vam->input;
5981 vl_api_sw_interface_set_table_t *mp;
5982 u32 sw_if_index, vrf_id = 0;
5983 u8 sw_if_index_set = 0;
5987 /* Parse args required to build the message */
5988 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5990 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5991 sw_if_index_set = 1;
5992 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5993 sw_if_index_set = 1;
5994 else if (unformat (i, "vrf %d", &vrf_id))
5996 else if (unformat (i, "ipv6"))
6002 if (sw_if_index_set == 0)
6004 errmsg ("missing interface name or sw_if_index");
6008 /* Construct the API message */
6009 M (SW_INTERFACE_SET_TABLE, mp);
6011 mp->sw_if_index = ntohl (sw_if_index);
6012 mp->is_ipv6 = is_ipv6;
6013 mp->vrf_id = ntohl (vrf_id);
6018 /* Wait for a reply... */
6023 static void vl_api_sw_interface_get_table_reply_t_handler
6024 (vl_api_sw_interface_get_table_reply_t * mp)
6026 vat_main_t *vam = &vat_main;
6028 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6030 vam->retval = ntohl (mp->retval);
6031 vam->result_ready = 1;
6035 static void vl_api_sw_interface_get_table_reply_t_handler_json
6036 (vl_api_sw_interface_get_table_reply_t * mp)
6038 vat_main_t *vam = &vat_main;
6039 vat_json_node_t node;
6041 vat_json_init_object (&node);
6042 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6043 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6045 vat_json_print (vam->ofp, &node);
6046 vat_json_free (&node);
6048 vam->retval = ntohl (mp->retval);
6049 vam->result_ready = 1;
6053 api_sw_interface_get_table (vat_main_t * vam)
6055 unformat_input_t *i = vam->input;
6056 vl_api_sw_interface_get_table_t *mp;
6058 u8 sw_if_index_set = 0;
6062 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6064 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6065 sw_if_index_set = 1;
6066 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6067 sw_if_index_set = 1;
6068 else if (unformat (i, "ipv6"))
6074 if (sw_if_index_set == 0)
6076 errmsg ("missing interface name or sw_if_index");
6080 M (SW_INTERFACE_GET_TABLE, mp);
6081 mp->sw_if_index = htonl (sw_if_index);
6082 mp->is_ipv6 = is_ipv6;
6090 api_sw_interface_set_vpath (vat_main_t * vam)
6092 unformat_input_t *i = vam->input;
6093 vl_api_sw_interface_set_vpath_t *mp;
6094 u32 sw_if_index = 0;
6095 u8 sw_if_index_set = 0;
6099 /* Parse args required to build the message */
6100 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6102 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6103 sw_if_index_set = 1;
6104 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6105 sw_if_index_set = 1;
6106 else if (unformat (i, "enable"))
6108 else if (unformat (i, "disable"))
6114 if (sw_if_index_set == 0)
6116 errmsg ("missing interface name or sw_if_index");
6120 /* Construct the API message */
6121 M (SW_INTERFACE_SET_VPATH, mp);
6123 mp->sw_if_index = ntohl (sw_if_index);
6124 mp->enable = is_enable;
6129 /* Wait for a reply... */
6135 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6137 unformat_input_t *i = vam->input;
6138 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6139 u32 sw_if_index = 0;
6140 u8 sw_if_index_set = 0;
6145 /* Parse args required to build the message */
6146 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6148 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6149 sw_if_index_set = 1;
6150 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6151 sw_if_index_set = 1;
6152 else if (unformat (i, "enable"))
6154 else if (unformat (i, "disable"))
6156 else if (unformat (i, "ip4"))
6158 else if (unformat (i, "ip6"))
6164 if (sw_if_index_set == 0)
6166 errmsg ("missing interface name or sw_if_index");
6170 /* Construct the API message */
6171 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6173 mp->sw_if_index = ntohl (sw_if_index);
6174 mp->enable = is_enable;
6175 mp->is_ipv6 = is_ipv6;
6180 /* Wait for a reply... */
6187 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6189 unformat_input_t *i = vam->input;
6190 vl_api_sw_interface_set_l2_xconnect_t *mp;
6192 u8 rx_sw_if_index_set = 0;
6194 u8 tx_sw_if_index_set = 0;
6198 /* Parse args required to build the message */
6199 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6201 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6202 rx_sw_if_index_set = 1;
6203 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6204 tx_sw_if_index_set = 1;
6205 else if (unformat (i, "rx"))
6207 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6209 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6211 rx_sw_if_index_set = 1;
6216 else if (unformat (i, "tx"))
6218 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6220 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6222 tx_sw_if_index_set = 1;
6227 else if (unformat (i, "enable"))
6229 else if (unformat (i, "disable"))
6235 if (rx_sw_if_index_set == 0)
6237 errmsg ("missing rx interface name or rx_sw_if_index");
6241 if (enable && (tx_sw_if_index_set == 0))
6243 errmsg ("missing tx interface name or tx_sw_if_index");
6247 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6249 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6250 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6251 mp->enable = enable;
6259 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6261 unformat_input_t *i = vam->input;
6262 vl_api_sw_interface_set_l2_bridge_t *mp;
6264 u8 rx_sw_if_index_set = 0;
6272 /* Parse args required to build the message */
6273 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6275 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6276 rx_sw_if_index_set = 1;
6277 else if (unformat (i, "bd_id %d", &bd_id))
6281 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6282 rx_sw_if_index_set = 1;
6283 else if (unformat (i, "shg %d", &shg))
6285 else if (unformat (i, "bvi"))
6287 else if (unformat (i, "enable"))
6289 else if (unformat (i, "disable"))
6295 if (rx_sw_if_index_set == 0)
6297 errmsg ("missing rx interface name or sw_if_index");
6301 if (enable && (bd_id_set == 0))
6303 errmsg ("missing bridge domain");
6307 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6309 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6310 mp->bd_id = ntohl (bd_id);
6313 mp->enable = enable;
6321 api_bridge_domain_dump (vat_main_t * vam)
6323 unformat_input_t *i = vam->input;
6324 vl_api_bridge_domain_dump_t *mp;
6325 vl_api_control_ping_t *mp_ping;
6329 /* Parse args required to build the message */
6330 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6332 if (unformat (i, "bd_id %d", &bd_id))
6338 M (BRIDGE_DOMAIN_DUMP, mp);
6339 mp->bd_id = ntohl (bd_id);
6342 /* Use a control ping for synchronization */
6343 M (CONTROL_PING, mp_ping);
6351 api_bridge_domain_add_del (vat_main_t * vam)
6353 unformat_input_t *i = vam->input;
6354 vl_api_bridge_domain_add_del_t *mp;
6357 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6361 /* Parse args required to build the message */
6362 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6364 if (unformat (i, "bd_id %d", &bd_id))
6366 else if (unformat (i, "flood %d", &flood))
6368 else if (unformat (i, "uu-flood %d", &uu_flood))
6370 else if (unformat (i, "forward %d", &forward))
6372 else if (unformat (i, "learn %d", &learn))
6374 else if (unformat (i, "arp-term %d", &arp_term))
6376 else if (unformat (i, "mac-age %d", &mac_age))
6378 else if (unformat (i, "del"))
6381 flood = uu_flood = forward = learn = 0;
6389 errmsg ("missing bridge domain");
6395 errmsg ("mac age must be less than 256 ");
6399 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6401 mp->bd_id = ntohl (bd_id);
6403 mp->uu_flood = uu_flood;
6404 mp->forward = forward;
6406 mp->arp_term = arp_term;
6407 mp->is_add = is_add;
6408 mp->mac_age = (u8) mac_age;
6416 api_l2fib_flush_bd (vat_main_t * vam)
6418 unformat_input_t *i = vam->input;
6419 vl_api_l2fib_flush_bd_t *mp;
6423 /* Parse args required to build the message */
6424 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6426 if (unformat (i, "bd_id %d", &bd_id));
6433 errmsg ("missing bridge domain");
6437 M (L2FIB_FLUSH_BD, mp);
6439 mp->bd_id = htonl (bd_id);
6447 api_l2fib_flush_int (vat_main_t * vam)
6449 unformat_input_t *i = vam->input;
6450 vl_api_l2fib_flush_int_t *mp;
6451 u32 sw_if_index = ~0;
6454 /* Parse args required to build the message */
6455 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6457 if (unformat (i, "sw_if_index %d", &sw_if_index));
6459 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6464 if (sw_if_index == ~0)
6466 errmsg ("missing interface name or sw_if_index");
6470 M (L2FIB_FLUSH_INT, mp);
6472 mp->sw_if_index = ntohl (sw_if_index);
6480 api_l2fib_add_del (vat_main_t * vam)
6482 unformat_input_t *i = vam->input;
6483 vl_api_l2fib_add_del_t *mp;
6489 u32 sw_if_index = ~0;
6490 u8 sw_if_index_set = 0;
6499 /* Parse args required to build the message */
6500 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6502 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6504 else if (unformat (i, "bd_id %d", &bd_id))
6506 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6507 sw_if_index_set = 1;
6508 else if (unformat (i, "sw_if"))
6510 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6513 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6514 sw_if_index_set = 1;
6519 else if (unformat (i, "static"))
6521 else if (unformat (i, "filter"))
6526 else if (unformat (i, "bvi"))
6531 else if (unformat (i, "del"))
6533 else if (unformat (i, "count %d", &count))
6541 errmsg ("missing mac address");
6547 errmsg ("missing bridge domain");
6551 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6553 errmsg ("missing interface name or sw_if_index");
6559 /* Turn on async mode */
6560 vam->async_mode = 1;
6561 vam->async_errors = 0;
6562 before = vat_time_now (vam);
6565 for (j = 0; j < count; j++)
6567 M (L2FIB_ADD_DEL, mp);
6570 mp->bd_id = ntohl (bd_id);
6571 mp->is_add = is_add;
6575 mp->sw_if_index = ntohl (sw_if_index);
6576 mp->static_mac = static_mac;
6577 mp->filter_mac = filter_mac;
6578 mp->bvi_mac = bvi_mac;
6580 increment_mac_address (&mac);
6587 vl_api_control_ping_t *mp_ping;
6590 /* Shut off async mode */
6591 vam->async_mode = 0;
6593 M (CONTROL_PING, mp_ping);
6596 timeout = vat_time_now (vam) + 1.0;
6597 while (vat_time_now (vam) < timeout)
6598 if (vam->result_ready == 1)
6603 if (vam->retval == -99)
6606 if (vam->async_errors > 0)
6608 errmsg ("%d asynchronous errors", vam->async_errors);
6611 vam->async_errors = 0;
6612 after = vat_time_now (vam);
6614 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6615 count, after - before, count / (after - before));
6621 /* Wait for a reply... */
6625 /* Return the good/bad news */
6626 return (vam->retval);
6630 api_bridge_domain_set_mac_age (vat_main_t * vam)
6632 unformat_input_t *i = vam->input;
6633 vl_api_bridge_domain_set_mac_age_t *mp;
6638 /* Parse args required to build the message */
6639 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6641 if (unformat (i, "bd_id %d", &bd_id));
6642 else if (unformat (i, "mac-age %d", &mac_age));
6649 errmsg ("missing bridge domain");
6655 errmsg ("mac age must be less than 256 ");
6659 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6661 mp->bd_id = htonl (bd_id);
6662 mp->mac_age = (u8) mac_age;
6670 api_l2_flags (vat_main_t * vam)
6672 unformat_input_t *i = vam->input;
6673 vl_api_l2_flags_t *mp;
6676 u8 sw_if_index_set = 0;
6680 /* Parse args required to build the message */
6681 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6683 if (unformat (i, "sw_if_index %d", &sw_if_index))
6684 sw_if_index_set = 1;
6685 else if (unformat (i, "sw_if"))
6687 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6690 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6691 sw_if_index_set = 1;
6696 else if (unformat (i, "learn"))
6698 else if (unformat (i, "forward"))
6700 else if (unformat (i, "flood"))
6702 else if (unformat (i, "uu-flood"))
6703 flags |= L2_UU_FLOOD;
6704 else if (unformat (i, "arp-term"))
6705 flags |= L2_ARP_TERM;
6706 else if (unformat (i, "off"))
6708 else if (unformat (i, "disable"))
6714 if (sw_if_index_set == 0)
6716 errmsg ("missing interface name or sw_if_index");
6722 mp->sw_if_index = ntohl (sw_if_index);
6723 mp->feature_bitmap = ntohl (flags);
6724 mp->is_set = is_set;
6732 api_bridge_flags (vat_main_t * vam)
6734 unformat_input_t *i = vam->input;
6735 vl_api_bridge_flags_t *mp;
6742 /* Parse args required to build the message */
6743 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6745 if (unformat (i, "bd_id %d", &bd_id))
6747 else if (unformat (i, "learn"))
6749 else if (unformat (i, "forward"))
6751 else if (unformat (i, "flood"))
6753 else if (unformat (i, "uu-flood"))
6754 flags |= L2_UU_FLOOD;
6755 else if (unformat (i, "arp-term"))
6756 flags |= L2_ARP_TERM;
6757 else if (unformat (i, "off"))
6759 else if (unformat (i, "disable"))
6767 errmsg ("missing bridge domain");
6771 M (BRIDGE_FLAGS, mp);
6773 mp->bd_id = ntohl (bd_id);
6774 mp->feature_bitmap = ntohl (flags);
6775 mp->is_set = is_set;
6783 api_bd_ip_mac_add_del (vat_main_t * vam)
6785 unformat_input_t *i = vam->input;
6786 vl_api_bd_ip_mac_add_del_t *mp;
6793 ip4_address_t v4addr;
6794 ip6_address_t v6addr;
6799 /* Parse args required to build the message */
6800 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6802 if (unformat (i, "bd_id %d", &bd_id))
6806 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6810 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6815 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6819 else if (unformat (i, "del"))
6827 errmsg ("missing bridge domain");
6830 else if (ip_set == 0)
6832 errmsg ("missing IP address");
6835 else if (mac_set == 0)
6837 errmsg ("missing MAC address");
6841 M (BD_IP_MAC_ADD_DEL, mp);
6843 mp->bd_id = ntohl (bd_id);
6844 mp->is_ipv6 = is_ipv6;
6845 mp->is_add = is_add;
6847 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6849 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6850 clib_memcpy (mp->mac_address, macaddr, 6);
6857 api_tap_connect (vat_main_t * vam)
6859 unformat_input_t *i = vam->input;
6860 vl_api_tap_connect_t *mp;
6866 ip4_address_t ip4_address;
6868 int ip4_address_set = 0;
6869 ip6_address_t ip6_address;
6871 int ip6_address_set = 0;
6874 memset (mac_address, 0, sizeof (mac_address));
6876 /* Parse args required to build the message */
6877 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6879 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6883 else if (unformat (i, "random-mac"))
6885 else if (unformat (i, "tapname %s", &tap_name))
6887 else if (unformat (i, "tag %s", &tag))
6889 else if (unformat (i, "address %U/%d",
6890 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6891 ip4_address_set = 1;
6892 else if (unformat (i, "address %U/%d",
6893 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6894 ip6_address_set = 1;
6901 errmsg ("missing tap name");
6904 if (vec_len (tap_name) > 63)
6906 errmsg ("tap name too long");
6909 vec_add1 (tap_name, 0);
6911 if (vec_len (tag) > 63)
6913 errmsg ("tag too long");
6917 /* Construct the API message */
6918 M (TAP_CONNECT, mp);
6920 mp->use_random_mac = random_mac;
6921 clib_memcpy (mp->mac_address, mac_address, 6);
6922 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6924 clib_memcpy (mp->tag, tag, vec_len (tag));
6926 if (ip4_address_set)
6928 mp->ip4_address_set = 1;
6929 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6930 mp->ip4_mask_width = ip4_mask_width;
6932 if (ip6_address_set)
6934 mp->ip6_address_set = 1;
6935 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6936 mp->ip6_mask_width = ip6_mask_width;
6939 vec_free (tap_name);
6945 /* Wait for a reply... */
6951 api_tap_modify (vat_main_t * vam)
6953 unformat_input_t *i = vam->input;
6954 vl_api_tap_modify_t *mp;
6959 u32 sw_if_index = ~0;
6960 u8 sw_if_index_set = 0;
6963 memset (mac_address, 0, sizeof (mac_address));
6965 /* Parse args required to build the message */
6966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6968 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6969 sw_if_index_set = 1;
6970 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6971 sw_if_index_set = 1;
6972 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6976 else if (unformat (i, "random-mac"))
6978 else if (unformat (i, "tapname %s", &tap_name))
6984 if (sw_if_index_set == 0)
6986 errmsg ("missing vpp interface name");
6991 errmsg ("missing tap name");
6994 if (vec_len (tap_name) > 63)
6996 errmsg ("tap name too long");
6998 vec_add1 (tap_name, 0);
7000 /* Construct the API message */
7003 mp->use_random_mac = random_mac;
7004 mp->sw_if_index = ntohl (sw_if_index);
7005 clib_memcpy (mp->mac_address, mac_address, 6);
7006 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7007 vec_free (tap_name);
7012 /* Wait for a reply... */
7018 api_tap_delete (vat_main_t * vam)
7020 unformat_input_t *i = vam->input;
7021 vl_api_tap_delete_t *mp;
7022 u32 sw_if_index = ~0;
7023 u8 sw_if_index_set = 0;
7026 /* Parse args required to build the message */
7027 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7029 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7030 sw_if_index_set = 1;
7031 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7032 sw_if_index_set = 1;
7037 if (sw_if_index_set == 0)
7039 errmsg ("missing vpp interface name");
7043 /* Construct the API message */
7046 mp->sw_if_index = ntohl (sw_if_index);
7051 /* Wait for a reply... */
7057 api_ip_add_del_route (vat_main_t * vam)
7059 unformat_input_t *i = vam->input;
7060 vl_api_ip_add_del_route_t *mp;
7061 u32 sw_if_index = ~0, vrf_id = 0;
7063 u8 is_local = 0, is_drop = 0;
7064 u8 is_unreach = 0, is_prohibit = 0;
7065 u8 create_vrf_if_needed = 0;
7067 u32 next_hop_weight = 1;
7069 u8 is_multipath = 0;
7071 u8 address_length_set = 0;
7072 u32 next_hop_table_id = 0;
7073 u32 resolve_attempts = 0;
7074 u32 dst_address_length = 0;
7075 u8 next_hop_set = 0;
7076 ip4_address_t v4_dst_address, v4_next_hop_address;
7077 ip6_address_t v6_dst_address, v6_next_hop_address;
7081 u32 random_add_del = 0;
7082 u32 *random_vector = 0;
7084 u32 random_seed = 0xdeaddabe;
7085 u32 classify_table_index = ~0;
7087 u8 resolve_host = 0, resolve_attached = 0;
7088 mpls_label_t *next_hop_out_label_stack = NULL;
7089 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7090 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7092 /* Parse args required to build the message */
7093 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7095 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7097 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7099 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
7104 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
7109 else if (unformat (i, "/%d", &dst_address_length))
7111 address_length_set = 1;
7114 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7115 &v4_next_hop_address))
7119 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7120 &v6_next_hop_address))
7124 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7126 else if (unformat (i, "weight %d", &next_hop_weight))
7128 else if (unformat (i, "drop"))
7132 else if (unformat (i, "null-send-unreach"))
7136 else if (unformat (i, "null-send-prohibit"))
7140 else if (unformat (i, "local"))
7144 else if (unformat (i, "classify %d", &classify_table_index))
7148 else if (unformat (i, "del"))
7150 else if (unformat (i, "add"))
7152 else if (unformat (i, "not-last"))
7154 else if (unformat (i, "resolve-via-host"))
7156 else if (unformat (i, "resolve-via-attached"))
7157 resolve_attached = 1;
7158 else if (unformat (i, "multipath"))
7160 else if (unformat (i, "vrf %d", &vrf_id))
7162 else if (unformat (i, "create-vrf"))
7163 create_vrf_if_needed = 1;
7164 else if (unformat (i, "count %d", &count))
7166 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7168 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7170 else if (unformat (i, "out-label %d", &next_hop_out_label))
7171 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7172 else if (unformat (i, "via-label %d", &next_hop_via_label))
7174 else if (unformat (i, "random"))
7176 else if (unformat (i, "seed %d", &random_seed))
7180 clib_warning ("parse error '%U'", format_unformat_error, i);
7185 if (!next_hop_set && !is_drop && !is_local &&
7186 !is_classify && !is_unreach && !is_prohibit &&
7187 MPLS_LABEL_INVALID == next_hop_via_label)
7190 ("next hop / local / drop / unreach / prohibit / classify not set");
7194 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7196 errmsg ("next hop and next-hop via label set");
7199 if (address_set == 0)
7201 errmsg ("missing addresses");
7205 if (address_length_set == 0)
7207 errmsg ("missing address length");
7211 /* Generate a pile of unique, random routes */
7214 u32 this_random_address;
7215 random_hash = hash_create (count, sizeof (uword));
7217 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7218 for (j = 0; j <= count; j++)
7222 this_random_address = random_u32 (&random_seed);
7223 this_random_address =
7224 clib_host_to_net_u32 (this_random_address);
7226 while (hash_get (random_hash, this_random_address));
7227 vec_add1 (random_vector, this_random_address);
7228 hash_set (random_hash, this_random_address, 1);
7230 hash_free (random_hash);
7231 v4_dst_address.as_u32 = random_vector[0];
7236 /* Turn on async mode */
7237 vam->async_mode = 1;
7238 vam->async_errors = 0;
7239 before = vat_time_now (vam);
7242 for (j = 0; j < count; j++)
7244 /* Construct the API message */
7245 M2 (IP_ADD_DEL_ROUTE, mp,
7246 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7248 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7249 mp->table_id = ntohl (vrf_id);
7250 mp->create_vrf_if_needed = create_vrf_if_needed;
7252 mp->is_add = is_add;
7253 mp->is_drop = is_drop;
7254 mp->is_unreach = is_unreach;
7255 mp->is_prohibit = is_prohibit;
7256 mp->is_ipv6 = is_ipv6;
7257 mp->is_local = is_local;
7258 mp->is_classify = is_classify;
7259 mp->is_multipath = is_multipath;
7260 mp->is_resolve_host = resolve_host;
7261 mp->is_resolve_attached = resolve_attached;
7262 mp->not_last = not_last;
7263 mp->next_hop_weight = next_hop_weight;
7264 mp->dst_address_length = dst_address_length;
7265 mp->next_hop_table_id = ntohl (next_hop_table_id);
7266 mp->classify_table_index = ntohl (classify_table_index);
7267 mp->next_hop_via_label = ntohl (next_hop_via_label);
7268 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7269 if (0 != mp->next_hop_n_out_labels)
7271 memcpy (mp->next_hop_out_label_stack,
7272 next_hop_out_label_stack,
7273 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7274 vec_free (next_hop_out_label_stack);
7279 clib_memcpy (mp->dst_address, &v6_dst_address,
7280 sizeof (v6_dst_address));
7282 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
7283 sizeof (v6_next_hop_address));
7284 increment_v6_address (&v6_dst_address);
7288 clib_memcpy (mp->dst_address, &v4_dst_address,
7289 sizeof (v4_dst_address));
7291 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
7292 sizeof (v4_next_hop_address));
7294 v4_dst_address.as_u32 = random_vector[j + 1];
7296 increment_v4_address (&v4_dst_address);
7300 /* If we receive SIGTERM, stop now... */
7305 /* When testing multiple add/del ops, use a control-ping to sync */
7308 vl_api_control_ping_t *mp_ping;
7312 /* Shut off async mode */
7313 vam->async_mode = 0;
7315 M (CONTROL_PING, mp_ping);
7318 timeout = vat_time_now (vam) + 1.0;
7319 while (vat_time_now (vam) < timeout)
7320 if (vam->result_ready == 1)
7325 if (vam->retval == -99)
7328 if (vam->async_errors > 0)
7330 errmsg ("%d asynchronous errors", vam->async_errors);
7333 vam->async_errors = 0;
7334 after = vat_time_now (vam);
7336 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7340 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7341 count, after - before, count / (after - before));
7347 /* Wait for a reply... */
7352 /* Return the good/bad news */
7353 return (vam->retval);
7357 api_ip_mroute_add_del (vat_main_t * vam)
7359 unformat_input_t *i = vam->input;
7360 vl_api_ip_mroute_add_del_t *mp;
7361 u32 sw_if_index = ~0, vrf_id = 0;
7364 u8 create_vrf_if_needed = 0;
7367 u32 grp_address_length = 0;
7368 ip4_address_t v4_grp_address, v4_src_address;
7369 ip6_address_t v6_grp_address, v6_src_address;
7370 mfib_itf_flags_t iflags = 0;
7371 mfib_entry_flags_t eflags = 0;
7374 /* Parse args required to build the message */
7375 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7377 if (unformat (i, "sw_if_index %d", &sw_if_index))
7379 else if (unformat (i, "%U %U",
7380 unformat_ip4_address, &v4_src_address,
7381 unformat_ip4_address, &v4_grp_address))
7383 grp_address_length = 64;
7387 else if (unformat (i, "%U %U",
7388 unformat_ip6_address, &v6_src_address,
7389 unformat_ip6_address, &v6_grp_address))
7391 grp_address_length = 256;
7395 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7397 memset (&v4_src_address, 0, sizeof (v4_src_address));
7398 grp_address_length = 32;
7402 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7404 memset (&v6_src_address, 0, sizeof (v6_src_address));
7405 grp_address_length = 128;
7409 else if (unformat (i, "/%d", &grp_address_length))
7411 else if (unformat (i, "local"))
7415 else if (unformat (i, "del"))
7417 else if (unformat (i, "add"))
7419 else if (unformat (i, "vrf %d", &vrf_id))
7421 else if (unformat (i, "create-vrf"))
7422 create_vrf_if_needed = 1;
7423 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7425 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7429 clib_warning ("parse error '%U'", format_unformat_error, i);
7434 if (address_set == 0)
7436 errmsg ("missing addresses\n");
7440 /* Construct the API message */
7441 M (IP_MROUTE_ADD_DEL, mp);
7443 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7444 mp->table_id = ntohl (vrf_id);
7445 mp->create_vrf_if_needed = create_vrf_if_needed;
7447 mp->is_add = is_add;
7448 mp->is_ipv6 = is_ipv6;
7449 mp->is_local = is_local;
7450 mp->itf_flags = ntohl (iflags);
7451 mp->entry_flags = ntohl (eflags);
7452 mp->grp_address_length = grp_address_length;
7453 mp->grp_address_length = ntohs (mp->grp_address_length);
7457 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7458 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7462 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7463 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7469 /* Wait for a reply... */
7475 api_mpls_route_add_del (vat_main_t * vam)
7477 unformat_input_t *i = vam->input;
7478 vl_api_mpls_route_add_del_t *mp;
7479 u32 sw_if_index = ~0, table_id = 0;
7480 u8 create_table_if_needed = 0;
7482 u32 next_hop_weight = 1;
7483 u8 is_multipath = 0;
7484 u32 next_hop_table_id = 0;
7485 u8 next_hop_set = 0;
7486 ip4_address_t v4_next_hop_address = {
7489 ip6_address_t v6_next_hop_address = { {0} };
7493 u32 classify_table_index = ~0;
7495 u8 resolve_host = 0, resolve_attached = 0;
7496 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7497 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7498 mpls_label_t *next_hop_out_label_stack = NULL;
7499 mpls_label_t local_label = MPLS_LABEL_INVALID;
7501 u8 next_hop_proto_is_ip4 = 1;
7503 /* Parse args required to build the message */
7504 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7506 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7508 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7510 else if (unformat (i, "%d", &local_label))
7512 else if (unformat (i, "eos"))
7514 else if (unformat (i, "non-eos"))
7516 else if (unformat (i, "via %U", unformat_ip4_address,
7517 &v4_next_hop_address))
7520 next_hop_proto_is_ip4 = 1;
7522 else if (unformat (i, "via %U", unformat_ip6_address,
7523 &v6_next_hop_address))
7526 next_hop_proto_is_ip4 = 0;
7528 else if (unformat (i, "weight %d", &next_hop_weight))
7530 else if (unformat (i, "create-table"))
7531 create_table_if_needed = 1;
7532 else if (unformat (i, "classify %d", &classify_table_index))
7536 else if (unformat (i, "del"))
7538 else if (unformat (i, "add"))
7540 else if (unformat (i, "resolve-via-host"))
7542 else if (unformat (i, "resolve-via-attached"))
7543 resolve_attached = 1;
7544 else if (unformat (i, "multipath"))
7546 else if (unformat (i, "count %d", &count))
7548 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
7551 next_hop_proto_is_ip4 = 1;
7553 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
7556 next_hop_proto_is_ip4 = 0;
7558 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7560 else if (unformat (i, "via-label %d", &next_hop_via_label))
7562 else if (unformat (i, "out-label %d", &next_hop_out_label))
7563 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7566 clib_warning ("parse error '%U'", format_unformat_error, i);
7571 if (!next_hop_set && !is_classify)
7573 errmsg ("next hop / classify not set");
7577 if (MPLS_LABEL_INVALID == local_label)
7579 errmsg ("missing label");
7585 /* Turn on async mode */
7586 vam->async_mode = 1;
7587 vam->async_errors = 0;
7588 before = vat_time_now (vam);
7591 for (j = 0; j < count; j++)
7593 /* Construct the API message */
7594 M2 (MPLS_ROUTE_ADD_DEL, mp,
7595 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7597 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
7598 mp->mr_table_id = ntohl (table_id);
7599 mp->mr_create_table_if_needed = create_table_if_needed;
7601 mp->mr_is_add = is_add;
7602 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7603 mp->mr_is_classify = is_classify;
7604 mp->mr_is_multipath = is_multipath;
7605 mp->mr_is_resolve_host = resolve_host;
7606 mp->mr_is_resolve_attached = resolve_attached;
7607 mp->mr_next_hop_weight = next_hop_weight;
7608 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
7609 mp->mr_classify_table_index = ntohl (classify_table_index);
7610 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
7611 mp->mr_label = ntohl (local_label);
7612 mp->mr_eos = is_eos;
7614 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7615 if (0 != mp->mr_next_hop_n_out_labels)
7617 memcpy (mp->mr_next_hop_out_label_stack,
7618 next_hop_out_label_stack,
7619 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7620 vec_free (next_hop_out_label_stack);
7625 if (next_hop_proto_is_ip4)
7627 clib_memcpy (mp->mr_next_hop,
7628 &v4_next_hop_address,
7629 sizeof (v4_next_hop_address));
7633 clib_memcpy (mp->mr_next_hop,
7634 &v6_next_hop_address,
7635 sizeof (v6_next_hop_address));
7642 /* If we receive SIGTERM, stop now... */
7647 /* When testing multiple add/del ops, use a control-ping to sync */
7650 vl_api_control_ping_t *mp_ping;
7654 /* Shut off async mode */
7655 vam->async_mode = 0;
7657 M (CONTROL_PING, mp_ping);
7660 timeout = vat_time_now (vam) + 1.0;
7661 while (vat_time_now (vam) < timeout)
7662 if (vam->result_ready == 1)
7667 if (vam->retval == -99)
7670 if (vam->async_errors > 0)
7672 errmsg ("%d asynchronous errors", vam->async_errors);
7675 vam->async_errors = 0;
7676 after = vat_time_now (vam);
7678 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7682 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7683 count, after - before, count / (after - before));
7689 /* Wait for a reply... */
7694 /* Return the good/bad news */
7695 return (vam->retval);
7699 api_mpls_ip_bind_unbind (vat_main_t * vam)
7701 unformat_input_t *i = vam->input;
7702 vl_api_mpls_ip_bind_unbind_t *mp;
7703 u32 ip_table_id = 0;
7704 u8 create_table_if_needed = 0;
7707 ip4_address_t v4_address;
7708 ip6_address_t v6_address;
7711 mpls_label_t local_label = MPLS_LABEL_INVALID;
7714 /* Parse args required to build the message */
7715 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7717 if (unformat (i, "%U/%d", unformat_ip4_address,
7718 &v4_address, &address_length))
7723 else if (unformat (i, "%U/%d", unformat_ip6_address,
7724 &v6_address, &address_length))
7729 else if (unformat (i, "%d", &local_label))
7731 else if (unformat (i, "create-table"))
7732 create_table_if_needed = 1;
7733 else if (unformat (i, "table-id %d", &ip_table_id))
7735 else if (unformat (i, "unbind"))
7737 else if (unformat (i, "bind"))
7741 clib_warning ("parse error '%U'", format_unformat_error, i);
7748 errmsg ("IP addres not set");
7752 if (MPLS_LABEL_INVALID == local_label)
7754 errmsg ("missing label");
7758 /* Construct the API message */
7759 M (MPLS_IP_BIND_UNBIND, mp);
7761 mp->mb_create_table_if_needed = create_table_if_needed;
7762 mp->mb_is_bind = is_bind;
7763 mp->mb_is_ip4 = is_ip4;
7764 mp->mb_ip_table_id = ntohl (ip_table_id);
7765 mp->mb_mpls_table_id = 0;
7766 mp->mb_label = ntohl (local_label);
7767 mp->mb_address_length = address_length;
7770 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7772 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7777 /* Wait for a reply... */
7783 api_proxy_arp_add_del (vat_main_t * vam)
7785 unformat_input_t *i = vam->input;
7786 vl_api_proxy_arp_add_del_t *mp;
7789 ip4_address_t lo, hi;
7793 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7795 if (unformat (i, "vrf %d", &vrf_id))
7797 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7798 unformat_ip4_address, &hi))
7800 else if (unformat (i, "del"))
7804 clib_warning ("parse error '%U'", format_unformat_error, i);
7811 errmsg ("address range not set");
7815 M (PROXY_ARP_ADD_DEL, mp);
7817 mp->vrf_id = ntohl (vrf_id);
7818 mp->is_add = is_add;
7819 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7820 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7828 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7830 unformat_input_t *i = vam->input;
7831 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7834 u8 sw_if_index_set = 0;
7837 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7839 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7840 sw_if_index_set = 1;
7841 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7842 sw_if_index_set = 1;
7843 else if (unformat (i, "enable"))
7845 else if (unformat (i, "disable"))
7849 clib_warning ("parse error '%U'", format_unformat_error, i);
7854 if (sw_if_index_set == 0)
7856 errmsg ("missing interface name or sw_if_index");
7860 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7862 mp->sw_if_index = ntohl (sw_if_index);
7863 mp->enable_disable = enable;
7871 api_mpls_tunnel_add_del (vat_main_t * vam)
7873 unformat_input_t *i = vam->input;
7874 vl_api_mpls_tunnel_add_del_t *mp;
7878 u32 sw_if_index = ~0;
7879 u32 next_hop_sw_if_index = ~0;
7880 u32 next_hop_proto_is_ip4 = 1;
7882 u32 next_hop_table_id = 0;
7883 ip4_address_t v4_next_hop_address = {
7886 ip6_address_t v6_next_hop_address = { {0} };
7887 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7890 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7892 if (unformat (i, "add"))
7894 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7896 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7898 else if (unformat (i, "via %U",
7899 unformat_ip4_address, &v4_next_hop_address))
7901 next_hop_proto_is_ip4 = 1;
7903 else if (unformat (i, "via %U",
7904 unformat_ip6_address, &v6_next_hop_address))
7906 next_hop_proto_is_ip4 = 0;
7908 else if (unformat (i, "l2-only"))
7910 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7912 else if (unformat (i, "out-label %d", &next_hop_out_label))
7913 vec_add1 (labels, ntohl (next_hop_out_label));
7916 clib_warning ("parse error '%U'", format_unformat_error, i);
7921 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7923 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7924 mp->mt_sw_if_index = ntohl (sw_if_index);
7925 mp->mt_is_add = is_add;
7926 mp->mt_l2_only = l2_only;
7927 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7928 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7930 mp->mt_next_hop_n_out_labels = vec_len (labels);
7932 if (0 != mp->mt_next_hop_n_out_labels)
7934 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7935 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7939 if (next_hop_proto_is_ip4)
7941 clib_memcpy (mp->mt_next_hop,
7942 &v4_next_hop_address, sizeof (v4_next_hop_address));
7946 clib_memcpy (mp->mt_next_hop,
7947 &v6_next_hop_address, sizeof (v6_next_hop_address));
7956 api_sw_interface_set_unnumbered (vat_main_t * vam)
7958 unformat_input_t *i = vam->input;
7959 vl_api_sw_interface_set_unnumbered_t *mp;
7961 u32 unnum_sw_index = ~0;
7963 u8 sw_if_index_set = 0;
7966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7968 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7969 sw_if_index_set = 1;
7970 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7971 sw_if_index_set = 1;
7972 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7974 else if (unformat (i, "del"))
7978 clib_warning ("parse error '%U'", format_unformat_error, i);
7983 if (sw_if_index_set == 0)
7985 errmsg ("missing interface name or sw_if_index");
7989 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7991 mp->sw_if_index = ntohl (sw_if_index);
7992 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7993 mp->is_add = is_add;
8001 api_ip_neighbor_add_del (vat_main_t * vam)
8003 unformat_input_t *i = vam->input;
8004 vl_api_ip_neighbor_add_del_t *mp;
8006 u8 sw_if_index_set = 0;
8009 u8 is_no_fib_entry = 0;
8012 u8 v4_address_set = 0;
8013 u8 v6_address_set = 0;
8014 ip4_address_t v4address;
8015 ip6_address_t v6address;
8018 memset (mac_address, 0, sizeof (mac_address));
8020 /* Parse args required to build the message */
8021 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8023 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8027 else if (unformat (i, "del"))
8030 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8031 sw_if_index_set = 1;
8032 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8033 sw_if_index_set = 1;
8034 else if (unformat (i, "is_static"))
8036 else if (unformat (i, "no-fib-entry"))
8037 is_no_fib_entry = 1;
8038 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
8040 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
8044 clib_warning ("parse error '%U'", format_unformat_error, i);
8049 if (sw_if_index_set == 0)
8051 errmsg ("missing interface name or sw_if_index");
8054 if (v4_address_set && v6_address_set)
8056 errmsg ("both v4 and v6 addresses set");
8059 if (!v4_address_set && !v6_address_set)
8061 errmsg ("no address set");
8065 /* Construct the API message */
8066 M (IP_NEIGHBOR_ADD_DEL, mp);
8068 mp->sw_if_index = ntohl (sw_if_index);
8069 mp->is_add = is_add;
8070 mp->is_static = is_static;
8071 mp->is_no_adj_fib = is_no_fib_entry;
8073 clib_memcpy (mp->mac_address, mac_address, 6);
8077 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
8081 /* mp->is_ipv6 = 0; via memset in M macro above */
8082 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
8088 /* Wait for a reply, return good/bad news */
8094 api_reset_vrf (vat_main_t * vam)
8096 unformat_input_t *i = vam->input;
8097 vl_api_reset_vrf_t *mp;
8103 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8105 if (unformat (i, "vrf %d", &vrf_id))
8107 else if (unformat (i, "ipv6"))
8111 clib_warning ("parse error '%U'", format_unformat_error, i);
8116 if (vrf_id_set == 0)
8118 errmsg ("missing vrf id");
8124 mp->vrf_id = ntohl (vrf_id);
8125 mp->is_ipv6 = is_ipv6;
8133 api_create_vlan_subif (vat_main_t * vam)
8135 unformat_input_t *i = vam->input;
8136 vl_api_create_vlan_subif_t *mp;
8138 u8 sw_if_index_set = 0;
8143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8145 if (unformat (i, "sw_if_index %d", &sw_if_index))
8146 sw_if_index_set = 1;
8148 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8149 sw_if_index_set = 1;
8150 else if (unformat (i, "vlan %d", &vlan_id))
8154 clib_warning ("parse error '%U'", format_unformat_error, i);
8159 if (sw_if_index_set == 0)
8161 errmsg ("missing interface name or sw_if_index");
8165 if (vlan_id_set == 0)
8167 errmsg ("missing vlan_id");
8170 M (CREATE_VLAN_SUBIF, mp);
8172 mp->sw_if_index = ntohl (sw_if_index);
8173 mp->vlan_id = ntohl (vlan_id);
8180 #define foreach_create_subif_bit \
8187 _(outer_vlan_id_any) \
8188 _(inner_vlan_id_any)
8191 api_create_subif (vat_main_t * vam)
8193 unformat_input_t *i = vam->input;
8194 vl_api_create_subif_t *mp;
8196 u8 sw_if_index_set = 0;
8203 u32 exact_match = 0;
8204 u32 default_sub = 0;
8205 u32 outer_vlan_id_any = 0;
8206 u32 inner_vlan_id_any = 0;
8208 u16 outer_vlan_id = 0;
8209 u16 inner_vlan_id = 0;
8212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8214 if (unformat (i, "sw_if_index %d", &sw_if_index))
8215 sw_if_index_set = 1;
8217 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8218 sw_if_index_set = 1;
8219 else if (unformat (i, "sub_id %d", &sub_id))
8221 else if (unformat (i, "outer_vlan_id %d", &tmp))
8222 outer_vlan_id = tmp;
8223 else if (unformat (i, "inner_vlan_id %d", &tmp))
8224 inner_vlan_id = tmp;
8226 #define _(a) else if (unformat (i, #a)) a = 1 ;
8227 foreach_create_subif_bit
8231 clib_warning ("parse error '%U'", format_unformat_error, i);
8236 if (sw_if_index_set == 0)
8238 errmsg ("missing interface name or sw_if_index");
8242 if (sub_id_set == 0)
8244 errmsg ("missing sub_id");
8247 M (CREATE_SUBIF, mp);
8249 mp->sw_if_index = ntohl (sw_if_index);
8250 mp->sub_id = ntohl (sub_id);
8252 #define _(a) mp->a = a;
8253 foreach_create_subif_bit;
8256 mp->outer_vlan_id = ntohs (outer_vlan_id);
8257 mp->inner_vlan_id = ntohs (inner_vlan_id);
8265 api_oam_add_del (vat_main_t * vam)
8267 unformat_input_t *i = vam->input;
8268 vl_api_oam_add_del_t *mp;
8271 ip4_address_t src, dst;
8276 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8278 if (unformat (i, "vrf %d", &vrf_id))
8280 else if (unformat (i, "src %U", unformat_ip4_address, &src))
8282 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
8284 else if (unformat (i, "del"))
8288 clib_warning ("parse error '%U'", format_unformat_error, i);
8295 errmsg ("missing src addr");
8301 errmsg ("missing dst addr");
8305 M (OAM_ADD_DEL, mp);
8307 mp->vrf_id = ntohl (vrf_id);
8308 mp->is_add = is_add;
8309 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
8310 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8318 api_reset_fib (vat_main_t * vam)
8320 unformat_input_t *i = vam->input;
8321 vl_api_reset_fib_t *mp;
8327 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8329 if (unformat (i, "vrf %d", &vrf_id))
8331 else if (unformat (i, "ipv6"))
8335 clib_warning ("parse error '%U'", format_unformat_error, i);
8340 if (vrf_id_set == 0)
8342 errmsg ("missing vrf id");
8348 mp->vrf_id = ntohl (vrf_id);
8349 mp->is_ipv6 = is_ipv6;
8357 api_dhcp_proxy_config (vat_main_t * vam)
8359 unformat_input_t *i = vam->input;
8360 vl_api_dhcp_proxy_config_t *mp;
8362 u32 server_vrf_id = 0;
8364 u8 v4_address_set = 0;
8365 u8 v6_address_set = 0;
8366 ip4_address_t v4address;
8367 ip6_address_t v6address;
8368 u8 v4_src_address_set = 0;
8369 u8 v6_src_address_set = 0;
8370 ip4_address_t v4srcaddress;
8371 ip6_address_t v6srcaddress;
8374 /* Parse args required to build the message */
8375 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8377 if (unformat (i, "del"))
8379 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8381 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8383 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8385 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8387 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8388 v4_src_address_set = 1;
8389 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8390 v6_src_address_set = 1;
8395 if (v4_address_set && v6_address_set)
8397 errmsg ("both v4 and v6 server addresses set");
8400 if (!v4_address_set && !v6_address_set)
8402 errmsg ("no server addresses set");
8406 if (v4_src_address_set && v6_src_address_set)
8408 errmsg ("both v4 and v6 src addresses set");
8411 if (!v4_src_address_set && !v6_src_address_set)
8413 errmsg ("no src addresses set");
8417 if (!(v4_src_address_set && v4_address_set) &&
8418 !(v6_src_address_set && v6_address_set))
8420 errmsg ("no matching server and src addresses set");
8424 /* Construct the API message */
8425 M (DHCP_PROXY_CONFIG, mp);
8427 mp->is_add = is_add;
8428 mp->rx_vrf_id = ntohl (rx_vrf_id);
8429 mp->server_vrf_id = ntohl (server_vrf_id);
8433 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
8434 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
8438 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
8439 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
8445 /* Wait for a reply, return good/bad news */
8450 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
8451 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
8454 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
8456 vat_main_t *vam = &vat_main;
8457 u32 i, count = mp->count;
8458 vl_api_dhcp_server_t *s;
8462 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8463 ntohl (mp->rx_vrf_id),
8464 format_ip6_address, mp->dhcp_src_address,
8465 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8468 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8469 ntohl (mp->rx_vrf_id),
8470 format_ip4_address, mp->dhcp_src_address,
8471 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8473 for (i = 0; i < count; i++)
8475 s = &mp->servers[i];
8479 " Server Table-ID %d, Server Address %U",
8480 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
8483 " Server Table-ID %d, Server Address %U",
8484 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
8488 static void vl_api_dhcp_proxy_details_t_handler_json
8489 (vl_api_dhcp_proxy_details_t * mp)
8491 vat_main_t *vam = &vat_main;
8492 vat_json_node_t *node = NULL;
8493 u32 i, count = mp->count;
8495 struct in6_addr ip6;
8496 vl_api_dhcp_server_t *s;
8498 if (VAT_JSON_ARRAY != vam->json_tree.type)
8500 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8501 vat_json_init_array (&vam->json_tree);
8503 node = vat_json_array_add (&vam->json_tree);
8505 vat_json_init_object (node);
8506 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
8507 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
8508 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
8512 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
8513 vat_json_object_add_ip6 (node, "src_address", ip6);
8517 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
8518 vat_json_object_add_ip4 (node, "src_address", ip4);
8521 for (i = 0; i < count; i++)
8523 s = &mp->servers[i];
8525 vat_json_object_add_uint (node, "server-table-id",
8526 ntohl (s->server_vrf_id));
8530 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
8531 vat_json_object_add_ip4 (node, "src_address", ip4);
8535 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
8536 vat_json_object_add_ip6 (node, "server_address", ip6);
8542 api_dhcp_proxy_dump (vat_main_t * vam)
8544 unformat_input_t *i = vam->input;
8545 vl_api_control_ping_t *mp_ping;
8546 vl_api_dhcp_proxy_dump_t *mp;
8550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8552 if (unformat (i, "ipv6"))
8556 clib_warning ("parse error '%U'", format_unformat_error, i);
8561 M (DHCP_PROXY_DUMP, mp);
8563 mp->is_ip6 = is_ipv6;
8566 /* Use a control ping for synchronization */
8567 M (CONTROL_PING, mp_ping);
8575 api_dhcp_proxy_set_vss (vat_main_t * vam)
8577 unformat_input_t *i = vam->input;
8578 vl_api_dhcp_proxy_set_vss_t *mp;
8589 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8591 if (unformat (i, "tbl_id %d", &tbl_id))
8593 if (unformat (i, "fib_id %d", &fib_id))
8595 if (unformat (i, "oui %d", &oui))
8597 else if (unformat (i, "ipv6"))
8599 else if (unformat (i, "del"))
8603 clib_warning ("parse error '%U'", format_unformat_error, i);
8608 if (tbl_id_set == 0)
8610 errmsg ("missing tbl id");
8614 if (fib_id_set == 0)
8616 errmsg ("missing fib id");
8621 errmsg ("missing oui");
8625 M (DHCP_PROXY_SET_VSS, mp);
8626 mp->tbl_id = ntohl (tbl_id);
8627 mp->fib_id = ntohl (fib_id);
8628 mp->oui = ntohl (oui);
8629 mp->is_ipv6 = is_ipv6;
8630 mp->is_add = is_add;
8638 api_dhcp_client_config (vat_main_t * vam)
8640 unformat_input_t *i = vam->input;
8641 vl_api_dhcp_client_config_t *mp;
8643 u8 sw_if_index_set = 0;
8646 u8 disable_event = 0;
8649 /* Parse args required to build the message */
8650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8652 if (unformat (i, "del"))
8655 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8656 sw_if_index_set = 1;
8657 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8658 sw_if_index_set = 1;
8659 else if (unformat (i, "hostname %s", &hostname))
8661 else if (unformat (i, "disable_event"))
8667 if (sw_if_index_set == 0)
8669 errmsg ("missing interface name or sw_if_index");
8673 if (vec_len (hostname) > 63)
8675 errmsg ("hostname too long");
8677 vec_add1 (hostname, 0);
8679 /* Construct the API message */
8680 M (DHCP_CLIENT_CONFIG, mp);
8682 mp->sw_if_index = htonl (sw_if_index);
8683 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
8684 vec_free (hostname);
8685 mp->is_add = is_add;
8686 mp->want_dhcp_event = disable_event ? 0 : 1;
8687 mp->pid = htonl (getpid ());
8692 /* Wait for a reply, return good/bad news */
8698 api_set_ip_flow_hash (vat_main_t * vam)
8700 unformat_input_t *i = vam->input;
8701 vl_api_set_ip_flow_hash_t *mp;
8713 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8715 if (unformat (i, "vrf %d", &vrf_id))
8717 else if (unformat (i, "ipv6"))
8719 else if (unformat (i, "src"))
8721 else if (unformat (i, "dst"))
8723 else if (unformat (i, "sport"))
8725 else if (unformat (i, "dport"))
8727 else if (unformat (i, "proto"))
8729 else if (unformat (i, "reverse"))
8734 clib_warning ("parse error '%U'", format_unformat_error, i);
8739 if (vrf_id_set == 0)
8741 errmsg ("missing vrf id");
8745 M (SET_IP_FLOW_HASH, mp);
8751 mp->reverse = reverse;
8752 mp->vrf_id = ntohl (vrf_id);
8753 mp->is_ipv6 = is_ipv6;
8761 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8763 unformat_input_t *i = vam->input;
8764 vl_api_sw_interface_ip6_enable_disable_t *mp;
8766 u8 sw_if_index_set = 0;
8770 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8772 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8773 sw_if_index_set = 1;
8774 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8775 sw_if_index_set = 1;
8776 else if (unformat (i, "enable"))
8778 else if (unformat (i, "disable"))
8782 clib_warning ("parse error '%U'", format_unformat_error, i);
8787 if (sw_if_index_set == 0)
8789 errmsg ("missing interface name or sw_if_index");
8793 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8795 mp->sw_if_index = ntohl (sw_if_index);
8796 mp->enable = enable;
8804 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8806 unformat_input_t *i = vam->input;
8807 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8809 u8 sw_if_index_set = 0;
8810 u8 v6_address_set = 0;
8811 ip6_address_t v6address;
8814 /* Parse args required to build the message */
8815 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8817 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8818 sw_if_index_set = 1;
8819 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8820 sw_if_index_set = 1;
8821 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8827 if (sw_if_index_set == 0)
8829 errmsg ("missing interface name or sw_if_index");
8832 if (!v6_address_set)
8834 errmsg ("no address set");
8838 /* Construct the API message */
8839 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8841 mp->sw_if_index = ntohl (sw_if_index);
8842 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8847 /* Wait for a reply, return good/bad news */
8853 api_ip6nd_proxy_add_del (vat_main_t * vam)
8855 unformat_input_t *i = vam->input;
8856 vl_api_ip6nd_proxy_add_del_t *mp;
8857 u32 sw_if_index = ~0;
8858 u8 v6_address_set = 0;
8859 ip6_address_t v6address;
8863 /* Parse args required to build the message */
8864 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8866 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8868 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8870 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8872 if (unformat (i, "del"))
8876 clib_warning ("parse error '%U'", format_unformat_error, i);
8881 if (sw_if_index == ~0)
8883 errmsg ("missing interface name or sw_if_index");
8886 if (!v6_address_set)
8888 errmsg ("no address set");
8892 /* Construct the API message */
8893 M (IP6ND_PROXY_ADD_DEL, mp);
8895 mp->is_del = is_del;
8896 mp->sw_if_index = ntohl (sw_if_index);
8897 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8902 /* Wait for a reply, return good/bad news */
8908 api_ip6nd_proxy_dump (vat_main_t * vam)
8910 vl_api_ip6nd_proxy_dump_t *mp;
8911 vl_api_control_ping_t *mp_ping;
8914 M (IP6ND_PROXY_DUMP, mp);
8918 /* Use a control ping for synchronization */
8919 M (CONTROL_PING, mp_ping);
8926 static void vl_api_ip6nd_proxy_details_t_handler
8927 (vl_api_ip6nd_proxy_details_t * mp)
8929 vat_main_t *vam = &vat_main;
8931 print (vam->ofp, "host %U sw_if_index %d",
8932 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
8935 static void vl_api_ip6nd_proxy_details_t_handler_json
8936 (vl_api_ip6nd_proxy_details_t * mp)
8938 vat_main_t *vam = &vat_main;
8939 struct in6_addr ip6;
8940 vat_json_node_t *node = NULL;
8942 if (VAT_JSON_ARRAY != vam->json_tree.type)
8944 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8945 vat_json_init_array (&vam->json_tree);
8947 node = vat_json_array_add (&vam->json_tree);
8949 vat_json_init_object (node);
8950 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
8952 clib_memcpy (&ip6, mp->address, sizeof (ip6));
8953 vat_json_object_add_ip6 (node, "host", ip6);
8957 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8959 unformat_input_t *i = vam->input;
8960 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8962 u8 sw_if_index_set = 0;
8963 u32 address_length = 0;
8964 u8 v6_address_set = 0;
8965 ip6_address_t v6address;
8967 u8 no_advertise = 0;
8969 u8 no_autoconfig = 0;
8972 u32 val_lifetime = 0;
8973 u32 pref_lifetime = 0;
8976 /* Parse args required to build the message */
8977 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8979 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8980 sw_if_index_set = 1;
8981 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8982 sw_if_index_set = 1;
8983 else if (unformat (i, "%U/%d",
8984 unformat_ip6_address, &v6address, &address_length))
8986 else if (unformat (i, "val_life %d", &val_lifetime))
8988 else if (unformat (i, "pref_life %d", &pref_lifetime))
8990 else if (unformat (i, "def"))
8992 else if (unformat (i, "noadv"))
8994 else if (unformat (i, "offl"))
8996 else if (unformat (i, "noauto"))
8998 else if (unformat (i, "nolink"))
9000 else if (unformat (i, "isno"))
9004 clib_warning ("parse error '%U'", format_unformat_error, i);
9009 if (sw_if_index_set == 0)
9011 errmsg ("missing interface name or sw_if_index");
9014 if (!v6_address_set)
9016 errmsg ("no address set");
9020 /* Construct the API message */
9021 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9023 mp->sw_if_index = ntohl (sw_if_index);
9024 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9025 mp->address_length = address_length;
9026 mp->use_default = use_default;
9027 mp->no_advertise = no_advertise;
9028 mp->off_link = off_link;
9029 mp->no_autoconfig = no_autoconfig;
9030 mp->no_onlink = no_onlink;
9032 mp->val_lifetime = ntohl (val_lifetime);
9033 mp->pref_lifetime = ntohl (pref_lifetime);
9038 /* Wait for a reply, return good/bad news */
9044 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9046 unformat_input_t *i = vam->input;
9047 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9049 u8 sw_if_index_set = 0;
9054 u8 send_unicast = 0;
9057 u8 default_router = 0;
9058 u32 max_interval = 0;
9059 u32 min_interval = 0;
9061 u32 initial_count = 0;
9062 u32 initial_interval = 0;
9066 /* Parse args required to build the message */
9067 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9069 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9070 sw_if_index_set = 1;
9071 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9072 sw_if_index_set = 1;
9073 else if (unformat (i, "maxint %d", &max_interval))
9075 else if (unformat (i, "minint %d", &min_interval))
9077 else if (unformat (i, "life %d", &lifetime))
9079 else if (unformat (i, "count %d", &initial_count))
9081 else if (unformat (i, "interval %d", &initial_interval))
9083 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9085 else if (unformat (i, "managed"))
9087 else if (unformat (i, "other"))
9089 else if (unformat (i, "ll"))
9091 else if (unformat (i, "send"))
9093 else if (unformat (i, "cease"))
9095 else if (unformat (i, "isno"))
9097 else if (unformat (i, "def"))
9101 clib_warning ("parse error '%U'", format_unformat_error, i);
9106 if (sw_if_index_set == 0)
9108 errmsg ("missing interface name or sw_if_index");
9112 /* Construct the API message */
9113 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9115 mp->sw_if_index = ntohl (sw_if_index);
9116 mp->max_interval = ntohl (max_interval);
9117 mp->min_interval = ntohl (min_interval);
9118 mp->lifetime = ntohl (lifetime);
9119 mp->initial_count = ntohl (initial_count);
9120 mp->initial_interval = ntohl (initial_interval);
9121 mp->suppress = suppress;
9122 mp->managed = managed;
9124 mp->ll_option = ll_option;
9125 mp->send_unicast = send_unicast;
9128 mp->default_router = default_router;
9133 /* Wait for a reply, return good/bad news */
9139 api_set_arp_neighbor_limit (vat_main_t * vam)
9141 unformat_input_t *i = vam->input;
9142 vl_api_set_arp_neighbor_limit_t *mp;
9148 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9150 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9152 else if (unformat (i, "ipv6"))
9156 clib_warning ("parse error '%U'", format_unformat_error, i);
9163 errmsg ("missing limit value");
9167 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9169 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9170 mp->is_ipv6 = is_ipv6;
9178 api_l2_patch_add_del (vat_main_t * vam)
9180 unformat_input_t *i = vam->input;
9181 vl_api_l2_patch_add_del_t *mp;
9183 u8 rx_sw_if_index_set = 0;
9185 u8 tx_sw_if_index_set = 0;
9189 /* Parse args required to build the message */
9190 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9192 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9193 rx_sw_if_index_set = 1;
9194 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9195 tx_sw_if_index_set = 1;
9196 else if (unformat (i, "rx"))
9198 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9200 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9202 rx_sw_if_index_set = 1;
9207 else if (unformat (i, "tx"))
9209 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9211 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9213 tx_sw_if_index_set = 1;
9218 else if (unformat (i, "del"))
9224 if (rx_sw_if_index_set == 0)
9226 errmsg ("missing rx interface name or rx_sw_if_index");
9230 if (tx_sw_if_index_set == 0)
9232 errmsg ("missing tx interface name or tx_sw_if_index");
9236 M (L2_PATCH_ADD_DEL, mp);
9238 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9239 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9240 mp->is_add = is_add;
9248 u8 localsid_addr[16];
9257 api_sr_localsid_add_del (vat_main_t * vam)
9259 unformat_input_t *i = vam->input;
9260 vl_api_sr_localsid_add_del_t *mp;
9263 ip6_address_t localsid;
9267 u32 fib_table = ~(u32) 0;
9268 ip6_address_t next_hop;
9270 bool nexthop_set = 0;
9274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9276 if (unformat (i, "del"))
9278 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9279 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
9281 else if (unformat (i, "behavior %u", &behavior));
9282 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9283 else if (unformat (i, "fib-table %u", &fib_table));
9284 else if (unformat (i, "end.psp %u", &behavior));
9289 M (SR_LOCALSID_ADD_DEL, mp);
9291 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
9293 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
9294 mp->behavior = behavior;
9295 mp->sw_if_index = ntohl (sw_if_index);
9296 mp->fib_table = ntohl (fib_table);
9297 mp->end_psp = end_psp;
9298 mp->is_del = is_del;
9306 api_ioam_enable (vat_main_t * vam)
9308 unformat_input_t *input = vam->input;
9309 vl_api_ioam_enable_t *mp;
9311 int has_trace_option = 0;
9312 int has_pot_option = 0;
9313 int has_seqno_option = 0;
9314 int has_analyse_option = 0;
9317 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9319 if (unformat (input, "trace"))
9320 has_trace_option = 1;
9321 else if (unformat (input, "pot"))
9323 else if (unformat (input, "seqno"))
9324 has_seqno_option = 1;
9325 else if (unformat (input, "analyse"))
9326 has_analyse_option = 1;
9330 M (IOAM_ENABLE, mp);
9331 mp->id = htons (id);
9332 mp->seqno = has_seqno_option;
9333 mp->analyse = has_analyse_option;
9334 mp->pot_enable = has_pot_option;
9335 mp->trace_enable = has_trace_option;
9344 api_ioam_disable (vat_main_t * vam)
9346 vl_api_ioam_disable_t *mp;
9349 M (IOAM_DISABLE, mp);
9355 #define foreach_tcp_proto_field \
9359 #define foreach_udp_proto_field \
9363 #define foreach_ip4_proto_field \
9375 u16 src_port, dst_port;
9378 #if VPP_API_TEST_BUILTIN == 0
9380 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9382 u8 **maskp = va_arg (*args, u8 **);
9384 u8 found_something = 0;
9387 #define _(a) u8 a=0;
9388 foreach_tcp_proto_field;
9391 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9394 #define _(a) else if (unformat (input, #a)) a=1;
9395 foreach_tcp_proto_field
9401 #define _(a) found_something += a;
9402 foreach_tcp_proto_field;
9405 if (found_something == 0)
9408 vec_validate (mask, sizeof (*tcp) - 1);
9410 tcp = (tcp_header_t *) mask;
9412 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9413 foreach_tcp_proto_field;
9421 unformat_udp_mask (unformat_input_t * input, va_list * args)
9423 u8 **maskp = va_arg (*args, u8 **);
9425 u8 found_something = 0;
9428 #define _(a) u8 a=0;
9429 foreach_udp_proto_field;
9432 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9435 #define _(a) else if (unformat (input, #a)) a=1;
9436 foreach_udp_proto_field
9442 #define _(a) found_something += a;
9443 foreach_udp_proto_field;
9446 if (found_something == 0)
9449 vec_validate (mask, sizeof (*udp) - 1);
9451 udp = (udp_header_t *) mask;
9453 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
9454 foreach_udp_proto_field;
9462 unformat_l4_mask (unformat_input_t * input, va_list * args)
9464 u8 **maskp = va_arg (*args, u8 **);
9465 u16 src_port = 0, dst_port = 0;
9466 tcpudp_header_t *tcpudp;
9468 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9470 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9472 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9474 else if (unformat (input, "src_port"))
9476 else if (unformat (input, "dst_port"))
9482 if (!src_port && !dst_port)
9486 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9488 tcpudp = (tcpudp_header_t *) mask;
9489 tcpudp->src_port = src_port;
9490 tcpudp->dst_port = dst_port;
9498 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9500 u8 **maskp = va_arg (*args, u8 **);
9502 u8 found_something = 0;
9505 #define _(a) u8 a=0;
9506 foreach_ip4_proto_field;
9512 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9514 if (unformat (input, "version"))
9516 else if (unformat (input, "hdr_length"))
9518 else if (unformat (input, "src"))
9520 else if (unformat (input, "dst"))
9522 else if (unformat (input, "proto"))
9525 #define _(a) else if (unformat (input, #a)) a=1;
9526 foreach_ip4_proto_field
9532 #define _(a) found_something += a;
9533 foreach_ip4_proto_field;
9536 if (found_something == 0)
9539 vec_validate (mask, sizeof (*ip) - 1);
9541 ip = (ip4_header_t *) mask;
9543 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9544 foreach_ip4_proto_field;
9547 ip->ip_version_and_header_length = 0;
9550 ip->ip_version_and_header_length |= 0xF0;
9553 ip->ip_version_and_header_length |= 0x0F;
9559 #define foreach_ip6_proto_field \
9567 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9569 u8 **maskp = va_arg (*args, u8 **);
9571 u8 found_something = 0;
9573 u32 ip_version_traffic_class_and_flow_label;
9575 #define _(a) u8 a=0;
9576 foreach_ip6_proto_field;
9579 u8 traffic_class = 0;
9582 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9584 if (unformat (input, "version"))
9586 else if (unformat (input, "traffic-class"))
9588 else if (unformat (input, "flow-label"))
9590 else if (unformat (input, "src"))
9592 else if (unformat (input, "dst"))
9594 else if (unformat (input, "proto"))
9597 #define _(a) else if (unformat (input, #a)) a=1;
9598 foreach_ip6_proto_field
9604 #define _(a) found_something += a;
9605 foreach_ip6_proto_field;
9608 if (found_something == 0)
9611 vec_validate (mask, sizeof (*ip) - 1);
9613 ip = (ip6_header_t *) mask;
9615 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9616 foreach_ip6_proto_field;
9619 ip_version_traffic_class_and_flow_label = 0;
9622 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9625 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9628 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9630 ip->ip_version_traffic_class_and_flow_label =
9631 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9638 unformat_l3_mask (unformat_input_t * input, va_list * args)
9640 u8 **maskp = va_arg (*args, u8 **);
9642 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9644 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9646 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9655 unformat_l2_mask (unformat_input_t * input, va_list * args)
9657 u8 **maskp = va_arg (*args, u8 **);
9672 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9674 if (unformat (input, "src"))
9676 else if (unformat (input, "dst"))
9678 else if (unformat (input, "proto"))
9680 else if (unformat (input, "tag1"))
9682 else if (unformat (input, "tag2"))
9684 else if (unformat (input, "ignore-tag1"))
9686 else if (unformat (input, "ignore-tag2"))
9688 else if (unformat (input, "cos1"))
9690 else if (unformat (input, "cos2"))
9692 else if (unformat (input, "dot1q"))
9694 else if (unformat (input, "dot1ad"))
9699 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9700 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9703 if (tag1 || ignore_tag1 || cos1 || dot1q)
9705 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9708 vec_validate (mask, len - 1);
9711 memset (mask, 0xff, 6);
9714 memset (mask + 6, 0xff, 6);
9718 /* inner vlan tag */
9727 mask[21] = mask[20] = 0xff;
9748 mask[16] = mask[17] = 0xff;
9758 mask[12] = mask[13] = 0xff;
9765 unformat_classify_mask (unformat_input_t * input, va_list * args)
9767 u8 **maskp = va_arg (*args, u8 **);
9768 u32 *skipp = va_arg (*args, u32 *);
9769 u32 *matchp = va_arg (*args, u32 *);
9777 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9779 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9781 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9783 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9785 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9799 if (mask || l2 || l3 || l4)
9803 /* "With a free Ethernet header in every package" */
9805 vec_validate (l2, 13);
9809 vec_append (mask, l3);
9814 vec_append (mask, l4);
9819 /* Scan forward looking for the first significant mask octet */
9820 for (i = 0; i < vec_len (mask); i++)
9824 /* compute (skip, match) params */
9825 *skipp = i / sizeof (u32x4);
9826 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9828 /* Pad mask to an even multiple of the vector size */
9829 while (vec_len (mask) % sizeof (u32x4))
9832 match = vec_len (mask) / sizeof (u32x4);
9834 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9836 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9837 if (*tmp || *(tmp + 1))
9842 clib_warning ("BUG: match 0");
9844 _vec_len (mask) = match * sizeof (u32x4);
9854 #endif /* VPP_API_TEST_BUILTIN */
9856 #define foreach_l2_next \
9858 _(ethernet, ETHERNET_INPUT) \
9863 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9865 u32 *miss_next_indexp = va_arg (*args, u32 *);
9870 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9874 if (unformat (input, "%d", &tmp))
9883 *miss_next_indexp = next_index;
9887 #define foreach_ip_next \
9893 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9895 u32 *miss_next_indexp = va_arg (*args, u32 *);
9900 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9904 if (unformat (input, "%d", &tmp))
9913 *miss_next_indexp = next_index;
9917 #define foreach_acl_next \
9921 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9923 u32 *miss_next_indexp = va_arg (*args, u32 *);
9928 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9932 if (unformat (input, "permit"))
9937 else if (unformat (input, "%d", &tmp))
9946 *miss_next_indexp = next_index;
9951 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9953 u32 *r = va_arg (*args, u32 *);
9955 if (unformat (input, "conform-color"))
9956 *r = POLICE_CONFORM;
9957 else if (unformat (input, "exceed-color"))
9966 api_classify_add_del_table (vat_main_t * vam)
9968 unformat_input_t *i = vam->input;
9969 vl_api_classify_add_del_table_t *mp;
9976 u32 table_index = ~0;
9977 u32 next_table_index = ~0;
9978 u32 miss_next_index = ~0;
9979 u32 memory_size = 32 << 20;
9981 u32 current_data_flag = 0;
9982 int current_data_offset = 0;
9985 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9987 if (unformat (i, "del"))
9989 else if (unformat (i, "del-chain"))
9994 else if (unformat (i, "buckets %d", &nbuckets))
9996 else if (unformat (i, "memory_size %d", &memory_size))
9998 else if (unformat (i, "skip %d", &skip))
10000 else if (unformat (i, "match %d", &match))
10002 else if (unformat (i, "table %d", &table_index))
10004 else if (unformat (i, "mask %U", unformat_classify_mask,
10005 &mask, &skip, &match))
10007 else if (unformat (i, "next-table %d", &next_table_index))
10009 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10012 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10015 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10018 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10020 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10026 if (is_add && mask == 0)
10028 errmsg ("Mask required");
10032 if (is_add && skip == ~0)
10034 errmsg ("skip count required");
10038 if (is_add && match == ~0)
10040 errmsg ("match count required");
10044 if (!is_add && table_index == ~0)
10046 errmsg ("table index required for delete");
10050 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10052 mp->is_add = is_add;
10053 mp->del_chain = del_chain;
10054 mp->table_index = ntohl (table_index);
10055 mp->nbuckets = ntohl (nbuckets);
10056 mp->memory_size = ntohl (memory_size);
10057 mp->skip_n_vectors = ntohl (skip);
10058 mp->match_n_vectors = ntohl (match);
10059 mp->next_table_index = ntohl (next_table_index);
10060 mp->miss_next_index = ntohl (miss_next_index);
10061 mp->current_data_flag = ntohl (current_data_flag);
10062 mp->current_data_offset = ntohl (current_data_offset);
10063 clib_memcpy (mp->mask, mask, vec_len (mask));
10072 #if VPP_API_TEST_BUILTIN == 0
10074 unformat_l4_match (unformat_input_t * input, va_list * args)
10076 u8 **matchp = va_arg (*args, u8 **);
10078 u8 *proto_header = 0;
10084 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10086 if (unformat (input, "src_port %d", &src_port))
10088 else if (unformat (input, "dst_port %d", &dst_port))
10094 h.src_port = clib_host_to_net_u16 (src_port);
10095 h.dst_port = clib_host_to_net_u16 (dst_port);
10096 vec_validate (proto_header, sizeof (h) - 1);
10097 memcpy (proto_header, &h, sizeof (h));
10099 *matchp = proto_header;
10105 unformat_ip4_match (unformat_input_t * input, va_list * args)
10107 u8 **matchp = va_arg (*args, u8 **);
10112 int hdr_length = 0;
10113 u32 hdr_length_val;
10114 int src = 0, dst = 0;
10115 ip4_address_t src_val, dst_val;
10122 int fragment_id = 0;
10123 u32 fragment_id_val;
10129 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10131 if (unformat (input, "version %d", &version_val))
10133 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10135 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10137 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10139 else if (unformat (input, "proto %d", &proto_val))
10141 else if (unformat (input, "tos %d", &tos_val))
10143 else if (unformat (input, "length %d", &length_val))
10145 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10147 else if (unformat (input, "ttl %d", &ttl_val))
10149 else if (unformat (input, "checksum %d", &checksum_val))
10155 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10156 + ttl + checksum == 0)
10160 * Aligned because we use the real comparison functions
10162 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10164 ip = (ip4_header_t *) match;
10166 /* These are realistically matched in practice */
10168 ip->src_address.as_u32 = src_val.as_u32;
10171 ip->dst_address.as_u32 = dst_val.as_u32;
10174 ip->protocol = proto_val;
10177 /* These are not, but they're included for completeness */
10179 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10182 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10188 ip->length = clib_host_to_net_u16 (length_val);
10194 ip->checksum = clib_host_to_net_u16 (checksum_val);
10201 unformat_ip6_match (unformat_input_t * input, va_list * args)
10203 u8 **matchp = va_arg (*args, u8 **);
10208 u8 traffic_class = 0;
10209 u32 traffic_class_val = 0;
10212 int src = 0, dst = 0;
10213 ip6_address_t src_val, dst_val;
10216 int payload_length = 0;
10217 u32 payload_length_val;
10220 u32 ip_version_traffic_class_and_flow_label;
10222 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10224 if (unformat (input, "version %d", &version_val))
10226 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10228 else if (unformat (input, "flow_label %d", &flow_label_val))
10230 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10232 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10234 else if (unformat (input, "proto %d", &proto_val))
10236 else if (unformat (input, "payload_length %d", &payload_length_val))
10237 payload_length = 1;
10238 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10244 if (version + traffic_class + flow_label + src + dst + proto +
10245 payload_length + hop_limit == 0)
10249 * Aligned because we use the real comparison functions
10251 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10253 ip = (ip6_header_t *) match;
10256 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10259 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10262 ip->protocol = proto_val;
10264 ip_version_traffic_class_and_flow_label = 0;
10267 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10270 ip_version_traffic_class_and_flow_label |=
10271 (traffic_class_val & 0xFF) << 20;
10274 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10276 ip->ip_version_traffic_class_and_flow_label =
10277 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10279 if (payload_length)
10280 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10283 ip->hop_limit = hop_limit_val;
10290 unformat_l3_match (unformat_input_t * input, va_list * args)
10292 u8 **matchp = va_arg (*args, u8 **);
10294 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10296 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10298 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10307 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10309 u8 *tagp = va_arg (*args, u8 *);
10312 if (unformat (input, "%d", &tag))
10314 tagp[0] = (tag >> 8) & 0x0F;
10315 tagp[1] = tag & 0xFF;
10323 unformat_l2_match (unformat_input_t * input, va_list * args)
10325 u8 **matchp = va_arg (*args, u8 **);
10338 u8 ignore_tag1 = 0;
10339 u8 ignore_tag2 = 0;
10345 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10347 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10350 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10352 else if (unformat (input, "proto %U",
10353 unformat_ethernet_type_host_byte_order, &proto_val))
10355 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10357 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10359 else if (unformat (input, "ignore-tag1"))
10361 else if (unformat (input, "ignore-tag2"))
10363 else if (unformat (input, "cos1 %d", &cos1_val))
10365 else if (unformat (input, "cos2 %d", &cos2_val))
10370 if ((src + dst + proto + tag1 + tag2 +
10371 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10374 if (tag1 || ignore_tag1 || cos1)
10376 if (tag2 || ignore_tag2 || cos2)
10379 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10382 clib_memcpy (match, dst_val, 6);
10385 clib_memcpy (match + 6, src_val, 6);
10389 /* inner vlan tag */
10390 match[19] = tag2_val[1];
10391 match[18] = tag2_val[0];
10393 match[18] |= (cos2_val & 0x7) << 5;
10396 match[21] = proto_val & 0xff;
10397 match[20] = proto_val >> 8;
10401 match[15] = tag1_val[1];
10402 match[14] = tag1_val[0];
10405 match[14] |= (cos1_val & 0x7) << 5;
10411 match[15] = tag1_val[1];
10412 match[14] = tag1_val[0];
10415 match[17] = proto_val & 0xff;
10416 match[16] = proto_val >> 8;
10419 match[14] |= (cos1_val & 0x7) << 5;
10425 match[18] |= (cos2_val & 0x7) << 5;
10427 match[14] |= (cos1_val & 0x7) << 5;
10430 match[13] = proto_val & 0xff;
10431 match[12] = proto_val >> 8;
10440 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10442 u8 **matchp = va_arg (*args, u8 **);
10443 u32 skip_n_vectors = va_arg (*args, u32);
10444 u32 match_n_vectors = va_arg (*args, u32);
10451 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10453 if (unformat (input, "hex %U", unformat_hex_string, &match))
10455 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10457 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10459 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10473 if (match || l2 || l3 || l4)
10475 if (l2 || l3 || l4)
10477 /* "Win a free Ethernet header in every packet" */
10479 vec_validate_aligned (l2, 13, sizeof (u32x4));
10483 vec_append_aligned (match, l3, sizeof (u32x4));
10488 vec_append_aligned (match, l4, sizeof (u32x4));
10493 /* Make sure the vector is big enough even if key is all 0's */
10494 vec_validate_aligned
10495 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10498 /* Set size, include skipped vectors */
10499 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10510 api_classify_add_del_session (vat_main_t * vam)
10512 unformat_input_t *i = vam->input;
10513 vl_api_classify_add_del_session_t *mp;
10515 u32 table_index = ~0;
10516 u32 hit_next_index = ~0;
10517 u32 opaque_index = ~0;
10520 u32 skip_n_vectors = 0;
10521 u32 match_n_vectors = 0;
10527 * Warning: you have to supply skip_n and match_n
10528 * because the API client cant simply look at the classify
10532 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10534 if (unformat (i, "del"))
10536 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10539 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10542 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10545 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10547 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10549 else if (unformat (i, "opaque-index %d", &opaque_index))
10551 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10553 else if (unformat (i, "match_n %d", &match_n_vectors))
10555 else if (unformat (i, "match %U", api_unformat_classify_match,
10556 &match, skip_n_vectors, match_n_vectors))
10558 else if (unformat (i, "advance %d", &advance))
10560 else if (unformat (i, "table-index %d", &table_index))
10562 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10564 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10566 else if (unformat (i, "action %d", &action))
10568 else if (unformat (i, "metadata %d", &metadata))
10574 if (table_index == ~0)
10576 errmsg ("Table index required");
10580 if (is_add && match == 0)
10582 errmsg ("Match value required");
10586 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10588 mp->is_add = is_add;
10589 mp->table_index = ntohl (table_index);
10590 mp->hit_next_index = ntohl (hit_next_index);
10591 mp->opaque_index = ntohl (opaque_index);
10592 mp->advance = ntohl (advance);
10593 mp->action = action;
10594 mp->metadata = ntohl (metadata);
10595 clib_memcpy (mp->match, match, vec_len (match));
10604 api_classify_set_interface_ip_table (vat_main_t * vam)
10606 unformat_input_t *i = vam->input;
10607 vl_api_classify_set_interface_ip_table_t *mp;
10609 int sw_if_index_set;
10610 u32 table_index = ~0;
10614 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10616 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10617 sw_if_index_set = 1;
10618 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10619 sw_if_index_set = 1;
10620 else if (unformat (i, "table %d", &table_index))
10624 clib_warning ("parse error '%U'", format_unformat_error, i);
10629 if (sw_if_index_set == 0)
10631 errmsg ("missing interface name or sw_if_index");
10636 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10638 mp->sw_if_index = ntohl (sw_if_index);
10639 mp->table_index = ntohl (table_index);
10640 mp->is_ipv6 = is_ipv6;
10648 api_classify_set_interface_l2_tables (vat_main_t * vam)
10650 unformat_input_t *i = vam->input;
10651 vl_api_classify_set_interface_l2_tables_t *mp;
10653 int sw_if_index_set;
10654 u32 ip4_table_index = ~0;
10655 u32 ip6_table_index = ~0;
10656 u32 other_table_index = ~0;
10660 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10662 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10663 sw_if_index_set = 1;
10664 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10665 sw_if_index_set = 1;
10666 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10668 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10670 else if (unformat (i, "other-table %d", &other_table_index))
10672 else if (unformat (i, "is-input %d", &is_input))
10676 clib_warning ("parse error '%U'", format_unformat_error, i);
10681 if (sw_if_index_set == 0)
10683 errmsg ("missing interface name or sw_if_index");
10688 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10690 mp->sw_if_index = ntohl (sw_if_index);
10691 mp->ip4_table_index = ntohl (ip4_table_index);
10692 mp->ip6_table_index = ntohl (ip6_table_index);
10693 mp->other_table_index = ntohl (other_table_index);
10694 mp->is_input = (u8) is_input;
10702 api_set_ipfix_exporter (vat_main_t * vam)
10704 unformat_input_t *i = vam->input;
10705 vl_api_set_ipfix_exporter_t *mp;
10706 ip4_address_t collector_address;
10707 u8 collector_address_set = 0;
10708 u32 collector_port = ~0;
10709 ip4_address_t src_address;
10710 u8 src_address_set = 0;
10713 u32 template_interval = ~0;
10714 u8 udp_checksum = 0;
10717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10719 if (unformat (i, "collector_address %U", unformat_ip4_address,
10720 &collector_address))
10721 collector_address_set = 1;
10722 else if (unformat (i, "collector_port %d", &collector_port))
10724 else if (unformat (i, "src_address %U", unformat_ip4_address,
10726 src_address_set = 1;
10727 else if (unformat (i, "vrf_id %d", &vrf_id))
10729 else if (unformat (i, "path_mtu %d", &path_mtu))
10731 else if (unformat (i, "template_interval %d", &template_interval))
10733 else if (unformat (i, "udp_checksum"))
10739 if (collector_address_set == 0)
10741 errmsg ("collector_address required");
10745 if (src_address_set == 0)
10747 errmsg ("src_address required");
10751 M (SET_IPFIX_EXPORTER, mp);
10753 memcpy (mp->collector_address, collector_address.data,
10754 sizeof (collector_address.data));
10755 mp->collector_port = htons ((u16) collector_port);
10756 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10757 mp->vrf_id = htonl (vrf_id);
10758 mp->path_mtu = htonl (path_mtu);
10759 mp->template_interval = htonl (template_interval);
10760 mp->udp_checksum = udp_checksum;
10768 api_set_ipfix_classify_stream (vat_main_t * vam)
10770 unformat_input_t *i = vam->input;
10771 vl_api_set_ipfix_classify_stream_t *mp;
10773 u32 src_port = UDP_DST_PORT_ipfix;
10776 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10778 if (unformat (i, "domain %d", &domain_id))
10780 else if (unformat (i, "src_port %d", &src_port))
10784 errmsg ("unknown input `%U'", format_unformat_error, i);
10789 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10791 mp->domain_id = htonl (domain_id);
10792 mp->src_port = htons ((u16) src_port);
10800 api_ipfix_classify_table_add_del (vat_main_t * vam)
10802 unformat_input_t *i = vam->input;
10803 vl_api_ipfix_classify_table_add_del_t *mp;
10805 u32 classify_table_index = ~0;
10807 u8 transport_protocol = 255;
10810 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10812 if (unformat (i, "add"))
10814 else if (unformat (i, "del"))
10816 else if (unformat (i, "table %d", &classify_table_index))
10818 else if (unformat (i, "ip4"))
10820 else if (unformat (i, "ip6"))
10822 else if (unformat (i, "tcp"))
10823 transport_protocol = 6;
10824 else if (unformat (i, "udp"))
10825 transport_protocol = 17;
10828 errmsg ("unknown input `%U'", format_unformat_error, i);
10835 errmsg ("expecting: add|del");
10838 if (classify_table_index == ~0)
10840 errmsg ("classifier table not specified");
10843 if (ip_version == 0)
10845 errmsg ("IP version not specified");
10849 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10851 mp->is_add = is_add;
10852 mp->table_id = htonl (classify_table_index);
10853 mp->ip_version = ip_version;
10854 mp->transport_protocol = transport_protocol;
10862 api_get_node_index (vat_main_t * vam)
10864 unformat_input_t *i = vam->input;
10865 vl_api_get_node_index_t *mp;
10869 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10871 if (unformat (i, "node %s", &name))
10878 errmsg ("node name required");
10881 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10883 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10887 M (GET_NODE_INDEX, mp);
10888 clib_memcpy (mp->node_name, name, vec_len (name));
10897 api_get_next_index (vat_main_t * vam)
10899 unformat_input_t *i = vam->input;
10900 vl_api_get_next_index_t *mp;
10901 u8 *node_name = 0, *next_node_name = 0;
10904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10906 if (unformat (i, "node-name %s", &node_name))
10908 else if (unformat (i, "next-node-name %s", &next_node_name))
10912 if (node_name == 0)
10914 errmsg ("node name required");
10917 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10919 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10923 if (next_node_name == 0)
10925 errmsg ("next node name required");
10928 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10930 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10934 M (GET_NEXT_INDEX, mp);
10935 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10936 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10937 vec_free (node_name);
10938 vec_free (next_node_name);
10946 api_add_node_next (vat_main_t * vam)
10948 unformat_input_t *i = vam->input;
10949 vl_api_add_node_next_t *mp;
10954 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10956 if (unformat (i, "node %s", &name))
10958 else if (unformat (i, "next %s", &next))
10965 errmsg ("node name required");
10968 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10970 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10975 errmsg ("next node required");
10978 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10980 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10984 M (ADD_NODE_NEXT, mp);
10985 clib_memcpy (mp->node_name, name, vec_len (name));
10986 clib_memcpy (mp->next_name, next, vec_len (next));
10996 api_l2tpv3_create_tunnel (vat_main_t * vam)
10998 unformat_input_t *i = vam->input;
10999 ip6_address_t client_address, our_address;
11000 int client_address_set = 0;
11001 int our_address_set = 0;
11002 u32 local_session_id = 0;
11003 u32 remote_session_id = 0;
11004 u64 local_cookie = 0;
11005 u64 remote_cookie = 0;
11006 u8 l2_sublayer_present = 0;
11007 vl_api_l2tpv3_create_tunnel_t *mp;
11010 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11012 if (unformat (i, "client_address %U", unformat_ip6_address,
11014 client_address_set = 1;
11015 else if (unformat (i, "our_address %U", unformat_ip6_address,
11017 our_address_set = 1;
11018 else if (unformat (i, "local_session_id %d", &local_session_id))
11020 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11022 else if (unformat (i, "local_cookie %lld", &local_cookie))
11024 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11026 else if (unformat (i, "l2-sublayer-present"))
11027 l2_sublayer_present = 1;
11032 if (client_address_set == 0)
11034 errmsg ("client_address required");
11038 if (our_address_set == 0)
11040 errmsg ("our_address required");
11044 M (L2TPV3_CREATE_TUNNEL, mp);
11046 clib_memcpy (mp->client_address, client_address.as_u8,
11047 sizeof (mp->client_address));
11049 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11051 mp->local_session_id = ntohl (local_session_id);
11052 mp->remote_session_id = ntohl (remote_session_id);
11053 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11054 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11055 mp->l2_sublayer_present = l2_sublayer_present;
11064 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11066 unformat_input_t *i = vam->input;
11068 u8 sw_if_index_set = 0;
11069 u64 new_local_cookie = 0;
11070 u64 new_remote_cookie = 0;
11071 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11074 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11076 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11077 sw_if_index_set = 1;
11078 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11079 sw_if_index_set = 1;
11080 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11082 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11088 if (sw_if_index_set == 0)
11090 errmsg ("missing interface name or sw_if_index");
11094 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11096 mp->sw_if_index = ntohl (sw_if_index);
11097 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11098 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11106 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11108 unformat_input_t *i = vam->input;
11109 vl_api_l2tpv3_interface_enable_disable_t *mp;
11111 u8 sw_if_index_set = 0;
11112 u8 enable_disable = 1;
11115 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11117 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11118 sw_if_index_set = 1;
11119 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11120 sw_if_index_set = 1;
11121 else if (unformat (i, "enable"))
11122 enable_disable = 1;
11123 else if (unformat (i, "disable"))
11124 enable_disable = 0;
11129 if (sw_if_index_set == 0)
11131 errmsg ("missing interface name or sw_if_index");
11135 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11137 mp->sw_if_index = ntohl (sw_if_index);
11138 mp->enable_disable = enable_disable;
11146 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11148 unformat_input_t *i = vam->input;
11149 vl_api_l2tpv3_set_lookup_key_t *mp;
11153 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11155 if (unformat (i, "lookup_v6_src"))
11156 key = L2T_LOOKUP_SRC_ADDRESS;
11157 else if (unformat (i, "lookup_v6_dst"))
11158 key = L2T_LOOKUP_DST_ADDRESS;
11159 else if (unformat (i, "lookup_session_id"))
11160 key = L2T_LOOKUP_SESSION_ID;
11165 if (key == (u8) ~ 0)
11167 errmsg ("l2tp session lookup key unset");
11171 M (L2TPV3_SET_LOOKUP_KEY, mp);
11180 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11181 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11183 vat_main_t *vam = &vat_main;
11185 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11186 format_ip6_address, mp->our_address,
11187 format_ip6_address, mp->client_address,
11188 clib_net_to_host_u32 (mp->sw_if_index));
11191 " local cookies %016llx %016llx remote cookie %016llx",
11192 clib_net_to_host_u64 (mp->local_cookie[0]),
11193 clib_net_to_host_u64 (mp->local_cookie[1]),
11194 clib_net_to_host_u64 (mp->remote_cookie));
11196 print (vam->ofp, " local session-id %d remote session-id %d",
11197 clib_net_to_host_u32 (mp->local_session_id),
11198 clib_net_to_host_u32 (mp->remote_session_id));
11200 print (vam->ofp, " l2 specific sublayer %s\n",
11201 mp->l2_sublayer_present ? "preset" : "absent");
11205 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11206 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11208 vat_main_t *vam = &vat_main;
11209 vat_json_node_t *node = NULL;
11210 struct in6_addr addr;
11212 if (VAT_JSON_ARRAY != vam->json_tree.type)
11214 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11215 vat_json_init_array (&vam->json_tree);
11217 node = vat_json_array_add (&vam->json_tree);
11219 vat_json_init_object (node);
11221 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11222 vat_json_object_add_ip6 (node, "our_address", addr);
11223 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11224 vat_json_object_add_ip6 (node, "client_address", addr);
11226 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11227 vat_json_init_array (lc);
11228 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11229 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11230 vat_json_object_add_uint (node, "remote_cookie",
11231 clib_net_to_host_u64 (mp->remote_cookie));
11233 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11234 vat_json_object_add_uint (node, "local_session_id",
11235 clib_net_to_host_u32 (mp->local_session_id));
11236 vat_json_object_add_uint (node, "remote_session_id",
11237 clib_net_to_host_u32 (mp->remote_session_id));
11238 vat_json_object_add_string_copy (node, "l2_sublayer",
11239 mp->l2_sublayer_present ? (u8 *) "present"
11240 : (u8 *) "absent");
11244 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11246 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11247 vl_api_control_ping_t *mp_ping;
11250 /* Get list of l2tpv3-tunnel interfaces */
11251 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11254 /* Use a control ping for synchronization */
11255 M (CONTROL_PING, mp_ping);
11263 static void vl_api_sw_interface_tap_details_t_handler
11264 (vl_api_sw_interface_tap_details_t * mp)
11266 vat_main_t *vam = &vat_main;
11268 print (vam->ofp, "%-16s %d",
11269 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
11272 static void vl_api_sw_interface_tap_details_t_handler_json
11273 (vl_api_sw_interface_tap_details_t * mp)
11275 vat_main_t *vam = &vat_main;
11276 vat_json_node_t *node = NULL;
11278 if (VAT_JSON_ARRAY != vam->json_tree.type)
11280 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11281 vat_json_init_array (&vam->json_tree);
11283 node = vat_json_array_add (&vam->json_tree);
11285 vat_json_init_object (node);
11286 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11287 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11291 api_sw_interface_tap_dump (vat_main_t * vam)
11293 vl_api_sw_interface_tap_dump_t *mp;
11294 vl_api_control_ping_t *mp_ping;
11297 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
11298 /* Get list of tap interfaces */
11299 M (SW_INTERFACE_TAP_DUMP, mp);
11302 /* Use a control ping for synchronization */
11303 M (CONTROL_PING, mp_ping);
11310 static uword unformat_vxlan_decap_next
11311 (unformat_input_t * input, va_list * args)
11313 u32 *result = va_arg (*args, u32 *);
11316 if (unformat (input, "l2"))
11317 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11318 else if (unformat (input, "%d", &tmp))
11326 api_vxlan_add_del_tunnel (vat_main_t * vam)
11328 unformat_input_t *line_input = vam->input;
11329 vl_api_vxlan_add_del_tunnel_t *mp;
11330 ip46_address_t src, dst;
11332 u8 ipv4_set = 0, ipv6_set = 0;
11336 u32 mcast_sw_if_index = ~0;
11337 u32 encap_vrf_id = 0;
11338 u32 decap_next_index = ~0;
11342 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11343 memset (&src, 0, sizeof src);
11344 memset (&dst, 0, sizeof dst);
11346 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11348 if (unformat (line_input, "del"))
11351 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11357 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11363 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11369 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11374 else if (unformat (line_input, "group %U %U",
11375 unformat_ip4_address, &dst.ip4,
11376 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11378 grp_set = dst_set = 1;
11381 else if (unformat (line_input, "group %U",
11382 unformat_ip4_address, &dst.ip4))
11384 grp_set = dst_set = 1;
11387 else if (unformat (line_input, "group %U %U",
11388 unformat_ip6_address, &dst.ip6,
11389 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11391 grp_set = dst_set = 1;
11394 else if (unformat (line_input, "group %U",
11395 unformat_ip6_address, &dst.ip6))
11397 grp_set = dst_set = 1;
11401 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11403 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11405 else if (unformat (line_input, "decap-next %U",
11406 unformat_vxlan_decap_next, &decap_next_index))
11408 else if (unformat (line_input, "vni %d", &vni))
11412 errmsg ("parse error '%U'", format_unformat_error, line_input);
11419 errmsg ("tunnel src address not specified");
11424 errmsg ("tunnel dst address not specified");
11428 if (grp_set && !ip46_address_is_multicast (&dst))
11430 errmsg ("tunnel group address not multicast");
11433 if (grp_set && mcast_sw_if_index == ~0)
11435 errmsg ("tunnel nonexistent multicast device");
11438 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11440 errmsg ("tunnel dst address must be unicast");
11445 if (ipv4_set && ipv6_set)
11447 errmsg ("both IPv4 and IPv6 addresses specified");
11451 if ((vni == 0) || (vni >> 24))
11453 errmsg ("vni not specified or out of range");
11457 M (VXLAN_ADD_DEL_TUNNEL, mp);
11461 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
11462 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
11466 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
11467 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
11469 mp->encap_vrf_id = ntohl (encap_vrf_id);
11470 mp->decap_next_index = ntohl (decap_next_index);
11471 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11472 mp->vni = ntohl (vni);
11473 mp->is_add = is_add;
11474 mp->is_ipv6 = ipv6_set;
11481 static void vl_api_vxlan_tunnel_details_t_handler
11482 (vl_api_vxlan_tunnel_details_t * mp)
11484 vat_main_t *vam = &vat_main;
11485 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
11486 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
11488 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
11489 ntohl (mp->sw_if_index),
11490 format_ip46_address, &src, IP46_TYPE_ANY,
11491 format_ip46_address, &dst, IP46_TYPE_ANY,
11492 ntohl (mp->encap_vrf_id),
11493 ntohl (mp->decap_next_index), ntohl (mp->vni),
11494 ntohl (mp->mcast_sw_if_index));
11497 static void vl_api_vxlan_tunnel_details_t_handler_json
11498 (vl_api_vxlan_tunnel_details_t * mp)
11500 vat_main_t *vam = &vat_main;
11501 vat_json_node_t *node = NULL;
11503 if (VAT_JSON_ARRAY != vam->json_tree.type)
11505 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11506 vat_json_init_array (&vam->json_tree);
11508 node = vat_json_array_add (&vam->json_tree);
11510 vat_json_init_object (node);
11511 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11514 struct in6_addr ip6;
11516 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
11517 vat_json_object_add_ip6 (node, "src_address", ip6);
11518 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
11519 vat_json_object_add_ip6 (node, "dst_address", ip6);
11523 struct in_addr ip4;
11525 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
11526 vat_json_object_add_ip4 (node, "src_address", ip4);
11527 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
11528 vat_json_object_add_ip4 (node, "dst_address", ip4);
11530 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11531 vat_json_object_add_uint (node, "decap_next_index",
11532 ntohl (mp->decap_next_index));
11533 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11534 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11535 vat_json_object_add_uint (node, "mcast_sw_if_index",
11536 ntohl (mp->mcast_sw_if_index));
11540 api_vxlan_tunnel_dump (vat_main_t * vam)
11542 unformat_input_t *i = vam->input;
11543 vl_api_vxlan_tunnel_dump_t *mp;
11544 vl_api_control_ping_t *mp_ping;
11546 u8 sw_if_index_set = 0;
11549 /* Parse args required to build the message */
11550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11552 if (unformat (i, "sw_if_index %d", &sw_if_index))
11553 sw_if_index_set = 1;
11558 if (sw_if_index_set == 0)
11563 if (!vam->json_output)
11565 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
11566 "sw_if_index", "src_address", "dst_address",
11567 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11570 /* Get list of vxlan-tunnel interfaces */
11571 M (VXLAN_TUNNEL_DUMP, mp);
11573 mp->sw_if_index = htonl (sw_if_index);
11577 /* Use a control ping for synchronization */
11578 M (CONTROL_PING, mp_ping);
11586 api_gre_add_del_tunnel (vat_main_t * vam)
11588 unformat_input_t *line_input = vam->input;
11589 vl_api_gre_add_del_tunnel_t *mp;
11590 ip4_address_t src4, dst4;
11591 ip6_address_t src6, dst6;
11598 u32 outer_fib_id = 0;
11601 memset (&src4, 0, sizeof src4);
11602 memset (&dst4, 0, sizeof dst4);
11603 memset (&src6, 0, sizeof src6);
11604 memset (&dst6, 0, sizeof dst6);
11606 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11608 if (unformat (line_input, "del"))
11610 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
11615 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
11620 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
11625 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
11630 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
11632 else if (unformat (line_input, "teb"))
11636 errmsg ("parse error '%U'", format_unformat_error, line_input);
11643 errmsg ("tunnel src address not specified");
11648 errmsg ("tunnel dst address not specified");
11651 if (ipv4_set && ipv6_set)
11653 errmsg ("both IPv4 and IPv6 addresses specified");
11658 M (GRE_ADD_DEL_TUNNEL, mp);
11662 clib_memcpy (&mp->src_address, &src4, 4);
11663 clib_memcpy (&mp->dst_address, &dst4, 4);
11667 clib_memcpy (&mp->src_address, &src6, 16);
11668 clib_memcpy (&mp->dst_address, &dst6, 16);
11670 mp->outer_fib_id = ntohl (outer_fib_id);
11671 mp->is_add = is_add;
11673 mp->is_ipv6 = ipv6_set;
11680 static void vl_api_gre_tunnel_details_t_handler
11681 (vl_api_gre_tunnel_details_t * mp)
11683 vat_main_t *vam = &vat_main;
11684 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
11685 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
11687 print (vam->ofp, "%11d%24U%24U%6d%14d",
11688 ntohl (mp->sw_if_index),
11689 format_ip46_address, &src, IP46_TYPE_ANY,
11690 format_ip46_address, &dst, IP46_TYPE_ANY,
11691 mp->teb, ntohl (mp->outer_fib_id));
11694 static void vl_api_gre_tunnel_details_t_handler_json
11695 (vl_api_gre_tunnel_details_t * mp)
11697 vat_main_t *vam = &vat_main;
11698 vat_json_node_t *node = NULL;
11699 struct in_addr ip4;
11700 struct in6_addr ip6;
11702 if (VAT_JSON_ARRAY != vam->json_tree.type)
11704 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11705 vat_json_init_array (&vam->json_tree);
11707 node = vat_json_array_add (&vam->json_tree);
11709 vat_json_init_object (node);
11710 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11713 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11714 vat_json_object_add_ip4 (node, "src_address", ip4);
11715 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11716 vat_json_object_add_ip4 (node, "dst_address", ip4);
11720 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
11721 vat_json_object_add_ip6 (node, "src_address", ip6);
11722 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
11723 vat_json_object_add_ip6 (node, "dst_address", ip6);
11725 vat_json_object_add_uint (node, "teb", mp->teb);
11726 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11727 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
11731 api_gre_tunnel_dump (vat_main_t * vam)
11733 unformat_input_t *i = vam->input;
11734 vl_api_gre_tunnel_dump_t *mp;
11735 vl_api_control_ping_t *mp_ping;
11737 u8 sw_if_index_set = 0;
11740 /* Parse args required to build the message */
11741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11743 if (unformat (i, "sw_if_index %d", &sw_if_index))
11744 sw_if_index_set = 1;
11749 if (sw_if_index_set == 0)
11754 if (!vam->json_output)
11756 print (vam->ofp, "%11s%24s%24s%6s%14s",
11757 "sw_if_index", "src_address", "dst_address", "teb",
11761 /* Get list of gre-tunnel interfaces */
11762 M (GRE_TUNNEL_DUMP, mp);
11764 mp->sw_if_index = htonl (sw_if_index);
11768 /* Use a control ping for synchronization */
11769 M (CONTROL_PING, mp_ping);
11777 api_l2_fib_clear_table (vat_main_t * vam)
11779 // unformat_input_t * i = vam->input;
11780 vl_api_l2_fib_clear_table_t *mp;
11783 M (L2_FIB_CLEAR_TABLE, mp);
11791 api_l2_interface_efp_filter (vat_main_t * vam)
11793 unformat_input_t *i = vam->input;
11794 vl_api_l2_interface_efp_filter_t *mp;
11797 u8 sw_if_index_set = 0;
11800 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11802 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11803 sw_if_index_set = 1;
11804 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11805 sw_if_index_set = 1;
11806 else if (unformat (i, "enable"))
11808 else if (unformat (i, "disable"))
11812 clib_warning ("parse error '%U'", format_unformat_error, i);
11817 if (sw_if_index_set == 0)
11819 errmsg ("missing sw_if_index");
11823 M (L2_INTERFACE_EFP_FILTER, mp);
11825 mp->sw_if_index = ntohl (sw_if_index);
11826 mp->enable_disable = enable;
11833 #define foreach_vtr_op \
11834 _("disable", L2_VTR_DISABLED) \
11835 _("push-1", L2_VTR_PUSH_1) \
11836 _("push-2", L2_VTR_PUSH_2) \
11837 _("pop-1", L2_VTR_POP_1) \
11838 _("pop-2", L2_VTR_POP_2) \
11839 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11840 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11841 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11842 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11845 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11847 unformat_input_t *i = vam->input;
11848 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11850 u8 sw_if_index_set = 0;
11853 u32 push_dot1q = 1;
11858 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11860 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11861 sw_if_index_set = 1;
11862 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11863 sw_if_index_set = 1;
11864 else if (unformat (i, "vtr_op %d", &vtr_op))
11866 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11869 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11871 else if (unformat (i, "tag1 %d", &tag1))
11873 else if (unformat (i, "tag2 %d", &tag2))
11877 clib_warning ("parse error '%U'", format_unformat_error, i);
11882 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11884 errmsg ("missing vtr operation or sw_if_index");
11888 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11889 mp->sw_if_index = ntohl (sw_if_index);
11890 mp->vtr_op = ntohl (vtr_op);
11891 mp->push_dot1q = ntohl (push_dot1q);
11892 mp->tag1 = ntohl (tag1);
11893 mp->tag2 = ntohl (tag2);
11901 api_create_vhost_user_if (vat_main_t * vam)
11903 unformat_input_t *i = vam->input;
11904 vl_api_create_vhost_user_if_t *mp;
11907 u8 file_name_set = 0;
11908 u32 custom_dev_instance = ~0;
11910 u8 use_custom_mac = 0;
11914 /* Shut up coverity */
11915 memset (hwaddr, 0, sizeof (hwaddr));
11917 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11919 if (unformat (i, "socket %s", &file_name))
11923 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11925 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11926 use_custom_mac = 1;
11927 else if (unformat (i, "server"))
11929 else if (unformat (i, "tag %s", &tag))
11935 if (file_name_set == 0)
11937 errmsg ("missing socket file name");
11941 if (vec_len (file_name) > 255)
11943 errmsg ("socket file name too long");
11946 vec_add1 (file_name, 0);
11948 M (CREATE_VHOST_USER_IF, mp);
11950 mp->is_server = is_server;
11951 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11952 vec_free (file_name);
11953 if (custom_dev_instance != ~0)
11956 mp->custom_dev_instance = ntohl (custom_dev_instance);
11958 mp->use_custom_mac = use_custom_mac;
11959 clib_memcpy (mp->mac_address, hwaddr, 6);
11961 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11970 api_modify_vhost_user_if (vat_main_t * vam)
11972 unformat_input_t *i = vam->input;
11973 vl_api_modify_vhost_user_if_t *mp;
11976 u8 file_name_set = 0;
11977 u32 custom_dev_instance = ~0;
11978 u8 sw_if_index_set = 0;
11979 u32 sw_if_index = (u32) ~ 0;
11982 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11984 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11985 sw_if_index_set = 1;
11986 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11987 sw_if_index_set = 1;
11988 else if (unformat (i, "socket %s", &file_name))
11992 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11994 else if (unformat (i, "server"))
12000 if (sw_if_index_set == 0)
12002 errmsg ("missing sw_if_index or interface name");
12006 if (file_name_set == 0)
12008 errmsg ("missing socket file name");
12012 if (vec_len (file_name) > 255)
12014 errmsg ("socket file name too long");
12017 vec_add1 (file_name, 0);
12019 M (MODIFY_VHOST_USER_IF, mp);
12021 mp->sw_if_index = ntohl (sw_if_index);
12022 mp->is_server = is_server;
12023 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12024 vec_free (file_name);
12025 if (custom_dev_instance != ~0)
12028 mp->custom_dev_instance = ntohl (custom_dev_instance);
12037 api_delete_vhost_user_if (vat_main_t * vam)
12039 unformat_input_t *i = vam->input;
12040 vl_api_delete_vhost_user_if_t *mp;
12041 u32 sw_if_index = ~0;
12042 u8 sw_if_index_set = 0;
12045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12047 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12048 sw_if_index_set = 1;
12049 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12050 sw_if_index_set = 1;
12055 if (sw_if_index_set == 0)
12057 errmsg ("missing sw_if_index or interface name");
12062 M (DELETE_VHOST_USER_IF, mp);
12064 mp->sw_if_index = ntohl (sw_if_index);
12071 static void vl_api_sw_interface_vhost_user_details_t_handler
12072 (vl_api_sw_interface_vhost_user_details_t * mp)
12074 vat_main_t *vam = &vat_main;
12076 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12077 (char *) mp->interface_name,
12078 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12079 clib_net_to_host_u64 (mp->features), mp->is_server,
12080 ntohl (mp->num_regions), (char *) mp->sock_filename);
12081 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12084 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12085 (vl_api_sw_interface_vhost_user_details_t * mp)
12087 vat_main_t *vam = &vat_main;
12088 vat_json_node_t *node = NULL;
12090 if (VAT_JSON_ARRAY != vam->json_tree.type)
12092 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12093 vat_json_init_array (&vam->json_tree);
12095 node = vat_json_array_add (&vam->json_tree);
12097 vat_json_init_object (node);
12098 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12099 vat_json_object_add_string_copy (node, "interface_name",
12100 mp->interface_name);
12101 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12102 ntohl (mp->virtio_net_hdr_sz));
12103 vat_json_object_add_uint (node, "features",
12104 clib_net_to_host_u64 (mp->features));
12105 vat_json_object_add_uint (node, "is_server", mp->is_server);
12106 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12107 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12108 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12112 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12114 vl_api_sw_interface_vhost_user_dump_t *mp;
12115 vl_api_control_ping_t *mp_ping;
12118 "Interface name idx hdr_sz features server regions filename");
12120 /* Get list of vhost-user interfaces */
12121 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12124 /* Use a control ping for synchronization */
12125 M (CONTROL_PING, mp_ping);
12133 api_show_version (vat_main_t * vam)
12135 vl_api_show_version_t *mp;
12138 M (SHOW_VERSION, mp);
12147 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12149 unformat_input_t *line_input = vam->input;
12150 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12151 ip4_address_t local4, remote4;
12152 ip6_address_t local6, remote6;
12154 u8 ipv4_set = 0, ipv6_set = 0;
12158 u32 mcast_sw_if_index = ~0;
12159 u32 encap_vrf_id = 0;
12160 u32 decap_vrf_id = 0;
12166 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12167 memset (&local4, 0, sizeof local4);
12168 memset (&remote4, 0, sizeof remote4);
12169 memset (&local6, 0, sizeof local6);
12170 memset (&remote6, 0, sizeof remote6);
12172 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12174 if (unformat (line_input, "del"))
12176 else if (unformat (line_input, "local %U",
12177 unformat_ip4_address, &local4))
12182 else if (unformat (line_input, "remote %U",
12183 unformat_ip4_address, &remote4))
12188 else if (unformat (line_input, "local %U",
12189 unformat_ip6_address, &local6))
12194 else if (unformat (line_input, "remote %U",
12195 unformat_ip6_address, &remote6))
12200 else if (unformat (line_input, "group %U %U",
12201 unformat_ip4_address, &remote4,
12202 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12204 grp_set = remote_set = 1;
12207 else if (unformat (line_input, "group %U",
12208 unformat_ip4_address, &remote4))
12210 grp_set = remote_set = 1;
12213 else if (unformat (line_input, "group %U %U",
12214 unformat_ip6_address, &remote6,
12215 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12217 grp_set = remote_set = 1;
12220 else if (unformat (line_input, "group %U",
12221 unformat_ip6_address, &remote6))
12223 grp_set = remote_set = 1;
12227 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12229 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12231 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
12233 else if (unformat (line_input, "vni %d", &vni))
12235 else if (unformat (line_input, "next-ip4"))
12237 else if (unformat (line_input, "next-ip6"))
12239 else if (unformat (line_input, "next-ethernet"))
12241 else if (unformat (line_input, "next-nsh"))
12245 errmsg ("parse error '%U'", format_unformat_error, line_input);
12250 if (local_set == 0)
12252 errmsg ("tunnel local address not specified");
12255 if (remote_set == 0)
12257 errmsg ("tunnel remote address not specified");
12260 if (grp_set && mcast_sw_if_index == ~0)
12262 errmsg ("tunnel nonexistent multicast device");
12265 if (ipv4_set && ipv6_set)
12267 errmsg ("both IPv4 and IPv6 addresses specified");
12273 errmsg ("vni not specified");
12277 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
12282 clib_memcpy (&mp->local, &local6, sizeof (local6));
12283 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
12287 clib_memcpy (&mp->local, &local4, sizeof (local4));
12288 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
12291 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12292 mp->encap_vrf_id = ntohl (encap_vrf_id);
12293 mp->decap_vrf_id = ntohl (decap_vrf_id);
12294 mp->protocol = protocol;
12295 mp->vni = ntohl (vni);
12296 mp->is_add = is_add;
12297 mp->is_ipv6 = ipv6_set;
12304 static void vl_api_vxlan_gpe_tunnel_details_t_handler
12305 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12307 vat_main_t *vam = &vat_main;
12308 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
12309 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
12311 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
12312 ntohl (mp->sw_if_index),
12313 format_ip46_address, &local, IP46_TYPE_ANY,
12314 format_ip46_address, &remote, IP46_TYPE_ANY,
12315 ntohl (mp->vni), mp->protocol,
12316 ntohl (mp->mcast_sw_if_index),
12317 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
12321 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
12322 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12324 vat_main_t *vam = &vat_main;
12325 vat_json_node_t *node = NULL;
12326 struct in_addr ip4;
12327 struct in6_addr ip6;
12329 if (VAT_JSON_ARRAY != vam->json_tree.type)
12331 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12332 vat_json_init_array (&vam->json_tree);
12334 node = vat_json_array_add (&vam->json_tree);
12336 vat_json_init_object (node);
12337 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12340 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
12341 vat_json_object_add_ip6 (node, "local", ip6);
12342 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
12343 vat_json_object_add_ip6 (node, "remote", ip6);
12347 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
12348 vat_json_object_add_ip4 (node, "local", ip4);
12349 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
12350 vat_json_object_add_ip4 (node, "remote", ip4);
12352 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12353 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
12354 vat_json_object_add_uint (node, "mcast_sw_if_index",
12355 ntohl (mp->mcast_sw_if_index));
12356 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12357 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
12358 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12362 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
12364 unformat_input_t *i = vam->input;
12365 vl_api_vxlan_gpe_tunnel_dump_t *mp;
12366 vl_api_control_ping_t *mp_ping;
12368 u8 sw_if_index_set = 0;
12371 /* Parse args required to build the message */
12372 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12374 if (unformat (i, "sw_if_index %d", &sw_if_index))
12375 sw_if_index_set = 1;
12380 if (sw_if_index_set == 0)
12385 if (!vam->json_output)
12387 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
12388 "sw_if_index", "local", "remote", "vni",
12389 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
12392 /* Get list of vxlan-tunnel interfaces */
12393 M (VXLAN_GPE_TUNNEL_DUMP, mp);
12395 mp->sw_if_index = htonl (sw_if_index);
12399 /* Use a control ping for synchronization */
12400 M (CONTROL_PING, mp_ping);
12409 format_l2_fib_mac_address (u8 * s, va_list * args)
12411 u8 *a = va_arg (*args, u8 *);
12413 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
12414 a[2], a[3], a[4], a[5], a[6], a[7]);
12417 static void vl_api_l2_fib_table_details_t_handler
12418 (vl_api_l2_fib_table_details_t * mp)
12420 vat_main_t *vam = &vat_main;
12422 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
12424 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
12425 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
12429 static void vl_api_l2_fib_table_details_t_handler_json
12430 (vl_api_l2_fib_table_details_t * mp)
12432 vat_main_t *vam = &vat_main;
12433 vat_json_node_t *node = NULL;
12435 if (VAT_JSON_ARRAY != vam->json_tree.type)
12437 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12438 vat_json_init_array (&vam->json_tree);
12440 node = vat_json_array_add (&vam->json_tree);
12442 vat_json_init_object (node);
12443 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
12444 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
12445 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12446 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
12447 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
12448 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
12452 api_l2_fib_table_dump (vat_main_t * vam)
12454 unformat_input_t *i = vam->input;
12455 vl_api_l2_fib_table_dump_t *mp;
12456 vl_api_control_ping_t *mp_ping;
12461 /* Parse args required to build the message */
12462 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12464 if (unformat (i, "bd_id %d", &bd_id))
12470 if (bd_id_set == 0)
12472 errmsg ("missing bridge domain");
12476 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
12478 /* Get list of l2 fib entries */
12479 M (L2_FIB_TABLE_DUMP, mp);
12481 mp->bd_id = ntohl (bd_id);
12484 /* Use a control ping for synchronization */
12485 M (CONTROL_PING, mp_ping);
12494 api_interface_name_renumber (vat_main_t * vam)
12496 unformat_input_t *line_input = vam->input;
12497 vl_api_interface_name_renumber_t *mp;
12498 u32 sw_if_index = ~0;
12499 u32 new_show_dev_instance = ~0;
12502 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12504 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
12507 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12509 else if (unformat (line_input, "new_show_dev_instance %d",
12510 &new_show_dev_instance))
12516 if (sw_if_index == ~0)
12518 errmsg ("missing interface name or sw_if_index");
12522 if (new_show_dev_instance == ~0)
12524 errmsg ("missing new_show_dev_instance");
12528 M (INTERFACE_NAME_RENUMBER, mp);
12530 mp->sw_if_index = ntohl (sw_if_index);
12531 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
12539 api_want_ip4_arp_events (vat_main_t * vam)
12541 unformat_input_t *line_input = vam->input;
12542 vl_api_want_ip4_arp_events_t *mp;
12543 ip4_address_t address;
12544 int address_set = 0;
12545 u32 enable_disable = 1;
12548 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12550 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
12552 else if (unformat (line_input, "del"))
12553 enable_disable = 0;
12558 if (address_set == 0)
12560 errmsg ("missing addresses");
12564 M (WANT_IP4_ARP_EVENTS, mp);
12565 mp->enable_disable = enable_disable;
12566 mp->pid = htonl (getpid ());
12567 mp->address = address.as_u32;
12575 api_want_ip6_nd_events (vat_main_t * vam)
12577 unformat_input_t *line_input = vam->input;
12578 vl_api_want_ip6_nd_events_t *mp;
12579 ip6_address_t address;
12580 int address_set = 0;
12581 u32 enable_disable = 1;
12584 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12586 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
12588 else if (unformat (line_input, "del"))
12589 enable_disable = 0;
12594 if (address_set == 0)
12596 errmsg ("missing addresses");
12600 M (WANT_IP6_ND_EVENTS, mp);
12601 mp->enable_disable = enable_disable;
12602 mp->pid = htonl (getpid ());
12603 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
12611 api_want_l2_macs_events (vat_main_t * vam)
12613 unformat_input_t *line_input = vam->input;
12614 vl_api_want_l2_macs_events_t *mp;
12615 u8 enable_disable = 1;
12616 u32 scan_delay = 0;
12617 u32 max_macs_in_event = 0;
12618 u32 learn_limit = 0;
12621 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12623 if (unformat (line_input, "learn-limit %d", &learn_limit))
12625 else if (unformat (line_input, "scan-delay %d", &scan_delay))
12627 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
12629 else if (unformat (line_input, "disable"))
12630 enable_disable = 0;
12635 M (WANT_L2_MACS_EVENTS, mp);
12636 mp->enable_disable = enable_disable;
12637 mp->pid = htonl (getpid ());
12638 mp->learn_limit = htonl (learn_limit);
12639 mp->scan_delay = (u8) scan_delay;
12640 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
12647 api_input_acl_set_interface (vat_main_t * vam)
12649 unformat_input_t *i = vam->input;
12650 vl_api_input_acl_set_interface_t *mp;
12652 int sw_if_index_set;
12653 u32 ip4_table_index = ~0;
12654 u32 ip6_table_index = ~0;
12655 u32 l2_table_index = ~0;
12659 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12661 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12662 sw_if_index_set = 1;
12663 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12664 sw_if_index_set = 1;
12665 else if (unformat (i, "del"))
12667 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12669 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12671 else if (unformat (i, "l2-table %d", &l2_table_index))
12675 clib_warning ("parse error '%U'", format_unformat_error, i);
12680 if (sw_if_index_set == 0)
12682 errmsg ("missing interface name or sw_if_index");
12686 M (INPUT_ACL_SET_INTERFACE, mp);
12688 mp->sw_if_index = ntohl (sw_if_index);
12689 mp->ip4_table_index = ntohl (ip4_table_index);
12690 mp->ip6_table_index = ntohl (ip6_table_index);
12691 mp->l2_table_index = ntohl (l2_table_index);
12692 mp->is_add = is_add;
12700 api_ip_address_dump (vat_main_t * vam)
12702 unformat_input_t *i = vam->input;
12703 vl_api_ip_address_dump_t *mp;
12704 vl_api_control_ping_t *mp_ping;
12705 u32 sw_if_index = ~0;
12706 u8 sw_if_index_set = 0;
12711 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12713 if (unformat (i, "sw_if_index %d", &sw_if_index))
12714 sw_if_index_set = 1;
12716 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12717 sw_if_index_set = 1;
12718 else if (unformat (i, "ipv4"))
12720 else if (unformat (i, "ipv6"))
12726 if (ipv4_set && ipv6_set)
12728 errmsg ("ipv4 and ipv6 flags cannot be both set");
12732 if ((!ipv4_set) && (!ipv6_set))
12734 errmsg ("no ipv4 nor ipv6 flag set");
12738 if (sw_if_index_set == 0)
12740 errmsg ("missing interface name or sw_if_index");
12744 vam->current_sw_if_index = sw_if_index;
12745 vam->is_ipv6 = ipv6_set;
12747 M (IP_ADDRESS_DUMP, mp);
12748 mp->sw_if_index = ntohl (sw_if_index);
12749 mp->is_ipv6 = ipv6_set;
12752 /* Use a control ping for synchronization */
12753 M (CONTROL_PING, mp_ping);
12761 api_ip_dump (vat_main_t * vam)
12763 vl_api_ip_dump_t *mp;
12764 vl_api_control_ping_t *mp_ping;
12765 unformat_input_t *in = vam->input;
12772 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
12774 if (unformat (in, "ipv4"))
12776 else if (unformat (in, "ipv6"))
12782 if (ipv4_set && ipv6_set)
12784 errmsg ("ipv4 and ipv6 flags cannot be both set");
12788 if ((!ipv4_set) && (!ipv6_set))
12790 errmsg ("no ipv4 nor ipv6 flag set");
12794 is_ipv6 = ipv6_set;
12795 vam->is_ipv6 = is_ipv6;
12797 /* free old data */
12798 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12800 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12802 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12805 mp->is_ipv6 = ipv6_set;
12808 /* Use a control ping for synchronization */
12809 M (CONTROL_PING, mp_ping);
12817 api_ipsec_spd_add_del (vat_main_t * vam)
12819 unformat_input_t *i = vam->input;
12820 vl_api_ipsec_spd_add_del_t *mp;
12825 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12827 if (unformat (i, "spd_id %d", &spd_id))
12829 else if (unformat (i, "del"))
12833 clib_warning ("parse error '%U'", format_unformat_error, i);
12839 errmsg ("spd_id must be set");
12843 M (IPSEC_SPD_ADD_DEL, mp);
12845 mp->spd_id = ntohl (spd_id);
12846 mp->is_add = is_add;
12854 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12856 unformat_input_t *i = vam->input;
12857 vl_api_ipsec_interface_add_del_spd_t *mp;
12859 u8 sw_if_index_set = 0;
12860 u32 spd_id = (u32) ~ 0;
12864 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12866 if (unformat (i, "del"))
12868 else if (unformat (i, "spd_id %d", &spd_id))
12871 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12872 sw_if_index_set = 1;
12873 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12874 sw_if_index_set = 1;
12877 clib_warning ("parse error '%U'", format_unformat_error, i);
12883 if (spd_id == (u32) ~ 0)
12885 errmsg ("spd_id must be set");
12889 if (sw_if_index_set == 0)
12891 errmsg ("missing interface name or sw_if_index");
12895 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12897 mp->spd_id = ntohl (spd_id);
12898 mp->sw_if_index = ntohl (sw_if_index);
12899 mp->is_add = is_add;
12907 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12909 unformat_input_t *i = vam->input;
12910 vl_api_ipsec_spd_add_del_entry_t *mp;
12911 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12912 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12914 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12915 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12916 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12917 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12920 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12921 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12922 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12923 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12924 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12925 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12929 if (unformat (i, "del"))
12931 if (unformat (i, "outbound"))
12933 if (unformat (i, "inbound"))
12935 else if (unformat (i, "spd_id %d", &spd_id))
12937 else if (unformat (i, "sa_id %d", &sa_id))
12939 else if (unformat (i, "priority %d", &priority))
12941 else if (unformat (i, "protocol %d", &protocol))
12943 else if (unformat (i, "lport_start %d", &lport_start))
12945 else if (unformat (i, "lport_stop %d", &lport_stop))
12947 else if (unformat (i, "rport_start %d", &rport_start))
12949 else if (unformat (i, "rport_stop %d", &rport_stop))
12953 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12959 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12966 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12972 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12979 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12985 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12992 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12998 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
13004 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13006 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13008 clib_warning ("unsupported action: 'resolve'");
13014 clib_warning ("parse error '%U'", format_unformat_error, i);
13020 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
13022 mp->spd_id = ntohl (spd_id);
13023 mp->priority = ntohl (priority);
13024 mp->is_outbound = is_outbound;
13026 mp->is_ipv6 = is_ipv6;
13027 if (is_ipv6 || is_ip_any)
13029 clib_memcpy (mp->remote_address_start, &raddr6_start,
13030 sizeof (ip6_address_t));
13031 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
13032 sizeof (ip6_address_t));
13033 clib_memcpy (mp->local_address_start, &laddr6_start,
13034 sizeof (ip6_address_t));
13035 clib_memcpy (mp->local_address_stop, &laddr6_stop,
13036 sizeof (ip6_address_t));
13040 clib_memcpy (mp->remote_address_start, &raddr4_start,
13041 sizeof (ip4_address_t));
13042 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
13043 sizeof (ip4_address_t));
13044 clib_memcpy (mp->local_address_start, &laddr4_start,
13045 sizeof (ip4_address_t));
13046 clib_memcpy (mp->local_address_stop, &laddr4_stop,
13047 sizeof (ip4_address_t));
13049 mp->protocol = (u8) protocol;
13050 mp->local_port_start = ntohs ((u16) lport_start);
13051 mp->local_port_stop = ntohs ((u16) lport_stop);
13052 mp->remote_port_start = ntohs ((u16) rport_start);
13053 mp->remote_port_stop = ntohs ((u16) rport_stop);
13054 mp->policy = (u8) policy;
13055 mp->sa_id = ntohl (sa_id);
13056 mp->is_add = is_add;
13057 mp->is_ip_any = is_ip_any;
13064 api_ipsec_sad_add_del_entry (vat_main_t * vam)
13066 unformat_input_t *i = vam->input;
13067 vl_api_ipsec_sad_add_del_entry_t *mp;
13068 u32 sad_id = 0, spi = 0;
13069 u8 *ck = 0, *ik = 0;
13072 u8 protocol = IPSEC_PROTOCOL_AH;
13073 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
13074 u32 crypto_alg = 0, integ_alg = 0;
13075 ip4_address_t tun_src4;
13076 ip4_address_t tun_dst4;
13077 ip6_address_t tun_src6;
13078 ip6_address_t tun_dst6;
13081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13083 if (unformat (i, "del"))
13085 else if (unformat (i, "sad_id %d", &sad_id))
13087 else if (unformat (i, "spi %d", &spi))
13089 else if (unformat (i, "esp"))
13090 protocol = IPSEC_PROTOCOL_ESP;
13091 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
13094 is_tunnel_ipv6 = 0;
13096 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
13099 is_tunnel_ipv6 = 0;
13101 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
13104 is_tunnel_ipv6 = 1;
13106 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
13109 is_tunnel_ipv6 = 1;
13113 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13115 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13116 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13118 clib_warning ("unsupported crypto-alg: '%U'",
13119 format_ipsec_crypto_alg, crypto_alg);
13123 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13127 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13129 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13130 integ_alg >= IPSEC_INTEG_N_ALG)
13132 clib_warning ("unsupported integ-alg: '%U'",
13133 format_ipsec_integ_alg, integ_alg);
13137 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13141 clib_warning ("parse error '%U'", format_unformat_error, i);
13147 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
13149 mp->sad_id = ntohl (sad_id);
13150 mp->is_add = is_add;
13151 mp->protocol = protocol;
13152 mp->spi = ntohl (spi);
13153 mp->is_tunnel = is_tunnel;
13154 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
13155 mp->crypto_algorithm = crypto_alg;
13156 mp->integrity_algorithm = integ_alg;
13157 mp->crypto_key_length = vec_len (ck);
13158 mp->integrity_key_length = vec_len (ik);
13160 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13161 mp->crypto_key_length = sizeof (mp->crypto_key);
13163 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13164 mp->integrity_key_length = sizeof (mp->integrity_key);
13167 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13169 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13173 if (is_tunnel_ipv6)
13175 clib_memcpy (mp->tunnel_src_address, &tun_src6,
13176 sizeof (ip6_address_t));
13177 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
13178 sizeof (ip6_address_t));
13182 clib_memcpy (mp->tunnel_src_address, &tun_src4,
13183 sizeof (ip4_address_t));
13184 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
13185 sizeof (ip4_address_t));
13195 api_ipsec_sa_set_key (vat_main_t * vam)
13197 unformat_input_t *i = vam->input;
13198 vl_api_ipsec_sa_set_key_t *mp;
13200 u8 *ck = 0, *ik = 0;
13203 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13205 if (unformat (i, "sa_id %d", &sa_id))
13207 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13209 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13213 clib_warning ("parse error '%U'", format_unformat_error, i);
13218 M (IPSEC_SA_SET_KEY, mp);
13220 mp->sa_id = ntohl (sa_id);
13221 mp->crypto_key_length = vec_len (ck);
13222 mp->integrity_key_length = vec_len (ik);
13224 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13225 mp->crypto_key_length = sizeof (mp->crypto_key);
13227 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13228 mp->integrity_key_length = sizeof (mp->integrity_key);
13231 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13233 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13241 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
13243 unformat_input_t *i = vam->input;
13244 vl_api_ipsec_tunnel_if_add_del_t *mp;
13245 u32 local_spi = 0, remote_spi = 0;
13246 u32 crypto_alg = 0, integ_alg = 0;
13247 u8 *lck = NULL, *rck = NULL;
13248 u8 *lik = NULL, *rik = NULL;
13249 ip4_address_t local_ip = { {0} };
13250 ip4_address_t remote_ip = { {0} };
13253 u8 anti_replay = 0;
13256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13258 if (unformat (i, "del"))
13260 else if (unformat (i, "esn"))
13262 else if (unformat (i, "anti_replay"))
13264 else if (unformat (i, "local_spi %d", &local_spi))
13266 else if (unformat (i, "remote_spi %d", &remote_spi))
13268 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
13270 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
13272 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
13275 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
13277 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
13279 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
13283 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13285 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13286 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13288 errmsg ("unsupported crypto-alg: '%U'\n",
13289 format_ipsec_crypto_alg, crypto_alg);
13295 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13297 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13298 integ_alg >= IPSEC_INTEG_N_ALG)
13300 errmsg ("unsupported integ-alg: '%U'\n",
13301 format_ipsec_integ_alg, integ_alg);
13307 errmsg ("parse error '%U'\n", format_unformat_error, i);
13312 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
13314 mp->is_add = is_add;
13316 mp->anti_replay = anti_replay;
13318 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
13319 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
13321 mp->local_spi = htonl (local_spi);
13322 mp->remote_spi = htonl (remote_spi);
13323 mp->crypto_alg = (u8) crypto_alg;
13325 mp->local_crypto_key_len = 0;
13328 mp->local_crypto_key_len = vec_len (lck);
13329 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
13330 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
13331 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
13334 mp->remote_crypto_key_len = 0;
13337 mp->remote_crypto_key_len = vec_len (rck);
13338 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
13339 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
13340 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
13343 mp->integ_alg = (u8) integ_alg;
13345 mp->local_integ_key_len = 0;
13348 mp->local_integ_key_len = vec_len (lik);
13349 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
13350 mp->local_integ_key_len = sizeof (mp->local_integ_key);
13351 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
13354 mp->remote_integ_key_len = 0;
13357 mp->remote_integ_key_len = vec_len (rik);
13358 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
13359 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
13360 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
13369 api_ikev2_profile_add_del (vat_main_t * vam)
13371 unformat_input_t *i = vam->input;
13372 vl_api_ikev2_profile_add_del_t *mp;
13377 const char *valid_chars = "a-zA-Z0-9_";
13379 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13381 if (unformat (i, "del"))
13383 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13384 vec_add1 (name, 0);
13387 errmsg ("parse error '%U'", format_unformat_error, i);
13392 if (!vec_len (name))
13394 errmsg ("profile name must be specified");
13398 if (vec_len (name) > 64)
13400 errmsg ("profile name too long");
13404 M (IKEV2_PROFILE_ADD_DEL, mp);
13406 clib_memcpy (mp->name, name, vec_len (name));
13407 mp->is_add = is_add;
13416 api_ikev2_profile_set_auth (vat_main_t * vam)
13418 unformat_input_t *i = vam->input;
13419 vl_api_ikev2_profile_set_auth_t *mp;
13422 u32 auth_method = 0;
13426 const char *valid_chars = "a-zA-Z0-9_";
13428 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13430 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13431 vec_add1 (name, 0);
13432 else if (unformat (i, "auth_method %U",
13433 unformat_ikev2_auth_method, &auth_method))
13435 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
13437 else if (unformat (i, "auth_data %v", &data))
13441 errmsg ("parse error '%U'", format_unformat_error, i);
13446 if (!vec_len (name))
13448 errmsg ("profile name must be specified");
13452 if (vec_len (name) > 64)
13454 errmsg ("profile name too long");
13458 if (!vec_len (data))
13460 errmsg ("auth_data must be specified");
13466 errmsg ("auth_method must be specified");
13470 M (IKEV2_PROFILE_SET_AUTH, mp);
13472 mp->is_hex = is_hex;
13473 mp->auth_method = (u8) auth_method;
13474 mp->data_len = vec_len (data);
13475 clib_memcpy (mp->name, name, vec_len (name));
13476 clib_memcpy (mp->data, data, vec_len (data));
13486 api_ikev2_profile_set_id (vat_main_t * vam)
13488 unformat_input_t *i = vam->input;
13489 vl_api_ikev2_profile_set_id_t *mp;
13497 const char *valid_chars = "a-zA-Z0-9_";
13499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13501 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13502 vec_add1 (name, 0);
13503 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
13505 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
13507 data = vec_new (u8, 4);
13508 clib_memcpy (data, ip4.as_u8, 4);
13510 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
13512 else if (unformat (i, "id_data %v", &data))
13514 else if (unformat (i, "local"))
13516 else if (unformat (i, "remote"))
13520 errmsg ("parse error '%U'", format_unformat_error, i);
13525 if (!vec_len (name))
13527 errmsg ("profile name must be specified");
13531 if (vec_len (name) > 64)
13533 errmsg ("profile name too long");
13537 if (!vec_len (data))
13539 errmsg ("id_data must be specified");
13545 errmsg ("id_type must be specified");
13549 M (IKEV2_PROFILE_SET_ID, mp);
13551 mp->is_local = is_local;
13552 mp->id_type = (u8) id_type;
13553 mp->data_len = vec_len (data);
13554 clib_memcpy (mp->name, name, vec_len (name));
13555 clib_memcpy (mp->data, data, vec_len (data));
13565 api_ikev2_profile_set_ts (vat_main_t * vam)
13567 unformat_input_t *i = vam->input;
13568 vl_api_ikev2_profile_set_ts_t *mp;
13571 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
13572 ip4_address_t start_addr, end_addr;
13574 const char *valid_chars = "a-zA-Z0-9_";
13577 start_addr.as_u32 = 0;
13578 end_addr.as_u32 = (u32) ~ 0;
13580 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13582 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13583 vec_add1 (name, 0);
13584 else if (unformat (i, "protocol %d", &proto))
13586 else if (unformat (i, "start_port %d", &start_port))
13588 else if (unformat (i, "end_port %d", &end_port))
13591 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
13593 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
13595 else if (unformat (i, "local"))
13597 else if (unformat (i, "remote"))
13601 errmsg ("parse error '%U'", format_unformat_error, i);
13606 if (!vec_len (name))
13608 errmsg ("profile name must be specified");
13612 if (vec_len (name) > 64)
13614 errmsg ("profile name too long");
13618 M (IKEV2_PROFILE_SET_TS, mp);
13620 mp->is_local = is_local;
13621 mp->proto = (u8) proto;
13622 mp->start_port = (u16) start_port;
13623 mp->end_port = (u16) end_port;
13624 mp->start_addr = start_addr.as_u32;
13625 mp->end_addr = end_addr.as_u32;
13626 clib_memcpy (mp->name, name, vec_len (name));
13635 api_ikev2_set_local_key (vat_main_t * vam)
13637 unformat_input_t *i = vam->input;
13638 vl_api_ikev2_set_local_key_t *mp;
13642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13644 if (unformat (i, "file %v", &file))
13645 vec_add1 (file, 0);
13648 errmsg ("parse error '%U'", format_unformat_error, i);
13653 if (!vec_len (file))
13655 errmsg ("RSA key file must be specified");
13659 if (vec_len (file) > 256)
13661 errmsg ("file name too long");
13665 M (IKEV2_SET_LOCAL_KEY, mp);
13667 clib_memcpy (mp->key_file, file, vec_len (file));
13676 api_ikev2_set_responder (vat_main_t * vam)
13678 unformat_input_t *i = vam->input;
13679 vl_api_ikev2_set_responder_t *mp;
13682 u32 sw_if_index = ~0;
13683 ip4_address_t address;
13685 const char *valid_chars = "a-zA-Z0-9_";
13687 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13690 (i, "%U interface %d address %U", unformat_token, valid_chars,
13691 &name, &sw_if_index, unformat_ip4_address, &address))
13692 vec_add1 (name, 0);
13695 errmsg ("parse error '%U'", format_unformat_error, i);
13700 if (!vec_len (name))
13702 errmsg ("profile name must be specified");
13706 if (vec_len (name) > 64)
13708 errmsg ("profile name too long");
13712 M (IKEV2_SET_RESPONDER, mp);
13714 clib_memcpy (mp->name, name, vec_len (name));
13717 mp->sw_if_index = sw_if_index;
13718 clib_memcpy (mp->address, &address, sizeof (address));
13726 api_ikev2_set_ike_transforms (vat_main_t * vam)
13728 unformat_input_t *i = vam->input;
13729 vl_api_ikev2_set_ike_transforms_t *mp;
13732 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13734 const char *valid_chars = "a-zA-Z0-9_";
13736 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13738 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13739 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13740 vec_add1 (name, 0);
13743 errmsg ("parse error '%U'", format_unformat_error, i);
13748 if (!vec_len (name))
13750 errmsg ("profile name must be specified");
13754 if (vec_len (name) > 64)
13756 errmsg ("profile name too long");
13760 M (IKEV2_SET_IKE_TRANSFORMS, mp);
13762 clib_memcpy (mp->name, name, vec_len (name));
13764 mp->crypto_alg = crypto_alg;
13765 mp->crypto_key_size = crypto_key_size;
13766 mp->integ_alg = integ_alg;
13767 mp->dh_group = dh_group;
13776 api_ikev2_set_esp_transforms (vat_main_t * vam)
13778 unformat_input_t *i = vam->input;
13779 vl_api_ikev2_set_esp_transforms_t *mp;
13782 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13784 const char *valid_chars = "a-zA-Z0-9_";
13786 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13788 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13789 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13790 vec_add1 (name, 0);
13793 errmsg ("parse error '%U'", format_unformat_error, i);
13798 if (!vec_len (name))
13800 errmsg ("profile name must be specified");
13804 if (vec_len (name) > 64)
13806 errmsg ("profile name too long");
13810 M (IKEV2_SET_ESP_TRANSFORMS, mp);
13812 clib_memcpy (mp->name, name, vec_len (name));
13814 mp->crypto_alg = crypto_alg;
13815 mp->crypto_key_size = crypto_key_size;
13816 mp->integ_alg = integ_alg;
13817 mp->dh_group = dh_group;
13825 api_ikev2_set_sa_lifetime (vat_main_t * vam)
13827 unformat_input_t *i = vam->input;
13828 vl_api_ikev2_set_sa_lifetime_t *mp;
13831 u64 lifetime, lifetime_maxdata;
13832 u32 lifetime_jitter, handover;
13834 const char *valid_chars = "a-zA-Z0-9_";
13836 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13838 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
13839 &lifetime, &lifetime_jitter, &handover,
13840 &lifetime_maxdata))
13841 vec_add1 (name, 0);
13844 errmsg ("parse error '%U'", format_unformat_error, i);
13849 if (!vec_len (name))
13851 errmsg ("profile name must be specified");
13855 if (vec_len (name) > 64)
13857 errmsg ("profile name too long");
13861 M (IKEV2_SET_SA_LIFETIME, mp);
13863 clib_memcpy (mp->name, name, vec_len (name));
13865 mp->lifetime = lifetime;
13866 mp->lifetime_jitter = lifetime_jitter;
13867 mp->handover = handover;
13868 mp->lifetime_maxdata = lifetime_maxdata;
13876 api_ikev2_initiate_sa_init (vat_main_t * vam)
13878 unformat_input_t *i = vam->input;
13879 vl_api_ikev2_initiate_sa_init_t *mp;
13883 const char *valid_chars = "a-zA-Z0-9_";
13885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13887 if (unformat (i, "%U", unformat_token, valid_chars, &name))
13888 vec_add1 (name, 0);
13891 errmsg ("parse error '%U'", format_unformat_error, i);
13896 if (!vec_len (name))
13898 errmsg ("profile name must be specified");
13902 if (vec_len (name) > 64)
13904 errmsg ("profile name too long");
13908 M (IKEV2_INITIATE_SA_INIT, mp);
13910 clib_memcpy (mp->name, name, vec_len (name));
13919 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
13921 unformat_input_t *i = vam->input;
13922 vl_api_ikev2_initiate_del_ike_sa_t *mp;
13927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13929 if (unformat (i, "%lx", &ispi))
13933 errmsg ("parse error '%U'", format_unformat_error, i);
13938 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
13948 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13950 unformat_input_t *i = vam->input;
13951 vl_api_ikev2_initiate_del_child_sa_t *mp;
13956 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13958 if (unformat (i, "%x", &ispi))
13962 errmsg ("parse error '%U'", format_unformat_error, i);
13967 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13977 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13979 unformat_input_t *i = vam->input;
13980 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13985 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13987 if (unformat (i, "%x", &ispi))
13991 errmsg ("parse error '%U'", format_unformat_error, i);
13996 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
14009 api_map_add_domain (vat_main_t * vam)
14011 unformat_input_t *i = vam->input;
14012 vl_api_map_add_domain_t *mp;
14014 ip4_address_t ip4_prefix;
14015 ip6_address_t ip6_prefix;
14016 ip6_address_t ip6_src;
14017 u32 num_m_args = 0;
14018 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
14019 0, psid_length = 0;
14020 u8 is_translation = 0;
14022 u32 ip6_src_len = 128;
14025 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14027 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
14028 &ip4_prefix, &ip4_prefix_len))
14030 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
14031 &ip6_prefix, &ip6_prefix_len))
14035 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
14038 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
14040 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
14042 else if (unformat (i, "psid-offset %d", &psid_offset))
14044 else if (unformat (i, "psid-len %d", &psid_length))
14046 else if (unformat (i, "mtu %d", &mtu))
14048 else if (unformat (i, "map-t"))
14049 is_translation = 1;
14052 clib_warning ("parse error '%U'", format_unformat_error, i);
14057 if (num_m_args < 3)
14059 errmsg ("mandatory argument(s) missing");
14063 /* Construct the API message */
14064 M (MAP_ADD_DOMAIN, mp);
14066 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
14067 mp->ip4_prefix_len = ip4_prefix_len;
14069 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
14070 mp->ip6_prefix_len = ip6_prefix_len;
14072 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
14073 mp->ip6_src_prefix_len = ip6_src_len;
14075 mp->ea_bits_len = ea_bits_len;
14076 mp->psid_offset = psid_offset;
14077 mp->psid_length = psid_length;
14078 mp->is_translation = is_translation;
14079 mp->mtu = htons (mtu);
14084 /* Wait for a reply, return good/bad news */
14090 api_map_del_domain (vat_main_t * vam)
14092 unformat_input_t *i = vam->input;
14093 vl_api_map_del_domain_t *mp;
14095 u32 num_m_args = 0;
14099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14101 if (unformat (i, "index %d", &index))
14105 clib_warning ("parse error '%U'", format_unformat_error, i);
14110 if (num_m_args != 1)
14112 errmsg ("mandatory argument(s) missing");
14116 /* Construct the API message */
14117 M (MAP_DEL_DOMAIN, mp);
14119 mp->index = ntohl (index);
14124 /* Wait for a reply, return good/bad news */
14130 api_map_add_del_rule (vat_main_t * vam)
14132 unformat_input_t *i = vam->input;
14133 vl_api_map_add_del_rule_t *mp;
14135 ip6_address_t ip6_dst;
14136 u32 num_m_args = 0, index, psid = 0;
14139 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14141 if (unformat (i, "index %d", &index))
14143 else if (unformat (i, "psid %d", &psid))
14145 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
14147 else if (unformat (i, "del"))
14153 clib_warning ("parse error '%U'", format_unformat_error, i);
14158 /* Construct the API message */
14159 M (MAP_ADD_DEL_RULE, mp);
14161 mp->index = ntohl (index);
14162 mp->is_add = is_add;
14163 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
14164 mp->psid = ntohs (psid);
14169 /* Wait for a reply, return good/bad news */
14175 api_map_domain_dump (vat_main_t * vam)
14177 vl_api_map_domain_dump_t *mp;
14178 vl_api_control_ping_t *mp_ping;
14181 /* Construct the API message */
14182 M (MAP_DOMAIN_DUMP, mp);
14187 /* Use a control ping for synchronization */
14188 M (CONTROL_PING, mp_ping);
14196 api_map_rule_dump (vat_main_t * vam)
14198 unformat_input_t *i = vam->input;
14199 vl_api_map_rule_dump_t *mp;
14200 vl_api_control_ping_t *mp_ping;
14201 u32 domain_index = ~0;
14204 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14206 if (unformat (i, "index %u", &domain_index))
14212 if (domain_index == ~0)
14214 clib_warning ("parse error: domain index expected");
14218 /* Construct the API message */
14219 M (MAP_RULE_DUMP, mp);
14221 mp->domain_index = htonl (domain_index);
14226 /* Use a control ping for synchronization */
14227 M (CONTROL_PING, mp_ping);
14234 static void vl_api_map_add_domain_reply_t_handler
14235 (vl_api_map_add_domain_reply_t * mp)
14237 vat_main_t *vam = &vat_main;
14238 i32 retval = ntohl (mp->retval);
14240 if (vam->async_mode)
14242 vam->async_errors += (retval < 0);
14246 vam->retval = retval;
14247 vam->result_ready = 1;
14251 static void vl_api_map_add_domain_reply_t_handler_json
14252 (vl_api_map_add_domain_reply_t * mp)
14254 vat_main_t *vam = &vat_main;
14255 vat_json_node_t node;
14257 vat_json_init_object (&node);
14258 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
14259 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
14261 vat_json_print (vam->ofp, &node);
14262 vat_json_free (&node);
14264 vam->retval = ntohl (mp->retval);
14265 vam->result_ready = 1;
14269 api_get_first_msg_id (vat_main_t * vam)
14271 vl_api_get_first_msg_id_t *mp;
14272 unformat_input_t *i = vam->input;
14277 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14279 if (unformat (i, "client %s", &name))
14287 errmsg ("missing client name");
14290 vec_add1 (name, 0);
14292 if (vec_len (name) > 63)
14294 errmsg ("client name too long");
14298 M (GET_FIRST_MSG_ID, mp);
14299 clib_memcpy (mp->name, name, vec_len (name));
14306 api_cop_interface_enable_disable (vat_main_t * vam)
14308 unformat_input_t *line_input = vam->input;
14309 vl_api_cop_interface_enable_disable_t *mp;
14310 u32 sw_if_index = ~0;
14311 u8 enable_disable = 1;
14314 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14316 if (unformat (line_input, "disable"))
14317 enable_disable = 0;
14318 if (unformat (line_input, "enable"))
14319 enable_disable = 1;
14320 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14321 vam, &sw_if_index))
14323 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14329 if (sw_if_index == ~0)
14331 errmsg ("missing interface name or sw_if_index");
14335 /* Construct the API message */
14336 M (COP_INTERFACE_ENABLE_DISABLE, mp);
14337 mp->sw_if_index = ntohl (sw_if_index);
14338 mp->enable_disable = enable_disable;
14342 /* Wait for the reply */
14348 api_cop_whitelist_enable_disable (vat_main_t * vam)
14350 unformat_input_t *line_input = vam->input;
14351 vl_api_cop_whitelist_enable_disable_t *mp;
14352 u32 sw_if_index = ~0;
14353 u8 ip4 = 0, ip6 = 0, default_cop = 0;
14357 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14359 if (unformat (line_input, "ip4"))
14361 else if (unformat (line_input, "ip6"))
14363 else if (unformat (line_input, "default"))
14365 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14366 vam, &sw_if_index))
14368 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14370 else if (unformat (line_input, "fib-id %d", &fib_id))
14376 if (sw_if_index == ~0)
14378 errmsg ("missing interface name or sw_if_index");
14382 /* Construct the API message */
14383 M (COP_WHITELIST_ENABLE_DISABLE, mp);
14384 mp->sw_if_index = ntohl (sw_if_index);
14385 mp->fib_id = ntohl (fib_id);
14388 mp->default_cop = default_cop;
14392 /* Wait for the reply */
14398 api_get_node_graph (vat_main_t * vam)
14400 vl_api_get_node_graph_t *mp;
14403 M (GET_NODE_GRAPH, mp);
14407 /* Wait for the reply */
14413 /** Used for parsing LISP eids */
14414 typedef CLIB_PACKED(struct{
14415 u8 addr[16]; /**< eid address */
14416 u32 len; /**< prefix length if IP */
14417 u8 type; /**< type of eid */
14422 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14424 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14426 memset (a, 0, sizeof (a[0]));
14428 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
14430 a->type = 0; /* ipv4 type */
14432 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
14434 a->type = 1; /* ipv6 type */
14436 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
14438 a->type = 2; /* mac type */
14440 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
14442 a->type = 3; /* NSH type */
14443 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
14444 nsh->spi = clib_host_to_net_u32 (nsh->spi);
14451 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
14460 lisp_eid_size_vat (u8 type)
14477 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
14479 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
14483 api_one_add_del_locator_set (vat_main_t * vam)
14485 unformat_input_t *input = vam->input;
14486 vl_api_one_add_del_locator_set_t *mp;
14488 u8 *locator_set_name = NULL;
14489 u8 locator_set_name_set = 0;
14490 vl_api_local_locator_t locator, *locators = 0;
14491 u32 sw_if_index, priority, weight;
14495 /* Parse args required to build the message */
14496 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14498 if (unformat (input, "del"))
14502 else if (unformat (input, "locator-set %s", &locator_set_name))
14504 locator_set_name_set = 1;
14506 else if (unformat (input, "sw_if_index %u p %u w %u",
14507 &sw_if_index, &priority, &weight))
14509 locator.sw_if_index = htonl (sw_if_index);
14510 locator.priority = priority;
14511 locator.weight = weight;
14512 vec_add1 (locators, locator);
14516 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14517 &sw_if_index, &priority, &weight))
14519 locator.sw_if_index = htonl (sw_if_index);
14520 locator.priority = priority;
14521 locator.weight = weight;
14522 vec_add1 (locators, locator);
14528 if (locator_set_name_set == 0)
14530 errmsg ("missing locator-set name");
14531 vec_free (locators);
14535 if (vec_len (locator_set_name) > 64)
14537 errmsg ("locator-set name too long");
14538 vec_free (locator_set_name);
14539 vec_free (locators);
14542 vec_add1 (locator_set_name, 0);
14544 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14546 /* Construct the API message */
14547 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14549 mp->is_add = is_add;
14550 clib_memcpy (mp->locator_set_name, locator_set_name,
14551 vec_len (locator_set_name));
14552 vec_free (locator_set_name);
14554 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14556 clib_memcpy (mp->locators, locators, data_len);
14557 vec_free (locators);
14562 /* Wait for a reply... */
14567 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14570 api_one_add_del_locator (vat_main_t * vam)
14572 unformat_input_t *input = vam->input;
14573 vl_api_one_add_del_locator_t *mp;
14574 u32 tmp_if_index = ~0;
14575 u32 sw_if_index = ~0;
14576 u8 sw_if_index_set = 0;
14577 u8 sw_if_index_if_name_set = 0;
14579 u8 priority_set = 0;
14583 u8 *locator_set_name = NULL;
14584 u8 locator_set_name_set = 0;
14587 /* Parse args required to build the message */
14588 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14590 if (unformat (input, "del"))
14594 else if (unformat (input, "locator-set %s", &locator_set_name))
14596 locator_set_name_set = 1;
14598 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14601 sw_if_index_if_name_set = 1;
14602 sw_if_index = tmp_if_index;
14604 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14606 sw_if_index_set = 1;
14607 sw_if_index = tmp_if_index;
14609 else if (unformat (input, "p %d", &priority))
14613 else if (unformat (input, "w %d", &weight))
14621 if (locator_set_name_set == 0)
14623 errmsg ("missing locator-set name");
14627 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14629 errmsg ("missing sw_if_index");
14630 vec_free (locator_set_name);
14634 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14636 errmsg ("cannot use both params interface name and sw_if_index");
14637 vec_free (locator_set_name);
14641 if (priority_set == 0)
14643 errmsg ("missing locator-set priority");
14644 vec_free (locator_set_name);
14648 if (weight_set == 0)
14650 errmsg ("missing locator-set weight");
14651 vec_free (locator_set_name);
14655 if (vec_len (locator_set_name) > 64)
14657 errmsg ("locator-set name too long");
14658 vec_free (locator_set_name);
14661 vec_add1 (locator_set_name, 0);
14663 /* Construct the API message */
14664 M (ONE_ADD_DEL_LOCATOR, mp);
14666 mp->is_add = is_add;
14667 mp->sw_if_index = ntohl (sw_if_index);
14668 mp->priority = priority;
14669 mp->weight = weight;
14670 clib_memcpy (mp->locator_set_name, locator_set_name,
14671 vec_len (locator_set_name));
14672 vec_free (locator_set_name);
14677 /* Wait for a reply... */
14682 #define api_lisp_add_del_locator api_one_add_del_locator
14685 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14687 u32 *key_id = va_arg (*args, u32 *);
14690 if (unformat (input, "%s", &s))
14692 if (!strcmp ((char *) s, "sha1"))
14693 key_id[0] = HMAC_SHA_1_96;
14694 else if (!strcmp ((char *) s, "sha256"))
14695 key_id[0] = HMAC_SHA_256_128;
14698 clib_warning ("invalid key_id: '%s'", s);
14699 key_id[0] = HMAC_NO_KEY;
14710 api_one_add_del_local_eid (vat_main_t * vam)
14712 unformat_input_t *input = vam->input;
14713 vl_api_one_add_del_local_eid_t *mp;
14716 lisp_eid_vat_t _eid, *eid = &_eid;
14717 u8 *locator_set_name = 0;
14718 u8 locator_set_name_set = 0;
14724 /* Parse args required to build the message */
14725 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14727 if (unformat (input, "del"))
14731 else if (unformat (input, "vni %d", &vni))
14735 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14739 else if (unformat (input, "locator-set %s", &locator_set_name))
14741 locator_set_name_set = 1;
14743 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14745 else if (unformat (input, "secret-key %_%v%_", &key))
14751 if (locator_set_name_set == 0)
14753 errmsg ("missing locator-set name");
14759 errmsg ("EID address not set!");
14760 vec_free (locator_set_name);
14764 if (key && (0 == key_id))
14766 errmsg ("invalid key_id!");
14770 if (vec_len (key) > 64)
14772 errmsg ("key too long");
14777 if (vec_len (locator_set_name) > 64)
14779 errmsg ("locator-set name too long");
14780 vec_free (locator_set_name);
14783 vec_add1 (locator_set_name, 0);
14785 /* Construct the API message */
14786 M (ONE_ADD_DEL_LOCAL_EID, mp);
14788 mp->is_add = is_add;
14789 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14790 mp->eid_type = eid->type;
14791 mp->prefix_len = eid->len;
14792 mp->vni = clib_host_to_net_u32 (vni);
14793 mp->key_id = clib_host_to_net_u16 (key_id);
14794 clib_memcpy (mp->locator_set_name, locator_set_name,
14795 vec_len (locator_set_name));
14796 clib_memcpy (mp->key, key, vec_len (key));
14798 vec_free (locator_set_name);
14804 /* Wait for a reply... */
14809 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14812 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14814 u32 dp_table = 0, vni = 0;;
14815 unformat_input_t *input = vam->input;
14816 vl_api_gpe_add_del_fwd_entry_t *mp;
14818 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14819 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14820 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14821 u32 action = ~0, w;
14822 ip4_address_t rmt_rloc4, lcl_rloc4;
14823 ip6_address_t rmt_rloc6, lcl_rloc6;
14824 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14827 memset (&rloc, 0, sizeof (rloc));
14829 /* Parse args required to build the message */
14830 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14832 if (unformat (input, "del"))
14834 else if (unformat (input, "add"))
14836 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14840 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14844 else if (unformat (input, "vrf %d", &dp_table))
14846 else if (unformat (input, "bd %d", &dp_table))
14848 else if (unformat (input, "vni %d", &vni))
14850 else if (unformat (input, "w %d", &w))
14854 errmsg ("No RLOC configured for setting priority/weight!");
14857 curr_rloc->weight = w;
14859 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14860 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14864 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
14866 vec_add1 (lcl_locs, rloc);
14868 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
14869 vec_add1 (rmt_locs, rloc);
14870 /* weight saved in rmt loc */
14871 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14873 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14874 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14877 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
14879 vec_add1 (lcl_locs, rloc);
14881 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
14882 vec_add1 (rmt_locs, rloc);
14883 /* weight saved in rmt loc */
14884 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14886 else if (unformat (input, "action %d", &action))
14892 clib_warning ("parse error '%U'", format_unformat_error, input);
14899 errmsg ("remote eid addresses not set");
14903 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14905 errmsg ("eid types don't match");
14909 if (0 == rmt_locs && (u32) ~ 0 == action)
14911 errmsg ("action not set for negative mapping");
14915 /* Construct the API message */
14916 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14917 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14919 mp->is_add = is_add;
14920 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14921 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14922 mp->eid_type = rmt_eid->type;
14923 mp->dp_table = clib_host_to_net_u32 (dp_table);
14924 mp->vni = clib_host_to_net_u32 (vni);
14925 mp->rmt_len = rmt_eid->len;
14926 mp->lcl_len = lcl_eid->len;
14927 mp->action = action;
14929 if (0 != rmt_locs && 0 != lcl_locs)
14931 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14932 clib_memcpy (mp->locs, lcl_locs,
14933 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14935 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14936 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14937 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14939 vec_free (lcl_locs);
14940 vec_free (rmt_locs);
14945 /* Wait for a reply... */
14951 api_one_add_del_map_server (vat_main_t * vam)
14953 unformat_input_t *input = vam->input;
14954 vl_api_one_add_del_map_server_t *mp;
14958 ip4_address_t ipv4;
14959 ip6_address_t ipv6;
14962 /* Parse args required to build the message */
14963 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14965 if (unformat (input, "del"))
14969 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14973 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14981 if (ipv4_set && ipv6_set)
14983 errmsg ("both eid v4 and v6 addresses set");
14987 if (!ipv4_set && !ipv6_set)
14989 errmsg ("eid addresses not set");
14993 /* Construct the API message */
14994 M (ONE_ADD_DEL_MAP_SERVER, mp);
14996 mp->is_add = is_add;
15000 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15005 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15011 /* Wait for a reply... */
15016 #define api_lisp_add_del_map_server api_one_add_del_map_server
15019 api_one_add_del_map_resolver (vat_main_t * vam)
15021 unformat_input_t *input = vam->input;
15022 vl_api_one_add_del_map_resolver_t *mp;
15026 ip4_address_t ipv4;
15027 ip6_address_t ipv6;
15030 /* Parse args required to build the message */
15031 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15033 if (unformat (input, "del"))
15037 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15041 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15049 if (ipv4_set && ipv6_set)
15051 errmsg ("both eid v4 and v6 addresses set");
15055 if (!ipv4_set && !ipv6_set)
15057 errmsg ("eid addresses not set");
15061 /* Construct the API message */
15062 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15064 mp->is_add = is_add;
15068 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15073 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15079 /* Wait for a reply... */
15084 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
15087 api_lisp_gpe_enable_disable (vat_main_t * vam)
15089 unformat_input_t *input = vam->input;
15090 vl_api_gpe_enable_disable_t *mp;
15095 /* Parse args required to build the message */
15096 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15098 if (unformat (input, "enable"))
15103 else if (unformat (input, "disable"))
15114 errmsg ("Value not set");
15118 /* Construct the API message */
15119 M (GPE_ENABLE_DISABLE, mp);
15126 /* Wait for a reply... */
15132 api_one_rloc_probe_enable_disable (vat_main_t * vam)
15134 unformat_input_t *input = vam->input;
15135 vl_api_one_rloc_probe_enable_disable_t *mp;
15140 /* Parse args required to build the message */
15141 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15143 if (unformat (input, "enable"))
15148 else if (unformat (input, "disable"))
15156 errmsg ("Value not set");
15160 /* Construct the API message */
15161 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15163 mp->is_enabled = is_en;
15168 /* Wait for a reply... */
15173 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15176 api_one_map_register_enable_disable (vat_main_t * vam)
15178 unformat_input_t *input = vam->input;
15179 vl_api_one_map_register_enable_disable_t *mp;
15184 /* Parse args required to build the message */
15185 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15187 if (unformat (input, "enable"))
15192 else if (unformat (input, "disable"))
15200 errmsg ("Value not set");
15204 /* Construct the API message */
15205 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15207 mp->is_enabled = is_en;
15212 /* Wait for a reply... */
15217 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15220 api_one_enable_disable (vat_main_t * vam)
15222 unformat_input_t *input = vam->input;
15223 vl_api_one_enable_disable_t *mp;
15228 /* Parse args required to build the message */
15229 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15231 if (unformat (input, "enable"))
15236 else if (unformat (input, "disable"))
15246 errmsg ("Value not set");
15250 /* Construct the API message */
15251 M (ONE_ENABLE_DISABLE, mp);
15258 /* Wait for a reply... */
15263 #define api_lisp_enable_disable api_one_enable_disable
15266 api_show_one_map_register_state (vat_main_t * vam)
15268 vl_api_show_one_map_register_state_t *mp;
15271 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
15276 /* wait for reply */
15281 #define api_show_lisp_map_register_state api_show_one_map_register_state
15284 api_show_one_rloc_probe_state (vat_main_t * vam)
15286 vl_api_show_one_rloc_probe_state_t *mp;
15289 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
15294 /* wait for reply */
15299 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
15302 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15304 vl_api_one_add_del_l2_arp_entry_t *mp;
15305 unformat_input_t *input = vam->input;
15310 u8 mac[6] = { 0, };
15311 u32 ip4 = 0, bd = ~0;
15314 /* Parse args required to build the message */
15315 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15317 if (unformat (input, "del"))
15319 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15321 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15323 else if (unformat (input, "bd %d", &bd))
15327 errmsg ("parse error '%U'", format_unformat_error, input);
15332 if (!bd_set || !ip_set || (!mac_set && is_add))
15334 errmsg ("Missing BD, IP or MAC!");
15338 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15339 mp->is_add = is_add;
15340 clib_memcpy (mp->mac, mac, 6);
15341 mp->bd = clib_host_to_net_u32 (bd);
15347 /* wait for reply */
15353 api_one_l2_arp_bd_get (vat_main_t * vam)
15355 vl_api_one_l2_arp_bd_get_t *mp;
15358 M (ONE_L2_ARP_BD_GET, mp);
15363 /* wait for reply */
15369 api_one_l2_arp_entries_get (vat_main_t * vam)
15371 vl_api_one_l2_arp_entries_get_t *mp;
15372 unformat_input_t *input = vam->input;
15377 /* Parse args required to build the message */
15378 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15380 if (unformat (input, "bd %d", &bd))
15384 errmsg ("parse error '%U'", format_unformat_error, input);
15391 errmsg ("Expected bridge domain!");
15395 M (ONE_L2_ARP_ENTRIES_GET, mp);
15396 mp->bd = clib_host_to_net_u32 (bd);
15401 /* wait for reply */
15407 api_one_stats_enable_disable (vat_main_t * vam)
15409 vl_api_one_stats_enable_disable_t *mp;
15410 unformat_input_t *input = vam->input;
15415 /* Parse args required to build the message */
15416 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15418 if (unformat (input, "enable"))
15423 else if (unformat (input, "disable"))
15433 errmsg ("Value not set");
15437 M (ONE_STATS_ENABLE_DISABLE, mp);
15443 /* wait for reply */
15449 api_show_one_stats_enable_disable (vat_main_t * vam)
15451 vl_api_show_one_stats_enable_disable_t *mp;
15454 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
15459 /* wait for reply */
15465 api_show_one_map_request_mode (vat_main_t * vam)
15467 vl_api_show_one_map_request_mode_t *mp;
15470 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
15475 /* wait for reply */
15480 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
15483 api_one_map_request_mode (vat_main_t * vam)
15485 unformat_input_t *input = vam->input;
15486 vl_api_one_map_request_mode_t *mp;
15490 /* Parse args required to build the message */
15491 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15493 if (unformat (input, "dst-only"))
15495 else if (unformat (input, "src-dst"))
15499 errmsg ("parse error '%U'", format_unformat_error, input);
15504 M (ONE_MAP_REQUEST_MODE, mp);
15511 /* wait for reply */
15516 #define api_lisp_map_request_mode api_one_map_request_mode
15519 * Enable/disable ONE proxy ITR.
15521 * @param vam vpp API test context
15522 * @return return code
15525 api_one_pitr_set_locator_set (vat_main_t * vam)
15527 u8 ls_name_set = 0;
15528 unformat_input_t *input = vam->input;
15529 vl_api_one_pitr_set_locator_set_t *mp;
15534 /* Parse args required to build the message */
15535 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15537 if (unformat (input, "del"))
15539 else if (unformat (input, "locator-set %s", &ls_name))
15543 errmsg ("parse error '%U'", format_unformat_error, input);
15550 errmsg ("locator-set name not set!");
15554 M (ONE_PITR_SET_LOCATOR_SET, mp);
15556 mp->is_add = is_add;
15557 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15558 vec_free (ls_name);
15563 /* wait for reply */
15568 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
15571 api_one_nsh_set_locator_set (vat_main_t * vam)
15573 u8 ls_name_set = 0;
15574 unformat_input_t *input = vam->input;
15575 vl_api_one_nsh_set_locator_set_t *mp;
15580 /* Parse args required to build the message */
15581 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15583 if (unformat (input, "del"))
15585 else if (unformat (input, "ls %s", &ls_name))
15589 errmsg ("parse error '%U'", format_unformat_error, input);
15594 if (!ls_name_set && is_add)
15596 errmsg ("locator-set name not set!");
15600 M (ONE_NSH_SET_LOCATOR_SET, mp);
15602 mp->is_add = is_add;
15603 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15604 vec_free (ls_name);
15609 /* wait for reply */
15615 api_show_one_pitr (vat_main_t * vam)
15617 vl_api_show_one_pitr_t *mp;
15620 if (!vam->json_output)
15622 print (vam->ofp, "%=20s", "lisp status:");
15625 M (SHOW_ONE_PITR, mp);
15629 /* Wait for a reply... */
15634 #define api_show_lisp_pitr api_show_one_pitr
15637 api_one_use_petr (vat_main_t * vam)
15639 unformat_input_t *input = vam->input;
15640 vl_api_one_use_petr_t *mp;
15645 memset (&ip, 0, sizeof (ip));
15647 /* Parse args required to build the message */
15648 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15650 if (unformat (input, "disable"))
15653 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
15656 ip_addr_version (&ip) = IP4;
15659 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
15662 ip_addr_version (&ip) = IP6;
15666 errmsg ("parse error '%U'", format_unformat_error, input);
15671 M (ONE_USE_PETR, mp);
15673 mp->is_add = is_add;
15676 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
15678 clib_memcpy (mp->address, &ip, 4);
15680 clib_memcpy (mp->address, &ip, 16);
15686 /* wait for reply */
15691 #define api_lisp_use_petr api_one_use_petr
15694 api_show_one_nsh_mapping (vat_main_t * vam)
15696 vl_api_show_one_use_petr_t *mp;
15699 if (!vam->json_output)
15701 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
15704 M (SHOW_ONE_NSH_MAPPING, mp);
15708 /* Wait for a reply... */
15714 api_show_one_use_petr (vat_main_t * vam)
15716 vl_api_show_one_use_petr_t *mp;
15719 if (!vam->json_output)
15721 print (vam->ofp, "%=20s", "Proxy-ETR status:");
15724 M (SHOW_ONE_USE_PETR, mp);
15728 /* Wait for a reply... */
15733 #define api_show_lisp_use_petr api_show_one_use_petr
15736 * Add/delete mapping between vni and vrf
15739 api_one_eid_table_add_del_map (vat_main_t * vam)
15741 unformat_input_t *input = vam->input;
15742 vl_api_one_eid_table_add_del_map_t *mp;
15743 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15744 u32 vni, vrf, bd_index;
15747 /* Parse args required to build the message */
15748 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15750 if (unformat (input, "del"))
15752 else if (unformat (input, "vrf %d", &vrf))
15754 else if (unformat (input, "bd_index %d", &bd_index))
15756 else if (unformat (input, "vni %d", &vni))
15762 if (!vni_set || (!vrf_set && !bd_index_set))
15764 errmsg ("missing arguments!");
15768 if (vrf_set && bd_index_set)
15770 errmsg ("error: both vrf and bd entered!");
15774 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15776 mp->is_add = is_add;
15777 mp->vni = htonl (vni);
15778 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15779 mp->is_l2 = bd_index_set;
15784 /* wait for reply */
15789 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15792 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15794 u32 *action = va_arg (*args, u32 *);
15797 if (unformat (input, "%s", &s))
15799 if (!strcmp ((char *) s, "no-action"))
15801 else if (!strcmp ((char *) s, "natively-forward"))
15803 else if (!strcmp ((char *) s, "send-map-request"))
15805 else if (!strcmp ((char *) s, "drop"))
15809 clib_warning ("invalid action: '%s'", s);
15821 * Add/del remote mapping to/from ONE control plane
15823 * @param vam vpp API test context
15824 * @return return code
15827 api_one_add_del_remote_mapping (vat_main_t * vam)
15829 unformat_input_t *input = vam->input;
15830 vl_api_one_add_del_remote_mapping_t *mp;
15832 lisp_eid_vat_t _eid, *eid = &_eid;
15833 lisp_eid_vat_t _seid, *seid = &_seid;
15834 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15835 u32 action = ~0, p, w, data_len;
15836 ip4_address_t rloc4;
15837 ip6_address_t rloc6;
15838 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15841 memset (&rloc, 0, sizeof (rloc));
15843 /* Parse args required to build the message */
15844 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15846 if (unformat (input, "del-all"))
15850 else if (unformat (input, "del"))
15854 else if (unformat (input, "add"))
15858 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15862 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15866 else if (unformat (input, "vni %d", &vni))
15870 else if (unformat (input, "p %d w %d", &p, &w))
15874 errmsg ("No RLOC configured for setting priority/weight!");
15877 curr_rloc->priority = p;
15878 curr_rloc->weight = w;
15880 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15883 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
15884 vec_add1 (rlocs, rloc);
15885 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15887 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15890 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
15891 vec_add1 (rlocs, rloc);
15892 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15894 else if (unformat (input, "action %U",
15895 unformat_negative_mapping_action, &action))
15901 clib_warning ("parse error '%U'", format_unformat_error, input);
15908 errmsg ("missing params!");
15912 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15914 errmsg ("no action set for negative map-reply!");
15918 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15920 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15921 mp->is_add = is_add;
15922 mp->vni = htonl (vni);
15923 mp->action = (u8) action;
15924 mp->is_src_dst = seid_set;
15925 mp->eid_len = eid->len;
15926 mp->seid_len = seid->len;
15927 mp->del_all = del_all;
15928 mp->eid_type = eid->type;
15929 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15930 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
15932 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15933 clib_memcpy (mp->rlocs, rlocs, data_len);
15939 /* Wait for a reply... */
15944 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15947 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15948 * forwarding entries in data-plane accordingly.
15950 * @param vam vpp API test context
15951 * @return return code
15954 api_one_add_del_adjacency (vat_main_t * vam)
15956 unformat_input_t *input = vam->input;
15957 vl_api_one_add_del_adjacency_t *mp;
15959 ip4_address_t leid4, reid4;
15960 ip6_address_t leid6, reid6;
15961 u8 reid_mac[6] = { 0 };
15962 u8 leid_mac[6] = { 0 };
15963 u8 reid_type, leid_type;
15964 u32 leid_len = 0, reid_len = 0, len;
15968 leid_type = reid_type = (u8) ~ 0;
15970 /* Parse args required to build the message */
15971 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15973 if (unformat (input, "del"))
15977 else if (unformat (input, "add"))
15981 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
15984 reid_type = 0; /* ipv4 */
15987 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
15990 reid_type = 1; /* ipv6 */
15993 else if (unformat (input, "reid %U", unformat_ethernet_address,
15996 reid_type = 2; /* mac */
15998 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
16001 leid_type = 0; /* ipv4 */
16004 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
16007 leid_type = 1; /* ipv6 */
16010 else if (unformat (input, "leid %U", unformat_ethernet_address,
16013 leid_type = 2; /* mac */
16015 else if (unformat (input, "vni %d", &vni))
16021 errmsg ("parse error '%U'", format_unformat_error, input);
16026 if ((u8) ~ 0 == reid_type)
16028 errmsg ("missing params!");
16032 if (leid_type != reid_type)
16034 errmsg ("remote and local EIDs are of different types!");
16038 M (ONE_ADD_DEL_ADJACENCY, mp);
16039 mp->is_add = is_add;
16040 mp->vni = htonl (vni);
16041 mp->leid_len = leid_len;
16042 mp->reid_len = reid_len;
16043 mp->eid_type = reid_type;
16045 switch (mp->eid_type)
16048 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
16049 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
16052 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
16053 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
16056 clib_memcpy (mp->leid, leid_mac, 6);
16057 clib_memcpy (mp->reid, reid_mac, 6);
16060 errmsg ("unknown EID type %d!", mp->eid_type);
16067 /* Wait for a reply... */
16072 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
16075 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
16077 u32 *mode = va_arg (*args, u32 *);
16079 if (unformat (input, "lisp"))
16081 else if (unformat (input, "vxlan"))
16090 api_gpe_get_encap_mode (vat_main_t * vam)
16092 vl_api_gpe_get_encap_mode_t *mp;
16095 /* Construct the API message */
16096 M (GPE_GET_ENCAP_MODE, mp);
16101 /* Wait for a reply... */
16107 api_gpe_set_encap_mode (vat_main_t * vam)
16109 unformat_input_t *input = vam->input;
16110 vl_api_gpe_set_encap_mode_t *mp;
16114 /* Parse args required to build the message */
16115 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16117 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
16123 /* Construct the API message */
16124 M (GPE_SET_ENCAP_MODE, mp);
16131 /* Wait for a reply... */
16137 api_lisp_gpe_add_del_iface (vat_main_t * vam)
16139 unformat_input_t *input = vam->input;
16140 vl_api_gpe_add_del_iface_t *mp;
16141 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
16142 u32 dp_table = 0, vni = 0;
16145 /* Parse args required to build the message */
16146 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16148 if (unformat (input, "up"))
16153 else if (unformat (input, "down"))
16158 else if (unformat (input, "table_id %d", &dp_table))
16162 else if (unformat (input, "bd_id %d", &dp_table))
16167 else if (unformat (input, "vni %d", &vni))
16175 if (action_set == 0)
16177 errmsg ("Action not set");
16180 if (dp_table_set == 0 || vni_set == 0)
16182 errmsg ("vni and dp_table must be set");
16186 /* Construct the API message */
16187 M (GPE_ADD_DEL_IFACE, mp);
16189 mp->is_add = is_add;
16190 mp->dp_table = clib_host_to_net_u32 (dp_table);
16192 mp->vni = clib_host_to_net_u32 (vni);
16197 /* Wait for a reply... */
16203 api_one_map_register_fallback_threshold (vat_main_t * vam)
16205 unformat_input_t *input = vam->input;
16206 vl_api_one_map_register_fallback_threshold_t *mp;
16211 /* Parse args required to build the message */
16212 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16214 if (unformat (input, "%u", &value))
16218 clib_warning ("parse error '%U'", format_unformat_error, input);
16225 errmsg ("fallback threshold value is missing!");
16229 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16230 mp->value = clib_host_to_net_u32 (value);
16235 /* Wait for a reply... */
16241 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
16243 vl_api_show_one_map_register_fallback_threshold_t *mp;
16246 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16251 /* Wait for a reply... */
16257 api_one_map_register_set_ttl (vat_main_t * vam)
16259 unformat_input_t *input = vam->input;
16260 vl_api_one_map_register_set_ttl_t *mp;
16265 /* Parse args required to build the message */
16266 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16268 if (unformat (input, "%u", &ttl))
16272 clib_warning ("parse error '%U'", format_unformat_error, input);
16279 errmsg ("TTL value missing!");
16283 M (ONE_MAP_REGISTER_SET_TTL, mp);
16284 mp->ttl = clib_host_to_net_u32 (ttl);
16289 /* Wait for a reply... */
16295 api_show_one_map_register_ttl (vat_main_t * vam)
16297 vl_api_show_one_map_register_ttl_t *mp;
16300 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
16305 /* Wait for a reply... */
16311 * Add/del map request itr rlocs from ONE control plane and updates
16313 * @param vam vpp API test context
16314 * @return return code
16317 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
16319 unformat_input_t *input = vam->input;
16320 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
16321 u8 *locator_set_name = 0;
16322 u8 locator_set_name_set = 0;
16326 /* Parse args required to build the message */
16327 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16329 if (unformat (input, "del"))
16333 else if (unformat (input, "%_%v%_", &locator_set_name))
16335 locator_set_name_set = 1;
16339 clib_warning ("parse error '%U'", format_unformat_error, input);
16344 if (is_add && !locator_set_name_set)
16346 errmsg ("itr-rloc is not set!");
16350 if (is_add && vec_len (locator_set_name) > 64)
16352 errmsg ("itr-rloc locator-set name too long");
16353 vec_free (locator_set_name);
16357 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
16358 mp->is_add = is_add;
16361 clib_memcpy (mp->locator_set_name, locator_set_name,
16362 vec_len (locator_set_name));
16366 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
16368 vec_free (locator_set_name);
16373 /* Wait for a reply... */
16378 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
16381 api_one_locator_dump (vat_main_t * vam)
16383 unformat_input_t *input = vam->input;
16384 vl_api_one_locator_dump_t *mp;
16385 vl_api_control_ping_t *mp_ping;
16386 u8 is_index_set = 0, is_name_set = 0;
16391 /* Parse args required to build the message */
16392 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16394 if (unformat (input, "ls_name %_%v%_", &ls_name))
16398 else if (unformat (input, "ls_index %d", &ls_index))
16404 errmsg ("parse error '%U'", format_unformat_error, input);
16409 if (!is_index_set && !is_name_set)
16411 errmsg ("error: expected one of index or name!");
16415 if (is_index_set && is_name_set)
16417 errmsg ("error: only one param expected!");
16421 if (vec_len (ls_name) > 62)
16423 errmsg ("error: locator set name too long!");
16427 if (!vam->json_output)
16429 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
16432 M (ONE_LOCATOR_DUMP, mp);
16433 mp->is_index_set = is_index_set;
16436 mp->ls_index = clib_host_to_net_u32 (ls_index);
16439 vec_add1 (ls_name, 0);
16440 strncpy ((char *) mp->ls_name, (char *) ls_name,
16441 sizeof (mp->ls_name) - 1);
16447 /* Use a control ping for synchronization */
16448 M (CONTROL_PING, mp_ping);
16451 /* Wait for a reply... */
16456 #define api_lisp_locator_dump api_one_locator_dump
16459 api_one_locator_set_dump (vat_main_t * vam)
16461 vl_api_one_locator_set_dump_t *mp;
16462 vl_api_control_ping_t *mp_ping;
16463 unformat_input_t *input = vam->input;
16467 /* Parse args required to build the message */
16468 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16470 if (unformat (input, "local"))
16474 else if (unformat (input, "remote"))
16480 errmsg ("parse error '%U'", format_unformat_error, input);
16485 if (!vam->json_output)
16487 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
16490 M (ONE_LOCATOR_SET_DUMP, mp);
16492 mp->filter = filter;
16497 /* Use a control ping for synchronization */
16498 M (CONTROL_PING, mp_ping);
16501 /* Wait for a reply... */
16506 #define api_lisp_locator_set_dump api_one_locator_set_dump
16509 api_one_eid_table_map_dump (vat_main_t * vam)
16513 unformat_input_t *input = vam->input;
16514 vl_api_one_eid_table_map_dump_t *mp;
16515 vl_api_control_ping_t *mp_ping;
16518 /* Parse args required to build the message */
16519 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16521 if (unformat (input, "l2"))
16526 else if (unformat (input, "l3"))
16533 errmsg ("parse error '%U'", format_unformat_error, input);
16540 errmsg ("expected one of 'l2' or 'l3' parameter!");
16544 if (!vam->json_output)
16546 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
16549 M (ONE_EID_TABLE_MAP_DUMP, mp);
16555 /* Use a control ping for synchronization */
16556 M (CONTROL_PING, mp_ping);
16559 /* Wait for a reply... */
16564 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
16567 api_one_eid_table_vni_dump (vat_main_t * vam)
16569 vl_api_one_eid_table_vni_dump_t *mp;
16570 vl_api_control_ping_t *mp_ping;
16573 if (!vam->json_output)
16575 print (vam->ofp, "VNI");
16578 M (ONE_EID_TABLE_VNI_DUMP, mp);
16583 /* Use a control ping for synchronization */
16584 M (CONTROL_PING, mp_ping);
16587 /* Wait for a reply... */
16592 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
16595 api_one_eid_table_dump (vat_main_t * vam)
16597 unformat_input_t *i = vam->input;
16598 vl_api_one_eid_table_dump_t *mp;
16599 vl_api_control_ping_t *mp_ping;
16600 struct in_addr ip4;
16601 struct in6_addr ip6;
16603 u8 eid_type = ~0, eid_set = 0;
16604 u32 prefix_length = ~0, t, vni = 0;
16607 lisp_nsh_api_t nsh;
16609 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16611 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
16617 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
16623 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
16628 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
16633 else if (unformat (i, "vni %d", &t))
16637 else if (unformat (i, "local"))
16641 else if (unformat (i, "remote"))
16647 errmsg ("parse error '%U'", format_unformat_error, i);
16652 if (!vam->json_output)
16654 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
16655 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
16658 M (ONE_EID_TABLE_DUMP, mp);
16660 mp->filter = filter;
16664 mp->vni = htonl (vni);
16665 mp->eid_type = eid_type;
16669 mp->prefix_length = prefix_length;
16670 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
16673 mp->prefix_length = prefix_length;
16674 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
16677 clib_memcpy (mp->eid, mac, sizeof (mac));
16680 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
16683 errmsg ("unknown EID type %d!", eid_type);
16691 /* Use a control ping for synchronization */
16692 M (CONTROL_PING, mp_ping);
16695 /* Wait for a reply... */
16700 #define api_lisp_eid_table_dump api_one_eid_table_dump
16703 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
16705 unformat_input_t *i = vam->input;
16706 vl_api_gpe_fwd_entries_get_t *mp;
16711 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16713 if (unformat (i, "vni %d", &vni))
16719 errmsg ("parse error '%U'", format_unformat_error, i);
16726 errmsg ("vni not set!");
16730 if (!vam->json_output)
16732 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
16736 M (GPE_FWD_ENTRIES_GET, mp);
16737 mp->vni = clib_host_to_net_u32 (vni);
16742 /* Wait for a reply... */
16747 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
16748 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
16749 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
16750 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
16751 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
16752 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
16753 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
16754 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
16757 api_one_adjacencies_get (vat_main_t * vam)
16759 unformat_input_t *i = vam->input;
16760 vl_api_one_adjacencies_get_t *mp;
16765 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16767 if (unformat (i, "vni %d", &vni))
16773 errmsg ("parse error '%U'", format_unformat_error, i);
16780 errmsg ("vni not set!");
16784 if (!vam->json_output)
16786 print (vam->ofp, "%s %40s", "leid", "reid");
16789 M (ONE_ADJACENCIES_GET, mp);
16790 mp->vni = clib_host_to_net_u32 (vni);
16795 /* Wait for a reply... */
16800 #define api_lisp_adjacencies_get api_one_adjacencies_get
16803 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
16805 unformat_input_t *i = vam->input;
16806 vl_api_gpe_native_fwd_rpaths_get_t *mp;
16808 u8 ip_family_set = 0, is_ip4 = 1;
16810 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16812 if (unformat (i, "ip4"))
16817 else if (unformat (i, "ip6"))
16824 errmsg ("parse error '%U'", format_unformat_error, i);
16829 if (!ip_family_set)
16831 errmsg ("ip family not set!");
16835 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
16836 mp->is_ip4 = is_ip4;
16841 /* Wait for a reply... */
16847 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
16849 vl_api_gpe_fwd_entry_vnis_get_t *mp;
16852 if (!vam->json_output)
16854 print (vam->ofp, "VNIs");
16857 M (GPE_FWD_ENTRY_VNIS_GET, mp);
16862 /* Wait for a reply... */
16868 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
16870 unformat_input_t *i = vam->input;
16871 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
16873 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
16874 struct in_addr ip4;
16875 struct in6_addr ip6;
16876 u32 table_id = 0, nh_sw_if_index = ~0;
16878 memset (&ip4, 0, sizeof (ip4));
16879 memset (&ip6, 0, sizeof (ip6));
16881 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16883 if (unformat (i, "del"))
16885 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
16886 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16891 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
16892 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16897 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
16901 nh_sw_if_index = ~0;
16903 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
16907 nh_sw_if_index = ~0;
16909 else if (unformat (i, "table %d", &table_id))
16913 errmsg ("parse error '%U'", format_unformat_error, i);
16920 errmsg ("nh addr not set!");
16924 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
16925 mp->is_add = is_add;
16926 mp->table_id = clib_host_to_net_u32 (table_id);
16927 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
16928 mp->is_ip4 = is_ip4;
16930 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
16932 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
16937 /* Wait for a reply... */
16943 api_one_map_server_dump (vat_main_t * vam)
16945 vl_api_one_map_server_dump_t *mp;
16946 vl_api_control_ping_t *mp_ping;
16949 if (!vam->json_output)
16951 print (vam->ofp, "%=20s", "Map server");
16954 M (ONE_MAP_SERVER_DUMP, mp);
16958 /* Use a control ping for synchronization */
16959 M (CONTROL_PING, mp_ping);
16962 /* Wait for a reply... */
16967 #define api_lisp_map_server_dump api_one_map_server_dump
16970 api_one_map_resolver_dump (vat_main_t * vam)
16972 vl_api_one_map_resolver_dump_t *mp;
16973 vl_api_control_ping_t *mp_ping;
16976 if (!vam->json_output)
16978 print (vam->ofp, "%=20s", "Map resolver");
16981 M (ONE_MAP_RESOLVER_DUMP, mp);
16985 /* Use a control ping for synchronization */
16986 M (CONTROL_PING, mp_ping);
16989 /* Wait for a reply... */
16994 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
16997 api_one_stats_flush (vat_main_t * vam)
16999 vl_api_one_stats_flush_t *mp;
17002 M (ONE_STATS_FLUSH, mp);
17009 api_one_stats_dump (vat_main_t * vam)
17011 vl_api_one_stats_dump_t *mp;
17012 vl_api_control_ping_t *mp_ping;
17015 M (ONE_STATS_DUMP, mp);
17019 /* Use a control ping for synchronization */
17020 M (CONTROL_PING, mp_ping);
17023 /* Wait for a reply... */
17029 api_show_one_status (vat_main_t * vam)
17031 vl_api_show_one_status_t *mp;
17034 if (!vam->json_output)
17036 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
17039 M (SHOW_ONE_STATUS, mp);
17042 /* Wait for a reply... */
17047 #define api_show_lisp_status api_show_one_status
17050 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
17052 vl_api_gpe_fwd_entry_path_dump_t *mp;
17053 vl_api_control_ping_t *mp_ping;
17054 unformat_input_t *i = vam->input;
17055 u32 fwd_entry_index = ~0;
17058 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17060 if (unformat (i, "index %d", &fwd_entry_index))
17066 if (~0 == fwd_entry_index)
17068 errmsg ("no index specified!");
17072 if (!vam->json_output)
17074 print (vam->ofp, "first line");
17077 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
17081 /* Use a control ping for synchronization */
17082 M (CONTROL_PING, mp_ping);
17085 /* Wait for a reply... */
17091 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
17093 vl_api_one_get_map_request_itr_rlocs_t *mp;
17096 if (!vam->json_output)
17098 print (vam->ofp, "%=20s", "itr-rlocs:");
17101 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
17104 /* Wait for a reply... */
17109 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
17112 api_af_packet_create (vat_main_t * vam)
17114 unformat_input_t *i = vam->input;
17115 vl_api_af_packet_create_t *mp;
17116 u8 *host_if_name = 0;
17118 u8 random_hw_addr = 1;
17121 memset (hw_addr, 0, sizeof (hw_addr));
17123 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17125 if (unformat (i, "name %s", &host_if_name))
17126 vec_add1 (host_if_name, 0);
17127 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17128 random_hw_addr = 0;
17133 if (!vec_len (host_if_name))
17135 errmsg ("host-interface name must be specified");
17139 if (vec_len (host_if_name) > 64)
17141 errmsg ("host-interface name too long");
17145 M (AF_PACKET_CREATE, mp);
17147 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17148 clib_memcpy (mp->hw_addr, hw_addr, 6);
17149 mp->use_random_hw_addr = random_hw_addr;
17150 vec_free (host_if_name);
17158 fprintf (vam->ofp ? vam->ofp : stderr,
17159 " new sw_if_index = %d\n", vam->sw_if_index);
17166 api_af_packet_delete (vat_main_t * vam)
17168 unformat_input_t *i = vam->input;
17169 vl_api_af_packet_delete_t *mp;
17170 u8 *host_if_name = 0;
17173 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17175 if (unformat (i, "name %s", &host_if_name))
17176 vec_add1 (host_if_name, 0);
17181 if (!vec_len (host_if_name))
17183 errmsg ("host-interface name must be specified");
17187 if (vec_len (host_if_name) > 64)
17189 errmsg ("host-interface name too long");
17193 M (AF_PACKET_DELETE, mp);
17195 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17196 vec_free (host_if_name);
17204 api_policer_add_del (vat_main_t * vam)
17206 unformat_input_t *i = vam->input;
17207 vl_api_policer_add_del_t *mp;
17217 u8 color_aware = 0;
17218 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
17221 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
17222 conform_action.dscp = 0;
17223 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
17224 exceed_action.dscp = 0;
17225 violate_action.action_type = SSE2_QOS_ACTION_DROP;
17226 violate_action.dscp = 0;
17228 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17230 if (unformat (i, "del"))
17232 else if (unformat (i, "name %s", &name))
17233 vec_add1 (name, 0);
17234 else if (unformat (i, "cir %u", &cir))
17236 else if (unformat (i, "eir %u", &eir))
17238 else if (unformat (i, "cb %u", &cb))
17240 else if (unformat (i, "eb %u", &eb))
17242 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
17245 else if (unformat (i, "round_type %U", unformat_policer_round_type,
17248 else if (unformat (i, "type %U", unformat_policer_type, &type))
17250 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
17253 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
17256 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
17259 else if (unformat (i, "color-aware"))
17265 if (!vec_len (name))
17267 errmsg ("policer name must be specified");
17271 if (vec_len (name) > 64)
17273 errmsg ("policer name too long");
17277 M (POLICER_ADD_DEL, mp);
17279 clib_memcpy (mp->name, name, vec_len (name));
17281 mp->is_add = is_add;
17286 mp->rate_type = rate_type;
17287 mp->round_type = round_type;
17289 mp->conform_action_type = conform_action.action_type;
17290 mp->conform_dscp = conform_action.dscp;
17291 mp->exceed_action_type = exceed_action.action_type;
17292 mp->exceed_dscp = exceed_action.dscp;
17293 mp->violate_action_type = violate_action.action_type;
17294 mp->violate_dscp = violate_action.dscp;
17295 mp->color_aware = color_aware;
17303 api_policer_dump (vat_main_t * vam)
17305 unformat_input_t *i = vam->input;
17306 vl_api_policer_dump_t *mp;
17307 vl_api_control_ping_t *mp_ping;
17308 u8 *match_name = 0;
17309 u8 match_name_valid = 0;
17312 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17314 if (unformat (i, "name %s", &match_name))
17316 vec_add1 (match_name, 0);
17317 match_name_valid = 1;
17323 M (POLICER_DUMP, mp);
17324 mp->match_name_valid = match_name_valid;
17325 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
17326 vec_free (match_name);
17330 /* Use a control ping for synchronization */
17331 M (CONTROL_PING, mp_ping);
17334 /* Wait for a reply... */
17340 api_policer_classify_set_interface (vat_main_t * vam)
17342 unformat_input_t *i = vam->input;
17343 vl_api_policer_classify_set_interface_t *mp;
17345 int sw_if_index_set;
17346 u32 ip4_table_index = ~0;
17347 u32 ip6_table_index = ~0;
17348 u32 l2_table_index = ~0;
17352 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17354 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17355 sw_if_index_set = 1;
17356 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17357 sw_if_index_set = 1;
17358 else if (unformat (i, "del"))
17360 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17362 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17364 else if (unformat (i, "l2-table %d", &l2_table_index))
17368 clib_warning ("parse error '%U'", format_unformat_error, i);
17373 if (sw_if_index_set == 0)
17375 errmsg ("missing interface name or sw_if_index");
17379 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
17381 mp->sw_if_index = ntohl (sw_if_index);
17382 mp->ip4_table_index = ntohl (ip4_table_index);
17383 mp->ip6_table_index = ntohl (ip6_table_index);
17384 mp->l2_table_index = ntohl (l2_table_index);
17385 mp->is_add = is_add;
17393 api_policer_classify_dump (vat_main_t * vam)
17395 unformat_input_t *i = vam->input;
17396 vl_api_policer_classify_dump_t *mp;
17397 vl_api_control_ping_t *mp_ping;
17398 u8 type = POLICER_CLASSIFY_N_TABLES;
17401 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
17405 errmsg ("classify table type must be specified");
17409 if (!vam->json_output)
17411 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17414 M (POLICER_CLASSIFY_DUMP, mp);
17419 /* Use a control ping for synchronization */
17420 M (CONTROL_PING, mp_ping);
17423 /* Wait for a reply... */
17429 api_netmap_create (vat_main_t * vam)
17431 unformat_input_t *i = vam->input;
17432 vl_api_netmap_create_t *mp;
17435 u8 random_hw_addr = 1;
17440 memset (hw_addr, 0, sizeof (hw_addr));
17442 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17444 if (unformat (i, "name %s", &if_name))
17445 vec_add1 (if_name, 0);
17446 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17447 random_hw_addr = 0;
17448 else if (unformat (i, "pipe"))
17450 else if (unformat (i, "master"))
17452 else if (unformat (i, "slave"))
17458 if (!vec_len (if_name))
17460 errmsg ("interface name must be specified");
17464 if (vec_len (if_name) > 64)
17466 errmsg ("interface name too long");
17470 M (NETMAP_CREATE, mp);
17472 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
17473 clib_memcpy (mp->hw_addr, hw_addr, 6);
17474 mp->use_random_hw_addr = random_hw_addr;
17475 mp->is_pipe = is_pipe;
17476 mp->is_master = is_master;
17477 vec_free (if_name);
17485 api_netmap_delete (vat_main_t * vam)
17487 unformat_input_t *i = vam->input;
17488 vl_api_netmap_delete_t *mp;
17492 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17494 if (unformat (i, "name %s", &if_name))
17495 vec_add1 (if_name, 0);
17500 if (!vec_len (if_name))
17502 errmsg ("interface name must be specified");
17506 if (vec_len (if_name) > 64)
17508 errmsg ("interface name too long");
17512 M (NETMAP_DELETE, mp);
17514 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
17515 vec_free (if_name);
17523 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
17525 if (fp->afi == IP46_TYPE_IP6)
17527 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17528 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17529 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17530 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17531 format_ip6_address, fp->next_hop);
17532 else if (fp->afi == IP46_TYPE_IP4)
17534 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17535 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17536 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17537 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17538 format_ip4_address, fp->next_hop);
17542 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
17543 vl_api_fib_path2_t * fp)
17545 struct in_addr ip4;
17546 struct in6_addr ip6;
17548 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17549 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17550 vat_json_object_add_uint (node, "is_local", fp->is_local);
17551 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17552 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17553 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17554 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17555 if (fp->afi == IP46_TYPE_IP4)
17557 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17558 vat_json_object_add_ip4 (node, "next_hop", ip4);
17560 else if (fp->afi == IP46_TYPE_IP6)
17562 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17563 vat_json_object_add_ip6 (node, "next_hop", ip6);
17568 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
17570 vat_main_t *vam = &vat_main;
17571 int count = ntohl (mp->mt_count);
17572 vl_api_fib_path2_t *fp;
17575 print (vam->ofp, "[%d]: sw_if_index %d via:",
17576 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
17578 for (i = 0; i < count; i++)
17580 vl_api_mpls_fib_path_print (vam, fp);
17584 print (vam->ofp, "");
17587 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
17588 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
17591 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
17593 vat_main_t *vam = &vat_main;
17594 vat_json_node_t *node = NULL;
17595 int count = ntohl (mp->mt_count);
17596 vl_api_fib_path2_t *fp;
17599 if (VAT_JSON_ARRAY != vam->json_tree.type)
17601 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17602 vat_json_init_array (&vam->json_tree);
17604 node = vat_json_array_add (&vam->json_tree);
17606 vat_json_init_object (node);
17607 vat_json_object_add_uint (node, "tunnel_index",
17608 ntohl (mp->mt_tunnel_index));
17609 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
17611 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
17614 for (i = 0; i < count; i++)
17616 vl_api_mpls_fib_path_json_print (node, fp);
17622 api_mpls_tunnel_dump (vat_main_t * vam)
17624 vl_api_mpls_tunnel_dump_t *mp;
17625 vl_api_control_ping_t *mp_ping;
17629 /* Parse args required to build the message */
17630 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
17632 if (!unformat (vam->input, "tunnel_index %d", &index))
17639 print (vam->ofp, " tunnel_index %d", index);
17641 M (MPLS_TUNNEL_DUMP, mp);
17642 mp->tunnel_index = htonl (index);
17645 /* Use a control ping for synchronization */
17646 M (CONTROL_PING, mp_ping);
17653 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
17654 #define vl_api_mpls_fib_details_t_print vl_noop_handler
17658 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
17660 vat_main_t *vam = &vat_main;
17661 int count = ntohl (mp->count);
17662 vl_api_fib_path2_t *fp;
17666 "table-id %d, label %u, ess_bit %u",
17667 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
17669 for (i = 0; i < count; i++)
17671 vl_api_mpls_fib_path_print (vam, fp);
17676 static void vl_api_mpls_fib_details_t_handler_json
17677 (vl_api_mpls_fib_details_t * mp)
17679 vat_main_t *vam = &vat_main;
17680 int count = ntohl (mp->count);
17681 vat_json_node_t *node = NULL;
17682 vl_api_fib_path2_t *fp;
17685 if (VAT_JSON_ARRAY != vam->json_tree.type)
17687 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17688 vat_json_init_array (&vam->json_tree);
17690 node = vat_json_array_add (&vam->json_tree);
17692 vat_json_init_object (node);
17693 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17694 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
17695 vat_json_object_add_uint (node, "label", ntohl (mp->label));
17696 vat_json_object_add_uint (node, "path_count", count);
17698 for (i = 0; i < count; i++)
17700 vl_api_mpls_fib_path_json_print (node, fp);
17706 api_mpls_fib_dump (vat_main_t * vam)
17708 vl_api_mpls_fib_dump_t *mp;
17709 vl_api_control_ping_t *mp_ping;
17712 M (MPLS_FIB_DUMP, mp);
17715 /* Use a control ping for synchronization */
17716 M (CONTROL_PING, mp_ping);
17723 #define vl_api_ip_fib_details_t_endian vl_noop_handler
17724 #define vl_api_ip_fib_details_t_print vl_noop_handler
17727 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
17729 vat_main_t *vam = &vat_main;
17730 int count = ntohl (mp->count);
17731 vl_api_fib_path_t *fp;
17735 "table-id %d, prefix %U/%d",
17736 ntohl (mp->table_id), format_ip4_address, mp->address,
17737 mp->address_length);
17739 for (i = 0; i < count; i++)
17741 if (fp->afi == IP46_TYPE_IP6)
17743 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17744 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17745 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17746 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17747 format_ip6_address, fp->next_hop);
17748 else if (fp->afi == IP46_TYPE_IP4)
17750 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17751 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17752 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17753 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17754 format_ip4_address, fp->next_hop);
17759 static void vl_api_ip_fib_details_t_handler_json
17760 (vl_api_ip_fib_details_t * mp)
17762 vat_main_t *vam = &vat_main;
17763 int count = ntohl (mp->count);
17764 vat_json_node_t *node = NULL;
17765 struct in_addr ip4;
17766 struct in6_addr ip6;
17767 vl_api_fib_path_t *fp;
17770 if (VAT_JSON_ARRAY != vam->json_tree.type)
17772 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17773 vat_json_init_array (&vam->json_tree);
17775 node = vat_json_array_add (&vam->json_tree);
17777 vat_json_init_object (node);
17778 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17779 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
17780 vat_json_object_add_ip4 (node, "prefix", ip4);
17781 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17782 vat_json_object_add_uint (node, "path_count", count);
17784 for (i = 0; i < count; i++)
17786 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17787 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17788 vat_json_object_add_uint (node, "is_local", fp->is_local);
17789 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17790 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17791 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17792 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17793 if (fp->afi == IP46_TYPE_IP4)
17795 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17796 vat_json_object_add_ip4 (node, "next_hop", ip4);
17798 else if (fp->afi == IP46_TYPE_IP6)
17800 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17801 vat_json_object_add_ip6 (node, "next_hop", ip6);
17807 api_ip_fib_dump (vat_main_t * vam)
17809 vl_api_ip_fib_dump_t *mp;
17810 vl_api_control_ping_t *mp_ping;
17813 M (IP_FIB_DUMP, mp);
17816 /* Use a control ping for synchronization */
17817 M (CONTROL_PING, mp_ping);
17825 api_ip_mfib_dump (vat_main_t * vam)
17827 vl_api_ip_mfib_dump_t *mp;
17828 vl_api_control_ping_t *mp_ping;
17831 M (IP_MFIB_DUMP, mp);
17834 /* Use a control ping for synchronization */
17835 M (CONTROL_PING, mp_ping);
17842 static void vl_api_ip_neighbor_details_t_handler
17843 (vl_api_ip_neighbor_details_t * mp)
17845 vat_main_t *vam = &vat_main;
17847 print (vam->ofp, "%c %U %U",
17848 (mp->is_static) ? 'S' : 'D',
17849 format_ethernet_address, &mp->mac_address,
17850 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
17854 static void vl_api_ip_neighbor_details_t_handler_json
17855 (vl_api_ip_neighbor_details_t * mp)
17858 vat_main_t *vam = &vat_main;
17859 vat_json_node_t *node;
17860 struct in_addr ip4;
17861 struct in6_addr ip6;
17863 if (VAT_JSON_ARRAY != vam->json_tree.type)
17865 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17866 vat_json_init_array (&vam->json_tree);
17868 node = vat_json_array_add (&vam->json_tree);
17870 vat_json_init_object (node);
17871 vat_json_object_add_string_copy (node, "flag",
17872 (mp->is_static) ? (u8 *) "static" : (u8 *)
17875 vat_json_object_add_string_copy (node, "link_layer",
17876 format (0, "%U", format_ethernet_address,
17877 &mp->mac_address));
17881 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
17882 vat_json_object_add_ip6 (node, "ip_address", ip6);
17886 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
17887 vat_json_object_add_ip4 (node, "ip_address", ip4);
17892 api_ip_neighbor_dump (vat_main_t * vam)
17894 unformat_input_t *i = vam->input;
17895 vl_api_ip_neighbor_dump_t *mp;
17896 vl_api_control_ping_t *mp_ping;
17898 u32 sw_if_index = ~0;
17901 /* Parse args required to build the message */
17902 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17904 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17906 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17908 else if (unformat (i, "ip6"))
17914 if (sw_if_index == ~0)
17916 errmsg ("missing interface name or sw_if_index");
17920 M (IP_NEIGHBOR_DUMP, mp);
17921 mp->is_ipv6 = (u8) is_ipv6;
17922 mp->sw_if_index = ntohl (sw_if_index);
17925 /* Use a control ping for synchronization */
17926 M (CONTROL_PING, mp_ping);
17933 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
17934 #define vl_api_ip6_fib_details_t_print vl_noop_handler
17937 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
17939 vat_main_t *vam = &vat_main;
17940 int count = ntohl (mp->count);
17941 vl_api_fib_path_t *fp;
17945 "table-id %d, prefix %U/%d",
17946 ntohl (mp->table_id), format_ip6_address, mp->address,
17947 mp->address_length);
17949 for (i = 0; i < count; i++)
17951 if (fp->afi == IP46_TYPE_IP6)
17953 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17954 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17955 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17956 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17957 format_ip6_address, fp->next_hop);
17958 else if (fp->afi == IP46_TYPE_IP4)
17960 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17961 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17962 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17963 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17964 format_ip4_address, fp->next_hop);
17969 static void vl_api_ip6_fib_details_t_handler_json
17970 (vl_api_ip6_fib_details_t * mp)
17972 vat_main_t *vam = &vat_main;
17973 int count = ntohl (mp->count);
17974 vat_json_node_t *node = NULL;
17975 struct in_addr ip4;
17976 struct in6_addr ip6;
17977 vl_api_fib_path_t *fp;
17980 if (VAT_JSON_ARRAY != vam->json_tree.type)
17982 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17983 vat_json_init_array (&vam->json_tree);
17985 node = vat_json_array_add (&vam->json_tree);
17987 vat_json_init_object (node);
17988 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17989 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
17990 vat_json_object_add_ip6 (node, "prefix", ip6);
17991 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17992 vat_json_object_add_uint (node, "path_count", count);
17994 for (i = 0; i < count; i++)
17996 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17997 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17998 vat_json_object_add_uint (node, "is_local", fp->is_local);
17999 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18000 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18001 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18002 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18003 if (fp->afi == IP46_TYPE_IP4)
18005 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18006 vat_json_object_add_ip4 (node, "next_hop", ip4);
18008 else if (fp->afi == IP46_TYPE_IP6)
18010 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18011 vat_json_object_add_ip6 (node, "next_hop", ip6);
18017 api_ip6_fib_dump (vat_main_t * vam)
18019 vl_api_ip6_fib_dump_t *mp;
18020 vl_api_control_ping_t *mp_ping;
18023 M (IP6_FIB_DUMP, mp);
18026 /* Use a control ping for synchronization */
18027 M (CONTROL_PING, mp_ping);
18035 api_ip6_mfib_dump (vat_main_t * vam)
18037 vl_api_ip6_mfib_dump_t *mp;
18038 vl_api_control_ping_t *mp_ping;
18041 M (IP6_MFIB_DUMP, mp);
18044 /* Use a control ping for synchronization */
18045 M (CONTROL_PING, mp_ping);
18053 api_classify_table_ids (vat_main_t * vam)
18055 vl_api_classify_table_ids_t *mp;
18058 /* Construct the API message */
18059 M (CLASSIFY_TABLE_IDS, mp);
18068 api_classify_table_by_interface (vat_main_t * vam)
18070 unformat_input_t *input = vam->input;
18071 vl_api_classify_table_by_interface_t *mp;
18073 u32 sw_if_index = ~0;
18075 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18077 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18079 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18084 if (sw_if_index == ~0)
18086 errmsg ("missing interface name or sw_if_index");
18090 /* Construct the API message */
18091 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
18093 mp->sw_if_index = ntohl (sw_if_index);
18101 api_classify_table_info (vat_main_t * vam)
18103 unformat_input_t *input = vam->input;
18104 vl_api_classify_table_info_t *mp;
18108 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18110 if (unformat (input, "table_id %d", &table_id))
18115 if (table_id == ~0)
18117 errmsg ("missing table id");
18121 /* Construct the API message */
18122 M (CLASSIFY_TABLE_INFO, mp);
18124 mp->table_id = ntohl (table_id);
18132 api_classify_session_dump (vat_main_t * vam)
18134 unformat_input_t *input = vam->input;
18135 vl_api_classify_session_dump_t *mp;
18136 vl_api_control_ping_t *mp_ping;
18140 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18142 if (unformat (input, "table_id %d", &table_id))
18147 if (table_id == ~0)
18149 errmsg ("missing table id");
18153 /* Construct the API message */
18154 M (CLASSIFY_SESSION_DUMP, mp);
18156 mp->table_id = ntohl (table_id);
18159 /* Use a control ping for synchronization */
18160 M (CONTROL_PING, mp_ping);
18168 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
18170 vat_main_t *vam = &vat_main;
18172 print (vam->ofp, "collector_address %U, collector_port %d, "
18173 "src_address %U, vrf_id %d, path_mtu %u, "
18174 "template_interval %u, udp_checksum %d",
18175 format_ip4_address, mp->collector_address,
18176 ntohs (mp->collector_port),
18177 format_ip4_address, mp->src_address,
18178 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
18179 ntohl (mp->template_interval), mp->udp_checksum);
18182 vam->result_ready = 1;
18186 vl_api_ipfix_exporter_details_t_handler_json
18187 (vl_api_ipfix_exporter_details_t * mp)
18189 vat_main_t *vam = &vat_main;
18190 vat_json_node_t node;
18191 struct in_addr collector_address;
18192 struct in_addr src_address;
18194 vat_json_init_object (&node);
18195 clib_memcpy (&collector_address, &mp->collector_address,
18196 sizeof (collector_address));
18197 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
18198 vat_json_object_add_uint (&node, "collector_port",
18199 ntohs (mp->collector_port));
18200 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
18201 vat_json_object_add_ip4 (&node, "src_address", src_address);
18202 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
18203 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
18204 vat_json_object_add_uint (&node, "template_interval",
18205 ntohl (mp->template_interval));
18206 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
18208 vat_json_print (vam->ofp, &node);
18209 vat_json_free (&node);
18211 vam->result_ready = 1;
18215 api_ipfix_exporter_dump (vat_main_t * vam)
18217 vl_api_ipfix_exporter_dump_t *mp;
18220 /* Construct the API message */
18221 M (IPFIX_EXPORTER_DUMP, mp);
18230 api_ipfix_classify_stream_dump (vat_main_t * vam)
18232 vl_api_ipfix_classify_stream_dump_t *mp;
18235 /* Construct the API message */
18236 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
18247 vl_api_ipfix_classify_stream_details_t_handler
18248 (vl_api_ipfix_classify_stream_details_t * mp)
18250 vat_main_t *vam = &vat_main;
18251 print (vam->ofp, "domain_id %d, src_port %d",
18252 ntohl (mp->domain_id), ntohs (mp->src_port));
18254 vam->result_ready = 1;
18258 vl_api_ipfix_classify_stream_details_t_handler_json
18259 (vl_api_ipfix_classify_stream_details_t * mp)
18261 vat_main_t *vam = &vat_main;
18262 vat_json_node_t node;
18264 vat_json_init_object (&node);
18265 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
18266 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
18268 vat_json_print (vam->ofp, &node);
18269 vat_json_free (&node);
18271 vam->result_ready = 1;
18275 api_ipfix_classify_table_dump (vat_main_t * vam)
18277 vl_api_ipfix_classify_table_dump_t *mp;
18278 vl_api_control_ping_t *mp_ping;
18281 if (!vam->json_output)
18283 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
18284 "transport_protocol");
18287 /* Construct the API message */
18288 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
18293 /* Use a control ping for synchronization */
18294 M (CONTROL_PING, mp_ping);
18302 vl_api_ipfix_classify_table_details_t_handler
18303 (vl_api_ipfix_classify_table_details_t * mp)
18305 vat_main_t *vam = &vat_main;
18306 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
18307 mp->transport_protocol);
18311 vl_api_ipfix_classify_table_details_t_handler_json
18312 (vl_api_ipfix_classify_table_details_t * mp)
18314 vat_json_node_t *node = NULL;
18315 vat_main_t *vam = &vat_main;
18317 if (VAT_JSON_ARRAY != vam->json_tree.type)
18319 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18320 vat_json_init_array (&vam->json_tree);
18323 node = vat_json_array_add (&vam->json_tree);
18324 vat_json_init_object (node);
18326 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
18327 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
18328 vat_json_object_add_uint (node, "transport_protocol",
18329 mp->transport_protocol);
18333 api_sw_interface_span_enable_disable (vat_main_t * vam)
18335 unformat_input_t *i = vam->input;
18336 vl_api_sw_interface_span_enable_disable_t *mp;
18337 u32 src_sw_if_index = ~0;
18338 u32 dst_sw_if_index = ~0;
18343 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18346 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
18348 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
18352 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
18354 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
18356 else if (unformat (i, "disable"))
18358 else if (unformat (i, "rx"))
18360 else if (unformat (i, "tx"))
18362 else if (unformat (i, "both"))
18364 else if (unformat (i, "l2"))
18370 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
18372 mp->sw_if_index_from = htonl (src_sw_if_index);
18373 mp->sw_if_index_to = htonl (dst_sw_if_index);
18383 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
18386 vat_main_t *vam = &vat_main;
18387 u8 *sw_if_from_name = 0;
18388 u8 *sw_if_to_name = 0;
18389 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18390 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18391 char *states[] = { "none", "rx", "tx", "both" };
18395 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18397 if ((u32) p->value[0] == sw_if_index_from)
18399 sw_if_from_name = (u8 *)(p->key);
18403 if ((u32) p->value[0] == sw_if_index_to)
18405 sw_if_to_name = (u8 *)(p->key);
18406 if (sw_if_from_name)
18411 print (vam->ofp, "%20s => %20s (%s)",
18412 sw_if_from_name, sw_if_to_name, states[mp->state]);
18416 vl_api_sw_interface_span_details_t_handler_json
18417 (vl_api_sw_interface_span_details_t * mp)
18419 vat_main_t *vam = &vat_main;
18420 vat_json_node_t *node = NULL;
18421 u8 *sw_if_from_name = 0;
18422 u8 *sw_if_to_name = 0;
18423 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18424 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18428 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18430 if ((u32) p->value[0] == sw_if_index_from)
18432 sw_if_from_name = (u8 *)(p->key);
18436 if ((u32) p->value[0] == sw_if_index_to)
18438 sw_if_to_name = (u8 *)(p->key);
18439 if (sw_if_from_name)
18445 if (VAT_JSON_ARRAY != vam->json_tree.type)
18447 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18448 vat_json_init_array (&vam->json_tree);
18450 node = vat_json_array_add (&vam->json_tree);
18452 vat_json_init_object (node);
18453 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
18454 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
18455 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
18456 if (0 != sw_if_to_name)
18458 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
18460 vat_json_object_add_uint (node, "state", mp->state);
18464 api_sw_interface_span_dump (vat_main_t * vam)
18466 unformat_input_t *input = vam->input;
18467 vl_api_sw_interface_span_dump_t *mp;
18468 vl_api_control_ping_t *mp_ping;
18472 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18474 if (unformat (input, "l2"))
18480 M (SW_INTERFACE_SPAN_DUMP, mp);
18484 /* Use a control ping for synchronization */
18485 M (CONTROL_PING, mp_ping);
18493 api_pg_create_interface (vat_main_t * vam)
18495 unformat_input_t *input = vam->input;
18496 vl_api_pg_create_interface_t *mp;
18500 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18502 if (unformat (input, "if_id %d", &if_id))
18509 errmsg ("missing pg interface index");
18513 /* Construct the API message */
18514 M (PG_CREATE_INTERFACE, mp);
18516 mp->interface_id = ntohl (if_id);
18524 api_pg_capture (vat_main_t * vam)
18526 unformat_input_t *input = vam->input;
18527 vl_api_pg_capture_t *mp;
18532 u8 pcap_file_set = 0;
18535 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18537 if (unformat (input, "if_id %d", &if_id))
18539 else if (unformat (input, "pcap %s", &pcap_file))
18541 else if (unformat (input, "count %d", &count))
18543 else if (unformat (input, "disable"))
18550 errmsg ("missing pg interface index");
18553 if (pcap_file_set > 0)
18555 if (vec_len (pcap_file) > 255)
18557 errmsg ("pcap file name is too long");
18562 u32 name_len = vec_len (pcap_file);
18563 /* Construct the API message */
18564 M (PG_CAPTURE, mp);
18566 mp->interface_id = ntohl (if_id);
18567 mp->is_enabled = enable;
18568 mp->count = ntohl (count);
18569 mp->pcap_name_length = ntohl (name_len);
18570 if (pcap_file_set != 0)
18572 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
18574 vec_free (pcap_file);
18582 api_pg_enable_disable (vat_main_t * vam)
18584 unformat_input_t *input = vam->input;
18585 vl_api_pg_enable_disable_t *mp;
18588 u8 stream_name_set = 0;
18589 u8 *stream_name = 0;
18591 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18593 if (unformat (input, "stream %s", &stream_name))
18594 stream_name_set = 1;
18595 else if (unformat (input, "disable"))
18601 if (stream_name_set > 0)
18603 if (vec_len (stream_name) > 255)
18605 errmsg ("stream name too long");
18610 u32 name_len = vec_len (stream_name);
18611 /* Construct the API message */
18612 M (PG_ENABLE_DISABLE, mp);
18614 mp->is_enabled = enable;
18615 if (stream_name_set != 0)
18617 mp->stream_name_length = ntohl (name_len);
18618 clib_memcpy (mp->stream_name, stream_name, name_len);
18620 vec_free (stream_name);
18628 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
18630 unformat_input_t *input = vam->input;
18631 vl_api_ip_source_and_port_range_check_add_del_t *mp;
18633 u16 *low_ports = 0;
18634 u16 *high_ports = 0;
18637 ip4_address_t ip4_addr;
18638 ip6_address_t ip6_addr;
18647 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18649 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
18655 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
18660 else if (unformat (input, "vrf %d", &vrf_id))
18662 else if (unformat (input, "del"))
18664 else if (unformat (input, "port %d", &tmp))
18666 if (tmp == 0 || tmp > 65535)
18668 errmsg ("port %d out of range", tmp);
18672 this_hi = this_low + 1;
18673 vec_add1 (low_ports, this_low);
18674 vec_add1 (high_ports, this_hi);
18676 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
18678 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
18680 errmsg ("incorrect range parameters");
18684 /* Note: in debug CLI +1 is added to high before
18685 passing to real fn that does "the work"
18686 (ip_source_and_port_range_check_add_del).
18687 This fn is a wrapper around the binary API fn a
18688 control plane will call, which expects this increment
18689 to have occurred. Hence letting the binary API control
18690 plane fn do the increment for consistency between VAT
18691 and other control planes.
18694 vec_add1 (low_ports, this_low);
18695 vec_add1 (high_ports, this_hi);
18701 if (prefix_set == 0)
18703 errmsg ("<address>/<mask> not specified");
18709 errmsg ("VRF ID required, not specified");
18716 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18720 if (vec_len (low_ports) == 0)
18722 errmsg ("At least one port or port range required");
18726 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
18728 mp->is_add = is_add;
18733 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
18738 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
18741 mp->mask_length = length;
18742 mp->number_of_ranges = vec_len (low_ports);
18744 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
18745 vec_free (low_ports);
18747 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
18748 vec_free (high_ports);
18750 mp->vrf_id = ntohl (vrf_id);
18758 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
18760 unformat_input_t *input = vam->input;
18761 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
18762 u32 sw_if_index = ~0;
18764 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
18765 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
18769 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18771 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18773 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18775 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
18777 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
18779 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
18781 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
18783 else if (unformat (input, "del"))
18789 if (sw_if_index == ~0)
18791 errmsg ("Interface required but not specified");
18797 errmsg ("VRF ID required but not specified");
18801 if (tcp_out_vrf_id == 0
18802 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
18805 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18809 /* Construct the API message */
18810 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
18812 mp->sw_if_index = ntohl (sw_if_index);
18813 mp->is_add = is_add;
18814 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
18815 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
18816 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
18817 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
18822 /* Wait for a reply... */
18828 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
18830 unformat_input_t *i = vam->input;
18831 vl_api_ipsec_gre_add_del_tunnel_t *mp;
18832 u32 local_sa_id = 0;
18833 u32 remote_sa_id = 0;
18834 ip4_address_t src_address;
18835 ip4_address_t dst_address;
18839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18841 if (unformat (i, "local_sa %d", &local_sa_id))
18843 else if (unformat (i, "remote_sa %d", &remote_sa_id))
18845 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
18847 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
18849 else if (unformat (i, "del"))
18853 clib_warning ("parse error '%U'", format_unformat_error, i);
18858 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
18860 mp->local_sa_id = ntohl (local_sa_id);
18861 mp->remote_sa_id = ntohl (remote_sa_id);
18862 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
18863 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
18864 mp->is_add = is_add;
18872 api_punt (vat_main_t * vam)
18874 unformat_input_t *i = vam->input;
18882 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18884 if (unformat (i, "ip %d", &ipv))
18886 else if (unformat (i, "protocol %d", &protocol))
18888 else if (unformat (i, "port %d", &port))
18890 else if (unformat (i, "del"))
18894 clib_warning ("parse error '%U'", format_unformat_error, i);
18901 mp->is_add = (u8) is_add;
18902 mp->ipv = (u8) ipv;
18903 mp->l4_protocol = (u8) protocol;
18904 mp->l4_port = htons ((u16) port);
18911 static void vl_api_ipsec_gre_tunnel_details_t_handler
18912 (vl_api_ipsec_gre_tunnel_details_t * mp)
18914 vat_main_t *vam = &vat_main;
18916 print (vam->ofp, "%11d%15U%15U%14d%14d",
18917 ntohl (mp->sw_if_index),
18918 format_ip4_address, &mp->src_address,
18919 format_ip4_address, &mp->dst_address,
18920 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
18923 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
18924 (vl_api_ipsec_gre_tunnel_details_t * mp)
18926 vat_main_t *vam = &vat_main;
18927 vat_json_node_t *node = NULL;
18928 struct in_addr ip4;
18930 if (VAT_JSON_ARRAY != vam->json_tree.type)
18932 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18933 vat_json_init_array (&vam->json_tree);
18935 node = vat_json_array_add (&vam->json_tree);
18937 vat_json_init_object (node);
18938 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18939 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
18940 vat_json_object_add_ip4 (node, "src_address", ip4);
18941 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
18942 vat_json_object_add_ip4 (node, "dst_address", ip4);
18943 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
18944 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
18948 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
18950 unformat_input_t *i = vam->input;
18951 vl_api_ipsec_gre_tunnel_dump_t *mp;
18952 vl_api_control_ping_t *mp_ping;
18954 u8 sw_if_index_set = 0;
18957 /* Parse args required to build the message */
18958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18960 if (unformat (i, "sw_if_index %d", &sw_if_index))
18961 sw_if_index_set = 1;
18966 if (sw_if_index_set == 0)
18971 if (!vam->json_output)
18973 print (vam->ofp, "%11s%15s%15s%14s%14s",
18974 "sw_if_index", "src_address", "dst_address",
18975 "local_sa_id", "remote_sa_id");
18978 /* Get list of gre-tunnel interfaces */
18979 M (IPSEC_GRE_TUNNEL_DUMP, mp);
18981 mp->sw_if_index = htonl (sw_if_index);
18985 /* Use a control ping for synchronization */
18986 M (CONTROL_PING, mp_ping);
18994 api_delete_subif (vat_main_t * vam)
18996 unformat_input_t *i = vam->input;
18997 vl_api_delete_subif_t *mp;
18998 u32 sw_if_index = ~0;
19001 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19003 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19005 if (unformat (i, "sw_if_index %d", &sw_if_index))
19011 if (sw_if_index == ~0)
19013 errmsg ("missing sw_if_index");
19017 /* Construct the API message */
19018 M (DELETE_SUBIF, mp);
19019 mp->sw_if_index = ntohl (sw_if_index);
19026 #define foreach_pbb_vtr_op \
19027 _("disable", L2_VTR_DISABLED) \
19028 _("pop", L2_VTR_POP_2) \
19029 _("push", L2_VTR_PUSH_2)
19032 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
19034 unformat_input_t *i = vam->input;
19035 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
19036 u32 sw_if_index = ~0, vtr_op = ~0;
19037 u16 outer_tag = ~0;
19038 u8 dmac[6], smac[6];
19039 u8 dmac_set = 0, smac_set = 0;
19045 /* Shut up coverity */
19046 memset (dmac, 0, sizeof (dmac));
19047 memset (smac, 0, sizeof (smac));
19049 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19051 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19053 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19055 else if (unformat (i, "vtr_op %d", &vtr_op))
19057 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
19060 else if (unformat (i, "translate_pbb_stag"))
19062 if (unformat (i, "%d", &tmp))
19064 vtr_op = L2_VTR_TRANSLATE_2_1;
19070 ("translate_pbb_stag operation requires outer tag definition");
19074 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
19076 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
19078 else if (unformat (i, "sid %d", &sid))
19080 else if (unformat (i, "vlanid %d", &tmp))
19084 clib_warning ("parse error '%U'", format_unformat_error, i);
19089 if ((sw_if_index == ~0) || (vtr_op == ~0))
19091 errmsg ("missing sw_if_index or vtr operation");
19094 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
19095 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
19098 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
19102 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
19103 mp->sw_if_index = ntohl (sw_if_index);
19104 mp->vtr_op = ntohl (vtr_op);
19105 mp->outer_tag = ntohs (outer_tag);
19106 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
19107 clib_memcpy (mp->b_smac, smac, sizeof (smac));
19108 mp->b_vlanid = ntohs (vlanid);
19109 mp->i_sid = ntohl (sid);
19117 api_flow_classify_set_interface (vat_main_t * vam)
19119 unformat_input_t *i = vam->input;
19120 vl_api_flow_classify_set_interface_t *mp;
19122 int sw_if_index_set;
19123 u32 ip4_table_index = ~0;
19124 u32 ip6_table_index = ~0;
19128 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19130 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19131 sw_if_index_set = 1;
19132 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19133 sw_if_index_set = 1;
19134 else if (unformat (i, "del"))
19136 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19138 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19142 clib_warning ("parse error '%U'", format_unformat_error, i);
19147 if (sw_if_index_set == 0)
19149 errmsg ("missing interface name or sw_if_index");
19153 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
19155 mp->sw_if_index = ntohl (sw_if_index);
19156 mp->ip4_table_index = ntohl (ip4_table_index);
19157 mp->ip6_table_index = ntohl (ip6_table_index);
19158 mp->is_add = is_add;
19166 api_flow_classify_dump (vat_main_t * vam)
19168 unformat_input_t *i = vam->input;
19169 vl_api_flow_classify_dump_t *mp;
19170 vl_api_control_ping_t *mp_ping;
19171 u8 type = FLOW_CLASSIFY_N_TABLES;
19174 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
19178 errmsg ("classify table type must be specified");
19182 if (!vam->json_output)
19184 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19187 M (FLOW_CLASSIFY_DUMP, mp);
19192 /* Use a control ping for synchronization */
19193 M (CONTROL_PING, mp_ping);
19196 /* Wait for a reply... */
19202 api_feature_enable_disable (vat_main_t * vam)
19204 unformat_input_t *i = vam->input;
19205 vl_api_feature_enable_disable_t *mp;
19207 u8 *feature_name = 0;
19208 u32 sw_if_index = ~0;
19212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19214 if (unformat (i, "arc_name %s", &arc_name))
19216 else if (unformat (i, "feature_name %s", &feature_name))
19219 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19221 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19223 else if (unformat (i, "disable"))
19231 errmsg ("missing arc name");
19234 if (vec_len (arc_name) > 63)
19236 errmsg ("arc name too long");
19239 if (feature_name == 0)
19241 errmsg ("missing feature name");
19244 if (vec_len (feature_name) > 63)
19246 errmsg ("feature name too long");
19249 if (sw_if_index == ~0)
19251 errmsg ("missing interface name or sw_if_index");
19255 /* Construct the API message */
19256 M (FEATURE_ENABLE_DISABLE, mp);
19257 mp->sw_if_index = ntohl (sw_if_index);
19258 mp->enable = enable;
19259 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
19260 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
19261 vec_free (arc_name);
19262 vec_free (feature_name);
19270 api_sw_interface_tag_add_del (vat_main_t * vam)
19272 unformat_input_t *i = vam->input;
19273 vl_api_sw_interface_tag_add_del_t *mp;
19274 u32 sw_if_index = ~0;
19279 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19281 if (unformat (i, "tag %s", &tag))
19283 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19285 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19287 else if (unformat (i, "del"))
19293 if (sw_if_index == ~0)
19295 errmsg ("missing interface name or sw_if_index");
19299 if (enable && (tag == 0))
19301 errmsg ("no tag specified");
19305 /* Construct the API message */
19306 M (SW_INTERFACE_TAG_ADD_DEL, mp);
19307 mp->sw_if_index = ntohl (sw_if_index);
19308 mp->is_add = enable;
19310 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
19318 static void vl_api_l2_xconnect_details_t_handler
19319 (vl_api_l2_xconnect_details_t * mp)
19321 vat_main_t *vam = &vat_main;
19323 print (vam->ofp, "%15d%15d",
19324 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
19327 static void vl_api_l2_xconnect_details_t_handler_json
19328 (vl_api_l2_xconnect_details_t * mp)
19330 vat_main_t *vam = &vat_main;
19331 vat_json_node_t *node = NULL;
19333 if (VAT_JSON_ARRAY != vam->json_tree.type)
19335 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19336 vat_json_init_array (&vam->json_tree);
19338 node = vat_json_array_add (&vam->json_tree);
19340 vat_json_init_object (node);
19341 vat_json_object_add_uint (node, "rx_sw_if_index",
19342 ntohl (mp->rx_sw_if_index));
19343 vat_json_object_add_uint (node, "tx_sw_if_index",
19344 ntohl (mp->tx_sw_if_index));
19348 api_l2_xconnect_dump (vat_main_t * vam)
19350 vl_api_l2_xconnect_dump_t *mp;
19351 vl_api_control_ping_t *mp_ping;
19354 if (!vam->json_output)
19356 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
19359 M (L2_XCONNECT_DUMP, mp);
19363 /* Use a control ping for synchronization */
19364 M (CONTROL_PING, mp_ping);
19372 api_sw_interface_set_mtu (vat_main_t * vam)
19374 unformat_input_t *i = vam->input;
19375 vl_api_sw_interface_set_mtu_t *mp;
19376 u32 sw_if_index = ~0;
19380 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19382 if (unformat (i, "mtu %d", &mtu))
19384 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19386 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19392 if (sw_if_index == ~0)
19394 errmsg ("missing interface name or sw_if_index");
19400 errmsg ("no mtu specified");
19404 /* Construct the API message */
19405 M (SW_INTERFACE_SET_MTU, mp);
19406 mp->sw_if_index = ntohl (sw_if_index);
19407 mp->mtu = ntohs ((u16) mtu);
19415 api_p2p_ethernet_add (vat_main_t * vam)
19417 unformat_input_t *i = vam->input;
19418 vl_api_p2p_ethernet_add_t *mp;
19419 u32 parent_if_index = ~0;
19425 memset (remote_mac, 0, sizeof (remote_mac));
19426 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19428 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19430 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19434 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19436 else if (unformat (i, "sub_id %d", &sub_id))
19440 clib_warning ("parse error '%U'", format_unformat_error, i);
19445 if (parent_if_index == ~0)
19447 errmsg ("missing interface name or sw_if_index");
19452 errmsg ("missing remote mac address");
19457 errmsg ("missing sub-interface id");
19461 M (P2P_ETHERNET_ADD, mp);
19462 mp->parent_if_index = ntohl (parent_if_index);
19463 mp->subif_id = ntohl (sub_id);
19464 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19472 api_p2p_ethernet_del (vat_main_t * vam)
19474 unformat_input_t *i = vam->input;
19475 vl_api_p2p_ethernet_del_t *mp;
19476 u32 parent_if_index = ~0;
19481 memset (remote_mac, 0, sizeof (remote_mac));
19482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19484 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19486 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19490 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19494 clib_warning ("parse error '%U'", format_unformat_error, i);
19499 if (parent_if_index == ~0)
19501 errmsg ("missing interface name or sw_if_index");
19506 errmsg ("missing remote mac address");
19510 M (P2P_ETHERNET_DEL, mp);
19511 mp->parent_if_index = ntohl (parent_if_index);
19512 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19520 api_lldp_config (vat_main_t * vam)
19522 unformat_input_t *i = vam->input;
19523 vl_api_lldp_config_t *mp;
19525 int tx_interval = 0;
19526 u8 *sys_name = NULL;
19529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19531 if (unformat (i, "system-name %s", &sys_name))
19533 else if (unformat (i, "tx-hold %d", &tx_hold))
19535 else if (unformat (i, "tx-interval %d", &tx_interval))
19539 clib_warning ("parse error '%U'", format_unformat_error, i);
19544 vec_add1 (sys_name, 0);
19546 M (LLDP_CONFIG, mp);
19547 mp->tx_hold = htonl (tx_hold);
19548 mp->tx_interval = htonl (tx_interval);
19549 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
19550 vec_free (sys_name);
19558 api_sw_interface_set_lldp (vat_main_t * vam)
19560 unformat_input_t *i = vam->input;
19561 vl_api_sw_interface_set_lldp_t *mp;
19562 u32 sw_if_index = ~0;
19564 u8 *port_desc = NULL;
19567 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19569 if (unformat (i, "disable"))
19572 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19574 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19576 else if (unformat (i, "port-desc %s", &port_desc))
19582 if (sw_if_index == ~0)
19584 errmsg ("missing interface name or sw_if_index");
19588 /* Construct the API message */
19589 vec_add1 (port_desc, 0);
19590 M (SW_INTERFACE_SET_LLDP, mp);
19591 mp->sw_if_index = ntohl (sw_if_index);
19592 mp->enable = enable;
19593 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
19594 vec_free (port_desc);
19602 q_or_quit (vat_main_t * vam)
19604 #if VPP_API_TEST_BUILTIN == 0
19605 longjmp (vam->jump_buf, 1);
19607 return 0; /* not so much */
19611 q (vat_main_t * vam)
19613 return q_or_quit (vam);
19617 quit (vat_main_t * vam)
19619 return q_or_quit (vam);
19623 comment (vat_main_t * vam)
19629 cmd_cmp (void *a1, void *a2)
19634 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
19638 help (vat_main_t * vam)
19643 unformat_input_t *i = vam->input;
19646 if (unformat (i, "%s", &name))
19650 vec_add1 (name, 0);
19652 hs = hash_get_mem (vam->help_by_name, name);
19654 print (vam->ofp, "usage: %s %s", name, hs[0]);
19656 print (vam->ofp, "No such msg / command '%s'", name);
19661 print (vam->ofp, "Help is available for the following:");
19664 hash_foreach_pair (p, vam->function_by_name,
19666 vec_add1 (cmds, (u8 *)(p->key));
19670 vec_sort_with_function (cmds, cmd_cmp);
19672 for (j = 0; j < vec_len (cmds); j++)
19673 print (vam->ofp, "%s", cmds[j]);
19680 set (vat_main_t * vam)
19682 u8 *name = 0, *value = 0;
19683 unformat_input_t *i = vam->input;
19685 if (unformat (i, "%s", &name))
19687 /* The input buffer is a vector, not a string. */
19688 value = vec_dup (i->buffer);
19689 vec_delete (value, i->index, 0);
19690 /* Almost certainly has a trailing newline */
19691 if (value[vec_len (value) - 1] == '\n')
19692 value[vec_len (value) - 1] = 0;
19693 /* Make sure it's a proper string, one way or the other */
19694 vec_add1 (value, 0);
19695 (void) clib_macro_set_value (&vam->macro_main,
19696 (char *) name, (char *) value);
19699 errmsg ("usage: set <name> <value>");
19707 unset (vat_main_t * vam)
19711 if (unformat (vam->input, "%s", &name))
19712 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
19713 errmsg ("unset: %s wasn't set", name);
19726 macro_sort_cmp (void *a1, void *a2)
19728 macro_sort_t *s1 = a1;
19729 macro_sort_t *s2 = a2;
19731 return strcmp ((char *) (s1->name), (char *) (s2->name));
19735 dump_macro_table (vat_main_t * vam)
19737 macro_sort_t *sort_me = 0, *sm;
19742 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
19744 vec_add2 (sort_me, sm, 1);
19745 sm->name = (u8 *)(p->key);
19746 sm->value = (u8 *) (p->value[0]);
19750 vec_sort_with_function (sort_me, macro_sort_cmp);
19752 if (vec_len (sort_me))
19753 print (vam->ofp, "%-15s%s", "Name", "Value");
19755 print (vam->ofp, "The macro table is empty...");
19757 for (i = 0; i < vec_len (sort_me); i++)
19758 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
19763 dump_node_table (vat_main_t * vam)
19766 vlib_node_t *node, *next_node;
19768 if (vec_len (vam->graph_nodes) == 0)
19770 print (vam->ofp, "Node table empty, issue get_node_graph...");
19774 for (i = 0; i < vec_len (vam->graph_nodes); i++)
19776 node = vam->graph_nodes[i];
19777 print (vam->ofp, "[%d] %s", i, node->name);
19778 for (j = 0; j < vec_len (node->next_nodes); j++)
19780 if (node->next_nodes[j] != ~0)
19782 next_node = vam->graph_nodes[node->next_nodes[j]];
19783 print (vam->ofp, " [%d] %s", j, next_node->name);
19791 value_sort_cmp (void *a1, void *a2)
19793 name_sort_t *n1 = a1;
19794 name_sort_t *n2 = a2;
19796 if (n1->value < n2->value)
19798 if (n1->value > n2->value)
19805 dump_msg_api_table (vat_main_t * vam)
19807 api_main_t *am = &api_main;
19808 name_sort_t *nses = 0, *ns;
19813 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
19815 vec_add2 (nses, ns, 1);
19816 ns->name = (u8 *)(hp->key);
19817 ns->value = (u32) hp->value[0];
19821 vec_sort_with_function (nses, value_sort_cmp);
19823 for (i = 0; i < vec_len (nses); i++)
19824 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
19830 get_msg_id (vat_main_t * vam)
19835 if (unformat (vam->input, "%s", &name_and_crc))
19837 message_index = vl_api_get_msg_index (name_and_crc);
19838 if (message_index == ~0)
19840 print (vam->ofp, " '%s' not found", name_and_crc);
19843 print (vam->ofp, " '%s' has message index %d",
19844 name_and_crc, message_index);
19847 errmsg ("name_and_crc required...");
19852 search_node_table (vat_main_t * vam)
19854 unformat_input_t *line_input = vam->input;
19857 vlib_node_t *node, *next_node;
19860 if (vam->graph_node_index_by_name == 0)
19862 print (vam->ofp, "Node table empty, issue get_node_graph...");
19866 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
19868 if (unformat (line_input, "%s", &node_to_find))
19870 vec_add1 (node_to_find, 0);
19871 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
19874 print (vam->ofp, "%s not found...", node_to_find);
19877 node = vam->graph_nodes[p[0]];
19878 print (vam->ofp, "[%d] %s", p[0], node->name);
19879 for (j = 0; j < vec_len (node->next_nodes); j++)
19881 if (node->next_nodes[j] != ~0)
19883 next_node = vam->graph_nodes[node->next_nodes[j]];
19884 print (vam->ofp, " [%d] %s", j, next_node->name);
19891 clib_warning ("parse error '%U'", format_unformat_error,
19897 vec_free (node_to_find);
19906 script (vat_main_t * vam)
19908 #if (VPP_API_TEST_BUILTIN==0)
19910 char *save_current_file;
19911 unformat_input_t save_input;
19912 jmp_buf save_jump_buf;
19913 u32 save_line_number;
19915 FILE *new_fp, *save_ifp;
19917 if (unformat (vam->input, "%s", &s))
19919 new_fp = fopen ((char *) s, "r");
19922 errmsg ("Couldn't open script file %s", s);
19929 errmsg ("Missing script name");
19933 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
19934 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
19935 save_ifp = vam->ifp;
19936 save_line_number = vam->input_line_number;
19937 save_current_file = (char *) vam->current_file;
19939 vam->input_line_number = 0;
19941 vam->current_file = s;
19944 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
19945 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
19946 vam->ifp = save_ifp;
19947 vam->input_line_number = save_line_number;
19948 vam->current_file = (u8 *) save_current_file;
19953 clib_warning ("use the exec command...");
19959 echo (vat_main_t * vam)
19961 print (vam->ofp, "%v", vam->input->buffer);
19965 /* List of API message constructors, CLI names map to api_xxx */
19966 #define foreach_vpe_api_msg \
19967 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
19968 _(sw_interface_dump,"") \
19969 _(sw_interface_set_flags, \
19970 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
19971 _(sw_interface_add_del_address, \
19972 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
19973 _(sw_interface_set_table, \
19974 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
19975 _(sw_interface_set_mpls_enable, \
19976 "<intfc> | sw_if_index [disable | dis]") \
19977 _(sw_interface_set_vpath, \
19978 "<intfc> | sw_if_index <id> enable | disable") \
19979 _(sw_interface_set_vxlan_bypass, \
19980 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
19981 _(sw_interface_set_l2_xconnect, \
19982 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
19983 "enable | disable") \
19984 _(sw_interface_set_l2_bridge, \
19985 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
19986 "[shg <split-horizon-group>] [bvi]\n" \
19987 "enable | disable") \
19988 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
19989 _(bridge_domain_add_del, \
19990 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [mac-age 0-255] [del]\n") \
19991 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
19993 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
19994 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
19995 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
19997 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
19999 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20001 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
20003 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
20005 "<vpp-if-name> | sw_if_index <id>") \
20006 _(sw_interface_tap_dump, "") \
20007 _(ip_add_del_route, \
20008 "<addr>/<mask> via <addr> [table-id <n>]\n" \
20009 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
20010 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
20011 "[multipath] [count <n>]") \
20012 _(ip_mroute_add_del, \
20013 "<src> <grp>/<mask> [table-id <n>]\n" \
20014 "[<intfc> | sw_if_index <id>] [local] [del]") \
20015 _(mpls_route_add_del, \
20016 "<label> <eos> via <addr> [table-id <n>]\n" \
20017 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
20018 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
20019 "[multipath] [count <n>]") \
20020 _(mpls_ip_bind_unbind, \
20021 "<label> <addr/len>") \
20022 _(mpls_tunnel_add_del, \
20023 " via <addr> [table-id <n>]\n" \
20024 "sw_if_index <id>] [l2] [del]") \
20025 _(proxy_arp_add_del, \
20026 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
20027 _(proxy_arp_intfc_enable_disable, \
20028 "<intfc> | sw_if_index <id> enable | disable") \
20029 _(sw_interface_set_unnumbered, \
20030 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
20031 _(ip_neighbor_add_del, \
20032 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
20033 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
20034 _(reset_vrf, "vrf <id> [ipv6]") \
20035 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
20036 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
20037 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
20038 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
20039 "[outer_vlan_id_any][inner_vlan_id_any]") \
20040 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
20041 _(reset_fib, "vrf <n> [ipv6]") \
20042 _(dhcp_proxy_config, \
20043 "svr <v46-address> src <v46-address>\n" \
20044 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
20045 _(dhcp_proxy_set_vss, \
20046 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
20047 _(dhcp_proxy_dump, "ip6") \
20048 _(dhcp_client_config, \
20049 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
20050 _(set_ip_flow_hash, \
20051 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
20052 _(sw_interface_ip6_enable_disable, \
20053 "<intfc> | sw_if_index <id> enable | disable") \
20054 _(sw_interface_ip6_set_link_local_address, \
20055 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
20056 _(ip6nd_proxy_add_del, \
20057 "<intfc> | sw_if_index <id> <ip6-address>") \
20058 _(ip6nd_proxy_dump, "") \
20059 _(sw_interface_ip6nd_ra_prefix, \
20060 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
20061 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
20062 "[nolink] [isno]") \
20063 _(sw_interface_ip6nd_ra_config, \
20064 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
20065 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
20066 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
20067 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
20068 _(l2_patch_add_del, \
20069 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20070 "enable | disable") \
20071 _(sr_localsid_add_del, \
20072 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
20073 "fib-table <num> (end.psp) sw_if_index <num>") \
20074 _(classify_add_del_table, \
20075 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
20076 " [del] [del-chain] mask <mask-value>\n" \
20077 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
20078 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
20079 _(classify_add_del_session, \
20080 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
20081 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
20082 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
20083 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
20084 _(classify_set_interface_ip_table, \
20085 "<intfc> | sw_if_index <nn> table <nn>") \
20086 _(classify_set_interface_l2_tables, \
20087 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20088 " [other-table <nn>]") \
20089 _(get_node_index, "node <node-name") \
20090 _(add_node_next, "node <node-name> next <next-node-name>") \
20091 _(l2tpv3_create_tunnel, \
20092 "client_address <ip6-addr> our_address <ip6-addr>\n" \
20093 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
20094 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
20095 _(l2tpv3_set_tunnel_cookies, \
20096 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
20097 "[new_remote_cookie <nn>]\n") \
20098 _(l2tpv3_interface_enable_disable, \
20099 "<intfc> | sw_if_index <nn> enable | disable") \
20100 _(l2tpv3_set_lookup_key, \
20101 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
20102 _(sw_if_l2tpv3_tunnel_dump, "") \
20103 _(vxlan_add_del_tunnel, \
20104 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
20105 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20106 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
20107 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20108 _(gre_add_del_tunnel, \
20109 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
20110 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20111 _(l2_fib_clear_table, "") \
20112 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
20113 _(l2_interface_vlan_tag_rewrite, \
20114 "<intfc> | sw_if_index <nn> \n" \
20115 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
20116 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
20117 _(create_vhost_user_if, \
20118 "socket <filename> [server] [renumber <dev_instance>] " \
20119 "[mac <mac_address>]") \
20120 _(modify_vhost_user_if, \
20121 "<intfc> | sw_if_index <nn> socket <filename>\n" \
20122 "[server] [renumber <dev_instance>]") \
20123 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
20124 _(sw_interface_vhost_user_dump, "") \
20125 _(show_version, "") \
20126 _(vxlan_gpe_add_del_tunnel, \
20127 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
20128 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20129 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
20130 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
20131 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20132 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
20133 _(interface_name_renumber, \
20134 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
20135 _(input_acl_set_interface, \
20136 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20137 " [l2-table <nn>] [del]") \
20138 _(want_ip4_arp_events, "address <ip4-address> [del]") \
20139 _(want_ip6_nd_events, "address <ip6-address> [del]") \
20140 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
20141 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
20142 _(ip_dump, "ipv4 | ipv6") \
20143 _(ipsec_spd_add_del, "spd_id <n> [del]") \
20144 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
20146 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
20147 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
20148 " integ_alg <alg> integ_key <hex>") \
20149 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
20150 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
20151 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
20152 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
20153 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
20154 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
20155 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
20156 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
20157 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
20158 _(ikev2_profile_add_del, "name <profile_name> [del]") \
20159 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
20160 "(auth_data 0x<data> | auth_data <data>)") \
20161 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
20162 "(id_data 0x<data> | id_data <data>) (local|remote)") \
20163 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
20164 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
20165 "(local|remote)") \
20166 _(ikev2_set_local_key, "file <absolute_file_path>") \
20167 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
20168 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
20169 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
20170 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
20171 _(ikev2_initiate_sa_init, "<profile_name>") \
20172 _(ikev2_initiate_del_ike_sa, "<ispi>") \
20173 _(ikev2_initiate_del_child_sa, "<ispi>") \
20174 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
20175 _(delete_loopback,"sw_if_index <nn>") \
20176 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
20177 _(map_add_domain, \
20178 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
20179 "ip6-src <ip6addr> " \
20180 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
20181 _(map_del_domain, "index <n>") \
20182 _(map_add_del_rule, \
20183 "index <n> psid <n> dst <ip6addr> [del]") \
20184 _(map_domain_dump, "") \
20185 _(map_rule_dump, "index <map-domain>") \
20186 _(want_interface_events, "enable|disable") \
20187 _(want_stats,"enable|disable") \
20188 _(get_first_msg_id, "client <name>") \
20189 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
20190 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
20191 "fib-id <nn> [ip4][ip6][default]") \
20192 _(get_node_graph, " ") \
20193 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
20194 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
20195 _(ioam_disable, "") \
20196 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
20197 " sw_if_index <sw_if_index> p <priority> " \
20198 "w <weight>] [del]") \
20199 _(one_add_del_locator, "locator-set <locator_name> " \
20200 "iface <intf> | sw_if_index <sw_if_index> " \
20201 "p <priority> w <weight> [del]") \
20202 _(one_add_del_local_eid,"vni <vni> eid " \
20203 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20204 "locator-set <locator_name> [del]" \
20205 "[key-id sha1|sha256 secret-key <secret-key>]")\
20206 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
20207 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
20208 _(one_enable_disable, "enable|disable") \
20209 _(one_map_register_enable_disable, "enable|disable") \
20210 _(one_map_register_fallback_threshold, "<value>") \
20211 _(one_rloc_probe_enable_disable, "enable|disable") \
20212 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20214 "rloc <locator> p <prio> " \
20215 "w <weight> [rloc <loc> ... ] " \
20216 "action <action> [del-all]") \
20217 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20219 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20220 _(one_use_petr, "ip-address> | disable") \
20221 _(one_map_request_mode, "src-dst|dst-only") \
20222 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20223 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20224 _(one_locator_set_dump, "[local | remote]") \
20225 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
20226 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20227 "[local] | [remote]") \
20228 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
20229 _(one_l2_arp_bd_get, "") \
20230 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
20231 _(one_stats_enable_disable, "enable|disalbe") \
20232 _(show_one_stats_enable_disable, "") \
20233 _(one_eid_table_vni_dump, "") \
20234 _(one_eid_table_map_dump, "l2|l3") \
20235 _(one_map_resolver_dump, "") \
20236 _(one_map_server_dump, "") \
20237 _(one_adjacencies_get, "vni <vni>") \
20238 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
20239 _(show_one_rloc_probe_state, "") \
20240 _(show_one_map_register_state, "") \
20241 _(show_one_status, "") \
20242 _(one_stats_dump, "") \
20243 _(one_stats_flush, "") \
20244 _(one_get_map_request_itr_rlocs, "") \
20245 _(one_map_register_set_ttl, "<ttl>") \
20246 _(show_one_nsh_mapping, "") \
20247 _(show_one_pitr, "") \
20248 _(show_one_use_petr, "") \
20249 _(show_one_map_request_mode, "") \
20250 _(show_one_map_register_ttl, "") \
20251 _(show_one_map_register_fallback_threshold, "") \
20252 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
20253 " sw_if_index <sw_if_index> p <priority> " \
20254 "w <weight>] [del]") \
20255 _(lisp_add_del_locator, "locator-set <locator_name> " \
20256 "iface <intf> | sw_if_index <sw_if_index> " \
20257 "p <priority> w <weight> [del]") \
20258 _(lisp_add_del_local_eid,"vni <vni> eid " \
20259 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20260 "locator-set <locator_name> [del]" \
20261 "[key-id sha1|sha256 secret-key <secret-key>]") \
20262 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
20263 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
20264 _(lisp_enable_disable, "enable|disable") \
20265 _(lisp_map_register_enable_disable, "enable|disable") \
20266 _(lisp_rloc_probe_enable_disable, "enable|disable") \
20267 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20269 "rloc <locator> p <prio> " \
20270 "w <weight> [rloc <loc> ... ] " \
20271 "action <action> [del-all]") \
20272 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20274 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20275 _(lisp_use_petr, "<ip-address> | disable") \
20276 _(lisp_map_request_mode, "src-dst|dst-only") \
20277 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20278 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20279 _(lisp_locator_set_dump, "[local | remote]") \
20280 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
20281 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20282 "[local] | [remote]") \
20283 _(lisp_eid_table_vni_dump, "") \
20284 _(lisp_eid_table_map_dump, "l2|l3") \
20285 _(lisp_map_resolver_dump, "") \
20286 _(lisp_map_server_dump, "") \
20287 _(lisp_adjacencies_get, "vni <vni>") \
20288 _(gpe_fwd_entry_vnis_get, "") \
20289 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
20290 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
20291 "[table <table-id>]") \
20292 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
20293 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
20294 _(gpe_set_encap_mode, "lisp|vxlan") \
20295 _(gpe_get_encap_mode, "") \
20296 _(lisp_gpe_add_del_iface, "up|down") \
20297 _(lisp_gpe_enable_disable, "enable|disable") \
20298 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
20299 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
20300 _(show_lisp_rloc_probe_state, "") \
20301 _(show_lisp_map_register_state, "") \
20302 _(show_lisp_status, "") \
20303 _(lisp_get_map_request_itr_rlocs, "") \
20304 _(show_lisp_pitr, "") \
20305 _(show_lisp_use_petr, "") \
20306 _(show_lisp_map_request_mode, "") \
20307 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
20308 _(af_packet_delete, "name <host interface name>") \
20309 _(policer_add_del, "name <policer name> <params> [del]") \
20310 _(policer_dump, "[name <policer name>]") \
20311 _(policer_classify_set_interface, \
20312 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20313 " [l2-table <nn>] [del]") \
20314 _(policer_classify_dump, "type [ip4|ip6|l2]") \
20315 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
20316 "[master|slave]") \
20317 _(netmap_delete, "name <interface name>") \
20318 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
20319 _(mpls_fib_dump, "") \
20320 _(classify_table_ids, "") \
20321 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
20322 _(classify_table_info, "table_id <nn>") \
20323 _(classify_session_dump, "table_id <nn>") \
20324 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
20325 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
20326 "[template_interval <nn>] [udp_checksum]") \
20327 _(ipfix_exporter_dump, "") \
20328 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
20329 _(ipfix_classify_stream_dump, "") \
20330 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
20331 _(ipfix_classify_table_dump, "") \
20332 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
20333 _(sw_interface_span_dump, "[l2]") \
20334 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
20335 _(pg_create_interface, "if_id <nn>") \
20336 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
20337 _(pg_enable_disable, "[stream <id>] disable") \
20338 _(ip_source_and_port_range_check_add_del, \
20339 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
20340 _(ip_source_and_port_range_check_interface_add_del, \
20341 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
20342 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
20343 _(ipsec_gre_add_del_tunnel, \
20344 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
20345 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
20346 _(delete_subif,"<intfc> | sw_if_index <nn>") \
20347 _(l2_interface_pbb_tag_rewrite, \
20348 "<intfc> | sw_if_index <nn> \n" \
20349 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
20350 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
20351 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
20352 _(flow_classify_set_interface, \
20353 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
20354 _(flow_classify_dump, "type [ip4|ip6]") \
20355 _(ip_fib_dump, "") \
20356 _(ip_mfib_dump, "") \
20357 _(ip6_fib_dump, "") \
20358 _(ip6_mfib_dump, "") \
20359 _(feature_enable_disable, "arc_name <arc_name> " \
20360 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
20361 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
20363 _(l2_xconnect_dump, "") \
20364 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
20365 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
20366 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
20367 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
20368 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
20369 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
20370 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>] [disable]")
20372 /* List of command functions, CLI names map directly to functions */
20373 #define foreach_cli_function \
20374 _(comment, "usage: comment <ignore-rest-of-line>") \
20375 _(dump_interface_table, "usage: dump_interface_table") \
20376 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
20377 _(dump_ipv4_table, "usage: dump_ipv4_table") \
20378 _(dump_ipv6_table, "usage: dump_ipv6_table") \
20379 _(dump_stats_table, "usage: dump_stats_table") \
20380 _(dump_macro_table, "usage: dump_macro_table ") \
20381 _(dump_node_table, "usage: dump_node_table") \
20382 _(dump_msg_api_table, "usage: dump_msg_api_table") \
20383 _(get_msg_id, "usage: get_msg_id name_and_crc") \
20384 _(echo, "usage: echo <message>") \
20385 _(exec, "usage: exec <vpe-debug-CLI-command>") \
20386 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
20387 _(help, "usage: help") \
20388 _(q, "usage: quit") \
20389 _(quit, "usage: quit") \
20390 _(search_node_table, "usage: search_node_table <name>...") \
20391 _(set, "usage: set <variable-name> <value>") \
20392 _(script, "usage: script <file-name>") \
20393 _(unset, "usage: unset <variable-name>")
20395 static void vl_api_##n##_t_handler_uni \
20396 (vl_api_##n##_t * mp) \
20398 vat_main_t * vam = &vat_main; \
20399 if (vam->json_output) { \
20400 vl_api_##n##_t_handler_json(mp); \
20402 vl_api_##n##_t_handler(mp); \
20405 foreach_vpe_api_reply_msg;
20406 #if VPP_API_TEST_BUILTIN == 0
20407 foreach_standalone_reply_msg;
20412 vat_api_hookup (vat_main_t * vam)
20415 vl_msg_api_set_handlers(VL_API_##N, #n, \
20416 vl_api_##n##_t_handler_uni, \
20418 vl_api_##n##_t_endian, \
20419 vl_api_##n##_t_print, \
20420 sizeof(vl_api_##n##_t), 1);
20421 foreach_vpe_api_reply_msg;
20422 #if VPP_API_TEST_BUILTIN == 0
20423 foreach_standalone_reply_msg;
20427 #if (VPP_API_TEST_BUILTIN==0)
20428 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
20430 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
20432 vam->function_by_name = hash_create_string (0, sizeof (uword));
20434 vam->help_by_name = hash_create_string (0, sizeof (uword));
20437 /* API messages we can send */
20438 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
20439 foreach_vpe_api_msg;
20443 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
20444 foreach_vpe_api_msg;
20447 /* CLI functions */
20448 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
20449 foreach_cli_function;
20453 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
20454 foreach_cli_function;
20458 #if VPP_API_TEST_BUILTIN
20459 static clib_error_t *
20460 vat_api_hookup_shim (vlib_main_t * vm)
20462 vat_api_hookup (&vat_main);
20466 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
20470 * fd.io coding-style-patch-verification: ON
20473 * eval: (c-set-style "gnu")