2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vlibapi/api.h>
22 #include <vlibmemory/api.h>
23 #include <vlibsocket/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/l2/l2_input.h>
26 #include <vnet/l2tp/l2tp.h>
27 #include <vnet/vxlan/vxlan.h>
28 #include <vnet/gre/gre.h>
29 #include <vnet/vxlan-gpe/vxlan_gpe.h>
30 #include <vnet/lisp-gpe/lisp_gpe.h>
32 #include <vpp/api/vpe_msg_enum.h>
33 #include <vnet/l2/l2_classify.h>
34 #include <vnet/l2/l2_vtr.h>
35 #include <vnet/classify/input_acl.h>
36 #include <vnet/classify/policer_classify.h>
37 #include <vnet/classify/flow_classify.h>
38 #include <vnet/mpls/mpls.h>
39 #include <vnet/ipsec/ipsec.h>
40 #include <vnet/ipsec/ikev2.h>
42 #include <vnet/map/map.h>
43 #include <vnet/cop/cop.h>
44 #include <vnet/ip/ip6_hop_by_hop.h>
45 #include <vnet/ip/ip_source_and_port_range_check.h>
46 #include <vnet/policer/xlate.h>
47 #include <vnet/span/span.h>
48 #include <vnet/policer/policer.h>
49 #include <vnet/policer/police.h>
50 #include <vnet/mfib/mfib_types.h>
52 #include "vat/json_format.h"
57 #define vl_typedefs /* define message structures */
58 #include <vpp/api/vpe_all_api_h.h>
61 /* declare message handlers for each api */
63 #define vl_endianfun /* define message structures */
64 #include <vpp/api/vpe_all_api_h.h>
67 /* instantiate all the print functions we know about */
68 #define vl_print(handle, ...)
70 #include <vpp/api/vpe_all_api_h.h>
73 #define __plugin_msg_base 0
74 #include <vlibapi/vat_helper_macros.h>
77 vat_time_now (vat_main_t * vam)
79 #if VPP_API_TEST_BUILTIN
80 return vlib_time_now (vam->vlib_main);
82 return clib_time_now (&vam->clib_time);
87 errmsg (char *fmt, ...)
89 vat_main_t *vam = &vat_main;
94 s = va_format (0, fmt, &va);
99 #if VPP_API_TEST_BUILTIN
100 vlib_cli_output (vam->vlib_main, (char *) s);
103 if (vam->ifp != stdin)
104 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
105 vam->input_line_number);
106 fformat (vam->ofp, (char *) s);
114 #if VPP_API_TEST_BUILTIN == 0
116 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
118 vat_main_t *vam = va_arg (*args, vat_main_t *);
119 u32 *result = va_arg (*args, u32 *);
123 if (!unformat (input, "%s", &if_name))
126 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
133 /* Parse an IP4 address %d.%d.%d.%d. */
135 unformat_ip4_address (unformat_input_t * input, va_list * args)
137 u8 *result = va_arg (*args, u8 *);
140 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
143 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
155 unformat_ethernet_address (unformat_input_t * input, va_list * args)
157 u8 *result = va_arg (*args, u8 *);
160 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
161 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
165 for (i = 0; i < 6; i++)
166 if (a[i] >= (1 << 8))
169 for (i = 0; i < 6; i++)
175 /* Returns ethernet type as an int in host byte order. */
177 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
180 u16 *result = va_arg (*args, u16 *);
184 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
186 if (type >= (1 << 16))
194 /* Parse an IP6 address. */
196 unformat_ip6_address (unformat_input_t * input, va_list * args)
198 ip6_address_t *result = va_arg (*args, ip6_address_t *);
200 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
201 uword c, n_colon, double_colon_index;
203 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
204 double_colon_index = ARRAY_LEN (hex_quads);
205 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
208 if (c >= '0' && c <= '9')
210 else if (c >= 'a' && c <= 'f')
211 hex_digit = c + 10 - 'a';
212 else if (c >= 'A' && c <= 'F')
213 hex_digit = c + 10 - 'A';
214 else if (c == ':' && n_colon < 2)
218 unformat_put_input (input);
222 /* Too many hex quads. */
223 if (n_hex_quads >= ARRAY_LEN (hex_quads))
228 hex_quad = (hex_quad << 4) | hex_digit;
230 /* Hex quad must fit in 16 bits. */
231 if (n_hex_digits >= 4)
238 /* Save position of :: */
241 /* More than one :: ? */
242 if (double_colon_index < ARRAY_LEN (hex_quads))
244 double_colon_index = n_hex_quads;
247 if (n_colon > 0 && n_hex_digits > 0)
249 hex_quads[n_hex_quads++] = hex_quad;
255 if (n_hex_digits > 0)
256 hex_quads[n_hex_quads++] = hex_quad;
261 /* Expand :: to appropriate number of zero hex quads. */
262 if (double_colon_index < ARRAY_LEN (hex_quads))
264 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
266 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
267 hex_quads[n_zero + i] = hex_quads[i];
269 for (i = 0; i < n_zero; i++)
270 hex_quads[double_colon_index + i] = 0;
272 n_hex_quads = ARRAY_LEN (hex_quads);
275 /* Too few hex quads given. */
276 if (n_hex_quads < ARRAY_LEN (hex_quads))
279 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
280 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
287 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
289 u32 *r = va_arg (*args, u32 *);
292 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
293 foreach_ipsec_policy_action
301 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
303 u32 *r = va_arg (*args, u32 *);
306 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
307 foreach_ipsec_crypto_alg
315 format_ipsec_crypto_alg (u8 * s, va_list * args)
317 u32 i = va_arg (*args, u32);
322 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
323 foreach_ipsec_crypto_alg
326 return format (s, "unknown");
328 return format (s, "%s", t);
332 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
334 u32 *r = va_arg (*args, u32 *);
337 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
338 foreach_ipsec_integ_alg
346 format_ipsec_integ_alg (u8 * s, va_list * args)
348 u32 i = va_arg (*args, u32);
353 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
354 foreach_ipsec_integ_alg
357 return format (s, "unknown");
359 return format (s, "%s", t);
363 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
365 u32 *r = va_arg (*args, u32 *);
368 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
369 foreach_ikev2_auth_method
377 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
379 u32 *r = va_arg (*args, u32 *);
382 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
383 foreach_ikev2_id_type
389 #else /* VPP_API_TEST_BUILTIN == 1 */
391 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
393 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
394 vnet_main_t *vnm = vnet_get_main ();
395 u32 *result = va_arg (*args, u32 *);
398 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
401 *result = sw_if_index;
404 #endif /* VPP_API_TEST_BUILTIN */
407 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
409 u8 *r = va_arg (*args, u8 *);
411 if (unformat (input, "kbps"))
412 *r = SSE2_QOS_RATE_KBPS;
413 else if (unformat (input, "pps"))
414 *r = SSE2_QOS_RATE_PPS;
421 unformat_policer_round_type (unformat_input_t * input, va_list * args)
423 u8 *r = va_arg (*args, u8 *);
425 if (unformat (input, "closest"))
426 *r = SSE2_QOS_ROUND_TO_CLOSEST;
427 else if (unformat (input, "up"))
428 *r = SSE2_QOS_ROUND_TO_UP;
429 else if (unformat (input, "down"))
430 *r = SSE2_QOS_ROUND_TO_DOWN;
437 unformat_policer_type (unformat_input_t * input, va_list * args)
439 u8 *r = va_arg (*args, u8 *);
441 if (unformat (input, "1r2c"))
442 *r = SSE2_QOS_POLICER_TYPE_1R2C;
443 else if (unformat (input, "1r3c"))
444 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
445 else if (unformat (input, "2r3c-2698"))
446 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
447 else if (unformat (input, "2r3c-4115"))
448 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
449 else if (unformat (input, "2r3c-mef5cf1"))
450 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
457 unformat_dscp (unformat_input_t * input, va_list * va)
459 u8 *r = va_arg (*va, u8 *);
462 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
471 unformat_policer_action_type (unformat_input_t * input, va_list * va)
473 sse2_qos_pol_action_params_st *a
474 = va_arg (*va, sse2_qos_pol_action_params_st *);
476 if (unformat (input, "drop"))
477 a->action_type = SSE2_QOS_ACTION_DROP;
478 else if (unformat (input, "transmit"))
479 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
480 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
481 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
488 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
490 u32 *r = va_arg (*va, u32 *);
493 if (unformat (input, "ip4"))
494 tid = POLICER_CLASSIFY_TABLE_IP4;
495 else if (unformat (input, "ip6"))
496 tid = POLICER_CLASSIFY_TABLE_IP6;
497 else if (unformat (input, "l2"))
498 tid = POLICER_CLASSIFY_TABLE_L2;
507 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
509 u32 *r = va_arg (*va, u32 *);
512 if (unformat (input, "ip4"))
513 tid = FLOW_CLASSIFY_TABLE_IP4;
514 else if (unformat (input, "ip6"))
515 tid = FLOW_CLASSIFY_TABLE_IP6;
523 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
524 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
525 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
526 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
528 #if (VPP_API_TEST_BUILTIN==0)
530 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
532 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
533 mfib_itf_attribute_t attr;
536 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
538 if (unformat (input, mfib_itf_flag_long_names[attr]))
539 *iflags |= (1 << attr);
541 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
543 if (unformat (input, mfib_itf_flag_names[attr]))
544 *iflags |= (1 << attr);
547 return (old == *iflags ? 0 : 1);
551 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
553 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
554 mfib_entry_attribute_t attr;
557 FOR_EACH_MFIB_ATTRIBUTE (attr)
559 if (unformat (input, mfib_flag_long_names[attr]))
560 *eflags |= (1 << attr);
562 FOR_EACH_MFIB_ATTRIBUTE (attr)
564 if (unformat (input, mfib_flag_names[attr]))
565 *eflags |= (1 << attr);
568 return (old == *eflags ? 0 : 1);
572 format_ip4_address (u8 * s, va_list * args)
574 u8 *a = va_arg (*args, u8 *);
575 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
579 format_ip6_address (u8 * s, va_list * args)
581 ip6_address_t *a = va_arg (*args, ip6_address_t *);
582 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
584 i_max_n_zero = ARRAY_LEN (a->as_u16);
586 i_first_zero = i_max_n_zero;
588 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
590 u32 is_zero = a->as_u16[i] == 0;
591 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
597 if ((!is_zero && n_zeros > max_n_zeros)
598 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
600 i_max_n_zero = i_first_zero;
601 max_n_zeros = n_zeros;
602 i_first_zero = ARRAY_LEN (a->as_u16);
607 last_double_colon = 0;
608 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
610 if (i == i_max_n_zero && max_n_zeros > 1)
612 s = format (s, "::");
613 i += max_n_zeros - 1;
614 last_double_colon = 1;
618 s = format (s, "%s%x",
619 (last_double_colon || i == 0) ? "" : ":",
620 clib_net_to_host_u16 (a->as_u16[i]));
621 last_double_colon = 0;
628 /* Format an IP46 address. */
630 format_ip46_address (u8 * s, va_list * args)
632 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
633 ip46_type_t type = va_arg (*args, ip46_type_t);
639 is_ip4 = ip46_address_is_ip4 (ip46);
650 format (s, "%U", format_ip4_address, &ip46->ip4) :
651 format (s, "%U", format_ip6_address, &ip46->ip6);
655 format_ethernet_address (u8 * s, va_list * args)
657 u8 *a = va_arg (*args, u8 *);
659 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
660 a[0], a[1], a[2], a[3], a[4], a[5]);
665 increment_v4_address (ip4_address_t * a)
669 v = ntohl (a->as_u32) + 1;
670 a->as_u32 = ntohl (v);
674 increment_v6_address (ip6_address_t * a)
678 v0 = clib_net_to_host_u64 (a->as_u64[0]);
679 v1 = clib_net_to_host_u64 (a->as_u64[1]);
684 a->as_u64[0] = clib_net_to_host_u64 (v0);
685 a->as_u64[1] = clib_net_to_host_u64 (v1);
689 increment_mac_address (u64 * mac)
693 tmp = clib_net_to_host_u64 (tmp);
694 tmp += 1 << 16; /* skip unused (least significant) octets */
695 tmp = clib_host_to_net_u64 (tmp);
699 static void vl_api_create_loopback_reply_t_handler
700 (vl_api_create_loopback_reply_t * mp)
702 vat_main_t *vam = &vat_main;
703 i32 retval = ntohl (mp->retval);
705 vam->retval = retval;
706 vam->regenerate_interface_table = 1;
707 vam->sw_if_index = ntohl (mp->sw_if_index);
708 vam->result_ready = 1;
711 static void vl_api_create_loopback_reply_t_handler_json
712 (vl_api_create_loopback_reply_t * mp)
714 vat_main_t *vam = &vat_main;
715 vat_json_node_t node;
717 vat_json_init_object (&node);
718 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
719 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
721 vat_json_print (vam->ofp, &node);
722 vat_json_free (&node);
723 vam->retval = ntohl (mp->retval);
724 vam->result_ready = 1;
727 static void vl_api_create_loopback_instance_reply_t_handler
728 (vl_api_create_loopback_instance_reply_t * mp)
730 vat_main_t *vam = &vat_main;
731 i32 retval = ntohl (mp->retval);
733 vam->retval = retval;
734 vam->regenerate_interface_table = 1;
735 vam->sw_if_index = ntohl (mp->sw_if_index);
736 vam->result_ready = 1;
739 static void vl_api_create_loopback_instance_reply_t_handler_json
740 (vl_api_create_loopback_instance_reply_t * mp)
742 vat_main_t *vam = &vat_main;
743 vat_json_node_t node;
745 vat_json_init_object (&node);
746 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
747 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
749 vat_json_print (vam->ofp, &node);
750 vat_json_free (&node);
751 vam->retval = ntohl (mp->retval);
752 vam->result_ready = 1;
755 static void vl_api_af_packet_create_reply_t_handler
756 (vl_api_af_packet_create_reply_t * mp)
758 vat_main_t *vam = &vat_main;
759 i32 retval = ntohl (mp->retval);
761 vam->retval = retval;
762 vam->regenerate_interface_table = 1;
763 vam->sw_if_index = ntohl (mp->sw_if_index);
764 vam->result_ready = 1;
767 static void vl_api_af_packet_create_reply_t_handler_json
768 (vl_api_af_packet_create_reply_t * mp)
770 vat_main_t *vam = &vat_main;
771 vat_json_node_t node;
773 vat_json_init_object (&node);
774 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
775 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
777 vat_json_print (vam->ofp, &node);
778 vat_json_free (&node);
780 vam->retval = ntohl (mp->retval);
781 vam->result_ready = 1;
784 static void vl_api_create_vlan_subif_reply_t_handler
785 (vl_api_create_vlan_subif_reply_t * mp)
787 vat_main_t *vam = &vat_main;
788 i32 retval = ntohl (mp->retval);
790 vam->retval = retval;
791 vam->regenerate_interface_table = 1;
792 vam->sw_if_index = ntohl (mp->sw_if_index);
793 vam->result_ready = 1;
796 static void vl_api_create_vlan_subif_reply_t_handler_json
797 (vl_api_create_vlan_subif_reply_t * mp)
799 vat_main_t *vam = &vat_main;
800 vat_json_node_t node;
802 vat_json_init_object (&node);
803 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
804 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
806 vat_json_print (vam->ofp, &node);
807 vat_json_free (&node);
809 vam->retval = ntohl (mp->retval);
810 vam->result_ready = 1;
813 static void vl_api_create_subif_reply_t_handler
814 (vl_api_create_subif_reply_t * mp)
816 vat_main_t *vam = &vat_main;
817 i32 retval = ntohl (mp->retval);
819 vam->retval = retval;
820 vam->regenerate_interface_table = 1;
821 vam->sw_if_index = ntohl (mp->sw_if_index);
822 vam->result_ready = 1;
825 static void vl_api_create_subif_reply_t_handler_json
826 (vl_api_create_subif_reply_t * mp)
828 vat_main_t *vam = &vat_main;
829 vat_json_node_t node;
831 vat_json_init_object (&node);
832 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
833 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
835 vat_json_print (vam->ofp, &node);
836 vat_json_free (&node);
838 vam->retval = ntohl (mp->retval);
839 vam->result_ready = 1;
842 static void vl_api_interface_name_renumber_reply_t_handler
843 (vl_api_interface_name_renumber_reply_t * mp)
845 vat_main_t *vam = &vat_main;
846 i32 retval = ntohl (mp->retval);
848 vam->retval = retval;
849 vam->regenerate_interface_table = 1;
850 vam->result_ready = 1;
853 static void vl_api_interface_name_renumber_reply_t_handler_json
854 (vl_api_interface_name_renumber_reply_t * mp)
856 vat_main_t *vam = &vat_main;
857 vat_json_node_t node;
859 vat_json_init_object (&node);
860 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
862 vat_json_print (vam->ofp, &node);
863 vat_json_free (&node);
865 vam->retval = ntohl (mp->retval);
866 vam->result_ready = 1;
870 * Special-case: build the interface table, maintain
871 * the next loopback sw_if_index vbl.
873 static void vl_api_sw_interface_details_t_handler
874 (vl_api_sw_interface_details_t * mp)
876 vat_main_t *vam = &vat_main;
877 u8 *s = format (0, "%s%c", mp->interface_name, 0);
879 hash_set_mem (vam->sw_if_index_by_interface_name, s,
880 ntohl (mp->sw_if_index));
882 /* In sub interface case, fill the sub interface table entry */
883 if (mp->sw_if_index != mp->sup_sw_if_index)
885 sw_interface_subif_t *sub = NULL;
887 vec_add2 (vam->sw_if_subif_table, sub, 1);
889 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
890 strncpy ((char *) sub->interface_name, (char *) s,
891 vec_len (sub->interface_name));
892 sub->sw_if_index = ntohl (mp->sw_if_index);
893 sub->sub_id = ntohl (mp->sub_id);
895 sub->sub_dot1ad = mp->sub_dot1ad;
896 sub->sub_number_of_tags = mp->sub_number_of_tags;
897 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
898 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
899 sub->sub_exact_match = mp->sub_exact_match;
900 sub->sub_default = mp->sub_default;
901 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
902 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
904 /* vlan tag rewrite */
905 sub->vtr_op = ntohl (mp->vtr_op);
906 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
907 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
908 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
912 static void vl_api_sw_interface_details_t_handler_json
913 (vl_api_sw_interface_details_t * mp)
915 vat_main_t *vam = &vat_main;
916 vat_json_node_t *node = NULL;
918 if (VAT_JSON_ARRAY != vam->json_tree.type)
920 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
921 vat_json_init_array (&vam->json_tree);
923 node = vat_json_array_add (&vam->json_tree);
925 vat_json_init_object (node);
926 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
927 vat_json_object_add_uint (node, "sup_sw_if_index",
928 ntohl (mp->sup_sw_if_index));
929 vat_json_object_add_uint (node, "l2_address_length",
930 ntohl (mp->l2_address_length));
931 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
932 sizeof (mp->l2_address));
933 vat_json_object_add_string_copy (node, "interface_name",
935 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
936 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
937 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
938 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
939 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
940 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
941 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
942 vat_json_object_add_uint (node, "sub_number_of_tags",
943 mp->sub_number_of_tags);
944 vat_json_object_add_uint (node, "sub_outer_vlan_id",
945 ntohs (mp->sub_outer_vlan_id));
946 vat_json_object_add_uint (node, "sub_inner_vlan_id",
947 ntohs (mp->sub_inner_vlan_id));
948 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
949 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
950 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
951 mp->sub_outer_vlan_id_any);
952 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
953 mp->sub_inner_vlan_id_any);
954 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
955 vat_json_object_add_uint (node, "vtr_push_dot1q",
956 ntohl (mp->vtr_push_dot1q));
957 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
958 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
961 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
963 format_ethernet_address,
965 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
967 format_ethernet_address,
969 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
970 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
974 #if VPP_API_TEST_BUILTIN == 0
975 static void vl_api_sw_interface_set_flags_t_handler
976 (vl_api_sw_interface_set_flags_t * mp)
978 vat_main_t *vam = &vat_main;
979 if (vam->interface_event_display)
980 errmsg ("interface flags: sw_if_index %d %s %s",
981 ntohl (mp->sw_if_index),
982 mp->admin_up_down ? "admin-up" : "admin-down",
983 mp->link_up_down ? "link-up" : "link-down");
987 static void vl_api_sw_interface_set_flags_t_handler_json
988 (vl_api_sw_interface_set_flags_t * mp)
990 /* JSON output not supported */
994 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
996 vat_main_t *vam = &vat_main;
997 i32 retval = ntohl (mp->retval);
999 vam->retval = retval;
1000 vam->shmem_result = (u8 *) mp->reply_in_shmem;
1001 vam->result_ready = 1;
1005 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1007 vat_main_t *vam = &vat_main;
1008 vat_json_node_t node;
1009 api_main_t *am = &api_main;
1013 vat_json_init_object (&node);
1014 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1015 vat_json_object_add_uint (&node, "reply_in_shmem",
1016 ntohl (mp->reply_in_shmem));
1017 /* Toss the shared-memory original... */
1018 pthread_mutex_lock (&am->vlib_rp->mutex);
1019 oldheap = svm_push_data_heap (am->vlib_rp);
1021 reply = (u8 *) (mp->reply_in_shmem);
1024 svm_pop_heap (oldheap);
1025 pthread_mutex_unlock (&am->vlib_rp->mutex);
1027 vat_json_print (vam->ofp, &node);
1028 vat_json_free (&node);
1030 vam->retval = ntohl (mp->retval);
1031 vam->result_ready = 1;
1035 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1037 vat_main_t *vam = &vat_main;
1038 i32 retval = ntohl (mp->retval);
1040 vam->retval = retval;
1041 vam->cmd_reply = mp->reply;
1042 vam->result_ready = 1;
1046 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1048 vat_main_t *vam = &vat_main;
1049 vat_json_node_t node;
1051 vat_json_init_object (&node);
1052 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1053 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1055 vat_json_print (vam->ofp, &node);
1056 vat_json_free (&node);
1058 vam->retval = ntohl (mp->retval);
1059 vam->result_ready = 1;
1062 static void vl_api_classify_add_del_table_reply_t_handler
1063 (vl_api_classify_add_del_table_reply_t * mp)
1065 vat_main_t *vam = &vat_main;
1066 i32 retval = ntohl (mp->retval);
1067 if (vam->async_mode)
1069 vam->async_errors += (retval < 0);
1073 vam->retval = retval;
1075 ((mp->new_table_index != 0xFFFFFFFF) ||
1076 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1077 (mp->match_n_vectors != 0xFFFFFFFF)))
1079 * Note: this is just barely thread-safe, depends on
1080 * the main thread spinning waiting for an answer...
1082 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1083 ntohl (mp->new_table_index),
1084 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1085 vam->result_ready = 1;
1089 static void vl_api_classify_add_del_table_reply_t_handler_json
1090 (vl_api_classify_add_del_table_reply_t * mp)
1092 vat_main_t *vam = &vat_main;
1093 vat_json_node_t node;
1095 vat_json_init_object (&node);
1096 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1097 vat_json_object_add_uint (&node, "new_table_index",
1098 ntohl (mp->new_table_index));
1099 vat_json_object_add_uint (&node, "skip_n_vectors",
1100 ntohl (mp->skip_n_vectors));
1101 vat_json_object_add_uint (&node, "match_n_vectors",
1102 ntohl (mp->match_n_vectors));
1104 vat_json_print (vam->ofp, &node);
1105 vat_json_free (&node);
1107 vam->retval = ntohl (mp->retval);
1108 vam->result_ready = 1;
1111 static void vl_api_get_node_index_reply_t_handler
1112 (vl_api_get_node_index_reply_t * mp)
1114 vat_main_t *vam = &vat_main;
1115 i32 retval = ntohl (mp->retval);
1116 if (vam->async_mode)
1118 vam->async_errors += (retval < 0);
1122 vam->retval = retval;
1124 errmsg ("node index %d", ntohl (mp->node_index));
1125 vam->result_ready = 1;
1129 static void vl_api_get_node_index_reply_t_handler_json
1130 (vl_api_get_node_index_reply_t * mp)
1132 vat_main_t *vam = &vat_main;
1133 vat_json_node_t node;
1135 vat_json_init_object (&node);
1136 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1137 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1139 vat_json_print (vam->ofp, &node);
1140 vat_json_free (&node);
1142 vam->retval = ntohl (mp->retval);
1143 vam->result_ready = 1;
1146 static void vl_api_get_next_index_reply_t_handler
1147 (vl_api_get_next_index_reply_t * mp)
1149 vat_main_t *vam = &vat_main;
1150 i32 retval = ntohl (mp->retval);
1151 if (vam->async_mode)
1153 vam->async_errors += (retval < 0);
1157 vam->retval = retval;
1159 errmsg ("next node index %d", ntohl (mp->next_index));
1160 vam->result_ready = 1;
1164 static void vl_api_get_next_index_reply_t_handler_json
1165 (vl_api_get_next_index_reply_t * mp)
1167 vat_main_t *vam = &vat_main;
1168 vat_json_node_t node;
1170 vat_json_init_object (&node);
1171 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1172 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1174 vat_json_print (vam->ofp, &node);
1175 vat_json_free (&node);
1177 vam->retval = ntohl (mp->retval);
1178 vam->result_ready = 1;
1181 static void vl_api_add_node_next_reply_t_handler
1182 (vl_api_add_node_next_reply_t * mp)
1184 vat_main_t *vam = &vat_main;
1185 i32 retval = ntohl (mp->retval);
1186 if (vam->async_mode)
1188 vam->async_errors += (retval < 0);
1192 vam->retval = retval;
1194 errmsg ("next index %d", ntohl (mp->next_index));
1195 vam->result_ready = 1;
1199 static void vl_api_add_node_next_reply_t_handler_json
1200 (vl_api_add_node_next_reply_t * mp)
1202 vat_main_t *vam = &vat_main;
1203 vat_json_node_t node;
1205 vat_json_init_object (&node);
1206 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1207 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1209 vat_json_print (vam->ofp, &node);
1210 vat_json_free (&node);
1212 vam->retval = ntohl (mp->retval);
1213 vam->result_ready = 1;
1216 static void vl_api_show_version_reply_t_handler
1217 (vl_api_show_version_reply_t * mp)
1219 vat_main_t *vam = &vat_main;
1220 i32 retval = ntohl (mp->retval);
1224 errmsg (" program: %s", mp->program);
1225 errmsg (" version: %s", mp->version);
1226 errmsg (" build date: %s", mp->build_date);
1227 errmsg ("build directory: %s", mp->build_directory);
1229 vam->retval = retval;
1230 vam->result_ready = 1;
1233 static void vl_api_show_version_reply_t_handler_json
1234 (vl_api_show_version_reply_t * mp)
1236 vat_main_t *vam = &vat_main;
1237 vat_json_node_t node;
1239 vat_json_init_object (&node);
1240 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1241 vat_json_object_add_string_copy (&node, "program", mp->program);
1242 vat_json_object_add_string_copy (&node, "version", mp->version);
1243 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1244 vat_json_object_add_string_copy (&node, "build_directory",
1245 mp->build_directory);
1247 vat_json_print (vam->ofp, &node);
1248 vat_json_free (&node);
1250 vam->retval = ntohl (mp->retval);
1251 vam->result_ready = 1;
1255 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1257 u32 sw_if_index = ntohl (mp->sw_if_index);
1258 errmsg ("arp %s event: address %U new mac %U sw_if_index %d",
1259 mp->mac_ip ? "mac/ip binding" : "address resolution",
1260 format_ip4_address, &mp->address,
1261 format_ethernet_address, mp->new_mac, sw_if_index);
1265 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1267 /* JSON output not supported */
1271 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1273 u32 sw_if_index = ntohl (mp->sw_if_index);
1274 errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d",
1275 mp->mac_ip ? "mac/ip binding" : "address resolution",
1276 format_ip6_address, mp->address,
1277 format_ethernet_address, mp->new_mac, sw_if_index);
1281 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1283 /* JSON output not supported */
1287 * Special-case: build the bridge domain table, maintain
1288 * the next bd id vbl.
1290 static void vl_api_bridge_domain_details_t_handler
1291 (vl_api_bridge_domain_details_t * mp)
1293 vat_main_t *vam = &vat_main;
1294 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1296 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1297 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1299 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1300 ntohl (mp->bd_id), mp->learn, mp->forward,
1301 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1304 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG", "Interface Name");
1307 static void vl_api_bridge_domain_details_t_handler_json
1308 (vl_api_bridge_domain_details_t * mp)
1310 vat_main_t *vam = &vat_main;
1311 vat_json_node_t *node, *array = NULL;
1313 if (VAT_JSON_ARRAY != vam->json_tree.type)
1315 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1316 vat_json_init_array (&vam->json_tree);
1318 node = vat_json_array_add (&vam->json_tree);
1320 vat_json_init_object (node);
1321 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1322 vat_json_object_add_uint (node, "flood", mp->flood);
1323 vat_json_object_add_uint (node, "forward", mp->forward);
1324 vat_json_object_add_uint (node, "learn", mp->learn);
1325 vat_json_object_add_uint (node, "bvi_sw_if_index",
1326 ntohl (mp->bvi_sw_if_index));
1327 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1328 array = vat_json_object_add (node, "sw_if");
1329 vat_json_init_array (array);
1333 * Special-case: build the bridge domain sw if table.
1335 static void vl_api_bridge_domain_sw_if_details_t_handler
1336 (vl_api_bridge_domain_sw_if_details_t * mp)
1338 vat_main_t *vam = &vat_main;
1343 sw_if_index = ntohl (mp->sw_if_index);
1345 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1347 if ((u32) p->value[0] == sw_if_index)
1349 sw_if_name = (u8 *)(p->key);
1355 print (vam->ofp, "%7d %3d %s", sw_if_index,
1356 mp->shg, sw_if_name ? (char *) sw_if_name :
1357 "sw_if_index not found!");
1360 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1361 (vl_api_bridge_domain_sw_if_details_t * mp)
1363 vat_main_t *vam = &vat_main;
1364 vat_json_node_t *node = NULL;
1365 uword last_index = 0;
1367 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1368 ASSERT (vec_len (vam->json_tree.array) >= 1);
1369 last_index = vec_len (vam->json_tree.array) - 1;
1370 node = &vam->json_tree.array[last_index];
1371 node = vat_json_object_get_element (node, "sw_if");
1372 ASSERT (NULL != node);
1373 node = vat_json_array_add (node);
1375 vat_json_init_object (node);
1376 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1377 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1378 vat_json_object_add_uint (node, "shg", mp->shg);
1381 static void vl_api_control_ping_reply_t_handler
1382 (vl_api_control_ping_reply_t * mp)
1384 vat_main_t *vam = &vat_main;
1385 i32 retval = ntohl (mp->retval);
1386 if (vam->async_mode)
1388 vam->async_errors += (retval < 0);
1392 vam->retval = retval;
1393 vam->result_ready = 1;
1397 static void vl_api_control_ping_reply_t_handler_json
1398 (vl_api_control_ping_reply_t * mp)
1400 vat_main_t *vam = &vat_main;
1401 i32 retval = ntohl (mp->retval);
1403 if (VAT_JSON_NONE != vam->json_tree.type)
1405 vat_json_print (vam->ofp, &vam->json_tree);
1406 vat_json_free (&vam->json_tree);
1407 vam->json_tree.type = VAT_JSON_NONE;
1412 vat_json_init_array (&vam->json_tree);
1413 vat_json_print (vam->ofp, &vam->json_tree);
1414 vam->json_tree.type = VAT_JSON_NONE;
1417 vam->retval = retval;
1418 vam->result_ready = 1;
1422 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1424 vat_main_t *vam = &vat_main;
1425 i32 retval = ntohl (mp->retval);
1426 if (vam->async_mode)
1428 vam->async_errors += (retval < 0);
1432 vam->retval = retval;
1433 vam->result_ready = 1;
1437 static void vl_api_l2_flags_reply_t_handler_json
1438 (vl_api_l2_flags_reply_t * mp)
1440 vat_main_t *vam = &vat_main;
1441 vat_json_node_t node;
1443 vat_json_init_object (&node);
1444 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1445 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1446 ntohl (mp->resulting_feature_bitmap));
1448 vat_json_print (vam->ofp, &node);
1449 vat_json_free (&node);
1451 vam->retval = ntohl (mp->retval);
1452 vam->result_ready = 1;
1455 static void vl_api_bridge_flags_reply_t_handler
1456 (vl_api_bridge_flags_reply_t * mp)
1458 vat_main_t *vam = &vat_main;
1459 i32 retval = ntohl (mp->retval);
1460 if (vam->async_mode)
1462 vam->async_errors += (retval < 0);
1466 vam->retval = retval;
1467 vam->result_ready = 1;
1471 static void vl_api_bridge_flags_reply_t_handler_json
1472 (vl_api_bridge_flags_reply_t * mp)
1474 vat_main_t *vam = &vat_main;
1475 vat_json_node_t node;
1477 vat_json_init_object (&node);
1478 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1479 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1480 ntohl (mp->resulting_feature_bitmap));
1482 vat_json_print (vam->ofp, &node);
1483 vat_json_free (&node);
1485 vam->retval = ntohl (mp->retval);
1486 vam->result_ready = 1;
1489 static void vl_api_tap_connect_reply_t_handler
1490 (vl_api_tap_connect_reply_t * mp)
1492 vat_main_t *vam = &vat_main;
1493 i32 retval = ntohl (mp->retval);
1494 if (vam->async_mode)
1496 vam->async_errors += (retval < 0);
1500 vam->retval = retval;
1501 vam->sw_if_index = ntohl (mp->sw_if_index);
1502 vam->result_ready = 1;
1507 static void vl_api_tap_connect_reply_t_handler_json
1508 (vl_api_tap_connect_reply_t * mp)
1510 vat_main_t *vam = &vat_main;
1511 vat_json_node_t node;
1513 vat_json_init_object (&node);
1514 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1515 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1517 vat_json_print (vam->ofp, &node);
1518 vat_json_free (&node);
1520 vam->retval = ntohl (mp->retval);
1521 vam->result_ready = 1;
1526 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1528 vat_main_t *vam = &vat_main;
1529 i32 retval = ntohl (mp->retval);
1530 if (vam->async_mode)
1532 vam->async_errors += (retval < 0);
1536 vam->retval = retval;
1537 vam->sw_if_index = ntohl (mp->sw_if_index);
1538 vam->result_ready = 1;
1542 static void vl_api_tap_modify_reply_t_handler_json
1543 (vl_api_tap_modify_reply_t * mp)
1545 vat_main_t *vam = &vat_main;
1546 vat_json_node_t node;
1548 vat_json_init_object (&node);
1549 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1550 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1552 vat_json_print (vam->ofp, &node);
1553 vat_json_free (&node);
1555 vam->retval = ntohl (mp->retval);
1556 vam->result_ready = 1;
1560 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1562 vat_main_t *vam = &vat_main;
1563 i32 retval = ntohl (mp->retval);
1564 if (vam->async_mode)
1566 vam->async_errors += (retval < 0);
1570 vam->retval = retval;
1571 vam->result_ready = 1;
1575 static void vl_api_tap_delete_reply_t_handler_json
1576 (vl_api_tap_delete_reply_t * mp)
1578 vat_main_t *vam = &vat_main;
1579 vat_json_node_t node;
1581 vat_json_init_object (&node);
1582 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1584 vat_json_print (vam->ofp, &node);
1585 vat_json_free (&node);
1587 vam->retval = ntohl (mp->retval);
1588 vam->result_ready = 1;
1591 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1592 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1594 vat_main_t *vam = &vat_main;
1595 i32 retval = ntohl (mp->retval);
1596 if (vam->async_mode)
1598 vam->async_errors += (retval < 0);
1602 vam->retval = retval;
1603 vam->result_ready = 1;
1607 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1608 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1610 vat_main_t *vam = &vat_main;
1611 vat_json_node_t node;
1613 vat_json_init_object (&node);
1614 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1615 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1616 ntohl (mp->sw_if_index));
1618 vat_json_print (vam->ofp, &node);
1619 vat_json_free (&node);
1621 vam->retval = ntohl (mp->retval);
1622 vam->result_ready = 1;
1625 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1626 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1628 vat_main_t *vam = &vat_main;
1629 i32 retval = ntohl (mp->retval);
1630 if (vam->async_mode)
1632 vam->async_errors += (retval < 0);
1636 vam->retval = retval;
1637 vam->sw_if_index = ntohl (mp->sw_if_index);
1638 vam->result_ready = 1;
1642 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1643 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1645 vat_main_t *vam = &vat_main;
1646 vat_json_node_t node;
1648 vat_json_init_object (&node);
1649 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1650 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1652 vat_json_print (vam->ofp, &node);
1653 vat_json_free (&node);
1655 vam->retval = ntohl (mp->retval);
1656 vam->result_ready = 1;
1660 static void vl_api_one_add_del_locator_set_reply_t_handler
1661 (vl_api_one_add_del_locator_set_reply_t * mp)
1663 vat_main_t *vam = &vat_main;
1664 i32 retval = ntohl (mp->retval);
1665 if (vam->async_mode)
1667 vam->async_errors += (retval < 0);
1671 vam->retval = retval;
1672 vam->result_ready = 1;
1676 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1677 (vl_api_one_add_del_locator_set_reply_t * mp)
1679 vat_main_t *vam = &vat_main;
1680 vat_json_node_t node;
1682 vat_json_init_object (&node);
1683 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1684 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1686 vat_json_print (vam->ofp, &node);
1687 vat_json_free (&node);
1689 vam->retval = ntohl (mp->retval);
1690 vam->result_ready = 1;
1693 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1694 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1696 vat_main_t *vam = &vat_main;
1697 i32 retval = ntohl (mp->retval);
1698 if (vam->async_mode)
1700 vam->async_errors += (retval < 0);
1704 vam->retval = retval;
1705 vam->sw_if_index = ntohl (mp->sw_if_index);
1706 vam->result_ready = 1;
1710 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1711 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1713 vat_main_t *vam = &vat_main;
1714 vat_json_node_t node;
1716 vat_json_init_object (&node);
1717 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1718 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1720 vat_json_print (vam->ofp, &node);
1721 vat_json_free (&node);
1723 vam->retval = ntohl (mp->retval);
1724 vam->result_ready = 1;
1727 static void vl_api_gre_add_del_tunnel_reply_t_handler
1728 (vl_api_gre_add_del_tunnel_reply_t * mp)
1730 vat_main_t *vam = &vat_main;
1731 i32 retval = ntohl (mp->retval);
1732 if (vam->async_mode)
1734 vam->async_errors += (retval < 0);
1738 vam->retval = retval;
1739 vam->sw_if_index = ntohl (mp->sw_if_index);
1740 vam->result_ready = 1;
1744 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1745 (vl_api_gre_add_del_tunnel_reply_t * mp)
1747 vat_main_t *vam = &vat_main;
1748 vat_json_node_t node;
1750 vat_json_init_object (&node);
1751 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1752 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1754 vat_json_print (vam->ofp, &node);
1755 vat_json_free (&node);
1757 vam->retval = ntohl (mp->retval);
1758 vam->result_ready = 1;
1761 static void vl_api_create_vhost_user_if_reply_t_handler
1762 (vl_api_create_vhost_user_if_reply_t * mp)
1764 vat_main_t *vam = &vat_main;
1765 i32 retval = ntohl (mp->retval);
1766 if (vam->async_mode)
1768 vam->async_errors += (retval < 0);
1772 vam->retval = retval;
1773 vam->sw_if_index = ntohl (mp->sw_if_index);
1774 vam->result_ready = 1;
1778 static void vl_api_create_vhost_user_if_reply_t_handler_json
1779 (vl_api_create_vhost_user_if_reply_t * mp)
1781 vat_main_t *vam = &vat_main;
1782 vat_json_node_t node;
1784 vat_json_init_object (&node);
1785 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1786 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1788 vat_json_print (vam->ofp, &node);
1789 vat_json_free (&node);
1791 vam->retval = ntohl (mp->retval);
1792 vam->result_ready = 1;
1795 static void vl_api_ip_address_details_t_handler
1796 (vl_api_ip_address_details_t * mp)
1798 vat_main_t *vam = &vat_main;
1799 static ip_address_details_t empty_ip_address_details = { {0} };
1800 ip_address_details_t *address = NULL;
1801 ip_details_t *current_ip_details = NULL;
1802 ip_details_t *details = NULL;
1804 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1806 if (!details || vam->current_sw_if_index >= vec_len (details)
1807 || !details[vam->current_sw_if_index].present)
1809 errmsg ("ip address details arrived but not stored");
1810 errmsg ("ip_dump should be called first");
1814 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1816 #define addresses (current_ip_details->addr)
1818 vec_validate_init_empty (addresses, vec_len (addresses),
1819 empty_ip_address_details);
1821 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1823 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1824 address->prefix_length = mp->prefix_length;
1828 static void vl_api_ip_address_details_t_handler_json
1829 (vl_api_ip_address_details_t * mp)
1831 vat_main_t *vam = &vat_main;
1832 vat_json_node_t *node = NULL;
1833 struct in6_addr ip6;
1836 if (VAT_JSON_ARRAY != vam->json_tree.type)
1838 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1839 vat_json_init_array (&vam->json_tree);
1841 node = vat_json_array_add (&vam->json_tree);
1843 vat_json_init_object (node);
1846 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1847 vat_json_object_add_ip6 (node, "ip", ip6);
1851 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1852 vat_json_object_add_ip4 (node, "ip", ip4);
1854 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1858 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1860 vat_main_t *vam = &vat_main;
1861 static ip_details_t empty_ip_details = { 0 };
1862 ip_details_t *ip = NULL;
1863 u32 sw_if_index = ~0;
1865 sw_if_index = ntohl (mp->sw_if_index);
1867 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1868 sw_if_index, empty_ip_details);
1870 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1877 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1879 vat_main_t *vam = &vat_main;
1881 if (VAT_JSON_ARRAY != vam->json_tree.type)
1883 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1884 vat_json_init_array (&vam->json_tree);
1886 vat_json_array_add_uint (&vam->json_tree,
1887 clib_net_to_host_u32 (mp->sw_if_index));
1890 static void vl_api_map_domain_details_t_handler_json
1891 (vl_api_map_domain_details_t * mp)
1893 vat_json_node_t *node = NULL;
1894 vat_main_t *vam = &vat_main;
1895 struct in6_addr ip6;
1898 if (VAT_JSON_ARRAY != vam->json_tree.type)
1900 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1901 vat_json_init_array (&vam->json_tree);
1904 node = vat_json_array_add (&vam->json_tree);
1905 vat_json_init_object (node);
1907 vat_json_object_add_uint (node, "domain_index",
1908 clib_net_to_host_u32 (mp->domain_index));
1909 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1910 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1911 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1912 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1913 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1914 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1915 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1916 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1917 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1918 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1919 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1920 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1921 vat_json_object_add_uint (node, "flags", mp->flags);
1922 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1923 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1926 static void vl_api_map_domain_details_t_handler
1927 (vl_api_map_domain_details_t * mp)
1929 vat_main_t *vam = &vat_main;
1931 if (mp->is_translation)
1934 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
1935 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1936 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1937 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1938 clib_net_to_host_u32 (mp->domain_index));
1943 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
1944 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1945 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1946 format_ip6_address, mp->ip6_src,
1947 clib_net_to_host_u32 (mp->domain_index));
1949 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
1950 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1951 mp->is_translation ? "map-t" : "");
1954 static void vl_api_map_rule_details_t_handler_json
1955 (vl_api_map_rule_details_t * mp)
1957 struct in6_addr ip6;
1958 vat_json_node_t *node = NULL;
1959 vat_main_t *vam = &vat_main;
1961 if (VAT_JSON_ARRAY != vam->json_tree.type)
1963 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1964 vat_json_init_array (&vam->json_tree);
1967 node = vat_json_array_add (&vam->json_tree);
1968 vat_json_init_object (node);
1970 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1971 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1972 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1976 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1978 vat_main_t *vam = &vat_main;
1979 print (vam->ofp, " %d (psid) %U (ip6-dst)",
1980 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1984 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1986 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1987 "router_addr %U host_mac %U",
1988 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1989 format_ip4_address, &mp->host_address,
1990 format_ip4_address, &mp->router_address,
1991 format_ethernet_address, mp->host_mac);
1994 static void vl_api_dhcp_compl_event_t_handler_json
1995 (vl_api_dhcp_compl_event_t * mp)
1997 /* JSON output not supported */
2001 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2004 vat_main_t *vam = &vat_main;
2005 static u64 default_counter = 0;
2007 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2009 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2010 sw_if_index, default_counter);
2011 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2015 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2016 interface_counter_t counter)
2018 vat_main_t *vam = &vat_main;
2019 static interface_counter_t default_counter = { 0, };
2021 vec_validate_init_empty (vam->combined_interface_counters,
2022 vnet_counter_type, NULL);
2023 vec_validate_init_empty (vam->combined_interface_counters
2024 [vnet_counter_type], sw_if_index, default_counter);
2025 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2028 static void vl_api_vnet_interface_counters_t_handler
2029 (vl_api_vnet_interface_counters_t * mp)
2034 static void vl_api_vnet_interface_counters_t_handler_json
2035 (vl_api_vnet_interface_counters_t * mp)
2037 interface_counter_t counter;
2042 u32 first_sw_if_index;
2045 count = ntohl (mp->count);
2046 first_sw_if_index = ntohl (mp->first_sw_if_index);
2048 if (!mp->is_combined)
2050 v_packets = (u64 *) & mp->data;
2051 for (i = 0; i < count; i++)
2054 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2055 set_simple_interface_counter (mp->vnet_counter_type,
2056 first_sw_if_index + i, packets);
2062 v = (vlib_counter_t *) & mp->data;
2063 for (i = 0; i < count; i++)
2066 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2068 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2069 set_combined_interface_counter (mp->vnet_counter_type,
2070 first_sw_if_index + i, counter);
2077 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2079 vat_main_t *vam = &vat_main;
2082 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2084 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2093 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2095 vat_main_t *vam = &vat_main;
2098 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2100 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2108 static void vl_api_vnet_ip4_fib_counters_t_handler
2109 (vl_api_vnet_ip4_fib_counters_t * mp)
2114 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2115 (vl_api_vnet_ip4_fib_counters_t * mp)
2117 vat_main_t *vam = &vat_main;
2118 vl_api_ip4_fib_counter_t *v;
2119 ip4_fib_counter_t *counter;
2126 vrf_id = ntohl (mp->vrf_id);
2127 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2128 if (~0 == vrf_index)
2130 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2131 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2132 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2133 vec_validate (vam->ip4_fib_counters, vrf_index);
2134 vam->ip4_fib_counters[vrf_index] = NULL;
2137 vec_free (vam->ip4_fib_counters[vrf_index]);
2138 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2139 count = ntohl (mp->count);
2140 for (i = 0; i < count; i++)
2142 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2143 counter = &vam->ip4_fib_counters[vrf_index][i];
2144 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2145 counter->address = ip4;
2146 counter->address_length = v->address_length;
2147 counter->packets = clib_net_to_host_u64 (v->packets);
2148 counter->bytes = clib_net_to_host_u64 (v->bytes);
2153 static void vl_api_vnet_ip4_nbr_counters_t_handler
2154 (vl_api_vnet_ip4_nbr_counters_t * mp)
2159 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2160 (vl_api_vnet_ip4_nbr_counters_t * mp)
2162 vat_main_t *vam = &vat_main;
2163 vl_api_ip4_nbr_counter_t *v;
2164 ip4_nbr_counter_t *counter;
2169 sw_if_index = ntohl (mp->sw_if_index);
2170 count = ntohl (mp->count);
2171 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2174 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2176 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2177 for (i = 0; i < count; i++)
2179 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2180 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2181 counter->address.s_addr = v->address;
2182 counter->packets = clib_net_to_host_u64 (v->packets);
2183 counter->bytes = clib_net_to_host_u64 (v->bytes);
2184 counter->linkt = v->link_type;
2189 static void vl_api_vnet_ip6_fib_counters_t_handler
2190 (vl_api_vnet_ip6_fib_counters_t * mp)
2195 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2196 (vl_api_vnet_ip6_fib_counters_t * mp)
2198 vat_main_t *vam = &vat_main;
2199 vl_api_ip6_fib_counter_t *v;
2200 ip6_fib_counter_t *counter;
2201 struct in6_addr ip6;
2207 vrf_id = ntohl (mp->vrf_id);
2208 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2209 if (~0 == vrf_index)
2211 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2212 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2213 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2214 vec_validate (vam->ip6_fib_counters, vrf_index);
2215 vam->ip6_fib_counters[vrf_index] = NULL;
2218 vec_free (vam->ip6_fib_counters[vrf_index]);
2219 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2220 count = ntohl (mp->count);
2221 for (i = 0; i < count; i++)
2223 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2224 counter = &vam->ip6_fib_counters[vrf_index][i];
2225 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2226 counter->address = ip6;
2227 counter->address_length = v->address_length;
2228 counter->packets = clib_net_to_host_u64 (v->packets);
2229 counter->bytes = clib_net_to_host_u64 (v->bytes);
2234 static void vl_api_vnet_ip6_nbr_counters_t_handler
2235 (vl_api_vnet_ip6_nbr_counters_t * mp)
2240 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2241 (vl_api_vnet_ip6_nbr_counters_t * mp)
2243 vat_main_t *vam = &vat_main;
2244 vl_api_ip6_nbr_counter_t *v;
2245 ip6_nbr_counter_t *counter;
2246 struct in6_addr ip6;
2251 sw_if_index = ntohl (mp->sw_if_index);
2252 count = ntohl (mp->count);
2253 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2256 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2258 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2259 for (i = 0; i < count; i++)
2261 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2262 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2263 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2264 counter->address = ip6;
2265 counter->packets = clib_net_to_host_u64 (v->packets);
2266 counter->bytes = clib_net_to_host_u64 (v->bytes);
2271 static void vl_api_get_first_msg_id_reply_t_handler
2272 (vl_api_get_first_msg_id_reply_t * mp)
2274 vat_main_t *vam = &vat_main;
2275 i32 retval = ntohl (mp->retval);
2277 if (vam->async_mode)
2279 vam->async_errors += (retval < 0);
2283 vam->retval = retval;
2284 vam->result_ready = 1;
2288 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2292 static void vl_api_get_first_msg_id_reply_t_handler_json
2293 (vl_api_get_first_msg_id_reply_t * mp)
2295 vat_main_t *vam = &vat_main;
2296 vat_json_node_t node;
2298 vat_json_init_object (&node);
2299 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2300 vat_json_object_add_uint (&node, "first_msg_id",
2301 (uint) ntohs (mp->first_msg_id));
2303 vat_json_print (vam->ofp, &node);
2304 vat_json_free (&node);
2306 vam->retval = ntohl (mp->retval);
2307 vam->result_ready = 1;
2310 static void vl_api_get_node_graph_reply_t_handler
2311 (vl_api_get_node_graph_reply_t * mp)
2313 vat_main_t *vam = &vat_main;
2314 api_main_t *am = &api_main;
2315 i32 retval = ntohl (mp->retval);
2316 u8 *pvt_copy, *reply;
2321 if (vam->async_mode)
2323 vam->async_errors += (retval < 0);
2327 vam->retval = retval;
2328 vam->result_ready = 1;
2331 /* "Should never happen..." */
2335 reply = (u8 *) (mp->reply_in_shmem);
2336 pvt_copy = vec_dup (reply);
2338 /* Toss the shared-memory original... */
2339 pthread_mutex_lock (&am->vlib_rp->mutex);
2340 oldheap = svm_push_data_heap (am->vlib_rp);
2344 svm_pop_heap (oldheap);
2345 pthread_mutex_unlock (&am->vlib_rp->mutex);
2347 if (vam->graph_nodes)
2349 hash_free (vam->graph_node_index_by_name);
2351 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2353 node = vam->graph_nodes[i];
2354 vec_free (node->name);
2355 vec_free (node->next_nodes);
2358 vec_free (vam->graph_nodes);
2361 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2362 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2363 vec_free (pvt_copy);
2365 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2367 node = vam->graph_nodes[i];
2368 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2372 static void vl_api_get_node_graph_reply_t_handler_json
2373 (vl_api_get_node_graph_reply_t * mp)
2375 vat_main_t *vam = &vat_main;
2376 api_main_t *am = &api_main;
2378 vat_json_node_t node;
2381 /* $$$$ make this real? */
2382 vat_json_init_object (&node);
2383 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2384 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2386 reply = (u8 *) (mp->reply_in_shmem);
2388 /* Toss the shared-memory original... */
2389 pthread_mutex_lock (&am->vlib_rp->mutex);
2390 oldheap = svm_push_data_heap (am->vlib_rp);
2394 svm_pop_heap (oldheap);
2395 pthread_mutex_unlock (&am->vlib_rp->mutex);
2397 vat_json_print (vam->ofp, &node);
2398 vat_json_free (&node);
2400 vam->retval = ntohl (mp->retval);
2401 vam->result_ready = 1;
2405 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2407 vat_main_t *vam = &vat_main;
2412 s = format (s, "%=16d%=16d%=16d",
2413 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2417 s = format (s, "%=16U%=16d%=16d",
2418 mp->is_ipv6 ? format_ip6_address :
2420 mp->ip_address, mp->priority, mp->weight);
2423 print (vam->ofp, "%v", s);
2428 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2430 vat_main_t *vam = &vat_main;
2431 vat_json_node_t *node = NULL;
2432 struct in6_addr ip6;
2435 if (VAT_JSON_ARRAY != vam->json_tree.type)
2437 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2438 vat_json_init_array (&vam->json_tree);
2440 node = vat_json_array_add (&vam->json_tree);
2441 vat_json_init_object (node);
2443 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2444 vat_json_object_add_uint (node, "priority", mp->priority);
2445 vat_json_object_add_uint (node, "weight", mp->weight);
2448 vat_json_object_add_uint (node, "sw_if_index",
2449 clib_net_to_host_u32 (mp->sw_if_index));
2454 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2455 vat_json_object_add_ip6 (node, "address", ip6);
2459 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2460 vat_json_object_add_ip4 (node, "address", ip4);
2466 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2469 vat_main_t *vam = &vat_main;
2472 ls_name = format (0, "%s", mp->ls_name);
2474 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2480 vl_api_one_locator_set_details_t_handler_json
2481 (vl_api_one_locator_set_details_t * mp)
2483 vat_main_t *vam = &vat_main;
2484 vat_json_node_t *node = 0;
2487 ls_name = format (0, "%s", mp->ls_name);
2488 vec_add1 (ls_name, 0);
2490 if (VAT_JSON_ARRAY != vam->json_tree.type)
2492 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2493 vat_json_init_array (&vam->json_tree);
2495 node = vat_json_array_add (&vam->json_tree);
2497 vat_json_init_object (node);
2498 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2499 vat_json_object_add_uint (node, "ls_index",
2500 clib_net_to_host_u32 (mp->ls_index));
2505 format_lisp_flat_eid (u8 * s, va_list * args)
2507 u32 type = va_arg (*args, u32);
2508 u8 *eid = va_arg (*args, u8 *);
2509 u32 eid_len = va_arg (*args, u32);
2514 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2516 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2518 return format (s, "%U", format_ethernet_address, eid);
2524 format_lisp_eid_vat (u8 * s, va_list * args)
2526 u32 type = va_arg (*args, u32);
2527 u8 *eid = va_arg (*args, u8 *);
2528 u32 eid_len = va_arg (*args, u32);
2529 u8 *seid = va_arg (*args, u8 *);
2530 u32 seid_len = va_arg (*args, u32);
2531 u32 is_src_dst = va_arg (*args, u32);
2534 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2536 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2542 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2544 vat_main_t *vam = &vat_main;
2545 u8 *s = 0, *eid = 0;
2547 if (~0 == mp->locator_set_index)
2548 s = format (0, "action: %d", mp->action);
2550 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2552 eid = format (0, "%U", format_lisp_eid_vat,
2556 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2559 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2560 clib_net_to_host_u32 (mp->vni),
2562 mp->is_local ? "local" : "remote",
2563 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2564 clib_net_to_host_u16 (mp->key_id), mp->key);
2571 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2574 vat_main_t *vam = &vat_main;
2575 vat_json_node_t *node = 0;
2578 if (VAT_JSON_ARRAY != vam->json_tree.type)
2580 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2581 vat_json_init_array (&vam->json_tree);
2583 node = vat_json_array_add (&vam->json_tree);
2585 vat_json_init_object (node);
2586 if (~0 == mp->locator_set_index)
2587 vat_json_object_add_uint (node, "action", mp->action);
2589 vat_json_object_add_uint (node, "locator_set_index",
2590 clib_net_to_host_u32 (mp->locator_set_index));
2592 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2593 eid = format (0, "%U", format_lisp_eid_vat,
2597 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2599 vat_json_object_add_string_copy (node, "eid", eid);
2600 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2601 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2602 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2606 vat_json_object_add_uint (node, "key_id",
2607 clib_net_to_host_u16 (mp->key_id));
2608 vat_json_object_add_string_copy (node, "key", mp->key);
2614 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
2616 vat_main_t *vam = &vat_main;
2617 u8 *seid = 0, *deid = 0;
2618 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2620 deid = format (0, "%U", format_lisp_eid_vat,
2621 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2623 seid = format (0, "%U", format_lisp_eid_vat,
2624 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2630 format_ip_address_fcn = format_ip4_address;
2632 format_ip_address_fcn = format_ip6_address;
2635 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
2636 clib_net_to_host_u32 (mp->vni),
2638 format_ip_address_fcn, mp->lloc,
2639 format_ip_address_fcn, mp->rloc,
2640 clib_net_to_host_u32 (mp->pkt_count),
2641 clib_net_to_host_u32 (mp->bytes));
2648 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
2650 struct in6_addr ip6;
2652 vat_main_t *vam = &vat_main;
2653 vat_json_node_t *node = 0;
2654 u8 *deid = 0, *seid = 0;
2656 if (VAT_JSON_ARRAY != vam->json_tree.type)
2658 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2659 vat_json_init_array (&vam->json_tree);
2661 node = vat_json_array_add (&vam->json_tree);
2663 vat_json_init_object (node);
2664 deid = format (0, "%U", format_lisp_eid_vat,
2665 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2667 seid = format (0, "%U", format_lisp_eid_vat,
2668 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2673 vat_json_object_add_string_copy (node, "seid", seid);
2674 vat_json_object_add_string_copy (node, "deid", deid);
2675 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2679 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
2680 vat_json_object_add_ip4 (node, "lloc", ip4);
2681 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
2682 vat_json_object_add_ip4 (node, "rloc", ip4);
2686 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
2687 vat_json_object_add_ip6 (node, "lloc", ip6);
2688 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
2689 vat_json_object_add_ip6 (node, "rloc", ip6);
2691 vat_json_object_add_uint (node, "pkt_count",
2692 clib_net_to_host_u32 (mp->pkt_count));
2693 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
2700 vl_api_one_eid_table_map_details_t_handler
2701 (vl_api_one_eid_table_map_details_t * mp)
2703 vat_main_t *vam = &vat_main;
2705 u8 *line = format (0, "%=10d%=10d",
2706 clib_net_to_host_u32 (mp->vni),
2707 clib_net_to_host_u32 (mp->dp_table));
2708 print (vam->ofp, "%v", line);
2713 vl_api_one_eid_table_map_details_t_handler_json
2714 (vl_api_one_eid_table_map_details_t * mp)
2716 vat_main_t *vam = &vat_main;
2717 vat_json_node_t *node = NULL;
2719 if (VAT_JSON_ARRAY != vam->json_tree.type)
2721 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2722 vat_json_init_array (&vam->json_tree);
2724 node = vat_json_array_add (&vam->json_tree);
2725 vat_json_init_object (node);
2726 vat_json_object_add_uint (node, "dp_table",
2727 clib_net_to_host_u32 (mp->dp_table));
2728 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2732 vl_api_one_eid_table_vni_details_t_handler
2733 (vl_api_one_eid_table_vni_details_t * mp)
2735 vat_main_t *vam = &vat_main;
2737 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2738 print (vam->ofp, "%v", line);
2743 vl_api_one_eid_table_vni_details_t_handler_json
2744 (vl_api_one_eid_table_vni_details_t * mp)
2746 vat_main_t *vam = &vat_main;
2747 vat_json_node_t *node = NULL;
2749 if (VAT_JSON_ARRAY != vam->json_tree.type)
2751 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2752 vat_json_init_array (&vam->json_tree);
2754 node = vat_json_array_add (&vam->json_tree);
2755 vat_json_init_object (node);
2756 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2760 vl_api_show_one_map_register_state_reply_t_handler
2761 (vl_api_show_one_map_register_state_reply_t * mp)
2763 vat_main_t *vam = &vat_main;
2764 int retval = clib_net_to_host_u32 (mp->retval);
2766 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2768 vam->retval = retval;
2769 vam->result_ready = 1;
2773 vl_api_show_one_map_register_state_reply_t_handler_json
2774 (vl_api_show_one_map_register_state_reply_t * mp)
2776 vat_main_t *vam = &vat_main;
2777 vat_json_node_t _node, *node = &_node;
2778 int retval = clib_net_to_host_u32 (mp->retval);
2780 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2782 vat_json_init_object (node);
2783 vat_json_object_add_string_copy (node, "state", s);
2785 vat_json_print (vam->ofp, node);
2786 vat_json_free (node);
2788 vam->retval = retval;
2789 vam->result_ready = 1;
2794 vl_api_show_one_rloc_probe_state_reply_t_handler
2795 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2797 vat_main_t *vam = &vat_main;
2798 int retval = clib_net_to_host_u32 (mp->retval);
2803 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2805 vam->retval = retval;
2806 vam->result_ready = 1;
2810 vl_api_show_one_rloc_probe_state_reply_t_handler_json
2811 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2813 vat_main_t *vam = &vat_main;
2814 vat_json_node_t _node, *node = &_node;
2815 int retval = clib_net_to_host_u32 (mp->retval);
2817 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2818 vat_json_init_object (node);
2819 vat_json_object_add_string_copy (node, "state", s);
2821 vat_json_print (vam->ofp, node);
2822 vat_json_free (node);
2824 vam->retval = retval;
2825 vam->result_ready = 1;
2830 vl_api_show_one_stats_enable_disable_reply_t_handler
2831 (vl_api_show_one_stats_enable_disable_reply_t * mp)
2833 vat_main_t *vam = &vat_main;
2834 int retval = clib_net_to_host_u32 (mp->retval);
2839 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
2841 vam->retval = retval;
2842 vam->result_ready = 1;
2846 vl_api_show_one_stats_enable_disable_reply_t_handler_json
2847 (vl_api_show_one_stats_enable_disable_reply_t * mp)
2849 vat_main_t *vam = &vat_main;
2850 vat_json_node_t _node, *node = &_node;
2851 int retval = clib_net_to_host_u32 (mp->retval);
2853 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
2854 vat_json_init_object (node);
2855 vat_json_object_add_string_copy (node, "state", s);
2857 vat_json_print (vam->ofp, node);
2858 vat_json_free (node);
2860 vam->retval = retval;
2861 vam->result_ready = 1;
2866 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
2868 e->dp_table = clib_net_to_host_u32 (e->dp_table);
2869 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
2873 gpe_fwd_entries_get_reply_t_net_to_host
2874 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2878 mp->count = clib_net_to_host_u32 (mp->count);
2879 for (i = 0; i < mp->count; i++)
2881 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
2886 format_gpe_encap_mode (u8 * s, va_list * args)
2888 u32 mode = va_arg (*args, u32);
2893 return format (s, "lisp");
2895 return format (s, "vxlan");
2901 vl_api_gpe_get_encap_mode_reply_t_handler
2902 (vl_api_gpe_get_encap_mode_reply_t * mp)
2904 vat_main_t *vam = &vat_main;
2906 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
2907 vam->retval = ntohl (mp->retval);
2908 vam->result_ready = 1;
2912 vl_api_gpe_get_encap_mode_reply_t_handler_json
2913 (vl_api_gpe_get_encap_mode_reply_t * mp)
2915 vat_main_t *vam = &vat_main;
2916 vat_json_node_t node;
2918 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
2919 vec_add1 (encap_mode, 0);
2921 vat_json_init_object (&node);
2922 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
2924 vec_free (encap_mode);
2925 vat_json_print (vam->ofp, &node);
2926 vat_json_free (&node);
2928 vam->retval = ntohl (mp->retval);
2929 vam->result_ready = 1;
2933 vl_api_gpe_fwd_entry_path_details_t_handler
2934 (vl_api_gpe_fwd_entry_path_details_t * mp)
2936 vat_main_t *vam = &vat_main;
2937 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2939 if (mp->lcl_loc.is_ip4)
2940 format_ip_address_fcn = format_ip4_address;
2942 format_ip_address_fcn = format_ip6_address;
2944 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
2945 format_ip_address_fcn, &mp->lcl_loc,
2946 format_ip_address_fcn, &mp->rmt_loc);
2950 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
2952 struct in6_addr ip6;
2957 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
2958 vat_json_object_add_ip4 (n, "address", ip4);
2962 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
2963 vat_json_object_add_ip6 (n, "address", ip6);
2965 vat_json_object_add_uint (n, "weight", loc->weight);
2969 vl_api_gpe_fwd_entry_path_details_t_handler_json
2970 (vl_api_gpe_fwd_entry_path_details_t * mp)
2972 vat_main_t *vam = &vat_main;
2973 vat_json_node_t *node = NULL;
2974 vat_json_node_t *loc_node;
2976 if (VAT_JSON_ARRAY != vam->json_tree.type)
2978 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2979 vat_json_init_array (&vam->json_tree);
2981 node = vat_json_array_add (&vam->json_tree);
2982 vat_json_init_object (node);
2984 loc_node = vat_json_object_add (node, "local_locator");
2985 vat_json_init_object (loc_node);
2986 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
2988 loc_node = vat_json_object_add (node, "remote_locator");
2989 vat_json_init_object (loc_node);
2990 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
2994 vl_api_gpe_fwd_entries_get_reply_t_handler
2995 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2997 vat_main_t *vam = &vat_main;
2999 int retval = clib_net_to_host_u32 (mp->retval);
3000 vl_api_gpe_fwd_entry_t *e;
3005 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3007 for (i = 0; i < mp->count; i++)
3009 e = &mp->entries[i];
3010 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3011 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3012 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3016 vam->retval = retval;
3017 vam->result_ready = 1;
3021 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3022 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3025 vat_main_t *vam = &vat_main;
3026 vat_json_node_t *e = 0, root;
3028 int retval = clib_net_to_host_u32 (mp->retval);
3029 vl_api_gpe_fwd_entry_t *fwd;
3034 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3035 vat_json_init_array (&root);
3037 for (i = 0; i < mp->count; i++)
3039 e = vat_json_array_add (&root);
3040 fwd = &mp->entries[i];
3042 vat_json_init_object (e);
3043 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3044 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3046 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3047 fwd->leid_prefix_len);
3049 vat_json_object_add_string_copy (e, "leid", s);
3052 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3053 fwd->reid_prefix_len);
3055 vat_json_object_add_string_copy (e, "reid", s);
3059 vat_json_print (vam->ofp, &root);
3060 vat_json_free (&root);
3063 vam->retval = retval;
3064 vam->result_ready = 1;
3068 vl_api_one_adjacencies_get_reply_t_handler
3069 (vl_api_one_adjacencies_get_reply_t * mp)
3071 vat_main_t *vam = &vat_main;
3073 int retval = clib_net_to_host_u32 (mp->retval);
3074 vl_api_one_adjacency_t *a;
3079 n = clib_net_to_host_u32 (mp->count);
3081 for (i = 0; i < n; i++)
3083 a = &mp->adjacencies[i];
3084 print (vam->ofp, "%U %40U",
3085 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3086 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3090 vam->retval = retval;
3091 vam->result_ready = 1;
3095 vl_api_one_adjacencies_get_reply_t_handler_json
3096 (vl_api_one_adjacencies_get_reply_t * mp)
3099 vat_main_t *vam = &vat_main;
3100 vat_json_node_t *e = 0, root;
3102 int retval = clib_net_to_host_u32 (mp->retval);
3103 vl_api_one_adjacency_t *a;
3108 n = clib_net_to_host_u32 (mp->count);
3109 vat_json_init_array (&root);
3111 for (i = 0; i < n; i++)
3113 e = vat_json_array_add (&root);
3114 a = &mp->adjacencies[i];
3116 vat_json_init_object (e);
3117 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3118 a->leid_prefix_len);
3120 vat_json_object_add_string_copy (e, "leid", s);
3123 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3124 a->reid_prefix_len);
3126 vat_json_object_add_string_copy (e, "reid", s);
3130 vat_json_print (vam->ofp, &root);
3131 vat_json_free (&root);
3134 vam->retval = retval;
3135 vam->result_ready = 1;
3139 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3141 vat_main_t *vam = &vat_main;
3143 print (vam->ofp, "%=20U",
3144 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3149 vl_api_one_map_server_details_t_handler_json
3150 (vl_api_one_map_server_details_t * mp)
3152 vat_main_t *vam = &vat_main;
3153 vat_json_node_t *node = NULL;
3154 struct in6_addr ip6;
3157 if (VAT_JSON_ARRAY != vam->json_tree.type)
3159 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3160 vat_json_init_array (&vam->json_tree);
3162 node = vat_json_array_add (&vam->json_tree);
3164 vat_json_init_object (node);
3167 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3168 vat_json_object_add_ip6 (node, "map-server", ip6);
3172 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3173 vat_json_object_add_ip4 (node, "map-server", ip4);
3178 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3181 vat_main_t *vam = &vat_main;
3183 print (vam->ofp, "%=20U",
3184 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3189 vl_api_one_map_resolver_details_t_handler_json
3190 (vl_api_one_map_resolver_details_t * mp)
3192 vat_main_t *vam = &vat_main;
3193 vat_json_node_t *node = NULL;
3194 struct in6_addr ip6;
3197 if (VAT_JSON_ARRAY != vam->json_tree.type)
3199 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3200 vat_json_init_array (&vam->json_tree);
3202 node = vat_json_array_add (&vam->json_tree);
3204 vat_json_init_object (node);
3207 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3208 vat_json_object_add_ip6 (node, "map resolver", ip6);
3212 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3213 vat_json_object_add_ip4 (node, "map resolver", ip4);
3218 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3220 vat_main_t *vam = &vat_main;
3221 i32 retval = ntohl (mp->retval);
3225 print (vam->ofp, "feature: %s\ngpe: %s",
3226 mp->feature_status ? "enabled" : "disabled",
3227 mp->gpe_status ? "enabled" : "disabled");
3230 vam->retval = retval;
3231 vam->result_ready = 1;
3235 vl_api_show_one_status_reply_t_handler_json
3236 (vl_api_show_one_status_reply_t * mp)
3238 vat_main_t *vam = &vat_main;
3239 vat_json_node_t node;
3240 u8 *gpe_status = NULL;
3241 u8 *feature_status = NULL;
3243 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3244 feature_status = format (0, "%s",
3245 mp->feature_status ? "enabled" : "disabled");
3246 vec_add1 (gpe_status, 0);
3247 vec_add1 (feature_status, 0);
3249 vat_json_init_object (&node);
3250 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3251 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3253 vec_free (gpe_status);
3254 vec_free (feature_status);
3256 vat_json_print (vam->ofp, &node);
3257 vat_json_free (&node);
3259 vam->retval = ntohl (mp->retval);
3260 vam->result_ready = 1;
3264 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3265 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3267 vat_main_t *vam = &vat_main;
3268 i32 retval = ntohl (mp->retval);
3272 print (vam->ofp, "%=20s", mp->locator_set_name);
3275 vam->retval = retval;
3276 vam->result_ready = 1;
3280 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3281 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3283 vat_main_t *vam = &vat_main;
3284 vat_json_node_t *node = NULL;
3286 if (VAT_JSON_ARRAY != vam->json_tree.type)
3288 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3289 vat_json_init_array (&vam->json_tree);
3291 node = vat_json_array_add (&vam->json_tree);
3293 vat_json_init_object (node);
3294 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3296 vat_json_print (vam->ofp, node);
3297 vat_json_free (node);
3299 vam->retval = ntohl (mp->retval);
3300 vam->result_ready = 1;
3304 format_lisp_map_request_mode (u8 * s, va_list * args)
3306 u32 mode = va_arg (*args, u32);
3311 return format (0, "dst-only");
3313 return format (0, "src-dst");
3319 vl_api_show_one_map_request_mode_reply_t_handler
3320 (vl_api_show_one_map_request_mode_reply_t * mp)
3322 vat_main_t *vam = &vat_main;
3323 i32 retval = ntohl (mp->retval);
3327 u32 mode = mp->mode;
3328 print (vam->ofp, "map_request_mode: %U",
3329 format_lisp_map_request_mode, mode);
3332 vam->retval = retval;
3333 vam->result_ready = 1;
3337 vl_api_show_one_map_request_mode_reply_t_handler_json
3338 (vl_api_show_one_map_request_mode_reply_t * mp)
3340 vat_main_t *vam = &vat_main;
3341 vat_json_node_t node;
3346 s = format (0, "%U", format_lisp_map_request_mode, mode);
3349 vat_json_init_object (&node);
3350 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3351 vat_json_print (vam->ofp, &node);
3352 vat_json_free (&node);
3355 vam->retval = ntohl (mp->retval);
3356 vam->result_ready = 1;
3360 vl_api_show_one_use_petr_reply_t_handler
3361 (vl_api_show_one_use_petr_reply_t * mp)
3363 vat_main_t *vam = &vat_main;
3364 i32 retval = ntohl (mp->retval);
3368 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
3371 print (vam->ofp, "Proxy-ETR address; %U",
3372 mp->is_ip4 ? format_ip4_address : format_ip6_address,
3377 vam->retval = retval;
3378 vam->result_ready = 1;
3382 vl_api_show_one_use_petr_reply_t_handler_json
3383 (vl_api_show_one_use_petr_reply_t * mp)
3385 vat_main_t *vam = &vat_main;
3386 vat_json_node_t node;
3389 struct in6_addr ip6;
3391 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3392 vec_add1 (status, 0);
3394 vat_json_init_object (&node);
3395 vat_json_object_add_string_copy (&node, "status", status);
3400 clib_memcpy (&ip6, mp->address, sizeof (ip6));
3401 vat_json_object_add_ip6 (&node, "address", ip6);
3405 clib_memcpy (&ip4, mp->address, sizeof (ip4));
3406 vat_json_object_add_ip4 (&node, "address", ip4);
3412 vat_json_print (vam->ofp, &node);
3413 vat_json_free (&node);
3415 vam->retval = ntohl (mp->retval);
3416 vam->result_ready = 1;
3420 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3422 vat_main_t *vam = &vat_main;
3423 i32 retval = ntohl (mp->retval);
3427 print (vam->ofp, "%-20s%-16s",
3428 mp->status ? "enabled" : "disabled",
3429 mp->status ? (char *) mp->locator_set_name : "");
3432 vam->retval = retval;
3433 vam->result_ready = 1;
3437 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3439 vat_main_t *vam = &vat_main;
3440 vat_json_node_t node;
3443 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3444 vec_add1 (status, 0);
3446 vat_json_init_object (&node);
3447 vat_json_object_add_string_copy (&node, "status", status);
3450 vat_json_object_add_string_copy (&node, "locator_set",
3451 mp->locator_set_name);
3456 vat_json_print (vam->ofp, &node);
3457 vat_json_free (&node);
3459 vam->retval = ntohl (mp->retval);
3460 vam->result_ready = 1;
3464 format_policer_type (u8 * s, va_list * va)
3466 u32 i = va_arg (*va, u32);
3468 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3469 s = format (s, "1r2c");
3470 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3471 s = format (s, "1r3c");
3472 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3473 s = format (s, "2r3c-2698");
3474 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3475 s = format (s, "2r3c-4115");
3476 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3477 s = format (s, "2r3c-mef5cf1");
3479 s = format (s, "ILLEGAL");
3484 format_policer_rate_type (u8 * s, va_list * va)
3486 u32 i = va_arg (*va, u32);
3488 if (i == SSE2_QOS_RATE_KBPS)
3489 s = format (s, "kbps");
3490 else if (i == SSE2_QOS_RATE_PPS)
3491 s = format (s, "pps");
3493 s = format (s, "ILLEGAL");
3498 format_policer_round_type (u8 * s, va_list * va)
3500 u32 i = va_arg (*va, u32);
3502 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3503 s = format (s, "closest");
3504 else if (i == SSE2_QOS_ROUND_TO_UP)
3505 s = format (s, "up");
3506 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3507 s = format (s, "down");
3509 s = format (s, "ILLEGAL");
3514 format_policer_action_type (u8 * s, va_list * va)
3516 u32 i = va_arg (*va, u32);
3518 if (i == SSE2_QOS_ACTION_DROP)
3519 s = format (s, "drop");
3520 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3521 s = format (s, "transmit");
3522 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3523 s = format (s, "mark-and-transmit");
3525 s = format (s, "ILLEGAL");
3530 format_dscp (u8 * s, va_list * va)
3532 u32 i = va_arg (*va, u32);
3537 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3541 return format (s, "ILLEGAL");
3543 s = format (s, "%s", t);
3548 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3550 vat_main_t *vam = &vat_main;
3551 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3553 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3554 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3556 conform_dscp_str = format (0, "");
3558 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3559 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3561 exceed_dscp_str = format (0, "");
3563 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3564 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3566 violate_dscp_str = format (0, "");
3568 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3569 "rate type %U, round type %U, %s rate, %s color-aware, "
3570 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3571 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3572 "conform action %U%s, exceed action %U%s, violate action %U%s",
3574 format_policer_type, mp->type,
3577 clib_net_to_host_u64 (mp->cb),
3578 clib_net_to_host_u64 (mp->eb),
3579 format_policer_rate_type, mp->rate_type,
3580 format_policer_round_type, mp->round_type,
3581 mp->single_rate ? "single" : "dual",
3582 mp->color_aware ? "is" : "not",
3583 ntohl (mp->cir_tokens_per_period),
3584 ntohl (mp->pir_tokens_per_period),
3586 ntohl (mp->current_limit),
3587 ntohl (mp->current_bucket),
3588 ntohl (mp->extended_limit),
3589 ntohl (mp->extended_bucket),
3590 clib_net_to_host_u64 (mp->last_update_time),
3591 format_policer_action_type, mp->conform_action_type,
3593 format_policer_action_type, mp->exceed_action_type,
3595 format_policer_action_type, mp->violate_action_type,
3598 vec_free (conform_dscp_str);
3599 vec_free (exceed_dscp_str);
3600 vec_free (violate_dscp_str);
3603 static void vl_api_policer_details_t_handler_json
3604 (vl_api_policer_details_t * mp)
3606 vat_main_t *vam = &vat_main;
3607 vat_json_node_t *node;
3608 u8 *rate_type_str, *round_type_str, *type_str;
3609 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3611 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3613 format (0, "%U", format_policer_round_type, mp->round_type);
3614 type_str = format (0, "%U", format_policer_type, mp->type);
3615 conform_action_str = format (0, "%U", format_policer_action_type,
3616 mp->conform_action_type);
3617 exceed_action_str = format (0, "%U", format_policer_action_type,
3618 mp->exceed_action_type);
3619 violate_action_str = format (0, "%U", format_policer_action_type,
3620 mp->violate_action_type);
3622 if (VAT_JSON_ARRAY != vam->json_tree.type)
3624 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3625 vat_json_init_array (&vam->json_tree);
3627 node = vat_json_array_add (&vam->json_tree);
3629 vat_json_init_object (node);
3630 vat_json_object_add_string_copy (node, "name", mp->name);
3631 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3632 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3633 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3634 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3635 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3636 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3637 vat_json_object_add_string_copy (node, "type", type_str);
3638 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3639 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3640 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3641 vat_json_object_add_uint (node, "cir_tokens_per_period",
3642 ntohl (mp->cir_tokens_per_period));
3643 vat_json_object_add_uint (node, "eir_tokens_per_period",
3644 ntohl (mp->pir_tokens_per_period));
3645 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3646 vat_json_object_add_uint (node, "current_bucket",
3647 ntohl (mp->current_bucket));
3648 vat_json_object_add_uint (node, "extended_limit",
3649 ntohl (mp->extended_limit));
3650 vat_json_object_add_uint (node, "extended_bucket",
3651 ntohl (mp->extended_bucket));
3652 vat_json_object_add_uint (node, "last_update_time",
3653 ntohl (mp->last_update_time));
3654 vat_json_object_add_string_copy (node, "conform_action",
3655 conform_action_str);
3656 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3658 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3659 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3660 vec_free (dscp_str);
3662 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3663 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3665 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3666 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3667 vec_free (dscp_str);
3669 vat_json_object_add_string_copy (node, "violate_action",
3670 violate_action_str);
3671 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3673 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3674 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3675 vec_free (dscp_str);
3678 vec_free (rate_type_str);
3679 vec_free (round_type_str);
3680 vec_free (type_str);
3681 vec_free (conform_action_str);
3682 vec_free (exceed_action_str);
3683 vec_free (violate_action_str);
3687 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3690 vat_main_t *vam = &vat_main;
3691 int i, count = ntohl (mp->count);
3694 print (vam->ofp, "classify table ids (%d) : ", count);
3695 for (i = 0; i < count; i++)
3697 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3698 print (vam->ofp, (i < count - 1) ? "," : "");
3700 vam->retval = ntohl (mp->retval);
3701 vam->result_ready = 1;
3705 vl_api_classify_table_ids_reply_t_handler_json
3706 (vl_api_classify_table_ids_reply_t * mp)
3708 vat_main_t *vam = &vat_main;
3709 int i, count = ntohl (mp->count);
3713 vat_json_node_t node;
3715 vat_json_init_object (&node);
3716 for (i = 0; i < count; i++)
3718 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3720 vat_json_print (vam->ofp, &node);
3721 vat_json_free (&node);
3723 vam->retval = ntohl (mp->retval);
3724 vam->result_ready = 1;
3728 vl_api_classify_table_by_interface_reply_t_handler
3729 (vl_api_classify_table_by_interface_reply_t * mp)
3731 vat_main_t *vam = &vat_main;
3734 table_id = ntohl (mp->l2_table_id);
3736 print (vam->ofp, "l2 table id : %d", table_id);
3738 print (vam->ofp, "l2 table id : No input ACL tables configured");
3739 table_id = ntohl (mp->ip4_table_id);
3741 print (vam->ofp, "ip4 table id : %d", table_id);
3743 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3744 table_id = ntohl (mp->ip6_table_id);
3746 print (vam->ofp, "ip6 table id : %d", table_id);
3748 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3749 vam->retval = ntohl (mp->retval);
3750 vam->result_ready = 1;
3754 vl_api_classify_table_by_interface_reply_t_handler_json
3755 (vl_api_classify_table_by_interface_reply_t * mp)
3757 vat_main_t *vam = &vat_main;
3758 vat_json_node_t node;
3760 vat_json_init_object (&node);
3762 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3763 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3764 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3766 vat_json_print (vam->ofp, &node);
3767 vat_json_free (&node);
3769 vam->retval = ntohl (mp->retval);
3770 vam->result_ready = 1;
3773 static void vl_api_policer_add_del_reply_t_handler
3774 (vl_api_policer_add_del_reply_t * mp)
3776 vat_main_t *vam = &vat_main;
3777 i32 retval = ntohl (mp->retval);
3778 if (vam->async_mode)
3780 vam->async_errors += (retval < 0);
3784 vam->retval = retval;
3785 vam->result_ready = 1;
3786 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3788 * Note: this is just barely thread-safe, depends on
3789 * the main thread spinning waiting for an answer...
3791 errmsg ("policer index %d", ntohl (mp->policer_index));
3795 static void vl_api_policer_add_del_reply_t_handler_json
3796 (vl_api_policer_add_del_reply_t * mp)
3798 vat_main_t *vam = &vat_main;
3799 vat_json_node_t node;
3801 vat_json_init_object (&node);
3802 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3803 vat_json_object_add_uint (&node, "policer_index",
3804 ntohl (mp->policer_index));
3806 vat_json_print (vam->ofp, &node);
3807 vat_json_free (&node);
3809 vam->retval = ntohl (mp->retval);
3810 vam->result_ready = 1;
3813 /* Format hex dump. */
3815 format_hex_bytes (u8 * s, va_list * va)
3817 u8 *bytes = va_arg (*va, u8 *);
3818 int n_bytes = va_arg (*va, int);
3821 /* Print short or long form depending on byte count. */
3822 uword short_form = n_bytes <= 32;
3823 uword indent = format_get_indent (s);
3828 for (i = 0; i < n_bytes; i++)
3830 if (!short_form && (i % 32) == 0)
3831 s = format (s, "%08x: ", i);
3832 s = format (s, "%02x", bytes[i]);
3833 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3834 s = format (s, "\n%U", format_white_space, indent);
3841 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3844 vat_main_t *vam = &vat_main;
3845 i32 retval = ntohl (mp->retval);
3848 print (vam->ofp, "classify table info :");
3849 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3850 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3851 ntohl (mp->miss_next_index));
3852 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3853 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3854 ntohl (mp->match_n_vectors));
3855 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3856 ntohl (mp->mask_length));
3858 vam->retval = retval;
3859 vam->result_ready = 1;
3863 vl_api_classify_table_info_reply_t_handler_json
3864 (vl_api_classify_table_info_reply_t * mp)
3866 vat_main_t *vam = &vat_main;
3867 vat_json_node_t node;
3869 i32 retval = ntohl (mp->retval);
3872 vat_json_init_object (&node);
3874 vat_json_object_add_int (&node, "sessions",
3875 ntohl (mp->active_sessions));
3876 vat_json_object_add_int (&node, "nexttbl",
3877 ntohl (mp->next_table_index));
3878 vat_json_object_add_int (&node, "nextnode",
3879 ntohl (mp->miss_next_index));
3880 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3881 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3882 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3883 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3884 ntohl (mp->mask_length), 0);
3885 vat_json_object_add_string_copy (&node, "mask", s);
3887 vat_json_print (vam->ofp, &node);
3888 vat_json_free (&node);
3890 vam->retval = ntohl (mp->retval);
3891 vam->result_ready = 1;
3895 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3898 vat_main_t *vam = &vat_main;
3900 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3901 ntohl (mp->hit_next_index), ntohl (mp->advance),
3902 ntohl (mp->opaque_index));
3903 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3904 ntohl (mp->match_length));
3908 vl_api_classify_session_details_t_handler_json
3909 (vl_api_classify_session_details_t * mp)
3911 vat_main_t *vam = &vat_main;
3912 vat_json_node_t *node = NULL;
3914 if (VAT_JSON_ARRAY != vam->json_tree.type)
3916 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3917 vat_json_init_array (&vam->json_tree);
3919 node = vat_json_array_add (&vam->json_tree);
3921 vat_json_init_object (node);
3922 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3923 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3924 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3926 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3928 vat_json_object_add_string_copy (node, "match", s);
3931 static void vl_api_pg_create_interface_reply_t_handler
3932 (vl_api_pg_create_interface_reply_t * mp)
3934 vat_main_t *vam = &vat_main;
3936 vam->retval = ntohl (mp->retval);
3937 vam->result_ready = 1;
3940 static void vl_api_pg_create_interface_reply_t_handler_json
3941 (vl_api_pg_create_interface_reply_t * mp)
3943 vat_main_t *vam = &vat_main;
3944 vat_json_node_t node;
3946 i32 retval = ntohl (mp->retval);
3949 vat_json_init_object (&node);
3951 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3953 vat_json_print (vam->ofp, &node);
3954 vat_json_free (&node);
3956 vam->retval = ntohl (mp->retval);
3957 vam->result_ready = 1;
3960 static void vl_api_policer_classify_details_t_handler
3961 (vl_api_policer_classify_details_t * mp)
3963 vat_main_t *vam = &vat_main;
3965 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3966 ntohl (mp->table_index));
3969 static void vl_api_policer_classify_details_t_handler_json
3970 (vl_api_policer_classify_details_t * mp)
3972 vat_main_t *vam = &vat_main;
3973 vat_json_node_t *node;
3975 if (VAT_JSON_ARRAY != vam->json_tree.type)
3977 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3978 vat_json_init_array (&vam->json_tree);
3980 node = vat_json_array_add (&vam->json_tree);
3982 vat_json_init_object (node);
3983 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3984 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3987 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3988 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3990 vat_main_t *vam = &vat_main;
3991 i32 retval = ntohl (mp->retval);
3992 if (vam->async_mode)
3994 vam->async_errors += (retval < 0);
3998 vam->retval = retval;
3999 vam->sw_if_index = ntohl (mp->sw_if_index);
4000 vam->result_ready = 1;
4004 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4005 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4007 vat_main_t *vam = &vat_main;
4008 vat_json_node_t node;
4010 vat_json_init_object (&node);
4011 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4012 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4014 vat_json_print (vam->ofp, &node);
4015 vat_json_free (&node);
4017 vam->retval = ntohl (mp->retval);
4018 vam->result_ready = 1;
4021 static void vl_api_flow_classify_details_t_handler
4022 (vl_api_flow_classify_details_t * mp)
4024 vat_main_t *vam = &vat_main;
4026 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4027 ntohl (mp->table_index));
4030 static void vl_api_flow_classify_details_t_handler_json
4031 (vl_api_flow_classify_details_t * mp)
4033 vat_main_t *vam = &vat_main;
4034 vat_json_node_t *node;
4036 if (VAT_JSON_ARRAY != vam->json_tree.type)
4038 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4039 vat_json_init_array (&vam->json_tree);
4041 node = vat_json_array_add (&vam->json_tree);
4043 vat_json_init_object (node);
4044 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4045 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4050 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4051 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4052 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4053 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4054 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4055 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4056 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4057 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4058 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4059 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4062 * Generate boilerplate reply handlers, which
4063 * dig the return value out of the xxx_reply_t API message,
4064 * stick it into vam->retval, and set vam->result_ready
4066 * Could also do this by pointing N message decode slots at
4067 * a single function, but that could break in subtle ways.
4070 #define foreach_standard_reply_retval_handler \
4071 _(sw_interface_set_flags_reply) \
4072 _(sw_interface_add_del_address_reply) \
4073 _(sw_interface_set_table_reply) \
4074 _(sw_interface_set_mpls_enable_reply) \
4075 _(sw_interface_set_vpath_reply) \
4076 _(sw_interface_set_vxlan_bypass_reply) \
4077 _(sw_interface_set_l2_bridge_reply) \
4078 _(bridge_domain_add_del_reply) \
4079 _(sw_interface_set_l2_xconnect_reply) \
4080 _(l2fib_add_del_reply) \
4081 _(ip_add_del_route_reply) \
4082 _(ip_mroute_add_del_reply) \
4083 _(mpls_route_add_del_reply) \
4084 _(mpls_ip_bind_unbind_reply) \
4085 _(proxy_arp_add_del_reply) \
4086 _(proxy_arp_intfc_enable_disable_reply) \
4087 _(sw_interface_set_unnumbered_reply) \
4088 _(ip_neighbor_add_del_reply) \
4089 _(reset_vrf_reply) \
4090 _(oam_add_del_reply) \
4091 _(reset_fib_reply) \
4092 _(dhcp_proxy_config_reply) \
4093 _(dhcp_proxy_set_vss_reply) \
4094 _(dhcp_client_config_reply) \
4095 _(set_ip_flow_hash_reply) \
4096 _(sw_interface_ip6_enable_disable_reply) \
4097 _(sw_interface_ip6_set_link_local_address_reply) \
4098 _(ip6nd_proxy_add_del_reply) \
4099 _(sw_interface_ip6nd_ra_prefix_reply) \
4100 _(sw_interface_ip6nd_ra_config_reply) \
4101 _(set_arp_neighbor_limit_reply) \
4102 _(l2_patch_add_del_reply) \
4103 _(sr_policy_add_reply) \
4104 _(sr_policy_mod_reply) \
4105 _(sr_policy_del_reply) \
4106 _(sr_localsid_add_del_reply) \
4107 _(sr_steering_add_del_reply) \
4108 _(classify_add_del_session_reply) \
4109 _(classify_set_interface_ip_table_reply) \
4110 _(classify_set_interface_l2_tables_reply) \
4111 _(l2tpv3_set_tunnel_cookies_reply) \
4112 _(l2tpv3_interface_enable_disable_reply) \
4113 _(l2tpv3_set_lookup_key_reply) \
4114 _(l2_fib_clear_table_reply) \
4115 _(l2_interface_efp_filter_reply) \
4116 _(l2_interface_vlan_tag_rewrite_reply) \
4117 _(modify_vhost_user_if_reply) \
4118 _(delete_vhost_user_if_reply) \
4119 _(want_ip4_arp_events_reply) \
4120 _(want_ip6_nd_events_reply) \
4121 _(input_acl_set_interface_reply) \
4122 _(ipsec_spd_add_del_reply) \
4123 _(ipsec_interface_add_del_spd_reply) \
4124 _(ipsec_spd_add_del_entry_reply) \
4125 _(ipsec_sad_add_del_entry_reply) \
4126 _(ipsec_sa_set_key_reply) \
4127 _(ikev2_profile_add_del_reply) \
4128 _(ikev2_profile_set_auth_reply) \
4129 _(ikev2_profile_set_id_reply) \
4130 _(ikev2_profile_set_ts_reply) \
4131 _(ikev2_set_local_key_reply) \
4132 _(ikev2_set_responder_reply) \
4133 _(ikev2_set_ike_transforms_reply) \
4134 _(ikev2_set_esp_transforms_reply) \
4135 _(ikev2_set_sa_lifetime_reply) \
4136 _(ikev2_initiate_sa_init_reply) \
4137 _(ikev2_initiate_del_ike_sa_reply) \
4138 _(ikev2_initiate_del_child_sa_reply) \
4139 _(ikev2_initiate_rekey_child_sa_reply) \
4140 _(delete_loopback_reply) \
4141 _(bd_ip_mac_add_del_reply) \
4142 _(map_del_domain_reply) \
4143 _(map_add_del_rule_reply) \
4144 _(want_interface_events_reply) \
4145 _(want_stats_reply) \
4146 _(cop_interface_enable_disable_reply) \
4147 _(cop_whitelist_enable_disable_reply) \
4148 _(sw_interface_clear_stats_reply) \
4149 _(ioam_enable_reply) \
4150 _(ioam_disable_reply) \
4151 _(one_add_del_locator_reply) \
4152 _(one_add_del_local_eid_reply) \
4153 _(one_add_del_remote_mapping_reply) \
4154 _(one_add_del_adjacency_reply) \
4155 _(one_add_del_map_resolver_reply) \
4156 _(one_add_del_map_server_reply) \
4157 _(one_enable_disable_reply) \
4158 _(one_rloc_probe_enable_disable_reply) \
4159 _(one_map_register_enable_disable_reply) \
4160 _(one_pitr_set_locator_set_reply) \
4161 _(one_map_request_mode_reply) \
4162 _(one_add_del_map_request_itr_rlocs_reply) \
4163 _(one_eid_table_add_del_map_reply) \
4164 _(one_use_petr_reply) \
4165 _(one_stats_enable_disable_reply) \
4166 _(gpe_add_del_fwd_entry_reply) \
4167 _(gpe_enable_disable_reply) \
4168 _(gpe_set_encap_mode_reply) \
4169 _(gpe_add_del_iface_reply) \
4170 _(vxlan_gpe_add_del_tunnel_reply) \
4171 _(af_packet_delete_reply) \
4172 _(policer_classify_set_interface_reply) \
4173 _(netmap_create_reply) \
4174 _(netmap_delete_reply) \
4175 _(set_ipfix_exporter_reply) \
4176 _(set_ipfix_classify_stream_reply) \
4177 _(ipfix_classify_table_add_del_reply) \
4178 _(flow_classify_set_interface_reply) \
4179 _(sw_interface_span_enable_disable_reply) \
4180 _(pg_capture_reply) \
4181 _(pg_enable_disable_reply) \
4182 _(ip_source_and_port_range_check_add_del_reply) \
4183 _(ip_source_and_port_range_check_interface_add_del_reply)\
4184 _(delete_subif_reply) \
4185 _(l2_interface_pbb_tag_rewrite_reply) \
4187 _(feature_enable_disable_reply) \
4188 _(sw_interface_tag_add_del_reply) \
4189 _(sw_interface_set_mtu_reply)
4192 static void vl_api_##n##_t_handler \
4193 (vl_api_##n##_t * mp) \
4195 vat_main_t * vam = &vat_main; \
4196 i32 retval = ntohl(mp->retval); \
4197 if (vam->async_mode) { \
4198 vam->async_errors += (retval < 0); \
4200 vam->retval = retval; \
4201 vam->result_ready = 1; \
4204 foreach_standard_reply_retval_handler;
4208 static void vl_api_##n##_t_handler_json \
4209 (vl_api_##n##_t * mp) \
4211 vat_main_t * vam = &vat_main; \
4212 vat_json_node_t node; \
4213 vat_json_init_object(&node); \
4214 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4215 vat_json_print(vam->ofp, &node); \
4216 vam->retval = ntohl(mp->retval); \
4217 vam->result_ready = 1; \
4219 foreach_standard_reply_retval_handler;
4223 * Table of message reply handlers, must include boilerplate handlers
4227 #define foreach_vpe_api_reply_msg \
4228 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4229 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4230 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4231 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4232 _(CONTROL_PING_REPLY, control_ping_reply) \
4233 _(CLI_REPLY, cli_reply) \
4234 _(CLI_INBAND_REPLY, cli_inband_reply) \
4235 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4236 sw_interface_add_del_address_reply) \
4237 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4238 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4239 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4240 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4241 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4242 sw_interface_set_l2_xconnect_reply) \
4243 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4244 sw_interface_set_l2_bridge_reply) \
4245 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4246 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4247 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
4248 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4249 _(L2_FLAGS_REPLY, l2_flags_reply) \
4250 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4251 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4252 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4253 _(TAP_DELETE_REPLY, tap_delete_reply) \
4254 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4255 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4256 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4257 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4258 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4259 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4260 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4261 proxy_arp_intfc_enable_disable_reply) \
4262 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4263 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4264 sw_interface_set_unnumbered_reply) \
4265 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4266 _(RESET_VRF_REPLY, reset_vrf_reply) \
4267 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4268 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4269 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4270 _(RESET_FIB_REPLY, reset_fib_reply) \
4271 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4272 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4273 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4274 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4275 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4276 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4277 sw_interface_ip6_enable_disable_reply) \
4278 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4279 sw_interface_ip6_set_link_local_address_reply) \
4280 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
4281 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
4282 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4283 sw_interface_ip6nd_ra_prefix_reply) \
4284 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4285 sw_interface_ip6nd_ra_config_reply) \
4286 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4287 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4288 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4289 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4290 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4291 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4292 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4293 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4294 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4295 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4296 classify_set_interface_ip_table_reply) \
4297 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4298 classify_set_interface_l2_tables_reply) \
4299 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4300 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4301 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4302 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4303 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4304 l2tpv3_interface_enable_disable_reply) \
4305 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4306 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4307 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4308 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4309 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4310 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4311 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4312 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4313 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4314 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4315 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4316 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4317 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4318 _(SHOW_VERSION_REPLY, show_version_reply) \
4319 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
4320 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4321 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4322 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4323 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4324 _(IP4_ARP_EVENT, ip4_arp_event) \
4325 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4326 _(IP6_ND_EVENT, ip6_nd_event) \
4327 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4328 _(IP_ADDRESS_DETAILS, ip_address_details) \
4329 _(IP_DETAILS, ip_details) \
4330 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4331 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4332 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4333 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4334 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4335 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4336 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4337 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4338 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4339 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4340 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4341 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4342 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4343 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4344 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4345 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4346 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4347 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4348 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4349 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4350 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4351 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4352 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4353 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4354 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4355 _(MAP_RULE_DETAILS, map_rule_details) \
4356 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4357 _(WANT_STATS_REPLY, want_stats_reply) \
4358 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4359 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4360 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4361 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4362 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4363 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4364 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4365 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4366 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4367 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4368 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4369 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4370 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4371 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4372 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4373 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4374 one_map_register_enable_disable_reply) \
4375 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4376 one_rloc_probe_enable_disable_reply) \
4377 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4378 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
4379 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4380 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4381 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4382 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4383 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4384 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4385 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4386 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4387 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4388 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4389 _(ONE_STATS_DETAILS, one_stats_details) \
4390 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
4391 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
4392 show_one_stats_enable_disable_reply) \
4393 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4394 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4395 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4396 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4397 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4398 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4399 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4400 gpe_fwd_entry_path_details) \
4401 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4402 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4403 one_add_del_map_request_itr_rlocs_reply) \
4404 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4405 one_get_map_request_itr_rlocs_reply) \
4406 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4407 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
4408 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4409 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4410 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4411 show_one_map_register_state_reply) \
4412 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4413 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4414 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4415 _(POLICER_DETAILS, policer_details) \
4416 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4417 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4418 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4419 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4420 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4421 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4422 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4423 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4424 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4425 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4426 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4427 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4428 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4429 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4430 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4431 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4432 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4433 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4434 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4435 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4436 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4437 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4438 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4439 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4440 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4441 ip_source_and_port_range_check_add_del_reply) \
4442 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4443 ip_source_and_port_range_check_interface_add_del_reply) \
4444 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4445 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4446 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4447 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4448 _(PUNT_REPLY, punt_reply) \
4449 _(IP_FIB_DETAILS, ip_fib_details) \
4450 _(IP6_FIB_DETAILS, ip6_fib_details) \
4451 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4452 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4453 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4454 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4455 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4456 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4458 #define foreach_standalone_reply_msg \
4459 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4460 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
4461 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4462 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4463 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4464 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
4473 #define STR_VTR_OP_CASE(op) \
4474 case L2_VTR_ ## op: \
4478 str_vtr_op (u32 vtr_op)
4482 STR_VTR_OP_CASE (DISABLED);
4483 STR_VTR_OP_CASE (PUSH_1);
4484 STR_VTR_OP_CASE (PUSH_2);
4485 STR_VTR_OP_CASE (POP_1);
4486 STR_VTR_OP_CASE (POP_2);
4487 STR_VTR_OP_CASE (TRANSLATE_1_1);
4488 STR_VTR_OP_CASE (TRANSLATE_1_2);
4489 STR_VTR_OP_CASE (TRANSLATE_2_1);
4490 STR_VTR_OP_CASE (TRANSLATE_2_2);
4497 dump_sub_interface_table (vat_main_t * vam)
4499 const sw_interface_subif_t *sub = NULL;
4501 if (vam->json_output)
4504 ("JSON output supported only for VPE API calls and dump_stats_table");
4509 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4510 "Interface", "sw_if_index",
4511 "sub id", "dot1ad", "tags", "outer id",
4512 "inner id", "exact", "default", "outer any", "inner any");
4514 vec_foreach (sub, vam->sw_if_subif_table)
4517 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4518 sub->interface_name,
4520 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4521 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4522 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4523 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4524 if (sub->vtr_op != L2_VTR_DISABLED)
4527 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4528 "tag1: %d tag2: %d ]",
4529 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4530 sub->vtr_tag1, sub->vtr_tag2);
4538 name_sort_cmp (void *a1, void *a2)
4540 name_sort_t *n1 = a1;
4541 name_sort_t *n2 = a2;
4543 return strcmp ((char *) n1->name, (char *) n2->name);
4547 dump_interface_table (vat_main_t * vam)
4550 name_sort_t *nses = 0, *ns;
4552 if (vam->json_output)
4555 ("JSON output supported only for VPE API calls and dump_stats_table");
4560 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4562 vec_add2 (nses, ns, 1);
4563 ns->name = (u8 *)(p->key);
4564 ns->value = (u32) p->value[0];
4568 vec_sort_with_function (nses, name_sort_cmp);
4570 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4571 vec_foreach (ns, nses)
4573 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4580 dump_ip_table (vat_main_t * vam, int is_ipv6)
4582 const ip_details_t *det = NULL;
4583 const ip_address_details_t *address = NULL;
4586 print (vam->ofp, "%-12s", "sw_if_index");
4588 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4595 print (vam->ofp, "%-12d", i);
4596 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4601 vec_foreach (address, det->addr)
4605 is_ipv6 ? format_ip6_address : format_ip4_address,
4606 address->ip, address->prefix_length);
4614 dump_ipv4_table (vat_main_t * vam)
4616 if (vam->json_output)
4619 ("JSON output supported only for VPE API calls and dump_stats_table");
4623 return dump_ip_table (vam, 0);
4627 dump_ipv6_table (vat_main_t * vam)
4629 if (vam->json_output)
4632 ("JSON output supported only for VPE API calls and dump_stats_table");
4636 return dump_ip_table (vam, 1);
4640 counter_type_to_str (u8 counter_type, u8 is_combined)
4644 switch (counter_type)
4646 case VNET_INTERFACE_COUNTER_DROP:
4648 case VNET_INTERFACE_COUNTER_PUNT:
4650 case VNET_INTERFACE_COUNTER_IP4:
4652 case VNET_INTERFACE_COUNTER_IP6:
4654 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4656 case VNET_INTERFACE_COUNTER_RX_MISS:
4658 case VNET_INTERFACE_COUNTER_RX_ERROR:
4660 case VNET_INTERFACE_COUNTER_TX_ERROR:
4663 return "INVALID-COUNTER-TYPE";
4668 switch (counter_type)
4670 case VNET_INTERFACE_COUNTER_RX:
4672 case VNET_INTERFACE_COUNTER_TX:
4675 return "INVALID-COUNTER-TYPE";
4681 dump_stats_table (vat_main_t * vam)
4683 vat_json_node_t node;
4684 vat_json_node_t *msg_array;
4685 vat_json_node_t *msg;
4686 vat_json_node_t *counter_array;
4687 vat_json_node_t *counter;
4688 interface_counter_t c;
4690 ip4_fib_counter_t *c4;
4691 ip6_fib_counter_t *c6;
4692 ip4_nbr_counter_t *n4;
4693 ip6_nbr_counter_t *n6;
4696 if (!vam->json_output)
4698 clib_warning ("dump_stats_table supported only in JSON format");
4702 vat_json_init_object (&node);
4704 /* interface counters */
4705 msg_array = vat_json_object_add (&node, "interface_counters");
4706 vat_json_init_array (msg_array);
4707 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4709 msg = vat_json_array_add (msg_array);
4710 vat_json_init_object (msg);
4711 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4712 (u8 *) counter_type_to_str (i, 0));
4713 vat_json_object_add_int (msg, "is_combined", 0);
4714 counter_array = vat_json_object_add (msg, "data");
4715 vat_json_init_array (counter_array);
4716 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4718 packets = vam->simple_interface_counters[i][j];
4719 vat_json_array_add_uint (counter_array, packets);
4722 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4724 msg = vat_json_array_add (msg_array);
4725 vat_json_init_object (msg);
4726 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4727 (u8 *) counter_type_to_str (i, 1));
4728 vat_json_object_add_int (msg, "is_combined", 1);
4729 counter_array = vat_json_object_add (msg, "data");
4730 vat_json_init_array (counter_array);
4731 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4733 c = vam->combined_interface_counters[i][j];
4734 counter = vat_json_array_add (counter_array);
4735 vat_json_init_object (counter);
4736 vat_json_object_add_uint (counter, "packets", c.packets);
4737 vat_json_object_add_uint (counter, "bytes", c.bytes);
4741 /* ip4 fib counters */
4742 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4743 vat_json_init_array (msg_array);
4744 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4746 msg = vat_json_array_add (msg_array);
4747 vat_json_init_object (msg);
4748 vat_json_object_add_uint (msg, "vrf_id",
4749 vam->ip4_fib_counters_vrf_id_by_index[i]);
4750 counter_array = vat_json_object_add (msg, "c");
4751 vat_json_init_array (counter_array);
4752 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4754 counter = vat_json_array_add (counter_array);
4755 vat_json_init_object (counter);
4756 c4 = &vam->ip4_fib_counters[i][j];
4757 vat_json_object_add_ip4 (counter, "address", c4->address);
4758 vat_json_object_add_uint (counter, "address_length",
4759 c4->address_length);
4760 vat_json_object_add_uint (counter, "packets", c4->packets);
4761 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4765 /* ip6 fib counters */
4766 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4767 vat_json_init_array (msg_array);
4768 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4770 msg = vat_json_array_add (msg_array);
4771 vat_json_init_object (msg);
4772 vat_json_object_add_uint (msg, "vrf_id",
4773 vam->ip6_fib_counters_vrf_id_by_index[i]);
4774 counter_array = vat_json_object_add (msg, "c");
4775 vat_json_init_array (counter_array);
4776 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4778 counter = vat_json_array_add (counter_array);
4779 vat_json_init_object (counter);
4780 c6 = &vam->ip6_fib_counters[i][j];
4781 vat_json_object_add_ip6 (counter, "address", c6->address);
4782 vat_json_object_add_uint (counter, "address_length",
4783 c6->address_length);
4784 vat_json_object_add_uint (counter, "packets", c6->packets);
4785 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4789 /* ip4 nbr counters */
4790 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4791 vat_json_init_array (msg_array);
4792 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4794 msg = vat_json_array_add (msg_array);
4795 vat_json_init_object (msg);
4796 vat_json_object_add_uint (msg, "sw_if_index", i);
4797 counter_array = vat_json_object_add (msg, "c");
4798 vat_json_init_array (counter_array);
4799 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4801 counter = vat_json_array_add (counter_array);
4802 vat_json_init_object (counter);
4803 n4 = &vam->ip4_nbr_counters[i][j];
4804 vat_json_object_add_ip4 (counter, "address", n4->address);
4805 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4806 vat_json_object_add_uint (counter, "packets", n4->packets);
4807 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4811 /* ip6 nbr counters */
4812 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4813 vat_json_init_array (msg_array);
4814 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4816 msg = vat_json_array_add (msg_array);
4817 vat_json_init_object (msg);
4818 vat_json_object_add_uint (msg, "sw_if_index", i);
4819 counter_array = vat_json_object_add (msg, "c");
4820 vat_json_init_array (counter_array);
4821 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4823 counter = vat_json_array_add (counter_array);
4824 vat_json_init_object (counter);
4825 n6 = &vam->ip6_nbr_counters[i][j];
4826 vat_json_object_add_ip6 (counter, "address", n6->address);
4827 vat_json_object_add_uint (counter, "packets", n6->packets);
4828 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4832 vat_json_print (vam->ofp, &node);
4833 vat_json_free (&node);
4839 exec (vat_main_t * vam)
4841 api_main_t *am = &api_main;
4842 vl_api_cli_request_t *mp;
4846 unformat_input_t *i = vam->input;
4848 if (vec_len (i->buffer) == 0)
4851 if (vam->exec_mode == 0 && unformat (i, "mode"))
4856 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4863 M (CLI_REQUEST, mp);
4866 * Copy cmd into shared memory.
4867 * In order for the CLI command to work, it
4868 * must be a vector ending in \n, not a C-string ending
4871 pthread_mutex_lock (&am->vlib_rp->mutex);
4872 oldheap = svm_push_data_heap (am->vlib_rp);
4874 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4875 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4877 svm_pop_heap (oldheap);
4878 pthread_mutex_unlock (&am->vlib_rp->mutex);
4880 mp->cmd_in_shmem = (u64) cmd;
4882 timeout = vat_time_now (vam) + 10.0;
4884 while (vat_time_now (vam) < timeout)
4886 if (vam->result_ready == 1)
4889 if (vam->shmem_result != NULL)
4890 print (vam->ofp, "%s", vam->shmem_result);
4891 pthread_mutex_lock (&am->vlib_rp->mutex);
4892 oldheap = svm_push_data_heap (am->vlib_rp);
4894 free_me = (u8 *) vam->shmem_result;
4897 svm_pop_heap (oldheap);
4898 pthread_mutex_unlock (&am->vlib_rp->mutex);
4906 * Future replacement of exec() that passes CLI buffers directly in
4907 * the API messages instead of an additional shared memory area.
4910 exec_inband (vat_main_t * vam)
4912 vl_api_cli_inband_t *mp;
4913 unformat_input_t *i = vam->input;
4916 if (vec_len (i->buffer) == 0)
4919 if (vam->exec_mode == 0 && unformat (i, "mode"))
4924 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4931 * In order for the CLI command to work, it
4932 * must be a vector ending in \n, not a C-string ending
4935 u32 len = vec_len (vam->input->buffer);
4936 M2 (CLI_INBAND, mp, len);
4937 clib_memcpy (mp->cmd, vam->input->buffer, len);
4938 mp->length = htonl (len);
4941 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
4946 api_create_loopback (vat_main_t * vam)
4948 unformat_input_t *i = vam->input;
4949 vl_api_create_loopback_t *mp;
4950 vl_api_create_loopback_instance_t *mp_lbi;
4953 u8 is_specified = 0;
4954 u32 user_instance = 0;
4957 memset (mac_address, 0, sizeof (mac_address));
4959 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4961 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4963 if (unformat (i, "instance %d", &user_instance))
4971 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
4972 mp_lbi->is_specified = is_specified;
4974 mp_lbi->user_instance = htonl (user_instance);
4976 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
4981 /* Construct the API message */
4982 M (CREATE_LOOPBACK, mp);
4984 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4993 api_delete_loopback (vat_main_t * vam)
4995 unformat_input_t *i = vam->input;
4996 vl_api_delete_loopback_t *mp;
4997 u32 sw_if_index = ~0;
5000 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5002 if (unformat (i, "sw_if_index %d", &sw_if_index))
5008 if (sw_if_index == ~0)
5010 errmsg ("missing sw_if_index");
5014 /* Construct the API message */
5015 M (DELETE_LOOPBACK, mp);
5016 mp->sw_if_index = ntohl (sw_if_index);
5024 api_want_stats (vat_main_t * vam)
5026 unformat_input_t *i = vam->input;
5027 vl_api_want_stats_t *mp;
5031 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5033 if (unformat (i, "enable"))
5035 else if (unformat (i, "disable"))
5043 errmsg ("missing enable|disable");
5048 mp->enable_disable = enable;
5056 api_want_interface_events (vat_main_t * vam)
5058 unformat_input_t *i = vam->input;
5059 vl_api_want_interface_events_t *mp;
5063 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5065 if (unformat (i, "enable"))
5067 else if (unformat (i, "disable"))
5075 errmsg ("missing enable|disable");
5079 M (WANT_INTERFACE_EVENTS, mp);
5080 mp->enable_disable = enable;
5082 vam->interface_event_display = enable;
5090 /* Note: non-static, called once to set up the initial intfc table */
5092 api_sw_interface_dump (vat_main_t * vam)
5094 vl_api_sw_interface_dump_t *mp;
5095 vl_api_control_ping_t *mp_ping;
5097 name_sort_t *nses = 0, *ns;
5098 sw_interface_subif_t *sub = NULL;
5101 /* Toss the old name table */
5103 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5105 vec_add2 (nses, ns, 1);
5106 ns->name = (u8 *)(p->key);
5107 ns->value = (u32) p->value[0];
5111 hash_free (vam->sw_if_index_by_interface_name);
5113 vec_foreach (ns, nses) vec_free (ns->name);
5117 vec_foreach (sub, vam->sw_if_subif_table)
5119 vec_free (sub->interface_name);
5121 vec_free (vam->sw_if_subif_table);
5123 /* recreate the interface name hash table */
5124 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5126 /* Get list of ethernets */
5127 M (SW_INTERFACE_DUMP, mp);
5128 mp->name_filter_valid = 1;
5129 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
5132 /* and local / loopback interfaces */
5133 M (SW_INTERFACE_DUMP, mp);
5134 mp->name_filter_valid = 1;
5135 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
5138 /* and packet-generator interfaces */
5139 M (SW_INTERFACE_DUMP, mp);
5140 mp->name_filter_valid = 1;
5141 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
5144 /* and vxlan-gpe tunnel interfaces */
5145 M (SW_INTERFACE_DUMP, mp);
5146 mp->name_filter_valid = 1;
5147 strncpy ((char *) mp->name_filter, "vxlan_gpe",
5148 sizeof (mp->name_filter) - 1);
5151 /* and vxlan tunnel interfaces */
5152 M (SW_INTERFACE_DUMP, mp);
5153 mp->name_filter_valid = 1;
5154 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
5157 /* and host (af_packet) interfaces */
5158 M (SW_INTERFACE_DUMP, mp);
5159 mp->name_filter_valid = 1;
5160 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
5163 /* and l2tpv3 tunnel interfaces */
5164 M (SW_INTERFACE_DUMP, mp);
5165 mp->name_filter_valid = 1;
5166 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
5167 sizeof (mp->name_filter) - 1);
5170 /* and GRE tunnel interfaces */
5171 M (SW_INTERFACE_DUMP, mp);
5172 mp->name_filter_valid = 1;
5173 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
5176 /* and LISP-GPE interfaces */
5177 M (SW_INTERFACE_DUMP, mp);
5178 mp->name_filter_valid = 1;
5179 strncpy ((char *) mp->name_filter, "lisp_gpe",
5180 sizeof (mp->name_filter) - 1);
5183 /* and IPSEC tunnel interfaces */
5184 M (SW_INTERFACE_DUMP, mp);
5185 mp->name_filter_valid = 1;
5186 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
5189 /* Use a control ping for synchronization */
5190 M (CONTROL_PING, mp_ping);
5198 api_sw_interface_set_flags (vat_main_t * vam)
5200 unformat_input_t *i = vam->input;
5201 vl_api_sw_interface_set_flags_t *mp;
5203 u8 sw_if_index_set = 0;
5204 u8 admin_up = 0, link_up = 0;
5207 /* Parse args required to build the message */
5208 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5210 if (unformat (i, "admin-up"))
5212 else if (unformat (i, "admin-down"))
5214 else if (unformat (i, "link-up"))
5216 else if (unformat (i, "link-down"))
5219 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5220 sw_if_index_set = 1;
5221 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5222 sw_if_index_set = 1;
5227 if (sw_if_index_set == 0)
5229 errmsg ("missing interface name or sw_if_index");
5233 /* Construct the API message */
5234 M (SW_INTERFACE_SET_FLAGS, mp);
5235 mp->sw_if_index = ntohl (sw_if_index);
5236 mp->admin_up_down = admin_up;
5237 mp->link_up_down = link_up;
5242 /* Wait for a reply, return the good/bad news... */
5248 api_sw_interface_clear_stats (vat_main_t * vam)
5250 unformat_input_t *i = vam->input;
5251 vl_api_sw_interface_clear_stats_t *mp;
5253 u8 sw_if_index_set = 0;
5256 /* Parse args required to build the message */
5257 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5259 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5260 sw_if_index_set = 1;
5261 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5262 sw_if_index_set = 1;
5267 /* Construct the API message */
5268 M (SW_INTERFACE_CLEAR_STATS, mp);
5270 if (sw_if_index_set == 1)
5271 mp->sw_if_index = ntohl (sw_if_index);
5273 mp->sw_if_index = ~0;
5278 /* Wait for a reply, return the good/bad news... */
5284 api_sw_interface_add_del_address (vat_main_t * vam)
5286 unformat_input_t *i = vam->input;
5287 vl_api_sw_interface_add_del_address_t *mp;
5289 u8 sw_if_index_set = 0;
5290 u8 is_add = 1, del_all = 0;
5291 u32 address_length = 0;
5292 u8 v4_address_set = 0;
5293 u8 v6_address_set = 0;
5294 ip4_address_t v4address;
5295 ip6_address_t v6address;
5298 /* Parse args required to build the message */
5299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5301 if (unformat (i, "del-all"))
5303 else if (unformat (i, "del"))
5306 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5307 sw_if_index_set = 1;
5308 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5309 sw_if_index_set = 1;
5310 else if (unformat (i, "%U/%d",
5311 unformat_ip4_address, &v4address, &address_length))
5313 else if (unformat (i, "%U/%d",
5314 unformat_ip6_address, &v6address, &address_length))
5320 if (sw_if_index_set == 0)
5322 errmsg ("missing interface name or sw_if_index");
5325 if (v4_address_set && v6_address_set)
5327 errmsg ("both v4 and v6 addresses set");
5330 if (!v4_address_set && !v6_address_set && !del_all)
5332 errmsg ("no addresses set");
5336 /* Construct the API message */
5337 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5339 mp->sw_if_index = ntohl (sw_if_index);
5340 mp->is_add = is_add;
5341 mp->del_all = del_all;
5345 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5349 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5351 mp->address_length = address_length;
5356 /* Wait for a reply, return good/bad news */
5362 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5364 unformat_input_t *i = vam->input;
5365 vl_api_sw_interface_set_mpls_enable_t *mp;
5367 u8 sw_if_index_set = 0;
5371 /* Parse args required to build the message */
5372 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5374 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5375 sw_if_index_set = 1;
5376 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5377 sw_if_index_set = 1;
5378 else if (unformat (i, "disable"))
5380 else if (unformat (i, "dis"))
5386 if (sw_if_index_set == 0)
5388 errmsg ("missing interface name or sw_if_index");
5392 /* Construct the API message */
5393 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5395 mp->sw_if_index = ntohl (sw_if_index);
5396 mp->enable = enable;
5401 /* Wait for a reply... */
5407 api_sw_interface_set_table (vat_main_t * vam)
5409 unformat_input_t *i = vam->input;
5410 vl_api_sw_interface_set_table_t *mp;
5411 u32 sw_if_index, vrf_id = 0;
5412 u8 sw_if_index_set = 0;
5416 /* Parse args required to build the message */
5417 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5419 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5420 sw_if_index_set = 1;
5421 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5422 sw_if_index_set = 1;
5423 else if (unformat (i, "vrf %d", &vrf_id))
5425 else if (unformat (i, "ipv6"))
5431 if (sw_if_index_set == 0)
5433 errmsg ("missing interface name or sw_if_index");
5437 /* Construct the API message */
5438 M (SW_INTERFACE_SET_TABLE, mp);
5440 mp->sw_if_index = ntohl (sw_if_index);
5441 mp->is_ipv6 = is_ipv6;
5442 mp->vrf_id = ntohl (vrf_id);
5447 /* Wait for a reply... */
5452 static void vl_api_sw_interface_get_table_reply_t_handler
5453 (vl_api_sw_interface_get_table_reply_t * mp)
5455 vat_main_t *vam = &vat_main;
5457 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5459 vam->retval = ntohl (mp->retval);
5460 vam->result_ready = 1;
5464 static void vl_api_sw_interface_get_table_reply_t_handler_json
5465 (vl_api_sw_interface_get_table_reply_t * mp)
5467 vat_main_t *vam = &vat_main;
5468 vat_json_node_t node;
5470 vat_json_init_object (&node);
5471 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5472 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5474 vat_json_print (vam->ofp, &node);
5475 vat_json_free (&node);
5477 vam->retval = ntohl (mp->retval);
5478 vam->result_ready = 1;
5482 api_sw_interface_get_table (vat_main_t * vam)
5484 unformat_input_t *i = vam->input;
5485 vl_api_sw_interface_get_table_t *mp;
5487 u8 sw_if_index_set = 0;
5491 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5493 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5494 sw_if_index_set = 1;
5495 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5496 sw_if_index_set = 1;
5497 else if (unformat (i, "ipv6"))
5503 if (sw_if_index_set == 0)
5505 errmsg ("missing interface name or sw_if_index");
5509 M (SW_INTERFACE_GET_TABLE, mp);
5510 mp->sw_if_index = htonl (sw_if_index);
5511 mp->is_ipv6 = is_ipv6;
5519 api_sw_interface_set_vpath (vat_main_t * vam)
5521 unformat_input_t *i = vam->input;
5522 vl_api_sw_interface_set_vpath_t *mp;
5523 u32 sw_if_index = 0;
5524 u8 sw_if_index_set = 0;
5528 /* Parse args required to build the message */
5529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5531 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5532 sw_if_index_set = 1;
5533 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5534 sw_if_index_set = 1;
5535 else if (unformat (i, "enable"))
5537 else if (unformat (i, "disable"))
5543 if (sw_if_index_set == 0)
5545 errmsg ("missing interface name or sw_if_index");
5549 /* Construct the API message */
5550 M (SW_INTERFACE_SET_VPATH, mp);
5552 mp->sw_if_index = ntohl (sw_if_index);
5553 mp->enable = is_enable;
5558 /* Wait for a reply... */
5564 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5566 unformat_input_t *i = vam->input;
5567 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5568 u32 sw_if_index = 0;
5569 u8 sw_if_index_set = 0;
5574 /* Parse args required to build the message */
5575 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5577 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5578 sw_if_index_set = 1;
5579 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5580 sw_if_index_set = 1;
5581 else if (unformat (i, "enable"))
5583 else if (unformat (i, "disable"))
5585 else if (unformat (i, "ip4"))
5587 else if (unformat (i, "ip6"))
5593 if (sw_if_index_set == 0)
5595 errmsg ("missing interface name or sw_if_index");
5599 /* Construct the API message */
5600 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5602 mp->sw_if_index = ntohl (sw_if_index);
5603 mp->enable = is_enable;
5604 mp->is_ipv6 = is_ipv6;
5609 /* Wait for a reply... */
5615 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5617 unformat_input_t *i = vam->input;
5618 vl_api_sw_interface_set_l2_xconnect_t *mp;
5620 u8 rx_sw_if_index_set = 0;
5622 u8 tx_sw_if_index_set = 0;
5626 /* Parse args required to build the message */
5627 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5629 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5630 rx_sw_if_index_set = 1;
5631 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5632 tx_sw_if_index_set = 1;
5633 else if (unformat (i, "rx"))
5635 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5637 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5639 rx_sw_if_index_set = 1;
5644 else if (unformat (i, "tx"))
5646 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5648 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5650 tx_sw_if_index_set = 1;
5655 else if (unformat (i, "enable"))
5657 else if (unformat (i, "disable"))
5663 if (rx_sw_if_index_set == 0)
5665 errmsg ("missing rx interface name or rx_sw_if_index");
5669 if (enable && (tx_sw_if_index_set == 0))
5671 errmsg ("missing tx interface name or tx_sw_if_index");
5675 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5677 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5678 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5679 mp->enable = enable;
5687 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5689 unformat_input_t *i = vam->input;
5690 vl_api_sw_interface_set_l2_bridge_t *mp;
5692 u8 rx_sw_if_index_set = 0;
5700 /* Parse args required to build the message */
5701 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5703 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5704 rx_sw_if_index_set = 1;
5705 else if (unformat (i, "bd_id %d", &bd_id))
5709 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5710 rx_sw_if_index_set = 1;
5711 else if (unformat (i, "shg %d", &shg))
5713 else if (unformat (i, "bvi"))
5715 else if (unformat (i, "enable"))
5717 else if (unformat (i, "disable"))
5723 if (rx_sw_if_index_set == 0)
5725 errmsg ("missing rx interface name or sw_if_index");
5729 if (enable && (bd_id_set == 0))
5731 errmsg ("missing bridge domain");
5735 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
5737 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5738 mp->bd_id = ntohl (bd_id);
5741 mp->enable = enable;
5749 api_bridge_domain_dump (vat_main_t * vam)
5751 unformat_input_t *i = vam->input;
5752 vl_api_bridge_domain_dump_t *mp;
5753 vl_api_control_ping_t *mp_ping;
5757 /* Parse args required to build the message */
5758 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5760 if (unformat (i, "bd_id %d", &bd_id))
5766 M (BRIDGE_DOMAIN_DUMP, mp);
5767 mp->bd_id = ntohl (bd_id);
5770 /* Use a control ping for synchronization */
5771 M (CONTROL_PING, mp_ping);
5779 api_bridge_domain_add_del (vat_main_t * vam)
5781 unformat_input_t *i = vam->input;
5782 vl_api_bridge_domain_add_del_t *mp;
5785 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5789 /* Parse args required to build the message */
5790 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5792 if (unformat (i, "bd_id %d", &bd_id))
5794 else if (unformat (i, "flood %d", &flood))
5796 else if (unformat (i, "uu-flood %d", &uu_flood))
5798 else if (unformat (i, "forward %d", &forward))
5800 else if (unformat (i, "learn %d", &learn))
5802 else if (unformat (i, "arp-term %d", &arp_term))
5804 else if (unformat (i, "mac-age %d", &mac_age))
5806 else if (unformat (i, "del"))
5809 flood = uu_flood = forward = learn = 0;
5817 errmsg ("missing bridge domain");
5823 errmsg ("mac age must be less than 256 ");
5827 M (BRIDGE_DOMAIN_ADD_DEL, mp);
5829 mp->bd_id = ntohl (bd_id);
5831 mp->uu_flood = uu_flood;
5832 mp->forward = forward;
5834 mp->arp_term = arp_term;
5835 mp->is_add = is_add;
5836 mp->mac_age = (u8) mac_age;
5844 api_l2fib_add_del (vat_main_t * vam)
5846 unformat_input_t *i = vam->input;
5847 vl_api_l2fib_add_del_t *mp;
5853 u32 sw_if_index = ~0;
5854 u8 sw_if_index_set = 0;
5863 /* Parse args required to build the message */
5864 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5866 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5868 else if (unformat (i, "bd_id %d", &bd_id))
5870 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5871 sw_if_index_set = 1;
5872 else if (unformat (i, "sw_if"))
5874 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5877 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5878 sw_if_index_set = 1;
5883 else if (unformat (i, "static"))
5885 else if (unformat (i, "filter"))
5890 else if (unformat (i, "bvi"))
5895 else if (unformat (i, "del"))
5897 else if (unformat (i, "count %d", &count))
5905 errmsg ("missing mac address");
5911 errmsg ("missing bridge domain");
5915 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5917 errmsg ("missing interface name or sw_if_index");
5923 /* Turn on async mode */
5924 vam->async_mode = 1;
5925 vam->async_errors = 0;
5926 before = vat_time_now (vam);
5929 for (j = 0; j < count; j++)
5931 M (L2FIB_ADD_DEL, mp);
5934 mp->bd_id = ntohl (bd_id);
5935 mp->is_add = is_add;
5939 mp->sw_if_index = ntohl (sw_if_index);
5940 mp->static_mac = static_mac;
5941 mp->filter_mac = filter_mac;
5942 mp->bvi_mac = bvi_mac;
5944 increment_mac_address (&mac);
5951 vl_api_control_ping_t *mp_ping;
5954 /* Shut off async mode */
5955 vam->async_mode = 0;
5957 M (CONTROL_PING, mp_ping);
5960 timeout = vat_time_now (vam) + 1.0;
5961 while (vat_time_now (vam) < timeout)
5962 if (vam->result_ready == 1)
5967 if (vam->retval == -99)
5970 if (vam->async_errors > 0)
5972 errmsg ("%d asynchronous errors", vam->async_errors);
5975 vam->async_errors = 0;
5976 after = vat_time_now (vam);
5978 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
5979 count, after - before, count / (after - before));
5985 /* Wait for a reply... */
5989 /* Return the good/bad news */
5990 return (vam->retval);
5994 api_l2_flags (vat_main_t * vam)
5996 unformat_input_t *i = vam->input;
5997 vl_api_l2_flags_t *mp;
5999 u32 feature_bitmap = 0;
6000 u8 sw_if_index_set = 0;
6003 /* Parse args required to build the message */
6004 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6006 if (unformat (i, "sw_if_index %d", &sw_if_index))
6007 sw_if_index_set = 1;
6008 else if (unformat (i, "sw_if"))
6010 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6013 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6014 sw_if_index_set = 1;
6019 else if (unformat (i, "learn"))
6020 feature_bitmap |= L2INPUT_FEAT_LEARN;
6021 else if (unformat (i, "forward"))
6022 feature_bitmap |= L2INPUT_FEAT_FWD;
6023 else if (unformat (i, "flood"))
6024 feature_bitmap |= L2INPUT_FEAT_FLOOD;
6025 else if (unformat (i, "uu-flood"))
6026 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
6031 if (sw_if_index_set == 0)
6033 errmsg ("missing interface name or sw_if_index");
6039 mp->sw_if_index = ntohl (sw_if_index);
6040 mp->feature_bitmap = ntohl (feature_bitmap);
6048 api_bridge_flags (vat_main_t * vam)
6050 unformat_input_t *i = vam->input;
6051 vl_api_bridge_flags_t *mp;
6058 /* Parse args required to build the message */
6059 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6061 if (unformat (i, "bd_id %d", &bd_id))
6063 else if (unformat (i, "learn"))
6065 else if (unformat (i, "forward"))
6067 else if (unformat (i, "flood"))
6069 else if (unformat (i, "uu-flood"))
6070 flags |= L2_UU_FLOOD;
6071 else if (unformat (i, "arp-term"))
6072 flags |= L2_ARP_TERM;
6073 else if (unformat (i, "off"))
6075 else if (unformat (i, "disable"))
6083 errmsg ("missing bridge domain");
6087 M (BRIDGE_FLAGS, mp);
6089 mp->bd_id = ntohl (bd_id);
6090 mp->feature_bitmap = ntohl (flags);
6091 mp->is_set = is_set;
6099 api_bd_ip_mac_add_del (vat_main_t * vam)
6101 unformat_input_t *i = vam->input;
6102 vl_api_bd_ip_mac_add_del_t *mp;
6109 ip4_address_t v4addr;
6110 ip6_address_t v6addr;
6115 /* Parse args required to build the message */
6116 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6118 if (unformat (i, "bd_id %d", &bd_id))
6122 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6126 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6131 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6135 else if (unformat (i, "del"))
6143 errmsg ("missing bridge domain");
6146 else if (ip_set == 0)
6148 errmsg ("missing IP address");
6151 else if (mac_set == 0)
6153 errmsg ("missing MAC address");
6157 M (BD_IP_MAC_ADD_DEL, mp);
6159 mp->bd_id = ntohl (bd_id);
6160 mp->is_ipv6 = is_ipv6;
6161 mp->is_add = is_add;
6163 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6165 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6166 clib_memcpy (mp->mac_address, macaddr, 6);
6173 api_tap_connect (vat_main_t * vam)
6175 unformat_input_t *i = vam->input;
6176 vl_api_tap_connect_t *mp;
6182 ip4_address_t ip4_address;
6184 int ip4_address_set = 0;
6185 ip6_address_t ip6_address;
6187 int ip6_address_set = 0;
6190 memset (mac_address, 0, sizeof (mac_address));
6192 /* Parse args required to build the message */
6193 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6195 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6199 else if (unformat (i, "random-mac"))
6201 else if (unformat (i, "tapname %s", &tap_name))
6203 else if (unformat (i, "tag %s", &tag))
6205 else if (unformat (i, "address %U/%d",
6206 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6207 ip4_address_set = 1;
6208 else if (unformat (i, "address %U/%d",
6209 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6210 ip6_address_set = 1;
6217 errmsg ("missing tap name");
6220 if (vec_len (tap_name) > 63)
6222 errmsg ("tap name too long");
6225 vec_add1 (tap_name, 0);
6227 if (vec_len (tag) > 63)
6229 errmsg ("tag too long");
6233 /* Construct the API message */
6234 M (TAP_CONNECT, mp);
6236 mp->use_random_mac = random_mac;
6237 clib_memcpy (mp->mac_address, mac_address, 6);
6238 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6240 clib_memcpy (mp->tag, tag, vec_len (tag));
6242 if (ip4_address_set)
6244 mp->ip4_address_set = 1;
6245 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6246 mp->ip4_mask_width = ip4_mask_width;
6248 if (ip6_address_set)
6250 mp->ip6_address_set = 1;
6251 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6252 mp->ip6_mask_width = ip6_mask_width;
6255 vec_free (tap_name);
6261 /* Wait for a reply... */
6267 api_tap_modify (vat_main_t * vam)
6269 unformat_input_t *i = vam->input;
6270 vl_api_tap_modify_t *mp;
6275 u32 sw_if_index = ~0;
6276 u8 sw_if_index_set = 0;
6279 memset (mac_address, 0, sizeof (mac_address));
6281 /* Parse args required to build the message */
6282 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6284 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6285 sw_if_index_set = 1;
6286 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6287 sw_if_index_set = 1;
6288 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6292 else if (unformat (i, "random-mac"))
6294 else if (unformat (i, "tapname %s", &tap_name))
6300 if (sw_if_index_set == 0)
6302 errmsg ("missing vpp interface name");
6307 errmsg ("missing tap name");
6310 if (vec_len (tap_name) > 63)
6312 errmsg ("tap name too long");
6314 vec_add1 (tap_name, 0);
6316 /* Construct the API message */
6319 mp->use_random_mac = random_mac;
6320 mp->sw_if_index = ntohl (sw_if_index);
6321 clib_memcpy (mp->mac_address, mac_address, 6);
6322 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6323 vec_free (tap_name);
6328 /* Wait for a reply... */
6334 api_tap_delete (vat_main_t * vam)
6336 unformat_input_t *i = vam->input;
6337 vl_api_tap_delete_t *mp;
6338 u32 sw_if_index = ~0;
6339 u8 sw_if_index_set = 0;
6342 /* Parse args required to build the message */
6343 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6345 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6346 sw_if_index_set = 1;
6347 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6348 sw_if_index_set = 1;
6353 if (sw_if_index_set == 0)
6355 errmsg ("missing vpp interface name");
6359 /* Construct the API message */
6362 mp->sw_if_index = ntohl (sw_if_index);
6367 /* Wait for a reply... */
6373 api_ip_add_del_route (vat_main_t * vam)
6375 unformat_input_t *i = vam->input;
6376 vl_api_ip_add_del_route_t *mp;
6377 u32 sw_if_index = ~0, vrf_id = 0;
6379 u8 is_local = 0, is_drop = 0;
6380 u8 is_unreach = 0, is_prohibit = 0;
6381 u8 create_vrf_if_needed = 0;
6383 u32 next_hop_weight = 1;
6385 u8 is_multipath = 0;
6387 u8 address_length_set = 0;
6388 u32 next_hop_table_id = 0;
6389 u32 resolve_attempts = 0;
6390 u32 dst_address_length = 0;
6391 u8 next_hop_set = 0;
6392 ip4_address_t v4_dst_address, v4_next_hop_address;
6393 ip6_address_t v6_dst_address, v6_next_hop_address;
6397 u32 random_add_del = 0;
6398 u32 *random_vector = 0;
6400 u32 random_seed = 0xdeaddabe;
6401 u32 classify_table_index = ~0;
6403 u8 resolve_host = 0, resolve_attached = 0;
6404 mpls_label_t *next_hop_out_label_stack = NULL;
6405 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6406 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6408 /* Parse args required to build the message */
6409 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6411 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6413 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6415 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6420 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6425 else if (unformat (i, "/%d", &dst_address_length))
6427 address_length_set = 1;
6430 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6431 &v4_next_hop_address))
6435 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6436 &v6_next_hop_address))
6440 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6442 else if (unformat (i, "weight %d", &next_hop_weight))
6444 else if (unformat (i, "drop"))
6448 else if (unformat (i, "null-send-unreach"))
6452 else if (unformat (i, "null-send-prohibit"))
6456 else if (unformat (i, "local"))
6460 else if (unformat (i, "classify %d", &classify_table_index))
6464 else if (unformat (i, "del"))
6466 else if (unformat (i, "add"))
6468 else if (unformat (i, "not-last"))
6470 else if (unformat (i, "resolve-via-host"))
6472 else if (unformat (i, "resolve-via-attached"))
6473 resolve_attached = 1;
6474 else if (unformat (i, "multipath"))
6476 else if (unformat (i, "vrf %d", &vrf_id))
6478 else if (unformat (i, "create-vrf"))
6479 create_vrf_if_needed = 1;
6480 else if (unformat (i, "count %d", &count))
6482 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6484 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6486 else if (unformat (i, "out-label %d", &next_hop_out_label))
6487 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6488 else if (unformat (i, "via-label %d", &next_hop_via_label))
6490 else if (unformat (i, "random"))
6492 else if (unformat (i, "seed %d", &random_seed))
6496 clib_warning ("parse error '%U'", format_unformat_error, i);
6501 if (!next_hop_set && !is_drop && !is_local &&
6502 !is_classify && !is_unreach && !is_prohibit &&
6503 MPLS_LABEL_INVALID == next_hop_via_label)
6506 ("next hop / local / drop / unreach / prohibit / classify not set");
6510 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6512 errmsg ("next hop and next-hop via label set");
6515 if (address_set == 0)
6517 errmsg ("missing addresses");
6521 if (address_length_set == 0)
6523 errmsg ("missing address length");
6527 /* Generate a pile of unique, random routes */
6530 u32 this_random_address;
6531 random_hash = hash_create (count, sizeof (uword));
6533 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6534 for (j = 0; j <= count; j++)
6538 this_random_address = random_u32 (&random_seed);
6539 this_random_address =
6540 clib_host_to_net_u32 (this_random_address);
6542 while (hash_get (random_hash, this_random_address));
6543 vec_add1 (random_vector, this_random_address);
6544 hash_set (random_hash, this_random_address, 1);
6546 hash_free (random_hash);
6547 v4_dst_address.as_u32 = random_vector[0];
6552 /* Turn on async mode */
6553 vam->async_mode = 1;
6554 vam->async_errors = 0;
6555 before = vat_time_now (vam);
6558 for (j = 0; j < count; j++)
6560 /* Construct the API message */
6561 M2 (IP_ADD_DEL_ROUTE, mp,
6562 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6564 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6565 mp->table_id = ntohl (vrf_id);
6566 mp->create_vrf_if_needed = create_vrf_if_needed;
6568 mp->is_add = is_add;
6569 mp->is_drop = is_drop;
6570 mp->is_unreach = is_unreach;
6571 mp->is_prohibit = is_prohibit;
6572 mp->is_ipv6 = is_ipv6;
6573 mp->is_local = is_local;
6574 mp->is_classify = is_classify;
6575 mp->is_multipath = is_multipath;
6576 mp->is_resolve_host = resolve_host;
6577 mp->is_resolve_attached = resolve_attached;
6578 mp->not_last = not_last;
6579 mp->next_hop_weight = next_hop_weight;
6580 mp->dst_address_length = dst_address_length;
6581 mp->next_hop_table_id = ntohl (next_hop_table_id);
6582 mp->classify_table_index = ntohl (classify_table_index);
6583 mp->next_hop_via_label = ntohl (next_hop_via_label);
6584 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6585 if (0 != mp->next_hop_n_out_labels)
6587 memcpy (mp->next_hop_out_label_stack,
6588 next_hop_out_label_stack,
6589 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6590 vec_free (next_hop_out_label_stack);
6595 clib_memcpy (mp->dst_address, &v6_dst_address,
6596 sizeof (v6_dst_address));
6598 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6599 sizeof (v6_next_hop_address));
6600 increment_v6_address (&v6_dst_address);
6604 clib_memcpy (mp->dst_address, &v4_dst_address,
6605 sizeof (v4_dst_address));
6607 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6608 sizeof (v4_next_hop_address));
6610 v4_dst_address.as_u32 = random_vector[j + 1];
6612 increment_v4_address (&v4_dst_address);
6616 /* If we receive SIGTERM, stop now... */
6621 /* When testing multiple add/del ops, use a control-ping to sync */
6624 vl_api_control_ping_t *mp_ping;
6628 /* Shut off async mode */
6629 vam->async_mode = 0;
6631 M (CONTROL_PING, mp_ping);
6634 timeout = vat_time_now (vam) + 1.0;
6635 while (vat_time_now (vam) < timeout)
6636 if (vam->result_ready == 1)
6641 if (vam->retval == -99)
6644 if (vam->async_errors > 0)
6646 errmsg ("%d asynchronous errors", vam->async_errors);
6649 vam->async_errors = 0;
6650 after = vat_time_now (vam);
6652 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6656 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6657 count, after - before, count / (after - before));
6663 /* Wait for a reply... */
6668 /* Return the good/bad news */
6669 return (vam->retval);
6673 api_ip_mroute_add_del (vat_main_t * vam)
6675 unformat_input_t *i = vam->input;
6676 vl_api_ip_mroute_add_del_t *mp;
6677 u32 sw_if_index = ~0, vrf_id = 0;
6680 u8 create_vrf_if_needed = 0;
6683 u32 grp_address_length = 0;
6684 ip4_address_t v4_grp_address, v4_src_address;
6685 ip6_address_t v6_grp_address, v6_src_address;
6686 mfib_itf_flags_t iflags = 0;
6687 mfib_entry_flags_t eflags = 0;
6690 /* Parse args required to build the message */
6691 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6693 if (unformat (i, "sw_if_index %d", &sw_if_index))
6695 else if (unformat (i, "%U %U",
6696 unformat_ip4_address, &v4_src_address,
6697 unformat_ip4_address, &v4_grp_address))
6699 grp_address_length = 64;
6703 else if (unformat (i, "%U %U",
6704 unformat_ip6_address, &v6_src_address,
6705 unformat_ip6_address, &v6_grp_address))
6707 grp_address_length = 256;
6711 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
6713 memset (&v4_src_address, 0, sizeof (v4_src_address));
6714 grp_address_length = 32;
6718 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
6720 memset (&v6_src_address, 0, sizeof (v6_src_address));
6721 grp_address_length = 128;
6725 else if (unformat (i, "/%d", &grp_address_length))
6727 else if (unformat (i, "local"))
6731 else if (unformat (i, "del"))
6733 else if (unformat (i, "add"))
6735 else if (unformat (i, "vrf %d", &vrf_id))
6737 else if (unformat (i, "create-vrf"))
6738 create_vrf_if_needed = 1;
6739 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
6741 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
6745 clib_warning ("parse error '%U'", format_unformat_error, i);
6750 if (address_set == 0)
6752 errmsg ("missing addresses\n");
6756 /* Construct the API message */
6757 M (IP_MROUTE_ADD_DEL, mp);
6759 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6760 mp->table_id = ntohl (vrf_id);
6761 mp->create_vrf_if_needed = create_vrf_if_needed;
6763 mp->is_add = is_add;
6764 mp->is_ipv6 = is_ipv6;
6765 mp->is_local = is_local;
6766 mp->itf_flags = ntohl (iflags);
6767 mp->entry_flags = ntohl (eflags);
6768 mp->grp_address_length = grp_address_length;
6769 mp->grp_address_length = ntohs (mp->grp_address_length);
6773 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
6774 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
6778 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
6779 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
6785 /* Wait for a reply... */
6791 api_mpls_route_add_del (vat_main_t * vam)
6793 unformat_input_t *i = vam->input;
6794 vl_api_mpls_route_add_del_t *mp;
6795 u32 sw_if_index = ~0, table_id = 0;
6796 u8 create_table_if_needed = 0;
6798 u32 next_hop_weight = 1;
6799 u8 is_multipath = 0;
6800 u32 next_hop_table_id = 0;
6801 u8 next_hop_set = 0;
6802 ip4_address_t v4_next_hop_address = {
6805 ip6_address_t v6_next_hop_address = { {0} };
6809 u32 classify_table_index = ~0;
6811 u8 resolve_host = 0, resolve_attached = 0;
6812 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6813 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6814 mpls_label_t *next_hop_out_label_stack = NULL;
6815 mpls_label_t local_label = MPLS_LABEL_INVALID;
6817 u8 next_hop_proto_is_ip4 = 1;
6819 /* Parse args required to build the message */
6820 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6822 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6824 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6826 else if (unformat (i, "%d", &local_label))
6828 else if (unformat (i, "eos"))
6830 else if (unformat (i, "non-eos"))
6832 else if (unformat (i, "via %U", unformat_ip4_address,
6833 &v4_next_hop_address))
6836 next_hop_proto_is_ip4 = 1;
6838 else if (unformat (i, "via %U", unformat_ip6_address,
6839 &v6_next_hop_address))
6842 next_hop_proto_is_ip4 = 0;
6844 else if (unformat (i, "weight %d", &next_hop_weight))
6846 else if (unformat (i, "create-table"))
6847 create_table_if_needed = 1;
6848 else if (unformat (i, "classify %d", &classify_table_index))
6852 else if (unformat (i, "del"))
6854 else if (unformat (i, "add"))
6856 else if (unformat (i, "resolve-via-host"))
6858 else if (unformat (i, "resolve-via-attached"))
6859 resolve_attached = 1;
6860 else if (unformat (i, "multipath"))
6862 else if (unformat (i, "count %d", &count))
6864 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6867 next_hop_proto_is_ip4 = 1;
6869 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6872 next_hop_proto_is_ip4 = 0;
6874 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6876 else if (unformat (i, "via-label %d", &next_hop_via_label))
6878 else if (unformat (i, "out-label %d", &next_hop_out_label))
6879 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6882 clib_warning ("parse error '%U'", format_unformat_error, i);
6887 if (!next_hop_set && !is_classify)
6889 errmsg ("next hop / classify not set");
6893 if (MPLS_LABEL_INVALID == local_label)
6895 errmsg ("missing label");
6901 /* Turn on async mode */
6902 vam->async_mode = 1;
6903 vam->async_errors = 0;
6904 before = vat_time_now (vam);
6907 for (j = 0; j < count; j++)
6909 /* Construct the API message */
6910 M2 (MPLS_ROUTE_ADD_DEL, mp,
6911 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6913 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6914 mp->mr_table_id = ntohl (table_id);
6915 mp->mr_create_table_if_needed = create_table_if_needed;
6917 mp->mr_is_add = is_add;
6918 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6919 mp->mr_is_classify = is_classify;
6920 mp->mr_is_multipath = is_multipath;
6921 mp->mr_is_resolve_host = resolve_host;
6922 mp->mr_is_resolve_attached = resolve_attached;
6923 mp->mr_next_hop_weight = next_hop_weight;
6924 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6925 mp->mr_classify_table_index = ntohl (classify_table_index);
6926 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6927 mp->mr_label = ntohl (local_label);
6928 mp->mr_eos = is_eos;
6930 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6931 if (0 != mp->mr_next_hop_n_out_labels)
6933 memcpy (mp->mr_next_hop_out_label_stack,
6934 next_hop_out_label_stack,
6935 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6936 vec_free (next_hop_out_label_stack);
6941 if (next_hop_proto_is_ip4)
6943 clib_memcpy (mp->mr_next_hop,
6944 &v4_next_hop_address,
6945 sizeof (v4_next_hop_address));
6949 clib_memcpy (mp->mr_next_hop,
6950 &v6_next_hop_address,
6951 sizeof (v6_next_hop_address));
6958 /* If we receive SIGTERM, stop now... */
6963 /* When testing multiple add/del ops, use a control-ping to sync */
6966 vl_api_control_ping_t *mp_ping;
6970 /* Shut off async mode */
6971 vam->async_mode = 0;
6973 M (CONTROL_PING, mp_ping);
6976 timeout = vat_time_now (vam) + 1.0;
6977 while (vat_time_now (vam) < timeout)
6978 if (vam->result_ready == 1)
6983 if (vam->retval == -99)
6986 if (vam->async_errors > 0)
6988 errmsg ("%d asynchronous errors", vam->async_errors);
6991 vam->async_errors = 0;
6992 after = vat_time_now (vam);
6994 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6998 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6999 count, after - before, count / (after - before));
7005 /* Wait for a reply... */
7010 /* Return the good/bad news */
7011 return (vam->retval);
7015 api_mpls_ip_bind_unbind (vat_main_t * vam)
7017 unformat_input_t *i = vam->input;
7018 vl_api_mpls_ip_bind_unbind_t *mp;
7019 u32 ip_table_id = 0;
7020 u8 create_table_if_needed = 0;
7023 ip4_address_t v4_address;
7024 ip6_address_t v6_address;
7027 mpls_label_t local_label = MPLS_LABEL_INVALID;
7030 /* Parse args required to build the message */
7031 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7033 if (unformat (i, "%U/%d", unformat_ip4_address,
7034 &v4_address, &address_length))
7039 else if (unformat (i, "%U/%d", unformat_ip6_address,
7040 &v6_address, &address_length))
7045 else if (unformat (i, "%d", &local_label))
7047 else if (unformat (i, "create-table"))
7048 create_table_if_needed = 1;
7049 else if (unformat (i, "table-id %d", &ip_table_id))
7051 else if (unformat (i, "unbind"))
7053 else if (unformat (i, "bind"))
7057 clib_warning ("parse error '%U'", format_unformat_error, i);
7064 errmsg ("IP addres not set");
7068 if (MPLS_LABEL_INVALID == local_label)
7070 errmsg ("missing label");
7074 /* Construct the API message */
7075 M (MPLS_IP_BIND_UNBIND, mp);
7077 mp->mb_create_table_if_needed = create_table_if_needed;
7078 mp->mb_is_bind = is_bind;
7079 mp->mb_is_ip4 = is_ip4;
7080 mp->mb_ip_table_id = ntohl (ip_table_id);
7081 mp->mb_mpls_table_id = 0;
7082 mp->mb_label = ntohl (local_label);
7083 mp->mb_address_length = address_length;
7086 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7088 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7093 /* Wait for a reply... */
7099 api_proxy_arp_add_del (vat_main_t * vam)
7101 unformat_input_t *i = vam->input;
7102 vl_api_proxy_arp_add_del_t *mp;
7105 ip4_address_t lo, hi;
7109 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7111 if (unformat (i, "vrf %d", &vrf_id))
7113 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7114 unformat_ip4_address, &hi))
7116 else if (unformat (i, "del"))
7120 clib_warning ("parse error '%U'", format_unformat_error, i);
7127 errmsg ("address range not set");
7131 M (PROXY_ARP_ADD_DEL, mp);
7133 mp->vrf_id = ntohl (vrf_id);
7134 mp->is_add = is_add;
7135 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7136 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7144 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7146 unformat_input_t *i = vam->input;
7147 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7150 u8 sw_if_index_set = 0;
7153 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7155 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7156 sw_if_index_set = 1;
7157 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7158 sw_if_index_set = 1;
7159 else if (unformat (i, "enable"))
7161 else if (unformat (i, "disable"))
7165 clib_warning ("parse error '%U'", format_unformat_error, i);
7170 if (sw_if_index_set == 0)
7172 errmsg ("missing interface name or sw_if_index");
7176 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7178 mp->sw_if_index = ntohl (sw_if_index);
7179 mp->enable_disable = enable;
7187 api_mpls_tunnel_add_del (vat_main_t * vam)
7189 unformat_input_t *i = vam->input;
7190 vl_api_mpls_tunnel_add_del_t *mp;
7194 u32 sw_if_index = ~0;
7195 u32 next_hop_sw_if_index = ~0;
7196 u32 next_hop_proto_is_ip4 = 1;
7198 u32 next_hop_table_id = 0;
7199 ip4_address_t v4_next_hop_address = {
7202 ip6_address_t v6_next_hop_address = { {0} };
7203 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7206 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7208 if (unformat (i, "add"))
7210 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7212 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7214 else if (unformat (i, "via %U",
7215 unformat_ip4_address, &v4_next_hop_address))
7217 next_hop_proto_is_ip4 = 1;
7219 else if (unformat (i, "via %U",
7220 unformat_ip6_address, &v6_next_hop_address))
7222 next_hop_proto_is_ip4 = 0;
7224 else if (unformat (i, "l2-only"))
7226 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7228 else if (unformat (i, "out-label %d", &next_hop_out_label))
7229 vec_add1 (labels, ntohl (next_hop_out_label));
7232 clib_warning ("parse error '%U'", format_unformat_error, i);
7237 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7239 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7240 mp->mt_sw_if_index = ntohl (sw_if_index);
7241 mp->mt_is_add = is_add;
7242 mp->mt_l2_only = l2_only;
7243 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7244 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7246 mp->mt_next_hop_n_out_labels = vec_len (labels);
7248 if (0 != mp->mt_next_hop_n_out_labels)
7250 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7251 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7255 if (next_hop_proto_is_ip4)
7257 clib_memcpy (mp->mt_next_hop,
7258 &v4_next_hop_address, sizeof (v4_next_hop_address));
7262 clib_memcpy (mp->mt_next_hop,
7263 &v6_next_hop_address, sizeof (v6_next_hop_address));
7272 api_sw_interface_set_unnumbered (vat_main_t * vam)
7274 unformat_input_t *i = vam->input;
7275 vl_api_sw_interface_set_unnumbered_t *mp;
7277 u32 unnum_sw_index = ~0;
7279 u8 sw_if_index_set = 0;
7282 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7284 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7285 sw_if_index_set = 1;
7286 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7287 sw_if_index_set = 1;
7288 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7290 else if (unformat (i, "del"))
7294 clib_warning ("parse error '%U'", format_unformat_error, i);
7299 if (sw_if_index_set == 0)
7301 errmsg ("missing interface name or sw_if_index");
7305 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7307 mp->sw_if_index = ntohl (sw_if_index);
7308 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7309 mp->is_add = is_add;
7317 api_ip_neighbor_add_del (vat_main_t * vam)
7319 unformat_input_t *i = vam->input;
7320 vl_api_ip_neighbor_add_del_t *mp;
7322 u8 sw_if_index_set = 0;
7325 u8 is_no_fib_entry = 0;
7328 u8 v4_address_set = 0;
7329 u8 v6_address_set = 0;
7330 ip4_address_t v4address;
7331 ip6_address_t v6address;
7334 memset (mac_address, 0, sizeof (mac_address));
7336 /* Parse args required to build the message */
7337 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7339 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7343 else if (unformat (i, "del"))
7346 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7347 sw_if_index_set = 1;
7348 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7349 sw_if_index_set = 1;
7350 else if (unformat (i, "is_static"))
7352 else if (unformat (i, "no-fib-entry"))
7353 is_no_fib_entry = 1;
7354 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7356 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7360 clib_warning ("parse error '%U'", format_unformat_error, i);
7365 if (sw_if_index_set == 0)
7367 errmsg ("missing interface name or sw_if_index");
7370 if (v4_address_set && v6_address_set)
7372 errmsg ("both v4 and v6 addresses set");
7375 if (!v4_address_set && !v6_address_set)
7377 errmsg ("no address set");
7381 /* Construct the API message */
7382 M (IP_NEIGHBOR_ADD_DEL, mp);
7384 mp->sw_if_index = ntohl (sw_if_index);
7385 mp->is_add = is_add;
7386 mp->is_static = is_static;
7387 mp->is_no_adj_fib = is_no_fib_entry;
7389 clib_memcpy (mp->mac_address, mac_address, 6);
7393 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7397 /* mp->is_ipv6 = 0; via memset in M macro above */
7398 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7404 /* Wait for a reply, return good/bad news */
7410 api_reset_vrf (vat_main_t * vam)
7412 unformat_input_t *i = vam->input;
7413 vl_api_reset_vrf_t *mp;
7419 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7421 if (unformat (i, "vrf %d", &vrf_id))
7423 else if (unformat (i, "ipv6"))
7427 clib_warning ("parse error '%U'", format_unformat_error, i);
7432 if (vrf_id_set == 0)
7434 errmsg ("missing vrf id");
7440 mp->vrf_id = ntohl (vrf_id);
7441 mp->is_ipv6 = is_ipv6;
7449 api_create_vlan_subif (vat_main_t * vam)
7451 unformat_input_t *i = vam->input;
7452 vl_api_create_vlan_subif_t *mp;
7454 u8 sw_if_index_set = 0;
7459 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7461 if (unformat (i, "sw_if_index %d", &sw_if_index))
7462 sw_if_index_set = 1;
7464 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7465 sw_if_index_set = 1;
7466 else if (unformat (i, "vlan %d", &vlan_id))
7470 clib_warning ("parse error '%U'", format_unformat_error, i);
7475 if (sw_if_index_set == 0)
7477 errmsg ("missing interface name or sw_if_index");
7481 if (vlan_id_set == 0)
7483 errmsg ("missing vlan_id");
7486 M (CREATE_VLAN_SUBIF, mp);
7488 mp->sw_if_index = ntohl (sw_if_index);
7489 mp->vlan_id = ntohl (vlan_id);
7496 #define foreach_create_subif_bit \
7503 _(outer_vlan_id_any) \
7504 _(inner_vlan_id_any)
7507 api_create_subif (vat_main_t * vam)
7509 unformat_input_t *i = vam->input;
7510 vl_api_create_subif_t *mp;
7512 u8 sw_if_index_set = 0;
7519 u32 exact_match = 0;
7520 u32 default_sub = 0;
7521 u32 outer_vlan_id_any = 0;
7522 u32 inner_vlan_id_any = 0;
7524 u16 outer_vlan_id = 0;
7525 u16 inner_vlan_id = 0;
7528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7530 if (unformat (i, "sw_if_index %d", &sw_if_index))
7531 sw_if_index_set = 1;
7533 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7534 sw_if_index_set = 1;
7535 else if (unformat (i, "sub_id %d", &sub_id))
7537 else if (unformat (i, "outer_vlan_id %d", &tmp))
7538 outer_vlan_id = tmp;
7539 else if (unformat (i, "inner_vlan_id %d", &tmp))
7540 inner_vlan_id = tmp;
7542 #define _(a) else if (unformat (i, #a)) a = 1 ;
7543 foreach_create_subif_bit
7547 clib_warning ("parse error '%U'", format_unformat_error, i);
7552 if (sw_if_index_set == 0)
7554 errmsg ("missing interface name or sw_if_index");
7558 if (sub_id_set == 0)
7560 errmsg ("missing sub_id");
7563 M (CREATE_SUBIF, mp);
7565 mp->sw_if_index = ntohl (sw_if_index);
7566 mp->sub_id = ntohl (sub_id);
7568 #define _(a) mp->a = a;
7569 foreach_create_subif_bit;
7572 mp->outer_vlan_id = ntohs (outer_vlan_id);
7573 mp->inner_vlan_id = ntohs (inner_vlan_id);
7581 api_oam_add_del (vat_main_t * vam)
7583 unformat_input_t *i = vam->input;
7584 vl_api_oam_add_del_t *mp;
7587 ip4_address_t src, dst;
7592 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7594 if (unformat (i, "vrf %d", &vrf_id))
7596 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7598 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7600 else if (unformat (i, "del"))
7604 clib_warning ("parse error '%U'", format_unformat_error, i);
7611 errmsg ("missing src addr");
7617 errmsg ("missing dst addr");
7621 M (OAM_ADD_DEL, mp);
7623 mp->vrf_id = ntohl (vrf_id);
7624 mp->is_add = is_add;
7625 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7626 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7634 api_reset_fib (vat_main_t * vam)
7636 unformat_input_t *i = vam->input;
7637 vl_api_reset_fib_t *mp;
7643 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7645 if (unformat (i, "vrf %d", &vrf_id))
7647 else if (unformat (i, "ipv6"))
7651 clib_warning ("parse error '%U'", format_unformat_error, i);
7656 if (vrf_id_set == 0)
7658 errmsg ("missing vrf id");
7664 mp->vrf_id = ntohl (vrf_id);
7665 mp->is_ipv6 = is_ipv6;
7673 api_dhcp_proxy_config (vat_main_t * vam)
7675 unformat_input_t *i = vam->input;
7676 vl_api_dhcp_proxy_config_t *mp;
7678 u32 server_vrf_id = 0;
7680 u8 v4_address_set = 0;
7681 u8 v6_address_set = 0;
7682 ip4_address_t v4address;
7683 ip6_address_t v6address;
7684 u8 v4_src_address_set = 0;
7685 u8 v6_src_address_set = 0;
7686 ip4_address_t v4srcaddress;
7687 ip6_address_t v6srcaddress;
7690 /* Parse args required to build the message */
7691 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7693 if (unformat (i, "del"))
7695 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7697 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7699 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7701 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7703 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7704 v4_src_address_set = 1;
7705 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7706 v6_src_address_set = 1;
7711 if (v4_address_set && v6_address_set)
7713 errmsg ("both v4 and v6 server addresses set");
7716 if (!v4_address_set && !v6_address_set)
7718 errmsg ("no server addresses set");
7722 if (v4_src_address_set && v6_src_address_set)
7724 errmsg ("both v4 and v6 src addresses set");
7727 if (!v4_src_address_set && !v6_src_address_set)
7729 errmsg ("no src addresses set");
7733 if (!(v4_src_address_set && v4_address_set) &&
7734 !(v6_src_address_set && v6_address_set))
7736 errmsg ("no matching server and src addresses set");
7740 /* Construct the API message */
7741 M (DHCP_PROXY_CONFIG, mp);
7743 mp->is_add = is_add;
7744 mp->rx_vrf_id = ntohl (rx_vrf_id);
7745 mp->server_vrf_id = ntohl (server_vrf_id);
7749 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7750 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7754 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7755 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7761 /* Wait for a reply, return good/bad news */
7766 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
7767 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
7770 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
7772 vat_main_t *vam = &vat_main;
7773 u32 i, count = mp->count;
7774 vl_api_dhcp_server_t *s;
7778 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7779 ntohl (mp->rx_vrf_id),
7780 format_ip6_address, mp->dhcp_src_address,
7781 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7784 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7785 ntohl (mp->rx_vrf_id),
7786 format_ip4_address, mp->dhcp_src_address,
7787 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7789 for (i = 0; i < count; i++)
7791 s = &mp->servers[i];
7795 " Server Table-ID %d, Server Address %U",
7796 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
7799 " Server Table-ID %d, Server Address %U",
7800 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
7804 static void vl_api_dhcp_proxy_details_t_handler_json
7805 (vl_api_dhcp_proxy_details_t * mp)
7807 vat_main_t *vam = &vat_main;
7808 vat_json_node_t *node = NULL;
7809 u32 i, count = mp->count;
7811 struct in6_addr ip6;
7812 vl_api_dhcp_server_t *s;
7814 if (VAT_JSON_ARRAY != vam->json_tree.type)
7816 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7817 vat_json_init_array (&vam->json_tree);
7819 node = vat_json_array_add (&vam->json_tree);
7821 vat_json_init_object (node);
7822 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
7823 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
7824 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
7828 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
7829 vat_json_object_add_ip6 (node, "src_address", ip6);
7833 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
7834 vat_json_object_add_ip4 (node, "src_address", ip4);
7837 for (i = 0; i < count; i++)
7839 s = &mp->servers[i];
7841 vat_json_object_add_uint (node, "server-table-id",
7842 ntohl (s->server_vrf_id));
7846 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
7847 vat_json_object_add_ip4 (node, "src_address", ip4);
7851 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
7852 vat_json_object_add_ip6 (node, "server_address", ip6);
7858 api_dhcp_proxy_dump (vat_main_t * vam)
7860 unformat_input_t *i = vam->input;
7861 vl_api_control_ping_t *mp_ping;
7862 vl_api_dhcp_proxy_dump_t *mp;
7866 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7868 if (unformat (i, "ipv6"))
7872 clib_warning ("parse error '%U'", format_unformat_error, i);
7877 M (DHCP_PROXY_DUMP, mp);
7879 mp->is_ip6 = is_ipv6;
7882 /* Use a control ping for synchronization */
7883 M (CONTROL_PING, mp_ping);
7891 api_dhcp_proxy_set_vss (vat_main_t * vam)
7893 unformat_input_t *i = vam->input;
7894 vl_api_dhcp_proxy_set_vss_t *mp;
7905 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7907 if (unformat (i, "tbl_id %d", &tbl_id))
7909 if (unformat (i, "fib_id %d", &fib_id))
7911 if (unformat (i, "oui %d", &oui))
7913 else if (unformat (i, "ipv6"))
7915 else if (unformat (i, "del"))
7919 clib_warning ("parse error '%U'", format_unformat_error, i);
7924 if (tbl_id_set == 0)
7926 errmsg ("missing tbl id");
7930 if (fib_id_set == 0)
7932 errmsg ("missing fib id");
7937 errmsg ("missing oui");
7941 M (DHCP_PROXY_SET_VSS, mp);
7942 mp->tbl_id = ntohl (tbl_id);
7943 mp->fib_id = ntohl (fib_id);
7944 mp->oui = ntohl (oui);
7945 mp->is_ipv6 = is_ipv6;
7946 mp->is_add = is_add;
7954 api_dhcp_client_config (vat_main_t * vam)
7956 unformat_input_t *i = vam->input;
7957 vl_api_dhcp_client_config_t *mp;
7959 u8 sw_if_index_set = 0;
7962 u8 disable_event = 0;
7965 /* Parse args required to build the message */
7966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7968 if (unformat (i, "del"))
7971 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7972 sw_if_index_set = 1;
7973 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7974 sw_if_index_set = 1;
7975 else if (unformat (i, "hostname %s", &hostname))
7977 else if (unformat (i, "disable_event"))
7983 if (sw_if_index_set == 0)
7985 errmsg ("missing interface name or sw_if_index");
7989 if (vec_len (hostname) > 63)
7991 errmsg ("hostname too long");
7993 vec_add1 (hostname, 0);
7995 /* Construct the API message */
7996 M (DHCP_CLIENT_CONFIG, mp);
7998 mp->sw_if_index = ntohl (sw_if_index);
7999 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
8000 vec_free (hostname);
8001 mp->is_add = is_add;
8002 mp->want_dhcp_event = disable_event ? 0 : 1;
8003 mp->pid = getpid ();
8008 /* Wait for a reply, return good/bad news */
8014 api_set_ip_flow_hash (vat_main_t * vam)
8016 unformat_input_t *i = vam->input;
8017 vl_api_set_ip_flow_hash_t *mp;
8029 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8031 if (unformat (i, "vrf %d", &vrf_id))
8033 else if (unformat (i, "ipv6"))
8035 else if (unformat (i, "src"))
8037 else if (unformat (i, "dst"))
8039 else if (unformat (i, "sport"))
8041 else if (unformat (i, "dport"))
8043 else if (unformat (i, "proto"))
8045 else if (unformat (i, "reverse"))
8050 clib_warning ("parse error '%U'", format_unformat_error, i);
8055 if (vrf_id_set == 0)
8057 errmsg ("missing vrf id");
8061 M (SET_IP_FLOW_HASH, mp);
8067 mp->reverse = reverse;
8068 mp->vrf_id = ntohl (vrf_id);
8069 mp->is_ipv6 = is_ipv6;
8077 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8079 unformat_input_t *i = vam->input;
8080 vl_api_sw_interface_ip6_enable_disable_t *mp;
8082 u8 sw_if_index_set = 0;
8086 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8088 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8089 sw_if_index_set = 1;
8090 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8091 sw_if_index_set = 1;
8092 else if (unformat (i, "enable"))
8094 else if (unformat (i, "disable"))
8098 clib_warning ("parse error '%U'", format_unformat_error, i);
8103 if (sw_if_index_set == 0)
8105 errmsg ("missing interface name or sw_if_index");
8109 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8111 mp->sw_if_index = ntohl (sw_if_index);
8112 mp->enable = enable;
8120 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8122 unformat_input_t *i = vam->input;
8123 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8125 u8 sw_if_index_set = 0;
8126 u8 v6_address_set = 0;
8127 ip6_address_t v6address;
8130 /* Parse args required to build the message */
8131 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8133 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8134 sw_if_index_set = 1;
8135 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8136 sw_if_index_set = 1;
8137 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8143 if (sw_if_index_set == 0)
8145 errmsg ("missing interface name or sw_if_index");
8148 if (!v6_address_set)
8150 errmsg ("no address set");
8154 /* Construct the API message */
8155 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8157 mp->sw_if_index = ntohl (sw_if_index);
8158 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8163 /* Wait for a reply, return good/bad news */
8169 api_ip6nd_proxy_add_del (vat_main_t * vam)
8171 unformat_input_t *i = vam->input;
8172 vl_api_ip6nd_proxy_add_del_t *mp;
8173 u32 sw_if_index = ~0;
8174 u8 v6_address_set = 0;
8175 ip6_address_t v6address;
8179 /* Parse args required to build the message */
8180 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8182 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8184 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8186 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8188 if (unformat (i, "del"))
8192 clib_warning ("parse error '%U'", format_unformat_error, i);
8197 if (sw_if_index == ~0)
8199 errmsg ("missing interface name or sw_if_index");
8202 if (!v6_address_set)
8204 errmsg ("no address set");
8208 /* Construct the API message */
8209 M (IP6ND_PROXY_ADD_DEL, mp);
8211 mp->is_del = is_del;
8212 mp->sw_if_index = ntohl (sw_if_index);
8213 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8218 /* Wait for a reply, return good/bad news */
8224 api_ip6nd_proxy_dump (vat_main_t * vam)
8226 vl_api_ip6nd_proxy_dump_t *mp;
8227 vl_api_control_ping_t *mp_ping;
8230 M (IP6ND_PROXY_DUMP, mp);
8234 /* Use a control ping for synchronization */
8235 M (CONTROL_PING, mp_ping);
8242 static void vl_api_ip6nd_proxy_details_t_handler
8243 (vl_api_ip6nd_proxy_details_t * mp)
8245 vat_main_t *vam = &vat_main;
8247 print (vam->ofp, "host %U sw_if_index %d",
8248 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
8251 static void vl_api_ip6nd_proxy_details_t_handler_json
8252 (vl_api_ip6nd_proxy_details_t * mp)
8254 vat_main_t *vam = &vat_main;
8255 struct in6_addr ip6;
8256 vat_json_node_t *node = NULL;
8258 if (VAT_JSON_ARRAY != vam->json_tree.type)
8260 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8261 vat_json_init_array (&vam->json_tree);
8263 node = vat_json_array_add (&vam->json_tree);
8265 vat_json_init_object (node);
8266 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
8268 clib_memcpy (&ip6, mp->address, sizeof (ip6));
8269 vat_json_object_add_ip6 (node, "host", ip6);
8273 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8275 unformat_input_t *i = vam->input;
8276 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8278 u8 sw_if_index_set = 0;
8279 u32 address_length = 0;
8280 u8 v6_address_set = 0;
8281 ip6_address_t v6address;
8283 u8 no_advertise = 0;
8285 u8 no_autoconfig = 0;
8288 u32 val_lifetime = 0;
8289 u32 pref_lifetime = 0;
8292 /* Parse args required to build the message */
8293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8295 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8296 sw_if_index_set = 1;
8297 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8298 sw_if_index_set = 1;
8299 else if (unformat (i, "%U/%d",
8300 unformat_ip6_address, &v6address, &address_length))
8302 else if (unformat (i, "val_life %d", &val_lifetime))
8304 else if (unformat (i, "pref_life %d", &pref_lifetime))
8306 else if (unformat (i, "def"))
8308 else if (unformat (i, "noadv"))
8310 else if (unformat (i, "offl"))
8312 else if (unformat (i, "noauto"))
8314 else if (unformat (i, "nolink"))
8316 else if (unformat (i, "isno"))
8320 clib_warning ("parse error '%U'", format_unformat_error, i);
8325 if (sw_if_index_set == 0)
8327 errmsg ("missing interface name or sw_if_index");
8330 if (!v6_address_set)
8332 errmsg ("no address set");
8336 /* Construct the API message */
8337 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8339 mp->sw_if_index = ntohl (sw_if_index);
8340 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8341 mp->address_length = address_length;
8342 mp->use_default = use_default;
8343 mp->no_advertise = no_advertise;
8344 mp->off_link = off_link;
8345 mp->no_autoconfig = no_autoconfig;
8346 mp->no_onlink = no_onlink;
8348 mp->val_lifetime = ntohl (val_lifetime);
8349 mp->pref_lifetime = ntohl (pref_lifetime);
8354 /* Wait for a reply, return good/bad news */
8360 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8362 unformat_input_t *i = vam->input;
8363 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8365 u8 sw_if_index_set = 0;
8370 u8 send_unicast = 0;
8373 u8 default_router = 0;
8374 u32 max_interval = 0;
8375 u32 min_interval = 0;
8377 u32 initial_count = 0;
8378 u32 initial_interval = 0;
8382 /* Parse args required to build the message */
8383 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8385 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8386 sw_if_index_set = 1;
8387 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8388 sw_if_index_set = 1;
8389 else if (unformat (i, "maxint %d", &max_interval))
8391 else if (unformat (i, "minint %d", &min_interval))
8393 else if (unformat (i, "life %d", &lifetime))
8395 else if (unformat (i, "count %d", &initial_count))
8397 else if (unformat (i, "interval %d", &initial_interval))
8399 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8401 else if (unformat (i, "managed"))
8403 else if (unformat (i, "other"))
8405 else if (unformat (i, "ll"))
8407 else if (unformat (i, "send"))
8409 else if (unformat (i, "cease"))
8411 else if (unformat (i, "isno"))
8413 else if (unformat (i, "def"))
8417 clib_warning ("parse error '%U'", format_unformat_error, i);
8422 if (sw_if_index_set == 0)
8424 errmsg ("missing interface name or sw_if_index");
8428 /* Construct the API message */
8429 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8431 mp->sw_if_index = ntohl (sw_if_index);
8432 mp->max_interval = ntohl (max_interval);
8433 mp->min_interval = ntohl (min_interval);
8434 mp->lifetime = ntohl (lifetime);
8435 mp->initial_count = ntohl (initial_count);
8436 mp->initial_interval = ntohl (initial_interval);
8437 mp->suppress = suppress;
8438 mp->managed = managed;
8440 mp->ll_option = ll_option;
8441 mp->send_unicast = send_unicast;
8444 mp->default_router = default_router;
8449 /* Wait for a reply, return good/bad news */
8455 api_set_arp_neighbor_limit (vat_main_t * vam)
8457 unformat_input_t *i = vam->input;
8458 vl_api_set_arp_neighbor_limit_t *mp;
8464 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8466 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8468 else if (unformat (i, "ipv6"))
8472 clib_warning ("parse error '%U'", format_unformat_error, i);
8479 errmsg ("missing limit value");
8483 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8485 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8486 mp->is_ipv6 = is_ipv6;
8494 api_l2_patch_add_del (vat_main_t * vam)
8496 unformat_input_t *i = vam->input;
8497 vl_api_l2_patch_add_del_t *mp;
8499 u8 rx_sw_if_index_set = 0;
8501 u8 tx_sw_if_index_set = 0;
8505 /* Parse args required to build the message */
8506 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8508 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8509 rx_sw_if_index_set = 1;
8510 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8511 tx_sw_if_index_set = 1;
8512 else if (unformat (i, "rx"))
8514 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8516 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8518 rx_sw_if_index_set = 1;
8523 else if (unformat (i, "tx"))
8525 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8527 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8529 tx_sw_if_index_set = 1;
8534 else if (unformat (i, "del"))
8540 if (rx_sw_if_index_set == 0)
8542 errmsg ("missing rx interface name or rx_sw_if_index");
8546 if (tx_sw_if_index_set == 0)
8548 errmsg ("missing tx interface name or tx_sw_if_index");
8552 M (L2_PATCH_ADD_DEL, mp);
8554 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8555 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8556 mp->is_add = is_add;
8564 u8 localsid_addr[16];
8573 api_sr_localsid_add_del (vat_main_t * vam)
8575 unformat_input_t *i = vam->input;
8576 vl_api_sr_localsid_add_del_t *mp;
8579 ip6_address_t localsid;
8583 u32 fib_table = ~(u32) 0;
8584 ip6_address_t next_hop;
8586 bool nexthop_set = 0;
8590 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8592 if (unformat (i, "del"))
8594 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
8595 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
8597 else if (unformat (i, "behavior %u", &behavior));
8598 else if (unformat (i, "sw_if_index %u", &sw_if_index));
8599 else if (unformat (i, "fib-table %u", &fib_table));
8600 else if (unformat (i, "end.psp %u", &behavior));
8605 M (SR_LOCALSID_ADD_DEL, mp);
8607 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
8609 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
8610 mp->behavior = behavior;
8611 mp->sw_if_index = ntohl (sw_if_index);
8612 mp->fib_table = ntohl (fib_table);
8613 mp->end_psp = end_psp;
8614 mp->is_del = is_del;
8622 api_ioam_enable (vat_main_t * vam)
8624 unformat_input_t *input = vam->input;
8625 vl_api_ioam_enable_t *mp;
8627 int has_trace_option = 0;
8628 int has_pot_option = 0;
8629 int has_seqno_option = 0;
8630 int has_analyse_option = 0;
8633 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8635 if (unformat (input, "trace"))
8636 has_trace_option = 1;
8637 else if (unformat (input, "pot"))
8639 else if (unformat (input, "seqno"))
8640 has_seqno_option = 1;
8641 else if (unformat (input, "analyse"))
8642 has_analyse_option = 1;
8646 M (IOAM_ENABLE, mp);
8647 mp->id = htons (id);
8648 mp->seqno = has_seqno_option;
8649 mp->analyse = has_analyse_option;
8650 mp->pot_enable = has_pot_option;
8651 mp->trace_enable = has_trace_option;
8660 api_ioam_disable (vat_main_t * vam)
8662 vl_api_ioam_disable_t *mp;
8665 M (IOAM_DISABLE, mp);
8671 #define foreach_tcp_proto_field \
8675 #define foreach_udp_proto_field \
8679 #define foreach_ip4_proto_field \
8691 u16 src_port, dst_port;
8694 #if VPP_API_TEST_BUILTIN == 0
8696 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8698 u8 **maskp = va_arg (*args, u8 **);
8700 u8 found_something = 0;
8703 #define _(a) u8 a=0;
8704 foreach_tcp_proto_field;
8707 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8710 #define _(a) else if (unformat (input, #a)) a=1;
8711 foreach_tcp_proto_field
8717 #define _(a) found_something += a;
8718 foreach_tcp_proto_field;
8721 if (found_something == 0)
8724 vec_validate (mask, sizeof (*tcp) - 1);
8726 tcp = (tcp_header_t *) mask;
8728 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8729 foreach_tcp_proto_field;
8737 unformat_udp_mask (unformat_input_t * input, va_list * args)
8739 u8 **maskp = va_arg (*args, u8 **);
8741 u8 found_something = 0;
8744 #define _(a) u8 a=0;
8745 foreach_udp_proto_field;
8748 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8751 #define _(a) else if (unformat (input, #a)) a=1;
8752 foreach_udp_proto_field
8758 #define _(a) found_something += a;
8759 foreach_udp_proto_field;
8762 if (found_something == 0)
8765 vec_validate (mask, sizeof (*udp) - 1);
8767 udp = (udp_header_t *) mask;
8769 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8770 foreach_udp_proto_field;
8778 unformat_l4_mask (unformat_input_t * input, va_list * args)
8780 u8 **maskp = va_arg (*args, u8 **);
8781 u16 src_port = 0, dst_port = 0;
8782 tcpudp_header_t *tcpudp;
8784 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8786 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8788 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8790 else if (unformat (input, "src_port"))
8792 else if (unformat (input, "dst_port"))
8798 if (!src_port && !dst_port)
8802 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8804 tcpudp = (tcpudp_header_t *) mask;
8805 tcpudp->src_port = src_port;
8806 tcpudp->dst_port = dst_port;
8814 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8816 u8 **maskp = va_arg (*args, u8 **);
8818 u8 found_something = 0;
8821 #define _(a) u8 a=0;
8822 foreach_ip4_proto_field;
8828 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8830 if (unformat (input, "version"))
8832 else if (unformat (input, "hdr_length"))
8834 else if (unformat (input, "src"))
8836 else if (unformat (input, "dst"))
8838 else if (unformat (input, "proto"))
8841 #define _(a) else if (unformat (input, #a)) a=1;
8842 foreach_ip4_proto_field
8848 #define _(a) found_something += a;
8849 foreach_ip4_proto_field;
8852 if (found_something == 0)
8855 vec_validate (mask, sizeof (*ip) - 1);
8857 ip = (ip4_header_t *) mask;
8859 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8860 foreach_ip4_proto_field;
8863 ip->ip_version_and_header_length = 0;
8866 ip->ip_version_and_header_length |= 0xF0;
8869 ip->ip_version_and_header_length |= 0x0F;
8875 #define foreach_ip6_proto_field \
8883 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8885 u8 **maskp = va_arg (*args, u8 **);
8887 u8 found_something = 0;
8889 u32 ip_version_traffic_class_and_flow_label;
8891 #define _(a) u8 a=0;
8892 foreach_ip6_proto_field;
8895 u8 traffic_class = 0;
8898 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8900 if (unformat (input, "version"))
8902 else if (unformat (input, "traffic-class"))
8904 else if (unformat (input, "flow-label"))
8906 else if (unformat (input, "src"))
8908 else if (unformat (input, "dst"))
8910 else if (unformat (input, "proto"))
8913 #define _(a) else if (unformat (input, #a)) a=1;
8914 foreach_ip6_proto_field
8920 #define _(a) found_something += a;
8921 foreach_ip6_proto_field;
8924 if (found_something == 0)
8927 vec_validate (mask, sizeof (*ip) - 1);
8929 ip = (ip6_header_t *) mask;
8931 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8932 foreach_ip6_proto_field;
8935 ip_version_traffic_class_and_flow_label = 0;
8938 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8941 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8944 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8946 ip->ip_version_traffic_class_and_flow_label =
8947 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8954 unformat_l3_mask (unformat_input_t * input, va_list * args)
8956 u8 **maskp = va_arg (*args, u8 **);
8958 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8960 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8962 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8971 unformat_l2_mask (unformat_input_t * input, va_list * args)
8973 u8 **maskp = va_arg (*args, u8 **);
8988 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8990 if (unformat (input, "src"))
8992 else if (unformat (input, "dst"))
8994 else if (unformat (input, "proto"))
8996 else if (unformat (input, "tag1"))
8998 else if (unformat (input, "tag2"))
9000 else if (unformat (input, "ignore-tag1"))
9002 else if (unformat (input, "ignore-tag2"))
9004 else if (unformat (input, "cos1"))
9006 else if (unformat (input, "cos2"))
9008 else if (unformat (input, "dot1q"))
9010 else if (unformat (input, "dot1ad"))
9015 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9016 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9019 if (tag1 || ignore_tag1 || cos1 || dot1q)
9021 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9024 vec_validate (mask, len - 1);
9027 memset (mask, 0xff, 6);
9030 memset (mask + 6, 0xff, 6);
9034 /* inner vlan tag */
9043 mask[21] = mask[20] = 0xff;
9064 mask[16] = mask[17] = 0xff;
9074 mask[12] = mask[13] = 0xff;
9081 unformat_classify_mask (unformat_input_t * input, va_list * args)
9083 u8 **maskp = va_arg (*args, u8 **);
9084 u32 *skipp = va_arg (*args, u32 *);
9085 u32 *matchp = va_arg (*args, u32 *);
9093 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9095 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9097 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9099 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9101 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9115 if (mask || l2 || l3 || l4)
9119 /* "With a free Ethernet header in every package" */
9121 vec_validate (l2, 13);
9125 vec_append (mask, l3);
9130 vec_append (mask, l4);
9135 /* Scan forward looking for the first significant mask octet */
9136 for (i = 0; i < vec_len (mask); i++)
9140 /* compute (skip, match) params */
9141 *skipp = i / sizeof (u32x4);
9142 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9144 /* Pad mask to an even multiple of the vector size */
9145 while (vec_len (mask) % sizeof (u32x4))
9148 match = vec_len (mask) / sizeof (u32x4);
9150 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9152 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9153 if (*tmp || *(tmp + 1))
9158 clib_warning ("BUG: match 0");
9160 _vec_len (mask) = match * sizeof (u32x4);
9170 #endif /* VPP_API_TEST_BUILTIN */
9172 #define foreach_l2_next \
9174 _(ethernet, ETHERNET_INPUT) \
9179 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9181 u32 *miss_next_indexp = va_arg (*args, u32 *);
9186 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9190 if (unformat (input, "%d", &tmp))
9199 *miss_next_indexp = next_index;
9203 #define foreach_ip_next \
9209 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9211 u32 *miss_next_indexp = va_arg (*args, u32 *);
9216 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9220 if (unformat (input, "%d", &tmp))
9229 *miss_next_indexp = next_index;
9233 #define foreach_acl_next \
9237 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9239 u32 *miss_next_indexp = va_arg (*args, u32 *);
9244 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9248 if (unformat (input, "permit"))
9253 else if (unformat (input, "%d", &tmp))
9262 *miss_next_indexp = next_index;
9267 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9269 u32 *r = va_arg (*args, u32 *);
9271 if (unformat (input, "conform-color"))
9272 *r = POLICE_CONFORM;
9273 else if (unformat (input, "exceed-color"))
9282 api_classify_add_del_table (vat_main_t * vam)
9284 unformat_input_t *i = vam->input;
9285 vl_api_classify_add_del_table_t *mp;
9292 u32 table_index = ~0;
9293 u32 next_table_index = ~0;
9294 u32 miss_next_index = ~0;
9295 u32 memory_size = 32 << 20;
9297 u32 current_data_flag = 0;
9298 int current_data_offset = 0;
9301 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9303 if (unformat (i, "del"))
9305 else if (unformat (i, "del-chain"))
9310 else if (unformat (i, "buckets %d", &nbuckets))
9312 else if (unformat (i, "memory_size %d", &memory_size))
9314 else if (unformat (i, "skip %d", &skip))
9316 else if (unformat (i, "match %d", &match))
9318 else if (unformat (i, "table %d", &table_index))
9320 else if (unformat (i, "mask %U", unformat_classify_mask,
9321 &mask, &skip, &match))
9323 else if (unformat (i, "next-table %d", &next_table_index))
9325 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9328 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9331 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9334 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9336 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9342 if (is_add && mask == 0)
9344 errmsg ("Mask required");
9348 if (is_add && skip == ~0)
9350 errmsg ("skip count required");
9354 if (is_add && match == ~0)
9356 errmsg ("match count required");
9360 if (!is_add && table_index == ~0)
9362 errmsg ("table index required for delete");
9366 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9368 mp->is_add = is_add;
9369 mp->del_chain = del_chain;
9370 mp->table_index = ntohl (table_index);
9371 mp->nbuckets = ntohl (nbuckets);
9372 mp->memory_size = ntohl (memory_size);
9373 mp->skip_n_vectors = ntohl (skip);
9374 mp->match_n_vectors = ntohl (match);
9375 mp->next_table_index = ntohl (next_table_index);
9376 mp->miss_next_index = ntohl (miss_next_index);
9377 mp->current_data_flag = ntohl (current_data_flag);
9378 mp->current_data_offset = ntohl (current_data_offset);
9379 clib_memcpy (mp->mask, mask, vec_len (mask));
9388 #if VPP_API_TEST_BUILTIN == 0
9390 unformat_l4_match (unformat_input_t * input, va_list * args)
9392 u8 **matchp = va_arg (*args, u8 **);
9394 u8 *proto_header = 0;
9400 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9402 if (unformat (input, "src_port %d", &src_port))
9404 else if (unformat (input, "dst_port %d", &dst_port))
9410 h.src_port = clib_host_to_net_u16 (src_port);
9411 h.dst_port = clib_host_to_net_u16 (dst_port);
9412 vec_validate (proto_header, sizeof (h) - 1);
9413 memcpy (proto_header, &h, sizeof (h));
9415 *matchp = proto_header;
9421 unformat_ip4_match (unformat_input_t * input, va_list * args)
9423 u8 **matchp = va_arg (*args, u8 **);
9430 int src = 0, dst = 0;
9431 ip4_address_t src_val, dst_val;
9438 int fragment_id = 0;
9439 u32 fragment_id_val;
9445 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9447 if (unformat (input, "version %d", &version_val))
9449 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9451 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9453 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9455 else if (unformat (input, "proto %d", &proto_val))
9457 else if (unformat (input, "tos %d", &tos_val))
9459 else if (unformat (input, "length %d", &length_val))
9461 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9463 else if (unformat (input, "ttl %d", &ttl_val))
9465 else if (unformat (input, "checksum %d", &checksum_val))
9471 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9472 + ttl + checksum == 0)
9476 * Aligned because we use the real comparison functions
9478 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9480 ip = (ip4_header_t *) match;
9482 /* These are realistically matched in practice */
9484 ip->src_address.as_u32 = src_val.as_u32;
9487 ip->dst_address.as_u32 = dst_val.as_u32;
9490 ip->protocol = proto_val;
9493 /* These are not, but they're included for completeness */
9495 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9498 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9504 ip->length = clib_host_to_net_u16 (length_val);
9510 ip->checksum = clib_host_to_net_u16 (checksum_val);
9517 unformat_ip6_match (unformat_input_t * input, va_list * args)
9519 u8 **matchp = va_arg (*args, u8 **);
9524 u8 traffic_class = 0;
9525 u32 traffic_class_val = 0;
9528 int src = 0, dst = 0;
9529 ip6_address_t src_val, dst_val;
9532 int payload_length = 0;
9533 u32 payload_length_val;
9536 u32 ip_version_traffic_class_and_flow_label;
9538 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9540 if (unformat (input, "version %d", &version_val))
9542 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9544 else if (unformat (input, "flow_label %d", &flow_label_val))
9546 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9548 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9550 else if (unformat (input, "proto %d", &proto_val))
9552 else if (unformat (input, "payload_length %d", &payload_length_val))
9554 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9560 if (version + traffic_class + flow_label + src + dst + proto +
9561 payload_length + hop_limit == 0)
9565 * Aligned because we use the real comparison functions
9567 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9569 ip = (ip6_header_t *) match;
9572 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9575 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9578 ip->protocol = proto_val;
9580 ip_version_traffic_class_and_flow_label = 0;
9583 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9586 ip_version_traffic_class_and_flow_label |=
9587 (traffic_class_val & 0xFF) << 20;
9590 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9592 ip->ip_version_traffic_class_and_flow_label =
9593 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9596 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9599 ip->hop_limit = hop_limit_val;
9606 unformat_l3_match (unformat_input_t * input, va_list * args)
9608 u8 **matchp = va_arg (*args, u8 **);
9610 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9612 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9614 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9623 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9625 u8 *tagp = va_arg (*args, u8 *);
9628 if (unformat (input, "%d", &tag))
9630 tagp[0] = (tag >> 8) & 0x0F;
9631 tagp[1] = tag & 0xFF;
9639 unformat_l2_match (unformat_input_t * input, va_list * args)
9641 u8 **matchp = va_arg (*args, u8 **);
9661 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9663 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9666 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9668 else if (unformat (input, "proto %U",
9669 unformat_ethernet_type_host_byte_order, &proto_val))
9671 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9673 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9675 else if (unformat (input, "ignore-tag1"))
9677 else if (unformat (input, "ignore-tag2"))
9679 else if (unformat (input, "cos1 %d", &cos1_val))
9681 else if (unformat (input, "cos2 %d", &cos2_val))
9686 if ((src + dst + proto + tag1 + tag2 +
9687 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9690 if (tag1 || ignore_tag1 || cos1)
9692 if (tag2 || ignore_tag2 || cos2)
9695 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9698 clib_memcpy (match, dst_val, 6);
9701 clib_memcpy (match + 6, src_val, 6);
9705 /* inner vlan tag */
9706 match[19] = tag2_val[1];
9707 match[18] = tag2_val[0];
9709 match[18] |= (cos2_val & 0x7) << 5;
9712 match[21] = proto_val & 0xff;
9713 match[20] = proto_val >> 8;
9717 match[15] = tag1_val[1];
9718 match[14] = tag1_val[0];
9721 match[14] |= (cos1_val & 0x7) << 5;
9727 match[15] = tag1_val[1];
9728 match[14] = tag1_val[0];
9731 match[17] = proto_val & 0xff;
9732 match[16] = proto_val >> 8;
9735 match[14] |= (cos1_val & 0x7) << 5;
9741 match[18] |= (cos2_val & 0x7) << 5;
9743 match[14] |= (cos1_val & 0x7) << 5;
9746 match[13] = proto_val & 0xff;
9747 match[12] = proto_val >> 8;
9756 api_unformat_classify_match (unformat_input_t * input, va_list * args)
9758 u8 **matchp = va_arg (*args, u8 **);
9759 u32 skip_n_vectors = va_arg (*args, u32);
9760 u32 match_n_vectors = va_arg (*args, u32);
9767 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9769 if (unformat (input, "hex %U", unformat_hex_string, &match))
9771 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9773 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9775 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9789 if (match || l2 || l3 || l4)
9793 /* "Win a free Ethernet header in every packet" */
9795 vec_validate_aligned (l2, 13, sizeof (u32x4));
9799 vec_append_aligned (match, l3, sizeof (u32x4));
9804 vec_append_aligned (match, l4, sizeof (u32x4));
9809 /* Make sure the vector is big enough even if key is all 0's */
9810 vec_validate_aligned
9811 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9814 /* Set size, include skipped vectors */
9815 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9826 api_classify_add_del_session (vat_main_t * vam)
9828 unformat_input_t *i = vam->input;
9829 vl_api_classify_add_del_session_t *mp;
9831 u32 table_index = ~0;
9832 u32 hit_next_index = ~0;
9833 u32 opaque_index = ~0;
9836 u32 skip_n_vectors = 0;
9837 u32 match_n_vectors = 0;
9843 * Warning: you have to supply skip_n and match_n
9844 * because the API client cant simply look at the classify
9848 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9850 if (unformat (i, "del"))
9852 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
9855 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9858 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
9861 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9863 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9865 else if (unformat (i, "opaque-index %d", &opaque_index))
9867 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9869 else if (unformat (i, "match_n %d", &match_n_vectors))
9871 else if (unformat (i, "match %U", api_unformat_classify_match,
9872 &match, skip_n_vectors, match_n_vectors))
9874 else if (unformat (i, "advance %d", &advance))
9876 else if (unformat (i, "table-index %d", &table_index))
9878 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9880 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9882 else if (unformat (i, "action %d", &action))
9884 else if (unformat (i, "metadata %d", &metadata))
9890 if (table_index == ~0)
9892 errmsg ("Table index required");
9896 if (is_add && match == 0)
9898 errmsg ("Match value required");
9902 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
9904 mp->is_add = is_add;
9905 mp->table_index = ntohl (table_index);
9906 mp->hit_next_index = ntohl (hit_next_index);
9907 mp->opaque_index = ntohl (opaque_index);
9908 mp->advance = ntohl (advance);
9909 mp->action = action;
9910 mp->metadata = ntohl (metadata);
9911 clib_memcpy (mp->match, match, vec_len (match));
9920 api_classify_set_interface_ip_table (vat_main_t * vam)
9922 unformat_input_t *i = vam->input;
9923 vl_api_classify_set_interface_ip_table_t *mp;
9925 int sw_if_index_set;
9926 u32 table_index = ~0;
9930 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9932 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9933 sw_if_index_set = 1;
9934 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9935 sw_if_index_set = 1;
9936 else if (unformat (i, "table %d", &table_index))
9940 clib_warning ("parse error '%U'", format_unformat_error, i);
9945 if (sw_if_index_set == 0)
9947 errmsg ("missing interface name or sw_if_index");
9952 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
9954 mp->sw_if_index = ntohl (sw_if_index);
9955 mp->table_index = ntohl (table_index);
9956 mp->is_ipv6 = is_ipv6;
9964 api_classify_set_interface_l2_tables (vat_main_t * vam)
9966 unformat_input_t *i = vam->input;
9967 vl_api_classify_set_interface_l2_tables_t *mp;
9969 int sw_if_index_set;
9970 u32 ip4_table_index = ~0;
9971 u32 ip6_table_index = ~0;
9972 u32 other_table_index = ~0;
9976 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9978 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9979 sw_if_index_set = 1;
9980 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9981 sw_if_index_set = 1;
9982 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9984 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9986 else if (unformat (i, "other-table %d", &other_table_index))
9988 else if (unformat (i, "is-input %d", &is_input))
9992 clib_warning ("parse error '%U'", format_unformat_error, i);
9997 if (sw_if_index_set == 0)
9999 errmsg ("missing interface name or sw_if_index");
10004 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10006 mp->sw_if_index = ntohl (sw_if_index);
10007 mp->ip4_table_index = ntohl (ip4_table_index);
10008 mp->ip6_table_index = ntohl (ip6_table_index);
10009 mp->other_table_index = ntohl (other_table_index);
10010 mp->is_input = (u8) is_input;
10018 api_set_ipfix_exporter (vat_main_t * vam)
10020 unformat_input_t *i = vam->input;
10021 vl_api_set_ipfix_exporter_t *mp;
10022 ip4_address_t collector_address;
10023 u8 collector_address_set = 0;
10024 u32 collector_port = ~0;
10025 ip4_address_t src_address;
10026 u8 src_address_set = 0;
10029 u32 template_interval = ~0;
10030 u8 udp_checksum = 0;
10033 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10035 if (unformat (i, "collector_address %U", unformat_ip4_address,
10036 &collector_address))
10037 collector_address_set = 1;
10038 else if (unformat (i, "collector_port %d", &collector_port))
10040 else if (unformat (i, "src_address %U", unformat_ip4_address,
10042 src_address_set = 1;
10043 else if (unformat (i, "vrf_id %d", &vrf_id))
10045 else if (unformat (i, "path_mtu %d", &path_mtu))
10047 else if (unformat (i, "template_interval %d", &template_interval))
10049 else if (unformat (i, "udp_checksum"))
10055 if (collector_address_set == 0)
10057 errmsg ("collector_address required");
10061 if (src_address_set == 0)
10063 errmsg ("src_address required");
10067 M (SET_IPFIX_EXPORTER, mp);
10069 memcpy (mp->collector_address, collector_address.data,
10070 sizeof (collector_address.data));
10071 mp->collector_port = htons ((u16) collector_port);
10072 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10073 mp->vrf_id = htonl (vrf_id);
10074 mp->path_mtu = htonl (path_mtu);
10075 mp->template_interval = htonl (template_interval);
10076 mp->udp_checksum = udp_checksum;
10084 api_set_ipfix_classify_stream (vat_main_t * vam)
10086 unformat_input_t *i = vam->input;
10087 vl_api_set_ipfix_classify_stream_t *mp;
10089 u32 src_port = UDP_DST_PORT_ipfix;
10092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10094 if (unformat (i, "domain %d", &domain_id))
10096 else if (unformat (i, "src_port %d", &src_port))
10100 errmsg ("unknown input `%U'", format_unformat_error, i);
10105 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10107 mp->domain_id = htonl (domain_id);
10108 mp->src_port = htons ((u16) src_port);
10116 api_ipfix_classify_table_add_del (vat_main_t * vam)
10118 unformat_input_t *i = vam->input;
10119 vl_api_ipfix_classify_table_add_del_t *mp;
10121 u32 classify_table_index = ~0;
10123 u8 transport_protocol = 255;
10126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10128 if (unformat (i, "add"))
10130 else if (unformat (i, "del"))
10132 else if (unformat (i, "table %d", &classify_table_index))
10134 else if (unformat (i, "ip4"))
10136 else if (unformat (i, "ip6"))
10138 else if (unformat (i, "tcp"))
10139 transport_protocol = 6;
10140 else if (unformat (i, "udp"))
10141 transport_protocol = 17;
10144 errmsg ("unknown input `%U'", format_unformat_error, i);
10151 errmsg ("expecting: add|del");
10154 if (classify_table_index == ~0)
10156 errmsg ("classifier table not specified");
10159 if (ip_version == 0)
10161 errmsg ("IP version not specified");
10165 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10167 mp->is_add = is_add;
10168 mp->table_id = htonl (classify_table_index);
10169 mp->ip_version = ip_version;
10170 mp->transport_protocol = transport_protocol;
10178 api_get_node_index (vat_main_t * vam)
10180 unformat_input_t *i = vam->input;
10181 vl_api_get_node_index_t *mp;
10185 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10187 if (unformat (i, "node %s", &name))
10194 errmsg ("node name required");
10197 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10199 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10203 M (GET_NODE_INDEX, mp);
10204 clib_memcpy (mp->node_name, name, vec_len (name));
10213 api_get_next_index (vat_main_t * vam)
10215 unformat_input_t *i = vam->input;
10216 vl_api_get_next_index_t *mp;
10217 u8 *node_name = 0, *next_node_name = 0;
10220 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10222 if (unformat (i, "node-name %s", &node_name))
10224 else if (unformat (i, "next-node-name %s", &next_node_name))
10228 if (node_name == 0)
10230 errmsg ("node name required");
10233 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10235 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10239 if (next_node_name == 0)
10241 errmsg ("next node name required");
10244 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10246 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10250 M (GET_NEXT_INDEX, mp);
10251 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10252 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10253 vec_free (node_name);
10254 vec_free (next_node_name);
10262 api_add_node_next (vat_main_t * vam)
10264 unformat_input_t *i = vam->input;
10265 vl_api_add_node_next_t *mp;
10270 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10272 if (unformat (i, "node %s", &name))
10274 else if (unformat (i, "next %s", &next))
10281 errmsg ("node name required");
10284 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10286 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10291 errmsg ("next node required");
10294 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10296 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10300 M (ADD_NODE_NEXT, mp);
10301 clib_memcpy (mp->node_name, name, vec_len (name));
10302 clib_memcpy (mp->next_name, next, vec_len (next));
10312 api_l2tpv3_create_tunnel (vat_main_t * vam)
10314 unformat_input_t *i = vam->input;
10315 ip6_address_t client_address, our_address;
10316 int client_address_set = 0;
10317 int our_address_set = 0;
10318 u32 local_session_id = 0;
10319 u32 remote_session_id = 0;
10320 u64 local_cookie = 0;
10321 u64 remote_cookie = 0;
10322 u8 l2_sublayer_present = 0;
10323 vl_api_l2tpv3_create_tunnel_t *mp;
10326 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10328 if (unformat (i, "client_address %U", unformat_ip6_address,
10330 client_address_set = 1;
10331 else if (unformat (i, "our_address %U", unformat_ip6_address,
10333 our_address_set = 1;
10334 else if (unformat (i, "local_session_id %d", &local_session_id))
10336 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10338 else if (unformat (i, "local_cookie %lld", &local_cookie))
10340 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10342 else if (unformat (i, "l2-sublayer-present"))
10343 l2_sublayer_present = 1;
10348 if (client_address_set == 0)
10350 errmsg ("client_address required");
10354 if (our_address_set == 0)
10356 errmsg ("our_address required");
10360 M (L2TPV3_CREATE_TUNNEL, mp);
10362 clib_memcpy (mp->client_address, client_address.as_u8,
10363 sizeof (mp->client_address));
10365 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10367 mp->local_session_id = ntohl (local_session_id);
10368 mp->remote_session_id = ntohl (remote_session_id);
10369 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10370 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10371 mp->l2_sublayer_present = l2_sublayer_present;
10380 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10382 unformat_input_t *i = vam->input;
10384 u8 sw_if_index_set = 0;
10385 u64 new_local_cookie = 0;
10386 u64 new_remote_cookie = 0;
10387 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10390 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10392 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10393 sw_if_index_set = 1;
10394 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10395 sw_if_index_set = 1;
10396 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10398 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10404 if (sw_if_index_set == 0)
10406 errmsg ("missing interface name or sw_if_index");
10410 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10412 mp->sw_if_index = ntohl (sw_if_index);
10413 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10414 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10422 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10424 unformat_input_t *i = vam->input;
10425 vl_api_l2tpv3_interface_enable_disable_t *mp;
10427 u8 sw_if_index_set = 0;
10428 u8 enable_disable = 1;
10431 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10433 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10434 sw_if_index_set = 1;
10435 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10436 sw_if_index_set = 1;
10437 else if (unformat (i, "enable"))
10438 enable_disable = 1;
10439 else if (unformat (i, "disable"))
10440 enable_disable = 0;
10445 if (sw_if_index_set == 0)
10447 errmsg ("missing interface name or sw_if_index");
10451 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10453 mp->sw_if_index = ntohl (sw_if_index);
10454 mp->enable_disable = enable_disable;
10462 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10464 unformat_input_t *i = vam->input;
10465 vl_api_l2tpv3_set_lookup_key_t *mp;
10469 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10471 if (unformat (i, "lookup_v6_src"))
10472 key = L2T_LOOKUP_SRC_ADDRESS;
10473 else if (unformat (i, "lookup_v6_dst"))
10474 key = L2T_LOOKUP_DST_ADDRESS;
10475 else if (unformat (i, "lookup_session_id"))
10476 key = L2T_LOOKUP_SESSION_ID;
10481 if (key == (u8) ~ 0)
10483 errmsg ("l2tp session lookup key unset");
10487 M (L2TPV3_SET_LOOKUP_KEY, mp);
10496 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10497 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10499 vat_main_t *vam = &vat_main;
10501 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10502 format_ip6_address, mp->our_address,
10503 format_ip6_address, mp->client_address,
10504 clib_net_to_host_u32 (mp->sw_if_index));
10507 " local cookies %016llx %016llx remote cookie %016llx",
10508 clib_net_to_host_u64 (mp->local_cookie[0]),
10509 clib_net_to_host_u64 (mp->local_cookie[1]),
10510 clib_net_to_host_u64 (mp->remote_cookie));
10512 print (vam->ofp, " local session-id %d remote session-id %d",
10513 clib_net_to_host_u32 (mp->local_session_id),
10514 clib_net_to_host_u32 (mp->remote_session_id));
10516 print (vam->ofp, " l2 specific sublayer %s\n",
10517 mp->l2_sublayer_present ? "preset" : "absent");
10521 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10522 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10524 vat_main_t *vam = &vat_main;
10525 vat_json_node_t *node = NULL;
10526 struct in6_addr addr;
10528 if (VAT_JSON_ARRAY != vam->json_tree.type)
10530 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10531 vat_json_init_array (&vam->json_tree);
10533 node = vat_json_array_add (&vam->json_tree);
10535 vat_json_init_object (node);
10537 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10538 vat_json_object_add_ip6 (node, "our_address", addr);
10539 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10540 vat_json_object_add_ip6 (node, "client_address", addr);
10542 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10543 vat_json_init_array (lc);
10544 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10545 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10546 vat_json_object_add_uint (node, "remote_cookie",
10547 clib_net_to_host_u64 (mp->remote_cookie));
10549 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10550 vat_json_object_add_uint (node, "local_session_id",
10551 clib_net_to_host_u32 (mp->local_session_id));
10552 vat_json_object_add_uint (node, "remote_session_id",
10553 clib_net_to_host_u32 (mp->remote_session_id));
10554 vat_json_object_add_string_copy (node, "l2_sublayer",
10555 mp->l2_sublayer_present ? (u8 *) "present"
10556 : (u8 *) "absent");
10560 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10562 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10563 vl_api_control_ping_t *mp_ping;
10566 /* Get list of l2tpv3-tunnel interfaces */
10567 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10570 /* Use a control ping for synchronization */
10571 M (CONTROL_PING, mp_ping);
10579 static void vl_api_sw_interface_tap_details_t_handler
10580 (vl_api_sw_interface_tap_details_t * mp)
10582 vat_main_t *vam = &vat_main;
10584 print (vam->ofp, "%-16s %d",
10585 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10588 static void vl_api_sw_interface_tap_details_t_handler_json
10589 (vl_api_sw_interface_tap_details_t * mp)
10591 vat_main_t *vam = &vat_main;
10592 vat_json_node_t *node = NULL;
10594 if (VAT_JSON_ARRAY != vam->json_tree.type)
10596 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10597 vat_json_init_array (&vam->json_tree);
10599 node = vat_json_array_add (&vam->json_tree);
10601 vat_json_init_object (node);
10602 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10603 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10607 api_sw_interface_tap_dump (vat_main_t * vam)
10609 vl_api_sw_interface_tap_dump_t *mp;
10610 vl_api_control_ping_t *mp_ping;
10613 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10614 /* Get list of tap interfaces */
10615 M (SW_INTERFACE_TAP_DUMP, mp);
10618 /* Use a control ping for synchronization */
10619 M (CONTROL_PING, mp_ping);
10626 static uword unformat_vxlan_decap_next
10627 (unformat_input_t * input, va_list * args)
10629 u32 *result = va_arg (*args, u32 *);
10632 if (unformat (input, "l2"))
10633 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10634 else if (unformat (input, "%d", &tmp))
10642 api_vxlan_add_del_tunnel (vat_main_t * vam)
10644 unformat_input_t *line_input = vam->input;
10645 vl_api_vxlan_add_del_tunnel_t *mp;
10646 ip46_address_t src, dst;
10648 u8 ipv4_set = 0, ipv6_set = 0;
10652 u32 mcast_sw_if_index = ~0;
10653 u32 encap_vrf_id = 0;
10654 u32 decap_next_index = ~0;
10658 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10659 memset (&src, 0, sizeof src);
10660 memset (&dst, 0, sizeof dst);
10662 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10664 if (unformat (line_input, "del"))
10667 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10673 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10679 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10685 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10690 else if (unformat (line_input, "group %U %U",
10691 unformat_ip4_address, &dst.ip4,
10692 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10694 grp_set = dst_set = 1;
10697 else if (unformat (line_input, "group %U",
10698 unformat_ip4_address, &dst.ip4))
10700 grp_set = dst_set = 1;
10703 else if (unformat (line_input, "group %U %U",
10704 unformat_ip6_address, &dst.ip6,
10705 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10707 grp_set = dst_set = 1;
10710 else if (unformat (line_input, "group %U",
10711 unformat_ip6_address, &dst.ip6))
10713 grp_set = dst_set = 1;
10717 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10719 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10721 else if (unformat (line_input, "decap-next %U",
10722 unformat_vxlan_decap_next, &decap_next_index))
10724 else if (unformat (line_input, "vni %d", &vni))
10728 errmsg ("parse error '%U'", format_unformat_error, line_input);
10735 errmsg ("tunnel src address not specified");
10740 errmsg ("tunnel dst address not specified");
10744 if (grp_set && !ip46_address_is_multicast (&dst))
10746 errmsg ("tunnel group address not multicast");
10749 if (grp_set && mcast_sw_if_index == ~0)
10751 errmsg ("tunnel nonexistent multicast device");
10754 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10756 errmsg ("tunnel dst address must be unicast");
10761 if (ipv4_set && ipv6_set)
10763 errmsg ("both IPv4 and IPv6 addresses specified");
10767 if ((vni == 0) || (vni >> 24))
10769 errmsg ("vni not specified or out of range");
10773 M (VXLAN_ADD_DEL_TUNNEL, mp);
10777 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10778 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10782 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10783 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10785 mp->encap_vrf_id = ntohl (encap_vrf_id);
10786 mp->decap_next_index = ntohl (decap_next_index);
10787 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10788 mp->vni = ntohl (vni);
10789 mp->is_add = is_add;
10790 mp->is_ipv6 = ipv6_set;
10797 static void vl_api_vxlan_tunnel_details_t_handler
10798 (vl_api_vxlan_tunnel_details_t * mp)
10800 vat_main_t *vam = &vat_main;
10801 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
10802 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
10804 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10805 ntohl (mp->sw_if_index),
10806 format_ip46_address, &src, IP46_TYPE_ANY,
10807 format_ip46_address, &dst, IP46_TYPE_ANY,
10808 ntohl (mp->encap_vrf_id),
10809 ntohl (mp->decap_next_index), ntohl (mp->vni),
10810 ntohl (mp->mcast_sw_if_index));
10813 static void vl_api_vxlan_tunnel_details_t_handler_json
10814 (vl_api_vxlan_tunnel_details_t * mp)
10816 vat_main_t *vam = &vat_main;
10817 vat_json_node_t *node = NULL;
10819 if (VAT_JSON_ARRAY != vam->json_tree.type)
10821 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10822 vat_json_init_array (&vam->json_tree);
10824 node = vat_json_array_add (&vam->json_tree);
10826 vat_json_init_object (node);
10827 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10830 struct in6_addr ip6;
10832 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10833 vat_json_object_add_ip6 (node, "src_address", ip6);
10834 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10835 vat_json_object_add_ip6 (node, "dst_address", ip6);
10839 struct in_addr ip4;
10841 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10842 vat_json_object_add_ip4 (node, "src_address", ip4);
10843 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10844 vat_json_object_add_ip4 (node, "dst_address", ip4);
10846 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10847 vat_json_object_add_uint (node, "decap_next_index",
10848 ntohl (mp->decap_next_index));
10849 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10850 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10851 vat_json_object_add_uint (node, "mcast_sw_if_index",
10852 ntohl (mp->mcast_sw_if_index));
10856 api_vxlan_tunnel_dump (vat_main_t * vam)
10858 unformat_input_t *i = vam->input;
10859 vl_api_vxlan_tunnel_dump_t *mp;
10860 vl_api_control_ping_t *mp_ping;
10862 u8 sw_if_index_set = 0;
10865 /* Parse args required to build the message */
10866 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10868 if (unformat (i, "sw_if_index %d", &sw_if_index))
10869 sw_if_index_set = 1;
10874 if (sw_if_index_set == 0)
10879 if (!vam->json_output)
10881 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10882 "sw_if_index", "src_address", "dst_address",
10883 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10886 /* Get list of vxlan-tunnel interfaces */
10887 M (VXLAN_TUNNEL_DUMP, mp);
10889 mp->sw_if_index = htonl (sw_if_index);
10893 /* Use a control ping for synchronization */
10894 M (CONTROL_PING, mp_ping);
10902 api_gre_add_del_tunnel (vat_main_t * vam)
10904 unformat_input_t *line_input = vam->input;
10905 vl_api_gre_add_del_tunnel_t *mp;
10906 ip4_address_t src4, dst4;
10911 u32 outer_fib_id = 0;
10914 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10916 if (unformat (line_input, "del"))
10918 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10920 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10922 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10924 else if (unformat (line_input, "teb"))
10928 errmsg ("parse error '%U'", format_unformat_error, line_input);
10935 errmsg ("tunnel src address not specified");
10940 errmsg ("tunnel dst address not specified");
10945 M (GRE_ADD_DEL_TUNNEL, mp);
10947 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10948 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10949 mp->outer_fib_id = ntohl (outer_fib_id);
10950 mp->is_add = is_add;
10958 static void vl_api_gre_tunnel_details_t_handler
10959 (vl_api_gre_tunnel_details_t * mp)
10961 vat_main_t *vam = &vat_main;
10963 print (vam->ofp, "%11d%15U%15U%6d%14d",
10964 ntohl (mp->sw_if_index),
10965 format_ip4_address, &mp->src_address,
10966 format_ip4_address, &mp->dst_address,
10967 mp->teb, ntohl (mp->outer_fib_id));
10970 static void vl_api_gre_tunnel_details_t_handler_json
10971 (vl_api_gre_tunnel_details_t * mp)
10973 vat_main_t *vam = &vat_main;
10974 vat_json_node_t *node = NULL;
10975 struct in_addr ip4;
10977 if (VAT_JSON_ARRAY != vam->json_tree.type)
10979 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10980 vat_json_init_array (&vam->json_tree);
10982 node = vat_json_array_add (&vam->json_tree);
10984 vat_json_init_object (node);
10985 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10986 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10987 vat_json_object_add_ip4 (node, "src_address", ip4);
10988 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10989 vat_json_object_add_ip4 (node, "dst_address", ip4);
10990 vat_json_object_add_uint (node, "teb", mp->teb);
10991 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10995 api_gre_tunnel_dump (vat_main_t * vam)
10997 unformat_input_t *i = vam->input;
10998 vl_api_gre_tunnel_dump_t *mp;
10999 vl_api_control_ping_t *mp_ping;
11001 u8 sw_if_index_set = 0;
11004 /* Parse args required to build the message */
11005 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11007 if (unformat (i, "sw_if_index %d", &sw_if_index))
11008 sw_if_index_set = 1;
11013 if (sw_if_index_set == 0)
11018 if (!vam->json_output)
11020 print (vam->ofp, "%11s%15s%15s%6s%14s",
11021 "sw_if_index", "src_address", "dst_address", "teb",
11025 /* Get list of gre-tunnel interfaces */
11026 M (GRE_TUNNEL_DUMP, mp);
11028 mp->sw_if_index = htonl (sw_if_index);
11032 /* Use a control ping for synchronization */
11033 M (CONTROL_PING, mp_ping);
11041 api_l2_fib_clear_table (vat_main_t * vam)
11043 // unformat_input_t * i = vam->input;
11044 vl_api_l2_fib_clear_table_t *mp;
11047 M (L2_FIB_CLEAR_TABLE, mp);
11055 api_l2_interface_efp_filter (vat_main_t * vam)
11057 unformat_input_t *i = vam->input;
11058 vl_api_l2_interface_efp_filter_t *mp;
11061 u8 sw_if_index_set = 0;
11064 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11066 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11067 sw_if_index_set = 1;
11068 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11069 sw_if_index_set = 1;
11070 else if (unformat (i, "enable"))
11072 else if (unformat (i, "disable"))
11076 clib_warning ("parse error '%U'", format_unformat_error, i);
11081 if (sw_if_index_set == 0)
11083 errmsg ("missing sw_if_index");
11087 M (L2_INTERFACE_EFP_FILTER, mp);
11089 mp->sw_if_index = ntohl (sw_if_index);
11090 mp->enable_disable = enable;
11097 #define foreach_vtr_op \
11098 _("disable", L2_VTR_DISABLED) \
11099 _("push-1", L2_VTR_PUSH_1) \
11100 _("push-2", L2_VTR_PUSH_2) \
11101 _("pop-1", L2_VTR_POP_1) \
11102 _("pop-2", L2_VTR_POP_2) \
11103 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11104 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11105 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11106 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11109 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11111 unformat_input_t *i = vam->input;
11112 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11114 u8 sw_if_index_set = 0;
11117 u32 push_dot1q = 1;
11122 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11124 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11125 sw_if_index_set = 1;
11126 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11127 sw_if_index_set = 1;
11128 else if (unformat (i, "vtr_op %d", &vtr_op))
11130 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11133 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11135 else if (unformat (i, "tag1 %d", &tag1))
11137 else if (unformat (i, "tag2 %d", &tag2))
11141 clib_warning ("parse error '%U'", format_unformat_error, i);
11146 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11148 errmsg ("missing vtr operation or sw_if_index");
11152 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11153 mp->sw_if_index = ntohl (sw_if_index);
11154 mp->vtr_op = ntohl (vtr_op);
11155 mp->push_dot1q = ntohl (push_dot1q);
11156 mp->tag1 = ntohl (tag1);
11157 mp->tag2 = ntohl (tag2);
11165 api_create_vhost_user_if (vat_main_t * vam)
11167 unformat_input_t *i = vam->input;
11168 vl_api_create_vhost_user_if_t *mp;
11171 u8 file_name_set = 0;
11172 u32 custom_dev_instance = ~0;
11174 u8 use_custom_mac = 0;
11178 /* Shut up coverity */
11179 memset (hwaddr, 0, sizeof (hwaddr));
11181 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11183 if (unformat (i, "socket %s", &file_name))
11187 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11189 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11190 use_custom_mac = 1;
11191 else if (unformat (i, "server"))
11193 else if (unformat (i, "tag %s", &tag))
11199 if (file_name_set == 0)
11201 errmsg ("missing socket file name");
11205 if (vec_len (file_name) > 255)
11207 errmsg ("socket file name too long");
11210 vec_add1 (file_name, 0);
11212 M (CREATE_VHOST_USER_IF, mp);
11214 mp->is_server = is_server;
11215 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11216 vec_free (file_name);
11217 if (custom_dev_instance != ~0)
11220 mp->custom_dev_instance = ntohl (custom_dev_instance);
11222 mp->use_custom_mac = use_custom_mac;
11223 clib_memcpy (mp->mac_address, hwaddr, 6);
11225 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11234 api_modify_vhost_user_if (vat_main_t * vam)
11236 unformat_input_t *i = vam->input;
11237 vl_api_modify_vhost_user_if_t *mp;
11240 u8 file_name_set = 0;
11241 u32 custom_dev_instance = ~0;
11242 u8 sw_if_index_set = 0;
11243 u32 sw_if_index = (u32) ~ 0;
11246 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11248 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11249 sw_if_index_set = 1;
11250 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11251 sw_if_index_set = 1;
11252 else if (unformat (i, "socket %s", &file_name))
11256 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11258 else if (unformat (i, "server"))
11264 if (sw_if_index_set == 0)
11266 errmsg ("missing sw_if_index or interface name");
11270 if (file_name_set == 0)
11272 errmsg ("missing socket file name");
11276 if (vec_len (file_name) > 255)
11278 errmsg ("socket file name too long");
11281 vec_add1 (file_name, 0);
11283 M (MODIFY_VHOST_USER_IF, mp);
11285 mp->sw_if_index = ntohl (sw_if_index);
11286 mp->is_server = is_server;
11287 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11288 vec_free (file_name);
11289 if (custom_dev_instance != ~0)
11292 mp->custom_dev_instance = ntohl (custom_dev_instance);
11301 api_delete_vhost_user_if (vat_main_t * vam)
11303 unformat_input_t *i = vam->input;
11304 vl_api_delete_vhost_user_if_t *mp;
11305 u32 sw_if_index = ~0;
11306 u8 sw_if_index_set = 0;
11309 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11311 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11312 sw_if_index_set = 1;
11313 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11314 sw_if_index_set = 1;
11319 if (sw_if_index_set == 0)
11321 errmsg ("missing sw_if_index or interface name");
11326 M (DELETE_VHOST_USER_IF, mp);
11328 mp->sw_if_index = ntohl (sw_if_index);
11335 static void vl_api_sw_interface_vhost_user_details_t_handler
11336 (vl_api_sw_interface_vhost_user_details_t * mp)
11338 vat_main_t *vam = &vat_main;
11340 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11341 (char *) mp->interface_name,
11342 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11343 clib_net_to_host_u64 (mp->features), mp->is_server,
11344 ntohl (mp->num_regions), (char *) mp->sock_filename);
11345 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11348 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11349 (vl_api_sw_interface_vhost_user_details_t * mp)
11351 vat_main_t *vam = &vat_main;
11352 vat_json_node_t *node = NULL;
11354 if (VAT_JSON_ARRAY != vam->json_tree.type)
11356 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11357 vat_json_init_array (&vam->json_tree);
11359 node = vat_json_array_add (&vam->json_tree);
11361 vat_json_init_object (node);
11362 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11363 vat_json_object_add_string_copy (node, "interface_name",
11364 mp->interface_name);
11365 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11366 ntohl (mp->virtio_net_hdr_sz));
11367 vat_json_object_add_uint (node, "features",
11368 clib_net_to_host_u64 (mp->features));
11369 vat_json_object_add_uint (node, "is_server", mp->is_server);
11370 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11371 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11372 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11376 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11378 vl_api_sw_interface_vhost_user_dump_t *mp;
11379 vl_api_control_ping_t *mp_ping;
11382 "Interface name idx hdr_sz features server regions filename");
11384 /* Get list of vhost-user interfaces */
11385 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11388 /* Use a control ping for synchronization */
11389 M (CONTROL_PING, mp_ping);
11397 api_show_version (vat_main_t * vam)
11399 vl_api_show_version_t *mp;
11402 M (SHOW_VERSION, mp);
11411 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11413 unformat_input_t *line_input = vam->input;
11414 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11415 ip4_address_t local4, remote4;
11416 ip6_address_t local6, remote6;
11418 u8 ipv4_set = 0, ipv6_set = 0;
11421 u32 encap_vrf_id = 0;
11422 u32 decap_vrf_id = 0;
11428 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11430 if (unformat (line_input, "del"))
11432 else if (unformat (line_input, "local %U",
11433 unformat_ip4_address, &local4))
11438 else if (unformat (line_input, "remote %U",
11439 unformat_ip4_address, &remote4))
11444 else if (unformat (line_input, "local %U",
11445 unformat_ip6_address, &local6))
11450 else if (unformat (line_input, "remote %U",
11451 unformat_ip6_address, &remote6))
11456 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11458 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11460 else if (unformat (line_input, "vni %d", &vni))
11462 else if (unformat (line_input, "next-ip4"))
11464 else if (unformat (line_input, "next-ip6"))
11466 else if (unformat (line_input, "next-ethernet"))
11468 else if (unformat (line_input, "next-nsh"))
11472 errmsg ("parse error '%U'", format_unformat_error, line_input);
11477 if (local_set == 0)
11479 errmsg ("tunnel local address not specified");
11482 if (remote_set == 0)
11484 errmsg ("tunnel remote address not specified");
11487 if (ipv4_set && ipv6_set)
11489 errmsg ("both IPv4 and IPv6 addresses specified");
11495 errmsg ("vni not specified");
11499 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11504 clib_memcpy (&mp->local, &local6, sizeof (local6));
11505 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11509 clib_memcpy (&mp->local, &local4, sizeof (local4));
11510 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11513 mp->encap_vrf_id = ntohl (encap_vrf_id);
11514 mp->decap_vrf_id = ntohl (decap_vrf_id);
11515 mp->protocol = protocol;
11516 mp->vni = ntohl (vni);
11517 mp->is_add = is_add;
11518 mp->is_ipv6 = ipv6_set;
11525 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11526 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11528 vat_main_t *vam = &vat_main;
11530 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11531 ntohl (mp->sw_if_index),
11532 format_ip46_address, &(mp->local[0]),
11533 format_ip46_address, &(mp->remote[0]),
11535 ntohl (mp->protocol),
11536 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11539 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11540 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11542 vat_main_t *vam = &vat_main;
11543 vat_json_node_t *node = NULL;
11544 struct in_addr ip4;
11545 struct in6_addr ip6;
11547 if (VAT_JSON_ARRAY != vam->json_tree.type)
11549 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11550 vat_json_init_array (&vam->json_tree);
11552 node = vat_json_array_add (&vam->json_tree);
11554 vat_json_init_object (node);
11555 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11558 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11559 vat_json_object_add_ip6 (node, "local", ip6);
11560 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11561 vat_json_object_add_ip6 (node, "remote", ip6);
11565 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11566 vat_json_object_add_ip4 (node, "local", ip4);
11567 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11568 vat_json_object_add_ip4 (node, "remote", ip4);
11570 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11571 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11572 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11573 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11574 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11578 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11580 unformat_input_t *i = vam->input;
11581 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11582 vl_api_control_ping_t *mp_ping;
11584 u8 sw_if_index_set = 0;
11587 /* Parse args required to build the message */
11588 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11590 if (unformat (i, "sw_if_index %d", &sw_if_index))
11591 sw_if_index_set = 1;
11596 if (sw_if_index_set == 0)
11601 if (!vam->json_output)
11603 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11604 "sw_if_index", "local", "remote", "vni",
11605 "protocol", "encap_vrf_id", "decap_vrf_id");
11608 /* Get list of vxlan-tunnel interfaces */
11609 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11611 mp->sw_if_index = htonl (sw_if_index);
11615 /* Use a control ping for synchronization */
11616 M (CONTROL_PING, mp_ping);
11624 format_l2_fib_mac_address (u8 * s, va_list * args)
11626 u8 *a = va_arg (*args, u8 *);
11628 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11629 a[2], a[3], a[4], a[5], a[6], a[7]);
11632 static void vl_api_l2_fib_table_entry_t_handler
11633 (vl_api_l2_fib_table_entry_t * mp)
11635 vat_main_t *vam = &vat_main;
11637 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11639 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11640 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11644 static void vl_api_l2_fib_table_entry_t_handler_json
11645 (vl_api_l2_fib_table_entry_t * mp)
11647 vat_main_t *vam = &vat_main;
11648 vat_json_node_t *node = NULL;
11650 if (VAT_JSON_ARRAY != vam->json_tree.type)
11652 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11653 vat_json_init_array (&vam->json_tree);
11655 node = vat_json_array_add (&vam->json_tree);
11657 vat_json_init_object (node);
11658 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11659 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11660 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11661 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11662 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11663 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11667 api_l2_fib_table_dump (vat_main_t * vam)
11669 unformat_input_t *i = vam->input;
11670 vl_api_l2_fib_table_dump_t *mp;
11671 vl_api_control_ping_t *mp_ping;
11676 /* Parse args required to build the message */
11677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11679 if (unformat (i, "bd_id %d", &bd_id))
11685 if (bd_id_set == 0)
11687 errmsg ("missing bridge domain");
11691 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11693 /* Get list of l2 fib entries */
11694 M (L2_FIB_TABLE_DUMP, mp);
11696 mp->bd_id = ntohl (bd_id);
11699 /* Use a control ping for synchronization */
11700 M (CONTROL_PING, mp_ping);
11709 api_interface_name_renumber (vat_main_t * vam)
11711 unformat_input_t *line_input = vam->input;
11712 vl_api_interface_name_renumber_t *mp;
11713 u32 sw_if_index = ~0;
11714 u32 new_show_dev_instance = ~0;
11717 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11719 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11722 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11724 else if (unformat (line_input, "new_show_dev_instance %d",
11725 &new_show_dev_instance))
11731 if (sw_if_index == ~0)
11733 errmsg ("missing interface name or sw_if_index");
11737 if (new_show_dev_instance == ~0)
11739 errmsg ("missing new_show_dev_instance");
11743 M (INTERFACE_NAME_RENUMBER, mp);
11745 mp->sw_if_index = ntohl (sw_if_index);
11746 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11754 api_want_ip4_arp_events (vat_main_t * vam)
11756 unformat_input_t *line_input = vam->input;
11757 vl_api_want_ip4_arp_events_t *mp;
11758 ip4_address_t address;
11759 int address_set = 0;
11760 u32 enable_disable = 1;
11763 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11765 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11767 else if (unformat (line_input, "del"))
11768 enable_disable = 0;
11773 if (address_set == 0)
11775 errmsg ("missing addresses");
11779 M (WANT_IP4_ARP_EVENTS, mp);
11780 mp->enable_disable = enable_disable;
11781 mp->pid = getpid ();
11782 mp->address = address.as_u32;
11790 api_want_ip6_nd_events (vat_main_t * vam)
11792 unformat_input_t *line_input = vam->input;
11793 vl_api_want_ip6_nd_events_t *mp;
11794 ip6_address_t address;
11795 int address_set = 0;
11796 u32 enable_disable = 1;
11799 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11801 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11803 else if (unformat (line_input, "del"))
11804 enable_disable = 0;
11809 if (address_set == 0)
11811 errmsg ("missing addresses");
11815 M (WANT_IP6_ND_EVENTS, mp);
11816 mp->enable_disable = enable_disable;
11817 mp->pid = getpid ();
11818 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11826 api_input_acl_set_interface (vat_main_t * vam)
11828 unformat_input_t *i = vam->input;
11829 vl_api_input_acl_set_interface_t *mp;
11831 int sw_if_index_set;
11832 u32 ip4_table_index = ~0;
11833 u32 ip6_table_index = ~0;
11834 u32 l2_table_index = ~0;
11838 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11840 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11841 sw_if_index_set = 1;
11842 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11843 sw_if_index_set = 1;
11844 else if (unformat (i, "del"))
11846 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11848 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11850 else if (unformat (i, "l2-table %d", &l2_table_index))
11854 clib_warning ("parse error '%U'", format_unformat_error, i);
11859 if (sw_if_index_set == 0)
11861 errmsg ("missing interface name or sw_if_index");
11865 M (INPUT_ACL_SET_INTERFACE, mp);
11867 mp->sw_if_index = ntohl (sw_if_index);
11868 mp->ip4_table_index = ntohl (ip4_table_index);
11869 mp->ip6_table_index = ntohl (ip6_table_index);
11870 mp->l2_table_index = ntohl (l2_table_index);
11871 mp->is_add = is_add;
11879 api_ip_address_dump (vat_main_t * vam)
11881 unformat_input_t *i = vam->input;
11882 vl_api_ip_address_dump_t *mp;
11883 vl_api_control_ping_t *mp_ping;
11884 u32 sw_if_index = ~0;
11885 u8 sw_if_index_set = 0;
11890 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11892 if (unformat (i, "sw_if_index %d", &sw_if_index))
11893 sw_if_index_set = 1;
11895 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11896 sw_if_index_set = 1;
11897 else if (unformat (i, "ipv4"))
11899 else if (unformat (i, "ipv6"))
11905 if (ipv4_set && ipv6_set)
11907 errmsg ("ipv4 and ipv6 flags cannot be both set");
11911 if ((!ipv4_set) && (!ipv6_set))
11913 errmsg ("no ipv4 nor ipv6 flag set");
11917 if (sw_if_index_set == 0)
11919 errmsg ("missing interface name or sw_if_index");
11923 vam->current_sw_if_index = sw_if_index;
11924 vam->is_ipv6 = ipv6_set;
11926 M (IP_ADDRESS_DUMP, mp);
11927 mp->sw_if_index = ntohl (sw_if_index);
11928 mp->is_ipv6 = ipv6_set;
11931 /* Use a control ping for synchronization */
11932 M (CONTROL_PING, mp_ping);
11940 api_ip_dump (vat_main_t * vam)
11942 vl_api_ip_dump_t *mp;
11943 vl_api_control_ping_t *mp_ping;
11944 unformat_input_t *in = vam->input;
11951 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11953 if (unformat (in, "ipv4"))
11955 else if (unformat (in, "ipv6"))
11961 if (ipv4_set && ipv6_set)
11963 errmsg ("ipv4 and ipv6 flags cannot be both set");
11967 if ((!ipv4_set) && (!ipv6_set))
11969 errmsg ("no ipv4 nor ipv6 flag set");
11973 is_ipv6 = ipv6_set;
11974 vam->is_ipv6 = is_ipv6;
11976 /* free old data */
11977 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11979 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11981 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11984 mp->is_ipv6 = ipv6_set;
11987 /* Use a control ping for synchronization */
11988 M (CONTROL_PING, mp_ping);
11996 api_ipsec_spd_add_del (vat_main_t * vam)
11998 unformat_input_t *i = vam->input;
11999 vl_api_ipsec_spd_add_del_t *mp;
12004 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12006 if (unformat (i, "spd_id %d", &spd_id))
12008 else if (unformat (i, "del"))
12012 clib_warning ("parse error '%U'", format_unformat_error, i);
12018 errmsg ("spd_id must be set");
12022 M (IPSEC_SPD_ADD_DEL, mp);
12024 mp->spd_id = ntohl (spd_id);
12025 mp->is_add = is_add;
12033 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12035 unformat_input_t *i = vam->input;
12036 vl_api_ipsec_interface_add_del_spd_t *mp;
12038 u8 sw_if_index_set = 0;
12039 u32 spd_id = (u32) ~ 0;
12043 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12045 if (unformat (i, "del"))
12047 else if (unformat (i, "spd_id %d", &spd_id))
12050 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12051 sw_if_index_set = 1;
12052 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12053 sw_if_index_set = 1;
12056 clib_warning ("parse error '%U'", format_unformat_error, i);
12062 if (spd_id == (u32) ~ 0)
12064 errmsg ("spd_id must be set");
12068 if (sw_if_index_set == 0)
12070 errmsg ("missing interface name or sw_if_index");
12074 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12076 mp->spd_id = ntohl (spd_id);
12077 mp->sw_if_index = ntohl (sw_if_index);
12078 mp->is_add = is_add;
12086 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12088 unformat_input_t *i = vam->input;
12089 vl_api_ipsec_spd_add_del_entry_t *mp;
12090 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12091 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12093 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12094 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12095 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12096 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12099 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12100 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12101 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12102 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12103 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12104 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12106 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12108 if (unformat (i, "del"))
12110 if (unformat (i, "outbound"))
12112 if (unformat (i, "inbound"))
12114 else if (unformat (i, "spd_id %d", &spd_id))
12116 else if (unformat (i, "sa_id %d", &sa_id))
12118 else if (unformat (i, "priority %d", &priority))
12120 else if (unformat (i, "protocol %d", &protocol))
12122 else if (unformat (i, "lport_start %d", &lport_start))
12124 else if (unformat (i, "lport_stop %d", &lport_stop))
12126 else if (unformat (i, "rport_start %d", &rport_start))
12128 else if (unformat (i, "rport_stop %d", &rport_stop))
12132 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12138 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12145 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12151 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12158 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12164 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12171 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12177 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12183 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12185 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12187 clib_warning ("unsupported action: 'resolve'");
12193 clib_warning ("parse error '%U'", format_unformat_error, i);
12199 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12201 mp->spd_id = ntohl (spd_id);
12202 mp->priority = ntohl (priority);
12203 mp->is_outbound = is_outbound;
12205 mp->is_ipv6 = is_ipv6;
12206 if (is_ipv6 || is_ip_any)
12208 clib_memcpy (mp->remote_address_start, &raddr6_start,
12209 sizeof (ip6_address_t));
12210 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12211 sizeof (ip6_address_t));
12212 clib_memcpy (mp->local_address_start, &laddr6_start,
12213 sizeof (ip6_address_t));
12214 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12215 sizeof (ip6_address_t));
12219 clib_memcpy (mp->remote_address_start, &raddr4_start,
12220 sizeof (ip4_address_t));
12221 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12222 sizeof (ip4_address_t));
12223 clib_memcpy (mp->local_address_start, &laddr4_start,
12224 sizeof (ip4_address_t));
12225 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12226 sizeof (ip4_address_t));
12228 mp->protocol = (u8) protocol;
12229 mp->local_port_start = ntohs ((u16) lport_start);
12230 mp->local_port_stop = ntohs ((u16) lport_stop);
12231 mp->remote_port_start = ntohs ((u16) rport_start);
12232 mp->remote_port_stop = ntohs ((u16) rport_stop);
12233 mp->policy = (u8) policy;
12234 mp->sa_id = ntohl (sa_id);
12235 mp->is_add = is_add;
12236 mp->is_ip_any = is_ip_any;
12243 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12245 unformat_input_t *i = vam->input;
12246 vl_api_ipsec_sad_add_del_entry_t *mp;
12247 u32 sad_id = 0, spi = 0;
12248 u8 *ck = 0, *ik = 0;
12251 u8 protocol = IPSEC_PROTOCOL_AH;
12252 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12253 u32 crypto_alg = 0, integ_alg = 0;
12254 ip4_address_t tun_src4;
12255 ip4_address_t tun_dst4;
12256 ip6_address_t tun_src6;
12257 ip6_address_t tun_dst6;
12260 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12262 if (unformat (i, "del"))
12264 else if (unformat (i, "sad_id %d", &sad_id))
12266 else if (unformat (i, "spi %d", &spi))
12268 else if (unformat (i, "esp"))
12269 protocol = IPSEC_PROTOCOL_ESP;
12270 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12273 is_tunnel_ipv6 = 0;
12275 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12278 is_tunnel_ipv6 = 0;
12280 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12283 is_tunnel_ipv6 = 1;
12285 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12288 is_tunnel_ipv6 = 1;
12292 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12294 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12295 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12297 clib_warning ("unsupported crypto-alg: '%U'",
12298 format_ipsec_crypto_alg, crypto_alg);
12302 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12306 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12308 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12309 integ_alg >= IPSEC_INTEG_N_ALG)
12311 clib_warning ("unsupported integ-alg: '%U'",
12312 format_ipsec_integ_alg, integ_alg);
12316 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12320 clib_warning ("parse error '%U'", format_unformat_error, i);
12326 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12328 mp->sad_id = ntohl (sad_id);
12329 mp->is_add = is_add;
12330 mp->protocol = protocol;
12331 mp->spi = ntohl (spi);
12332 mp->is_tunnel = is_tunnel;
12333 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12334 mp->crypto_algorithm = crypto_alg;
12335 mp->integrity_algorithm = integ_alg;
12336 mp->crypto_key_length = vec_len (ck);
12337 mp->integrity_key_length = vec_len (ik);
12339 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12340 mp->crypto_key_length = sizeof (mp->crypto_key);
12342 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12343 mp->integrity_key_length = sizeof (mp->integrity_key);
12346 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12348 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12352 if (is_tunnel_ipv6)
12354 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12355 sizeof (ip6_address_t));
12356 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12357 sizeof (ip6_address_t));
12361 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12362 sizeof (ip4_address_t));
12363 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12364 sizeof (ip4_address_t));
12374 api_ipsec_sa_set_key (vat_main_t * vam)
12376 unformat_input_t *i = vam->input;
12377 vl_api_ipsec_sa_set_key_t *mp;
12379 u8 *ck = 0, *ik = 0;
12382 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12384 if (unformat (i, "sa_id %d", &sa_id))
12386 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12388 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12392 clib_warning ("parse error '%U'", format_unformat_error, i);
12397 M (IPSEC_SA_SET_KEY, mp);
12399 mp->sa_id = ntohl (sa_id);
12400 mp->crypto_key_length = vec_len (ck);
12401 mp->integrity_key_length = vec_len (ik);
12403 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12404 mp->crypto_key_length = sizeof (mp->crypto_key);
12406 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12407 mp->integrity_key_length = sizeof (mp->integrity_key);
12410 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12412 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12420 api_ikev2_profile_add_del (vat_main_t * vam)
12422 unformat_input_t *i = vam->input;
12423 vl_api_ikev2_profile_add_del_t *mp;
12428 const char *valid_chars = "a-zA-Z0-9_";
12430 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12432 if (unformat (i, "del"))
12434 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12435 vec_add1 (name, 0);
12438 errmsg ("parse error '%U'", format_unformat_error, i);
12443 if (!vec_len (name))
12445 errmsg ("profile name must be specified");
12449 if (vec_len (name) > 64)
12451 errmsg ("profile name too long");
12455 M (IKEV2_PROFILE_ADD_DEL, mp);
12457 clib_memcpy (mp->name, name, vec_len (name));
12458 mp->is_add = is_add;
12467 api_ikev2_profile_set_auth (vat_main_t * vam)
12469 unformat_input_t *i = vam->input;
12470 vl_api_ikev2_profile_set_auth_t *mp;
12473 u32 auth_method = 0;
12477 const char *valid_chars = "a-zA-Z0-9_";
12479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12481 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12482 vec_add1 (name, 0);
12483 else if (unformat (i, "auth_method %U",
12484 unformat_ikev2_auth_method, &auth_method))
12486 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12488 else if (unformat (i, "auth_data %v", &data))
12492 errmsg ("parse error '%U'", format_unformat_error, i);
12497 if (!vec_len (name))
12499 errmsg ("profile name must be specified");
12503 if (vec_len (name) > 64)
12505 errmsg ("profile name too long");
12509 if (!vec_len (data))
12511 errmsg ("auth_data must be specified");
12517 errmsg ("auth_method must be specified");
12521 M (IKEV2_PROFILE_SET_AUTH, mp);
12523 mp->is_hex = is_hex;
12524 mp->auth_method = (u8) auth_method;
12525 mp->data_len = vec_len (data);
12526 clib_memcpy (mp->name, name, vec_len (name));
12527 clib_memcpy (mp->data, data, vec_len (data));
12537 api_ikev2_profile_set_id (vat_main_t * vam)
12539 unformat_input_t *i = vam->input;
12540 vl_api_ikev2_profile_set_id_t *mp;
12548 const char *valid_chars = "a-zA-Z0-9_";
12550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12552 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12553 vec_add1 (name, 0);
12554 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12556 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12558 data = vec_new (u8, 4);
12559 clib_memcpy (data, ip4.as_u8, 4);
12561 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12563 else if (unformat (i, "id_data %v", &data))
12565 else if (unformat (i, "local"))
12567 else if (unformat (i, "remote"))
12571 errmsg ("parse error '%U'", format_unformat_error, i);
12576 if (!vec_len (name))
12578 errmsg ("profile name must be specified");
12582 if (vec_len (name) > 64)
12584 errmsg ("profile name too long");
12588 if (!vec_len (data))
12590 errmsg ("id_data must be specified");
12596 errmsg ("id_type must be specified");
12600 M (IKEV2_PROFILE_SET_ID, mp);
12602 mp->is_local = is_local;
12603 mp->id_type = (u8) id_type;
12604 mp->data_len = vec_len (data);
12605 clib_memcpy (mp->name, name, vec_len (name));
12606 clib_memcpy (mp->data, data, vec_len (data));
12616 api_ikev2_profile_set_ts (vat_main_t * vam)
12618 unformat_input_t *i = vam->input;
12619 vl_api_ikev2_profile_set_ts_t *mp;
12622 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12623 ip4_address_t start_addr, end_addr;
12625 const char *valid_chars = "a-zA-Z0-9_";
12628 start_addr.as_u32 = 0;
12629 end_addr.as_u32 = (u32) ~ 0;
12631 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12633 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12634 vec_add1 (name, 0);
12635 else if (unformat (i, "protocol %d", &proto))
12637 else if (unformat (i, "start_port %d", &start_port))
12639 else if (unformat (i, "end_port %d", &end_port))
12642 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12644 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12646 else if (unformat (i, "local"))
12648 else if (unformat (i, "remote"))
12652 errmsg ("parse error '%U'", format_unformat_error, i);
12657 if (!vec_len (name))
12659 errmsg ("profile name must be specified");
12663 if (vec_len (name) > 64)
12665 errmsg ("profile name too long");
12669 M (IKEV2_PROFILE_SET_TS, mp);
12671 mp->is_local = is_local;
12672 mp->proto = (u8) proto;
12673 mp->start_port = (u16) start_port;
12674 mp->end_port = (u16) end_port;
12675 mp->start_addr = start_addr.as_u32;
12676 mp->end_addr = end_addr.as_u32;
12677 clib_memcpy (mp->name, name, vec_len (name));
12686 api_ikev2_set_local_key (vat_main_t * vam)
12688 unformat_input_t *i = vam->input;
12689 vl_api_ikev2_set_local_key_t *mp;
12693 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12695 if (unformat (i, "file %v", &file))
12696 vec_add1 (file, 0);
12699 errmsg ("parse error '%U'", format_unformat_error, i);
12704 if (!vec_len (file))
12706 errmsg ("RSA key file must be specified");
12710 if (vec_len (file) > 256)
12712 errmsg ("file name too long");
12716 M (IKEV2_SET_LOCAL_KEY, mp);
12718 clib_memcpy (mp->key_file, file, vec_len (file));
12727 api_ikev2_set_responder (vat_main_t * vam)
12729 unformat_input_t *i = vam->input;
12730 vl_api_ikev2_set_responder_t *mp;
12733 u32 sw_if_index = ~0;
12734 ip4_address_t address;
12736 const char *valid_chars = "a-zA-Z0-9_";
12738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12741 (i, "%U interface %d address %U", unformat_token, valid_chars,
12742 &name, &sw_if_index, unformat_ip4_address, &address))
12743 vec_add1 (name, 0);
12746 errmsg ("parse error '%U'", format_unformat_error, i);
12751 if (!vec_len (name))
12753 errmsg ("profile name must be specified");
12757 if (vec_len (name) > 64)
12759 errmsg ("profile name too long");
12763 M (IKEV2_SET_RESPONDER, mp);
12765 clib_memcpy (mp->name, name, vec_len (name));
12768 mp->sw_if_index = sw_if_index;
12769 clib_memcpy (mp->address, &address, sizeof (address));
12777 api_ikev2_set_ike_transforms (vat_main_t * vam)
12779 unformat_input_t *i = vam->input;
12780 vl_api_ikev2_set_ike_transforms_t *mp;
12783 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12785 const char *valid_chars = "a-zA-Z0-9_";
12787 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12789 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12790 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12791 vec_add1 (name, 0);
12794 errmsg ("parse error '%U'", format_unformat_error, i);
12799 if (!vec_len (name))
12801 errmsg ("profile name must be specified");
12805 if (vec_len (name) > 64)
12807 errmsg ("profile name too long");
12811 M (IKEV2_SET_IKE_TRANSFORMS, mp);
12813 clib_memcpy (mp->name, name, vec_len (name));
12815 mp->crypto_alg = crypto_alg;
12816 mp->crypto_key_size = crypto_key_size;
12817 mp->integ_alg = integ_alg;
12818 mp->dh_group = dh_group;
12827 api_ikev2_set_esp_transforms (vat_main_t * vam)
12829 unformat_input_t *i = vam->input;
12830 vl_api_ikev2_set_esp_transforms_t *mp;
12833 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12835 const char *valid_chars = "a-zA-Z0-9_";
12837 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12839 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12840 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12841 vec_add1 (name, 0);
12844 errmsg ("parse error '%U'", format_unformat_error, i);
12849 if (!vec_len (name))
12851 errmsg ("profile name must be specified");
12855 if (vec_len (name) > 64)
12857 errmsg ("profile name too long");
12861 M (IKEV2_SET_ESP_TRANSFORMS, mp);
12863 clib_memcpy (mp->name, name, vec_len (name));
12865 mp->crypto_alg = crypto_alg;
12866 mp->crypto_key_size = crypto_key_size;
12867 mp->integ_alg = integ_alg;
12868 mp->dh_group = dh_group;
12876 api_ikev2_set_sa_lifetime (vat_main_t * vam)
12878 unformat_input_t *i = vam->input;
12879 vl_api_ikev2_set_sa_lifetime_t *mp;
12882 u64 lifetime, lifetime_maxdata;
12883 u32 lifetime_jitter, handover;
12885 const char *valid_chars = "a-zA-Z0-9_";
12887 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12889 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
12890 &lifetime, &lifetime_jitter, &handover,
12891 &lifetime_maxdata))
12892 vec_add1 (name, 0);
12895 errmsg ("parse error '%U'", format_unformat_error, i);
12900 if (!vec_len (name))
12902 errmsg ("profile name must be specified");
12906 if (vec_len (name) > 64)
12908 errmsg ("profile name too long");
12912 M (IKEV2_SET_SA_LIFETIME, mp);
12914 clib_memcpy (mp->name, name, vec_len (name));
12916 mp->lifetime = lifetime;
12917 mp->lifetime_jitter = lifetime_jitter;
12918 mp->handover = handover;
12919 mp->lifetime_maxdata = lifetime_maxdata;
12927 api_ikev2_initiate_sa_init (vat_main_t * vam)
12929 unformat_input_t *i = vam->input;
12930 vl_api_ikev2_initiate_sa_init_t *mp;
12934 const char *valid_chars = "a-zA-Z0-9_";
12936 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12938 if (unformat (i, "%U", unformat_token, valid_chars, &name))
12939 vec_add1 (name, 0);
12942 errmsg ("parse error '%U'", format_unformat_error, i);
12947 if (!vec_len (name))
12949 errmsg ("profile name must be specified");
12953 if (vec_len (name) > 64)
12955 errmsg ("profile name too long");
12959 M (IKEV2_INITIATE_SA_INIT, mp);
12961 clib_memcpy (mp->name, name, vec_len (name));
12970 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
12972 unformat_input_t *i = vam->input;
12973 vl_api_ikev2_initiate_del_ike_sa_t *mp;
12978 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12980 if (unformat (i, "%lx", &ispi))
12984 errmsg ("parse error '%U'", format_unformat_error, i);
12989 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
12999 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13001 unformat_input_t *i = vam->input;
13002 vl_api_ikev2_initiate_del_child_sa_t *mp;
13007 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13009 if (unformat (i, "%x", &ispi))
13013 errmsg ("parse error '%U'", format_unformat_error, i);
13018 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13028 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13030 unformat_input_t *i = vam->input;
13031 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13036 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13038 if (unformat (i, "%x", &ispi))
13042 errmsg ("parse error '%U'", format_unformat_error, i);
13047 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
13060 api_map_add_domain (vat_main_t * vam)
13062 unformat_input_t *i = vam->input;
13063 vl_api_map_add_domain_t *mp;
13065 ip4_address_t ip4_prefix;
13066 ip6_address_t ip6_prefix;
13067 ip6_address_t ip6_src;
13068 u32 num_m_args = 0;
13069 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
13070 0, psid_length = 0;
13071 u8 is_translation = 0;
13073 u32 ip6_src_len = 128;
13076 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13078 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
13079 &ip4_prefix, &ip4_prefix_len))
13081 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
13082 &ip6_prefix, &ip6_prefix_len))
13086 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
13089 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
13091 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
13093 else if (unformat (i, "psid-offset %d", &psid_offset))
13095 else if (unformat (i, "psid-len %d", &psid_length))
13097 else if (unformat (i, "mtu %d", &mtu))
13099 else if (unformat (i, "map-t"))
13100 is_translation = 1;
13103 clib_warning ("parse error '%U'", format_unformat_error, i);
13108 if (num_m_args < 3)
13110 errmsg ("mandatory argument(s) missing");
13114 /* Construct the API message */
13115 M (MAP_ADD_DOMAIN, mp);
13117 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
13118 mp->ip4_prefix_len = ip4_prefix_len;
13120 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
13121 mp->ip6_prefix_len = ip6_prefix_len;
13123 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
13124 mp->ip6_src_prefix_len = ip6_src_len;
13126 mp->ea_bits_len = ea_bits_len;
13127 mp->psid_offset = psid_offset;
13128 mp->psid_length = psid_length;
13129 mp->is_translation = is_translation;
13130 mp->mtu = htons (mtu);
13135 /* Wait for a reply, return good/bad news */
13141 api_map_del_domain (vat_main_t * vam)
13143 unformat_input_t *i = vam->input;
13144 vl_api_map_del_domain_t *mp;
13146 u32 num_m_args = 0;
13150 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13152 if (unformat (i, "index %d", &index))
13156 clib_warning ("parse error '%U'", format_unformat_error, i);
13161 if (num_m_args != 1)
13163 errmsg ("mandatory argument(s) missing");
13167 /* Construct the API message */
13168 M (MAP_DEL_DOMAIN, mp);
13170 mp->index = ntohl (index);
13175 /* Wait for a reply, return good/bad news */
13181 api_map_add_del_rule (vat_main_t * vam)
13183 unformat_input_t *i = vam->input;
13184 vl_api_map_add_del_rule_t *mp;
13186 ip6_address_t ip6_dst;
13187 u32 num_m_args = 0, index, psid = 0;
13190 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13192 if (unformat (i, "index %d", &index))
13194 else if (unformat (i, "psid %d", &psid))
13196 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13198 else if (unformat (i, "del"))
13204 clib_warning ("parse error '%U'", format_unformat_error, i);
13209 /* Construct the API message */
13210 M (MAP_ADD_DEL_RULE, mp);
13212 mp->index = ntohl (index);
13213 mp->is_add = is_add;
13214 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13215 mp->psid = ntohs (psid);
13220 /* Wait for a reply, return good/bad news */
13226 api_map_domain_dump (vat_main_t * vam)
13228 vl_api_map_domain_dump_t *mp;
13229 vl_api_control_ping_t *mp_ping;
13232 /* Construct the API message */
13233 M (MAP_DOMAIN_DUMP, mp);
13238 /* Use a control ping for synchronization */
13239 M (CONTROL_PING, mp_ping);
13247 api_map_rule_dump (vat_main_t * vam)
13249 unformat_input_t *i = vam->input;
13250 vl_api_map_rule_dump_t *mp;
13251 vl_api_control_ping_t *mp_ping;
13252 u32 domain_index = ~0;
13255 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13257 if (unformat (i, "index %u", &domain_index))
13263 if (domain_index == ~0)
13265 clib_warning ("parse error: domain index expected");
13269 /* Construct the API message */
13270 M (MAP_RULE_DUMP, mp);
13272 mp->domain_index = htonl (domain_index);
13277 /* Use a control ping for synchronization */
13278 M (CONTROL_PING, mp_ping);
13285 static void vl_api_map_add_domain_reply_t_handler
13286 (vl_api_map_add_domain_reply_t * mp)
13288 vat_main_t *vam = &vat_main;
13289 i32 retval = ntohl (mp->retval);
13291 if (vam->async_mode)
13293 vam->async_errors += (retval < 0);
13297 vam->retval = retval;
13298 vam->result_ready = 1;
13302 static void vl_api_map_add_domain_reply_t_handler_json
13303 (vl_api_map_add_domain_reply_t * mp)
13305 vat_main_t *vam = &vat_main;
13306 vat_json_node_t node;
13308 vat_json_init_object (&node);
13309 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13310 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13312 vat_json_print (vam->ofp, &node);
13313 vat_json_free (&node);
13315 vam->retval = ntohl (mp->retval);
13316 vam->result_ready = 1;
13320 api_get_first_msg_id (vat_main_t * vam)
13322 vl_api_get_first_msg_id_t *mp;
13323 unformat_input_t *i = vam->input;
13328 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13330 if (unformat (i, "client %s", &name))
13338 errmsg ("missing client name");
13341 vec_add1 (name, 0);
13343 if (vec_len (name) > 63)
13345 errmsg ("client name too long");
13349 M (GET_FIRST_MSG_ID, mp);
13350 clib_memcpy (mp->name, name, vec_len (name));
13357 api_cop_interface_enable_disable (vat_main_t * vam)
13359 unformat_input_t *line_input = vam->input;
13360 vl_api_cop_interface_enable_disable_t *mp;
13361 u32 sw_if_index = ~0;
13362 u8 enable_disable = 1;
13365 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13367 if (unformat (line_input, "disable"))
13368 enable_disable = 0;
13369 if (unformat (line_input, "enable"))
13370 enable_disable = 1;
13371 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13372 vam, &sw_if_index))
13374 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13380 if (sw_if_index == ~0)
13382 errmsg ("missing interface name or sw_if_index");
13386 /* Construct the API message */
13387 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13388 mp->sw_if_index = ntohl (sw_if_index);
13389 mp->enable_disable = enable_disable;
13393 /* Wait for the reply */
13399 api_cop_whitelist_enable_disable (vat_main_t * vam)
13401 unformat_input_t *line_input = vam->input;
13402 vl_api_cop_whitelist_enable_disable_t *mp;
13403 u32 sw_if_index = ~0;
13404 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13408 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13410 if (unformat (line_input, "ip4"))
13412 else if (unformat (line_input, "ip6"))
13414 else if (unformat (line_input, "default"))
13416 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13417 vam, &sw_if_index))
13419 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13421 else if (unformat (line_input, "fib-id %d", &fib_id))
13427 if (sw_if_index == ~0)
13429 errmsg ("missing interface name or sw_if_index");
13433 /* Construct the API message */
13434 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13435 mp->sw_if_index = ntohl (sw_if_index);
13436 mp->fib_id = ntohl (fib_id);
13439 mp->default_cop = default_cop;
13443 /* Wait for the reply */
13449 api_get_node_graph (vat_main_t * vam)
13451 vl_api_get_node_graph_t *mp;
13454 M (GET_NODE_GRAPH, mp);
13458 /* Wait for the reply */
13464 /** Used for parsing LISP eids */
13465 typedef CLIB_PACKED(struct{
13466 u8 addr[16]; /**< eid address */
13467 u32 len; /**< prefix length if IP */
13468 u8 type; /**< type of eid */
13473 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13475 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13477 memset (a, 0, sizeof (a[0]));
13479 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13481 a->type = 0; /* ipv4 type */
13483 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13485 a->type = 1; /* ipv6 type */
13487 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13489 a->type = 2; /* mac type */
13496 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13505 lisp_eid_size_vat (u8 type)
13520 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13522 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13526 api_one_add_del_locator_set (vat_main_t * vam)
13528 unformat_input_t *input = vam->input;
13529 vl_api_one_add_del_locator_set_t *mp;
13531 u8 *locator_set_name = NULL;
13532 u8 locator_set_name_set = 0;
13533 vl_api_local_locator_t locator, *locators = 0;
13534 u32 sw_if_index, priority, weight;
13538 /* Parse args required to build the message */
13539 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13541 if (unformat (input, "del"))
13545 else if (unformat (input, "locator-set %s", &locator_set_name))
13547 locator_set_name_set = 1;
13549 else if (unformat (input, "sw_if_index %u p %u w %u",
13550 &sw_if_index, &priority, &weight))
13552 locator.sw_if_index = htonl (sw_if_index);
13553 locator.priority = priority;
13554 locator.weight = weight;
13555 vec_add1 (locators, locator);
13559 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13560 &sw_if_index, &priority, &weight))
13562 locator.sw_if_index = htonl (sw_if_index);
13563 locator.priority = priority;
13564 locator.weight = weight;
13565 vec_add1 (locators, locator);
13571 if (locator_set_name_set == 0)
13573 errmsg ("missing locator-set name");
13574 vec_free (locators);
13578 if (vec_len (locator_set_name) > 64)
13580 errmsg ("locator-set name too long");
13581 vec_free (locator_set_name);
13582 vec_free (locators);
13585 vec_add1 (locator_set_name, 0);
13587 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13589 /* Construct the API message */
13590 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
13592 mp->is_add = is_add;
13593 clib_memcpy (mp->locator_set_name, locator_set_name,
13594 vec_len (locator_set_name));
13595 vec_free (locator_set_name);
13597 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13599 clib_memcpy (mp->locators, locators, data_len);
13600 vec_free (locators);
13605 /* Wait for a reply... */
13610 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
13613 api_one_add_del_locator (vat_main_t * vam)
13615 unformat_input_t *input = vam->input;
13616 vl_api_one_add_del_locator_t *mp;
13617 u32 tmp_if_index = ~0;
13618 u32 sw_if_index = ~0;
13619 u8 sw_if_index_set = 0;
13620 u8 sw_if_index_if_name_set = 0;
13622 u8 priority_set = 0;
13626 u8 *locator_set_name = NULL;
13627 u8 locator_set_name_set = 0;
13630 /* Parse args required to build the message */
13631 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13633 if (unformat (input, "del"))
13637 else if (unformat (input, "locator-set %s", &locator_set_name))
13639 locator_set_name_set = 1;
13641 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13644 sw_if_index_if_name_set = 1;
13645 sw_if_index = tmp_if_index;
13647 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13649 sw_if_index_set = 1;
13650 sw_if_index = tmp_if_index;
13652 else if (unformat (input, "p %d", &priority))
13656 else if (unformat (input, "w %d", &weight))
13664 if (locator_set_name_set == 0)
13666 errmsg ("missing locator-set name");
13670 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13672 errmsg ("missing sw_if_index");
13673 vec_free (locator_set_name);
13677 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13679 errmsg ("cannot use both params interface name and sw_if_index");
13680 vec_free (locator_set_name);
13684 if (priority_set == 0)
13686 errmsg ("missing locator-set priority");
13687 vec_free (locator_set_name);
13691 if (weight_set == 0)
13693 errmsg ("missing locator-set weight");
13694 vec_free (locator_set_name);
13698 if (vec_len (locator_set_name) > 64)
13700 errmsg ("locator-set name too long");
13701 vec_free (locator_set_name);
13704 vec_add1 (locator_set_name, 0);
13706 /* Construct the API message */
13707 M (ONE_ADD_DEL_LOCATOR, mp);
13709 mp->is_add = is_add;
13710 mp->sw_if_index = ntohl (sw_if_index);
13711 mp->priority = priority;
13712 mp->weight = weight;
13713 clib_memcpy (mp->locator_set_name, locator_set_name,
13714 vec_len (locator_set_name));
13715 vec_free (locator_set_name);
13720 /* Wait for a reply... */
13725 #define api_lisp_add_del_locator api_one_add_del_locator
13728 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13730 u32 *key_id = va_arg (*args, u32 *);
13733 if (unformat (input, "%s", &s))
13735 if (!strcmp ((char *) s, "sha1"))
13736 key_id[0] = HMAC_SHA_1_96;
13737 else if (!strcmp ((char *) s, "sha256"))
13738 key_id[0] = HMAC_SHA_256_128;
13741 clib_warning ("invalid key_id: '%s'", s);
13742 key_id[0] = HMAC_NO_KEY;
13753 api_one_add_del_local_eid (vat_main_t * vam)
13755 unformat_input_t *input = vam->input;
13756 vl_api_one_add_del_local_eid_t *mp;
13759 lisp_eid_vat_t _eid, *eid = &_eid;
13760 u8 *locator_set_name = 0;
13761 u8 locator_set_name_set = 0;
13767 /* Parse args required to build the message */
13768 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13770 if (unformat (input, "del"))
13774 else if (unformat (input, "vni %d", &vni))
13778 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13782 else if (unformat (input, "locator-set %s", &locator_set_name))
13784 locator_set_name_set = 1;
13786 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13788 else if (unformat (input, "secret-key %_%v%_", &key))
13794 if (locator_set_name_set == 0)
13796 errmsg ("missing locator-set name");
13802 errmsg ("EID address not set!");
13803 vec_free (locator_set_name);
13807 if (key && (0 == key_id))
13809 errmsg ("invalid key_id!");
13813 if (vec_len (key) > 64)
13815 errmsg ("key too long");
13820 if (vec_len (locator_set_name) > 64)
13822 errmsg ("locator-set name too long");
13823 vec_free (locator_set_name);
13826 vec_add1 (locator_set_name, 0);
13828 /* Construct the API message */
13829 M (ONE_ADD_DEL_LOCAL_EID, mp);
13831 mp->is_add = is_add;
13832 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13833 mp->eid_type = eid->type;
13834 mp->prefix_len = eid->len;
13835 mp->vni = clib_host_to_net_u32 (vni);
13836 mp->key_id = clib_host_to_net_u16 (key_id);
13837 clib_memcpy (mp->locator_set_name, locator_set_name,
13838 vec_len (locator_set_name));
13839 clib_memcpy (mp->key, key, vec_len (key));
13841 vec_free (locator_set_name);
13847 /* Wait for a reply... */
13852 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
13855 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13857 u32 dp_table = 0, vni = 0;;
13858 unformat_input_t *input = vam->input;
13859 vl_api_gpe_add_del_fwd_entry_t *mp;
13861 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13862 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13863 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13864 u32 action = ~0, w;
13865 ip4_address_t rmt_rloc4, lcl_rloc4;
13866 ip6_address_t rmt_rloc6, lcl_rloc6;
13867 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13870 memset (&rloc, 0, sizeof (rloc));
13872 /* Parse args required to build the message */
13873 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13875 if (unformat (input, "del"))
13877 else if (unformat (input, "add"))
13879 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13883 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13887 else if (unformat (input, "vrf %d", &dp_table))
13889 else if (unformat (input, "bd %d", &dp_table))
13891 else if (unformat (input, "vni %d", &vni))
13893 else if (unformat (input, "w %d", &w))
13897 errmsg ("No RLOC configured for setting priority/weight!");
13900 curr_rloc->weight = w;
13902 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13903 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13907 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13909 vec_add1 (lcl_locs, rloc);
13911 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13912 vec_add1 (rmt_locs, rloc);
13913 /* weight saved in rmt loc */
13914 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13916 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13917 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13920 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13922 vec_add1 (lcl_locs, rloc);
13924 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13925 vec_add1 (rmt_locs, rloc);
13926 /* weight saved in rmt loc */
13927 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13929 else if (unformat (input, "action %d", &action))
13935 clib_warning ("parse error '%U'", format_unformat_error, input);
13942 errmsg ("remote eid addresses not set");
13946 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13948 errmsg ("eid types don't match");
13952 if (0 == rmt_locs && (u32) ~ 0 == action)
13954 errmsg ("action not set for negative mapping");
13958 /* Construct the API message */
13959 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
13960 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
13962 mp->is_add = is_add;
13963 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13964 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13965 mp->eid_type = rmt_eid->type;
13966 mp->dp_table = clib_host_to_net_u32 (dp_table);
13967 mp->vni = clib_host_to_net_u32 (vni);
13968 mp->rmt_len = rmt_eid->len;
13969 mp->lcl_len = lcl_eid->len;
13970 mp->action = action;
13972 if (0 != rmt_locs && 0 != lcl_locs)
13974 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
13975 clib_memcpy (mp->locs, lcl_locs,
13976 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
13978 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
13979 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
13980 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
13982 vec_free (lcl_locs);
13983 vec_free (rmt_locs);
13988 /* Wait for a reply... */
13994 api_one_add_del_map_server (vat_main_t * vam)
13996 unformat_input_t *input = vam->input;
13997 vl_api_one_add_del_map_server_t *mp;
14001 ip4_address_t ipv4;
14002 ip6_address_t ipv6;
14005 /* Parse args required to build the message */
14006 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14008 if (unformat (input, "del"))
14012 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14016 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14024 if (ipv4_set && ipv6_set)
14026 errmsg ("both eid v4 and v6 addresses set");
14030 if (!ipv4_set && !ipv6_set)
14032 errmsg ("eid addresses not set");
14036 /* Construct the API message */
14037 M (ONE_ADD_DEL_MAP_SERVER, mp);
14039 mp->is_add = is_add;
14043 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14048 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14054 /* Wait for a reply... */
14059 #define api_lisp_add_del_map_server api_one_add_del_map_server
14062 api_one_add_del_map_resolver (vat_main_t * vam)
14064 unformat_input_t *input = vam->input;
14065 vl_api_one_add_del_map_resolver_t *mp;
14069 ip4_address_t ipv4;
14070 ip6_address_t ipv6;
14073 /* Parse args required to build the message */
14074 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14076 if (unformat (input, "del"))
14080 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14084 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14092 if (ipv4_set && ipv6_set)
14094 errmsg ("both eid v4 and v6 addresses set");
14098 if (!ipv4_set && !ipv6_set)
14100 errmsg ("eid addresses not set");
14104 /* Construct the API message */
14105 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14107 mp->is_add = is_add;
14111 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14116 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14122 /* Wait for a reply... */
14127 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14130 api_lisp_gpe_enable_disable (vat_main_t * vam)
14132 unformat_input_t *input = vam->input;
14133 vl_api_gpe_enable_disable_t *mp;
14138 /* Parse args required to build the message */
14139 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14141 if (unformat (input, "enable"))
14146 else if (unformat (input, "disable"))
14157 errmsg ("Value not set");
14161 /* Construct the API message */
14162 M (GPE_ENABLE_DISABLE, mp);
14169 /* Wait for a reply... */
14175 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14177 unformat_input_t *input = vam->input;
14178 vl_api_one_rloc_probe_enable_disable_t *mp;
14183 /* Parse args required to build the message */
14184 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14186 if (unformat (input, "enable"))
14191 else if (unformat (input, "disable"))
14199 errmsg ("Value not set");
14203 /* Construct the API message */
14204 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14206 mp->is_enabled = is_en;
14211 /* Wait for a reply... */
14216 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14219 api_one_map_register_enable_disable (vat_main_t * vam)
14221 unformat_input_t *input = vam->input;
14222 vl_api_one_map_register_enable_disable_t *mp;
14227 /* Parse args required to build the message */
14228 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14230 if (unformat (input, "enable"))
14235 else if (unformat (input, "disable"))
14243 errmsg ("Value not set");
14247 /* Construct the API message */
14248 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14250 mp->is_enabled = is_en;
14255 /* Wait for a reply... */
14260 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14263 api_one_enable_disable (vat_main_t * vam)
14265 unformat_input_t *input = vam->input;
14266 vl_api_one_enable_disable_t *mp;
14271 /* Parse args required to build the message */
14272 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14274 if (unformat (input, "enable"))
14279 else if (unformat (input, "disable"))
14289 errmsg ("Value not set");
14293 /* Construct the API message */
14294 M (ONE_ENABLE_DISABLE, mp);
14301 /* Wait for a reply... */
14306 #define api_lisp_enable_disable api_one_enable_disable
14309 api_show_one_map_register_state (vat_main_t * vam)
14311 vl_api_show_one_map_register_state_t *mp;
14314 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14319 /* wait for reply */
14324 #define api_show_lisp_map_register_state api_show_one_map_register_state
14327 api_show_one_rloc_probe_state (vat_main_t * vam)
14329 vl_api_show_one_rloc_probe_state_t *mp;
14332 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14337 /* wait for reply */
14342 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14345 api_one_stats_enable_disable (vat_main_t * vam)
14347 vl_api_one_stats_enable_disable_t *mp;
14348 unformat_input_t *input = vam->input;
14353 /* Parse args required to build the message */
14354 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14356 if (unformat (input, "enable"))
14361 else if (unformat (input, "disable"))
14371 errmsg ("Value not set");
14375 M (ONE_STATS_ENABLE_DISABLE, mp);
14381 /* wait for reply */
14387 api_show_one_stats_enable_disable (vat_main_t * vam)
14389 vl_api_show_one_stats_enable_disable_t *mp;
14392 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
14397 /* wait for reply */
14403 api_show_one_map_request_mode (vat_main_t * vam)
14405 vl_api_show_one_map_request_mode_t *mp;
14408 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
14413 /* wait for reply */
14418 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
14421 api_one_map_request_mode (vat_main_t * vam)
14423 unformat_input_t *input = vam->input;
14424 vl_api_one_map_request_mode_t *mp;
14428 /* Parse args required to build the message */
14429 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14431 if (unformat (input, "dst-only"))
14433 else if (unformat (input, "src-dst"))
14437 errmsg ("parse error '%U'", format_unformat_error, input);
14442 M (ONE_MAP_REQUEST_MODE, mp);
14449 /* wait for reply */
14454 #define api_lisp_map_request_mode api_one_map_request_mode
14457 * Enable/disable ONE proxy ITR.
14459 * @param vam vpp API test context
14460 * @return return code
14463 api_one_pitr_set_locator_set (vat_main_t * vam)
14465 u8 ls_name_set = 0;
14466 unformat_input_t *input = vam->input;
14467 vl_api_one_pitr_set_locator_set_t *mp;
14472 /* Parse args required to build the message */
14473 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14475 if (unformat (input, "del"))
14477 else if (unformat (input, "locator-set %s", &ls_name))
14481 errmsg ("parse error '%U'", format_unformat_error, input);
14488 errmsg ("locator-set name not set!");
14492 M (ONE_PITR_SET_LOCATOR_SET, mp);
14494 mp->is_add = is_add;
14495 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14496 vec_free (ls_name);
14501 /* wait for reply */
14506 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
14509 api_show_one_pitr (vat_main_t * vam)
14511 vl_api_show_one_pitr_t *mp;
14514 if (!vam->json_output)
14516 print (vam->ofp, "%=20s", "lisp status:");
14519 M (SHOW_ONE_PITR, mp);
14523 /* Wait for a reply... */
14528 #define api_show_lisp_pitr api_show_one_pitr
14531 api_one_use_petr (vat_main_t * vam)
14533 unformat_input_t *input = vam->input;
14534 vl_api_one_use_petr_t *mp;
14539 memset (&ip, 0, sizeof (ip));
14541 /* Parse args required to build the message */
14542 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14544 if (unformat (input, "disable"))
14547 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
14550 ip_addr_version (&ip) = IP4;
14553 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
14556 ip_addr_version (&ip) = IP6;
14560 errmsg ("parse error '%U'", format_unformat_error, input);
14565 M (ONE_USE_PETR, mp);
14567 mp->is_add = is_add;
14570 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
14572 clib_memcpy (mp->address, &ip, 4);
14574 clib_memcpy (mp->address, &ip, 16);
14580 /* wait for reply */
14585 #define api_lisp_use_petr api_one_use_petr
14588 api_show_one_use_petr (vat_main_t * vam)
14590 vl_api_show_one_use_petr_t *mp;
14593 if (!vam->json_output)
14595 print (vam->ofp, "%=20s", "Proxy-ETR status:");
14598 M (SHOW_ONE_USE_PETR, mp);
14602 /* Wait for a reply... */
14607 #define api_show_lisp_use_petr api_show_one_use_petr
14610 * Add/delete mapping between vni and vrf
14613 api_one_eid_table_add_del_map (vat_main_t * vam)
14615 unformat_input_t *input = vam->input;
14616 vl_api_one_eid_table_add_del_map_t *mp;
14617 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
14618 u32 vni, vrf, bd_index;
14621 /* Parse args required to build the message */
14622 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14624 if (unformat (input, "del"))
14626 else if (unformat (input, "vrf %d", &vrf))
14628 else if (unformat (input, "bd_index %d", &bd_index))
14630 else if (unformat (input, "vni %d", &vni))
14636 if (!vni_set || (!vrf_set && !bd_index_set))
14638 errmsg ("missing arguments!");
14642 if (vrf_set && bd_index_set)
14644 errmsg ("error: both vrf and bd entered!");
14648 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
14650 mp->is_add = is_add;
14651 mp->vni = htonl (vni);
14652 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
14653 mp->is_l2 = bd_index_set;
14658 /* wait for reply */
14663 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
14666 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
14668 u32 *action = va_arg (*args, u32 *);
14671 if (unformat (input, "%s", &s))
14673 if (!strcmp ((char *) s, "no-action"))
14675 else if (!strcmp ((char *) s, "natively-forward"))
14677 else if (!strcmp ((char *) s, "send-map-request"))
14679 else if (!strcmp ((char *) s, "drop"))
14683 clib_warning ("invalid action: '%s'", s);
14695 * Add/del remote mapping to/from ONE control plane
14697 * @param vam vpp API test context
14698 * @return return code
14701 api_one_add_del_remote_mapping (vat_main_t * vam)
14703 unformat_input_t *input = vam->input;
14704 vl_api_one_add_del_remote_mapping_t *mp;
14706 lisp_eid_vat_t _eid, *eid = &_eid;
14707 lisp_eid_vat_t _seid, *seid = &_seid;
14708 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
14709 u32 action = ~0, p, w, data_len;
14710 ip4_address_t rloc4;
14711 ip6_address_t rloc6;
14712 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
14715 memset (&rloc, 0, sizeof (rloc));
14717 /* Parse args required to build the message */
14718 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14720 if (unformat (input, "del-all"))
14724 else if (unformat (input, "del"))
14728 else if (unformat (input, "add"))
14732 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14736 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14740 else if (unformat (input, "vni %d", &vni))
14744 else if (unformat (input, "p %d w %d", &p, &w))
14748 errmsg ("No RLOC configured for setting priority/weight!");
14751 curr_rloc->priority = p;
14752 curr_rloc->weight = w;
14754 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14757 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14758 vec_add1 (rlocs, rloc);
14759 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14761 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14764 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14765 vec_add1 (rlocs, rloc);
14766 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14768 else if (unformat (input, "action %U",
14769 unformat_negative_mapping_action, &action))
14775 clib_warning ("parse error '%U'", format_unformat_error, input);
14782 errmsg ("missing params!");
14786 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14788 errmsg ("no action set for negative map-reply!");
14792 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
14794 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
14795 mp->is_add = is_add;
14796 mp->vni = htonl (vni);
14797 mp->action = (u8) action;
14798 mp->is_src_dst = seid_set;
14799 mp->eid_len = eid->len;
14800 mp->seid_len = seid->len;
14801 mp->del_all = del_all;
14802 mp->eid_type = eid->type;
14803 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14804 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14806 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14807 clib_memcpy (mp->rlocs, rlocs, data_len);
14813 /* Wait for a reply... */
14818 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
14821 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
14822 * forwarding entries in data-plane accordingly.
14824 * @param vam vpp API test context
14825 * @return return code
14828 api_one_add_del_adjacency (vat_main_t * vam)
14830 unformat_input_t *input = vam->input;
14831 vl_api_one_add_del_adjacency_t *mp;
14833 ip4_address_t leid4, reid4;
14834 ip6_address_t leid6, reid6;
14835 u8 reid_mac[6] = { 0 };
14836 u8 leid_mac[6] = { 0 };
14837 u8 reid_type, leid_type;
14838 u32 leid_len = 0, reid_len = 0, len;
14842 leid_type = reid_type = (u8) ~ 0;
14844 /* Parse args required to build the message */
14845 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14847 if (unformat (input, "del"))
14851 else if (unformat (input, "add"))
14855 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14858 reid_type = 0; /* ipv4 */
14861 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14864 reid_type = 1; /* ipv6 */
14867 else if (unformat (input, "reid %U", unformat_ethernet_address,
14870 reid_type = 2; /* mac */
14872 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14875 leid_type = 0; /* ipv4 */
14878 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14881 leid_type = 1; /* ipv6 */
14884 else if (unformat (input, "leid %U", unformat_ethernet_address,
14887 leid_type = 2; /* mac */
14889 else if (unformat (input, "vni %d", &vni))
14895 errmsg ("parse error '%U'", format_unformat_error, input);
14900 if ((u8) ~ 0 == reid_type)
14902 errmsg ("missing params!");
14906 if (leid_type != reid_type)
14908 errmsg ("remote and local EIDs are of different types!");
14912 M (ONE_ADD_DEL_ADJACENCY, mp);
14913 mp->is_add = is_add;
14914 mp->vni = htonl (vni);
14915 mp->leid_len = leid_len;
14916 mp->reid_len = reid_len;
14917 mp->eid_type = reid_type;
14919 switch (mp->eid_type)
14922 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14923 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14926 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14927 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14930 clib_memcpy (mp->leid, leid_mac, 6);
14931 clib_memcpy (mp->reid, reid_mac, 6);
14934 errmsg ("unknown EID type %d!", mp->eid_type);
14941 /* Wait for a reply... */
14946 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
14949 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
14951 u32 *mode = va_arg (*args, u32 *);
14953 if (unformat (input, "lisp"))
14955 else if (unformat (input, "vxlan"))
14964 api_gpe_get_encap_mode (vat_main_t * vam)
14966 vl_api_gpe_get_encap_mode_t *mp;
14969 /* Construct the API message */
14970 M (GPE_GET_ENCAP_MODE, mp);
14975 /* Wait for a reply... */
14981 api_gpe_set_encap_mode (vat_main_t * vam)
14983 unformat_input_t *input = vam->input;
14984 vl_api_gpe_set_encap_mode_t *mp;
14988 /* Parse args required to build the message */
14989 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14991 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
14997 /* Construct the API message */
14998 M (GPE_SET_ENCAP_MODE, mp);
15005 /* Wait for a reply... */
15011 api_lisp_gpe_add_del_iface (vat_main_t * vam)
15013 unformat_input_t *input = vam->input;
15014 vl_api_gpe_add_del_iface_t *mp;
15015 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
15016 u32 dp_table = 0, vni = 0;
15019 /* Parse args required to build the message */
15020 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15022 if (unformat (input, "up"))
15027 else if (unformat (input, "down"))
15032 else if (unformat (input, "table_id %d", &dp_table))
15036 else if (unformat (input, "bd_id %d", &dp_table))
15041 else if (unformat (input, "vni %d", &vni))
15049 if (action_set == 0)
15051 errmsg ("Action not set");
15054 if (dp_table_set == 0 || vni_set == 0)
15056 errmsg ("vni and dp_table must be set");
15060 /* Construct the API message */
15061 M (GPE_ADD_DEL_IFACE, mp);
15063 mp->is_add = is_add;
15064 mp->dp_table = dp_table;
15071 /* Wait for a reply... */
15077 * Add/del map request itr rlocs from ONE control plane and updates
15079 * @param vam vpp API test context
15080 * @return return code
15083 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
15085 unformat_input_t *input = vam->input;
15086 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
15087 u8 *locator_set_name = 0;
15088 u8 locator_set_name_set = 0;
15092 /* Parse args required to build the message */
15093 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15095 if (unformat (input, "del"))
15099 else if (unformat (input, "%_%v%_", &locator_set_name))
15101 locator_set_name_set = 1;
15105 clib_warning ("parse error '%U'", format_unformat_error, input);
15110 if (is_add && !locator_set_name_set)
15112 errmsg ("itr-rloc is not set!");
15116 if (is_add && vec_len (locator_set_name) > 64)
15118 errmsg ("itr-rloc locator-set name too long");
15119 vec_free (locator_set_name);
15123 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
15124 mp->is_add = is_add;
15127 clib_memcpy (mp->locator_set_name, locator_set_name,
15128 vec_len (locator_set_name));
15132 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
15134 vec_free (locator_set_name);
15139 /* Wait for a reply... */
15144 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
15147 api_one_locator_dump (vat_main_t * vam)
15149 unformat_input_t *input = vam->input;
15150 vl_api_one_locator_dump_t *mp;
15151 vl_api_control_ping_t *mp_ping;
15152 u8 is_index_set = 0, is_name_set = 0;
15157 /* Parse args required to build the message */
15158 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15160 if (unformat (input, "ls_name %_%v%_", &ls_name))
15164 else if (unformat (input, "ls_index %d", &ls_index))
15170 errmsg ("parse error '%U'", format_unformat_error, input);
15175 if (!is_index_set && !is_name_set)
15177 errmsg ("error: expected one of index or name!");
15181 if (is_index_set && is_name_set)
15183 errmsg ("error: only one param expected!");
15187 if (vec_len (ls_name) > 62)
15189 errmsg ("error: locator set name too long!");
15193 if (!vam->json_output)
15195 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
15198 M (ONE_LOCATOR_DUMP, mp);
15199 mp->is_index_set = is_index_set;
15202 mp->ls_index = clib_host_to_net_u32 (ls_index);
15205 vec_add1 (ls_name, 0);
15206 strncpy ((char *) mp->ls_name, (char *) ls_name,
15207 sizeof (mp->ls_name) - 1);
15213 /* Use a control ping for synchronization */
15214 M (CONTROL_PING, mp_ping);
15217 /* Wait for a reply... */
15222 #define api_lisp_locator_dump api_one_locator_dump
15225 api_one_locator_set_dump (vat_main_t * vam)
15227 vl_api_one_locator_set_dump_t *mp;
15228 vl_api_control_ping_t *mp_ping;
15229 unformat_input_t *input = vam->input;
15233 /* Parse args required to build the message */
15234 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15236 if (unformat (input, "local"))
15240 else if (unformat (input, "remote"))
15246 errmsg ("parse error '%U'", format_unformat_error, input);
15251 if (!vam->json_output)
15253 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
15256 M (ONE_LOCATOR_SET_DUMP, mp);
15258 mp->filter = filter;
15263 /* Use a control ping for synchronization */
15264 M (CONTROL_PING, mp_ping);
15267 /* Wait for a reply... */
15272 #define api_lisp_locator_set_dump api_one_locator_set_dump
15275 api_one_eid_table_map_dump (vat_main_t * vam)
15279 unformat_input_t *input = vam->input;
15280 vl_api_one_eid_table_map_dump_t *mp;
15281 vl_api_control_ping_t *mp_ping;
15284 /* Parse args required to build the message */
15285 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15287 if (unformat (input, "l2"))
15292 else if (unformat (input, "l3"))
15299 errmsg ("parse error '%U'", format_unformat_error, input);
15306 errmsg ("expected one of 'l2' or 'l3' parameter!");
15310 if (!vam->json_output)
15312 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
15315 M (ONE_EID_TABLE_MAP_DUMP, mp);
15321 /* Use a control ping for synchronization */
15322 M (CONTROL_PING, mp_ping);
15325 /* Wait for a reply... */
15330 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
15333 api_one_eid_table_vni_dump (vat_main_t * vam)
15335 vl_api_one_eid_table_vni_dump_t *mp;
15336 vl_api_control_ping_t *mp_ping;
15339 if (!vam->json_output)
15341 print (vam->ofp, "VNI");
15344 M (ONE_EID_TABLE_VNI_DUMP, mp);
15349 /* Use a control ping for synchronization */
15350 M (CONTROL_PING, mp_ping);
15353 /* Wait for a reply... */
15358 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
15361 api_one_eid_table_dump (vat_main_t * vam)
15363 unformat_input_t *i = vam->input;
15364 vl_api_one_eid_table_dump_t *mp;
15365 vl_api_control_ping_t *mp_ping;
15366 struct in_addr ip4;
15367 struct in6_addr ip6;
15369 u8 eid_type = ~0, eid_set = 0;
15370 u32 prefix_length = ~0, t, vni = 0;
15374 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15376 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
15382 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
15388 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
15393 else if (unformat (i, "vni %d", &t))
15397 else if (unformat (i, "local"))
15401 else if (unformat (i, "remote"))
15407 errmsg ("parse error '%U'", format_unformat_error, i);
15412 if (!vam->json_output)
15414 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
15415 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
15418 M (ONE_EID_TABLE_DUMP, mp);
15420 mp->filter = filter;
15424 mp->vni = htonl (vni);
15425 mp->eid_type = eid_type;
15429 mp->prefix_length = prefix_length;
15430 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
15433 mp->prefix_length = prefix_length;
15434 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
15437 clib_memcpy (mp->eid, mac, sizeof (mac));
15440 errmsg ("unknown EID type %d!", eid_type);
15448 /* Use a control ping for synchronization */
15449 M (CONTROL_PING, mp_ping);
15452 /* Wait for a reply... */
15457 #define api_lisp_eid_table_dump api_one_eid_table_dump
15460 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
15462 unformat_input_t *i = vam->input;
15463 vl_api_gpe_fwd_entries_get_t *mp;
15468 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15470 if (unformat (i, "vni %d", &vni))
15476 errmsg ("parse error '%U'", format_unformat_error, i);
15483 errmsg ("vni not set!");
15487 if (!vam->json_output)
15489 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15493 M (GPE_FWD_ENTRIES_GET, mp);
15494 mp->vni = clib_host_to_net_u32 (vni);
15499 /* Wait for a reply... */
15504 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15505 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15506 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15507 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
15510 api_one_adjacencies_get (vat_main_t * vam)
15512 unformat_input_t *i = vam->input;
15513 vl_api_one_adjacencies_get_t *mp;
15518 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15520 if (unformat (i, "vni %d", &vni))
15526 errmsg ("parse error '%U'", format_unformat_error, i);
15533 errmsg ("vni not set!");
15537 if (!vam->json_output)
15539 print (vam->ofp, "%s %40s", "leid", "reid");
15542 M (ONE_ADJACENCIES_GET, mp);
15543 mp->vni = clib_host_to_net_u32 (vni);
15548 /* Wait for a reply... */
15553 #define api_lisp_adjacencies_get api_one_adjacencies_get
15556 api_one_map_server_dump (vat_main_t * vam)
15558 vl_api_one_map_server_dump_t *mp;
15559 vl_api_control_ping_t *mp_ping;
15562 if (!vam->json_output)
15564 print (vam->ofp, "%=20s", "Map server");
15567 M (ONE_MAP_SERVER_DUMP, mp);
15571 /* Use a control ping for synchronization */
15572 M (CONTROL_PING, mp_ping);
15575 /* Wait for a reply... */
15580 #define api_lisp_map_server_dump api_one_map_server_dump
15583 api_one_map_resolver_dump (vat_main_t * vam)
15585 vl_api_one_map_resolver_dump_t *mp;
15586 vl_api_control_ping_t *mp_ping;
15589 if (!vam->json_output)
15591 print (vam->ofp, "%=20s", "Map resolver");
15594 M (ONE_MAP_RESOLVER_DUMP, mp);
15598 /* Use a control ping for synchronization */
15599 M (CONTROL_PING, mp_ping);
15602 /* Wait for a reply... */
15607 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
15610 api_one_stats_dump (vat_main_t * vam)
15612 vl_api_one_stats_dump_t *mp;
15613 vl_api_control_ping_t *mp_ping;
15616 M (ONE_STATS_DUMP, mp);
15620 /* Use a control ping for synchronization */
15621 M (CONTROL_PING, mp_ping);
15624 /* Wait for a reply... */
15630 api_show_one_status (vat_main_t * vam)
15632 vl_api_show_one_status_t *mp;
15635 if (!vam->json_output)
15637 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
15640 M (SHOW_ONE_STATUS, mp);
15643 /* Wait for a reply... */
15648 #define api_show_lisp_status api_show_one_status
15651 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
15653 vl_api_gpe_fwd_entry_path_dump_t *mp;
15654 vl_api_control_ping_t *mp_ping;
15655 unformat_input_t *i = vam->input;
15656 u32 fwd_entry_index = ~0;
15659 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15661 if (unformat (i, "index %d", &fwd_entry_index))
15667 if (~0 == fwd_entry_index)
15669 errmsg ("no index specified!");
15673 if (!vam->json_output)
15675 print (vam->ofp, "first line");
15678 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
15682 /* Use a control ping for synchronization */
15683 M (CONTROL_PING, mp_ping);
15686 /* Wait for a reply... */
15692 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
15694 vl_api_one_get_map_request_itr_rlocs_t *mp;
15697 if (!vam->json_output)
15699 print (vam->ofp, "%=20s", "itr-rlocs:");
15702 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
15705 /* Wait for a reply... */
15710 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
15713 api_af_packet_create (vat_main_t * vam)
15715 unformat_input_t *i = vam->input;
15716 vl_api_af_packet_create_t *mp;
15717 u8 *host_if_name = 0;
15719 u8 random_hw_addr = 1;
15722 memset (hw_addr, 0, sizeof (hw_addr));
15724 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15726 if (unformat (i, "name %s", &host_if_name))
15727 vec_add1 (host_if_name, 0);
15728 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15729 random_hw_addr = 0;
15734 if (!vec_len (host_if_name))
15736 errmsg ("host-interface name must be specified");
15740 if (vec_len (host_if_name) > 64)
15742 errmsg ("host-interface name too long");
15746 M (AF_PACKET_CREATE, mp);
15748 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15749 clib_memcpy (mp->hw_addr, hw_addr, 6);
15750 mp->use_random_hw_addr = random_hw_addr;
15751 vec_free (host_if_name);
15759 fprintf (vam->ofp ? vam->ofp : stderr,
15760 " new sw_if_index = %d\n", vam->sw_if_index);
15767 api_af_packet_delete (vat_main_t * vam)
15769 unformat_input_t *i = vam->input;
15770 vl_api_af_packet_delete_t *mp;
15771 u8 *host_if_name = 0;
15774 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15776 if (unformat (i, "name %s", &host_if_name))
15777 vec_add1 (host_if_name, 0);
15782 if (!vec_len (host_if_name))
15784 errmsg ("host-interface name must be specified");
15788 if (vec_len (host_if_name) > 64)
15790 errmsg ("host-interface name too long");
15794 M (AF_PACKET_DELETE, mp);
15796 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15797 vec_free (host_if_name);
15805 api_policer_add_del (vat_main_t * vam)
15807 unformat_input_t *i = vam->input;
15808 vl_api_policer_add_del_t *mp;
15818 u8 color_aware = 0;
15819 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
15822 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
15823 conform_action.dscp = 0;
15824 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
15825 exceed_action.dscp = 0;
15826 violate_action.action_type = SSE2_QOS_ACTION_DROP;
15827 violate_action.dscp = 0;
15829 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15831 if (unformat (i, "del"))
15833 else if (unformat (i, "name %s", &name))
15834 vec_add1 (name, 0);
15835 else if (unformat (i, "cir %u", &cir))
15837 else if (unformat (i, "eir %u", &eir))
15839 else if (unformat (i, "cb %u", &cb))
15841 else if (unformat (i, "eb %u", &eb))
15843 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
15846 else if (unformat (i, "round_type %U", unformat_policer_round_type,
15849 else if (unformat (i, "type %U", unformat_policer_type, &type))
15851 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
15854 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
15857 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
15860 else if (unformat (i, "color-aware"))
15866 if (!vec_len (name))
15868 errmsg ("policer name must be specified");
15872 if (vec_len (name) > 64)
15874 errmsg ("policer name too long");
15878 M (POLICER_ADD_DEL, mp);
15880 clib_memcpy (mp->name, name, vec_len (name));
15882 mp->is_add = is_add;
15887 mp->rate_type = rate_type;
15888 mp->round_type = round_type;
15890 mp->conform_action_type = conform_action.action_type;
15891 mp->conform_dscp = conform_action.dscp;
15892 mp->exceed_action_type = exceed_action.action_type;
15893 mp->exceed_dscp = exceed_action.dscp;
15894 mp->violate_action_type = violate_action.action_type;
15895 mp->violate_dscp = violate_action.dscp;
15896 mp->color_aware = color_aware;
15904 api_policer_dump (vat_main_t * vam)
15906 unformat_input_t *i = vam->input;
15907 vl_api_policer_dump_t *mp;
15908 vl_api_control_ping_t *mp_ping;
15909 u8 *match_name = 0;
15910 u8 match_name_valid = 0;
15913 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15915 if (unformat (i, "name %s", &match_name))
15917 vec_add1 (match_name, 0);
15918 match_name_valid = 1;
15924 M (POLICER_DUMP, mp);
15925 mp->match_name_valid = match_name_valid;
15926 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15927 vec_free (match_name);
15931 /* Use a control ping for synchronization */
15932 M (CONTROL_PING, mp_ping);
15935 /* Wait for a reply... */
15941 api_policer_classify_set_interface (vat_main_t * vam)
15943 unformat_input_t *i = vam->input;
15944 vl_api_policer_classify_set_interface_t *mp;
15946 int sw_if_index_set;
15947 u32 ip4_table_index = ~0;
15948 u32 ip6_table_index = ~0;
15949 u32 l2_table_index = ~0;
15953 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15955 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15956 sw_if_index_set = 1;
15957 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15958 sw_if_index_set = 1;
15959 else if (unformat (i, "del"))
15961 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15963 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15965 else if (unformat (i, "l2-table %d", &l2_table_index))
15969 clib_warning ("parse error '%U'", format_unformat_error, i);
15974 if (sw_if_index_set == 0)
15976 errmsg ("missing interface name or sw_if_index");
15980 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
15982 mp->sw_if_index = ntohl (sw_if_index);
15983 mp->ip4_table_index = ntohl (ip4_table_index);
15984 mp->ip6_table_index = ntohl (ip6_table_index);
15985 mp->l2_table_index = ntohl (l2_table_index);
15986 mp->is_add = is_add;
15994 api_policer_classify_dump (vat_main_t * vam)
15996 unformat_input_t *i = vam->input;
15997 vl_api_policer_classify_dump_t *mp;
15998 vl_api_control_ping_t *mp_ping;
15999 u8 type = POLICER_CLASSIFY_N_TABLES;
16002 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
16006 errmsg ("classify table type must be specified");
16010 if (!vam->json_output)
16012 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
16015 M (POLICER_CLASSIFY_DUMP, mp);
16020 /* Use a control ping for synchronization */
16021 M (CONTROL_PING, mp_ping);
16024 /* Wait for a reply... */
16030 api_netmap_create (vat_main_t * vam)
16032 unformat_input_t *i = vam->input;
16033 vl_api_netmap_create_t *mp;
16036 u8 random_hw_addr = 1;
16041 memset (hw_addr, 0, sizeof (hw_addr));
16043 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16045 if (unformat (i, "name %s", &if_name))
16046 vec_add1 (if_name, 0);
16047 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16048 random_hw_addr = 0;
16049 else if (unformat (i, "pipe"))
16051 else if (unformat (i, "master"))
16053 else if (unformat (i, "slave"))
16059 if (!vec_len (if_name))
16061 errmsg ("interface name must be specified");
16065 if (vec_len (if_name) > 64)
16067 errmsg ("interface name too long");
16071 M (NETMAP_CREATE, mp);
16073 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16074 clib_memcpy (mp->hw_addr, hw_addr, 6);
16075 mp->use_random_hw_addr = random_hw_addr;
16076 mp->is_pipe = is_pipe;
16077 mp->is_master = is_master;
16078 vec_free (if_name);
16086 api_netmap_delete (vat_main_t * vam)
16088 unformat_input_t *i = vam->input;
16089 vl_api_netmap_delete_t *mp;
16093 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16095 if (unformat (i, "name %s", &if_name))
16096 vec_add1 (if_name, 0);
16101 if (!vec_len (if_name))
16103 errmsg ("interface name must be specified");
16107 if (vec_len (if_name) > 64)
16109 errmsg ("interface name too long");
16113 M (NETMAP_DELETE, mp);
16115 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16116 vec_free (if_name);
16123 static void vl_api_mpls_tunnel_details_t_handler
16124 (vl_api_mpls_tunnel_details_t * mp)
16126 vat_main_t *vam = &vat_main;
16127 i32 len = mp->mt_next_hop_n_labels;
16130 print (vam->ofp, "[%d]: via %U %d labels ",
16132 format_ip4_address, mp->mt_next_hop,
16133 ntohl (mp->mt_next_hop_sw_if_index));
16134 for (i = 0; i < len; i++)
16136 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
16138 print (vam->ofp, "");
16141 static void vl_api_mpls_tunnel_details_t_handler_json
16142 (vl_api_mpls_tunnel_details_t * mp)
16144 vat_main_t *vam = &vat_main;
16145 vat_json_node_t *node = NULL;
16146 struct in_addr ip4;
16148 i32 len = mp->mt_next_hop_n_labels;
16150 if (VAT_JSON_ARRAY != vam->json_tree.type)
16152 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16153 vat_json_init_array (&vam->json_tree);
16155 node = vat_json_array_add (&vam->json_tree);
16157 vat_json_init_object (node);
16158 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
16159 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
16160 vat_json_object_add_ip4 (node, "next_hop", ip4);
16161 vat_json_object_add_uint (node, "next_hop_sw_if_index",
16162 ntohl (mp->mt_next_hop_sw_if_index));
16163 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
16164 vat_json_object_add_uint (node, "label_count", len);
16165 for (i = 0; i < len; i++)
16167 vat_json_object_add_uint (node, "label",
16168 ntohl (mp->mt_next_hop_out_labels[i]));
16173 api_mpls_tunnel_dump (vat_main_t * vam)
16175 vl_api_mpls_tunnel_dump_t *mp;
16176 vl_api_control_ping_t *mp_ping;
16180 /* Parse args required to build the message */
16181 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
16183 if (!unformat (vam->input, "tunnel_index %d", &index))
16190 print (vam->ofp, " tunnel_index %d", index);
16192 M (MPLS_TUNNEL_DUMP, mp);
16193 mp->tunnel_index = htonl (index);
16196 /* Use a control ping for synchronization */
16197 M (CONTROL_PING, mp_ping);
16204 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
16205 #define vl_api_mpls_fib_details_t_print vl_noop_handler
16208 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
16210 vat_main_t *vam = &vat_main;
16211 int count = ntohl (mp->count);
16212 vl_api_fib_path2_t *fp;
16216 "table-id %d, label %u, ess_bit %u",
16217 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
16219 for (i = 0; i < count; i++)
16221 if (fp->afi == IP46_TYPE_IP6)
16223 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16224 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16225 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16226 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16227 format_ip6_address, fp->next_hop);
16228 else if (fp->afi == IP46_TYPE_IP4)
16230 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16231 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16232 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16233 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16234 format_ip4_address, fp->next_hop);
16239 static void vl_api_mpls_fib_details_t_handler_json
16240 (vl_api_mpls_fib_details_t * mp)
16242 vat_main_t *vam = &vat_main;
16243 int count = ntohl (mp->count);
16244 vat_json_node_t *node = NULL;
16245 struct in_addr ip4;
16246 struct in6_addr ip6;
16247 vl_api_fib_path2_t *fp;
16250 if (VAT_JSON_ARRAY != vam->json_tree.type)
16252 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16253 vat_json_init_array (&vam->json_tree);
16255 node = vat_json_array_add (&vam->json_tree);
16257 vat_json_init_object (node);
16258 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16259 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
16260 vat_json_object_add_uint (node, "label", ntohl (mp->label));
16261 vat_json_object_add_uint (node, "path_count", count);
16263 for (i = 0; i < count; i++)
16265 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16266 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16267 vat_json_object_add_uint (node, "is_local", fp->is_local);
16268 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16269 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16270 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16271 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16272 if (fp->afi == IP46_TYPE_IP4)
16274 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16275 vat_json_object_add_ip4 (node, "next_hop", ip4);
16277 else if (fp->afi == IP46_TYPE_IP6)
16279 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16280 vat_json_object_add_ip6 (node, "next_hop", ip6);
16286 api_mpls_fib_dump (vat_main_t * vam)
16288 vl_api_mpls_fib_dump_t *mp;
16289 vl_api_control_ping_t *mp_ping;
16292 M (MPLS_FIB_DUMP, mp);
16295 /* Use a control ping for synchronization */
16296 M (CONTROL_PING, mp_ping);
16303 #define vl_api_ip_fib_details_t_endian vl_noop_handler
16304 #define vl_api_ip_fib_details_t_print vl_noop_handler
16307 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
16309 vat_main_t *vam = &vat_main;
16310 int count = ntohl (mp->count);
16311 vl_api_fib_path_t *fp;
16315 "table-id %d, prefix %U/%d",
16316 ntohl (mp->table_id), format_ip4_address, mp->address,
16317 mp->address_length);
16319 for (i = 0; i < count; i++)
16321 if (fp->afi == IP46_TYPE_IP6)
16323 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16324 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16325 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16326 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16327 format_ip6_address, fp->next_hop);
16328 else if (fp->afi == IP46_TYPE_IP4)
16330 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16331 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16332 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16333 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16334 format_ip4_address, fp->next_hop);
16339 static void vl_api_ip_fib_details_t_handler_json
16340 (vl_api_ip_fib_details_t * mp)
16342 vat_main_t *vam = &vat_main;
16343 int count = ntohl (mp->count);
16344 vat_json_node_t *node = NULL;
16345 struct in_addr ip4;
16346 struct in6_addr ip6;
16347 vl_api_fib_path_t *fp;
16350 if (VAT_JSON_ARRAY != vam->json_tree.type)
16352 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16353 vat_json_init_array (&vam->json_tree);
16355 node = vat_json_array_add (&vam->json_tree);
16357 vat_json_init_object (node);
16358 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16359 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
16360 vat_json_object_add_ip4 (node, "prefix", ip4);
16361 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16362 vat_json_object_add_uint (node, "path_count", count);
16364 for (i = 0; i < count; i++)
16366 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16367 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16368 vat_json_object_add_uint (node, "is_local", fp->is_local);
16369 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16370 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16371 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16372 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16373 if (fp->afi == IP46_TYPE_IP4)
16375 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16376 vat_json_object_add_ip4 (node, "next_hop", ip4);
16378 else if (fp->afi == IP46_TYPE_IP6)
16380 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16381 vat_json_object_add_ip6 (node, "next_hop", ip6);
16387 api_ip_fib_dump (vat_main_t * vam)
16389 vl_api_ip_fib_dump_t *mp;
16390 vl_api_control_ping_t *mp_ping;
16393 M (IP_FIB_DUMP, mp);
16396 /* Use a control ping for synchronization */
16397 M (CONTROL_PING, mp_ping);
16405 api_ip_mfib_dump (vat_main_t * vam)
16407 vl_api_ip_mfib_dump_t *mp;
16408 vl_api_control_ping_t *mp_ping;
16411 M (IP_MFIB_DUMP, mp);
16414 /* Use a control ping for synchronization */
16415 M (CONTROL_PING, mp_ping);
16422 static void vl_api_ip_neighbor_details_t_handler
16423 (vl_api_ip_neighbor_details_t * mp)
16425 vat_main_t *vam = &vat_main;
16427 print (vam->ofp, "%c %U %U",
16428 (mp->is_static) ? 'S' : 'D',
16429 format_ethernet_address, &mp->mac_address,
16430 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
16434 static void vl_api_ip_neighbor_details_t_handler_json
16435 (vl_api_ip_neighbor_details_t * mp)
16438 vat_main_t *vam = &vat_main;
16439 vat_json_node_t *node;
16440 struct in_addr ip4;
16441 struct in6_addr ip6;
16443 if (VAT_JSON_ARRAY != vam->json_tree.type)
16445 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16446 vat_json_init_array (&vam->json_tree);
16448 node = vat_json_array_add (&vam->json_tree);
16450 vat_json_init_object (node);
16451 vat_json_object_add_string_copy (node, "flag",
16452 (mp->is_static) ? (u8 *) "static" : (u8 *)
16455 vat_json_object_add_string_copy (node, "link_layer",
16456 format (0, "%U", format_ethernet_address,
16457 &mp->mac_address));
16461 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
16462 vat_json_object_add_ip6 (node, "ip_address", ip6);
16466 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
16467 vat_json_object_add_ip4 (node, "ip_address", ip4);
16472 api_ip_neighbor_dump (vat_main_t * vam)
16474 unformat_input_t *i = vam->input;
16475 vl_api_ip_neighbor_dump_t *mp;
16476 vl_api_control_ping_t *mp_ping;
16478 u32 sw_if_index = ~0;
16481 /* Parse args required to build the message */
16482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16484 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16486 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16488 else if (unformat (i, "ip6"))
16494 if (sw_if_index == ~0)
16496 errmsg ("missing interface name or sw_if_index");
16500 M (IP_NEIGHBOR_DUMP, mp);
16501 mp->is_ipv6 = (u8) is_ipv6;
16502 mp->sw_if_index = ntohl (sw_if_index);
16505 /* Use a control ping for synchronization */
16506 M (CONTROL_PING, mp_ping);
16513 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
16514 #define vl_api_ip6_fib_details_t_print vl_noop_handler
16517 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
16519 vat_main_t *vam = &vat_main;
16520 int count = ntohl (mp->count);
16521 vl_api_fib_path_t *fp;
16525 "table-id %d, prefix %U/%d",
16526 ntohl (mp->table_id), format_ip6_address, mp->address,
16527 mp->address_length);
16529 for (i = 0; i < count; i++)
16531 if (fp->afi == IP46_TYPE_IP6)
16533 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16534 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16535 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16536 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16537 format_ip6_address, fp->next_hop);
16538 else if (fp->afi == IP46_TYPE_IP4)
16540 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16541 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16542 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16543 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16544 format_ip4_address, fp->next_hop);
16549 static void vl_api_ip6_fib_details_t_handler_json
16550 (vl_api_ip6_fib_details_t * mp)
16552 vat_main_t *vam = &vat_main;
16553 int count = ntohl (mp->count);
16554 vat_json_node_t *node = NULL;
16555 struct in_addr ip4;
16556 struct in6_addr ip6;
16557 vl_api_fib_path_t *fp;
16560 if (VAT_JSON_ARRAY != vam->json_tree.type)
16562 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16563 vat_json_init_array (&vam->json_tree);
16565 node = vat_json_array_add (&vam->json_tree);
16567 vat_json_init_object (node);
16568 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16569 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
16570 vat_json_object_add_ip6 (node, "prefix", ip6);
16571 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16572 vat_json_object_add_uint (node, "path_count", count);
16574 for (i = 0; i < count; i++)
16576 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16577 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16578 vat_json_object_add_uint (node, "is_local", fp->is_local);
16579 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16580 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16581 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16582 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16583 if (fp->afi == IP46_TYPE_IP4)
16585 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16586 vat_json_object_add_ip4 (node, "next_hop", ip4);
16588 else if (fp->afi == IP46_TYPE_IP6)
16590 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16591 vat_json_object_add_ip6 (node, "next_hop", ip6);
16597 api_ip6_fib_dump (vat_main_t * vam)
16599 vl_api_ip6_fib_dump_t *mp;
16600 vl_api_control_ping_t *mp_ping;
16603 M (IP6_FIB_DUMP, mp);
16606 /* Use a control ping for synchronization */
16607 M (CONTROL_PING, mp_ping);
16615 api_ip6_mfib_dump (vat_main_t * vam)
16617 vl_api_ip6_mfib_dump_t *mp;
16618 vl_api_control_ping_t *mp_ping;
16621 M (IP6_MFIB_DUMP, mp);
16624 /* Use a control ping for synchronization */
16625 M (CONTROL_PING, mp_ping);
16633 api_classify_table_ids (vat_main_t * vam)
16635 vl_api_classify_table_ids_t *mp;
16638 /* Construct the API message */
16639 M (CLASSIFY_TABLE_IDS, mp);
16648 api_classify_table_by_interface (vat_main_t * vam)
16650 unformat_input_t *input = vam->input;
16651 vl_api_classify_table_by_interface_t *mp;
16653 u32 sw_if_index = ~0;
16655 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16657 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16659 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16664 if (sw_if_index == ~0)
16666 errmsg ("missing interface name or sw_if_index");
16670 /* Construct the API message */
16671 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
16673 mp->sw_if_index = ntohl (sw_if_index);
16681 api_classify_table_info (vat_main_t * vam)
16683 unformat_input_t *input = vam->input;
16684 vl_api_classify_table_info_t *mp;
16688 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16690 if (unformat (input, "table_id %d", &table_id))
16695 if (table_id == ~0)
16697 errmsg ("missing table id");
16701 /* Construct the API message */
16702 M (CLASSIFY_TABLE_INFO, mp);
16704 mp->table_id = ntohl (table_id);
16712 api_classify_session_dump (vat_main_t * vam)
16714 unformat_input_t *input = vam->input;
16715 vl_api_classify_session_dump_t *mp;
16716 vl_api_control_ping_t *mp_ping;
16720 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16722 if (unformat (input, "table_id %d", &table_id))
16727 if (table_id == ~0)
16729 errmsg ("missing table id");
16733 /* Construct the API message */
16734 M (CLASSIFY_SESSION_DUMP, mp);
16736 mp->table_id = ntohl (table_id);
16739 /* Use a control ping for synchronization */
16740 M (CONTROL_PING, mp_ping);
16748 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
16750 vat_main_t *vam = &vat_main;
16752 print (vam->ofp, "collector_address %U, collector_port %d, "
16753 "src_address %U, vrf_id %d, path_mtu %u, "
16754 "template_interval %u, udp_checksum %d",
16755 format_ip4_address, mp->collector_address,
16756 ntohs (mp->collector_port),
16757 format_ip4_address, mp->src_address,
16758 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
16759 ntohl (mp->template_interval), mp->udp_checksum);
16762 vam->result_ready = 1;
16766 vl_api_ipfix_exporter_details_t_handler_json
16767 (vl_api_ipfix_exporter_details_t * mp)
16769 vat_main_t *vam = &vat_main;
16770 vat_json_node_t node;
16771 struct in_addr collector_address;
16772 struct in_addr src_address;
16774 vat_json_init_object (&node);
16775 clib_memcpy (&collector_address, &mp->collector_address,
16776 sizeof (collector_address));
16777 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
16778 vat_json_object_add_uint (&node, "collector_port",
16779 ntohs (mp->collector_port));
16780 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
16781 vat_json_object_add_ip4 (&node, "src_address", src_address);
16782 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
16783 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
16784 vat_json_object_add_uint (&node, "template_interval",
16785 ntohl (mp->template_interval));
16786 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
16788 vat_json_print (vam->ofp, &node);
16789 vat_json_free (&node);
16791 vam->result_ready = 1;
16795 api_ipfix_exporter_dump (vat_main_t * vam)
16797 vl_api_ipfix_exporter_dump_t *mp;
16800 /* Construct the API message */
16801 M (IPFIX_EXPORTER_DUMP, mp);
16810 api_ipfix_classify_stream_dump (vat_main_t * vam)
16812 vl_api_ipfix_classify_stream_dump_t *mp;
16815 /* Construct the API message */
16816 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
16827 vl_api_ipfix_classify_stream_details_t_handler
16828 (vl_api_ipfix_classify_stream_details_t * mp)
16830 vat_main_t *vam = &vat_main;
16831 print (vam->ofp, "domain_id %d, src_port %d",
16832 ntohl (mp->domain_id), ntohs (mp->src_port));
16834 vam->result_ready = 1;
16838 vl_api_ipfix_classify_stream_details_t_handler_json
16839 (vl_api_ipfix_classify_stream_details_t * mp)
16841 vat_main_t *vam = &vat_main;
16842 vat_json_node_t node;
16844 vat_json_init_object (&node);
16845 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
16846 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
16848 vat_json_print (vam->ofp, &node);
16849 vat_json_free (&node);
16851 vam->result_ready = 1;
16855 api_ipfix_classify_table_dump (vat_main_t * vam)
16857 vl_api_ipfix_classify_table_dump_t *mp;
16858 vl_api_control_ping_t *mp_ping;
16861 if (!vam->json_output)
16863 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
16864 "transport_protocol");
16867 /* Construct the API message */
16868 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
16873 /* Use a control ping for synchronization */
16874 M (CONTROL_PING, mp_ping);
16882 vl_api_ipfix_classify_table_details_t_handler
16883 (vl_api_ipfix_classify_table_details_t * mp)
16885 vat_main_t *vam = &vat_main;
16886 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
16887 mp->transport_protocol);
16891 vl_api_ipfix_classify_table_details_t_handler_json
16892 (vl_api_ipfix_classify_table_details_t * mp)
16894 vat_json_node_t *node = NULL;
16895 vat_main_t *vam = &vat_main;
16897 if (VAT_JSON_ARRAY != vam->json_tree.type)
16899 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16900 vat_json_init_array (&vam->json_tree);
16903 node = vat_json_array_add (&vam->json_tree);
16904 vat_json_init_object (node);
16906 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
16907 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
16908 vat_json_object_add_uint (node, "transport_protocol",
16909 mp->transport_protocol);
16913 api_sw_interface_span_enable_disable (vat_main_t * vam)
16915 unformat_input_t *i = vam->input;
16916 vl_api_sw_interface_span_enable_disable_t *mp;
16917 u32 src_sw_if_index = ~0;
16918 u32 dst_sw_if_index = ~0;
16922 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16925 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
16927 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
16931 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
16933 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16935 else if (unformat (i, "disable"))
16937 else if (unformat (i, "rx"))
16939 else if (unformat (i, "tx"))
16941 else if (unformat (i, "both"))
16947 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
16949 mp->sw_if_index_from = htonl (src_sw_if_index);
16950 mp->sw_if_index_to = htonl (dst_sw_if_index);
16959 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16962 vat_main_t *vam = &vat_main;
16963 u8 *sw_if_from_name = 0;
16964 u8 *sw_if_to_name = 0;
16965 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16966 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16967 char *states[] = { "none", "rx", "tx", "both" };
16971 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16973 if ((u32) p->value[0] == sw_if_index_from)
16975 sw_if_from_name = (u8 *)(p->key);
16979 if ((u32) p->value[0] == sw_if_index_to)
16981 sw_if_to_name = (u8 *)(p->key);
16982 if (sw_if_from_name)
16987 print (vam->ofp, "%20s => %20s (%s)",
16988 sw_if_from_name, sw_if_to_name, states[mp->state]);
16992 vl_api_sw_interface_span_details_t_handler_json
16993 (vl_api_sw_interface_span_details_t * mp)
16995 vat_main_t *vam = &vat_main;
16996 vat_json_node_t *node = NULL;
16997 u8 *sw_if_from_name = 0;
16998 u8 *sw_if_to_name = 0;
16999 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17000 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17004 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17006 if ((u32) p->value[0] == sw_if_index_from)
17008 sw_if_from_name = (u8 *)(p->key);
17012 if ((u32) p->value[0] == sw_if_index_to)
17014 sw_if_to_name = (u8 *)(p->key);
17015 if (sw_if_from_name)
17021 if (VAT_JSON_ARRAY != vam->json_tree.type)
17023 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17024 vat_json_init_array (&vam->json_tree);
17026 node = vat_json_array_add (&vam->json_tree);
17028 vat_json_init_object (node);
17029 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
17030 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
17031 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
17032 if (0 != sw_if_to_name)
17034 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
17036 vat_json_object_add_uint (node, "state", mp->state);
17040 api_sw_interface_span_dump (vat_main_t * vam)
17042 vl_api_sw_interface_span_dump_t *mp;
17043 vl_api_control_ping_t *mp_ping;
17046 M (SW_INTERFACE_SPAN_DUMP, mp);
17049 /* Use a control ping for synchronization */
17050 M (CONTROL_PING, mp_ping);
17058 api_pg_create_interface (vat_main_t * vam)
17060 unformat_input_t *input = vam->input;
17061 vl_api_pg_create_interface_t *mp;
17065 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17067 if (unformat (input, "if_id %d", &if_id))
17074 errmsg ("missing pg interface index");
17078 /* Construct the API message */
17079 M (PG_CREATE_INTERFACE, mp);
17081 mp->interface_id = ntohl (if_id);
17089 api_pg_capture (vat_main_t * vam)
17091 unformat_input_t *input = vam->input;
17092 vl_api_pg_capture_t *mp;
17097 u8 pcap_file_set = 0;
17100 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17102 if (unformat (input, "if_id %d", &if_id))
17104 else if (unformat (input, "pcap %s", &pcap_file))
17106 else if (unformat (input, "count %d", &count))
17108 else if (unformat (input, "disable"))
17115 errmsg ("missing pg interface index");
17118 if (pcap_file_set > 0)
17120 if (vec_len (pcap_file) > 255)
17122 errmsg ("pcap file name is too long");
17127 u32 name_len = vec_len (pcap_file);
17128 /* Construct the API message */
17129 M (PG_CAPTURE, mp);
17131 mp->interface_id = ntohl (if_id);
17132 mp->is_enabled = enable;
17133 mp->count = ntohl (count);
17134 mp->pcap_name_length = ntohl (name_len);
17135 if (pcap_file_set != 0)
17137 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
17139 vec_free (pcap_file);
17147 api_pg_enable_disable (vat_main_t * vam)
17149 unformat_input_t *input = vam->input;
17150 vl_api_pg_enable_disable_t *mp;
17153 u8 stream_name_set = 0;
17154 u8 *stream_name = 0;
17156 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17158 if (unformat (input, "stream %s", &stream_name))
17159 stream_name_set = 1;
17160 else if (unformat (input, "disable"))
17166 if (stream_name_set > 0)
17168 if (vec_len (stream_name) > 255)
17170 errmsg ("stream name too long");
17175 u32 name_len = vec_len (stream_name);
17176 /* Construct the API message */
17177 M (PG_ENABLE_DISABLE, mp);
17179 mp->is_enabled = enable;
17180 if (stream_name_set != 0)
17182 mp->stream_name_length = ntohl (name_len);
17183 clib_memcpy (mp->stream_name, stream_name, name_len);
17185 vec_free (stream_name);
17193 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
17195 unformat_input_t *input = vam->input;
17196 vl_api_ip_source_and_port_range_check_add_del_t *mp;
17198 u16 *low_ports = 0;
17199 u16 *high_ports = 0;
17202 ip4_address_t ip4_addr;
17203 ip6_address_t ip6_addr;
17212 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17214 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
17220 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
17225 else if (unformat (input, "vrf %d", &vrf_id))
17227 else if (unformat (input, "del"))
17229 else if (unformat (input, "port %d", &tmp))
17231 if (tmp == 0 || tmp > 65535)
17233 errmsg ("port %d out of range", tmp);
17237 this_hi = this_low + 1;
17238 vec_add1 (low_ports, this_low);
17239 vec_add1 (high_ports, this_hi);
17241 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
17243 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
17245 errmsg ("incorrect range parameters");
17249 /* Note: in debug CLI +1 is added to high before
17250 passing to real fn that does "the work"
17251 (ip_source_and_port_range_check_add_del).
17252 This fn is a wrapper around the binary API fn a
17253 control plane will call, which expects this increment
17254 to have occurred. Hence letting the binary API control
17255 plane fn do the increment for consistency between VAT
17256 and other control planes.
17259 vec_add1 (low_ports, this_low);
17260 vec_add1 (high_ports, this_hi);
17266 if (prefix_set == 0)
17268 errmsg ("<address>/<mask> not specified");
17274 errmsg ("VRF ID required, not specified");
17281 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17285 if (vec_len (low_ports) == 0)
17287 errmsg ("At least one port or port range required");
17291 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
17293 mp->is_add = is_add;
17298 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
17303 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
17306 mp->mask_length = length;
17307 mp->number_of_ranges = vec_len (low_ports);
17309 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
17310 vec_free (low_ports);
17312 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
17313 vec_free (high_ports);
17315 mp->vrf_id = ntohl (vrf_id);
17323 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
17325 unformat_input_t *input = vam->input;
17326 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
17327 u32 sw_if_index = ~0;
17329 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
17330 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
17334 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17336 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17338 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17340 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
17342 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
17344 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
17346 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
17348 else if (unformat (input, "del"))
17354 if (sw_if_index == ~0)
17356 errmsg ("Interface required but not specified");
17362 errmsg ("VRF ID required but not specified");
17366 if (tcp_out_vrf_id == 0
17367 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
17370 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17374 /* Construct the API message */
17375 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
17377 mp->sw_if_index = ntohl (sw_if_index);
17378 mp->is_add = is_add;
17379 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
17380 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
17381 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
17382 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
17387 /* Wait for a reply... */
17393 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
17395 unformat_input_t *i = vam->input;
17396 vl_api_ipsec_gre_add_del_tunnel_t *mp;
17397 u32 local_sa_id = 0;
17398 u32 remote_sa_id = 0;
17399 ip4_address_t src_address;
17400 ip4_address_t dst_address;
17404 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17406 if (unformat (i, "local_sa %d", &local_sa_id))
17408 else if (unformat (i, "remote_sa %d", &remote_sa_id))
17410 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
17412 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
17414 else if (unformat (i, "del"))
17418 clib_warning ("parse error '%U'", format_unformat_error, i);
17423 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
17425 mp->local_sa_id = ntohl (local_sa_id);
17426 mp->remote_sa_id = ntohl (remote_sa_id);
17427 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
17428 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
17429 mp->is_add = is_add;
17437 api_punt (vat_main_t * vam)
17439 unformat_input_t *i = vam->input;
17447 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17449 if (unformat (i, "ip %d", &ipv))
17451 else if (unformat (i, "protocol %d", &protocol))
17453 else if (unformat (i, "port %d", &port))
17455 else if (unformat (i, "del"))
17459 clib_warning ("parse error '%U'", format_unformat_error, i);
17466 mp->is_add = (u8) is_add;
17467 mp->ipv = (u8) ipv;
17468 mp->l4_protocol = (u8) protocol;
17469 mp->l4_port = htons ((u16) port);
17476 static void vl_api_ipsec_gre_tunnel_details_t_handler
17477 (vl_api_ipsec_gre_tunnel_details_t * mp)
17479 vat_main_t *vam = &vat_main;
17481 print (vam->ofp, "%11d%15U%15U%14d%14d",
17482 ntohl (mp->sw_if_index),
17483 format_ip4_address, &mp->src_address,
17484 format_ip4_address, &mp->dst_address,
17485 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
17488 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
17489 (vl_api_ipsec_gre_tunnel_details_t * mp)
17491 vat_main_t *vam = &vat_main;
17492 vat_json_node_t *node = NULL;
17493 struct in_addr ip4;
17495 if (VAT_JSON_ARRAY != vam->json_tree.type)
17497 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17498 vat_json_init_array (&vam->json_tree);
17500 node = vat_json_array_add (&vam->json_tree);
17502 vat_json_init_object (node);
17503 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17504 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
17505 vat_json_object_add_ip4 (node, "src_address", ip4);
17506 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
17507 vat_json_object_add_ip4 (node, "dst_address", ip4);
17508 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
17509 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
17513 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
17515 unformat_input_t *i = vam->input;
17516 vl_api_ipsec_gre_tunnel_dump_t *mp;
17517 vl_api_control_ping_t *mp_ping;
17519 u8 sw_if_index_set = 0;
17522 /* Parse args required to build the message */
17523 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17525 if (unformat (i, "sw_if_index %d", &sw_if_index))
17526 sw_if_index_set = 1;
17531 if (sw_if_index_set == 0)
17536 if (!vam->json_output)
17538 print (vam->ofp, "%11s%15s%15s%14s%14s",
17539 "sw_if_index", "src_address", "dst_address",
17540 "local_sa_id", "remote_sa_id");
17543 /* Get list of gre-tunnel interfaces */
17544 M (IPSEC_GRE_TUNNEL_DUMP, mp);
17546 mp->sw_if_index = htonl (sw_if_index);
17550 /* Use a control ping for synchronization */
17551 M (CONTROL_PING, mp_ping);
17559 api_delete_subif (vat_main_t * vam)
17561 unformat_input_t *i = vam->input;
17562 vl_api_delete_subif_t *mp;
17563 u32 sw_if_index = ~0;
17566 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17568 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17570 if (unformat (i, "sw_if_index %d", &sw_if_index))
17576 if (sw_if_index == ~0)
17578 errmsg ("missing sw_if_index");
17582 /* Construct the API message */
17583 M (DELETE_SUBIF, mp);
17584 mp->sw_if_index = ntohl (sw_if_index);
17591 #define foreach_pbb_vtr_op \
17592 _("disable", L2_VTR_DISABLED) \
17593 _("pop", L2_VTR_POP_2) \
17594 _("push", L2_VTR_PUSH_2)
17597 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
17599 unformat_input_t *i = vam->input;
17600 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
17601 u32 sw_if_index = ~0, vtr_op = ~0;
17602 u16 outer_tag = ~0;
17603 u8 dmac[6], smac[6];
17604 u8 dmac_set = 0, smac_set = 0;
17610 /* Shut up coverity */
17611 memset (dmac, 0, sizeof (dmac));
17612 memset (smac, 0, sizeof (smac));
17614 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17616 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17618 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17620 else if (unformat (i, "vtr_op %d", &vtr_op))
17622 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
17625 else if (unformat (i, "translate_pbb_stag"))
17627 if (unformat (i, "%d", &tmp))
17629 vtr_op = L2_VTR_TRANSLATE_2_1;
17635 ("translate_pbb_stag operation requires outer tag definition");
17639 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
17641 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
17643 else if (unformat (i, "sid %d", &sid))
17645 else if (unformat (i, "vlanid %d", &tmp))
17649 clib_warning ("parse error '%U'", format_unformat_error, i);
17654 if ((sw_if_index == ~0) || (vtr_op == ~0))
17656 errmsg ("missing sw_if_index or vtr operation");
17659 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
17660 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
17663 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
17667 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
17668 mp->sw_if_index = ntohl (sw_if_index);
17669 mp->vtr_op = ntohl (vtr_op);
17670 mp->outer_tag = ntohs (outer_tag);
17671 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
17672 clib_memcpy (mp->b_smac, smac, sizeof (smac));
17673 mp->b_vlanid = ntohs (vlanid);
17674 mp->i_sid = ntohl (sid);
17682 api_flow_classify_set_interface (vat_main_t * vam)
17684 unformat_input_t *i = vam->input;
17685 vl_api_flow_classify_set_interface_t *mp;
17687 int sw_if_index_set;
17688 u32 ip4_table_index = ~0;
17689 u32 ip6_table_index = ~0;
17693 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17695 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17696 sw_if_index_set = 1;
17697 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17698 sw_if_index_set = 1;
17699 else if (unformat (i, "del"))
17701 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17703 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17707 clib_warning ("parse error '%U'", format_unformat_error, i);
17712 if (sw_if_index_set == 0)
17714 errmsg ("missing interface name or sw_if_index");
17718 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
17720 mp->sw_if_index = ntohl (sw_if_index);
17721 mp->ip4_table_index = ntohl (ip4_table_index);
17722 mp->ip6_table_index = ntohl (ip6_table_index);
17723 mp->is_add = is_add;
17731 api_flow_classify_dump (vat_main_t * vam)
17733 unformat_input_t *i = vam->input;
17734 vl_api_flow_classify_dump_t *mp;
17735 vl_api_control_ping_t *mp_ping;
17736 u8 type = FLOW_CLASSIFY_N_TABLES;
17739 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
17743 errmsg ("classify table type must be specified");
17747 if (!vam->json_output)
17749 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17752 M (FLOW_CLASSIFY_DUMP, mp);
17757 /* Use a control ping for synchronization */
17758 M (CONTROL_PING, mp_ping);
17761 /* Wait for a reply... */
17767 api_feature_enable_disable (vat_main_t * vam)
17769 unformat_input_t *i = vam->input;
17770 vl_api_feature_enable_disable_t *mp;
17772 u8 *feature_name = 0;
17773 u32 sw_if_index = ~0;
17777 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17779 if (unformat (i, "arc_name %s", &arc_name))
17781 else if (unformat (i, "feature_name %s", &feature_name))
17784 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17786 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17788 else if (unformat (i, "disable"))
17796 errmsg ("missing arc name");
17799 if (vec_len (arc_name) > 63)
17801 errmsg ("arc name too long");
17804 if (feature_name == 0)
17806 errmsg ("missing feature name");
17809 if (vec_len (feature_name) > 63)
17811 errmsg ("feature name too long");
17814 if (sw_if_index == ~0)
17816 errmsg ("missing interface name or sw_if_index");
17820 /* Construct the API message */
17821 M (FEATURE_ENABLE_DISABLE, mp);
17822 mp->sw_if_index = ntohl (sw_if_index);
17823 mp->enable = enable;
17824 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
17825 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
17826 vec_free (arc_name);
17827 vec_free (feature_name);
17835 api_sw_interface_tag_add_del (vat_main_t * vam)
17837 unformat_input_t *i = vam->input;
17838 vl_api_sw_interface_tag_add_del_t *mp;
17839 u32 sw_if_index = ~0;
17844 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17846 if (unformat (i, "tag %s", &tag))
17848 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17850 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17852 else if (unformat (i, "del"))
17858 if (sw_if_index == ~0)
17860 errmsg ("missing interface name or sw_if_index");
17864 if (enable && (tag == 0))
17866 errmsg ("no tag specified");
17870 /* Construct the API message */
17871 M (SW_INTERFACE_TAG_ADD_DEL, mp);
17872 mp->sw_if_index = ntohl (sw_if_index);
17873 mp->is_add = enable;
17875 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
17883 static void vl_api_l2_xconnect_details_t_handler
17884 (vl_api_l2_xconnect_details_t * mp)
17886 vat_main_t *vam = &vat_main;
17888 print (vam->ofp, "%15d%15d",
17889 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
17892 static void vl_api_l2_xconnect_details_t_handler_json
17893 (vl_api_l2_xconnect_details_t * mp)
17895 vat_main_t *vam = &vat_main;
17896 vat_json_node_t *node = NULL;
17898 if (VAT_JSON_ARRAY != vam->json_tree.type)
17900 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17901 vat_json_init_array (&vam->json_tree);
17903 node = vat_json_array_add (&vam->json_tree);
17905 vat_json_init_object (node);
17906 vat_json_object_add_uint (node, "rx_sw_if_index",
17907 ntohl (mp->rx_sw_if_index));
17908 vat_json_object_add_uint (node, "tx_sw_if_index",
17909 ntohl (mp->tx_sw_if_index));
17913 api_l2_xconnect_dump (vat_main_t * vam)
17915 vl_api_l2_xconnect_dump_t *mp;
17916 vl_api_control_ping_t *mp_ping;
17919 if (!vam->json_output)
17921 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
17924 M (L2_XCONNECT_DUMP, mp);
17928 /* Use a control ping for synchronization */
17929 M (CONTROL_PING, mp_ping);
17937 api_sw_interface_set_mtu (vat_main_t * vam)
17939 unformat_input_t *i = vam->input;
17940 vl_api_sw_interface_set_mtu_t *mp;
17941 u32 sw_if_index = ~0;
17945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17947 if (unformat (i, "mtu %d", &mtu))
17949 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17951 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17957 if (sw_if_index == ~0)
17959 errmsg ("missing interface name or sw_if_index");
17965 errmsg ("no mtu specified");
17969 /* Construct the API message */
17970 M (SW_INTERFACE_SET_MTU, mp);
17971 mp->sw_if_index = ntohl (sw_if_index);
17972 mp->mtu = ntohs ((u16) mtu);
17981 q_or_quit (vat_main_t * vam)
17983 #if VPP_API_TEST_BUILTIN == 0
17984 longjmp (vam->jump_buf, 1);
17986 return 0; /* not so much */
17990 q (vat_main_t * vam)
17992 return q_or_quit (vam);
17996 quit (vat_main_t * vam)
17998 return q_or_quit (vam);
18002 comment (vat_main_t * vam)
18008 cmd_cmp (void *a1, void *a2)
18013 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
18017 help (vat_main_t * vam)
18022 unformat_input_t *i = vam->input;
18025 if (unformat (i, "%s", &name))
18029 vec_add1 (name, 0);
18031 hs = hash_get_mem (vam->help_by_name, name);
18033 print (vam->ofp, "usage: %s %s", name, hs[0]);
18035 print (vam->ofp, "No such msg / command '%s'", name);
18040 print (vam->ofp, "Help is available for the following:");
18043 hash_foreach_pair (p, vam->function_by_name,
18045 vec_add1 (cmds, (u8 *)(p->key));
18049 vec_sort_with_function (cmds, cmd_cmp);
18051 for (j = 0; j < vec_len (cmds); j++)
18052 print (vam->ofp, "%s", cmds[j]);
18059 set (vat_main_t * vam)
18061 u8 *name = 0, *value = 0;
18062 unformat_input_t *i = vam->input;
18064 if (unformat (i, "%s", &name))
18066 /* The input buffer is a vector, not a string. */
18067 value = vec_dup (i->buffer);
18068 vec_delete (value, i->index, 0);
18069 /* Almost certainly has a trailing newline */
18070 if (value[vec_len (value) - 1] == '\n')
18071 value[vec_len (value) - 1] = 0;
18072 /* Make sure it's a proper string, one way or the other */
18073 vec_add1 (value, 0);
18074 (void) clib_macro_set_value (&vam->macro_main,
18075 (char *) name, (char *) value);
18078 errmsg ("usage: set <name> <value>");
18086 unset (vat_main_t * vam)
18090 if (unformat (vam->input, "%s", &name))
18091 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
18092 errmsg ("unset: %s wasn't set", name);
18105 macro_sort_cmp (void *a1, void *a2)
18107 macro_sort_t *s1 = a1;
18108 macro_sort_t *s2 = a2;
18110 return strcmp ((char *) (s1->name), (char *) (s2->name));
18114 dump_macro_table (vat_main_t * vam)
18116 macro_sort_t *sort_me = 0, *sm;
18121 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
18123 vec_add2 (sort_me, sm, 1);
18124 sm->name = (u8 *)(p->key);
18125 sm->value = (u8 *) (p->value[0]);
18129 vec_sort_with_function (sort_me, macro_sort_cmp);
18131 if (vec_len (sort_me))
18132 print (vam->ofp, "%-15s%s", "Name", "Value");
18134 print (vam->ofp, "The macro table is empty...");
18136 for (i = 0; i < vec_len (sort_me); i++)
18137 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
18142 dump_node_table (vat_main_t * vam)
18145 vlib_node_t *node, *next_node;
18147 if (vec_len (vam->graph_nodes) == 0)
18149 print (vam->ofp, "Node table empty, issue get_node_graph...");
18153 for (i = 0; i < vec_len (vam->graph_nodes); i++)
18155 node = vam->graph_nodes[i];
18156 print (vam->ofp, "[%d] %s", i, node->name);
18157 for (j = 0; j < vec_len (node->next_nodes); j++)
18159 if (node->next_nodes[j] != ~0)
18161 next_node = vam->graph_nodes[node->next_nodes[j]];
18162 print (vam->ofp, " [%d] %s", j, next_node->name);
18170 value_sort_cmp (void *a1, void *a2)
18172 name_sort_t *n1 = a1;
18173 name_sort_t *n2 = a2;
18175 if (n1->value < n2->value)
18177 if (n1->value > n2->value)
18184 dump_msg_api_table (vat_main_t * vam)
18186 api_main_t *am = &api_main;
18187 name_sort_t *nses = 0, *ns;
18192 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
18194 vec_add2 (nses, ns, 1);
18195 ns->name = (u8 *)(hp->key);
18196 ns->value = (u32) hp->value[0];
18200 vec_sort_with_function (nses, value_sort_cmp);
18202 for (i = 0; i < vec_len (nses); i++)
18203 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
18209 get_msg_id (vat_main_t * vam)
18214 if (unformat (vam->input, "%s", &name_and_crc))
18216 message_index = vl_api_get_msg_index (name_and_crc);
18217 if (message_index == ~0)
18219 print (vam->ofp, " '%s' not found", name_and_crc);
18222 print (vam->ofp, " '%s' has message index %d",
18223 name_and_crc, message_index);
18226 errmsg ("name_and_crc required...");
18231 search_node_table (vat_main_t * vam)
18233 unformat_input_t *line_input = vam->input;
18236 vlib_node_t *node, *next_node;
18239 if (vam->graph_node_index_by_name == 0)
18241 print (vam->ofp, "Node table empty, issue get_node_graph...");
18245 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
18247 if (unformat (line_input, "%s", &node_to_find))
18249 vec_add1 (node_to_find, 0);
18250 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
18253 print (vam->ofp, "%s not found...", node_to_find);
18256 node = vam->graph_nodes[p[0]];
18257 print (vam->ofp, "[%d] %s", p[0], node->name);
18258 for (j = 0; j < vec_len (node->next_nodes); j++)
18260 if (node->next_nodes[j] != ~0)
18262 next_node = vam->graph_nodes[node->next_nodes[j]];
18263 print (vam->ofp, " [%d] %s", j, next_node->name);
18270 clib_warning ("parse error '%U'", format_unformat_error,
18276 vec_free (node_to_find);
18285 script (vat_main_t * vam)
18287 #if (VPP_API_TEST_BUILTIN==0)
18289 char *save_current_file;
18290 unformat_input_t save_input;
18291 jmp_buf save_jump_buf;
18292 u32 save_line_number;
18294 FILE *new_fp, *save_ifp;
18296 if (unformat (vam->input, "%s", &s))
18298 new_fp = fopen ((char *) s, "r");
18301 errmsg ("Couldn't open script file %s", s);
18308 errmsg ("Missing script name");
18312 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
18313 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
18314 save_ifp = vam->ifp;
18315 save_line_number = vam->input_line_number;
18316 save_current_file = (char *) vam->current_file;
18318 vam->input_line_number = 0;
18320 vam->current_file = s;
18323 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
18324 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
18325 vam->ifp = save_ifp;
18326 vam->input_line_number = save_line_number;
18327 vam->current_file = (u8 *) save_current_file;
18332 clib_warning ("use the exec command...");
18338 echo (vat_main_t * vam)
18340 print (vam->ofp, "%v", vam->input->buffer);
18344 /* List of API message constructors, CLI names map to api_xxx */
18345 #define foreach_vpe_api_msg \
18346 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
18347 _(sw_interface_dump,"") \
18348 _(sw_interface_set_flags, \
18349 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
18350 _(sw_interface_add_del_address, \
18351 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
18352 _(sw_interface_set_table, \
18353 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
18354 _(sw_interface_set_mpls_enable, \
18355 "<intfc> | sw_if_index [disable | dis]") \
18356 _(sw_interface_set_vpath, \
18357 "<intfc> | sw_if_index <id> enable | disable") \
18358 _(sw_interface_set_vxlan_bypass, \
18359 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
18360 _(sw_interface_set_l2_xconnect, \
18361 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18362 "enable | disable") \
18363 _(sw_interface_set_l2_bridge, \
18364 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
18365 "[shg <split-horizon-group>] [bvi]\n" \
18366 "enable | disable") \
18367 _(bridge_domain_add_del, \
18368 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
18369 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
18371 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
18373 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
18375 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
18377 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
18379 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
18381 "<vpp-if-name> | sw_if_index <id>") \
18382 _(sw_interface_tap_dump, "") \
18383 _(ip_add_del_route, \
18384 "<addr>/<mask> via <addr> [table-id <n>]\n" \
18385 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18386 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18387 "[multipath] [count <n>]") \
18388 _(ip_mroute_add_del, \
18389 "<src> <grp>/<mask> [table-id <n>]\n" \
18390 "[<intfc> | sw_if_index <id>] [local] [del]") \
18391 _(mpls_route_add_del, \
18392 "<label> <eos> via <addr> [table-id <n>]\n" \
18393 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18394 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18395 "[multipath] [count <n>]") \
18396 _(mpls_ip_bind_unbind, \
18397 "<label> <addr/len>") \
18398 _(mpls_tunnel_add_del, \
18399 " via <addr> [table-id <n>]\n" \
18400 "sw_if_index <id>] [l2] [del]") \
18401 _(proxy_arp_add_del, \
18402 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
18403 _(proxy_arp_intfc_enable_disable, \
18404 "<intfc> | sw_if_index <id> enable | disable") \
18405 _(sw_interface_set_unnumbered, \
18406 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
18407 _(ip_neighbor_add_del, \
18408 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
18409 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
18410 _(reset_vrf, "vrf <id> [ipv6]") \
18411 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
18412 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
18413 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
18414 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
18415 "[outer_vlan_id_any][inner_vlan_id_any]") \
18416 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
18417 _(reset_fib, "vrf <n> [ipv6]") \
18418 _(dhcp_proxy_config, \
18419 "svr <v46-address> src <v46-address>\n" \
18420 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
18421 _(dhcp_proxy_set_vss, \
18422 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
18423 _(dhcp_proxy_dump, "ip6") \
18424 _(dhcp_client_config, \
18425 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
18426 _(set_ip_flow_hash, \
18427 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
18428 _(sw_interface_ip6_enable_disable, \
18429 "<intfc> | sw_if_index <id> enable | disable") \
18430 _(sw_interface_ip6_set_link_local_address, \
18431 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
18432 _(ip6nd_proxy_add_del, \
18433 "<intfc> | sw_if_index <id> <ip6-address>") \
18434 _(ip6nd_proxy_dump, "") \
18435 _(sw_interface_ip6nd_ra_prefix, \
18436 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
18437 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
18438 "[nolink] [isno]") \
18439 _(sw_interface_ip6nd_ra_config, \
18440 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
18441 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
18442 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
18443 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
18444 _(l2_patch_add_del, \
18445 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18446 "enable | disable") \
18447 _(sr_localsid_add_del, \
18448 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
18449 "fib-table <num> (end.psp) sw_if_index <num>") \
18450 _(classify_add_del_table, \
18451 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
18452 " [del] [del-chain] mask <mask-value>\n" \
18453 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
18454 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
18455 _(classify_add_del_session, \
18456 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
18457 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
18458 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
18459 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
18460 _(classify_set_interface_ip_table, \
18461 "<intfc> | sw_if_index <nn> table <nn>") \
18462 _(classify_set_interface_l2_tables, \
18463 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18464 " [other-table <nn>]") \
18465 _(get_node_index, "node <node-name") \
18466 _(add_node_next, "node <node-name> next <next-node-name>") \
18467 _(l2tpv3_create_tunnel, \
18468 "client_address <ip6-addr> our_address <ip6-addr>\n" \
18469 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
18470 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
18471 _(l2tpv3_set_tunnel_cookies, \
18472 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
18473 "[new_remote_cookie <nn>]\n") \
18474 _(l2tpv3_interface_enable_disable, \
18475 "<intfc> | sw_if_index <nn> enable | disable") \
18476 _(l2tpv3_set_lookup_key, \
18477 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
18478 _(sw_if_l2tpv3_tunnel_dump, "") \
18479 _(vxlan_add_del_tunnel, \
18480 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
18481 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
18482 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
18483 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18484 _(gre_add_del_tunnel, \
18485 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
18486 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18487 _(l2_fib_clear_table, "") \
18488 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
18489 _(l2_interface_vlan_tag_rewrite, \
18490 "<intfc> | sw_if_index <nn> \n" \
18491 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
18492 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
18493 _(create_vhost_user_if, \
18494 "socket <filename> [server] [renumber <dev_instance>] " \
18495 "[mac <mac_address>]") \
18496 _(modify_vhost_user_if, \
18497 "<intfc> | sw_if_index <nn> socket <filename>\n" \
18498 "[server] [renumber <dev_instance>]") \
18499 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
18500 _(sw_interface_vhost_user_dump, "") \
18501 _(show_version, "") \
18502 _(vxlan_gpe_add_del_tunnel, \
18503 "local <addr> remote <addr> vni <nn>\n" \
18504 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
18505 "[next-ethernet] [next-nsh]\n") \
18506 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18507 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
18508 _(interface_name_renumber, \
18509 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
18510 _(input_acl_set_interface, \
18511 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18512 " [l2-table <nn>] [del]") \
18513 _(want_ip4_arp_events, "address <ip4-address> [del]") \
18514 _(want_ip6_nd_events, "address <ip6-address> [del]") \
18515 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
18516 _(ip_dump, "ipv4 | ipv6") \
18517 _(ipsec_spd_add_del, "spd_id <n> [del]") \
18518 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
18520 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
18521 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
18522 " integ_alg <alg> integ_key <hex>") \
18523 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
18524 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
18525 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
18526 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
18527 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
18528 _(ikev2_profile_add_del, "name <profile_name> [del]") \
18529 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
18530 "(auth_data 0x<data> | auth_data <data>)") \
18531 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
18532 "(id_data 0x<data> | id_data <data>) (local|remote)") \
18533 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
18534 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
18535 "(local|remote)") \
18536 _(ikev2_set_local_key, "file <absolute_file_path>") \
18537 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
18538 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18539 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18540 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
18541 _(ikev2_initiate_sa_init, "<profile_name>") \
18542 _(ikev2_initiate_del_ike_sa, "<ispi>") \
18543 _(ikev2_initiate_del_child_sa, "<ispi>") \
18544 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
18545 _(delete_loopback,"sw_if_index <nn>") \
18546 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
18547 _(map_add_domain, \
18548 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
18549 "ip6-src <ip6addr> " \
18550 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
18551 _(map_del_domain, "index <n>") \
18552 _(map_add_del_rule, \
18553 "index <n> psid <n> dst <ip6addr> [del]") \
18554 _(map_domain_dump, "") \
18555 _(map_rule_dump, "index <map-domain>") \
18556 _(want_interface_events, "enable|disable") \
18557 _(want_stats,"enable|disable") \
18558 _(get_first_msg_id, "client <name>") \
18559 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
18560 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
18561 "fib-id <nn> [ip4][ip6][default]") \
18562 _(get_node_graph, " ") \
18563 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
18564 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
18565 _(ioam_disable, "") \
18566 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
18567 " sw_if_index <sw_if_index> p <priority> " \
18568 "w <weight>] [del]") \
18569 _(one_add_del_locator, "locator-set <locator_name> " \
18570 "iface <intf> | sw_if_index <sw_if_index> " \
18571 "p <priority> w <weight> [del]") \
18572 _(one_add_del_local_eid,"vni <vni> eid " \
18573 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18574 "locator-set <locator_name> [del]" \
18575 "[key-id sha1|sha256 secret-key <secret-key>]")\
18576 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
18577 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
18578 _(one_enable_disable, "enable|disable") \
18579 _(one_map_register_enable_disable, "enable|disable") \
18580 _(one_rloc_probe_enable_disable, "enable|disable") \
18581 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18583 "rloc <locator> p <prio> " \
18584 "w <weight> [rloc <loc> ... ] " \
18585 "action <action> [del-all]") \
18586 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18588 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18589 _(one_use_petr, "ip-address> | disable") \
18590 _(one_map_request_mode, "src-dst|dst-only") \
18591 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18592 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18593 _(one_locator_set_dump, "[local | remote]") \
18594 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
18595 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18596 "[local] | [remote]") \
18597 _(one_stats_enable_disable, "enable|disalbe") \
18598 _(show_one_stats_enable_disable, "") \
18599 _(one_eid_table_vni_dump, "") \
18600 _(one_eid_table_map_dump, "l2|l3") \
18601 _(one_map_resolver_dump, "") \
18602 _(one_map_server_dump, "") \
18603 _(one_adjacencies_get, "vni <vni>") \
18604 _(show_one_rloc_probe_state, "") \
18605 _(show_one_map_register_state, "") \
18606 _(show_one_status, "") \
18607 _(one_stats_dump, "") \
18608 _(one_get_map_request_itr_rlocs, "") \
18609 _(show_one_pitr, "") \
18610 _(show_one_use_petr, "") \
18611 _(show_one_map_request_mode, "") \
18612 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
18613 " sw_if_index <sw_if_index> p <priority> " \
18614 "w <weight>] [del]") \
18615 _(lisp_add_del_locator, "locator-set <locator_name> " \
18616 "iface <intf> | sw_if_index <sw_if_index> " \
18617 "p <priority> w <weight> [del]") \
18618 _(lisp_add_del_local_eid,"vni <vni> eid " \
18619 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18620 "locator-set <locator_name> [del]" \
18621 "[key-id sha1|sha256 secret-key <secret-key>]") \
18622 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
18623 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
18624 _(lisp_enable_disable, "enable|disable") \
18625 _(lisp_map_register_enable_disable, "enable|disable") \
18626 _(lisp_rloc_probe_enable_disable, "enable|disable") \
18627 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18629 "rloc <locator> p <prio> " \
18630 "w <weight> [rloc <loc> ... ] " \
18631 "action <action> [del-all]") \
18632 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18634 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18635 _(lisp_use_petr, "<ip-address> | disable") \
18636 _(lisp_map_request_mode, "src-dst|dst-only") \
18637 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18638 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18639 _(lisp_locator_set_dump, "[local | remote]") \
18640 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
18641 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18642 "[local] | [remote]") \
18643 _(lisp_eid_table_vni_dump, "") \
18644 _(lisp_eid_table_map_dump, "l2|l3") \
18645 _(lisp_map_resolver_dump, "") \
18646 _(lisp_map_server_dump, "") \
18647 _(lisp_adjacencies_get, "vni <vni>") \
18648 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
18649 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
18650 _(gpe_set_encap_mode, "lisp|vxlan") \
18651 _(gpe_get_encap_mode, "") \
18652 _(lisp_gpe_add_del_iface, "up|down") \
18653 _(lisp_gpe_enable_disable, "enable|disable") \
18654 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
18655 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
18656 _(show_lisp_rloc_probe_state, "") \
18657 _(show_lisp_map_register_state, "") \
18658 _(show_lisp_status, "") \
18659 _(lisp_get_map_request_itr_rlocs, "") \
18660 _(show_lisp_pitr, "") \
18661 _(show_lisp_use_petr, "") \
18662 _(show_lisp_map_request_mode, "") \
18663 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
18664 _(af_packet_delete, "name <host interface name>") \
18665 _(policer_add_del, "name <policer name> <params> [del]") \
18666 _(policer_dump, "[name <policer name>]") \
18667 _(policer_classify_set_interface, \
18668 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18669 " [l2-table <nn>] [del]") \
18670 _(policer_classify_dump, "type [ip4|ip6|l2]") \
18671 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
18672 "[master|slave]") \
18673 _(netmap_delete, "name <interface name>") \
18674 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
18675 _(mpls_fib_dump, "") \
18676 _(classify_table_ids, "") \
18677 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
18678 _(classify_table_info, "table_id <nn>") \
18679 _(classify_session_dump, "table_id <nn>") \
18680 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
18681 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
18682 "[template_interval <nn>] [udp_checksum]") \
18683 _(ipfix_exporter_dump, "") \
18684 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
18685 _(ipfix_classify_stream_dump, "") \
18686 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
18687 _(ipfix_classify_table_dump, "") \
18688 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
18689 _(sw_interface_span_dump, "") \
18690 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
18691 _(pg_create_interface, "if_id <nn>") \
18692 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
18693 _(pg_enable_disable, "[stream <id>] disable") \
18694 _(ip_source_and_port_range_check_add_del, \
18695 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
18696 _(ip_source_and_port_range_check_interface_add_del, \
18697 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
18698 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
18699 _(ipsec_gre_add_del_tunnel, \
18700 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
18701 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
18702 _(delete_subif,"<intfc> | sw_if_index <nn>") \
18703 _(l2_interface_pbb_tag_rewrite, \
18704 "<intfc> | sw_if_index <nn> \n" \
18705 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
18706 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
18707 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
18708 _(flow_classify_set_interface, \
18709 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
18710 _(flow_classify_dump, "type [ip4|ip6]") \
18711 _(ip_fib_dump, "") \
18712 _(ip_mfib_dump, "") \
18713 _(ip6_fib_dump, "") \
18714 _(ip6_mfib_dump, "") \
18715 _(feature_enable_disable, "arc_name <arc_name> " \
18716 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
18717 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
18719 _(l2_xconnect_dump, "") \
18720 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
18721 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
18722 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
18724 /* List of command functions, CLI names map directly to functions */
18725 #define foreach_cli_function \
18726 _(comment, "usage: comment <ignore-rest-of-line>") \
18727 _(dump_interface_table, "usage: dump_interface_table") \
18728 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
18729 _(dump_ipv4_table, "usage: dump_ipv4_table") \
18730 _(dump_ipv6_table, "usage: dump_ipv6_table") \
18731 _(dump_stats_table, "usage: dump_stats_table") \
18732 _(dump_macro_table, "usage: dump_macro_table ") \
18733 _(dump_node_table, "usage: dump_node_table") \
18734 _(dump_msg_api_table, "usage: dump_msg_api_table") \
18735 _(get_msg_id, "usage: get_msg_id name_and_crc") \
18736 _(echo, "usage: echo <message>") \
18737 _(exec, "usage: exec <vpe-debug-CLI-command>") \
18738 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
18739 _(help, "usage: help") \
18740 _(q, "usage: quit") \
18741 _(quit, "usage: quit") \
18742 _(search_node_table, "usage: search_node_table <name>...") \
18743 _(set, "usage: set <variable-name> <value>") \
18744 _(script, "usage: script <file-name>") \
18745 _(unset, "usage: unset <variable-name>")
18748 static void vl_api_##n##_t_handler_uni \
18749 (vl_api_##n##_t * mp) \
18751 vat_main_t * vam = &vat_main; \
18752 if (vam->json_output) { \
18753 vl_api_##n##_t_handler_json(mp); \
18755 vl_api_##n##_t_handler(mp); \
18758 foreach_vpe_api_reply_msg;
18759 #if VPP_API_TEST_BUILTIN == 0
18760 foreach_standalone_reply_msg;
18765 vat_api_hookup (vat_main_t * vam)
18768 vl_msg_api_set_handlers(VL_API_##N, #n, \
18769 vl_api_##n##_t_handler_uni, \
18771 vl_api_##n##_t_endian, \
18772 vl_api_##n##_t_print, \
18773 sizeof(vl_api_##n##_t), 1);
18774 foreach_vpe_api_reply_msg;
18775 #if VPP_API_TEST_BUILTIN == 0
18776 foreach_standalone_reply_msg;
18780 #if (VPP_API_TEST_BUILTIN==0)
18781 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
18783 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
18785 vam->function_by_name = hash_create_string (0, sizeof (uword));
18787 vam->help_by_name = hash_create_string (0, sizeof (uword));
18790 /* API messages we can send */
18791 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18792 foreach_vpe_api_msg;
18796 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18797 foreach_vpe_api_msg;
18800 /* CLI functions */
18801 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
18802 foreach_cli_function;
18806 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18807 foreach_cli_function;
18811 #if VPP_API_TEST_BUILTIN
18812 static clib_error_t *
18813 vat_api_hookup_shim (vlib_main_t * vm)
18815 vat_api_hookup (&vat_main);
18819 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
18823 * fd.io coding-style-patch-verification: ON
18826 * eval: (c-set-style "gnu")