2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vlibapi/api.h>
22 #include <vlibmemory/api.h>
23 #include <vlibsocket/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/l2/l2_input.h>
26 #include <vnet/l2tp/l2tp.h>
27 #include <vnet/vxlan/vxlan.h>
28 #include <vnet/gre/gre.h>
29 #include <vnet/vxlan-gpe/vxlan_gpe.h>
30 #include <vnet/lisp-gpe/lisp_gpe.h>
32 #include <vpp/api/vpe_msg_enum.h>
33 #include <vnet/l2/l2_classify.h>
34 #include <vnet/l2/l2_vtr.h>
35 #include <vnet/classify/input_acl.h>
36 #include <vnet/classify/policer_classify.h>
37 #include <vnet/classify/flow_classify.h>
38 #include <vnet/mpls/mpls.h>
39 #include <vnet/ipsec/ipsec.h>
40 #include <vnet/ipsec/ikev2.h>
42 #include <vnet/map/map.h>
43 #include <vnet/cop/cop.h>
44 #include <vnet/ip/ip6_hop_by_hop.h>
45 #include <vnet/ip/ip_source_and_port_range_check.h>
46 #include <vnet/policer/xlate.h>
47 #include <vnet/span/span.h>
48 #include <vnet/policer/policer.h>
49 #include <vnet/policer/police.h>
50 #include <vnet/mfib/mfib_types.h>
52 #include "vat/json_format.h"
57 #define vl_typedefs /* define message structures */
58 #include <vpp/api/vpe_all_api_h.h>
61 /* declare message handlers for each api */
63 #define vl_endianfun /* define message structures */
64 #include <vpp/api/vpe_all_api_h.h>
67 /* instantiate all the print functions we know about */
68 #define vl_print(handle, ...)
70 #include <vpp/api/vpe_all_api_h.h>
73 #define __plugin_msg_base 0
74 #include <vlibapi/vat_helper_macros.h>
77 vat_time_now (vat_main_t * vam)
79 #if VPP_API_TEST_BUILTIN
80 return vlib_time_now (vam->vlib_main);
82 return clib_time_now (&vam->clib_time);
87 errmsg (char *fmt, ...)
89 vat_main_t *vam = &vat_main;
94 s = va_format (0, fmt, &va);
99 #if VPP_API_TEST_BUILTIN
100 vlib_cli_output (vam->vlib_main, (char *) s);
103 if (vam->ifp != stdin)
104 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
105 vam->input_line_number);
106 fformat (vam->ofp, (char *) s);
114 #if VPP_API_TEST_BUILTIN == 0
116 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
118 vat_main_t *vam = va_arg (*args, vat_main_t *);
119 u32 *result = va_arg (*args, u32 *);
123 if (!unformat (input, "%s", &if_name))
126 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
133 /* Parse an IP4 address %d.%d.%d.%d. */
135 unformat_ip4_address (unformat_input_t * input, va_list * args)
137 u8 *result = va_arg (*args, u8 *);
140 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
143 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
155 unformat_ethernet_address (unformat_input_t * input, va_list * args)
157 u8 *result = va_arg (*args, u8 *);
160 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
161 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
165 for (i = 0; i < 6; i++)
166 if (a[i] >= (1 << 8))
169 for (i = 0; i < 6; i++)
175 /* Returns ethernet type as an int in host byte order. */
177 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
180 u16 *result = va_arg (*args, u16 *);
184 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
186 if (type >= (1 << 16))
194 /* Parse an IP6 address. */
196 unformat_ip6_address (unformat_input_t * input, va_list * args)
198 ip6_address_t *result = va_arg (*args, ip6_address_t *);
200 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
201 uword c, n_colon, double_colon_index;
203 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
204 double_colon_index = ARRAY_LEN (hex_quads);
205 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
208 if (c >= '0' && c <= '9')
210 else if (c >= 'a' && c <= 'f')
211 hex_digit = c + 10 - 'a';
212 else if (c >= 'A' && c <= 'F')
213 hex_digit = c + 10 - 'A';
214 else if (c == ':' && n_colon < 2)
218 unformat_put_input (input);
222 /* Too many hex quads. */
223 if (n_hex_quads >= ARRAY_LEN (hex_quads))
228 hex_quad = (hex_quad << 4) | hex_digit;
230 /* Hex quad must fit in 16 bits. */
231 if (n_hex_digits >= 4)
238 /* Save position of :: */
241 /* More than one :: ? */
242 if (double_colon_index < ARRAY_LEN (hex_quads))
244 double_colon_index = n_hex_quads;
247 if (n_colon > 0 && n_hex_digits > 0)
249 hex_quads[n_hex_quads++] = hex_quad;
255 if (n_hex_digits > 0)
256 hex_quads[n_hex_quads++] = hex_quad;
261 /* Expand :: to appropriate number of zero hex quads. */
262 if (double_colon_index < ARRAY_LEN (hex_quads))
264 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
266 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
267 hex_quads[n_zero + i] = hex_quads[i];
269 for (i = 0; i < n_zero; i++)
270 hex_quads[double_colon_index + i] = 0;
272 n_hex_quads = ARRAY_LEN (hex_quads);
275 /* Too few hex quads given. */
276 if (n_hex_quads < ARRAY_LEN (hex_quads))
279 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
280 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
287 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
289 u32 *r = va_arg (*args, u32 *);
292 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
293 foreach_ipsec_policy_action
301 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
303 u32 *r = va_arg (*args, u32 *);
306 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
307 foreach_ipsec_crypto_alg
315 format_ipsec_crypto_alg (u8 * s, va_list * args)
317 u32 i = va_arg (*args, u32);
322 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
323 foreach_ipsec_crypto_alg
326 return format (s, "unknown");
328 return format (s, "%s", t);
332 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
334 u32 *r = va_arg (*args, u32 *);
337 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
338 foreach_ipsec_integ_alg
346 format_ipsec_integ_alg (u8 * s, va_list * args)
348 u32 i = va_arg (*args, u32);
353 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
354 foreach_ipsec_integ_alg
357 return format (s, "unknown");
359 return format (s, "%s", t);
363 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
365 u32 *r = va_arg (*args, u32 *);
368 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
369 foreach_ikev2_auth_method
377 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
379 u32 *r = va_arg (*args, u32 *);
382 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
383 foreach_ikev2_id_type
389 #else /* VPP_API_TEST_BUILTIN == 1 */
391 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
393 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
394 vnet_main_t *vnm = vnet_get_main ();
395 u32 *result = va_arg (*args, u32 *);
398 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
401 *result = sw_if_index;
404 #endif /* VPP_API_TEST_BUILTIN */
407 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
409 u8 *r = va_arg (*args, u8 *);
411 if (unformat (input, "kbps"))
412 *r = SSE2_QOS_RATE_KBPS;
413 else if (unformat (input, "pps"))
414 *r = SSE2_QOS_RATE_PPS;
421 unformat_policer_round_type (unformat_input_t * input, va_list * args)
423 u8 *r = va_arg (*args, u8 *);
425 if (unformat (input, "closest"))
426 *r = SSE2_QOS_ROUND_TO_CLOSEST;
427 else if (unformat (input, "up"))
428 *r = SSE2_QOS_ROUND_TO_UP;
429 else if (unformat (input, "down"))
430 *r = SSE2_QOS_ROUND_TO_DOWN;
437 unformat_policer_type (unformat_input_t * input, va_list * args)
439 u8 *r = va_arg (*args, u8 *);
441 if (unformat (input, "1r2c"))
442 *r = SSE2_QOS_POLICER_TYPE_1R2C;
443 else if (unformat (input, "1r3c"))
444 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
445 else if (unformat (input, "2r3c-2698"))
446 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
447 else if (unformat (input, "2r3c-4115"))
448 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
449 else if (unformat (input, "2r3c-mef5cf1"))
450 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
457 unformat_dscp (unformat_input_t * input, va_list * va)
459 u8 *r = va_arg (*va, u8 *);
462 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
471 unformat_policer_action_type (unformat_input_t * input, va_list * va)
473 sse2_qos_pol_action_params_st *a
474 = va_arg (*va, sse2_qos_pol_action_params_st *);
476 if (unformat (input, "drop"))
477 a->action_type = SSE2_QOS_ACTION_DROP;
478 else if (unformat (input, "transmit"))
479 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
480 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
481 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
488 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
490 u32 *r = va_arg (*va, u32 *);
493 if (unformat (input, "ip4"))
494 tid = POLICER_CLASSIFY_TABLE_IP4;
495 else if (unformat (input, "ip6"))
496 tid = POLICER_CLASSIFY_TABLE_IP6;
497 else if (unformat (input, "l2"))
498 tid = POLICER_CLASSIFY_TABLE_L2;
507 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
509 u32 *r = va_arg (*va, u32 *);
512 if (unformat (input, "ip4"))
513 tid = FLOW_CLASSIFY_TABLE_IP4;
514 else if (unformat (input, "ip6"))
515 tid = FLOW_CLASSIFY_TABLE_IP6;
523 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
524 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
525 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
526 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
528 #if (VPP_API_TEST_BUILTIN==0)
530 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
532 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
533 mfib_itf_attribute_t attr;
536 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
538 if (unformat (input, mfib_itf_flag_long_names[attr]))
539 *iflags |= (1 << attr);
541 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
543 if (unformat (input, mfib_itf_flag_names[attr]))
544 *iflags |= (1 << attr);
547 return (old == *iflags ? 0 : 1);
551 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
553 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
554 mfib_entry_attribute_t attr;
557 FOR_EACH_MFIB_ATTRIBUTE (attr)
559 if (unformat (input, mfib_flag_long_names[attr]))
560 *eflags |= (1 << attr);
562 FOR_EACH_MFIB_ATTRIBUTE (attr)
564 if (unformat (input, mfib_flag_names[attr]))
565 *eflags |= (1 << attr);
568 return (old == *eflags ? 0 : 1);
572 format_ip4_address (u8 * s, va_list * args)
574 u8 *a = va_arg (*args, u8 *);
575 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
579 format_ip6_address (u8 * s, va_list * args)
581 ip6_address_t *a = va_arg (*args, ip6_address_t *);
582 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
584 i_max_n_zero = ARRAY_LEN (a->as_u16);
586 i_first_zero = i_max_n_zero;
588 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
590 u32 is_zero = a->as_u16[i] == 0;
591 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
597 if ((!is_zero && n_zeros > max_n_zeros)
598 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
600 i_max_n_zero = i_first_zero;
601 max_n_zeros = n_zeros;
602 i_first_zero = ARRAY_LEN (a->as_u16);
607 last_double_colon = 0;
608 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
610 if (i == i_max_n_zero && max_n_zeros > 1)
612 s = format (s, "::");
613 i += max_n_zeros - 1;
614 last_double_colon = 1;
618 s = format (s, "%s%x",
619 (last_double_colon || i == 0) ? "" : ":",
620 clib_net_to_host_u16 (a->as_u16[i]));
621 last_double_colon = 0;
628 /* Format an IP46 address. */
630 format_ip46_address (u8 * s, va_list * args)
632 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
633 ip46_type_t type = va_arg (*args, ip46_type_t);
639 is_ip4 = ip46_address_is_ip4 (ip46);
650 format (s, "%U", format_ip4_address, &ip46->ip4) :
651 format (s, "%U", format_ip6_address, &ip46->ip6);
655 format_ethernet_address (u8 * s, va_list * args)
657 u8 *a = va_arg (*args, u8 *);
659 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
660 a[0], a[1], a[2], a[3], a[4], a[5]);
665 increment_v4_address (ip4_address_t * a)
669 v = ntohl (a->as_u32) + 1;
670 a->as_u32 = ntohl (v);
674 increment_v6_address (ip6_address_t * a)
678 v0 = clib_net_to_host_u64 (a->as_u64[0]);
679 v1 = clib_net_to_host_u64 (a->as_u64[1]);
684 a->as_u64[0] = clib_net_to_host_u64 (v0);
685 a->as_u64[1] = clib_net_to_host_u64 (v1);
689 increment_mac_address (u64 * mac)
693 tmp = clib_net_to_host_u64 (tmp);
694 tmp += 1 << 16; /* skip unused (least significant) octets */
695 tmp = clib_host_to_net_u64 (tmp);
699 static void vl_api_create_loopback_reply_t_handler
700 (vl_api_create_loopback_reply_t * mp)
702 vat_main_t *vam = &vat_main;
703 i32 retval = ntohl (mp->retval);
705 vam->retval = retval;
706 vam->regenerate_interface_table = 1;
707 vam->sw_if_index = ntohl (mp->sw_if_index);
708 vam->result_ready = 1;
711 static void vl_api_create_loopback_reply_t_handler_json
712 (vl_api_create_loopback_reply_t * mp)
714 vat_main_t *vam = &vat_main;
715 vat_json_node_t node;
717 vat_json_init_object (&node);
718 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
719 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
721 vat_json_print (vam->ofp, &node);
722 vat_json_free (&node);
723 vam->retval = ntohl (mp->retval);
724 vam->result_ready = 1;
727 static void vl_api_create_loopback_instance_reply_t_handler
728 (vl_api_create_loopback_instance_reply_t * mp)
730 vat_main_t *vam = &vat_main;
731 i32 retval = ntohl (mp->retval);
733 vam->retval = retval;
734 vam->regenerate_interface_table = 1;
735 vam->sw_if_index = ntohl (mp->sw_if_index);
736 vam->result_ready = 1;
739 static void vl_api_create_loopback_instance_reply_t_handler_json
740 (vl_api_create_loopback_instance_reply_t * mp)
742 vat_main_t *vam = &vat_main;
743 vat_json_node_t node;
745 vat_json_init_object (&node);
746 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
747 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
749 vat_json_print (vam->ofp, &node);
750 vat_json_free (&node);
751 vam->retval = ntohl (mp->retval);
752 vam->result_ready = 1;
755 static void vl_api_af_packet_create_reply_t_handler
756 (vl_api_af_packet_create_reply_t * mp)
758 vat_main_t *vam = &vat_main;
759 i32 retval = ntohl (mp->retval);
761 vam->retval = retval;
762 vam->regenerate_interface_table = 1;
763 vam->sw_if_index = ntohl (mp->sw_if_index);
764 vam->result_ready = 1;
767 static void vl_api_af_packet_create_reply_t_handler_json
768 (vl_api_af_packet_create_reply_t * mp)
770 vat_main_t *vam = &vat_main;
771 vat_json_node_t node;
773 vat_json_init_object (&node);
774 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
775 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
777 vat_json_print (vam->ofp, &node);
778 vat_json_free (&node);
780 vam->retval = ntohl (mp->retval);
781 vam->result_ready = 1;
784 static void vl_api_create_vlan_subif_reply_t_handler
785 (vl_api_create_vlan_subif_reply_t * mp)
787 vat_main_t *vam = &vat_main;
788 i32 retval = ntohl (mp->retval);
790 vam->retval = retval;
791 vam->regenerate_interface_table = 1;
792 vam->sw_if_index = ntohl (mp->sw_if_index);
793 vam->result_ready = 1;
796 static void vl_api_create_vlan_subif_reply_t_handler_json
797 (vl_api_create_vlan_subif_reply_t * mp)
799 vat_main_t *vam = &vat_main;
800 vat_json_node_t node;
802 vat_json_init_object (&node);
803 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
804 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
806 vat_json_print (vam->ofp, &node);
807 vat_json_free (&node);
809 vam->retval = ntohl (mp->retval);
810 vam->result_ready = 1;
813 static void vl_api_create_subif_reply_t_handler
814 (vl_api_create_subif_reply_t * mp)
816 vat_main_t *vam = &vat_main;
817 i32 retval = ntohl (mp->retval);
819 vam->retval = retval;
820 vam->regenerate_interface_table = 1;
821 vam->sw_if_index = ntohl (mp->sw_if_index);
822 vam->result_ready = 1;
825 static void vl_api_create_subif_reply_t_handler_json
826 (vl_api_create_subif_reply_t * mp)
828 vat_main_t *vam = &vat_main;
829 vat_json_node_t node;
831 vat_json_init_object (&node);
832 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
833 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
835 vat_json_print (vam->ofp, &node);
836 vat_json_free (&node);
838 vam->retval = ntohl (mp->retval);
839 vam->result_ready = 1;
842 static void vl_api_interface_name_renumber_reply_t_handler
843 (vl_api_interface_name_renumber_reply_t * mp)
845 vat_main_t *vam = &vat_main;
846 i32 retval = ntohl (mp->retval);
848 vam->retval = retval;
849 vam->regenerate_interface_table = 1;
850 vam->result_ready = 1;
853 static void vl_api_interface_name_renumber_reply_t_handler_json
854 (vl_api_interface_name_renumber_reply_t * mp)
856 vat_main_t *vam = &vat_main;
857 vat_json_node_t node;
859 vat_json_init_object (&node);
860 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
862 vat_json_print (vam->ofp, &node);
863 vat_json_free (&node);
865 vam->retval = ntohl (mp->retval);
866 vam->result_ready = 1;
870 * Special-case: build the interface table, maintain
871 * the next loopback sw_if_index vbl.
873 static void vl_api_sw_interface_details_t_handler
874 (vl_api_sw_interface_details_t * mp)
876 vat_main_t *vam = &vat_main;
877 u8 *s = format (0, "%s%c", mp->interface_name, 0);
879 hash_set_mem (vam->sw_if_index_by_interface_name, s,
880 ntohl (mp->sw_if_index));
882 /* In sub interface case, fill the sub interface table entry */
883 if (mp->sw_if_index != mp->sup_sw_if_index)
885 sw_interface_subif_t *sub = NULL;
887 vec_add2 (vam->sw_if_subif_table, sub, 1);
889 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
890 strncpy ((char *) sub->interface_name, (char *) s,
891 vec_len (sub->interface_name));
892 sub->sw_if_index = ntohl (mp->sw_if_index);
893 sub->sub_id = ntohl (mp->sub_id);
895 sub->sub_dot1ad = mp->sub_dot1ad;
896 sub->sub_number_of_tags = mp->sub_number_of_tags;
897 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
898 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
899 sub->sub_exact_match = mp->sub_exact_match;
900 sub->sub_default = mp->sub_default;
901 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
902 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
904 /* vlan tag rewrite */
905 sub->vtr_op = ntohl (mp->vtr_op);
906 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
907 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
908 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
912 static void vl_api_sw_interface_details_t_handler_json
913 (vl_api_sw_interface_details_t * mp)
915 vat_main_t *vam = &vat_main;
916 vat_json_node_t *node = NULL;
918 if (VAT_JSON_ARRAY != vam->json_tree.type)
920 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
921 vat_json_init_array (&vam->json_tree);
923 node = vat_json_array_add (&vam->json_tree);
925 vat_json_init_object (node);
926 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
927 vat_json_object_add_uint (node, "sup_sw_if_index",
928 ntohl (mp->sup_sw_if_index));
929 vat_json_object_add_uint (node, "l2_address_length",
930 ntohl (mp->l2_address_length));
931 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
932 sizeof (mp->l2_address));
933 vat_json_object_add_string_copy (node, "interface_name",
935 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
936 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
937 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
938 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
939 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
940 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
941 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
942 vat_json_object_add_uint (node, "sub_number_of_tags",
943 mp->sub_number_of_tags);
944 vat_json_object_add_uint (node, "sub_outer_vlan_id",
945 ntohs (mp->sub_outer_vlan_id));
946 vat_json_object_add_uint (node, "sub_inner_vlan_id",
947 ntohs (mp->sub_inner_vlan_id));
948 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
949 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
950 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
951 mp->sub_outer_vlan_id_any);
952 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
953 mp->sub_inner_vlan_id_any);
954 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
955 vat_json_object_add_uint (node, "vtr_push_dot1q",
956 ntohl (mp->vtr_push_dot1q));
957 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
958 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
961 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
963 format_ethernet_address,
965 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
967 format_ethernet_address,
969 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
970 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
974 #if VPP_API_TEST_BUILTIN == 0
975 static void vl_api_sw_interface_set_flags_t_handler
976 (vl_api_sw_interface_set_flags_t * mp)
978 vat_main_t *vam = &vat_main;
979 if (vam->interface_event_display)
980 errmsg ("interface flags: sw_if_index %d %s %s",
981 ntohl (mp->sw_if_index),
982 mp->admin_up_down ? "admin-up" : "admin-down",
983 mp->link_up_down ? "link-up" : "link-down");
987 static void vl_api_sw_interface_set_flags_t_handler_json
988 (vl_api_sw_interface_set_flags_t * mp)
990 /* JSON output not supported */
994 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
996 vat_main_t *vam = &vat_main;
997 i32 retval = ntohl (mp->retval);
999 vam->retval = retval;
1000 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1001 vam->result_ready = 1;
1005 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1007 vat_main_t *vam = &vat_main;
1008 vat_json_node_t node;
1009 api_main_t *am = &api_main;
1013 vat_json_init_object (&node);
1014 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1015 vat_json_object_add_uint (&node, "reply_in_shmem",
1016 ntohl (mp->reply_in_shmem));
1017 /* Toss the shared-memory original... */
1018 pthread_mutex_lock (&am->vlib_rp->mutex);
1019 oldheap = svm_push_data_heap (am->vlib_rp);
1021 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1024 svm_pop_heap (oldheap);
1025 pthread_mutex_unlock (&am->vlib_rp->mutex);
1027 vat_json_print (vam->ofp, &node);
1028 vat_json_free (&node);
1030 vam->retval = ntohl (mp->retval);
1031 vam->result_ready = 1;
1035 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1037 vat_main_t *vam = &vat_main;
1038 i32 retval = ntohl (mp->retval);
1040 vam->retval = retval;
1041 vam->cmd_reply = mp->reply;
1042 vam->result_ready = 1;
1046 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1048 vat_main_t *vam = &vat_main;
1049 vat_json_node_t node;
1051 vat_json_init_object (&node);
1052 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1053 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1055 vat_json_print (vam->ofp, &node);
1056 vat_json_free (&node);
1058 vam->retval = ntohl (mp->retval);
1059 vam->result_ready = 1;
1062 static void vl_api_classify_add_del_table_reply_t_handler
1063 (vl_api_classify_add_del_table_reply_t * mp)
1065 vat_main_t *vam = &vat_main;
1066 i32 retval = ntohl (mp->retval);
1067 if (vam->async_mode)
1069 vam->async_errors += (retval < 0);
1073 vam->retval = retval;
1075 ((mp->new_table_index != 0xFFFFFFFF) ||
1076 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1077 (mp->match_n_vectors != 0xFFFFFFFF)))
1079 * Note: this is just barely thread-safe, depends on
1080 * the main thread spinning waiting for an answer...
1082 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1083 ntohl (mp->new_table_index),
1084 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1085 vam->result_ready = 1;
1089 static void vl_api_classify_add_del_table_reply_t_handler_json
1090 (vl_api_classify_add_del_table_reply_t * mp)
1092 vat_main_t *vam = &vat_main;
1093 vat_json_node_t node;
1095 vat_json_init_object (&node);
1096 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1097 vat_json_object_add_uint (&node, "new_table_index",
1098 ntohl (mp->new_table_index));
1099 vat_json_object_add_uint (&node, "skip_n_vectors",
1100 ntohl (mp->skip_n_vectors));
1101 vat_json_object_add_uint (&node, "match_n_vectors",
1102 ntohl (mp->match_n_vectors));
1104 vat_json_print (vam->ofp, &node);
1105 vat_json_free (&node);
1107 vam->retval = ntohl (mp->retval);
1108 vam->result_ready = 1;
1111 static void vl_api_get_node_index_reply_t_handler
1112 (vl_api_get_node_index_reply_t * mp)
1114 vat_main_t *vam = &vat_main;
1115 i32 retval = ntohl (mp->retval);
1116 if (vam->async_mode)
1118 vam->async_errors += (retval < 0);
1122 vam->retval = retval;
1124 errmsg ("node index %d", ntohl (mp->node_index));
1125 vam->result_ready = 1;
1129 static void vl_api_get_node_index_reply_t_handler_json
1130 (vl_api_get_node_index_reply_t * mp)
1132 vat_main_t *vam = &vat_main;
1133 vat_json_node_t node;
1135 vat_json_init_object (&node);
1136 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1137 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1139 vat_json_print (vam->ofp, &node);
1140 vat_json_free (&node);
1142 vam->retval = ntohl (mp->retval);
1143 vam->result_ready = 1;
1146 static void vl_api_get_next_index_reply_t_handler
1147 (vl_api_get_next_index_reply_t * mp)
1149 vat_main_t *vam = &vat_main;
1150 i32 retval = ntohl (mp->retval);
1151 if (vam->async_mode)
1153 vam->async_errors += (retval < 0);
1157 vam->retval = retval;
1159 errmsg ("next node index %d", ntohl (mp->next_index));
1160 vam->result_ready = 1;
1164 static void vl_api_get_next_index_reply_t_handler_json
1165 (vl_api_get_next_index_reply_t * mp)
1167 vat_main_t *vam = &vat_main;
1168 vat_json_node_t node;
1170 vat_json_init_object (&node);
1171 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1172 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1174 vat_json_print (vam->ofp, &node);
1175 vat_json_free (&node);
1177 vam->retval = ntohl (mp->retval);
1178 vam->result_ready = 1;
1181 static void vl_api_add_node_next_reply_t_handler
1182 (vl_api_add_node_next_reply_t * mp)
1184 vat_main_t *vam = &vat_main;
1185 i32 retval = ntohl (mp->retval);
1186 if (vam->async_mode)
1188 vam->async_errors += (retval < 0);
1192 vam->retval = retval;
1194 errmsg ("next index %d", ntohl (mp->next_index));
1195 vam->result_ready = 1;
1199 static void vl_api_add_node_next_reply_t_handler_json
1200 (vl_api_add_node_next_reply_t * mp)
1202 vat_main_t *vam = &vat_main;
1203 vat_json_node_t node;
1205 vat_json_init_object (&node);
1206 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1207 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1209 vat_json_print (vam->ofp, &node);
1210 vat_json_free (&node);
1212 vam->retval = ntohl (mp->retval);
1213 vam->result_ready = 1;
1216 static void vl_api_show_version_reply_t_handler
1217 (vl_api_show_version_reply_t * mp)
1219 vat_main_t *vam = &vat_main;
1220 i32 retval = ntohl (mp->retval);
1224 errmsg (" program: %s", mp->program);
1225 errmsg (" version: %s", mp->version);
1226 errmsg (" build date: %s", mp->build_date);
1227 errmsg ("build directory: %s", mp->build_directory);
1229 vam->retval = retval;
1230 vam->result_ready = 1;
1233 static void vl_api_show_version_reply_t_handler_json
1234 (vl_api_show_version_reply_t * mp)
1236 vat_main_t *vam = &vat_main;
1237 vat_json_node_t node;
1239 vat_json_init_object (&node);
1240 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1241 vat_json_object_add_string_copy (&node, "program", mp->program);
1242 vat_json_object_add_string_copy (&node, "version", mp->version);
1243 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1244 vat_json_object_add_string_copy (&node, "build_directory",
1245 mp->build_directory);
1247 vat_json_print (vam->ofp, &node);
1248 vat_json_free (&node);
1250 vam->retval = ntohl (mp->retval);
1251 vam->result_ready = 1;
1255 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1257 u32 sw_if_index = ntohl (mp->sw_if_index);
1258 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1259 mp->mac_ip ? "mac/ip binding" : "address resolution",
1260 ntohl (mp->pid), format_ip4_address, &mp->address,
1261 format_ethernet_address, mp->new_mac, sw_if_index);
1265 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1267 /* JSON output not supported */
1271 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1273 u32 sw_if_index = ntohl (mp->sw_if_index);
1274 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1275 mp->mac_ip ? "mac/ip binding" : "address resolution",
1276 ntohl (mp->pid), format_ip6_address, mp->address,
1277 format_ethernet_address, mp->new_mac, sw_if_index);
1281 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1283 /* JSON output not supported */
1286 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1287 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1290 * Special-case: build the bridge domain table, maintain
1291 * the next bd id vbl.
1293 static void vl_api_bridge_domain_details_t_handler
1294 (vl_api_bridge_domain_details_t * mp)
1296 vat_main_t *vam = &vat_main;
1297 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1300 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1301 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1303 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1304 ntohl (mp->bd_id), mp->learn, mp->forward,
1305 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1309 vl_api_bridge_domain_sw_if_t *sw_ifs;
1310 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1313 sw_ifs = mp->sw_if_details;
1314 for (i = 0; i < n_sw_ifs; i++)
1320 sw_if_index = ntohl (sw_ifs->sw_if_index);
1323 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1325 if ((u32) p->value[0] == sw_if_index)
1327 sw_if_name = (u8 *)(p->key);
1332 print (vam->ofp, "%7d %3d %s", sw_if_index,
1333 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1334 "sw_if_index not found!");
1341 static void vl_api_bridge_domain_details_t_handler_json
1342 (vl_api_bridge_domain_details_t * mp)
1344 vat_main_t *vam = &vat_main;
1345 vat_json_node_t *node, *array = NULL;
1346 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1348 if (VAT_JSON_ARRAY != vam->json_tree.type)
1350 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1351 vat_json_init_array (&vam->json_tree);
1353 node = vat_json_array_add (&vam->json_tree);
1355 vat_json_init_object (node);
1356 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1357 vat_json_object_add_uint (node, "flood", mp->flood);
1358 vat_json_object_add_uint (node, "forward", mp->forward);
1359 vat_json_object_add_uint (node, "learn", mp->learn);
1360 vat_json_object_add_uint (node, "bvi_sw_if_index",
1361 ntohl (mp->bvi_sw_if_index));
1362 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1363 array = vat_json_object_add (node, "sw_if");
1364 vat_json_init_array (array);
1370 vl_api_bridge_domain_sw_if_t *sw_ifs;
1373 sw_ifs = mp->sw_if_details;
1374 for (i = 0; i < n_sw_ifs; i++)
1376 node = vat_json_array_add (array);
1377 vat_json_init_object (node);
1378 vat_json_object_add_uint (node, "sw_if_index",
1379 ntohl (sw_ifs->sw_if_index));
1380 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1386 static void vl_api_control_ping_reply_t_handler
1387 (vl_api_control_ping_reply_t * mp)
1389 vat_main_t *vam = &vat_main;
1390 i32 retval = ntohl (mp->retval);
1391 if (vam->async_mode)
1393 vam->async_errors += (retval < 0);
1397 vam->retval = retval;
1398 vam->result_ready = 1;
1402 static void vl_api_control_ping_reply_t_handler_json
1403 (vl_api_control_ping_reply_t * mp)
1405 vat_main_t *vam = &vat_main;
1406 i32 retval = ntohl (mp->retval);
1408 if (VAT_JSON_NONE != vam->json_tree.type)
1410 vat_json_print (vam->ofp, &vam->json_tree);
1411 vat_json_free (&vam->json_tree);
1412 vam->json_tree.type = VAT_JSON_NONE;
1417 vat_json_init_array (&vam->json_tree);
1418 vat_json_print (vam->ofp, &vam->json_tree);
1419 vam->json_tree.type = VAT_JSON_NONE;
1422 vam->retval = retval;
1423 vam->result_ready = 1;
1427 vl_api_bridge_domain_set_mac_age_reply_t_handler
1428 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1430 vat_main_t *vam = &vat_main;
1431 i32 retval = ntohl (mp->retval);
1432 if (vam->async_mode)
1434 vam->async_errors += (retval < 0);
1438 vam->retval = retval;
1439 vam->result_ready = 1;
1443 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1444 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1446 vat_main_t *vam = &vat_main;
1447 vat_json_node_t node;
1449 vat_json_init_object (&node);
1450 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1452 vat_json_print (vam->ofp, &node);
1453 vat_json_free (&node);
1455 vam->retval = ntohl (mp->retval);
1456 vam->result_ready = 1;
1460 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1462 vat_main_t *vam = &vat_main;
1463 i32 retval = ntohl (mp->retval);
1464 if (vam->async_mode)
1466 vam->async_errors += (retval < 0);
1470 vam->retval = retval;
1471 vam->result_ready = 1;
1475 static void vl_api_l2_flags_reply_t_handler_json
1476 (vl_api_l2_flags_reply_t * mp)
1478 vat_main_t *vam = &vat_main;
1479 vat_json_node_t node;
1481 vat_json_init_object (&node);
1482 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1483 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1484 ntohl (mp->resulting_feature_bitmap));
1486 vat_json_print (vam->ofp, &node);
1487 vat_json_free (&node);
1489 vam->retval = ntohl (mp->retval);
1490 vam->result_ready = 1;
1493 static void vl_api_bridge_flags_reply_t_handler
1494 (vl_api_bridge_flags_reply_t * mp)
1496 vat_main_t *vam = &vat_main;
1497 i32 retval = ntohl (mp->retval);
1498 if (vam->async_mode)
1500 vam->async_errors += (retval < 0);
1504 vam->retval = retval;
1505 vam->result_ready = 1;
1509 static void vl_api_bridge_flags_reply_t_handler_json
1510 (vl_api_bridge_flags_reply_t * mp)
1512 vat_main_t *vam = &vat_main;
1513 vat_json_node_t node;
1515 vat_json_init_object (&node);
1516 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1517 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1518 ntohl (mp->resulting_feature_bitmap));
1520 vat_json_print (vam->ofp, &node);
1521 vat_json_free (&node);
1523 vam->retval = ntohl (mp->retval);
1524 vam->result_ready = 1;
1527 static void vl_api_tap_connect_reply_t_handler
1528 (vl_api_tap_connect_reply_t * mp)
1530 vat_main_t *vam = &vat_main;
1531 i32 retval = ntohl (mp->retval);
1532 if (vam->async_mode)
1534 vam->async_errors += (retval < 0);
1538 vam->retval = retval;
1539 vam->sw_if_index = ntohl (mp->sw_if_index);
1540 vam->result_ready = 1;
1545 static void vl_api_tap_connect_reply_t_handler_json
1546 (vl_api_tap_connect_reply_t * mp)
1548 vat_main_t *vam = &vat_main;
1549 vat_json_node_t node;
1551 vat_json_init_object (&node);
1552 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1553 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1555 vat_json_print (vam->ofp, &node);
1556 vat_json_free (&node);
1558 vam->retval = ntohl (mp->retval);
1559 vam->result_ready = 1;
1564 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1566 vat_main_t *vam = &vat_main;
1567 i32 retval = ntohl (mp->retval);
1568 if (vam->async_mode)
1570 vam->async_errors += (retval < 0);
1574 vam->retval = retval;
1575 vam->sw_if_index = ntohl (mp->sw_if_index);
1576 vam->result_ready = 1;
1580 static void vl_api_tap_modify_reply_t_handler_json
1581 (vl_api_tap_modify_reply_t * mp)
1583 vat_main_t *vam = &vat_main;
1584 vat_json_node_t node;
1586 vat_json_init_object (&node);
1587 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1588 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1590 vat_json_print (vam->ofp, &node);
1591 vat_json_free (&node);
1593 vam->retval = ntohl (mp->retval);
1594 vam->result_ready = 1;
1598 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1600 vat_main_t *vam = &vat_main;
1601 i32 retval = ntohl (mp->retval);
1602 if (vam->async_mode)
1604 vam->async_errors += (retval < 0);
1608 vam->retval = retval;
1609 vam->result_ready = 1;
1613 static void vl_api_tap_delete_reply_t_handler_json
1614 (vl_api_tap_delete_reply_t * mp)
1616 vat_main_t *vam = &vat_main;
1617 vat_json_node_t node;
1619 vat_json_init_object (&node);
1620 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1622 vat_json_print (vam->ofp, &node);
1623 vat_json_free (&node);
1625 vam->retval = ntohl (mp->retval);
1626 vam->result_ready = 1;
1629 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1630 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1632 vat_main_t *vam = &vat_main;
1633 i32 retval = ntohl (mp->retval);
1634 if (vam->async_mode)
1636 vam->async_errors += (retval < 0);
1640 vam->retval = retval;
1641 vam->result_ready = 1;
1645 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1646 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1648 vat_main_t *vam = &vat_main;
1649 vat_json_node_t node;
1651 vat_json_init_object (&node);
1652 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1653 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1654 ntohl (mp->sw_if_index));
1656 vat_json_print (vam->ofp, &node);
1657 vat_json_free (&node);
1659 vam->retval = ntohl (mp->retval);
1660 vam->result_ready = 1;
1663 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1664 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1666 vat_main_t *vam = &vat_main;
1667 i32 retval = ntohl (mp->retval);
1668 if (vam->async_mode)
1670 vam->async_errors += (retval < 0);
1674 vam->retval = retval;
1675 vam->sw_if_index = ntohl (mp->sw_if_index);
1676 vam->result_ready = 1;
1680 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1681 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1683 vat_main_t *vam = &vat_main;
1684 vat_json_node_t node;
1686 vat_json_init_object (&node);
1687 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1688 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1690 vat_json_print (vam->ofp, &node);
1691 vat_json_free (&node);
1693 vam->retval = ntohl (mp->retval);
1694 vam->result_ready = 1;
1697 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
1698 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1700 vat_main_t *vam = &vat_main;
1701 i32 retval = ntohl (mp->retval);
1702 if (vam->async_mode)
1704 vam->async_errors += (retval < 0);
1708 vam->retval = retval;
1709 vam->result_ready = 1;
1713 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
1714 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1716 vat_main_t *vam = &vat_main;
1717 vat_json_node_t node;
1719 vat_json_init_object (&node);
1720 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1721 vat_json_object_add_uint (&node, "fwd_entry_index",
1722 clib_net_to_host_u32 (mp->fwd_entry_index));
1724 vat_json_print (vam->ofp, &node);
1725 vat_json_free (&node);
1727 vam->retval = ntohl (mp->retval);
1728 vam->result_ready = 1;
1731 static void vl_api_one_add_del_locator_set_reply_t_handler
1732 (vl_api_one_add_del_locator_set_reply_t * mp)
1734 vat_main_t *vam = &vat_main;
1735 i32 retval = ntohl (mp->retval);
1736 if (vam->async_mode)
1738 vam->async_errors += (retval < 0);
1742 vam->retval = retval;
1743 vam->result_ready = 1;
1747 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1748 (vl_api_one_add_del_locator_set_reply_t * mp)
1750 vat_main_t *vam = &vat_main;
1751 vat_json_node_t node;
1753 vat_json_init_object (&node);
1754 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1755 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1757 vat_json_print (vam->ofp, &node);
1758 vat_json_free (&node);
1760 vam->retval = ntohl (mp->retval);
1761 vam->result_ready = 1;
1764 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1765 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1767 vat_main_t *vam = &vat_main;
1768 i32 retval = ntohl (mp->retval);
1769 if (vam->async_mode)
1771 vam->async_errors += (retval < 0);
1775 vam->retval = retval;
1776 vam->sw_if_index = ntohl (mp->sw_if_index);
1777 vam->result_ready = 1;
1781 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1782 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1784 vat_main_t *vam = &vat_main;
1785 vat_json_node_t node;
1787 vat_json_init_object (&node);
1788 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1789 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1791 vat_json_print (vam->ofp, &node);
1792 vat_json_free (&node);
1794 vam->retval = ntohl (mp->retval);
1795 vam->result_ready = 1;
1798 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
1799 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1801 vat_main_t *vam = &vat_main;
1802 i32 retval = ntohl (mp->retval);
1803 if (vam->async_mode)
1805 vam->async_errors += (retval < 0);
1809 vam->retval = retval;
1810 vam->sw_if_index = ntohl (mp->sw_if_index);
1811 vam->result_ready = 1;
1815 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
1816 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1818 vat_main_t *vam = &vat_main;
1819 vat_json_node_t node;
1821 vat_json_init_object (&node);
1822 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1823 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1825 vat_json_print (vam->ofp, &node);
1826 vat_json_free (&node);
1828 vam->retval = ntohl (mp->retval);
1829 vam->result_ready = 1;
1832 static void vl_api_gre_add_del_tunnel_reply_t_handler
1833 (vl_api_gre_add_del_tunnel_reply_t * mp)
1835 vat_main_t *vam = &vat_main;
1836 i32 retval = ntohl (mp->retval);
1837 if (vam->async_mode)
1839 vam->async_errors += (retval < 0);
1843 vam->retval = retval;
1844 vam->sw_if_index = ntohl (mp->sw_if_index);
1845 vam->result_ready = 1;
1849 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1850 (vl_api_gre_add_del_tunnel_reply_t * mp)
1852 vat_main_t *vam = &vat_main;
1853 vat_json_node_t node;
1855 vat_json_init_object (&node);
1856 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1857 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1859 vat_json_print (vam->ofp, &node);
1860 vat_json_free (&node);
1862 vam->retval = ntohl (mp->retval);
1863 vam->result_ready = 1;
1866 static void vl_api_create_vhost_user_if_reply_t_handler
1867 (vl_api_create_vhost_user_if_reply_t * mp)
1869 vat_main_t *vam = &vat_main;
1870 i32 retval = ntohl (mp->retval);
1871 if (vam->async_mode)
1873 vam->async_errors += (retval < 0);
1877 vam->retval = retval;
1878 vam->sw_if_index = ntohl (mp->sw_if_index);
1879 vam->result_ready = 1;
1883 static void vl_api_create_vhost_user_if_reply_t_handler_json
1884 (vl_api_create_vhost_user_if_reply_t * mp)
1886 vat_main_t *vam = &vat_main;
1887 vat_json_node_t node;
1889 vat_json_init_object (&node);
1890 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1891 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1893 vat_json_print (vam->ofp, &node);
1894 vat_json_free (&node);
1896 vam->retval = ntohl (mp->retval);
1897 vam->result_ready = 1;
1900 static void vl_api_ip_address_details_t_handler
1901 (vl_api_ip_address_details_t * mp)
1903 vat_main_t *vam = &vat_main;
1904 static ip_address_details_t empty_ip_address_details = { {0} };
1905 ip_address_details_t *address = NULL;
1906 ip_details_t *current_ip_details = NULL;
1907 ip_details_t *details = NULL;
1909 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1911 if (!details || vam->current_sw_if_index >= vec_len (details)
1912 || !details[vam->current_sw_if_index].present)
1914 errmsg ("ip address details arrived but not stored");
1915 errmsg ("ip_dump should be called first");
1919 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1921 #define addresses (current_ip_details->addr)
1923 vec_validate_init_empty (addresses, vec_len (addresses),
1924 empty_ip_address_details);
1926 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1928 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1929 address->prefix_length = mp->prefix_length;
1933 static void vl_api_ip_address_details_t_handler_json
1934 (vl_api_ip_address_details_t * mp)
1936 vat_main_t *vam = &vat_main;
1937 vat_json_node_t *node = NULL;
1938 struct in6_addr ip6;
1941 if (VAT_JSON_ARRAY != vam->json_tree.type)
1943 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1944 vat_json_init_array (&vam->json_tree);
1946 node = vat_json_array_add (&vam->json_tree);
1948 vat_json_init_object (node);
1951 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1952 vat_json_object_add_ip6 (node, "ip", ip6);
1956 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1957 vat_json_object_add_ip4 (node, "ip", ip4);
1959 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1963 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1965 vat_main_t *vam = &vat_main;
1966 static ip_details_t empty_ip_details = { 0 };
1967 ip_details_t *ip = NULL;
1968 u32 sw_if_index = ~0;
1970 sw_if_index = ntohl (mp->sw_if_index);
1972 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1973 sw_if_index, empty_ip_details);
1975 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1982 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1984 vat_main_t *vam = &vat_main;
1986 if (VAT_JSON_ARRAY != vam->json_tree.type)
1988 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1989 vat_json_init_array (&vam->json_tree);
1991 vat_json_array_add_uint (&vam->json_tree,
1992 clib_net_to_host_u32 (mp->sw_if_index));
1995 static void vl_api_map_domain_details_t_handler_json
1996 (vl_api_map_domain_details_t * mp)
1998 vat_json_node_t *node = NULL;
1999 vat_main_t *vam = &vat_main;
2000 struct in6_addr ip6;
2003 if (VAT_JSON_ARRAY != vam->json_tree.type)
2005 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2006 vat_json_init_array (&vam->json_tree);
2009 node = vat_json_array_add (&vam->json_tree);
2010 vat_json_init_object (node);
2012 vat_json_object_add_uint (node, "domain_index",
2013 clib_net_to_host_u32 (mp->domain_index));
2014 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2015 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2016 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2017 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2018 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2019 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2020 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2021 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2022 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2023 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2024 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2025 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2026 vat_json_object_add_uint (node, "flags", mp->flags);
2027 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2028 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2031 static void vl_api_map_domain_details_t_handler
2032 (vl_api_map_domain_details_t * mp)
2034 vat_main_t *vam = &vat_main;
2036 if (mp->is_translation)
2039 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2040 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2041 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2042 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2043 clib_net_to_host_u32 (mp->domain_index));
2048 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2049 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2050 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2051 format_ip6_address, mp->ip6_src,
2052 clib_net_to_host_u32 (mp->domain_index));
2054 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2055 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2056 mp->is_translation ? "map-t" : "");
2059 static void vl_api_map_rule_details_t_handler_json
2060 (vl_api_map_rule_details_t * mp)
2062 struct in6_addr ip6;
2063 vat_json_node_t *node = NULL;
2064 vat_main_t *vam = &vat_main;
2066 if (VAT_JSON_ARRAY != vam->json_tree.type)
2068 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2069 vat_json_init_array (&vam->json_tree);
2072 node = vat_json_array_add (&vam->json_tree);
2073 vat_json_init_object (node);
2075 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2076 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2077 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2081 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2083 vat_main_t *vam = &vat_main;
2084 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2085 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2089 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2091 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2092 "router_addr %U host_mac %U",
2093 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2094 format_ip4_address, &mp->host_address,
2095 format_ip4_address, &mp->router_address,
2096 format_ethernet_address, mp->host_mac);
2099 static void vl_api_dhcp_compl_event_t_handler_json
2100 (vl_api_dhcp_compl_event_t * mp)
2102 /* JSON output not supported */
2106 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2109 vat_main_t *vam = &vat_main;
2110 static u64 default_counter = 0;
2112 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2114 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2115 sw_if_index, default_counter);
2116 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2120 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2121 interface_counter_t counter)
2123 vat_main_t *vam = &vat_main;
2124 static interface_counter_t default_counter = { 0, };
2126 vec_validate_init_empty (vam->combined_interface_counters,
2127 vnet_counter_type, NULL);
2128 vec_validate_init_empty (vam->combined_interface_counters
2129 [vnet_counter_type], sw_if_index, default_counter);
2130 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2133 static void vl_api_vnet_interface_simple_counters_t_handler
2134 (vl_api_vnet_interface_simple_counters_t * mp)
2139 static void vl_api_vnet_interface_combined_counters_t_handler
2140 (vl_api_vnet_interface_combined_counters_t * mp)
2145 static void vl_api_vnet_interface_simple_counters_t_handler_json
2146 (vl_api_vnet_interface_simple_counters_t * mp)
2151 u32 first_sw_if_index;
2154 count = ntohl (mp->count);
2155 first_sw_if_index = ntohl (mp->first_sw_if_index);
2157 v_packets = (u64 *) & mp->data;
2158 for (i = 0; i < count; i++)
2160 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2161 set_simple_interface_counter (mp->vnet_counter_type,
2162 first_sw_if_index + i, packets);
2167 static void vl_api_vnet_interface_combined_counters_t_handler_json
2168 (vl_api_vnet_interface_combined_counters_t * mp)
2170 interface_counter_t counter;
2172 u32 first_sw_if_index;
2176 count = ntohl (mp->count);
2177 first_sw_if_index = ntohl (mp->first_sw_if_index);
2179 v = (vlib_counter_t *) & mp->data;
2180 for (i = 0; i < count; i++)
2183 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2185 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2186 set_combined_interface_counter (mp->vnet_counter_type,
2187 first_sw_if_index + i, counter);
2193 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2195 vat_main_t *vam = &vat_main;
2198 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2200 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2209 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2211 vat_main_t *vam = &vat_main;
2214 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2216 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2224 static void vl_api_vnet_ip4_fib_counters_t_handler
2225 (vl_api_vnet_ip4_fib_counters_t * mp)
2230 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2231 (vl_api_vnet_ip4_fib_counters_t * mp)
2233 vat_main_t *vam = &vat_main;
2234 vl_api_ip4_fib_counter_t *v;
2235 ip4_fib_counter_t *counter;
2242 vrf_id = ntohl (mp->vrf_id);
2243 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2244 if (~0 == vrf_index)
2246 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2247 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2248 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2249 vec_validate (vam->ip4_fib_counters, vrf_index);
2250 vam->ip4_fib_counters[vrf_index] = NULL;
2253 vec_free (vam->ip4_fib_counters[vrf_index]);
2254 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2255 count = ntohl (mp->count);
2256 for (i = 0; i < count; i++)
2258 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2259 counter = &vam->ip4_fib_counters[vrf_index][i];
2260 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2261 counter->address = ip4;
2262 counter->address_length = v->address_length;
2263 counter->packets = clib_net_to_host_u64 (v->packets);
2264 counter->bytes = clib_net_to_host_u64 (v->bytes);
2269 static void vl_api_vnet_ip4_nbr_counters_t_handler
2270 (vl_api_vnet_ip4_nbr_counters_t * mp)
2275 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2276 (vl_api_vnet_ip4_nbr_counters_t * mp)
2278 vat_main_t *vam = &vat_main;
2279 vl_api_ip4_nbr_counter_t *v;
2280 ip4_nbr_counter_t *counter;
2285 sw_if_index = ntohl (mp->sw_if_index);
2286 count = ntohl (mp->count);
2287 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2290 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2292 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2293 for (i = 0; i < count; i++)
2295 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2296 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2297 counter->address.s_addr = v->address;
2298 counter->packets = clib_net_to_host_u64 (v->packets);
2299 counter->bytes = clib_net_to_host_u64 (v->bytes);
2300 counter->linkt = v->link_type;
2305 static void vl_api_vnet_ip6_fib_counters_t_handler
2306 (vl_api_vnet_ip6_fib_counters_t * mp)
2311 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2312 (vl_api_vnet_ip6_fib_counters_t * mp)
2314 vat_main_t *vam = &vat_main;
2315 vl_api_ip6_fib_counter_t *v;
2316 ip6_fib_counter_t *counter;
2317 struct in6_addr ip6;
2323 vrf_id = ntohl (mp->vrf_id);
2324 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2325 if (~0 == vrf_index)
2327 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2328 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2329 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2330 vec_validate (vam->ip6_fib_counters, vrf_index);
2331 vam->ip6_fib_counters[vrf_index] = NULL;
2334 vec_free (vam->ip6_fib_counters[vrf_index]);
2335 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2336 count = ntohl (mp->count);
2337 for (i = 0; i < count; i++)
2339 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2340 counter = &vam->ip6_fib_counters[vrf_index][i];
2341 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2342 counter->address = ip6;
2343 counter->address_length = v->address_length;
2344 counter->packets = clib_net_to_host_u64 (v->packets);
2345 counter->bytes = clib_net_to_host_u64 (v->bytes);
2350 static void vl_api_vnet_ip6_nbr_counters_t_handler
2351 (vl_api_vnet_ip6_nbr_counters_t * mp)
2356 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2357 (vl_api_vnet_ip6_nbr_counters_t * mp)
2359 vat_main_t *vam = &vat_main;
2360 vl_api_ip6_nbr_counter_t *v;
2361 ip6_nbr_counter_t *counter;
2362 struct in6_addr ip6;
2367 sw_if_index = ntohl (mp->sw_if_index);
2368 count = ntohl (mp->count);
2369 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2372 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2374 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2375 for (i = 0; i < count; i++)
2377 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2378 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2379 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2380 counter->address = ip6;
2381 counter->packets = clib_net_to_host_u64 (v->packets);
2382 counter->bytes = clib_net_to_host_u64 (v->bytes);
2387 static void vl_api_get_first_msg_id_reply_t_handler
2388 (vl_api_get_first_msg_id_reply_t * mp)
2390 vat_main_t *vam = &vat_main;
2391 i32 retval = ntohl (mp->retval);
2393 if (vam->async_mode)
2395 vam->async_errors += (retval < 0);
2399 vam->retval = retval;
2400 vam->result_ready = 1;
2404 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2408 static void vl_api_get_first_msg_id_reply_t_handler_json
2409 (vl_api_get_first_msg_id_reply_t * mp)
2411 vat_main_t *vam = &vat_main;
2412 vat_json_node_t node;
2414 vat_json_init_object (&node);
2415 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2416 vat_json_object_add_uint (&node, "first_msg_id",
2417 (uint) ntohs (mp->first_msg_id));
2419 vat_json_print (vam->ofp, &node);
2420 vat_json_free (&node);
2422 vam->retval = ntohl (mp->retval);
2423 vam->result_ready = 1;
2426 static void vl_api_get_node_graph_reply_t_handler
2427 (vl_api_get_node_graph_reply_t * mp)
2429 vat_main_t *vam = &vat_main;
2430 api_main_t *am = &api_main;
2431 i32 retval = ntohl (mp->retval);
2432 u8 *pvt_copy, *reply;
2437 if (vam->async_mode)
2439 vam->async_errors += (retval < 0);
2443 vam->retval = retval;
2444 vam->result_ready = 1;
2447 /* "Should never happen..." */
2451 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2452 pvt_copy = vec_dup (reply);
2454 /* Toss the shared-memory original... */
2455 pthread_mutex_lock (&am->vlib_rp->mutex);
2456 oldheap = svm_push_data_heap (am->vlib_rp);
2460 svm_pop_heap (oldheap);
2461 pthread_mutex_unlock (&am->vlib_rp->mutex);
2463 if (vam->graph_nodes)
2465 hash_free (vam->graph_node_index_by_name);
2467 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2469 node = vam->graph_nodes[i];
2470 vec_free (node->name);
2471 vec_free (node->next_nodes);
2474 vec_free (vam->graph_nodes);
2477 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2478 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2479 vec_free (pvt_copy);
2481 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2483 node = vam->graph_nodes[i];
2484 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2488 static void vl_api_get_node_graph_reply_t_handler_json
2489 (vl_api_get_node_graph_reply_t * mp)
2491 vat_main_t *vam = &vat_main;
2492 api_main_t *am = &api_main;
2494 vat_json_node_t node;
2497 /* $$$$ make this real? */
2498 vat_json_init_object (&node);
2499 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2500 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2502 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2504 /* Toss the shared-memory original... */
2505 pthread_mutex_lock (&am->vlib_rp->mutex);
2506 oldheap = svm_push_data_heap (am->vlib_rp);
2510 svm_pop_heap (oldheap);
2511 pthread_mutex_unlock (&am->vlib_rp->mutex);
2513 vat_json_print (vam->ofp, &node);
2514 vat_json_free (&node);
2516 vam->retval = ntohl (mp->retval);
2517 vam->result_ready = 1;
2521 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2523 vat_main_t *vam = &vat_main;
2528 s = format (s, "%=16d%=16d%=16d",
2529 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2533 s = format (s, "%=16U%=16d%=16d",
2534 mp->is_ipv6 ? format_ip6_address :
2536 mp->ip_address, mp->priority, mp->weight);
2539 print (vam->ofp, "%v", s);
2544 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2546 vat_main_t *vam = &vat_main;
2547 vat_json_node_t *node = NULL;
2548 struct in6_addr ip6;
2551 if (VAT_JSON_ARRAY != vam->json_tree.type)
2553 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2554 vat_json_init_array (&vam->json_tree);
2556 node = vat_json_array_add (&vam->json_tree);
2557 vat_json_init_object (node);
2559 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2560 vat_json_object_add_uint (node, "priority", mp->priority);
2561 vat_json_object_add_uint (node, "weight", mp->weight);
2564 vat_json_object_add_uint (node, "sw_if_index",
2565 clib_net_to_host_u32 (mp->sw_if_index));
2570 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2571 vat_json_object_add_ip6 (node, "address", ip6);
2575 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2576 vat_json_object_add_ip4 (node, "address", ip4);
2582 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2585 vat_main_t *vam = &vat_main;
2588 ls_name = format (0, "%s", mp->ls_name);
2590 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2596 vl_api_one_locator_set_details_t_handler_json
2597 (vl_api_one_locator_set_details_t * mp)
2599 vat_main_t *vam = &vat_main;
2600 vat_json_node_t *node = 0;
2603 ls_name = format (0, "%s", mp->ls_name);
2604 vec_add1 (ls_name, 0);
2606 if (VAT_JSON_ARRAY != vam->json_tree.type)
2608 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2609 vat_json_init_array (&vam->json_tree);
2611 node = vat_json_array_add (&vam->json_tree);
2613 vat_json_init_object (node);
2614 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2615 vat_json_object_add_uint (node, "ls_index",
2616 clib_net_to_host_u32 (mp->ls_index));
2624 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2627 unformat_nsh_address (unformat_input_t * input, va_list * args)
2629 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2630 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2634 format_nsh_address_vat (u8 * s, va_list * args)
2636 nsh_t *a = va_arg (*args, nsh_t *);
2637 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2641 format_lisp_flat_eid (u8 * s, va_list * args)
2643 u32 type = va_arg (*args, u32);
2644 u8 *eid = va_arg (*args, u8 *);
2645 u32 eid_len = va_arg (*args, u32);
2650 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2652 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2654 return format (s, "%U", format_ethernet_address, eid);
2656 return format (s, "%U", format_nsh_address_vat, eid);
2662 format_lisp_eid_vat (u8 * s, va_list * args)
2664 u32 type = va_arg (*args, u32);
2665 u8 *eid = va_arg (*args, u8 *);
2666 u32 eid_len = va_arg (*args, u32);
2667 u8 *seid = va_arg (*args, u8 *);
2668 u32 seid_len = va_arg (*args, u32);
2669 u32 is_src_dst = va_arg (*args, u32);
2672 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2674 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2680 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2682 vat_main_t *vam = &vat_main;
2683 u8 *s = 0, *eid = 0;
2685 if (~0 == mp->locator_set_index)
2686 s = format (0, "action: %d", mp->action);
2688 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2690 eid = format (0, "%U", format_lisp_eid_vat,
2694 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2697 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2698 clib_net_to_host_u32 (mp->vni),
2700 mp->is_local ? "local" : "remote",
2701 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2702 clib_net_to_host_u16 (mp->key_id), mp->key);
2709 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2712 vat_main_t *vam = &vat_main;
2713 vat_json_node_t *node = 0;
2716 if (VAT_JSON_ARRAY != vam->json_tree.type)
2718 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2719 vat_json_init_array (&vam->json_tree);
2721 node = vat_json_array_add (&vam->json_tree);
2723 vat_json_init_object (node);
2724 if (~0 == mp->locator_set_index)
2725 vat_json_object_add_uint (node, "action", mp->action);
2727 vat_json_object_add_uint (node, "locator_set_index",
2728 clib_net_to_host_u32 (mp->locator_set_index));
2730 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2731 if (mp->eid_type == 3)
2733 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
2734 vat_json_init_object (nsh_json);
2735 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
2736 vat_json_object_add_uint (nsh_json, "spi",
2737 clib_net_to_host_u32 (nsh->spi));
2738 vat_json_object_add_uint (nsh_json, "si", nsh->si);
2742 eid = format (0, "%U", format_lisp_eid_vat,
2746 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2748 vat_json_object_add_string_copy (node, "eid", eid);
2751 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2752 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2753 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2757 vat_json_object_add_uint (node, "key_id",
2758 clib_net_to_host_u16 (mp->key_id));
2759 vat_json_object_add_string_copy (node, "key", mp->key);
2764 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
2766 vat_main_t *vam = &vat_main;
2767 u8 *seid = 0, *deid = 0;
2768 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2770 deid = format (0, "%U", format_lisp_eid_vat,
2771 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2773 seid = format (0, "%U", format_lisp_eid_vat,
2774 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2780 format_ip_address_fcn = format_ip4_address;
2782 format_ip_address_fcn = format_ip6_address;
2785 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
2786 clib_net_to_host_u32 (mp->vni),
2788 format_ip_address_fcn, mp->lloc,
2789 format_ip_address_fcn, mp->rloc,
2790 clib_net_to_host_u32 (mp->pkt_count),
2791 clib_net_to_host_u32 (mp->bytes));
2798 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
2800 struct in6_addr ip6;
2802 vat_main_t *vam = &vat_main;
2803 vat_json_node_t *node = 0;
2804 u8 *deid = 0, *seid = 0;
2806 if (VAT_JSON_ARRAY != vam->json_tree.type)
2808 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2809 vat_json_init_array (&vam->json_tree);
2811 node = vat_json_array_add (&vam->json_tree);
2813 vat_json_init_object (node);
2814 deid = format (0, "%U", format_lisp_eid_vat,
2815 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2817 seid = format (0, "%U", format_lisp_eid_vat,
2818 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2823 vat_json_object_add_string_copy (node, "seid", seid);
2824 vat_json_object_add_string_copy (node, "deid", deid);
2825 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2829 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
2830 vat_json_object_add_ip4 (node, "lloc", ip4);
2831 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
2832 vat_json_object_add_ip4 (node, "rloc", ip4);
2836 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
2837 vat_json_object_add_ip6 (node, "lloc", ip6);
2838 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
2839 vat_json_object_add_ip6 (node, "rloc", ip6);
2841 vat_json_object_add_uint (node, "pkt_count",
2842 clib_net_to_host_u32 (mp->pkt_count));
2843 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
2850 vl_api_one_eid_table_map_details_t_handler
2851 (vl_api_one_eid_table_map_details_t * mp)
2853 vat_main_t *vam = &vat_main;
2855 u8 *line = format (0, "%=10d%=10d",
2856 clib_net_to_host_u32 (mp->vni),
2857 clib_net_to_host_u32 (mp->dp_table));
2858 print (vam->ofp, "%v", line);
2863 vl_api_one_eid_table_map_details_t_handler_json
2864 (vl_api_one_eid_table_map_details_t * mp)
2866 vat_main_t *vam = &vat_main;
2867 vat_json_node_t *node = NULL;
2869 if (VAT_JSON_ARRAY != vam->json_tree.type)
2871 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2872 vat_json_init_array (&vam->json_tree);
2874 node = vat_json_array_add (&vam->json_tree);
2875 vat_json_init_object (node);
2876 vat_json_object_add_uint (node, "dp_table",
2877 clib_net_to_host_u32 (mp->dp_table));
2878 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2882 vl_api_one_eid_table_vni_details_t_handler
2883 (vl_api_one_eid_table_vni_details_t * mp)
2885 vat_main_t *vam = &vat_main;
2887 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2888 print (vam->ofp, "%v", line);
2893 vl_api_one_eid_table_vni_details_t_handler_json
2894 (vl_api_one_eid_table_vni_details_t * mp)
2896 vat_main_t *vam = &vat_main;
2897 vat_json_node_t *node = NULL;
2899 if (VAT_JSON_ARRAY != vam->json_tree.type)
2901 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2902 vat_json_init_array (&vam->json_tree);
2904 node = vat_json_array_add (&vam->json_tree);
2905 vat_json_init_object (node);
2906 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2910 vl_api_show_one_map_register_state_reply_t_handler
2911 (vl_api_show_one_map_register_state_reply_t * mp)
2913 vat_main_t *vam = &vat_main;
2914 int retval = clib_net_to_host_u32 (mp->retval);
2916 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2918 vam->retval = retval;
2919 vam->result_ready = 1;
2923 vl_api_show_one_map_register_state_reply_t_handler_json
2924 (vl_api_show_one_map_register_state_reply_t * mp)
2926 vat_main_t *vam = &vat_main;
2927 vat_json_node_t _node, *node = &_node;
2928 int retval = clib_net_to_host_u32 (mp->retval);
2930 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2932 vat_json_init_object (node);
2933 vat_json_object_add_string_copy (node, "state", s);
2935 vat_json_print (vam->ofp, node);
2936 vat_json_free (node);
2938 vam->retval = retval;
2939 vam->result_ready = 1;
2944 vl_api_show_one_rloc_probe_state_reply_t_handler
2945 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2947 vat_main_t *vam = &vat_main;
2948 int retval = clib_net_to_host_u32 (mp->retval);
2953 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2955 vam->retval = retval;
2956 vam->result_ready = 1;
2960 vl_api_show_one_rloc_probe_state_reply_t_handler_json
2961 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2963 vat_main_t *vam = &vat_main;
2964 vat_json_node_t _node, *node = &_node;
2965 int retval = clib_net_to_host_u32 (mp->retval);
2967 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2968 vat_json_init_object (node);
2969 vat_json_object_add_string_copy (node, "state", s);
2971 vat_json_print (vam->ofp, node);
2972 vat_json_free (node);
2974 vam->retval = retval;
2975 vam->result_ready = 1;
2980 vl_api_show_one_stats_enable_disable_reply_t_handler
2981 (vl_api_show_one_stats_enable_disable_reply_t * mp)
2983 vat_main_t *vam = &vat_main;
2984 int retval = clib_net_to_host_u32 (mp->retval);
2989 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
2991 vam->retval = retval;
2992 vam->result_ready = 1;
2996 vl_api_show_one_stats_enable_disable_reply_t_handler_json
2997 (vl_api_show_one_stats_enable_disable_reply_t * mp)
2999 vat_main_t *vam = &vat_main;
3000 vat_json_node_t _node, *node = &_node;
3001 int retval = clib_net_to_host_u32 (mp->retval);
3003 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3004 vat_json_init_object (node);
3005 vat_json_object_add_string_copy (node, "state", s);
3007 vat_json_print (vam->ofp, node);
3008 vat_json_free (node);
3010 vam->retval = retval;
3011 vam->result_ready = 1;
3016 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3018 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3019 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3020 e->vni = clib_net_to_host_u32 (e->vni);
3024 gpe_fwd_entries_get_reply_t_net_to_host
3025 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3029 mp->count = clib_net_to_host_u32 (mp->count);
3030 for (i = 0; i < mp->count; i++)
3032 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3037 format_gpe_encap_mode (u8 * s, va_list * args)
3039 u32 mode = va_arg (*args, u32);
3044 return format (s, "lisp");
3046 return format (s, "vxlan");
3052 vl_api_gpe_get_encap_mode_reply_t_handler
3053 (vl_api_gpe_get_encap_mode_reply_t * mp)
3055 vat_main_t *vam = &vat_main;
3057 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3058 vam->retval = ntohl (mp->retval);
3059 vam->result_ready = 1;
3063 vl_api_gpe_get_encap_mode_reply_t_handler_json
3064 (vl_api_gpe_get_encap_mode_reply_t * mp)
3066 vat_main_t *vam = &vat_main;
3067 vat_json_node_t node;
3069 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3070 vec_add1 (encap_mode, 0);
3072 vat_json_init_object (&node);
3073 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3075 vec_free (encap_mode);
3076 vat_json_print (vam->ofp, &node);
3077 vat_json_free (&node);
3079 vam->retval = ntohl (mp->retval);
3080 vam->result_ready = 1;
3084 vl_api_gpe_fwd_entry_path_details_t_handler
3085 (vl_api_gpe_fwd_entry_path_details_t * mp)
3087 vat_main_t *vam = &vat_main;
3088 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3090 if (mp->lcl_loc.is_ip4)
3091 format_ip_address_fcn = format_ip4_address;
3093 format_ip_address_fcn = format_ip6_address;
3095 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3096 format_ip_address_fcn, &mp->lcl_loc,
3097 format_ip_address_fcn, &mp->rmt_loc);
3101 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3103 struct in6_addr ip6;
3108 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3109 vat_json_object_add_ip4 (n, "address", ip4);
3113 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3114 vat_json_object_add_ip6 (n, "address", ip6);
3116 vat_json_object_add_uint (n, "weight", loc->weight);
3120 vl_api_gpe_fwd_entry_path_details_t_handler_json
3121 (vl_api_gpe_fwd_entry_path_details_t * mp)
3123 vat_main_t *vam = &vat_main;
3124 vat_json_node_t *node = NULL;
3125 vat_json_node_t *loc_node;
3127 if (VAT_JSON_ARRAY != vam->json_tree.type)
3129 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3130 vat_json_init_array (&vam->json_tree);
3132 node = vat_json_array_add (&vam->json_tree);
3133 vat_json_init_object (node);
3135 loc_node = vat_json_object_add (node, "local_locator");
3136 vat_json_init_object (loc_node);
3137 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3139 loc_node = vat_json_object_add (node, "remote_locator");
3140 vat_json_init_object (loc_node);
3141 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3145 vl_api_gpe_fwd_entries_get_reply_t_handler
3146 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3148 vat_main_t *vam = &vat_main;
3150 int retval = clib_net_to_host_u32 (mp->retval);
3151 vl_api_gpe_fwd_entry_t *e;
3156 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3158 for (i = 0; i < mp->count; i++)
3160 e = &mp->entries[i];
3161 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3162 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3163 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3167 vam->retval = retval;
3168 vam->result_ready = 1;
3172 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3173 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3176 vat_main_t *vam = &vat_main;
3177 vat_json_node_t *e = 0, root;
3179 int retval = clib_net_to_host_u32 (mp->retval);
3180 vl_api_gpe_fwd_entry_t *fwd;
3185 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3186 vat_json_init_array (&root);
3188 for (i = 0; i < mp->count; i++)
3190 e = vat_json_array_add (&root);
3191 fwd = &mp->entries[i];
3193 vat_json_init_object (e);
3194 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3195 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3196 vat_json_object_add_int (e, "vni", fwd->vni);
3197 vat_json_object_add_int (e, "action", fwd->action);
3199 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3200 fwd->leid_prefix_len);
3202 vat_json_object_add_string_copy (e, "leid", s);
3205 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3206 fwd->reid_prefix_len);
3208 vat_json_object_add_string_copy (e, "reid", s);
3212 vat_json_print (vam->ofp, &root);
3213 vat_json_free (&root);
3216 vam->retval = retval;
3217 vam->result_ready = 1;
3221 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3222 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3224 vat_main_t *vam = &vat_main;
3226 int retval = clib_net_to_host_u32 (mp->retval);
3227 vl_api_gpe_native_fwd_rpath_t *r;
3232 n = clib_net_to_host_u32 (mp->count);
3234 for (i = 0; i < n; i++)
3236 r = &mp->entries[i];
3237 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3238 clib_net_to_host_u32 (r->fib_index),
3239 clib_net_to_host_u32 (r->nh_sw_if_index),
3240 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3244 vam->retval = retval;
3245 vam->result_ready = 1;
3249 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3250 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3252 vat_main_t *vam = &vat_main;
3253 vat_json_node_t root, *e;
3255 int retval = clib_net_to_host_u32 (mp->retval);
3256 vl_api_gpe_native_fwd_rpath_t *r;
3262 n = clib_net_to_host_u32 (mp->count);
3263 vat_json_init_array (&root);
3265 for (i = 0; i < n; i++)
3267 e = vat_json_array_add (&root);
3268 vat_json_init_object (e);
3269 r = &mp->entries[i];
3271 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3274 vat_json_object_add_string_copy (e, "ip4", s);
3277 vat_json_object_add_uint (e, "fib_index",
3278 clib_net_to_host_u32 (r->fib_index));
3279 vat_json_object_add_uint (e, "nh_sw_if_index",
3280 clib_net_to_host_u32 (r->nh_sw_if_index));
3283 vat_json_print (vam->ofp, &root);
3284 vat_json_free (&root);
3287 vam->retval = retval;
3288 vam->result_ready = 1;
3292 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3293 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3295 vat_main_t *vam = &vat_main;
3297 int retval = clib_net_to_host_u32 (mp->retval);
3302 n = clib_net_to_host_u32 (mp->count);
3304 for (i = 0; i < n; i++)
3305 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3308 vam->retval = retval;
3309 vam->result_ready = 1;
3313 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3314 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3316 vat_main_t *vam = &vat_main;
3317 vat_json_node_t root;
3319 int retval = clib_net_to_host_u32 (mp->retval);
3324 n = clib_net_to_host_u32 (mp->count);
3325 vat_json_init_array (&root);
3327 for (i = 0; i < n; i++)
3328 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3330 vat_json_print (vam->ofp, &root);
3331 vat_json_free (&root);
3334 vam->retval = retval;
3335 vam->result_ready = 1;
3339 vl_api_one_l2_arp_entries_get_reply_t_handler
3340 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3342 vat_main_t *vam = &vat_main;
3344 int retval = clib_net_to_host_u32 (mp->retval);
3349 n = clib_net_to_host_u32 (mp->count);
3351 for (i = 0; i < n; i++)
3352 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3353 format_ethernet_address, mp->entries[i].mac);
3356 vam->retval = retval;
3357 vam->result_ready = 1;
3361 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3362 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3365 vat_main_t *vam = &vat_main;
3366 vat_json_node_t *e = 0, root;
3368 int retval = clib_net_to_host_u32 (mp->retval);
3369 vl_api_one_l2_arp_entry_t *arp_entry;
3374 n = clib_net_to_host_u32 (mp->count);
3375 vat_json_init_array (&root);
3377 for (i = 0; i < n; i++)
3379 e = vat_json_array_add (&root);
3380 arp_entry = &mp->entries[i];
3382 vat_json_init_object (e);
3383 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3386 vat_json_object_add_string_copy (e, "mac", s);
3389 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3391 vat_json_object_add_string_copy (e, "ip4", s);
3395 vat_json_print (vam->ofp, &root);
3396 vat_json_free (&root);
3399 vam->retval = retval;
3400 vam->result_ready = 1;
3404 vl_api_one_l2_arp_bd_get_reply_t_handler
3405 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3407 vat_main_t *vam = &vat_main;
3409 int retval = clib_net_to_host_u32 (mp->retval);
3414 n = clib_net_to_host_u32 (mp->count);
3416 for (i = 0; i < n; i++)
3418 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3422 vam->retval = retval;
3423 vam->result_ready = 1;
3427 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3428 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3430 vat_main_t *vam = &vat_main;
3431 vat_json_node_t root;
3433 int retval = clib_net_to_host_u32 (mp->retval);
3438 n = clib_net_to_host_u32 (mp->count);
3439 vat_json_init_array (&root);
3441 for (i = 0; i < n; i++)
3443 vat_json_array_add_uint (&root,
3444 clib_net_to_host_u32 (mp->bridge_domains[i]));
3447 vat_json_print (vam->ofp, &root);
3448 vat_json_free (&root);
3451 vam->retval = retval;
3452 vam->result_ready = 1;
3456 vl_api_one_adjacencies_get_reply_t_handler
3457 (vl_api_one_adjacencies_get_reply_t * mp)
3459 vat_main_t *vam = &vat_main;
3461 int retval = clib_net_to_host_u32 (mp->retval);
3462 vl_api_one_adjacency_t *a;
3467 n = clib_net_to_host_u32 (mp->count);
3469 for (i = 0; i < n; i++)
3471 a = &mp->adjacencies[i];
3472 print (vam->ofp, "%U %40U",
3473 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3474 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3478 vam->retval = retval;
3479 vam->result_ready = 1;
3483 vl_api_one_adjacencies_get_reply_t_handler_json
3484 (vl_api_one_adjacencies_get_reply_t * mp)
3487 vat_main_t *vam = &vat_main;
3488 vat_json_node_t *e = 0, root;
3490 int retval = clib_net_to_host_u32 (mp->retval);
3491 vl_api_one_adjacency_t *a;
3496 n = clib_net_to_host_u32 (mp->count);
3497 vat_json_init_array (&root);
3499 for (i = 0; i < n; i++)
3501 e = vat_json_array_add (&root);
3502 a = &mp->adjacencies[i];
3504 vat_json_init_object (e);
3505 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3506 a->leid_prefix_len);
3508 vat_json_object_add_string_copy (e, "leid", s);
3511 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3512 a->reid_prefix_len);
3514 vat_json_object_add_string_copy (e, "reid", s);
3518 vat_json_print (vam->ofp, &root);
3519 vat_json_free (&root);
3522 vam->retval = retval;
3523 vam->result_ready = 1;
3527 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3529 vat_main_t *vam = &vat_main;
3531 print (vam->ofp, "%=20U",
3532 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3537 vl_api_one_map_server_details_t_handler_json
3538 (vl_api_one_map_server_details_t * mp)
3540 vat_main_t *vam = &vat_main;
3541 vat_json_node_t *node = NULL;
3542 struct in6_addr ip6;
3545 if (VAT_JSON_ARRAY != vam->json_tree.type)
3547 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3548 vat_json_init_array (&vam->json_tree);
3550 node = vat_json_array_add (&vam->json_tree);
3552 vat_json_init_object (node);
3555 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3556 vat_json_object_add_ip6 (node, "map-server", ip6);
3560 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3561 vat_json_object_add_ip4 (node, "map-server", ip4);
3566 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3569 vat_main_t *vam = &vat_main;
3571 print (vam->ofp, "%=20U",
3572 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3577 vl_api_one_map_resolver_details_t_handler_json
3578 (vl_api_one_map_resolver_details_t * mp)
3580 vat_main_t *vam = &vat_main;
3581 vat_json_node_t *node = NULL;
3582 struct in6_addr ip6;
3585 if (VAT_JSON_ARRAY != vam->json_tree.type)
3587 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3588 vat_json_init_array (&vam->json_tree);
3590 node = vat_json_array_add (&vam->json_tree);
3592 vat_json_init_object (node);
3595 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3596 vat_json_object_add_ip6 (node, "map resolver", ip6);
3600 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3601 vat_json_object_add_ip4 (node, "map resolver", ip4);
3606 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3608 vat_main_t *vam = &vat_main;
3609 i32 retval = ntohl (mp->retval);
3613 print (vam->ofp, "feature: %s\ngpe: %s",
3614 mp->feature_status ? "enabled" : "disabled",
3615 mp->gpe_status ? "enabled" : "disabled");
3618 vam->retval = retval;
3619 vam->result_ready = 1;
3623 vl_api_show_one_status_reply_t_handler_json
3624 (vl_api_show_one_status_reply_t * mp)
3626 vat_main_t *vam = &vat_main;
3627 vat_json_node_t node;
3628 u8 *gpe_status = NULL;
3629 u8 *feature_status = NULL;
3631 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3632 feature_status = format (0, "%s",
3633 mp->feature_status ? "enabled" : "disabled");
3634 vec_add1 (gpe_status, 0);
3635 vec_add1 (feature_status, 0);
3637 vat_json_init_object (&node);
3638 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3639 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3641 vec_free (gpe_status);
3642 vec_free (feature_status);
3644 vat_json_print (vam->ofp, &node);
3645 vat_json_free (&node);
3647 vam->retval = ntohl (mp->retval);
3648 vam->result_ready = 1;
3652 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3653 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3655 vat_main_t *vam = &vat_main;
3656 i32 retval = ntohl (mp->retval);
3660 print (vam->ofp, "%=20s", mp->locator_set_name);
3663 vam->retval = retval;
3664 vam->result_ready = 1;
3668 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3669 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3671 vat_main_t *vam = &vat_main;
3672 vat_json_node_t *node = NULL;
3674 if (VAT_JSON_ARRAY != vam->json_tree.type)
3676 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3677 vat_json_init_array (&vam->json_tree);
3679 node = vat_json_array_add (&vam->json_tree);
3681 vat_json_init_object (node);
3682 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3684 vat_json_print (vam->ofp, node);
3685 vat_json_free (node);
3687 vam->retval = ntohl (mp->retval);
3688 vam->result_ready = 1;
3692 format_lisp_map_request_mode (u8 * s, va_list * args)
3694 u32 mode = va_arg (*args, u32);
3699 return format (0, "dst-only");
3701 return format (0, "src-dst");
3707 vl_api_show_one_map_request_mode_reply_t_handler
3708 (vl_api_show_one_map_request_mode_reply_t * mp)
3710 vat_main_t *vam = &vat_main;
3711 i32 retval = ntohl (mp->retval);
3715 u32 mode = mp->mode;
3716 print (vam->ofp, "map_request_mode: %U",
3717 format_lisp_map_request_mode, mode);
3720 vam->retval = retval;
3721 vam->result_ready = 1;
3725 vl_api_show_one_map_request_mode_reply_t_handler_json
3726 (vl_api_show_one_map_request_mode_reply_t * mp)
3728 vat_main_t *vam = &vat_main;
3729 vat_json_node_t node;
3734 s = format (0, "%U", format_lisp_map_request_mode, mode);
3737 vat_json_init_object (&node);
3738 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3739 vat_json_print (vam->ofp, &node);
3740 vat_json_free (&node);
3743 vam->retval = ntohl (mp->retval);
3744 vam->result_ready = 1;
3748 vl_api_show_one_use_petr_reply_t_handler
3749 (vl_api_show_one_use_petr_reply_t * mp)
3751 vat_main_t *vam = &vat_main;
3752 i32 retval = ntohl (mp->retval);
3756 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
3759 print (vam->ofp, "Proxy-ETR address; %U",
3760 mp->is_ip4 ? format_ip4_address : format_ip6_address,
3765 vam->retval = retval;
3766 vam->result_ready = 1;
3770 vl_api_show_one_use_petr_reply_t_handler_json
3771 (vl_api_show_one_use_petr_reply_t * mp)
3773 vat_main_t *vam = &vat_main;
3774 vat_json_node_t node;
3777 struct in6_addr ip6;
3779 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3780 vec_add1 (status, 0);
3782 vat_json_init_object (&node);
3783 vat_json_object_add_string_copy (&node, "status", status);
3788 clib_memcpy (&ip6, mp->address, sizeof (ip6));
3789 vat_json_object_add_ip6 (&node, "address", ip6);
3793 clib_memcpy (&ip4, mp->address, sizeof (ip4));
3794 vat_json_object_add_ip4 (&node, "address", ip4);
3800 vat_json_print (vam->ofp, &node);
3801 vat_json_free (&node);
3803 vam->retval = ntohl (mp->retval);
3804 vam->result_ready = 1;
3808 vl_api_show_one_nsh_mapping_reply_t_handler
3809 (vl_api_show_one_nsh_mapping_reply_t * mp)
3811 vat_main_t *vam = &vat_main;
3812 i32 retval = ntohl (mp->retval);
3816 print (vam->ofp, "%-20s%-16s",
3817 mp->is_set ? "set" : "not-set",
3818 mp->is_set ? (char *) mp->locator_set_name : "");
3821 vam->retval = retval;
3822 vam->result_ready = 1;
3826 vl_api_show_one_nsh_mapping_reply_t_handler_json
3827 (vl_api_show_one_nsh_mapping_reply_t * mp)
3829 vat_main_t *vam = &vat_main;
3830 vat_json_node_t node;
3833 status = format (0, "%s", mp->is_set ? "yes" : "no");
3834 vec_add1 (status, 0);
3836 vat_json_init_object (&node);
3837 vat_json_object_add_string_copy (&node, "is_set", status);
3840 vat_json_object_add_string_copy (&node, "locator_set",
3841 mp->locator_set_name);
3846 vat_json_print (vam->ofp, &node);
3847 vat_json_free (&node);
3849 vam->retval = ntohl (mp->retval);
3850 vam->result_ready = 1;
3854 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3856 vat_main_t *vam = &vat_main;
3857 i32 retval = ntohl (mp->retval);
3861 print (vam->ofp, "%-20s%-16s",
3862 mp->status ? "enabled" : "disabled",
3863 mp->status ? (char *) mp->locator_set_name : "");
3866 vam->retval = retval;
3867 vam->result_ready = 1;
3871 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3873 vat_main_t *vam = &vat_main;
3874 vat_json_node_t node;
3877 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3878 vec_add1 (status, 0);
3880 vat_json_init_object (&node);
3881 vat_json_object_add_string_copy (&node, "status", status);
3884 vat_json_object_add_string_copy (&node, "locator_set",
3885 mp->locator_set_name);
3890 vat_json_print (vam->ofp, &node);
3891 vat_json_free (&node);
3893 vam->retval = ntohl (mp->retval);
3894 vam->result_ready = 1;
3898 format_policer_type (u8 * s, va_list * va)
3900 u32 i = va_arg (*va, u32);
3902 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3903 s = format (s, "1r2c");
3904 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3905 s = format (s, "1r3c");
3906 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3907 s = format (s, "2r3c-2698");
3908 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3909 s = format (s, "2r3c-4115");
3910 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3911 s = format (s, "2r3c-mef5cf1");
3913 s = format (s, "ILLEGAL");
3918 format_policer_rate_type (u8 * s, va_list * va)
3920 u32 i = va_arg (*va, u32);
3922 if (i == SSE2_QOS_RATE_KBPS)
3923 s = format (s, "kbps");
3924 else if (i == SSE2_QOS_RATE_PPS)
3925 s = format (s, "pps");
3927 s = format (s, "ILLEGAL");
3932 format_policer_round_type (u8 * s, va_list * va)
3934 u32 i = va_arg (*va, u32);
3936 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3937 s = format (s, "closest");
3938 else if (i == SSE2_QOS_ROUND_TO_UP)
3939 s = format (s, "up");
3940 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3941 s = format (s, "down");
3943 s = format (s, "ILLEGAL");
3948 format_policer_action_type (u8 * s, va_list * va)
3950 u32 i = va_arg (*va, u32);
3952 if (i == SSE2_QOS_ACTION_DROP)
3953 s = format (s, "drop");
3954 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3955 s = format (s, "transmit");
3956 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3957 s = format (s, "mark-and-transmit");
3959 s = format (s, "ILLEGAL");
3964 format_dscp (u8 * s, va_list * va)
3966 u32 i = va_arg (*va, u32);
3971 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3975 return format (s, "ILLEGAL");
3977 s = format (s, "%s", t);
3982 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3984 vat_main_t *vam = &vat_main;
3985 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3987 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3988 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3990 conform_dscp_str = format (0, "");
3992 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3993 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3995 exceed_dscp_str = format (0, "");
3997 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3998 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4000 violate_dscp_str = format (0, "");
4002 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4003 "rate type %U, round type %U, %s rate, %s color-aware, "
4004 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4005 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4006 "conform action %U%s, exceed action %U%s, violate action %U%s",
4008 format_policer_type, mp->type,
4011 clib_net_to_host_u64 (mp->cb),
4012 clib_net_to_host_u64 (mp->eb),
4013 format_policer_rate_type, mp->rate_type,
4014 format_policer_round_type, mp->round_type,
4015 mp->single_rate ? "single" : "dual",
4016 mp->color_aware ? "is" : "not",
4017 ntohl (mp->cir_tokens_per_period),
4018 ntohl (mp->pir_tokens_per_period),
4020 ntohl (mp->current_limit),
4021 ntohl (mp->current_bucket),
4022 ntohl (mp->extended_limit),
4023 ntohl (mp->extended_bucket),
4024 clib_net_to_host_u64 (mp->last_update_time),
4025 format_policer_action_type, mp->conform_action_type,
4027 format_policer_action_type, mp->exceed_action_type,
4029 format_policer_action_type, mp->violate_action_type,
4032 vec_free (conform_dscp_str);
4033 vec_free (exceed_dscp_str);
4034 vec_free (violate_dscp_str);
4037 static void vl_api_policer_details_t_handler_json
4038 (vl_api_policer_details_t * mp)
4040 vat_main_t *vam = &vat_main;
4041 vat_json_node_t *node;
4042 u8 *rate_type_str, *round_type_str, *type_str;
4043 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4045 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4047 format (0, "%U", format_policer_round_type, mp->round_type);
4048 type_str = format (0, "%U", format_policer_type, mp->type);
4049 conform_action_str = format (0, "%U", format_policer_action_type,
4050 mp->conform_action_type);
4051 exceed_action_str = format (0, "%U", format_policer_action_type,
4052 mp->exceed_action_type);
4053 violate_action_str = format (0, "%U", format_policer_action_type,
4054 mp->violate_action_type);
4056 if (VAT_JSON_ARRAY != vam->json_tree.type)
4058 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4059 vat_json_init_array (&vam->json_tree);
4061 node = vat_json_array_add (&vam->json_tree);
4063 vat_json_init_object (node);
4064 vat_json_object_add_string_copy (node, "name", mp->name);
4065 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4066 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4067 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4068 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4069 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4070 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4071 vat_json_object_add_string_copy (node, "type", type_str);
4072 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4073 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4074 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4075 vat_json_object_add_uint (node, "cir_tokens_per_period",
4076 ntohl (mp->cir_tokens_per_period));
4077 vat_json_object_add_uint (node, "eir_tokens_per_period",
4078 ntohl (mp->pir_tokens_per_period));
4079 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4080 vat_json_object_add_uint (node, "current_bucket",
4081 ntohl (mp->current_bucket));
4082 vat_json_object_add_uint (node, "extended_limit",
4083 ntohl (mp->extended_limit));
4084 vat_json_object_add_uint (node, "extended_bucket",
4085 ntohl (mp->extended_bucket));
4086 vat_json_object_add_uint (node, "last_update_time",
4087 ntohl (mp->last_update_time));
4088 vat_json_object_add_string_copy (node, "conform_action",
4089 conform_action_str);
4090 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4092 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4093 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4094 vec_free (dscp_str);
4096 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4097 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4099 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4100 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4101 vec_free (dscp_str);
4103 vat_json_object_add_string_copy (node, "violate_action",
4104 violate_action_str);
4105 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4107 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4108 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4109 vec_free (dscp_str);
4112 vec_free (rate_type_str);
4113 vec_free (round_type_str);
4114 vec_free (type_str);
4115 vec_free (conform_action_str);
4116 vec_free (exceed_action_str);
4117 vec_free (violate_action_str);
4121 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4124 vat_main_t *vam = &vat_main;
4125 int i, count = ntohl (mp->count);
4128 print (vam->ofp, "classify table ids (%d) : ", count);
4129 for (i = 0; i < count; i++)
4131 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4132 print (vam->ofp, (i < count - 1) ? "," : "");
4134 vam->retval = ntohl (mp->retval);
4135 vam->result_ready = 1;
4139 vl_api_classify_table_ids_reply_t_handler_json
4140 (vl_api_classify_table_ids_reply_t * mp)
4142 vat_main_t *vam = &vat_main;
4143 int i, count = ntohl (mp->count);
4147 vat_json_node_t node;
4149 vat_json_init_object (&node);
4150 for (i = 0; i < count; i++)
4152 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4154 vat_json_print (vam->ofp, &node);
4155 vat_json_free (&node);
4157 vam->retval = ntohl (mp->retval);
4158 vam->result_ready = 1;
4162 vl_api_classify_table_by_interface_reply_t_handler
4163 (vl_api_classify_table_by_interface_reply_t * mp)
4165 vat_main_t *vam = &vat_main;
4168 table_id = ntohl (mp->l2_table_id);
4170 print (vam->ofp, "l2 table id : %d", table_id);
4172 print (vam->ofp, "l2 table id : No input ACL tables configured");
4173 table_id = ntohl (mp->ip4_table_id);
4175 print (vam->ofp, "ip4 table id : %d", table_id);
4177 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4178 table_id = ntohl (mp->ip6_table_id);
4180 print (vam->ofp, "ip6 table id : %d", table_id);
4182 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4183 vam->retval = ntohl (mp->retval);
4184 vam->result_ready = 1;
4188 vl_api_classify_table_by_interface_reply_t_handler_json
4189 (vl_api_classify_table_by_interface_reply_t * mp)
4191 vat_main_t *vam = &vat_main;
4192 vat_json_node_t node;
4194 vat_json_init_object (&node);
4196 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4197 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4198 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4200 vat_json_print (vam->ofp, &node);
4201 vat_json_free (&node);
4203 vam->retval = ntohl (mp->retval);
4204 vam->result_ready = 1;
4207 static void vl_api_policer_add_del_reply_t_handler
4208 (vl_api_policer_add_del_reply_t * mp)
4210 vat_main_t *vam = &vat_main;
4211 i32 retval = ntohl (mp->retval);
4212 if (vam->async_mode)
4214 vam->async_errors += (retval < 0);
4218 vam->retval = retval;
4219 vam->result_ready = 1;
4220 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4222 * Note: this is just barely thread-safe, depends on
4223 * the main thread spinning waiting for an answer...
4225 errmsg ("policer index %d", ntohl (mp->policer_index));
4229 static void vl_api_policer_add_del_reply_t_handler_json
4230 (vl_api_policer_add_del_reply_t * mp)
4232 vat_main_t *vam = &vat_main;
4233 vat_json_node_t node;
4235 vat_json_init_object (&node);
4236 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4237 vat_json_object_add_uint (&node, "policer_index",
4238 ntohl (mp->policer_index));
4240 vat_json_print (vam->ofp, &node);
4241 vat_json_free (&node);
4243 vam->retval = ntohl (mp->retval);
4244 vam->result_ready = 1;
4247 /* Format hex dump. */
4249 format_hex_bytes (u8 * s, va_list * va)
4251 u8 *bytes = va_arg (*va, u8 *);
4252 int n_bytes = va_arg (*va, int);
4255 /* Print short or long form depending on byte count. */
4256 uword short_form = n_bytes <= 32;
4257 uword indent = format_get_indent (s);
4262 for (i = 0; i < n_bytes; i++)
4264 if (!short_form && (i % 32) == 0)
4265 s = format (s, "%08x: ", i);
4266 s = format (s, "%02x", bytes[i]);
4267 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4268 s = format (s, "\n%U", format_white_space, indent);
4275 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4278 vat_main_t *vam = &vat_main;
4279 i32 retval = ntohl (mp->retval);
4282 print (vam->ofp, "classify table info :");
4283 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4284 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4285 ntohl (mp->miss_next_index));
4286 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4287 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4288 ntohl (mp->match_n_vectors));
4289 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4290 ntohl (mp->mask_length));
4292 vam->retval = retval;
4293 vam->result_ready = 1;
4297 vl_api_classify_table_info_reply_t_handler_json
4298 (vl_api_classify_table_info_reply_t * mp)
4300 vat_main_t *vam = &vat_main;
4301 vat_json_node_t node;
4303 i32 retval = ntohl (mp->retval);
4306 vat_json_init_object (&node);
4308 vat_json_object_add_int (&node, "sessions",
4309 ntohl (mp->active_sessions));
4310 vat_json_object_add_int (&node, "nexttbl",
4311 ntohl (mp->next_table_index));
4312 vat_json_object_add_int (&node, "nextnode",
4313 ntohl (mp->miss_next_index));
4314 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4315 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4316 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4317 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4318 ntohl (mp->mask_length), 0);
4319 vat_json_object_add_string_copy (&node, "mask", s);
4321 vat_json_print (vam->ofp, &node);
4322 vat_json_free (&node);
4324 vam->retval = ntohl (mp->retval);
4325 vam->result_ready = 1;
4329 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4332 vat_main_t *vam = &vat_main;
4334 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4335 ntohl (mp->hit_next_index), ntohl (mp->advance),
4336 ntohl (mp->opaque_index));
4337 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4338 ntohl (mp->match_length));
4342 vl_api_classify_session_details_t_handler_json
4343 (vl_api_classify_session_details_t * mp)
4345 vat_main_t *vam = &vat_main;
4346 vat_json_node_t *node = NULL;
4348 if (VAT_JSON_ARRAY != vam->json_tree.type)
4350 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4351 vat_json_init_array (&vam->json_tree);
4353 node = vat_json_array_add (&vam->json_tree);
4355 vat_json_init_object (node);
4356 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4357 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4358 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4360 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4362 vat_json_object_add_string_copy (node, "match", s);
4365 static void vl_api_pg_create_interface_reply_t_handler
4366 (vl_api_pg_create_interface_reply_t * mp)
4368 vat_main_t *vam = &vat_main;
4370 vam->retval = ntohl (mp->retval);
4371 vam->result_ready = 1;
4374 static void vl_api_pg_create_interface_reply_t_handler_json
4375 (vl_api_pg_create_interface_reply_t * mp)
4377 vat_main_t *vam = &vat_main;
4378 vat_json_node_t node;
4380 i32 retval = ntohl (mp->retval);
4383 vat_json_init_object (&node);
4385 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4387 vat_json_print (vam->ofp, &node);
4388 vat_json_free (&node);
4390 vam->retval = ntohl (mp->retval);
4391 vam->result_ready = 1;
4394 static void vl_api_policer_classify_details_t_handler
4395 (vl_api_policer_classify_details_t * mp)
4397 vat_main_t *vam = &vat_main;
4399 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4400 ntohl (mp->table_index));
4403 static void vl_api_policer_classify_details_t_handler_json
4404 (vl_api_policer_classify_details_t * mp)
4406 vat_main_t *vam = &vat_main;
4407 vat_json_node_t *node;
4409 if (VAT_JSON_ARRAY != vam->json_tree.type)
4411 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4412 vat_json_init_array (&vam->json_tree);
4414 node = vat_json_array_add (&vam->json_tree);
4416 vat_json_init_object (node);
4417 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4418 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4421 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4422 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4424 vat_main_t *vam = &vat_main;
4425 i32 retval = ntohl (mp->retval);
4426 if (vam->async_mode)
4428 vam->async_errors += (retval < 0);
4432 vam->retval = retval;
4433 vam->sw_if_index = ntohl (mp->sw_if_index);
4434 vam->result_ready = 1;
4438 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4439 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4441 vat_main_t *vam = &vat_main;
4442 vat_json_node_t node;
4444 vat_json_init_object (&node);
4445 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4446 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4448 vat_json_print (vam->ofp, &node);
4449 vat_json_free (&node);
4451 vam->retval = ntohl (mp->retval);
4452 vam->result_ready = 1;
4455 static void vl_api_flow_classify_details_t_handler
4456 (vl_api_flow_classify_details_t * mp)
4458 vat_main_t *vam = &vat_main;
4460 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4461 ntohl (mp->table_index));
4464 static void vl_api_flow_classify_details_t_handler_json
4465 (vl_api_flow_classify_details_t * mp)
4467 vat_main_t *vam = &vat_main;
4468 vat_json_node_t *node;
4470 if (VAT_JSON_ARRAY != vam->json_tree.type)
4472 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4473 vat_json_init_array (&vam->json_tree);
4475 node = vat_json_array_add (&vam->json_tree);
4477 vat_json_init_object (node);
4478 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4479 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4482 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
4483 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
4484 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
4485 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
4486 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4487 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4488 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4489 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4490 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4491 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4492 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4493 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4494 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4495 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4496 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
4497 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
4498 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
4499 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
4502 * Generate boilerplate reply handlers, which
4503 * dig the return value out of the xxx_reply_t API message,
4504 * stick it into vam->retval, and set vam->result_ready
4506 * Could also do this by pointing N message decode slots at
4507 * a single function, but that could break in subtle ways.
4510 #define foreach_standard_reply_retval_handler \
4511 _(sw_interface_set_flags_reply) \
4512 _(sw_interface_add_del_address_reply) \
4513 _(sw_interface_set_table_reply) \
4514 _(sw_interface_set_mpls_enable_reply) \
4515 _(sw_interface_set_vpath_reply) \
4516 _(sw_interface_set_vxlan_bypass_reply) \
4517 _(sw_interface_set_vxlan_gpe_bypass_reply) \
4518 _(sw_interface_set_l2_bridge_reply) \
4519 _(bridge_domain_add_del_reply) \
4520 _(sw_interface_set_l2_xconnect_reply) \
4521 _(l2fib_add_del_reply) \
4522 _(l2fib_flush_int_reply) \
4523 _(l2fib_flush_bd_reply) \
4524 _(ip_add_del_route_reply) \
4525 _(ip_mroute_add_del_reply) \
4526 _(mpls_route_add_del_reply) \
4527 _(mpls_ip_bind_unbind_reply) \
4528 _(proxy_arp_add_del_reply) \
4529 _(proxy_arp_intfc_enable_disable_reply) \
4530 _(sw_interface_set_unnumbered_reply) \
4531 _(ip_neighbor_add_del_reply) \
4532 _(reset_vrf_reply) \
4533 _(oam_add_del_reply) \
4534 _(reset_fib_reply) \
4535 _(dhcp_proxy_config_reply) \
4536 _(dhcp_proxy_set_vss_reply) \
4537 _(dhcp_client_config_reply) \
4538 _(set_ip_flow_hash_reply) \
4539 _(sw_interface_ip6_enable_disable_reply) \
4540 _(sw_interface_ip6_set_link_local_address_reply) \
4541 _(ip6nd_proxy_add_del_reply) \
4542 _(sw_interface_ip6nd_ra_prefix_reply) \
4543 _(sw_interface_ip6nd_ra_config_reply) \
4544 _(set_arp_neighbor_limit_reply) \
4545 _(l2_patch_add_del_reply) \
4546 _(sr_policy_add_reply) \
4547 _(sr_policy_mod_reply) \
4548 _(sr_policy_del_reply) \
4549 _(sr_localsid_add_del_reply) \
4550 _(sr_steering_add_del_reply) \
4551 _(classify_add_del_session_reply) \
4552 _(classify_set_interface_ip_table_reply) \
4553 _(classify_set_interface_l2_tables_reply) \
4554 _(l2tpv3_set_tunnel_cookies_reply) \
4555 _(l2tpv3_interface_enable_disable_reply) \
4556 _(l2tpv3_set_lookup_key_reply) \
4557 _(l2_fib_clear_table_reply) \
4558 _(l2_interface_efp_filter_reply) \
4559 _(l2_interface_vlan_tag_rewrite_reply) \
4560 _(modify_vhost_user_if_reply) \
4561 _(delete_vhost_user_if_reply) \
4562 _(want_ip4_arp_events_reply) \
4563 _(want_ip6_nd_events_reply) \
4564 _(input_acl_set_interface_reply) \
4565 _(ipsec_spd_add_del_reply) \
4566 _(ipsec_interface_add_del_spd_reply) \
4567 _(ipsec_spd_add_del_entry_reply) \
4568 _(ipsec_sad_add_del_entry_reply) \
4569 _(ipsec_sa_set_key_reply) \
4570 _(ipsec_tunnel_if_add_del_reply) \
4571 _(ikev2_profile_add_del_reply) \
4572 _(ikev2_profile_set_auth_reply) \
4573 _(ikev2_profile_set_id_reply) \
4574 _(ikev2_profile_set_ts_reply) \
4575 _(ikev2_set_local_key_reply) \
4576 _(ikev2_set_responder_reply) \
4577 _(ikev2_set_ike_transforms_reply) \
4578 _(ikev2_set_esp_transforms_reply) \
4579 _(ikev2_set_sa_lifetime_reply) \
4580 _(ikev2_initiate_sa_init_reply) \
4581 _(ikev2_initiate_del_ike_sa_reply) \
4582 _(ikev2_initiate_del_child_sa_reply) \
4583 _(ikev2_initiate_rekey_child_sa_reply) \
4584 _(delete_loopback_reply) \
4585 _(bd_ip_mac_add_del_reply) \
4586 _(map_del_domain_reply) \
4587 _(map_add_del_rule_reply) \
4588 _(want_interface_events_reply) \
4589 _(want_stats_reply) \
4590 _(cop_interface_enable_disable_reply) \
4591 _(cop_whitelist_enable_disable_reply) \
4592 _(sw_interface_clear_stats_reply) \
4593 _(ioam_enable_reply) \
4594 _(ioam_disable_reply) \
4595 _(one_add_del_locator_reply) \
4596 _(one_add_del_local_eid_reply) \
4597 _(one_add_del_remote_mapping_reply) \
4598 _(one_add_del_adjacency_reply) \
4599 _(one_add_del_map_resolver_reply) \
4600 _(one_add_del_map_server_reply) \
4601 _(one_enable_disable_reply) \
4602 _(one_rloc_probe_enable_disable_reply) \
4603 _(one_map_register_enable_disable_reply) \
4604 _(one_pitr_set_locator_set_reply) \
4605 _(one_map_request_mode_reply) \
4606 _(one_add_del_map_request_itr_rlocs_reply) \
4607 _(one_eid_table_add_del_map_reply) \
4608 _(one_use_petr_reply) \
4609 _(one_stats_enable_disable_reply) \
4610 _(one_add_del_l2_arp_entry_reply) \
4611 _(one_stats_flush_reply) \
4612 _(gpe_enable_disable_reply) \
4613 _(gpe_set_encap_mode_reply) \
4614 _(gpe_add_del_iface_reply) \
4615 _(gpe_add_del_native_fwd_rpath_reply) \
4616 _(af_packet_delete_reply) \
4617 _(policer_classify_set_interface_reply) \
4618 _(netmap_create_reply) \
4619 _(netmap_delete_reply) \
4620 _(set_ipfix_exporter_reply) \
4621 _(set_ipfix_classify_stream_reply) \
4622 _(ipfix_classify_table_add_del_reply) \
4623 _(flow_classify_set_interface_reply) \
4624 _(sw_interface_span_enable_disable_reply) \
4625 _(pg_capture_reply) \
4626 _(pg_enable_disable_reply) \
4627 _(ip_source_and_port_range_check_add_del_reply) \
4628 _(ip_source_and_port_range_check_interface_add_del_reply)\
4629 _(delete_subif_reply) \
4630 _(l2_interface_pbb_tag_rewrite_reply) \
4632 _(feature_enable_disable_reply) \
4633 _(sw_interface_tag_add_del_reply) \
4634 _(sw_interface_set_mtu_reply) \
4635 _(p2p_ethernet_add_reply) \
4636 _(p2p_ethernet_del_reply) \
4637 _(lldp_config_reply) \
4638 _(sw_interface_set_lldp_reply)
4641 static void vl_api_##n##_t_handler \
4642 (vl_api_##n##_t * mp) \
4644 vat_main_t * vam = &vat_main; \
4645 i32 retval = ntohl(mp->retval); \
4646 if (vam->async_mode) { \
4647 vam->async_errors += (retval < 0); \
4649 vam->retval = retval; \
4650 vam->result_ready = 1; \
4653 foreach_standard_reply_retval_handler;
4657 static void vl_api_##n##_t_handler_json \
4658 (vl_api_##n##_t * mp) \
4660 vat_main_t * vam = &vat_main; \
4661 vat_json_node_t node; \
4662 vat_json_init_object(&node); \
4663 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4664 vat_json_print(vam->ofp, &node); \
4665 vam->retval = ntohl(mp->retval); \
4666 vam->result_ready = 1; \
4668 foreach_standard_reply_retval_handler;
4672 * Table of message reply handlers, must include boilerplate handlers
4676 #define foreach_vpe_api_reply_msg \
4677 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4678 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4679 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4680 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4681 _(CONTROL_PING_REPLY, control_ping_reply) \
4682 _(CLI_REPLY, cli_reply) \
4683 _(CLI_INBAND_REPLY, cli_inband_reply) \
4684 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4685 sw_interface_add_del_address_reply) \
4686 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4687 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4688 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4689 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4690 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
4691 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4692 sw_interface_set_l2_xconnect_reply) \
4693 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4694 sw_interface_set_l2_bridge_reply) \
4695 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4696 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4697 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
4698 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4699 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
4700 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
4701 _(L2_FLAGS_REPLY, l2_flags_reply) \
4702 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4703 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4704 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4705 _(TAP_DELETE_REPLY, tap_delete_reply) \
4706 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4707 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4708 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4709 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4710 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4711 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4712 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4713 proxy_arp_intfc_enable_disable_reply) \
4714 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4715 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4716 sw_interface_set_unnumbered_reply) \
4717 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4718 _(RESET_VRF_REPLY, reset_vrf_reply) \
4719 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4720 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4721 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4722 _(RESET_FIB_REPLY, reset_fib_reply) \
4723 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4724 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4725 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4726 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4727 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4728 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4729 sw_interface_ip6_enable_disable_reply) \
4730 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4731 sw_interface_ip6_set_link_local_address_reply) \
4732 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
4733 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
4734 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4735 sw_interface_ip6nd_ra_prefix_reply) \
4736 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4737 sw_interface_ip6nd_ra_config_reply) \
4738 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4739 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4740 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4741 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4742 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4743 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4744 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4745 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4746 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4747 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4748 classify_set_interface_ip_table_reply) \
4749 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4750 classify_set_interface_l2_tables_reply) \
4751 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4752 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4753 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4754 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4755 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4756 l2tpv3_interface_enable_disable_reply) \
4757 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4758 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4759 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4760 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4761 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4762 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4763 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4764 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4765 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4766 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4767 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4768 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4769 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4770 _(SHOW_VERSION_REPLY, show_version_reply) \
4771 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
4772 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4773 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4774 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4775 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4776 _(IP4_ARP_EVENT, ip4_arp_event) \
4777 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4778 _(IP6_ND_EVENT, ip6_nd_event) \
4779 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4780 _(IP_ADDRESS_DETAILS, ip_address_details) \
4781 _(IP_DETAILS, ip_details) \
4782 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4783 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4784 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4785 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4786 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4787 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
4788 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4789 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4790 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4791 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4792 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4793 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4794 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4795 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4796 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4797 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4798 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4799 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4800 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4801 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4802 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4803 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4804 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4805 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4806 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4807 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4808 _(MAP_RULE_DETAILS, map_rule_details) \
4809 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4810 _(WANT_STATS_REPLY, want_stats_reply) \
4811 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4812 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4813 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4814 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4815 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4816 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4817 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4818 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4819 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4820 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4821 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4822 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4823 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4824 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4825 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4826 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4827 one_map_register_enable_disable_reply) \
4828 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4829 one_rloc_probe_enable_disable_reply) \
4830 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4831 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
4832 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4833 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4834 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4835 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4836 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4837 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4838 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4839 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4840 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4841 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4842 _(ONE_STATS_DETAILS, one_stats_details) \
4843 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
4844 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
4845 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
4846 show_one_stats_enable_disable_reply) \
4847 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
4848 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
4849 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
4850 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4851 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4852 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4853 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4854 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4855 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
4856 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4857 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
4858 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
4859 gpe_add_del_native_fwd_rpath_reply) \
4860 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4861 gpe_fwd_entry_path_details) \
4862 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4863 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4864 one_add_del_map_request_itr_rlocs_reply) \
4865 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4866 one_get_map_request_itr_rlocs_reply) \
4867 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
4868 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4869 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
4870 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4871 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4872 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4873 show_one_map_register_state_reply) \
4874 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4875 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4876 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4877 _(POLICER_DETAILS, policer_details) \
4878 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4879 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4880 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4881 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4882 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4883 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4884 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4885 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4886 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4887 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4888 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4889 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4890 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4891 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4892 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4893 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4894 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4895 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4896 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4897 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4898 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4899 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4900 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4901 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4902 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4903 ip_source_and_port_range_check_add_del_reply) \
4904 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4905 ip_source_and_port_range_check_interface_add_del_reply) \
4906 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4907 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4908 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4909 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4910 _(PUNT_REPLY, punt_reply) \
4911 _(IP_FIB_DETAILS, ip_fib_details) \
4912 _(IP6_FIB_DETAILS, ip6_fib_details) \
4913 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4914 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4915 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4916 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4917 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4918 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
4919 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
4920 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
4921 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
4922 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply)
4924 #define foreach_standalone_reply_msg \
4925 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4926 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
4927 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
4928 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4929 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4930 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4931 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
4940 #define STR_VTR_OP_CASE(op) \
4941 case L2_VTR_ ## op: \
4945 str_vtr_op (u32 vtr_op)
4949 STR_VTR_OP_CASE (DISABLED);
4950 STR_VTR_OP_CASE (PUSH_1);
4951 STR_VTR_OP_CASE (PUSH_2);
4952 STR_VTR_OP_CASE (POP_1);
4953 STR_VTR_OP_CASE (POP_2);
4954 STR_VTR_OP_CASE (TRANSLATE_1_1);
4955 STR_VTR_OP_CASE (TRANSLATE_1_2);
4956 STR_VTR_OP_CASE (TRANSLATE_2_1);
4957 STR_VTR_OP_CASE (TRANSLATE_2_2);
4964 dump_sub_interface_table (vat_main_t * vam)
4966 const sw_interface_subif_t *sub = NULL;
4968 if (vam->json_output)
4971 ("JSON output supported only for VPE API calls and dump_stats_table");
4976 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4977 "Interface", "sw_if_index",
4978 "sub id", "dot1ad", "tags", "outer id",
4979 "inner id", "exact", "default", "outer any", "inner any");
4981 vec_foreach (sub, vam->sw_if_subif_table)
4984 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4985 sub->interface_name,
4987 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4988 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4989 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4990 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4991 if (sub->vtr_op != L2_VTR_DISABLED)
4994 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4995 "tag1: %d tag2: %d ]",
4996 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4997 sub->vtr_tag1, sub->vtr_tag2);
5005 name_sort_cmp (void *a1, void *a2)
5007 name_sort_t *n1 = a1;
5008 name_sort_t *n2 = a2;
5010 return strcmp ((char *) n1->name, (char *) n2->name);
5014 dump_interface_table (vat_main_t * vam)
5017 name_sort_t *nses = 0, *ns;
5019 if (vam->json_output)
5022 ("JSON output supported only for VPE API calls and dump_stats_table");
5027 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5029 vec_add2 (nses, ns, 1);
5030 ns->name = (u8 *)(p->key);
5031 ns->value = (u32) p->value[0];
5035 vec_sort_with_function (nses, name_sort_cmp);
5037 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5038 vec_foreach (ns, nses)
5040 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5047 dump_ip_table (vat_main_t * vam, int is_ipv6)
5049 const ip_details_t *det = NULL;
5050 const ip_address_details_t *address = NULL;
5053 print (vam->ofp, "%-12s", "sw_if_index");
5055 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5062 print (vam->ofp, "%-12d", i);
5063 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5068 vec_foreach (address, det->addr)
5072 is_ipv6 ? format_ip6_address : format_ip4_address,
5073 address->ip, address->prefix_length);
5081 dump_ipv4_table (vat_main_t * vam)
5083 if (vam->json_output)
5086 ("JSON output supported only for VPE API calls and dump_stats_table");
5090 return dump_ip_table (vam, 0);
5094 dump_ipv6_table (vat_main_t * vam)
5096 if (vam->json_output)
5099 ("JSON output supported only for VPE API calls and dump_stats_table");
5103 return dump_ip_table (vam, 1);
5107 counter_type_to_str (u8 counter_type, u8 is_combined)
5111 switch (counter_type)
5113 case VNET_INTERFACE_COUNTER_DROP:
5115 case VNET_INTERFACE_COUNTER_PUNT:
5117 case VNET_INTERFACE_COUNTER_IP4:
5119 case VNET_INTERFACE_COUNTER_IP6:
5121 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5123 case VNET_INTERFACE_COUNTER_RX_MISS:
5125 case VNET_INTERFACE_COUNTER_RX_ERROR:
5127 case VNET_INTERFACE_COUNTER_TX_ERROR:
5130 return "INVALID-COUNTER-TYPE";
5135 switch (counter_type)
5137 case VNET_INTERFACE_COUNTER_RX:
5139 case VNET_INTERFACE_COUNTER_TX:
5142 return "INVALID-COUNTER-TYPE";
5148 dump_stats_table (vat_main_t * vam)
5150 vat_json_node_t node;
5151 vat_json_node_t *msg_array;
5152 vat_json_node_t *msg;
5153 vat_json_node_t *counter_array;
5154 vat_json_node_t *counter;
5155 interface_counter_t c;
5157 ip4_fib_counter_t *c4;
5158 ip6_fib_counter_t *c6;
5159 ip4_nbr_counter_t *n4;
5160 ip6_nbr_counter_t *n6;
5163 if (!vam->json_output)
5165 clib_warning ("dump_stats_table supported only in JSON format");
5169 vat_json_init_object (&node);
5171 /* interface counters */
5172 msg_array = vat_json_object_add (&node, "interface_counters");
5173 vat_json_init_array (msg_array);
5174 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5176 msg = vat_json_array_add (msg_array);
5177 vat_json_init_object (msg);
5178 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5179 (u8 *) counter_type_to_str (i, 0));
5180 vat_json_object_add_int (msg, "is_combined", 0);
5181 counter_array = vat_json_object_add (msg, "data");
5182 vat_json_init_array (counter_array);
5183 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5185 packets = vam->simple_interface_counters[i][j];
5186 vat_json_array_add_uint (counter_array, packets);
5189 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5191 msg = vat_json_array_add (msg_array);
5192 vat_json_init_object (msg);
5193 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5194 (u8 *) counter_type_to_str (i, 1));
5195 vat_json_object_add_int (msg, "is_combined", 1);
5196 counter_array = vat_json_object_add (msg, "data");
5197 vat_json_init_array (counter_array);
5198 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5200 c = vam->combined_interface_counters[i][j];
5201 counter = vat_json_array_add (counter_array);
5202 vat_json_init_object (counter);
5203 vat_json_object_add_uint (counter, "packets", c.packets);
5204 vat_json_object_add_uint (counter, "bytes", c.bytes);
5208 /* ip4 fib counters */
5209 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5210 vat_json_init_array (msg_array);
5211 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5213 msg = vat_json_array_add (msg_array);
5214 vat_json_init_object (msg);
5215 vat_json_object_add_uint (msg, "vrf_id",
5216 vam->ip4_fib_counters_vrf_id_by_index[i]);
5217 counter_array = vat_json_object_add (msg, "c");
5218 vat_json_init_array (counter_array);
5219 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5221 counter = vat_json_array_add (counter_array);
5222 vat_json_init_object (counter);
5223 c4 = &vam->ip4_fib_counters[i][j];
5224 vat_json_object_add_ip4 (counter, "address", c4->address);
5225 vat_json_object_add_uint (counter, "address_length",
5226 c4->address_length);
5227 vat_json_object_add_uint (counter, "packets", c4->packets);
5228 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5232 /* ip6 fib counters */
5233 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5234 vat_json_init_array (msg_array);
5235 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5237 msg = vat_json_array_add (msg_array);
5238 vat_json_init_object (msg);
5239 vat_json_object_add_uint (msg, "vrf_id",
5240 vam->ip6_fib_counters_vrf_id_by_index[i]);
5241 counter_array = vat_json_object_add (msg, "c");
5242 vat_json_init_array (counter_array);
5243 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5245 counter = vat_json_array_add (counter_array);
5246 vat_json_init_object (counter);
5247 c6 = &vam->ip6_fib_counters[i][j];
5248 vat_json_object_add_ip6 (counter, "address", c6->address);
5249 vat_json_object_add_uint (counter, "address_length",
5250 c6->address_length);
5251 vat_json_object_add_uint (counter, "packets", c6->packets);
5252 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5256 /* ip4 nbr counters */
5257 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5258 vat_json_init_array (msg_array);
5259 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5261 msg = vat_json_array_add (msg_array);
5262 vat_json_init_object (msg);
5263 vat_json_object_add_uint (msg, "sw_if_index", i);
5264 counter_array = vat_json_object_add (msg, "c");
5265 vat_json_init_array (counter_array);
5266 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5268 counter = vat_json_array_add (counter_array);
5269 vat_json_init_object (counter);
5270 n4 = &vam->ip4_nbr_counters[i][j];
5271 vat_json_object_add_ip4 (counter, "address", n4->address);
5272 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5273 vat_json_object_add_uint (counter, "packets", n4->packets);
5274 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5278 /* ip6 nbr counters */
5279 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5280 vat_json_init_array (msg_array);
5281 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5283 msg = vat_json_array_add (msg_array);
5284 vat_json_init_object (msg);
5285 vat_json_object_add_uint (msg, "sw_if_index", i);
5286 counter_array = vat_json_object_add (msg, "c");
5287 vat_json_init_array (counter_array);
5288 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5290 counter = vat_json_array_add (counter_array);
5291 vat_json_init_object (counter);
5292 n6 = &vam->ip6_nbr_counters[i][j];
5293 vat_json_object_add_ip6 (counter, "address", n6->address);
5294 vat_json_object_add_uint (counter, "packets", n6->packets);
5295 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5299 vat_json_print (vam->ofp, &node);
5300 vat_json_free (&node);
5306 exec (vat_main_t * vam)
5308 api_main_t *am = &api_main;
5313 unformat_input_t *i = vam->input;
5315 if (vec_len (i->buffer) == 0)
5318 if (vam->exec_mode == 0 && unformat (i, "mode"))
5323 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5333 * Copy cmd into shared memory.
5334 * In order for the CLI command to work, it
5335 * must be a vector ending in \n, not a C-string ending
5338 pthread_mutex_lock (&am->vlib_rp->mutex);
5339 oldheap = svm_push_data_heap (am->vlib_rp);
5341 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
5342 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
5344 svm_pop_heap (oldheap);
5345 pthread_mutex_unlock (&am->vlib_rp->mutex);
5347 mp->cmd_in_shmem = pointer_to_uword (cmd);
5349 timeout = vat_time_now (vam) + 10.0;
5351 while (vat_time_now (vam) < timeout)
5353 if (vam->result_ready == 1)
5356 if (vam->shmem_result != NULL)
5357 print (vam->ofp, "%s", vam->shmem_result);
5358 pthread_mutex_lock (&am->vlib_rp->mutex);
5359 oldheap = svm_push_data_heap (am->vlib_rp);
5361 free_me = (u8 *) vam->shmem_result;
5364 svm_pop_heap (oldheap);
5365 pthread_mutex_unlock (&am->vlib_rp->mutex);
5373 * Future replacement of exec() that passes CLI buffers directly in
5374 * the API messages instead of an additional shared memory area.
5377 exec_inband (vat_main_t * vam)
5379 vl_api_cli_inband_t *mp;
5380 unformat_input_t *i = vam->input;
5383 if (vec_len (i->buffer) == 0)
5386 if (vam->exec_mode == 0 && unformat (i, "mode"))
5391 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5398 * In order for the CLI command to work, it
5399 * must be a vector ending in \n, not a C-string ending
5402 u32 len = vec_len (vam->input->buffer);
5403 M2 (CLI_INBAND, mp, len);
5404 clib_memcpy (mp->cmd, vam->input->buffer, len);
5405 mp->length = htonl (len);
5408 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
5413 api_create_loopback (vat_main_t * vam)
5415 unformat_input_t *i = vam->input;
5416 vl_api_create_loopback_t *mp;
5417 vl_api_create_loopback_instance_t *mp_lbi;
5420 u8 is_specified = 0;
5421 u32 user_instance = 0;
5424 memset (mac_address, 0, sizeof (mac_address));
5426 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5428 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5430 if (unformat (i, "instance %d", &user_instance))
5438 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5439 mp_lbi->is_specified = is_specified;
5441 mp_lbi->user_instance = htonl (user_instance);
5443 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5448 /* Construct the API message */
5449 M (CREATE_LOOPBACK, mp);
5451 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5460 api_delete_loopback (vat_main_t * vam)
5462 unformat_input_t *i = vam->input;
5463 vl_api_delete_loopback_t *mp;
5464 u32 sw_if_index = ~0;
5467 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5469 if (unformat (i, "sw_if_index %d", &sw_if_index))
5475 if (sw_if_index == ~0)
5477 errmsg ("missing sw_if_index");
5481 /* Construct the API message */
5482 M (DELETE_LOOPBACK, mp);
5483 mp->sw_if_index = ntohl (sw_if_index);
5491 api_want_stats (vat_main_t * vam)
5493 unformat_input_t *i = vam->input;
5494 vl_api_want_stats_t *mp;
5498 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5500 if (unformat (i, "enable"))
5502 else if (unformat (i, "disable"))
5510 errmsg ("missing enable|disable");
5515 mp->enable_disable = enable;
5523 api_want_interface_events (vat_main_t * vam)
5525 unformat_input_t *i = vam->input;
5526 vl_api_want_interface_events_t *mp;
5530 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5532 if (unformat (i, "enable"))
5534 else if (unformat (i, "disable"))
5542 errmsg ("missing enable|disable");
5546 M (WANT_INTERFACE_EVENTS, mp);
5547 mp->enable_disable = enable;
5549 vam->interface_event_display = enable;
5557 /* Note: non-static, called once to set up the initial intfc table */
5559 api_sw_interface_dump (vat_main_t * vam)
5561 vl_api_sw_interface_dump_t *mp;
5562 vl_api_control_ping_t *mp_ping;
5564 name_sort_t *nses = 0, *ns;
5565 sw_interface_subif_t *sub = NULL;
5568 /* Toss the old name table */
5570 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5572 vec_add2 (nses, ns, 1);
5573 ns->name = (u8 *)(p->key);
5574 ns->value = (u32) p->value[0];
5578 hash_free (vam->sw_if_index_by_interface_name);
5580 vec_foreach (ns, nses) vec_free (ns->name);
5584 vec_foreach (sub, vam->sw_if_subif_table)
5586 vec_free (sub->interface_name);
5588 vec_free (vam->sw_if_subif_table);
5590 /* recreate the interface name hash table */
5591 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5593 /* Get list of ethernets */
5594 M (SW_INTERFACE_DUMP, mp);
5595 mp->name_filter_valid = 1;
5596 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
5599 /* and local / loopback interfaces */
5600 M (SW_INTERFACE_DUMP, mp);
5601 mp->name_filter_valid = 1;
5602 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
5605 /* and packet-generator interfaces */
5606 M (SW_INTERFACE_DUMP, mp);
5607 mp->name_filter_valid = 1;
5608 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
5611 /* and vxlan-gpe tunnel interfaces */
5612 M (SW_INTERFACE_DUMP, mp);
5613 mp->name_filter_valid = 1;
5614 strncpy ((char *) mp->name_filter, "vxlan_gpe",
5615 sizeof (mp->name_filter) - 1);
5618 /* and vxlan tunnel interfaces */
5619 M (SW_INTERFACE_DUMP, mp);
5620 mp->name_filter_valid = 1;
5621 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
5624 /* and host (af_packet) interfaces */
5625 M (SW_INTERFACE_DUMP, mp);
5626 mp->name_filter_valid = 1;
5627 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
5630 /* and l2tpv3 tunnel interfaces */
5631 M (SW_INTERFACE_DUMP, mp);
5632 mp->name_filter_valid = 1;
5633 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
5634 sizeof (mp->name_filter) - 1);
5637 /* and GRE tunnel interfaces */
5638 M (SW_INTERFACE_DUMP, mp);
5639 mp->name_filter_valid = 1;
5640 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
5643 /* and LISP-GPE interfaces */
5644 M (SW_INTERFACE_DUMP, mp);
5645 mp->name_filter_valid = 1;
5646 strncpy ((char *) mp->name_filter, "lisp_gpe",
5647 sizeof (mp->name_filter) - 1);
5650 /* and IPSEC tunnel interfaces */
5651 M (SW_INTERFACE_DUMP, mp);
5652 mp->name_filter_valid = 1;
5653 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
5656 /* Use a control ping for synchronization */
5657 M (CONTROL_PING, mp_ping);
5665 api_sw_interface_set_flags (vat_main_t * vam)
5667 unformat_input_t *i = vam->input;
5668 vl_api_sw_interface_set_flags_t *mp;
5670 u8 sw_if_index_set = 0;
5671 u8 admin_up = 0, link_up = 0;
5674 /* Parse args required to build the message */
5675 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5677 if (unformat (i, "admin-up"))
5679 else if (unformat (i, "admin-down"))
5681 else if (unformat (i, "link-up"))
5683 else if (unformat (i, "link-down"))
5686 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5687 sw_if_index_set = 1;
5688 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5689 sw_if_index_set = 1;
5694 if (sw_if_index_set == 0)
5696 errmsg ("missing interface name or sw_if_index");
5700 /* Construct the API message */
5701 M (SW_INTERFACE_SET_FLAGS, mp);
5702 mp->sw_if_index = ntohl (sw_if_index);
5703 mp->admin_up_down = admin_up;
5704 mp->link_up_down = link_up;
5709 /* Wait for a reply, return the good/bad news... */
5715 api_sw_interface_clear_stats (vat_main_t * vam)
5717 unformat_input_t *i = vam->input;
5718 vl_api_sw_interface_clear_stats_t *mp;
5720 u8 sw_if_index_set = 0;
5723 /* Parse args required to build the message */
5724 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5726 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5727 sw_if_index_set = 1;
5728 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5729 sw_if_index_set = 1;
5734 /* Construct the API message */
5735 M (SW_INTERFACE_CLEAR_STATS, mp);
5737 if (sw_if_index_set == 1)
5738 mp->sw_if_index = ntohl (sw_if_index);
5740 mp->sw_if_index = ~0;
5745 /* Wait for a reply, return the good/bad news... */
5751 api_sw_interface_add_del_address (vat_main_t * vam)
5753 unformat_input_t *i = vam->input;
5754 vl_api_sw_interface_add_del_address_t *mp;
5756 u8 sw_if_index_set = 0;
5757 u8 is_add = 1, del_all = 0;
5758 u32 address_length = 0;
5759 u8 v4_address_set = 0;
5760 u8 v6_address_set = 0;
5761 ip4_address_t v4address;
5762 ip6_address_t v6address;
5765 /* Parse args required to build the message */
5766 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5768 if (unformat (i, "del-all"))
5770 else if (unformat (i, "del"))
5773 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5774 sw_if_index_set = 1;
5775 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5776 sw_if_index_set = 1;
5777 else if (unformat (i, "%U/%d",
5778 unformat_ip4_address, &v4address, &address_length))
5780 else if (unformat (i, "%U/%d",
5781 unformat_ip6_address, &v6address, &address_length))
5787 if (sw_if_index_set == 0)
5789 errmsg ("missing interface name or sw_if_index");
5792 if (v4_address_set && v6_address_set)
5794 errmsg ("both v4 and v6 addresses set");
5797 if (!v4_address_set && !v6_address_set && !del_all)
5799 errmsg ("no addresses set");
5803 /* Construct the API message */
5804 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5806 mp->sw_if_index = ntohl (sw_if_index);
5807 mp->is_add = is_add;
5808 mp->del_all = del_all;
5812 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5816 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5818 mp->address_length = address_length;
5823 /* Wait for a reply, return good/bad news */
5829 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5831 unformat_input_t *i = vam->input;
5832 vl_api_sw_interface_set_mpls_enable_t *mp;
5834 u8 sw_if_index_set = 0;
5838 /* Parse args required to build the message */
5839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5841 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5842 sw_if_index_set = 1;
5843 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5844 sw_if_index_set = 1;
5845 else if (unformat (i, "disable"))
5847 else if (unformat (i, "dis"))
5853 if (sw_if_index_set == 0)
5855 errmsg ("missing interface name or sw_if_index");
5859 /* Construct the API message */
5860 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5862 mp->sw_if_index = ntohl (sw_if_index);
5863 mp->enable = enable;
5868 /* Wait for a reply... */
5874 api_sw_interface_set_table (vat_main_t * vam)
5876 unformat_input_t *i = vam->input;
5877 vl_api_sw_interface_set_table_t *mp;
5878 u32 sw_if_index, vrf_id = 0;
5879 u8 sw_if_index_set = 0;
5883 /* Parse args required to build the message */
5884 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5886 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5887 sw_if_index_set = 1;
5888 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5889 sw_if_index_set = 1;
5890 else if (unformat (i, "vrf %d", &vrf_id))
5892 else if (unformat (i, "ipv6"))
5898 if (sw_if_index_set == 0)
5900 errmsg ("missing interface name or sw_if_index");
5904 /* Construct the API message */
5905 M (SW_INTERFACE_SET_TABLE, mp);
5907 mp->sw_if_index = ntohl (sw_if_index);
5908 mp->is_ipv6 = is_ipv6;
5909 mp->vrf_id = ntohl (vrf_id);
5914 /* Wait for a reply... */
5919 static void vl_api_sw_interface_get_table_reply_t_handler
5920 (vl_api_sw_interface_get_table_reply_t * mp)
5922 vat_main_t *vam = &vat_main;
5924 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5926 vam->retval = ntohl (mp->retval);
5927 vam->result_ready = 1;
5931 static void vl_api_sw_interface_get_table_reply_t_handler_json
5932 (vl_api_sw_interface_get_table_reply_t * mp)
5934 vat_main_t *vam = &vat_main;
5935 vat_json_node_t node;
5937 vat_json_init_object (&node);
5938 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5939 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5941 vat_json_print (vam->ofp, &node);
5942 vat_json_free (&node);
5944 vam->retval = ntohl (mp->retval);
5945 vam->result_ready = 1;
5949 api_sw_interface_get_table (vat_main_t * vam)
5951 unformat_input_t *i = vam->input;
5952 vl_api_sw_interface_get_table_t *mp;
5954 u8 sw_if_index_set = 0;
5958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5960 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5961 sw_if_index_set = 1;
5962 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5963 sw_if_index_set = 1;
5964 else if (unformat (i, "ipv6"))
5970 if (sw_if_index_set == 0)
5972 errmsg ("missing interface name or sw_if_index");
5976 M (SW_INTERFACE_GET_TABLE, mp);
5977 mp->sw_if_index = htonl (sw_if_index);
5978 mp->is_ipv6 = is_ipv6;
5986 api_sw_interface_set_vpath (vat_main_t * vam)
5988 unformat_input_t *i = vam->input;
5989 vl_api_sw_interface_set_vpath_t *mp;
5990 u32 sw_if_index = 0;
5991 u8 sw_if_index_set = 0;
5995 /* Parse args required to build the message */
5996 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5998 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5999 sw_if_index_set = 1;
6000 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6001 sw_if_index_set = 1;
6002 else if (unformat (i, "enable"))
6004 else if (unformat (i, "disable"))
6010 if (sw_if_index_set == 0)
6012 errmsg ("missing interface name or sw_if_index");
6016 /* Construct the API message */
6017 M (SW_INTERFACE_SET_VPATH, mp);
6019 mp->sw_if_index = ntohl (sw_if_index);
6020 mp->enable = is_enable;
6025 /* Wait for a reply... */
6031 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6033 unformat_input_t *i = vam->input;
6034 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6035 u32 sw_if_index = 0;
6036 u8 sw_if_index_set = 0;
6041 /* Parse args required to build the message */
6042 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6044 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6045 sw_if_index_set = 1;
6046 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6047 sw_if_index_set = 1;
6048 else if (unformat (i, "enable"))
6050 else if (unformat (i, "disable"))
6052 else if (unformat (i, "ip4"))
6054 else if (unformat (i, "ip6"))
6060 if (sw_if_index_set == 0)
6062 errmsg ("missing interface name or sw_if_index");
6066 /* Construct the API message */
6067 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6069 mp->sw_if_index = ntohl (sw_if_index);
6070 mp->enable = is_enable;
6071 mp->is_ipv6 = is_ipv6;
6076 /* Wait for a reply... */
6083 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6085 unformat_input_t *i = vam->input;
6086 vl_api_sw_interface_set_l2_xconnect_t *mp;
6088 u8 rx_sw_if_index_set = 0;
6090 u8 tx_sw_if_index_set = 0;
6094 /* Parse args required to build the message */
6095 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6097 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6098 rx_sw_if_index_set = 1;
6099 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6100 tx_sw_if_index_set = 1;
6101 else if (unformat (i, "rx"))
6103 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6105 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6107 rx_sw_if_index_set = 1;
6112 else if (unformat (i, "tx"))
6114 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6116 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6118 tx_sw_if_index_set = 1;
6123 else if (unformat (i, "enable"))
6125 else if (unformat (i, "disable"))
6131 if (rx_sw_if_index_set == 0)
6133 errmsg ("missing rx interface name or rx_sw_if_index");
6137 if (enable && (tx_sw_if_index_set == 0))
6139 errmsg ("missing tx interface name or tx_sw_if_index");
6143 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6145 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6146 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6147 mp->enable = enable;
6155 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6157 unformat_input_t *i = vam->input;
6158 vl_api_sw_interface_set_l2_bridge_t *mp;
6160 u8 rx_sw_if_index_set = 0;
6168 /* Parse args required to build the message */
6169 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6171 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6172 rx_sw_if_index_set = 1;
6173 else if (unformat (i, "bd_id %d", &bd_id))
6177 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6178 rx_sw_if_index_set = 1;
6179 else if (unformat (i, "shg %d", &shg))
6181 else if (unformat (i, "bvi"))
6183 else if (unformat (i, "enable"))
6185 else if (unformat (i, "disable"))
6191 if (rx_sw_if_index_set == 0)
6193 errmsg ("missing rx interface name or sw_if_index");
6197 if (enable && (bd_id_set == 0))
6199 errmsg ("missing bridge domain");
6203 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6205 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6206 mp->bd_id = ntohl (bd_id);
6209 mp->enable = enable;
6217 api_bridge_domain_dump (vat_main_t * vam)
6219 unformat_input_t *i = vam->input;
6220 vl_api_bridge_domain_dump_t *mp;
6221 vl_api_control_ping_t *mp_ping;
6225 /* Parse args required to build the message */
6226 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6228 if (unformat (i, "bd_id %d", &bd_id))
6234 M (BRIDGE_DOMAIN_DUMP, mp);
6235 mp->bd_id = ntohl (bd_id);
6238 /* Use a control ping for synchronization */
6239 M (CONTROL_PING, mp_ping);
6247 api_bridge_domain_add_del (vat_main_t * vam)
6249 unformat_input_t *i = vam->input;
6250 vl_api_bridge_domain_add_del_t *mp;
6253 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6257 /* Parse args required to build the message */
6258 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6260 if (unformat (i, "bd_id %d", &bd_id))
6262 else if (unformat (i, "flood %d", &flood))
6264 else if (unformat (i, "uu-flood %d", &uu_flood))
6266 else if (unformat (i, "forward %d", &forward))
6268 else if (unformat (i, "learn %d", &learn))
6270 else if (unformat (i, "arp-term %d", &arp_term))
6272 else if (unformat (i, "mac-age %d", &mac_age))
6274 else if (unformat (i, "del"))
6277 flood = uu_flood = forward = learn = 0;
6285 errmsg ("missing bridge domain");
6291 errmsg ("mac age must be less than 256 ");
6295 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6297 mp->bd_id = ntohl (bd_id);
6299 mp->uu_flood = uu_flood;
6300 mp->forward = forward;
6302 mp->arp_term = arp_term;
6303 mp->is_add = is_add;
6304 mp->mac_age = (u8) mac_age;
6312 api_l2fib_flush_bd (vat_main_t * vam)
6314 unformat_input_t *i = vam->input;
6315 vl_api_l2fib_flush_bd_t *mp;
6319 /* Parse args required to build the message */
6320 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6322 if (unformat (i, "bd_id %d", &bd_id));
6329 errmsg ("missing bridge domain");
6333 M (L2FIB_FLUSH_BD, mp);
6335 mp->bd_id = htonl (bd_id);
6343 api_l2fib_flush_int (vat_main_t * vam)
6345 unformat_input_t *i = vam->input;
6346 vl_api_l2fib_flush_int_t *mp;
6347 u32 sw_if_index = ~0;
6350 /* Parse args required to build the message */
6351 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6353 if (unformat (i, "sw_if_index %d", &sw_if_index));
6355 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6360 if (sw_if_index == ~0)
6362 errmsg ("missing interface name or sw_if_index");
6366 M (L2FIB_FLUSH_INT, mp);
6368 mp->sw_if_index = ntohl (sw_if_index);
6376 api_l2fib_add_del (vat_main_t * vam)
6378 unformat_input_t *i = vam->input;
6379 vl_api_l2fib_add_del_t *mp;
6385 u32 sw_if_index = ~0;
6386 u8 sw_if_index_set = 0;
6395 /* Parse args required to build the message */
6396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6398 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6400 else if (unformat (i, "bd_id %d", &bd_id))
6402 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6403 sw_if_index_set = 1;
6404 else if (unformat (i, "sw_if"))
6406 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6409 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6410 sw_if_index_set = 1;
6415 else if (unformat (i, "static"))
6417 else if (unformat (i, "filter"))
6422 else if (unformat (i, "bvi"))
6427 else if (unformat (i, "del"))
6429 else if (unformat (i, "count %d", &count))
6437 errmsg ("missing mac address");
6443 errmsg ("missing bridge domain");
6447 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6449 errmsg ("missing interface name or sw_if_index");
6455 /* Turn on async mode */
6456 vam->async_mode = 1;
6457 vam->async_errors = 0;
6458 before = vat_time_now (vam);
6461 for (j = 0; j < count; j++)
6463 M (L2FIB_ADD_DEL, mp);
6466 mp->bd_id = ntohl (bd_id);
6467 mp->is_add = is_add;
6471 mp->sw_if_index = ntohl (sw_if_index);
6472 mp->static_mac = static_mac;
6473 mp->filter_mac = filter_mac;
6474 mp->bvi_mac = bvi_mac;
6476 increment_mac_address (&mac);
6483 vl_api_control_ping_t *mp_ping;
6486 /* Shut off async mode */
6487 vam->async_mode = 0;
6489 M (CONTROL_PING, mp_ping);
6492 timeout = vat_time_now (vam) + 1.0;
6493 while (vat_time_now (vam) < timeout)
6494 if (vam->result_ready == 1)
6499 if (vam->retval == -99)
6502 if (vam->async_errors > 0)
6504 errmsg ("%d asynchronous errors", vam->async_errors);
6507 vam->async_errors = 0;
6508 after = vat_time_now (vam);
6510 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6511 count, after - before, count / (after - before));
6517 /* Wait for a reply... */
6521 /* Return the good/bad news */
6522 return (vam->retval);
6526 api_bridge_domain_set_mac_age (vat_main_t * vam)
6528 unformat_input_t *i = vam->input;
6529 vl_api_bridge_domain_set_mac_age_t *mp;
6534 /* Parse args required to build the message */
6535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6537 if (unformat (i, "bd_id %d", &bd_id));
6538 else if (unformat (i, "mac-age %d", &mac_age));
6545 errmsg ("missing bridge domain");
6551 errmsg ("mac age must be less than 256 ");
6555 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6557 mp->bd_id = htonl (bd_id);
6558 mp->mac_age = (u8) mac_age;
6566 api_l2_flags (vat_main_t * vam)
6568 unformat_input_t *i = vam->input;
6569 vl_api_l2_flags_t *mp;
6571 u32 feature_bitmap = 0;
6572 u8 sw_if_index_set = 0;
6575 /* Parse args required to build the message */
6576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6578 if (unformat (i, "sw_if_index %d", &sw_if_index))
6579 sw_if_index_set = 1;
6580 else if (unformat (i, "sw_if"))
6582 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6585 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6586 sw_if_index_set = 1;
6591 else if (unformat (i, "learn"))
6592 feature_bitmap |= L2INPUT_FEAT_LEARN;
6593 else if (unformat (i, "forward"))
6594 feature_bitmap |= L2INPUT_FEAT_FWD;
6595 else if (unformat (i, "flood"))
6596 feature_bitmap |= L2INPUT_FEAT_FLOOD;
6597 else if (unformat (i, "uu-flood"))
6598 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
6603 if (sw_if_index_set == 0)
6605 errmsg ("missing interface name or sw_if_index");
6611 mp->sw_if_index = ntohl (sw_if_index);
6612 mp->feature_bitmap = ntohl (feature_bitmap);
6620 api_bridge_flags (vat_main_t * vam)
6622 unformat_input_t *i = vam->input;
6623 vl_api_bridge_flags_t *mp;
6630 /* Parse args required to build the message */
6631 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6633 if (unformat (i, "bd_id %d", &bd_id))
6635 else if (unformat (i, "learn"))
6637 else if (unformat (i, "forward"))
6639 else if (unformat (i, "flood"))
6641 else if (unformat (i, "uu-flood"))
6642 flags |= L2_UU_FLOOD;
6643 else if (unformat (i, "arp-term"))
6644 flags |= L2_ARP_TERM;
6645 else if (unformat (i, "off"))
6647 else if (unformat (i, "disable"))
6655 errmsg ("missing bridge domain");
6659 M (BRIDGE_FLAGS, mp);
6661 mp->bd_id = ntohl (bd_id);
6662 mp->feature_bitmap = ntohl (flags);
6663 mp->is_set = is_set;
6671 api_bd_ip_mac_add_del (vat_main_t * vam)
6673 unformat_input_t *i = vam->input;
6674 vl_api_bd_ip_mac_add_del_t *mp;
6681 ip4_address_t v4addr;
6682 ip6_address_t v6addr;
6687 /* Parse args required to build the message */
6688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6690 if (unformat (i, "bd_id %d", &bd_id))
6694 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6698 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6703 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6707 else if (unformat (i, "del"))
6715 errmsg ("missing bridge domain");
6718 else if (ip_set == 0)
6720 errmsg ("missing IP address");
6723 else if (mac_set == 0)
6725 errmsg ("missing MAC address");
6729 M (BD_IP_MAC_ADD_DEL, mp);
6731 mp->bd_id = ntohl (bd_id);
6732 mp->is_ipv6 = is_ipv6;
6733 mp->is_add = is_add;
6735 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6737 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6738 clib_memcpy (mp->mac_address, macaddr, 6);
6745 api_tap_connect (vat_main_t * vam)
6747 unformat_input_t *i = vam->input;
6748 vl_api_tap_connect_t *mp;
6754 ip4_address_t ip4_address;
6756 int ip4_address_set = 0;
6757 ip6_address_t ip6_address;
6759 int ip6_address_set = 0;
6762 memset (mac_address, 0, sizeof (mac_address));
6764 /* Parse args required to build the message */
6765 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6767 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6771 else if (unformat (i, "random-mac"))
6773 else if (unformat (i, "tapname %s", &tap_name))
6775 else if (unformat (i, "tag %s", &tag))
6777 else if (unformat (i, "address %U/%d",
6778 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6779 ip4_address_set = 1;
6780 else if (unformat (i, "address %U/%d",
6781 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6782 ip6_address_set = 1;
6789 errmsg ("missing tap name");
6792 if (vec_len (tap_name) > 63)
6794 errmsg ("tap name too long");
6797 vec_add1 (tap_name, 0);
6799 if (vec_len (tag) > 63)
6801 errmsg ("tag too long");
6805 /* Construct the API message */
6806 M (TAP_CONNECT, mp);
6808 mp->use_random_mac = random_mac;
6809 clib_memcpy (mp->mac_address, mac_address, 6);
6810 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6812 clib_memcpy (mp->tag, tag, vec_len (tag));
6814 if (ip4_address_set)
6816 mp->ip4_address_set = 1;
6817 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6818 mp->ip4_mask_width = ip4_mask_width;
6820 if (ip6_address_set)
6822 mp->ip6_address_set = 1;
6823 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6824 mp->ip6_mask_width = ip6_mask_width;
6827 vec_free (tap_name);
6833 /* Wait for a reply... */
6839 api_tap_modify (vat_main_t * vam)
6841 unformat_input_t *i = vam->input;
6842 vl_api_tap_modify_t *mp;
6847 u32 sw_if_index = ~0;
6848 u8 sw_if_index_set = 0;
6851 memset (mac_address, 0, sizeof (mac_address));
6853 /* Parse args required to build the message */
6854 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6856 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6857 sw_if_index_set = 1;
6858 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6859 sw_if_index_set = 1;
6860 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6864 else if (unformat (i, "random-mac"))
6866 else if (unformat (i, "tapname %s", &tap_name))
6872 if (sw_if_index_set == 0)
6874 errmsg ("missing vpp interface name");
6879 errmsg ("missing tap name");
6882 if (vec_len (tap_name) > 63)
6884 errmsg ("tap name too long");
6886 vec_add1 (tap_name, 0);
6888 /* Construct the API message */
6891 mp->use_random_mac = random_mac;
6892 mp->sw_if_index = ntohl (sw_if_index);
6893 clib_memcpy (mp->mac_address, mac_address, 6);
6894 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6895 vec_free (tap_name);
6900 /* Wait for a reply... */
6906 api_tap_delete (vat_main_t * vam)
6908 unformat_input_t *i = vam->input;
6909 vl_api_tap_delete_t *mp;
6910 u32 sw_if_index = ~0;
6911 u8 sw_if_index_set = 0;
6914 /* Parse args required to build the message */
6915 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6917 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6918 sw_if_index_set = 1;
6919 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6920 sw_if_index_set = 1;
6925 if (sw_if_index_set == 0)
6927 errmsg ("missing vpp interface name");
6931 /* Construct the API message */
6934 mp->sw_if_index = ntohl (sw_if_index);
6939 /* Wait for a reply... */
6945 api_ip_add_del_route (vat_main_t * vam)
6947 unformat_input_t *i = vam->input;
6948 vl_api_ip_add_del_route_t *mp;
6949 u32 sw_if_index = ~0, vrf_id = 0;
6951 u8 is_local = 0, is_drop = 0;
6952 u8 is_unreach = 0, is_prohibit = 0;
6953 u8 create_vrf_if_needed = 0;
6955 u32 next_hop_weight = 1;
6957 u8 is_multipath = 0;
6959 u8 address_length_set = 0;
6960 u32 next_hop_table_id = 0;
6961 u32 resolve_attempts = 0;
6962 u32 dst_address_length = 0;
6963 u8 next_hop_set = 0;
6964 ip4_address_t v4_dst_address, v4_next_hop_address;
6965 ip6_address_t v6_dst_address, v6_next_hop_address;
6969 u32 random_add_del = 0;
6970 u32 *random_vector = 0;
6972 u32 random_seed = 0xdeaddabe;
6973 u32 classify_table_index = ~0;
6975 u8 resolve_host = 0, resolve_attached = 0;
6976 mpls_label_t *next_hop_out_label_stack = NULL;
6977 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6978 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6980 /* Parse args required to build the message */
6981 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6983 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6985 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6987 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6992 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6997 else if (unformat (i, "/%d", &dst_address_length))
6999 address_length_set = 1;
7002 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7003 &v4_next_hop_address))
7007 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7008 &v6_next_hop_address))
7012 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7014 else if (unformat (i, "weight %d", &next_hop_weight))
7016 else if (unformat (i, "drop"))
7020 else if (unformat (i, "null-send-unreach"))
7024 else if (unformat (i, "null-send-prohibit"))
7028 else if (unformat (i, "local"))
7032 else if (unformat (i, "classify %d", &classify_table_index))
7036 else if (unformat (i, "del"))
7038 else if (unformat (i, "add"))
7040 else if (unformat (i, "not-last"))
7042 else if (unformat (i, "resolve-via-host"))
7044 else if (unformat (i, "resolve-via-attached"))
7045 resolve_attached = 1;
7046 else if (unformat (i, "multipath"))
7048 else if (unformat (i, "vrf %d", &vrf_id))
7050 else if (unformat (i, "create-vrf"))
7051 create_vrf_if_needed = 1;
7052 else if (unformat (i, "count %d", &count))
7054 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7056 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7058 else if (unformat (i, "out-label %d", &next_hop_out_label))
7059 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7060 else if (unformat (i, "via-label %d", &next_hop_via_label))
7062 else if (unformat (i, "random"))
7064 else if (unformat (i, "seed %d", &random_seed))
7068 clib_warning ("parse error '%U'", format_unformat_error, i);
7073 if (!next_hop_set && !is_drop && !is_local &&
7074 !is_classify && !is_unreach && !is_prohibit &&
7075 MPLS_LABEL_INVALID == next_hop_via_label)
7078 ("next hop / local / drop / unreach / prohibit / classify not set");
7082 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7084 errmsg ("next hop and next-hop via label set");
7087 if (address_set == 0)
7089 errmsg ("missing addresses");
7093 if (address_length_set == 0)
7095 errmsg ("missing address length");
7099 /* Generate a pile of unique, random routes */
7102 u32 this_random_address;
7103 random_hash = hash_create (count, sizeof (uword));
7105 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7106 for (j = 0; j <= count; j++)
7110 this_random_address = random_u32 (&random_seed);
7111 this_random_address =
7112 clib_host_to_net_u32 (this_random_address);
7114 while (hash_get (random_hash, this_random_address));
7115 vec_add1 (random_vector, this_random_address);
7116 hash_set (random_hash, this_random_address, 1);
7118 hash_free (random_hash);
7119 v4_dst_address.as_u32 = random_vector[0];
7124 /* Turn on async mode */
7125 vam->async_mode = 1;
7126 vam->async_errors = 0;
7127 before = vat_time_now (vam);
7130 for (j = 0; j < count; j++)
7132 /* Construct the API message */
7133 M2 (IP_ADD_DEL_ROUTE, mp,
7134 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7136 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7137 mp->table_id = ntohl (vrf_id);
7138 mp->create_vrf_if_needed = create_vrf_if_needed;
7140 mp->is_add = is_add;
7141 mp->is_drop = is_drop;
7142 mp->is_unreach = is_unreach;
7143 mp->is_prohibit = is_prohibit;
7144 mp->is_ipv6 = is_ipv6;
7145 mp->is_local = is_local;
7146 mp->is_classify = is_classify;
7147 mp->is_multipath = is_multipath;
7148 mp->is_resolve_host = resolve_host;
7149 mp->is_resolve_attached = resolve_attached;
7150 mp->not_last = not_last;
7151 mp->next_hop_weight = next_hop_weight;
7152 mp->dst_address_length = dst_address_length;
7153 mp->next_hop_table_id = ntohl (next_hop_table_id);
7154 mp->classify_table_index = ntohl (classify_table_index);
7155 mp->next_hop_via_label = ntohl (next_hop_via_label);
7156 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7157 if (0 != mp->next_hop_n_out_labels)
7159 memcpy (mp->next_hop_out_label_stack,
7160 next_hop_out_label_stack,
7161 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7162 vec_free (next_hop_out_label_stack);
7167 clib_memcpy (mp->dst_address, &v6_dst_address,
7168 sizeof (v6_dst_address));
7170 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
7171 sizeof (v6_next_hop_address));
7172 increment_v6_address (&v6_dst_address);
7176 clib_memcpy (mp->dst_address, &v4_dst_address,
7177 sizeof (v4_dst_address));
7179 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
7180 sizeof (v4_next_hop_address));
7182 v4_dst_address.as_u32 = random_vector[j + 1];
7184 increment_v4_address (&v4_dst_address);
7188 /* If we receive SIGTERM, stop now... */
7193 /* When testing multiple add/del ops, use a control-ping to sync */
7196 vl_api_control_ping_t *mp_ping;
7200 /* Shut off async mode */
7201 vam->async_mode = 0;
7203 M (CONTROL_PING, mp_ping);
7206 timeout = vat_time_now (vam) + 1.0;
7207 while (vat_time_now (vam) < timeout)
7208 if (vam->result_ready == 1)
7213 if (vam->retval == -99)
7216 if (vam->async_errors > 0)
7218 errmsg ("%d asynchronous errors", vam->async_errors);
7221 vam->async_errors = 0;
7222 after = vat_time_now (vam);
7224 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7228 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7229 count, after - before, count / (after - before));
7235 /* Wait for a reply... */
7240 /* Return the good/bad news */
7241 return (vam->retval);
7245 api_ip_mroute_add_del (vat_main_t * vam)
7247 unformat_input_t *i = vam->input;
7248 vl_api_ip_mroute_add_del_t *mp;
7249 u32 sw_if_index = ~0, vrf_id = 0;
7252 u8 create_vrf_if_needed = 0;
7255 u32 grp_address_length = 0;
7256 ip4_address_t v4_grp_address, v4_src_address;
7257 ip6_address_t v6_grp_address, v6_src_address;
7258 mfib_itf_flags_t iflags = 0;
7259 mfib_entry_flags_t eflags = 0;
7262 /* Parse args required to build the message */
7263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7265 if (unformat (i, "sw_if_index %d", &sw_if_index))
7267 else if (unformat (i, "%U %U",
7268 unformat_ip4_address, &v4_src_address,
7269 unformat_ip4_address, &v4_grp_address))
7271 grp_address_length = 64;
7275 else if (unformat (i, "%U %U",
7276 unformat_ip6_address, &v6_src_address,
7277 unformat_ip6_address, &v6_grp_address))
7279 grp_address_length = 256;
7283 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7285 memset (&v4_src_address, 0, sizeof (v4_src_address));
7286 grp_address_length = 32;
7290 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7292 memset (&v6_src_address, 0, sizeof (v6_src_address));
7293 grp_address_length = 128;
7297 else if (unformat (i, "/%d", &grp_address_length))
7299 else if (unformat (i, "local"))
7303 else if (unformat (i, "del"))
7305 else if (unformat (i, "add"))
7307 else if (unformat (i, "vrf %d", &vrf_id))
7309 else if (unformat (i, "create-vrf"))
7310 create_vrf_if_needed = 1;
7311 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7313 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7317 clib_warning ("parse error '%U'", format_unformat_error, i);
7322 if (address_set == 0)
7324 errmsg ("missing addresses\n");
7328 /* Construct the API message */
7329 M (IP_MROUTE_ADD_DEL, mp);
7331 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7332 mp->table_id = ntohl (vrf_id);
7333 mp->create_vrf_if_needed = create_vrf_if_needed;
7335 mp->is_add = is_add;
7336 mp->is_ipv6 = is_ipv6;
7337 mp->is_local = is_local;
7338 mp->itf_flags = ntohl (iflags);
7339 mp->entry_flags = ntohl (eflags);
7340 mp->grp_address_length = grp_address_length;
7341 mp->grp_address_length = ntohs (mp->grp_address_length);
7345 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7346 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7350 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7351 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7357 /* Wait for a reply... */
7363 api_mpls_route_add_del (vat_main_t * vam)
7365 unformat_input_t *i = vam->input;
7366 vl_api_mpls_route_add_del_t *mp;
7367 u32 sw_if_index = ~0, table_id = 0;
7368 u8 create_table_if_needed = 0;
7370 u32 next_hop_weight = 1;
7371 u8 is_multipath = 0;
7372 u32 next_hop_table_id = 0;
7373 u8 next_hop_set = 0;
7374 ip4_address_t v4_next_hop_address = {
7377 ip6_address_t v6_next_hop_address = { {0} };
7381 u32 classify_table_index = ~0;
7383 u8 resolve_host = 0, resolve_attached = 0;
7384 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7385 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7386 mpls_label_t *next_hop_out_label_stack = NULL;
7387 mpls_label_t local_label = MPLS_LABEL_INVALID;
7389 u8 next_hop_proto_is_ip4 = 1;
7391 /* Parse args required to build the message */
7392 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7394 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7396 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7398 else if (unformat (i, "%d", &local_label))
7400 else if (unformat (i, "eos"))
7402 else if (unformat (i, "non-eos"))
7404 else if (unformat (i, "via %U", unformat_ip4_address,
7405 &v4_next_hop_address))
7408 next_hop_proto_is_ip4 = 1;
7410 else if (unformat (i, "via %U", unformat_ip6_address,
7411 &v6_next_hop_address))
7414 next_hop_proto_is_ip4 = 0;
7416 else if (unformat (i, "weight %d", &next_hop_weight))
7418 else if (unformat (i, "create-table"))
7419 create_table_if_needed = 1;
7420 else if (unformat (i, "classify %d", &classify_table_index))
7424 else if (unformat (i, "del"))
7426 else if (unformat (i, "add"))
7428 else if (unformat (i, "resolve-via-host"))
7430 else if (unformat (i, "resolve-via-attached"))
7431 resolve_attached = 1;
7432 else if (unformat (i, "multipath"))
7434 else if (unformat (i, "count %d", &count))
7436 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
7439 next_hop_proto_is_ip4 = 1;
7441 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
7444 next_hop_proto_is_ip4 = 0;
7446 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7448 else if (unformat (i, "via-label %d", &next_hop_via_label))
7450 else if (unformat (i, "out-label %d", &next_hop_out_label))
7451 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7454 clib_warning ("parse error '%U'", format_unformat_error, i);
7459 if (!next_hop_set && !is_classify)
7461 errmsg ("next hop / classify not set");
7465 if (MPLS_LABEL_INVALID == local_label)
7467 errmsg ("missing label");
7473 /* Turn on async mode */
7474 vam->async_mode = 1;
7475 vam->async_errors = 0;
7476 before = vat_time_now (vam);
7479 for (j = 0; j < count; j++)
7481 /* Construct the API message */
7482 M2 (MPLS_ROUTE_ADD_DEL, mp,
7483 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7485 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
7486 mp->mr_table_id = ntohl (table_id);
7487 mp->mr_create_table_if_needed = create_table_if_needed;
7489 mp->mr_is_add = is_add;
7490 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7491 mp->mr_is_classify = is_classify;
7492 mp->mr_is_multipath = is_multipath;
7493 mp->mr_is_resolve_host = resolve_host;
7494 mp->mr_is_resolve_attached = resolve_attached;
7495 mp->mr_next_hop_weight = next_hop_weight;
7496 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
7497 mp->mr_classify_table_index = ntohl (classify_table_index);
7498 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
7499 mp->mr_label = ntohl (local_label);
7500 mp->mr_eos = is_eos;
7502 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7503 if (0 != mp->mr_next_hop_n_out_labels)
7505 memcpy (mp->mr_next_hop_out_label_stack,
7506 next_hop_out_label_stack,
7507 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7508 vec_free (next_hop_out_label_stack);
7513 if (next_hop_proto_is_ip4)
7515 clib_memcpy (mp->mr_next_hop,
7516 &v4_next_hop_address,
7517 sizeof (v4_next_hop_address));
7521 clib_memcpy (mp->mr_next_hop,
7522 &v6_next_hop_address,
7523 sizeof (v6_next_hop_address));
7530 /* If we receive SIGTERM, stop now... */
7535 /* When testing multiple add/del ops, use a control-ping to sync */
7538 vl_api_control_ping_t *mp_ping;
7542 /* Shut off async mode */
7543 vam->async_mode = 0;
7545 M (CONTROL_PING, mp_ping);
7548 timeout = vat_time_now (vam) + 1.0;
7549 while (vat_time_now (vam) < timeout)
7550 if (vam->result_ready == 1)
7555 if (vam->retval == -99)
7558 if (vam->async_errors > 0)
7560 errmsg ("%d asynchronous errors", vam->async_errors);
7563 vam->async_errors = 0;
7564 after = vat_time_now (vam);
7566 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7570 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7571 count, after - before, count / (after - before));
7577 /* Wait for a reply... */
7582 /* Return the good/bad news */
7583 return (vam->retval);
7587 api_mpls_ip_bind_unbind (vat_main_t * vam)
7589 unformat_input_t *i = vam->input;
7590 vl_api_mpls_ip_bind_unbind_t *mp;
7591 u32 ip_table_id = 0;
7592 u8 create_table_if_needed = 0;
7595 ip4_address_t v4_address;
7596 ip6_address_t v6_address;
7599 mpls_label_t local_label = MPLS_LABEL_INVALID;
7602 /* Parse args required to build the message */
7603 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7605 if (unformat (i, "%U/%d", unformat_ip4_address,
7606 &v4_address, &address_length))
7611 else if (unformat (i, "%U/%d", unformat_ip6_address,
7612 &v6_address, &address_length))
7617 else if (unformat (i, "%d", &local_label))
7619 else if (unformat (i, "create-table"))
7620 create_table_if_needed = 1;
7621 else if (unformat (i, "table-id %d", &ip_table_id))
7623 else if (unformat (i, "unbind"))
7625 else if (unformat (i, "bind"))
7629 clib_warning ("parse error '%U'", format_unformat_error, i);
7636 errmsg ("IP addres not set");
7640 if (MPLS_LABEL_INVALID == local_label)
7642 errmsg ("missing label");
7646 /* Construct the API message */
7647 M (MPLS_IP_BIND_UNBIND, mp);
7649 mp->mb_create_table_if_needed = create_table_if_needed;
7650 mp->mb_is_bind = is_bind;
7651 mp->mb_is_ip4 = is_ip4;
7652 mp->mb_ip_table_id = ntohl (ip_table_id);
7653 mp->mb_mpls_table_id = 0;
7654 mp->mb_label = ntohl (local_label);
7655 mp->mb_address_length = address_length;
7658 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7660 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7665 /* Wait for a reply... */
7671 api_proxy_arp_add_del (vat_main_t * vam)
7673 unformat_input_t *i = vam->input;
7674 vl_api_proxy_arp_add_del_t *mp;
7677 ip4_address_t lo, hi;
7681 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7683 if (unformat (i, "vrf %d", &vrf_id))
7685 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7686 unformat_ip4_address, &hi))
7688 else if (unformat (i, "del"))
7692 clib_warning ("parse error '%U'", format_unformat_error, i);
7699 errmsg ("address range not set");
7703 M (PROXY_ARP_ADD_DEL, mp);
7705 mp->vrf_id = ntohl (vrf_id);
7706 mp->is_add = is_add;
7707 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7708 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7716 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7718 unformat_input_t *i = vam->input;
7719 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7722 u8 sw_if_index_set = 0;
7725 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7727 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7728 sw_if_index_set = 1;
7729 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7730 sw_if_index_set = 1;
7731 else if (unformat (i, "enable"))
7733 else if (unformat (i, "disable"))
7737 clib_warning ("parse error '%U'", format_unformat_error, i);
7742 if (sw_if_index_set == 0)
7744 errmsg ("missing interface name or sw_if_index");
7748 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7750 mp->sw_if_index = ntohl (sw_if_index);
7751 mp->enable_disable = enable;
7759 api_mpls_tunnel_add_del (vat_main_t * vam)
7761 unformat_input_t *i = vam->input;
7762 vl_api_mpls_tunnel_add_del_t *mp;
7766 u32 sw_if_index = ~0;
7767 u32 next_hop_sw_if_index = ~0;
7768 u32 next_hop_proto_is_ip4 = 1;
7770 u32 next_hop_table_id = 0;
7771 ip4_address_t v4_next_hop_address = {
7774 ip6_address_t v6_next_hop_address = { {0} };
7775 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7780 if (unformat (i, "add"))
7782 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7784 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7786 else if (unformat (i, "via %U",
7787 unformat_ip4_address, &v4_next_hop_address))
7789 next_hop_proto_is_ip4 = 1;
7791 else if (unformat (i, "via %U",
7792 unformat_ip6_address, &v6_next_hop_address))
7794 next_hop_proto_is_ip4 = 0;
7796 else if (unformat (i, "l2-only"))
7798 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7800 else if (unformat (i, "out-label %d", &next_hop_out_label))
7801 vec_add1 (labels, ntohl (next_hop_out_label));
7804 clib_warning ("parse error '%U'", format_unformat_error, i);
7809 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7811 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7812 mp->mt_sw_if_index = ntohl (sw_if_index);
7813 mp->mt_is_add = is_add;
7814 mp->mt_l2_only = l2_only;
7815 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7816 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7818 mp->mt_next_hop_n_out_labels = vec_len (labels);
7820 if (0 != mp->mt_next_hop_n_out_labels)
7822 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7823 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7827 if (next_hop_proto_is_ip4)
7829 clib_memcpy (mp->mt_next_hop,
7830 &v4_next_hop_address, sizeof (v4_next_hop_address));
7834 clib_memcpy (mp->mt_next_hop,
7835 &v6_next_hop_address, sizeof (v6_next_hop_address));
7844 api_sw_interface_set_unnumbered (vat_main_t * vam)
7846 unformat_input_t *i = vam->input;
7847 vl_api_sw_interface_set_unnumbered_t *mp;
7849 u32 unnum_sw_index = ~0;
7851 u8 sw_if_index_set = 0;
7854 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7856 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7857 sw_if_index_set = 1;
7858 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7859 sw_if_index_set = 1;
7860 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7862 else if (unformat (i, "del"))
7866 clib_warning ("parse error '%U'", format_unformat_error, i);
7871 if (sw_if_index_set == 0)
7873 errmsg ("missing interface name or sw_if_index");
7877 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7879 mp->sw_if_index = ntohl (sw_if_index);
7880 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7881 mp->is_add = is_add;
7889 api_ip_neighbor_add_del (vat_main_t * vam)
7891 unformat_input_t *i = vam->input;
7892 vl_api_ip_neighbor_add_del_t *mp;
7894 u8 sw_if_index_set = 0;
7897 u8 is_no_fib_entry = 0;
7900 u8 v4_address_set = 0;
7901 u8 v6_address_set = 0;
7902 ip4_address_t v4address;
7903 ip6_address_t v6address;
7906 memset (mac_address, 0, sizeof (mac_address));
7908 /* Parse args required to build the message */
7909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7911 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7915 else if (unformat (i, "del"))
7918 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7919 sw_if_index_set = 1;
7920 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7921 sw_if_index_set = 1;
7922 else if (unformat (i, "is_static"))
7924 else if (unformat (i, "no-fib-entry"))
7925 is_no_fib_entry = 1;
7926 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7928 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7932 clib_warning ("parse error '%U'", format_unformat_error, i);
7937 if (sw_if_index_set == 0)
7939 errmsg ("missing interface name or sw_if_index");
7942 if (v4_address_set && v6_address_set)
7944 errmsg ("both v4 and v6 addresses set");
7947 if (!v4_address_set && !v6_address_set)
7949 errmsg ("no address set");
7953 /* Construct the API message */
7954 M (IP_NEIGHBOR_ADD_DEL, mp);
7956 mp->sw_if_index = ntohl (sw_if_index);
7957 mp->is_add = is_add;
7958 mp->is_static = is_static;
7959 mp->is_no_adj_fib = is_no_fib_entry;
7961 clib_memcpy (mp->mac_address, mac_address, 6);
7965 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7969 /* mp->is_ipv6 = 0; via memset in M macro above */
7970 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7976 /* Wait for a reply, return good/bad news */
7982 api_reset_vrf (vat_main_t * vam)
7984 unformat_input_t *i = vam->input;
7985 vl_api_reset_vrf_t *mp;
7991 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7993 if (unformat (i, "vrf %d", &vrf_id))
7995 else if (unformat (i, "ipv6"))
7999 clib_warning ("parse error '%U'", format_unformat_error, i);
8004 if (vrf_id_set == 0)
8006 errmsg ("missing vrf id");
8012 mp->vrf_id = ntohl (vrf_id);
8013 mp->is_ipv6 = is_ipv6;
8021 api_create_vlan_subif (vat_main_t * vam)
8023 unformat_input_t *i = vam->input;
8024 vl_api_create_vlan_subif_t *mp;
8026 u8 sw_if_index_set = 0;
8031 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8033 if (unformat (i, "sw_if_index %d", &sw_if_index))
8034 sw_if_index_set = 1;
8036 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8037 sw_if_index_set = 1;
8038 else if (unformat (i, "vlan %d", &vlan_id))
8042 clib_warning ("parse error '%U'", format_unformat_error, i);
8047 if (sw_if_index_set == 0)
8049 errmsg ("missing interface name or sw_if_index");
8053 if (vlan_id_set == 0)
8055 errmsg ("missing vlan_id");
8058 M (CREATE_VLAN_SUBIF, mp);
8060 mp->sw_if_index = ntohl (sw_if_index);
8061 mp->vlan_id = ntohl (vlan_id);
8068 #define foreach_create_subif_bit \
8075 _(outer_vlan_id_any) \
8076 _(inner_vlan_id_any)
8079 api_create_subif (vat_main_t * vam)
8081 unformat_input_t *i = vam->input;
8082 vl_api_create_subif_t *mp;
8084 u8 sw_if_index_set = 0;
8091 u32 exact_match = 0;
8092 u32 default_sub = 0;
8093 u32 outer_vlan_id_any = 0;
8094 u32 inner_vlan_id_any = 0;
8096 u16 outer_vlan_id = 0;
8097 u16 inner_vlan_id = 0;
8100 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8102 if (unformat (i, "sw_if_index %d", &sw_if_index))
8103 sw_if_index_set = 1;
8105 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8106 sw_if_index_set = 1;
8107 else if (unformat (i, "sub_id %d", &sub_id))
8109 else if (unformat (i, "outer_vlan_id %d", &tmp))
8110 outer_vlan_id = tmp;
8111 else if (unformat (i, "inner_vlan_id %d", &tmp))
8112 inner_vlan_id = tmp;
8114 #define _(a) else if (unformat (i, #a)) a = 1 ;
8115 foreach_create_subif_bit
8119 clib_warning ("parse error '%U'", format_unformat_error, i);
8124 if (sw_if_index_set == 0)
8126 errmsg ("missing interface name or sw_if_index");
8130 if (sub_id_set == 0)
8132 errmsg ("missing sub_id");
8135 M (CREATE_SUBIF, mp);
8137 mp->sw_if_index = ntohl (sw_if_index);
8138 mp->sub_id = ntohl (sub_id);
8140 #define _(a) mp->a = a;
8141 foreach_create_subif_bit;
8144 mp->outer_vlan_id = ntohs (outer_vlan_id);
8145 mp->inner_vlan_id = ntohs (inner_vlan_id);
8153 api_oam_add_del (vat_main_t * vam)
8155 unformat_input_t *i = vam->input;
8156 vl_api_oam_add_del_t *mp;
8159 ip4_address_t src, dst;
8164 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8166 if (unformat (i, "vrf %d", &vrf_id))
8168 else if (unformat (i, "src %U", unformat_ip4_address, &src))
8170 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
8172 else if (unformat (i, "del"))
8176 clib_warning ("parse error '%U'", format_unformat_error, i);
8183 errmsg ("missing src addr");
8189 errmsg ("missing dst addr");
8193 M (OAM_ADD_DEL, mp);
8195 mp->vrf_id = ntohl (vrf_id);
8196 mp->is_add = is_add;
8197 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
8198 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8206 api_reset_fib (vat_main_t * vam)
8208 unformat_input_t *i = vam->input;
8209 vl_api_reset_fib_t *mp;
8215 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8217 if (unformat (i, "vrf %d", &vrf_id))
8219 else if (unformat (i, "ipv6"))
8223 clib_warning ("parse error '%U'", format_unformat_error, i);
8228 if (vrf_id_set == 0)
8230 errmsg ("missing vrf id");
8236 mp->vrf_id = ntohl (vrf_id);
8237 mp->is_ipv6 = is_ipv6;
8245 api_dhcp_proxy_config (vat_main_t * vam)
8247 unformat_input_t *i = vam->input;
8248 vl_api_dhcp_proxy_config_t *mp;
8250 u32 server_vrf_id = 0;
8252 u8 v4_address_set = 0;
8253 u8 v6_address_set = 0;
8254 ip4_address_t v4address;
8255 ip6_address_t v6address;
8256 u8 v4_src_address_set = 0;
8257 u8 v6_src_address_set = 0;
8258 ip4_address_t v4srcaddress;
8259 ip6_address_t v6srcaddress;
8262 /* Parse args required to build the message */
8263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8265 if (unformat (i, "del"))
8267 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8269 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8271 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8273 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8275 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8276 v4_src_address_set = 1;
8277 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8278 v6_src_address_set = 1;
8283 if (v4_address_set && v6_address_set)
8285 errmsg ("both v4 and v6 server addresses set");
8288 if (!v4_address_set && !v6_address_set)
8290 errmsg ("no server addresses set");
8294 if (v4_src_address_set && v6_src_address_set)
8296 errmsg ("both v4 and v6 src addresses set");
8299 if (!v4_src_address_set && !v6_src_address_set)
8301 errmsg ("no src addresses set");
8305 if (!(v4_src_address_set && v4_address_set) &&
8306 !(v6_src_address_set && v6_address_set))
8308 errmsg ("no matching server and src addresses set");
8312 /* Construct the API message */
8313 M (DHCP_PROXY_CONFIG, mp);
8315 mp->is_add = is_add;
8316 mp->rx_vrf_id = ntohl (rx_vrf_id);
8317 mp->server_vrf_id = ntohl (server_vrf_id);
8321 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
8322 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
8326 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
8327 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
8333 /* Wait for a reply, return good/bad news */
8338 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
8339 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
8342 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
8344 vat_main_t *vam = &vat_main;
8345 u32 i, count = mp->count;
8346 vl_api_dhcp_server_t *s;
8350 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8351 ntohl (mp->rx_vrf_id),
8352 format_ip6_address, mp->dhcp_src_address,
8353 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8356 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8357 ntohl (mp->rx_vrf_id),
8358 format_ip4_address, mp->dhcp_src_address,
8359 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8361 for (i = 0; i < count; i++)
8363 s = &mp->servers[i];
8367 " Server Table-ID %d, Server Address %U",
8368 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
8371 " Server Table-ID %d, Server Address %U",
8372 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
8376 static void vl_api_dhcp_proxy_details_t_handler_json
8377 (vl_api_dhcp_proxy_details_t * mp)
8379 vat_main_t *vam = &vat_main;
8380 vat_json_node_t *node = NULL;
8381 u32 i, count = mp->count;
8383 struct in6_addr ip6;
8384 vl_api_dhcp_server_t *s;
8386 if (VAT_JSON_ARRAY != vam->json_tree.type)
8388 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8389 vat_json_init_array (&vam->json_tree);
8391 node = vat_json_array_add (&vam->json_tree);
8393 vat_json_init_object (node);
8394 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
8395 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
8396 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
8400 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
8401 vat_json_object_add_ip6 (node, "src_address", ip6);
8405 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
8406 vat_json_object_add_ip4 (node, "src_address", ip4);
8409 for (i = 0; i < count; i++)
8411 s = &mp->servers[i];
8413 vat_json_object_add_uint (node, "server-table-id",
8414 ntohl (s->server_vrf_id));
8418 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
8419 vat_json_object_add_ip4 (node, "src_address", ip4);
8423 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
8424 vat_json_object_add_ip6 (node, "server_address", ip6);
8430 api_dhcp_proxy_dump (vat_main_t * vam)
8432 unformat_input_t *i = vam->input;
8433 vl_api_control_ping_t *mp_ping;
8434 vl_api_dhcp_proxy_dump_t *mp;
8438 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8440 if (unformat (i, "ipv6"))
8444 clib_warning ("parse error '%U'", format_unformat_error, i);
8449 M (DHCP_PROXY_DUMP, mp);
8451 mp->is_ip6 = is_ipv6;
8454 /* Use a control ping for synchronization */
8455 M (CONTROL_PING, mp_ping);
8463 api_dhcp_proxy_set_vss (vat_main_t * vam)
8465 unformat_input_t *i = vam->input;
8466 vl_api_dhcp_proxy_set_vss_t *mp;
8477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8479 if (unformat (i, "tbl_id %d", &tbl_id))
8481 if (unformat (i, "fib_id %d", &fib_id))
8483 if (unformat (i, "oui %d", &oui))
8485 else if (unformat (i, "ipv6"))
8487 else if (unformat (i, "del"))
8491 clib_warning ("parse error '%U'", format_unformat_error, i);
8496 if (tbl_id_set == 0)
8498 errmsg ("missing tbl id");
8502 if (fib_id_set == 0)
8504 errmsg ("missing fib id");
8509 errmsg ("missing oui");
8513 M (DHCP_PROXY_SET_VSS, mp);
8514 mp->tbl_id = ntohl (tbl_id);
8515 mp->fib_id = ntohl (fib_id);
8516 mp->oui = ntohl (oui);
8517 mp->is_ipv6 = is_ipv6;
8518 mp->is_add = is_add;
8526 api_dhcp_client_config (vat_main_t * vam)
8528 unformat_input_t *i = vam->input;
8529 vl_api_dhcp_client_config_t *mp;
8531 u8 sw_if_index_set = 0;
8534 u8 disable_event = 0;
8537 /* Parse args required to build the message */
8538 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8540 if (unformat (i, "del"))
8543 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8544 sw_if_index_set = 1;
8545 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8546 sw_if_index_set = 1;
8547 else if (unformat (i, "hostname %s", &hostname))
8549 else if (unformat (i, "disable_event"))
8555 if (sw_if_index_set == 0)
8557 errmsg ("missing interface name or sw_if_index");
8561 if (vec_len (hostname) > 63)
8563 errmsg ("hostname too long");
8565 vec_add1 (hostname, 0);
8567 /* Construct the API message */
8568 M (DHCP_CLIENT_CONFIG, mp);
8570 mp->sw_if_index = htonl (sw_if_index);
8571 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
8572 vec_free (hostname);
8573 mp->is_add = is_add;
8574 mp->want_dhcp_event = disable_event ? 0 : 1;
8575 mp->pid = htonl (getpid ());
8580 /* Wait for a reply, return good/bad news */
8586 api_set_ip_flow_hash (vat_main_t * vam)
8588 unformat_input_t *i = vam->input;
8589 vl_api_set_ip_flow_hash_t *mp;
8601 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8603 if (unformat (i, "vrf %d", &vrf_id))
8605 else if (unformat (i, "ipv6"))
8607 else if (unformat (i, "src"))
8609 else if (unformat (i, "dst"))
8611 else if (unformat (i, "sport"))
8613 else if (unformat (i, "dport"))
8615 else if (unformat (i, "proto"))
8617 else if (unformat (i, "reverse"))
8622 clib_warning ("parse error '%U'", format_unformat_error, i);
8627 if (vrf_id_set == 0)
8629 errmsg ("missing vrf id");
8633 M (SET_IP_FLOW_HASH, mp);
8639 mp->reverse = reverse;
8640 mp->vrf_id = ntohl (vrf_id);
8641 mp->is_ipv6 = is_ipv6;
8649 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8651 unformat_input_t *i = vam->input;
8652 vl_api_sw_interface_ip6_enable_disable_t *mp;
8654 u8 sw_if_index_set = 0;
8658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8660 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8661 sw_if_index_set = 1;
8662 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8663 sw_if_index_set = 1;
8664 else if (unformat (i, "enable"))
8666 else if (unformat (i, "disable"))
8670 clib_warning ("parse error '%U'", format_unformat_error, i);
8675 if (sw_if_index_set == 0)
8677 errmsg ("missing interface name or sw_if_index");
8681 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8683 mp->sw_if_index = ntohl (sw_if_index);
8684 mp->enable = enable;
8692 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8694 unformat_input_t *i = vam->input;
8695 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8697 u8 sw_if_index_set = 0;
8698 u8 v6_address_set = 0;
8699 ip6_address_t v6address;
8702 /* Parse args required to build the message */
8703 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8705 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8706 sw_if_index_set = 1;
8707 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8708 sw_if_index_set = 1;
8709 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8715 if (sw_if_index_set == 0)
8717 errmsg ("missing interface name or sw_if_index");
8720 if (!v6_address_set)
8722 errmsg ("no address set");
8726 /* Construct the API message */
8727 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8729 mp->sw_if_index = ntohl (sw_if_index);
8730 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8735 /* Wait for a reply, return good/bad news */
8741 api_ip6nd_proxy_add_del (vat_main_t * vam)
8743 unformat_input_t *i = vam->input;
8744 vl_api_ip6nd_proxy_add_del_t *mp;
8745 u32 sw_if_index = ~0;
8746 u8 v6_address_set = 0;
8747 ip6_address_t v6address;
8751 /* Parse args required to build the message */
8752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8754 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8756 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8758 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8760 if (unformat (i, "del"))
8764 clib_warning ("parse error '%U'", format_unformat_error, i);
8769 if (sw_if_index == ~0)
8771 errmsg ("missing interface name or sw_if_index");
8774 if (!v6_address_set)
8776 errmsg ("no address set");
8780 /* Construct the API message */
8781 M (IP6ND_PROXY_ADD_DEL, mp);
8783 mp->is_del = is_del;
8784 mp->sw_if_index = ntohl (sw_if_index);
8785 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8790 /* Wait for a reply, return good/bad news */
8796 api_ip6nd_proxy_dump (vat_main_t * vam)
8798 vl_api_ip6nd_proxy_dump_t *mp;
8799 vl_api_control_ping_t *mp_ping;
8802 M (IP6ND_PROXY_DUMP, mp);
8806 /* Use a control ping for synchronization */
8807 M (CONTROL_PING, mp_ping);
8814 static void vl_api_ip6nd_proxy_details_t_handler
8815 (vl_api_ip6nd_proxy_details_t * mp)
8817 vat_main_t *vam = &vat_main;
8819 print (vam->ofp, "host %U sw_if_index %d",
8820 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
8823 static void vl_api_ip6nd_proxy_details_t_handler_json
8824 (vl_api_ip6nd_proxy_details_t * mp)
8826 vat_main_t *vam = &vat_main;
8827 struct in6_addr ip6;
8828 vat_json_node_t *node = NULL;
8830 if (VAT_JSON_ARRAY != vam->json_tree.type)
8832 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8833 vat_json_init_array (&vam->json_tree);
8835 node = vat_json_array_add (&vam->json_tree);
8837 vat_json_init_object (node);
8838 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
8840 clib_memcpy (&ip6, mp->address, sizeof (ip6));
8841 vat_json_object_add_ip6 (node, "host", ip6);
8845 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8847 unformat_input_t *i = vam->input;
8848 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8850 u8 sw_if_index_set = 0;
8851 u32 address_length = 0;
8852 u8 v6_address_set = 0;
8853 ip6_address_t v6address;
8855 u8 no_advertise = 0;
8857 u8 no_autoconfig = 0;
8860 u32 val_lifetime = 0;
8861 u32 pref_lifetime = 0;
8864 /* Parse args required to build the message */
8865 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8867 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8868 sw_if_index_set = 1;
8869 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8870 sw_if_index_set = 1;
8871 else if (unformat (i, "%U/%d",
8872 unformat_ip6_address, &v6address, &address_length))
8874 else if (unformat (i, "val_life %d", &val_lifetime))
8876 else if (unformat (i, "pref_life %d", &pref_lifetime))
8878 else if (unformat (i, "def"))
8880 else if (unformat (i, "noadv"))
8882 else if (unformat (i, "offl"))
8884 else if (unformat (i, "noauto"))
8886 else if (unformat (i, "nolink"))
8888 else if (unformat (i, "isno"))
8892 clib_warning ("parse error '%U'", format_unformat_error, i);
8897 if (sw_if_index_set == 0)
8899 errmsg ("missing interface name or sw_if_index");
8902 if (!v6_address_set)
8904 errmsg ("no address set");
8908 /* Construct the API message */
8909 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8911 mp->sw_if_index = ntohl (sw_if_index);
8912 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8913 mp->address_length = address_length;
8914 mp->use_default = use_default;
8915 mp->no_advertise = no_advertise;
8916 mp->off_link = off_link;
8917 mp->no_autoconfig = no_autoconfig;
8918 mp->no_onlink = no_onlink;
8920 mp->val_lifetime = ntohl (val_lifetime);
8921 mp->pref_lifetime = ntohl (pref_lifetime);
8926 /* Wait for a reply, return good/bad news */
8932 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8934 unformat_input_t *i = vam->input;
8935 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8937 u8 sw_if_index_set = 0;
8942 u8 send_unicast = 0;
8945 u8 default_router = 0;
8946 u32 max_interval = 0;
8947 u32 min_interval = 0;
8949 u32 initial_count = 0;
8950 u32 initial_interval = 0;
8954 /* Parse args required to build the message */
8955 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8957 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8958 sw_if_index_set = 1;
8959 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8960 sw_if_index_set = 1;
8961 else if (unformat (i, "maxint %d", &max_interval))
8963 else if (unformat (i, "minint %d", &min_interval))
8965 else if (unformat (i, "life %d", &lifetime))
8967 else if (unformat (i, "count %d", &initial_count))
8969 else if (unformat (i, "interval %d", &initial_interval))
8971 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8973 else if (unformat (i, "managed"))
8975 else if (unformat (i, "other"))
8977 else if (unformat (i, "ll"))
8979 else if (unformat (i, "send"))
8981 else if (unformat (i, "cease"))
8983 else if (unformat (i, "isno"))
8985 else if (unformat (i, "def"))
8989 clib_warning ("parse error '%U'", format_unformat_error, i);
8994 if (sw_if_index_set == 0)
8996 errmsg ("missing interface name or sw_if_index");
9000 /* Construct the API message */
9001 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9003 mp->sw_if_index = ntohl (sw_if_index);
9004 mp->max_interval = ntohl (max_interval);
9005 mp->min_interval = ntohl (min_interval);
9006 mp->lifetime = ntohl (lifetime);
9007 mp->initial_count = ntohl (initial_count);
9008 mp->initial_interval = ntohl (initial_interval);
9009 mp->suppress = suppress;
9010 mp->managed = managed;
9012 mp->ll_option = ll_option;
9013 mp->send_unicast = send_unicast;
9016 mp->default_router = default_router;
9021 /* Wait for a reply, return good/bad news */
9027 api_set_arp_neighbor_limit (vat_main_t * vam)
9029 unformat_input_t *i = vam->input;
9030 vl_api_set_arp_neighbor_limit_t *mp;
9036 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9038 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9040 else if (unformat (i, "ipv6"))
9044 clib_warning ("parse error '%U'", format_unformat_error, i);
9051 errmsg ("missing limit value");
9055 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9057 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9058 mp->is_ipv6 = is_ipv6;
9066 api_l2_patch_add_del (vat_main_t * vam)
9068 unformat_input_t *i = vam->input;
9069 vl_api_l2_patch_add_del_t *mp;
9071 u8 rx_sw_if_index_set = 0;
9073 u8 tx_sw_if_index_set = 0;
9077 /* Parse args required to build the message */
9078 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9080 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9081 rx_sw_if_index_set = 1;
9082 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9083 tx_sw_if_index_set = 1;
9084 else if (unformat (i, "rx"))
9086 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9088 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9090 rx_sw_if_index_set = 1;
9095 else if (unformat (i, "tx"))
9097 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9099 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9101 tx_sw_if_index_set = 1;
9106 else if (unformat (i, "del"))
9112 if (rx_sw_if_index_set == 0)
9114 errmsg ("missing rx interface name or rx_sw_if_index");
9118 if (tx_sw_if_index_set == 0)
9120 errmsg ("missing tx interface name or tx_sw_if_index");
9124 M (L2_PATCH_ADD_DEL, mp);
9126 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9127 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9128 mp->is_add = is_add;
9136 u8 localsid_addr[16];
9145 api_sr_localsid_add_del (vat_main_t * vam)
9147 unformat_input_t *i = vam->input;
9148 vl_api_sr_localsid_add_del_t *mp;
9151 ip6_address_t localsid;
9155 u32 fib_table = ~(u32) 0;
9156 ip6_address_t next_hop;
9158 bool nexthop_set = 0;
9162 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9164 if (unformat (i, "del"))
9166 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9167 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
9169 else if (unformat (i, "behavior %u", &behavior));
9170 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9171 else if (unformat (i, "fib-table %u", &fib_table));
9172 else if (unformat (i, "end.psp %u", &behavior));
9177 M (SR_LOCALSID_ADD_DEL, mp);
9179 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
9181 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
9182 mp->behavior = behavior;
9183 mp->sw_if_index = ntohl (sw_if_index);
9184 mp->fib_table = ntohl (fib_table);
9185 mp->end_psp = end_psp;
9186 mp->is_del = is_del;
9194 api_ioam_enable (vat_main_t * vam)
9196 unformat_input_t *input = vam->input;
9197 vl_api_ioam_enable_t *mp;
9199 int has_trace_option = 0;
9200 int has_pot_option = 0;
9201 int has_seqno_option = 0;
9202 int has_analyse_option = 0;
9205 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9207 if (unformat (input, "trace"))
9208 has_trace_option = 1;
9209 else if (unformat (input, "pot"))
9211 else if (unformat (input, "seqno"))
9212 has_seqno_option = 1;
9213 else if (unformat (input, "analyse"))
9214 has_analyse_option = 1;
9218 M (IOAM_ENABLE, mp);
9219 mp->id = htons (id);
9220 mp->seqno = has_seqno_option;
9221 mp->analyse = has_analyse_option;
9222 mp->pot_enable = has_pot_option;
9223 mp->trace_enable = has_trace_option;
9232 api_ioam_disable (vat_main_t * vam)
9234 vl_api_ioam_disable_t *mp;
9237 M (IOAM_DISABLE, mp);
9243 #define foreach_tcp_proto_field \
9247 #define foreach_udp_proto_field \
9251 #define foreach_ip4_proto_field \
9263 u16 src_port, dst_port;
9266 #if VPP_API_TEST_BUILTIN == 0
9268 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9270 u8 **maskp = va_arg (*args, u8 **);
9272 u8 found_something = 0;
9275 #define _(a) u8 a=0;
9276 foreach_tcp_proto_field;
9279 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9282 #define _(a) else if (unformat (input, #a)) a=1;
9283 foreach_tcp_proto_field
9289 #define _(a) found_something += a;
9290 foreach_tcp_proto_field;
9293 if (found_something == 0)
9296 vec_validate (mask, sizeof (*tcp) - 1);
9298 tcp = (tcp_header_t *) mask;
9300 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9301 foreach_tcp_proto_field;
9309 unformat_udp_mask (unformat_input_t * input, va_list * args)
9311 u8 **maskp = va_arg (*args, u8 **);
9313 u8 found_something = 0;
9316 #define _(a) u8 a=0;
9317 foreach_udp_proto_field;
9320 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9323 #define _(a) else if (unformat (input, #a)) a=1;
9324 foreach_udp_proto_field
9330 #define _(a) found_something += a;
9331 foreach_udp_proto_field;
9334 if (found_something == 0)
9337 vec_validate (mask, sizeof (*udp) - 1);
9339 udp = (udp_header_t *) mask;
9341 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
9342 foreach_udp_proto_field;
9350 unformat_l4_mask (unformat_input_t * input, va_list * args)
9352 u8 **maskp = va_arg (*args, u8 **);
9353 u16 src_port = 0, dst_port = 0;
9354 tcpudp_header_t *tcpudp;
9356 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9358 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9360 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9362 else if (unformat (input, "src_port"))
9364 else if (unformat (input, "dst_port"))
9370 if (!src_port && !dst_port)
9374 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9376 tcpudp = (tcpudp_header_t *) mask;
9377 tcpudp->src_port = src_port;
9378 tcpudp->dst_port = dst_port;
9386 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9388 u8 **maskp = va_arg (*args, u8 **);
9390 u8 found_something = 0;
9393 #define _(a) u8 a=0;
9394 foreach_ip4_proto_field;
9400 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9402 if (unformat (input, "version"))
9404 else if (unformat (input, "hdr_length"))
9406 else if (unformat (input, "src"))
9408 else if (unformat (input, "dst"))
9410 else if (unformat (input, "proto"))
9413 #define _(a) else if (unformat (input, #a)) a=1;
9414 foreach_ip4_proto_field
9420 #define _(a) found_something += a;
9421 foreach_ip4_proto_field;
9424 if (found_something == 0)
9427 vec_validate (mask, sizeof (*ip) - 1);
9429 ip = (ip4_header_t *) mask;
9431 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9432 foreach_ip4_proto_field;
9435 ip->ip_version_and_header_length = 0;
9438 ip->ip_version_and_header_length |= 0xF0;
9441 ip->ip_version_and_header_length |= 0x0F;
9447 #define foreach_ip6_proto_field \
9455 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9457 u8 **maskp = va_arg (*args, u8 **);
9459 u8 found_something = 0;
9461 u32 ip_version_traffic_class_and_flow_label;
9463 #define _(a) u8 a=0;
9464 foreach_ip6_proto_field;
9467 u8 traffic_class = 0;
9470 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9472 if (unformat (input, "version"))
9474 else if (unformat (input, "traffic-class"))
9476 else if (unformat (input, "flow-label"))
9478 else if (unformat (input, "src"))
9480 else if (unformat (input, "dst"))
9482 else if (unformat (input, "proto"))
9485 #define _(a) else if (unformat (input, #a)) a=1;
9486 foreach_ip6_proto_field
9492 #define _(a) found_something += a;
9493 foreach_ip6_proto_field;
9496 if (found_something == 0)
9499 vec_validate (mask, sizeof (*ip) - 1);
9501 ip = (ip6_header_t *) mask;
9503 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9504 foreach_ip6_proto_field;
9507 ip_version_traffic_class_and_flow_label = 0;
9510 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9513 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9516 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9518 ip->ip_version_traffic_class_and_flow_label =
9519 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9526 unformat_l3_mask (unformat_input_t * input, va_list * args)
9528 u8 **maskp = va_arg (*args, u8 **);
9530 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9532 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9534 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9543 unformat_l2_mask (unformat_input_t * input, va_list * args)
9545 u8 **maskp = va_arg (*args, u8 **);
9560 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9562 if (unformat (input, "src"))
9564 else if (unformat (input, "dst"))
9566 else if (unformat (input, "proto"))
9568 else if (unformat (input, "tag1"))
9570 else if (unformat (input, "tag2"))
9572 else if (unformat (input, "ignore-tag1"))
9574 else if (unformat (input, "ignore-tag2"))
9576 else if (unformat (input, "cos1"))
9578 else if (unformat (input, "cos2"))
9580 else if (unformat (input, "dot1q"))
9582 else if (unformat (input, "dot1ad"))
9587 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9588 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9591 if (tag1 || ignore_tag1 || cos1 || dot1q)
9593 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9596 vec_validate (mask, len - 1);
9599 memset (mask, 0xff, 6);
9602 memset (mask + 6, 0xff, 6);
9606 /* inner vlan tag */
9615 mask[21] = mask[20] = 0xff;
9636 mask[16] = mask[17] = 0xff;
9646 mask[12] = mask[13] = 0xff;
9653 unformat_classify_mask (unformat_input_t * input, va_list * args)
9655 u8 **maskp = va_arg (*args, u8 **);
9656 u32 *skipp = va_arg (*args, u32 *);
9657 u32 *matchp = va_arg (*args, u32 *);
9665 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9667 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9669 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9671 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9673 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9687 if (mask || l2 || l3 || l4)
9691 /* "With a free Ethernet header in every package" */
9693 vec_validate (l2, 13);
9697 vec_append (mask, l3);
9702 vec_append (mask, l4);
9707 /* Scan forward looking for the first significant mask octet */
9708 for (i = 0; i < vec_len (mask); i++)
9712 /* compute (skip, match) params */
9713 *skipp = i / sizeof (u32x4);
9714 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9716 /* Pad mask to an even multiple of the vector size */
9717 while (vec_len (mask) % sizeof (u32x4))
9720 match = vec_len (mask) / sizeof (u32x4);
9722 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9724 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9725 if (*tmp || *(tmp + 1))
9730 clib_warning ("BUG: match 0");
9732 _vec_len (mask) = match * sizeof (u32x4);
9742 #endif /* VPP_API_TEST_BUILTIN */
9744 #define foreach_l2_next \
9746 _(ethernet, ETHERNET_INPUT) \
9751 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9753 u32 *miss_next_indexp = va_arg (*args, u32 *);
9758 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9762 if (unformat (input, "%d", &tmp))
9771 *miss_next_indexp = next_index;
9775 #define foreach_ip_next \
9781 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9783 u32 *miss_next_indexp = va_arg (*args, u32 *);
9788 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9792 if (unformat (input, "%d", &tmp))
9801 *miss_next_indexp = next_index;
9805 #define foreach_acl_next \
9809 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9811 u32 *miss_next_indexp = va_arg (*args, u32 *);
9816 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9820 if (unformat (input, "permit"))
9825 else if (unformat (input, "%d", &tmp))
9834 *miss_next_indexp = next_index;
9839 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9841 u32 *r = va_arg (*args, u32 *);
9843 if (unformat (input, "conform-color"))
9844 *r = POLICE_CONFORM;
9845 else if (unformat (input, "exceed-color"))
9854 api_classify_add_del_table (vat_main_t * vam)
9856 unformat_input_t *i = vam->input;
9857 vl_api_classify_add_del_table_t *mp;
9864 u32 table_index = ~0;
9865 u32 next_table_index = ~0;
9866 u32 miss_next_index = ~0;
9867 u32 memory_size = 32 << 20;
9869 u32 current_data_flag = 0;
9870 int current_data_offset = 0;
9873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9875 if (unformat (i, "del"))
9877 else if (unformat (i, "del-chain"))
9882 else if (unformat (i, "buckets %d", &nbuckets))
9884 else if (unformat (i, "memory_size %d", &memory_size))
9886 else if (unformat (i, "skip %d", &skip))
9888 else if (unformat (i, "match %d", &match))
9890 else if (unformat (i, "table %d", &table_index))
9892 else if (unformat (i, "mask %U", unformat_classify_mask,
9893 &mask, &skip, &match))
9895 else if (unformat (i, "next-table %d", &next_table_index))
9897 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9900 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9903 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9906 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9908 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9914 if (is_add && mask == 0)
9916 errmsg ("Mask required");
9920 if (is_add && skip == ~0)
9922 errmsg ("skip count required");
9926 if (is_add && match == ~0)
9928 errmsg ("match count required");
9932 if (!is_add && table_index == ~0)
9934 errmsg ("table index required for delete");
9938 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9940 mp->is_add = is_add;
9941 mp->del_chain = del_chain;
9942 mp->table_index = ntohl (table_index);
9943 mp->nbuckets = ntohl (nbuckets);
9944 mp->memory_size = ntohl (memory_size);
9945 mp->skip_n_vectors = ntohl (skip);
9946 mp->match_n_vectors = ntohl (match);
9947 mp->next_table_index = ntohl (next_table_index);
9948 mp->miss_next_index = ntohl (miss_next_index);
9949 mp->current_data_flag = ntohl (current_data_flag);
9950 mp->current_data_offset = ntohl (current_data_offset);
9951 clib_memcpy (mp->mask, mask, vec_len (mask));
9960 #if VPP_API_TEST_BUILTIN == 0
9962 unformat_l4_match (unformat_input_t * input, va_list * args)
9964 u8 **matchp = va_arg (*args, u8 **);
9966 u8 *proto_header = 0;
9972 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9974 if (unformat (input, "src_port %d", &src_port))
9976 else if (unformat (input, "dst_port %d", &dst_port))
9982 h.src_port = clib_host_to_net_u16 (src_port);
9983 h.dst_port = clib_host_to_net_u16 (dst_port);
9984 vec_validate (proto_header, sizeof (h) - 1);
9985 memcpy (proto_header, &h, sizeof (h));
9987 *matchp = proto_header;
9993 unformat_ip4_match (unformat_input_t * input, va_list * args)
9995 u8 **matchp = va_arg (*args, u8 **);
10000 int hdr_length = 0;
10001 u32 hdr_length_val;
10002 int src = 0, dst = 0;
10003 ip4_address_t src_val, dst_val;
10010 int fragment_id = 0;
10011 u32 fragment_id_val;
10017 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10019 if (unformat (input, "version %d", &version_val))
10021 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10023 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10025 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10027 else if (unformat (input, "proto %d", &proto_val))
10029 else if (unformat (input, "tos %d", &tos_val))
10031 else if (unformat (input, "length %d", &length_val))
10033 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10035 else if (unformat (input, "ttl %d", &ttl_val))
10037 else if (unformat (input, "checksum %d", &checksum_val))
10043 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10044 + ttl + checksum == 0)
10048 * Aligned because we use the real comparison functions
10050 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10052 ip = (ip4_header_t *) match;
10054 /* These are realistically matched in practice */
10056 ip->src_address.as_u32 = src_val.as_u32;
10059 ip->dst_address.as_u32 = dst_val.as_u32;
10062 ip->protocol = proto_val;
10065 /* These are not, but they're included for completeness */
10067 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10070 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10076 ip->length = clib_host_to_net_u16 (length_val);
10082 ip->checksum = clib_host_to_net_u16 (checksum_val);
10089 unformat_ip6_match (unformat_input_t * input, va_list * args)
10091 u8 **matchp = va_arg (*args, u8 **);
10096 u8 traffic_class = 0;
10097 u32 traffic_class_val = 0;
10100 int src = 0, dst = 0;
10101 ip6_address_t src_val, dst_val;
10104 int payload_length = 0;
10105 u32 payload_length_val;
10108 u32 ip_version_traffic_class_and_flow_label;
10110 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10112 if (unformat (input, "version %d", &version_val))
10114 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10116 else if (unformat (input, "flow_label %d", &flow_label_val))
10118 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10120 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10122 else if (unformat (input, "proto %d", &proto_val))
10124 else if (unformat (input, "payload_length %d", &payload_length_val))
10125 payload_length = 1;
10126 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10132 if (version + traffic_class + flow_label + src + dst + proto +
10133 payload_length + hop_limit == 0)
10137 * Aligned because we use the real comparison functions
10139 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10141 ip = (ip6_header_t *) match;
10144 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10147 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10150 ip->protocol = proto_val;
10152 ip_version_traffic_class_and_flow_label = 0;
10155 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10158 ip_version_traffic_class_and_flow_label |=
10159 (traffic_class_val & 0xFF) << 20;
10162 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10164 ip->ip_version_traffic_class_and_flow_label =
10165 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10167 if (payload_length)
10168 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10171 ip->hop_limit = hop_limit_val;
10178 unformat_l3_match (unformat_input_t * input, va_list * args)
10180 u8 **matchp = va_arg (*args, u8 **);
10182 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10184 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10186 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10195 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10197 u8 *tagp = va_arg (*args, u8 *);
10200 if (unformat (input, "%d", &tag))
10202 tagp[0] = (tag >> 8) & 0x0F;
10203 tagp[1] = tag & 0xFF;
10211 unformat_l2_match (unformat_input_t * input, va_list * args)
10213 u8 **matchp = va_arg (*args, u8 **);
10226 u8 ignore_tag1 = 0;
10227 u8 ignore_tag2 = 0;
10233 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10235 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10238 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10240 else if (unformat (input, "proto %U",
10241 unformat_ethernet_type_host_byte_order, &proto_val))
10243 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10245 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10247 else if (unformat (input, "ignore-tag1"))
10249 else if (unformat (input, "ignore-tag2"))
10251 else if (unformat (input, "cos1 %d", &cos1_val))
10253 else if (unformat (input, "cos2 %d", &cos2_val))
10258 if ((src + dst + proto + tag1 + tag2 +
10259 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10262 if (tag1 || ignore_tag1 || cos1)
10264 if (tag2 || ignore_tag2 || cos2)
10267 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10270 clib_memcpy (match, dst_val, 6);
10273 clib_memcpy (match + 6, src_val, 6);
10277 /* inner vlan tag */
10278 match[19] = tag2_val[1];
10279 match[18] = tag2_val[0];
10281 match[18] |= (cos2_val & 0x7) << 5;
10284 match[21] = proto_val & 0xff;
10285 match[20] = proto_val >> 8;
10289 match[15] = tag1_val[1];
10290 match[14] = tag1_val[0];
10293 match[14] |= (cos1_val & 0x7) << 5;
10299 match[15] = tag1_val[1];
10300 match[14] = tag1_val[0];
10303 match[17] = proto_val & 0xff;
10304 match[16] = proto_val >> 8;
10307 match[14] |= (cos1_val & 0x7) << 5;
10313 match[18] |= (cos2_val & 0x7) << 5;
10315 match[14] |= (cos1_val & 0x7) << 5;
10318 match[13] = proto_val & 0xff;
10319 match[12] = proto_val >> 8;
10328 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10330 u8 **matchp = va_arg (*args, u8 **);
10331 u32 skip_n_vectors = va_arg (*args, u32);
10332 u32 match_n_vectors = va_arg (*args, u32);
10339 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10341 if (unformat (input, "hex %U", unformat_hex_string, &match))
10343 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10345 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10347 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10361 if (match || l2 || l3 || l4)
10363 if (l2 || l3 || l4)
10365 /* "Win a free Ethernet header in every packet" */
10367 vec_validate_aligned (l2, 13, sizeof (u32x4));
10371 vec_append_aligned (match, l3, sizeof (u32x4));
10376 vec_append_aligned (match, l4, sizeof (u32x4));
10381 /* Make sure the vector is big enough even if key is all 0's */
10382 vec_validate_aligned
10383 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10386 /* Set size, include skipped vectors */
10387 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10398 api_classify_add_del_session (vat_main_t * vam)
10400 unformat_input_t *i = vam->input;
10401 vl_api_classify_add_del_session_t *mp;
10403 u32 table_index = ~0;
10404 u32 hit_next_index = ~0;
10405 u32 opaque_index = ~0;
10408 u32 skip_n_vectors = 0;
10409 u32 match_n_vectors = 0;
10415 * Warning: you have to supply skip_n and match_n
10416 * because the API client cant simply look at the classify
10420 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10422 if (unformat (i, "del"))
10424 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10427 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10430 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10433 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10435 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10437 else if (unformat (i, "opaque-index %d", &opaque_index))
10439 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10441 else if (unformat (i, "match_n %d", &match_n_vectors))
10443 else if (unformat (i, "match %U", api_unformat_classify_match,
10444 &match, skip_n_vectors, match_n_vectors))
10446 else if (unformat (i, "advance %d", &advance))
10448 else if (unformat (i, "table-index %d", &table_index))
10450 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10452 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10454 else if (unformat (i, "action %d", &action))
10456 else if (unformat (i, "metadata %d", &metadata))
10462 if (table_index == ~0)
10464 errmsg ("Table index required");
10468 if (is_add && match == 0)
10470 errmsg ("Match value required");
10474 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10476 mp->is_add = is_add;
10477 mp->table_index = ntohl (table_index);
10478 mp->hit_next_index = ntohl (hit_next_index);
10479 mp->opaque_index = ntohl (opaque_index);
10480 mp->advance = ntohl (advance);
10481 mp->action = action;
10482 mp->metadata = ntohl (metadata);
10483 clib_memcpy (mp->match, match, vec_len (match));
10492 api_classify_set_interface_ip_table (vat_main_t * vam)
10494 unformat_input_t *i = vam->input;
10495 vl_api_classify_set_interface_ip_table_t *mp;
10497 int sw_if_index_set;
10498 u32 table_index = ~0;
10502 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10504 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10505 sw_if_index_set = 1;
10506 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10507 sw_if_index_set = 1;
10508 else if (unformat (i, "table %d", &table_index))
10512 clib_warning ("parse error '%U'", format_unformat_error, i);
10517 if (sw_if_index_set == 0)
10519 errmsg ("missing interface name or sw_if_index");
10524 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10526 mp->sw_if_index = ntohl (sw_if_index);
10527 mp->table_index = ntohl (table_index);
10528 mp->is_ipv6 = is_ipv6;
10536 api_classify_set_interface_l2_tables (vat_main_t * vam)
10538 unformat_input_t *i = vam->input;
10539 vl_api_classify_set_interface_l2_tables_t *mp;
10541 int sw_if_index_set;
10542 u32 ip4_table_index = ~0;
10543 u32 ip6_table_index = ~0;
10544 u32 other_table_index = ~0;
10548 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10550 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10551 sw_if_index_set = 1;
10552 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10553 sw_if_index_set = 1;
10554 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10556 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10558 else if (unformat (i, "other-table %d", &other_table_index))
10560 else if (unformat (i, "is-input %d", &is_input))
10564 clib_warning ("parse error '%U'", format_unformat_error, i);
10569 if (sw_if_index_set == 0)
10571 errmsg ("missing interface name or sw_if_index");
10576 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10578 mp->sw_if_index = ntohl (sw_if_index);
10579 mp->ip4_table_index = ntohl (ip4_table_index);
10580 mp->ip6_table_index = ntohl (ip6_table_index);
10581 mp->other_table_index = ntohl (other_table_index);
10582 mp->is_input = (u8) is_input;
10590 api_set_ipfix_exporter (vat_main_t * vam)
10592 unformat_input_t *i = vam->input;
10593 vl_api_set_ipfix_exporter_t *mp;
10594 ip4_address_t collector_address;
10595 u8 collector_address_set = 0;
10596 u32 collector_port = ~0;
10597 ip4_address_t src_address;
10598 u8 src_address_set = 0;
10601 u32 template_interval = ~0;
10602 u8 udp_checksum = 0;
10605 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10607 if (unformat (i, "collector_address %U", unformat_ip4_address,
10608 &collector_address))
10609 collector_address_set = 1;
10610 else if (unformat (i, "collector_port %d", &collector_port))
10612 else if (unformat (i, "src_address %U", unformat_ip4_address,
10614 src_address_set = 1;
10615 else if (unformat (i, "vrf_id %d", &vrf_id))
10617 else if (unformat (i, "path_mtu %d", &path_mtu))
10619 else if (unformat (i, "template_interval %d", &template_interval))
10621 else if (unformat (i, "udp_checksum"))
10627 if (collector_address_set == 0)
10629 errmsg ("collector_address required");
10633 if (src_address_set == 0)
10635 errmsg ("src_address required");
10639 M (SET_IPFIX_EXPORTER, mp);
10641 memcpy (mp->collector_address, collector_address.data,
10642 sizeof (collector_address.data));
10643 mp->collector_port = htons ((u16) collector_port);
10644 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10645 mp->vrf_id = htonl (vrf_id);
10646 mp->path_mtu = htonl (path_mtu);
10647 mp->template_interval = htonl (template_interval);
10648 mp->udp_checksum = udp_checksum;
10656 api_set_ipfix_classify_stream (vat_main_t * vam)
10658 unformat_input_t *i = vam->input;
10659 vl_api_set_ipfix_classify_stream_t *mp;
10661 u32 src_port = UDP_DST_PORT_ipfix;
10664 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10666 if (unformat (i, "domain %d", &domain_id))
10668 else if (unformat (i, "src_port %d", &src_port))
10672 errmsg ("unknown input `%U'", format_unformat_error, i);
10677 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10679 mp->domain_id = htonl (domain_id);
10680 mp->src_port = htons ((u16) src_port);
10688 api_ipfix_classify_table_add_del (vat_main_t * vam)
10690 unformat_input_t *i = vam->input;
10691 vl_api_ipfix_classify_table_add_del_t *mp;
10693 u32 classify_table_index = ~0;
10695 u8 transport_protocol = 255;
10698 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10700 if (unformat (i, "add"))
10702 else if (unformat (i, "del"))
10704 else if (unformat (i, "table %d", &classify_table_index))
10706 else if (unformat (i, "ip4"))
10708 else if (unformat (i, "ip6"))
10710 else if (unformat (i, "tcp"))
10711 transport_protocol = 6;
10712 else if (unformat (i, "udp"))
10713 transport_protocol = 17;
10716 errmsg ("unknown input `%U'", format_unformat_error, i);
10723 errmsg ("expecting: add|del");
10726 if (classify_table_index == ~0)
10728 errmsg ("classifier table not specified");
10731 if (ip_version == 0)
10733 errmsg ("IP version not specified");
10737 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10739 mp->is_add = is_add;
10740 mp->table_id = htonl (classify_table_index);
10741 mp->ip_version = ip_version;
10742 mp->transport_protocol = transport_protocol;
10750 api_get_node_index (vat_main_t * vam)
10752 unformat_input_t *i = vam->input;
10753 vl_api_get_node_index_t *mp;
10757 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10759 if (unformat (i, "node %s", &name))
10766 errmsg ("node name required");
10769 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10771 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10775 M (GET_NODE_INDEX, mp);
10776 clib_memcpy (mp->node_name, name, vec_len (name));
10785 api_get_next_index (vat_main_t * vam)
10787 unformat_input_t *i = vam->input;
10788 vl_api_get_next_index_t *mp;
10789 u8 *node_name = 0, *next_node_name = 0;
10792 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10794 if (unformat (i, "node-name %s", &node_name))
10796 else if (unformat (i, "next-node-name %s", &next_node_name))
10800 if (node_name == 0)
10802 errmsg ("node name required");
10805 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10807 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10811 if (next_node_name == 0)
10813 errmsg ("next node name required");
10816 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10818 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10822 M (GET_NEXT_INDEX, mp);
10823 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10824 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10825 vec_free (node_name);
10826 vec_free (next_node_name);
10834 api_add_node_next (vat_main_t * vam)
10836 unformat_input_t *i = vam->input;
10837 vl_api_add_node_next_t *mp;
10842 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10844 if (unformat (i, "node %s", &name))
10846 else if (unformat (i, "next %s", &next))
10853 errmsg ("node name required");
10856 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10858 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10863 errmsg ("next node required");
10866 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10868 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10872 M (ADD_NODE_NEXT, mp);
10873 clib_memcpy (mp->node_name, name, vec_len (name));
10874 clib_memcpy (mp->next_name, next, vec_len (next));
10884 api_l2tpv3_create_tunnel (vat_main_t * vam)
10886 unformat_input_t *i = vam->input;
10887 ip6_address_t client_address, our_address;
10888 int client_address_set = 0;
10889 int our_address_set = 0;
10890 u32 local_session_id = 0;
10891 u32 remote_session_id = 0;
10892 u64 local_cookie = 0;
10893 u64 remote_cookie = 0;
10894 u8 l2_sublayer_present = 0;
10895 vl_api_l2tpv3_create_tunnel_t *mp;
10898 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10900 if (unformat (i, "client_address %U", unformat_ip6_address,
10902 client_address_set = 1;
10903 else if (unformat (i, "our_address %U", unformat_ip6_address,
10905 our_address_set = 1;
10906 else if (unformat (i, "local_session_id %d", &local_session_id))
10908 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10910 else if (unformat (i, "local_cookie %lld", &local_cookie))
10912 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10914 else if (unformat (i, "l2-sublayer-present"))
10915 l2_sublayer_present = 1;
10920 if (client_address_set == 0)
10922 errmsg ("client_address required");
10926 if (our_address_set == 0)
10928 errmsg ("our_address required");
10932 M (L2TPV3_CREATE_TUNNEL, mp);
10934 clib_memcpy (mp->client_address, client_address.as_u8,
10935 sizeof (mp->client_address));
10937 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10939 mp->local_session_id = ntohl (local_session_id);
10940 mp->remote_session_id = ntohl (remote_session_id);
10941 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10942 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10943 mp->l2_sublayer_present = l2_sublayer_present;
10952 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10954 unformat_input_t *i = vam->input;
10956 u8 sw_if_index_set = 0;
10957 u64 new_local_cookie = 0;
10958 u64 new_remote_cookie = 0;
10959 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10962 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10964 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10965 sw_if_index_set = 1;
10966 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10967 sw_if_index_set = 1;
10968 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10970 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10976 if (sw_if_index_set == 0)
10978 errmsg ("missing interface name or sw_if_index");
10982 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10984 mp->sw_if_index = ntohl (sw_if_index);
10985 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10986 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10994 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10996 unformat_input_t *i = vam->input;
10997 vl_api_l2tpv3_interface_enable_disable_t *mp;
10999 u8 sw_if_index_set = 0;
11000 u8 enable_disable = 1;
11003 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11005 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11006 sw_if_index_set = 1;
11007 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11008 sw_if_index_set = 1;
11009 else if (unformat (i, "enable"))
11010 enable_disable = 1;
11011 else if (unformat (i, "disable"))
11012 enable_disable = 0;
11017 if (sw_if_index_set == 0)
11019 errmsg ("missing interface name or sw_if_index");
11023 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11025 mp->sw_if_index = ntohl (sw_if_index);
11026 mp->enable_disable = enable_disable;
11034 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11036 unformat_input_t *i = vam->input;
11037 vl_api_l2tpv3_set_lookup_key_t *mp;
11041 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11043 if (unformat (i, "lookup_v6_src"))
11044 key = L2T_LOOKUP_SRC_ADDRESS;
11045 else if (unformat (i, "lookup_v6_dst"))
11046 key = L2T_LOOKUP_DST_ADDRESS;
11047 else if (unformat (i, "lookup_session_id"))
11048 key = L2T_LOOKUP_SESSION_ID;
11053 if (key == (u8) ~ 0)
11055 errmsg ("l2tp session lookup key unset");
11059 M (L2TPV3_SET_LOOKUP_KEY, mp);
11068 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11069 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11071 vat_main_t *vam = &vat_main;
11073 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11074 format_ip6_address, mp->our_address,
11075 format_ip6_address, mp->client_address,
11076 clib_net_to_host_u32 (mp->sw_if_index));
11079 " local cookies %016llx %016llx remote cookie %016llx",
11080 clib_net_to_host_u64 (mp->local_cookie[0]),
11081 clib_net_to_host_u64 (mp->local_cookie[1]),
11082 clib_net_to_host_u64 (mp->remote_cookie));
11084 print (vam->ofp, " local session-id %d remote session-id %d",
11085 clib_net_to_host_u32 (mp->local_session_id),
11086 clib_net_to_host_u32 (mp->remote_session_id));
11088 print (vam->ofp, " l2 specific sublayer %s\n",
11089 mp->l2_sublayer_present ? "preset" : "absent");
11093 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11094 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11096 vat_main_t *vam = &vat_main;
11097 vat_json_node_t *node = NULL;
11098 struct in6_addr addr;
11100 if (VAT_JSON_ARRAY != vam->json_tree.type)
11102 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11103 vat_json_init_array (&vam->json_tree);
11105 node = vat_json_array_add (&vam->json_tree);
11107 vat_json_init_object (node);
11109 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11110 vat_json_object_add_ip6 (node, "our_address", addr);
11111 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11112 vat_json_object_add_ip6 (node, "client_address", addr);
11114 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11115 vat_json_init_array (lc);
11116 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11117 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11118 vat_json_object_add_uint (node, "remote_cookie",
11119 clib_net_to_host_u64 (mp->remote_cookie));
11121 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11122 vat_json_object_add_uint (node, "local_session_id",
11123 clib_net_to_host_u32 (mp->local_session_id));
11124 vat_json_object_add_uint (node, "remote_session_id",
11125 clib_net_to_host_u32 (mp->remote_session_id));
11126 vat_json_object_add_string_copy (node, "l2_sublayer",
11127 mp->l2_sublayer_present ? (u8 *) "present"
11128 : (u8 *) "absent");
11132 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11134 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11135 vl_api_control_ping_t *mp_ping;
11138 /* Get list of l2tpv3-tunnel interfaces */
11139 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11142 /* Use a control ping for synchronization */
11143 M (CONTROL_PING, mp_ping);
11151 static void vl_api_sw_interface_tap_details_t_handler
11152 (vl_api_sw_interface_tap_details_t * mp)
11154 vat_main_t *vam = &vat_main;
11156 print (vam->ofp, "%-16s %d",
11157 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
11160 static void vl_api_sw_interface_tap_details_t_handler_json
11161 (vl_api_sw_interface_tap_details_t * mp)
11163 vat_main_t *vam = &vat_main;
11164 vat_json_node_t *node = NULL;
11166 if (VAT_JSON_ARRAY != vam->json_tree.type)
11168 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11169 vat_json_init_array (&vam->json_tree);
11171 node = vat_json_array_add (&vam->json_tree);
11173 vat_json_init_object (node);
11174 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11175 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11179 api_sw_interface_tap_dump (vat_main_t * vam)
11181 vl_api_sw_interface_tap_dump_t *mp;
11182 vl_api_control_ping_t *mp_ping;
11185 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
11186 /* Get list of tap interfaces */
11187 M (SW_INTERFACE_TAP_DUMP, mp);
11190 /* Use a control ping for synchronization */
11191 M (CONTROL_PING, mp_ping);
11198 static uword unformat_vxlan_decap_next
11199 (unformat_input_t * input, va_list * args)
11201 u32 *result = va_arg (*args, u32 *);
11204 if (unformat (input, "l2"))
11205 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11206 else if (unformat (input, "%d", &tmp))
11214 api_vxlan_add_del_tunnel (vat_main_t * vam)
11216 unformat_input_t *line_input = vam->input;
11217 vl_api_vxlan_add_del_tunnel_t *mp;
11218 ip46_address_t src, dst;
11220 u8 ipv4_set = 0, ipv6_set = 0;
11224 u32 mcast_sw_if_index = ~0;
11225 u32 encap_vrf_id = 0;
11226 u32 decap_next_index = ~0;
11230 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11231 memset (&src, 0, sizeof src);
11232 memset (&dst, 0, sizeof dst);
11234 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11236 if (unformat (line_input, "del"))
11239 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11245 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11251 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11257 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11262 else if (unformat (line_input, "group %U %U",
11263 unformat_ip4_address, &dst.ip4,
11264 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11266 grp_set = dst_set = 1;
11269 else if (unformat (line_input, "group %U",
11270 unformat_ip4_address, &dst.ip4))
11272 grp_set = dst_set = 1;
11275 else if (unformat (line_input, "group %U %U",
11276 unformat_ip6_address, &dst.ip6,
11277 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11279 grp_set = dst_set = 1;
11282 else if (unformat (line_input, "group %U",
11283 unformat_ip6_address, &dst.ip6))
11285 grp_set = dst_set = 1;
11289 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11291 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11293 else if (unformat (line_input, "decap-next %U",
11294 unformat_vxlan_decap_next, &decap_next_index))
11296 else if (unformat (line_input, "vni %d", &vni))
11300 errmsg ("parse error '%U'", format_unformat_error, line_input);
11307 errmsg ("tunnel src address not specified");
11312 errmsg ("tunnel dst address not specified");
11316 if (grp_set && !ip46_address_is_multicast (&dst))
11318 errmsg ("tunnel group address not multicast");
11321 if (grp_set && mcast_sw_if_index == ~0)
11323 errmsg ("tunnel nonexistent multicast device");
11326 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11328 errmsg ("tunnel dst address must be unicast");
11333 if (ipv4_set && ipv6_set)
11335 errmsg ("both IPv4 and IPv6 addresses specified");
11339 if ((vni == 0) || (vni >> 24))
11341 errmsg ("vni not specified or out of range");
11345 M (VXLAN_ADD_DEL_TUNNEL, mp);
11349 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
11350 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
11354 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
11355 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
11357 mp->encap_vrf_id = ntohl (encap_vrf_id);
11358 mp->decap_next_index = ntohl (decap_next_index);
11359 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11360 mp->vni = ntohl (vni);
11361 mp->is_add = is_add;
11362 mp->is_ipv6 = ipv6_set;
11369 static void vl_api_vxlan_tunnel_details_t_handler
11370 (vl_api_vxlan_tunnel_details_t * mp)
11372 vat_main_t *vam = &vat_main;
11373 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
11374 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
11376 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
11377 ntohl (mp->sw_if_index),
11378 format_ip46_address, &src, IP46_TYPE_ANY,
11379 format_ip46_address, &dst, IP46_TYPE_ANY,
11380 ntohl (mp->encap_vrf_id),
11381 ntohl (mp->decap_next_index), ntohl (mp->vni),
11382 ntohl (mp->mcast_sw_if_index));
11385 static void vl_api_vxlan_tunnel_details_t_handler_json
11386 (vl_api_vxlan_tunnel_details_t * mp)
11388 vat_main_t *vam = &vat_main;
11389 vat_json_node_t *node = NULL;
11391 if (VAT_JSON_ARRAY != vam->json_tree.type)
11393 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11394 vat_json_init_array (&vam->json_tree);
11396 node = vat_json_array_add (&vam->json_tree);
11398 vat_json_init_object (node);
11399 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11402 struct in6_addr ip6;
11404 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
11405 vat_json_object_add_ip6 (node, "src_address", ip6);
11406 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
11407 vat_json_object_add_ip6 (node, "dst_address", ip6);
11411 struct in_addr ip4;
11413 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
11414 vat_json_object_add_ip4 (node, "src_address", ip4);
11415 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
11416 vat_json_object_add_ip4 (node, "dst_address", ip4);
11418 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11419 vat_json_object_add_uint (node, "decap_next_index",
11420 ntohl (mp->decap_next_index));
11421 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11422 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11423 vat_json_object_add_uint (node, "mcast_sw_if_index",
11424 ntohl (mp->mcast_sw_if_index));
11428 api_vxlan_tunnel_dump (vat_main_t * vam)
11430 unformat_input_t *i = vam->input;
11431 vl_api_vxlan_tunnel_dump_t *mp;
11432 vl_api_control_ping_t *mp_ping;
11434 u8 sw_if_index_set = 0;
11437 /* Parse args required to build the message */
11438 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11440 if (unformat (i, "sw_if_index %d", &sw_if_index))
11441 sw_if_index_set = 1;
11446 if (sw_if_index_set == 0)
11451 if (!vam->json_output)
11453 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
11454 "sw_if_index", "src_address", "dst_address",
11455 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11458 /* Get list of vxlan-tunnel interfaces */
11459 M (VXLAN_TUNNEL_DUMP, mp);
11461 mp->sw_if_index = htonl (sw_if_index);
11465 /* Use a control ping for synchronization */
11466 M (CONTROL_PING, mp_ping);
11474 api_gre_add_del_tunnel (vat_main_t * vam)
11476 unformat_input_t *line_input = vam->input;
11477 vl_api_gre_add_del_tunnel_t *mp;
11478 ip4_address_t src4, dst4;
11479 ip6_address_t src6, dst6;
11486 u32 outer_fib_id = 0;
11489 memset (&src4, 0, sizeof src4);
11490 memset (&dst4, 0, sizeof dst4);
11491 memset (&src6, 0, sizeof src6);
11492 memset (&dst6, 0, sizeof dst6);
11494 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11496 if (unformat (line_input, "del"))
11498 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
11503 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
11508 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
11513 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
11518 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
11520 else if (unformat (line_input, "teb"))
11524 errmsg ("parse error '%U'", format_unformat_error, line_input);
11531 errmsg ("tunnel src address not specified");
11536 errmsg ("tunnel dst address not specified");
11539 if (ipv4_set && ipv6_set)
11541 errmsg ("both IPv4 and IPv6 addresses specified");
11546 M (GRE_ADD_DEL_TUNNEL, mp);
11550 clib_memcpy (&mp->src_address, &src4, 4);
11551 clib_memcpy (&mp->dst_address, &dst4, 4);
11555 clib_memcpy (&mp->src_address, &src6, 16);
11556 clib_memcpy (&mp->dst_address, &dst6, 16);
11558 mp->outer_fib_id = ntohl (outer_fib_id);
11559 mp->is_add = is_add;
11561 mp->is_ipv6 = ipv6_set;
11568 static void vl_api_gre_tunnel_details_t_handler
11569 (vl_api_gre_tunnel_details_t * mp)
11571 vat_main_t *vam = &vat_main;
11572 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
11573 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
11575 print (vam->ofp, "%11d%24U%24U%6d%14d",
11576 ntohl (mp->sw_if_index),
11577 format_ip46_address, &src, IP46_TYPE_ANY,
11578 format_ip46_address, &dst, IP46_TYPE_ANY,
11579 mp->teb, ntohl (mp->outer_fib_id));
11582 static void vl_api_gre_tunnel_details_t_handler_json
11583 (vl_api_gre_tunnel_details_t * mp)
11585 vat_main_t *vam = &vat_main;
11586 vat_json_node_t *node = NULL;
11587 struct in_addr ip4;
11588 struct in6_addr ip6;
11590 if (VAT_JSON_ARRAY != vam->json_tree.type)
11592 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11593 vat_json_init_array (&vam->json_tree);
11595 node = vat_json_array_add (&vam->json_tree);
11597 vat_json_init_object (node);
11598 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11601 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11602 vat_json_object_add_ip4 (node, "src_address", ip4);
11603 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11604 vat_json_object_add_ip4 (node, "dst_address", ip4);
11608 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
11609 vat_json_object_add_ip6 (node, "src_address", ip6);
11610 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
11611 vat_json_object_add_ip6 (node, "dst_address", ip6);
11613 vat_json_object_add_uint (node, "teb", mp->teb);
11614 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11615 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
11619 api_gre_tunnel_dump (vat_main_t * vam)
11621 unformat_input_t *i = vam->input;
11622 vl_api_gre_tunnel_dump_t *mp;
11623 vl_api_control_ping_t *mp_ping;
11625 u8 sw_if_index_set = 0;
11628 /* Parse args required to build the message */
11629 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11631 if (unformat (i, "sw_if_index %d", &sw_if_index))
11632 sw_if_index_set = 1;
11637 if (sw_if_index_set == 0)
11642 if (!vam->json_output)
11644 print (vam->ofp, "%11s%24s%24s%6s%14s",
11645 "sw_if_index", "src_address", "dst_address", "teb",
11649 /* Get list of gre-tunnel interfaces */
11650 M (GRE_TUNNEL_DUMP, mp);
11652 mp->sw_if_index = htonl (sw_if_index);
11656 /* Use a control ping for synchronization */
11657 M (CONTROL_PING, mp_ping);
11665 api_l2_fib_clear_table (vat_main_t * vam)
11667 // unformat_input_t * i = vam->input;
11668 vl_api_l2_fib_clear_table_t *mp;
11671 M (L2_FIB_CLEAR_TABLE, mp);
11679 api_l2_interface_efp_filter (vat_main_t * vam)
11681 unformat_input_t *i = vam->input;
11682 vl_api_l2_interface_efp_filter_t *mp;
11685 u8 sw_if_index_set = 0;
11688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11690 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11691 sw_if_index_set = 1;
11692 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11693 sw_if_index_set = 1;
11694 else if (unformat (i, "enable"))
11696 else if (unformat (i, "disable"))
11700 clib_warning ("parse error '%U'", format_unformat_error, i);
11705 if (sw_if_index_set == 0)
11707 errmsg ("missing sw_if_index");
11711 M (L2_INTERFACE_EFP_FILTER, mp);
11713 mp->sw_if_index = ntohl (sw_if_index);
11714 mp->enable_disable = enable;
11721 #define foreach_vtr_op \
11722 _("disable", L2_VTR_DISABLED) \
11723 _("push-1", L2_VTR_PUSH_1) \
11724 _("push-2", L2_VTR_PUSH_2) \
11725 _("pop-1", L2_VTR_POP_1) \
11726 _("pop-2", L2_VTR_POP_2) \
11727 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11728 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11729 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11730 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11733 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11735 unformat_input_t *i = vam->input;
11736 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11738 u8 sw_if_index_set = 0;
11741 u32 push_dot1q = 1;
11746 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11748 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11749 sw_if_index_set = 1;
11750 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11751 sw_if_index_set = 1;
11752 else if (unformat (i, "vtr_op %d", &vtr_op))
11754 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11757 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11759 else if (unformat (i, "tag1 %d", &tag1))
11761 else if (unformat (i, "tag2 %d", &tag2))
11765 clib_warning ("parse error '%U'", format_unformat_error, i);
11770 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11772 errmsg ("missing vtr operation or sw_if_index");
11776 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11777 mp->sw_if_index = ntohl (sw_if_index);
11778 mp->vtr_op = ntohl (vtr_op);
11779 mp->push_dot1q = ntohl (push_dot1q);
11780 mp->tag1 = ntohl (tag1);
11781 mp->tag2 = ntohl (tag2);
11789 api_create_vhost_user_if (vat_main_t * vam)
11791 unformat_input_t *i = vam->input;
11792 vl_api_create_vhost_user_if_t *mp;
11795 u8 file_name_set = 0;
11796 u32 custom_dev_instance = ~0;
11798 u8 use_custom_mac = 0;
11802 /* Shut up coverity */
11803 memset (hwaddr, 0, sizeof (hwaddr));
11805 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11807 if (unformat (i, "socket %s", &file_name))
11811 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11813 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11814 use_custom_mac = 1;
11815 else if (unformat (i, "server"))
11817 else if (unformat (i, "tag %s", &tag))
11823 if (file_name_set == 0)
11825 errmsg ("missing socket file name");
11829 if (vec_len (file_name) > 255)
11831 errmsg ("socket file name too long");
11834 vec_add1 (file_name, 0);
11836 M (CREATE_VHOST_USER_IF, mp);
11838 mp->is_server = is_server;
11839 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11840 vec_free (file_name);
11841 if (custom_dev_instance != ~0)
11844 mp->custom_dev_instance = ntohl (custom_dev_instance);
11846 mp->use_custom_mac = use_custom_mac;
11847 clib_memcpy (mp->mac_address, hwaddr, 6);
11849 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11858 api_modify_vhost_user_if (vat_main_t * vam)
11860 unformat_input_t *i = vam->input;
11861 vl_api_modify_vhost_user_if_t *mp;
11864 u8 file_name_set = 0;
11865 u32 custom_dev_instance = ~0;
11866 u8 sw_if_index_set = 0;
11867 u32 sw_if_index = (u32) ~ 0;
11870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11872 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11873 sw_if_index_set = 1;
11874 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11875 sw_if_index_set = 1;
11876 else if (unformat (i, "socket %s", &file_name))
11880 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11882 else if (unformat (i, "server"))
11888 if (sw_if_index_set == 0)
11890 errmsg ("missing sw_if_index or interface name");
11894 if (file_name_set == 0)
11896 errmsg ("missing socket file name");
11900 if (vec_len (file_name) > 255)
11902 errmsg ("socket file name too long");
11905 vec_add1 (file_name, 0);
11907 M (MODIFY_VHOST_USER_IF, mp);
11909 mp->sw_if_index = ntohl (sw_if_index);
11910 mp->is_server = is_server;
11911 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11912 vec_free (file_name);
11913 if (custom_dev_instance != ~0)
11916 mp->custom_dev_instance = ntohl (custom_dev_instance);
11925 api_delete_vhost_user_if (vat_main_t * vam)
11927 unformat_input_t *i = vam->input;
11928 vl_api_delete_vhost_user_if_t *mp;
11929 u32 sw_if_index = ~0;
11930 u8 sw_if_index_set = 0;
11933 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11935 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11936 sw_if_index_set = 1;
11937 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11938 sw_if_index_set = 1;
11943 if (sw_if_index_set == 0)
11945 errmsg ("missing sw_if_index or interface name");
11950 M (DELETE_VHOST_USER_IF, mp);
11952 mp->sw_if_index = ntohl (sw_if_index);
11959 static void vl_api_sw_interface_vhost_user_details_t_handler
11960 (vl_api_sw_interface_vhost_user_details_t * mp)
11962 vat_main_t *vam = &vat_main;
11964 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11965 (char *) mp->interface_name,
11966 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11967 clib_net_to_host_u64 (mp->features), mp->is_server,
11968 ntohl (mp->num_regions), (char *) mp->sock_filename);
11969 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11972 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11973 (vl_api_sw_interface_vhost_user_details_t * mp)
11975 vat_main_t *vam = &vat_main;
11976 vat_json_node_t *node = NULL;
11978 if (VAT_JSON_ARRAY != vam->json_tree.type)
11980 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11981 vat_json_init_array (&vam->json_tree);
11983 node = vat_json_array_add (&vam->json_tree);
11985 vat_json_init_object (node);
11986 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11987 vat_json_object_add_string_copy (node, "interface_name",
11988 mp->interface_name);
11989 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11990 ntohl (mp->virtio_net_hdr_sz));
11991 vat_json_object_add_uint (node, "features",
11992 clib_net_to_host_u64 (mp->features));
11993 vat_json_object_add_uint (node, "is_server", mp->is_server);
11994 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11995 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11996 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12000 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12002 vl_api_sw_interface_vhost_user_dump_t *mp;
12003 vl_api_control_ping_t *mp_ping;
12006 "Interface name idx hdr_sz features server regions filename");
12008 /* Get list of vhost-user interfaces */
12009 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12012 /* Use a control ping for synchronization */
12013 M (CONTROL_PING, mp_ping);
12021 api_show_version (vat_main_t * vam)
12023 vl_api_show_version_t *mp;
12026 M (SHOW_VERSION, mp);
12035 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12037 unformat_input_t *line_input = vam->input;
12038 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12039 ip4_address_t local4, remote4;
12040 ip6_address_t local6, remote6;
12042 u8 ipv4_set = 0, ipv6_set = 0;
12046 u32 mcast_sw_if_index = ~0;
12047 u32 encap_vrf_id = 0;
12048 u32 decap_vrf_id = 0;
12054 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12055 memset (&local4, 0, sizeof local4);
12056 memset (&remote4, 0, sizeof remote4);
12057 memset (&local6, 0, sizeof local6);
12058 memset (&remote6, 0, sizeof remote6);
12060 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12062 if (unformat (line_input, "del"))
12064 else if (unformat (line_input, "local %U",
12065 unformat_ip4_address, &local4))
12070 else if (unformat (line_input, "remote %U",
12071 unformat_ip4_address, &remote4))
12076 else if (unformat (line_input, "local %U",
12077 unformat_ip6_address, &local6))
12082 else if (unformat (line_input, "remote %U",
12083 unformat_ip6_address, &remote6))
12088 else if (unformat (line_input, "group %U %U",
12089 unformat_ip4_address, &remote4,
12090 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12092 grp_set = remote_set = 1;
12095 else if (unformat (line_input, "group %U",
12096 unformat_ip4_address, &remote4))
12098 grp_set = remote_set = 1;
12101 else if (unformat (line_input, "group %U %U",
12102 unformat_ip6_address, &remote6,
12103 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12105 grp_set = remote_set = 1;
12108 else if (unformat (line_input, "group %U",
12109 unformat_ip6_address, &remote6))
12111 grp_set = remote_set = 1;
12115 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12117 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12119 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
12121 else if (unformat (line_input, "vni %d", &vni))
12123 else if (unformat (line_input, "next-ip4"))
12125 else if (unformat (line_input, "next-ip6"))
12127 else if (unformat (line_input, "next-ethernet"))
12129 else if (unformat (line_input, "next-nsh"))
12133 errmsg ("parse error '%U'", format_unformat_error, line_input);
12138 if (local_set == 0)
12140 errmsg ("tunnel local address not specified");
12143 if (remote_set == 0)
12145 errmsg ("tunnel remote address not specified");
12148 if (grp_set && mcast_sw_if_index == ~0)
12150 errmsg ("tunnel nonexistent multicast device");
12153 if (ipv4_set && ipv6_set)
12155 errmsg ("both IPv4 and IPv6 addresses specified");
12161 errmsg ("vni not specified");
12165 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
12170 clib_memcpy (&mp->local, &local6, sizeof (local6));
12171 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
12175 clib_memcpy (&mp->local, &local4, sizeof (local4));
12176 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
12179 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12180 mp->encap_vrf_id = ntohl (encap_vrf_id);
12181 mp->decap_vrf_id = ntohl (decap_vrf_id);
12182 mp->protocol = protocol;
12183 mp->vni = ntohl (vni);
12184 mp->is_add = is_add;
12185 mp->is_ipv6 = ipv6_set;
12192 static void vl_api_vxlan_gpe_tunnel_details_t_handler
12193 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12195 vat_main_t *vam = &vat_main;
12196 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
12197 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
12199 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
12200 ntohl (mp->sw_if_index),
12201 format_ip46_address, &local, IP46_TYPE_ANY,
12202 format_ip46_address, &remote, IP46_TYPE_ANY,
12203 ntohl (mp->vni), mp->protocol,
12204 ntohl (mp->mcast_sw_if_index),
12205 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
12209 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
12210 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12212 vat_main_t *vam = &vat_main;
12213 vat_json_node_t *node = NULL;
12214 struct in_addr ip4;
12215 struct in6_addr ip6;
12217 if (VAT_JSON_ARRAY != vam->json_tree.type)
12219 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12220 vat_json_init_array (&vam->json_tree);
12222 node = vat_json_array_add (&vam->json_tree);
12224 vat_json_init_object (node);
12225 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12228 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
12229 vat_json_object_add_ip6 (node, "local", ip6);
12230 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
12231 vat_json_object_add_ip6 (node, "remote", ip6);
12235 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
12236 vat_json_object_add_ip4 (node, "local", ip4);
12237 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
12238 vat_json_object_add_ip4 (node, "remote", ip4);
12240 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12241 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
12242 vat_json_object_add_uint (node, "mcast_sw_if_index",
12243 ntohl (mp->mcast_sw_if_index));
12244 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12245 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
12246 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12250 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
12252 unformat_input_t *i = vam->input;
12253 vl_api_vxlan_gpe_tunnel_dump_t *mp;
12254 vl_api_control_ping_t *mp_ping;
12256 u8 sw_if_index_set = 0;
12259 /* Parse args required to build the message */
12260 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12262 if (unformat (i, "sw_if_index %d", &sw_if_index))
12263 sw_if_index_set = 1;
12268 if (sw_if_index_set == 0)
12273 if (!vam->json_output)
12275 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
12276 "sw_if_index", "local", "remote", "vni",
12277 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
12280 /* Get list of vxlan-tunnel interfaces */
12281 M (VXLAN_GPE_TUNNEL_DUMP, mp);
12283 mp->sw_if_index = htonl (sw_if_index);
12287 /* Use a control ping for synchronization */
12288 M (CONTROL_PING, mp_ping);
12297 format_l2_fib_mac_address (u8 * s, va_list * args)
12299 u8 *a = va_arg (*args, u8 *);
12301 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
12302 a[2], a[3], a[4], a[5], a[6], a[7]);
12305 static void vl_api_l2_fib_table_details_t_handler
12306 (vl_api_l2_fib_table_details_t * mp)
12308 vat_main_t *vam = &vat_main;
12310 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
12312 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
12313 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
12317 static void vl_api_l2_fib_table_details_t_handler_json
12318 (vl_api_l2_fib_table_details_t * mp)
12320 vat_main_t *vam = &vat_main;
12321 vat_json_node_t *node = NULL;
12323 if (VAT_JSON_ARRAY != vam->json_tree.type)
12325 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12326 vat_json_init_array (&vam->json_tree);
12328 node = vat_json_array_add (&vam->json_tree);
12330 vat_json_init_object (node);
12331 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
12332 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
12333 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12334 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
12335 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
12336 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
12340 api_l2_fib_table_dump (vat_main_t * vam)
12342 unformat_input_t *i = vam->input;
12343 vl_api_l2_fib_table_dump_t *mp;
12344 vl_api_control_ping_t *mp_ping;
12349 /* Parse args required to build the message */
12350 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12352 if (unformat (i, "bd_id %d", &bd_id))
12358 if (bd_id_set == 0)
12360 errmsg ("missing bridge domain");
12364 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
12366 /* Get list of l2 fib entries */
12367 M (L2_FIB_TABLE_DUMP, mp);
12369 mp->bd_id = ntohl (bd_id);
12372 /* Use a control ping for synchronization */
12373 M (CONTROL_PING, mp_ping);
12382 api_interface_name_renumber (vat_main_t * vam)
12384 unformat_input_t *line_input = vam->input;
12385 vl_api_interface_name_renumber_t *mp;
12386 u32 sw_if_index = ~0;
12387 u32 new_show_dev_instance = ~0;
12390 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12392 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
12395 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12397 else if (unformat (line_input, "new_show_dev_instance %d",
12398 &new_show_dev_instance))
12404 if (sw_if_index == ~0)
12406 errmsg ("missing interface name or sw_if_index");
12410 if (new_show_dev_instance == ~0)
12412 errmsg ("missing new_show_dev_instance");
12416 M (INTERFACE_NAME_RENUMBER, mp);
12418 mp->sw_if_index = ntohl (sw_if_index);
12419 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
12427 api_want_ip4_arp_events (vat_main_t * vam)
12429 unformat_input_t *line_input = vam->input;
12430 vl_api_want_ip4_arp_events_t *mp;
12431 ip4_address_t address;
12432 int address_set = 0;
12433 u32 enable_disable = 1;
12436 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12438 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
12440 else if (unformat (line_input, "del"))
12441 enable_disable = 0;
12446 if (address_set == 0)
12448 errmsg ("missing addresses");
12452 M (WANT_IP4_ARP_EVENTS, mp);
12453 mp->enable_disable = enable_disable;
12454 mp->pid = htonl (getpid ());
12455 mp->address = address.as_u32;
12463 api_want_ip6_nd_events (vat_main_t * vam)
12465 unformat_input_t *line_input = vam->input;
12466 vl_api_want_ip6_nd_events_t *mp;
12467 ip6_address_t address;
12468 int address_set = 0;
12469 u32 enable_disable = 1;
12472 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12474 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
12476 else if (unformat (line_input, "del"))
12477 enable_disable = 0;
12482 if (address_set == 0)
12484 errmsg ("missing addresses");
12488 M (WANT_IP6_ND_EVENTS, mp);
12489 mp->enable_disable = enable_disable;
12490 mp->pid = htonl (getpid ());
12491 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
12499 api_input_acl_set_interface (vat_main_t * vam)
12501 unformat_input_t *i = vam->input;
12502 vl_api_input_acl_set_interface_t *mp;
12504 int sw_if_index_set;
12505 u32 ip4_table_index = ~0;
12506 u32 ip6_table_index = ~0;
12507 u32 l2_table_index = ~0;
12511 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12513 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12514 sw_if_index_set = 1;
12515 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12516 sw_if_index_set = 1;
12517 else if (unformat (i, "del"))
12519 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12521 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12523 else if (unformat (i, "l2-table %d", &l2_table_index))
12527 clib_warning ("parse error '%U'", format_unformat_error, i);
12532 if (sw_if_index_set == 0)
12534 errmsg ("missing interface name or sw_if_index");
12538 M (INPUT_ACL_SET_INTERFACE, mp);
12540 mp->sw_if_index = ntohl (sw_if_index);
12541 mp->ip4_table_index = ntohl (ip4_table_index);
12542 mp->ip6_table_index = ntohl (ip6_table_index);
12543 mp->l2_table_index = ntohl (l2_table_index);
12544 mp->is_add = is_add;
12552 api_ip_address_dump (vat_main_t * vam)
12554 unformat_input_t *i = vam->input;
12555 vl_api_ip_address_dump_t *mp;
12556 vl_api_control_ping_t *mp_ping;
12557 u32 sw_if_index = ~0;
12558 u8 sw_if_index_set = 0;
12563 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12565 if (unformat (i, "sw_if_index %d", &sw_if_index))
12566 sw_if_index_set = 1;
12568 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12569 sw_if_index_set = 1;
12570 else if (unformat (i, "ipv4"))
12572 else if (unformat (i, "ipv6"))
12578 if (ipv4_set && ipv6_set)
12580 errmsg ("ipv4 and ipv6 flags cannot be both set");
12584 if ((!ipv4_set) && (!ipv6_set))
12586 errmsg ("no ipv4 nor ipv6 flag set");
12590 if (sw_if_index_set == 0)
12592 errmsg ("missing interface name or sw_if_index");
12596 vam->current_sw_if_index = sw_if_index;
12597 vam->is_ipv6 = ipv6_set;
12599 M (IP_ADDRESS_DUMP, mp);
12600 mp->sw_if_index = ntohl (sw_if_index);
12601 mp->is_ipv6 = ipv6_set;
12604 /* Use a control ping for synchronization */
12605 M (CONTROL_PING, mp_ping);
12613 api_ip_dump (vat_main_t * vam)
12615 vl_api_ip_dump_t *mp;
12616 vl_api_control_ping_t *mp_ping;
12617 unformat_input_t *in = vam->input;
12624 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
12626 if (unformat (in, "ipv4"))
12628 else if (unformat (in, "ipv6"))
12634 if (ipv4_set && ipv6_set)
12636 errmsg ("ipv4 and ipv6 flags cannot be both set");
12640 if ((!ipv4_set) && (!ipv6_set))
12642 errmsg ("no ipv4 nor ipv6 flag set");
12646 is_ipv6 = ipv6_set;
12647 vam->is_ipv6 = is_ipv6;
12649 /* free old data */
12650 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12652 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12654 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12657 mp->is_ipv6 = ipv6_set;
12660 /* Use a control ping for synchronization */
12661 M (CONTROL_PING, mp_ping);
12669 api_ipsec_spd_add_del (vat_main_t * vam)
12671 unformat_input_t *i = vam->input;
12672 vl_api_ipsec_spd_add_del_t *mp;
12677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12679 if (unformat (i, "spd_id %d", &spd_id))
12681 else if (unformat (i, "del"))
12685 clib_warning ("parse error '%U'", format_unformat_error, i);
12691 errmsg ("spd_id must be set");
12695 M (IPSEC_SPD_ADD_DEL, mp);
12697 mp->spd_id = ntohl (spd_id);
12698 mp->is_add = is_add;
12706 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12708 unformat_input_t *i = vam->input;
12709 vl_api_ipsec_interface_add_del_spd_t *mp;
12711 u8 sw_if_index_set = 0;
12712 u32 spd_id = (u32) ~ 0;
12716 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12718 if (unformat (i, "del"))
12720 else if (unformat (i, "spd_id %d", &spd_id))
12723 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12724 sw_if_index_set = 1;
12725 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12726 sw_if_index_set = 1;
12729 clib_warning ("parse error '%U'", format_unformat_error, i);
12735 if (spd_id == (u32) ~ 0)
12737 errmsg ("spd_id must be set");
12741 if (sw_if_index_set == 0)
12743 errmsg ("missing interface name or sw_if_index");
12747 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12749 mp->spd_id = ntohl (spd_id);
12750 mp->sw_if_index = ntohl (sw_if_index);
12751 mp->is_add = is_add;
12759 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12761 unformat_input_t *i = vam->input;
12762 vl_api_ipsec_spd_add_del_entry_t *mp;
12763 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12764 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12766 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12767 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12768 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12769 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12772 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12773 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12774 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12775 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12776 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12777 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12779 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12781 if (unformat (i, "del"))
12783 if (unformat (i, "outbound"))
12785 if (unformat (i, "inbound"))
12787 else if (unformat (i, "spd_id %d", &spd_id))
12789 else if (unformat (i, "sa_id %d", &sa_id))
12791 else if (unformat (i, "priority %d", &priority))
12793 else if (unformat (i, "protocol %d", &protocol))
12795 else if (unformat (i, "lport_start %d", &lport_start))
12797 else if (unformat (i, "lport_stop %d", &lport_stop))
12799 else if (unformat (i, "rport_start %d", &rport_start))
12801 else if (unformat (i, "rport_stop %d", &rport_stop))
12805 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12811 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12818 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12824 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12831 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12837 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12844 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12850 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12856 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12858 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12860 clib_warning ("unsupported action: 'resolve'");
12866 clib_warning ("parse error '%U'", format_unformat_error, i);
12872 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12874 mp->spd_id = ntohl (spd_id);
12875 mp->priority = ntohl (priority);
12876 mp->is_outbound = is_outbound;
12878 mp->is_ipv6 = is_ipv6;
12879 if (is_ipv6 || is_ip_any)
12881 clib_memcpy (mp->remote_address_start, &raddr6_start,
12882 sizeof (ip6_address_t));
12883 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12884 sizeof (ip6_address_t));
12885 clib_memcpy (mp->local_address_start, &laddr6_start,
12886 sizeof (ip6_address_t));
12887 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12888 sizeof (ip6_address_t));
12892 clib_memcpy (mp->remote_address_start, &raddr4_start,
12893 sizeof (ip4_address_t));
12894 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12895 sizeof (ip4_address_t));
12896 clib_memcpy (mp->local_address_start, &laddr4_start,
12897 sizeof (ip4_address_t));
12898 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12899 sizeof (ip4_address_t));
12901 mp->protocol = (u8) protocol;
12902 mp->local_port_start = ntohs ((u16) lport_start);
12903 mp->local_port_stop = ntohs ((u16) lport_stop);
12904 mp->remote_port_start = ntohs ((u16) rport_start);
12905 mp->remote_port_stop = ntohs ((u16) rport_stop);
12906 mp->policy = (u8) policy;
12907 mp->sa_id = ntohl (sa_id);
12908 mp->is_add = is_add;
12909 mp->is_ip_any = is_ip_any;
12916 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12918 unformat_input_t *i = vam->input;
12919 vl_api_ipsec_sad_add_del_entry_t *mp;
12920 u32 sad_id = 0, spi = 0;
12921 u8 *ck = 0, *ik = 0;
12924 u8 protocol = IPSEC_PROTOCOL_AH;
12925 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12926 u32 crypto_alg = 0, integ_alg = 0;
12927 ip4_address_t tun_src4;
12928 ip4_address_t tun_dst4;
12929 ip6_address_t tun_src6;
12930 ip6_address_t tun_dst6;
12933 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12935 if (unformat (i, "del"))
12937 else if (unformat (i, "sad_id %d", &sad_id))
12939 else if (unformat (i, "spi %d", &spi))
12941 else if (unformat (i, "esp"))
12942 protocol = IPSEC_PROTOCOL_ESP;
12943 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12946 is_tunnel_ipv6 = 0;
12948 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12951 is_tunnel_ipv6 = 0;
12953 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12956 is_tunnel_ipv6 = 1;
12958 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12961 is_tunnel_ipv6 = 1;
12965 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12967 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12968 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12970 clib_warning ("unsupported crypto-alg: '%U'",
12971 format_ipsec_crypto_alg, crypto_alg);
12975 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12979 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12981 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12982 integ_alg >= IPSEC_INTEG_N_ALG)
12984 clib_warning ("unsupported integ-alg: '%U'",
12985 format_ipsec_integ_alg, integ_alg);
12989 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12993 clib_warning ("parse error '%U'", format_unformat_error, i);
12999 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
13001 mp->sad_id = ntohl (sad_id);
13002 mp->is_add = is_add;
13003 mp->protocol = protocol;
13004 mp->spi = ntohl (spi);
13005 mp->is_tunnel = is_tunnel;
13006 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
13007 mp->crypto_algorithm = crypto_alg;
13008 mp->integrity_algorithm = integ_alg;
13009 mp->crypto_key_length = vec_len (ck);
13010 mp->integrity_key_length = vec_len (ik);
13012 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13013 mp->crypto_key_length = sizeof (mp->crypto_key);
13015 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13016 mp->integrity_key_length = sizeof (mp->integrity_key);
13019 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13021 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13025 if (is_tunnel_ipv6)
13027 clib_memcpy (mp->tunnel_src_address, &tun_src6,
13028 sizeof (ip6_address_t));
13029 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
13030 sizeof (ip6_address_t));
13034 clib_memcpy (mp->tunnel_src_address, &tun_src4,
13035 sizeof (ip4_address_t));
13036 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
13037 sizeof (ip4_address_t));
13047 api_ipsec_sa_set_key (vat_main_t * vam)
13049 unformat_input_t *i = vam->input;
13050 vl_api_ipsec_sa_set_key_t *mp;
13052 u8 *ck = 0, *ik = 0;
13055 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13057 if (unformat (i, "sa_id %d", &sa_id))
13059 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13061 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13065 clib_warning ("parse error '%U'", format_unformat_error, i);
13070 M (IPSEC_SA_SET_KEY, mp);
13072 mp->sa_id = ntohl (sa_id);
13073 mp->crypto_key_length = vec_len (ck);
13074 mp->integrity_key_length = vec_len (ik);
13076 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13077 mp->crypto_key_length = sizeof (mp->crypto_key);
13079 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13080 mp->integrity_key_length = sizeof (mp->integrity_key);
13083 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13085 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13093 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
13095 unformat_input_t *i = vam->input;
13096 vl_api_ipsec_tunnel_if_add_del_t *mp;
13097 u32 local_spi = 0, remote_spi = 0;
13098 u32 crypto_alg = 0, integ_alg = 0;
13099 u8 *lck = NULL, *rck = NULL;
13100 u8 *lik = NULL, *rik = NULL;
13101 ip4_address_t local_ip = { {0} };
13102 ip4_address_t remote_ip = { {0} };
13105 u8 anti_replay = 0;
13108 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13110 if (unformat (i, "del"))
13112 else if (unformat (i, "esn"))
13114 else if (unformat (i, "anti_replay"))
13116 else if (unformat (i, "local_spi %d", &local_spi))
13118 else if (unformat (i, "remote_spi %d", &remote_spi))
13120 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
13122 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
13124 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
13127 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
13129 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
13131 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
13135 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13137 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13138 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13140 errmsg ("unsupported crypto-alg: '%U'\n",
13141 format_ipsec_crypto_alg, crypto_alg);
13147 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13149 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13150 integ_alg >= IPSEC_INTEG_N_ALG)
13152 errmsg ("unsupported integ-alg: '%U'\n",
13153 format_ipsec_integ_alg, integ_alg);
13159 errmsg ("parse error '%U'\n", format_unformat_error, i);
13164 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
13166 mp->is_add = is_add;
13168 mp->anti_replay = anti_replay;
13170 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
13171 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
13173 mp->local_spi = htonl (local_spi);
13174 mp->remote_spi = htonl (remote_spi);
13175 mp->crypto_alg = (u8) crypto_alg;
13177 mp->local_crypto_key_len = 0;
13180 mp->local_crypto_key_len = vec_len (lck);
13181 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
13182 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
13183 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
13186 mp->remote_crypto_key_len = 0;
13189 mp->remote_crypto_key_len = vec_len (rck);
13190 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
13191 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
13192 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
13195 mp->integ_alg = (u8) integ_alg;
13197 mp->local_integ_key_len = 0;
13200 mp->local_integ_key_len = vec_len (lik);
13201 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
13202 mp->local_integ_key_len = sizeof (mp->local_integ_key);
13203 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
13206 mp->remote_integ_key_len = 0;
13209 mp->remote_integ_key_len = vec_len (rik);
13210 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
13211 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
13212 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
13221 api_ikev2_profile_add_del (vat_main_t * vam)
13223 unformat_input_t *i = vam->input;
13224 vl_api_ikev2_profile_add_del_t *mp;
13229 const char *valid_chars = "a-zA-Z0-9_";
13231 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13233 if (unformat (i, "del"))
13235 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13236 vec_add1 (name, 0);
13239 errmsg ("parse error '%U'", format_unformat_error, i);
13244 if (!vec_len (name))
13246 errmsg ("profile name must be specified");
13250 if (vec_len (name) > 64)
13252 errmsg ("profile name too long");
13256 M (IKEV2_PROFILE_ADD_DEL, mp);
13258 clib_memcpy (mp->name, name, vec_len (name));
13259 mp->is_add = is_add;
13268 api_ikev2_profile_set_auth (vat_main_t * vam)
13270 unformat_input_t *i = vam->input;
13271 vl_api_ikev2_profile_set_auth_t *mp;
13274 u32 auth_method = 0;
13278 const char *valid_chars = "a-zA-Z0-9_";
13280 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13282 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13283 vec_add1 (name, 0);
13284 else if (unformat (i, "auth_method %U",
13285 unformat_ikev2_auth_method, &auth_method))
13287 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
13289 else if (unformat (i, "auth_data %v", &data))
13293 errmsg ("parse error '%U'", format_unformat_error, i);
13298 if (!vec_len (name))
13300 errmsg ("profile name must be specified");
13304 if (vec_len (name) > 64)
13306 errmsg ("profile name too long");
13310 if (!vec_len (data))
13312 errmsg ("auth_data must be specified");
13318 errmsg ("auth_method must be specified");
13322 M (IKEV2_PROFILE_SET_AUTH, mp);
13324 mp->is_hex = is_hex;
13325 mp->auth_method = (u8) auth_method;
13326 mp->data_len = vec_len (data);
13327 clib_memcpy (mp->name, name, vec_len (name));
13328 clib_memcpy (mp->data, data, vec_len (data));
13338 api_ikev2_profile_set_id (vat_main_t * vam)
13340 unformat_input_t *i = vam->input;
13341 vl_api_ikev2_profile_set_id_t *mp;
13349 const char *valid_chars = "a-zA-Z0-9_";
13351 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13353 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13354 vec_add1 (name, 0);
13355 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
13357 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
13359 data = vec_new (u8, 4);
13360 clib_memcpy (data, ip4.as_u8, 4);
13362 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
13364 else if (unformat (i, "id_data %v", &data))
13366 else if (unformat (i, "local"))
13368 else if (unformat (i, "remote"))
13372 errmsg ("parse error '%U'", format_unformat_error, i);
13377 if (!vec_len (name))
13379 errmsg ("profile name must be specified");
13383 if (vec_len (name) > 64)
13385 errmsg ("profile name too long");
13389 if (!vec_len (data))
13391 errmsg ("id_data must be specified");
13397 errmsg ("id_type must be specified");
13401 M (IKEV2_PROFILE_SET_ID, mp);
13403 mp->is_local = is_local;
13404 mp->id_type = (u8) id_type;
13405 mp->data_len = vec_len (data);
13406 clib_memcpy (mp->name, name, vec_len (name));
13407 clib_memcpy (mp->data, data, vec_len (data));
13417 api_ikev2_profile_set_ts (vat_main_t * vam)
13419 unformat_input_t *i = vam->input;
13420 vl_api_ikev2_profile_set_ts_t *mp;
13423 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
13424 ip4_address_t start_addr, end_addr;
13426 const char *valid_chars = "a-zA-Z0-9_";
13429 start_addr.as_u32 = 0;
13430 end_addr.as_u32 = (u32) ~ 0;
13432 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13434 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13435 vec_add1 (name, 0);
13436 else if (unformat (i, "protocol %d", &proto))
13438 else if (unformat (i, "start_port %d", &start_port))
13440 else if (unformat (i, "end_port %d", &end_port))
13443 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
13445 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
13447 else if (unformat (i, "local"))
13449 else if (unformat (i, "remote"))
13453 errmsg ("parse error '%U'", format_unformat_error, i);
13458 if (!vec_len (name))
13460 errmsg ("profile name must be specified");
13464 if (vec_len (name) > 64)
13466 errmsg ("profile name too long");
13470 M (IKEV2_PROFILE_SET_TS, mp);
13472 mp->is_local = is_local;
13473 mp->proto = (u8) proto;
13474 mp->start_port = (u16) start_port;
13475 mp->end_port = (u16) end_port;
13476 mp->start_addr = start_addr.as_u32;
13477 mp->end_addr = end_addr.as_u32;
13478 clib_memcpy (mp->name, name, vec_len (name));
13487 api_ikev2_set_local_key (vat_main_t * vam)
13489 unformat_input_t *i = vam->input;
13490 vl_api_ikev2_set_local_key_t *mp;
13494 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13496 if (unformat (i, "file %v", &file))
13497 vec_add1 (file, 0);
13500 errmsg ("parse error '%U'", format_unformat_error, i);
13505 if (!vec_len (file))
13507 errmsg ("RSA key file must be specified");
13511 if (vec_len (file) > 256)
13513 errmsg ("file name too long");
13517 M (IKEV2_SET_LOCAL_KEY, mp);
13519 clib_memcpy (mp->key_file, file, vec_len (file));
13528 api_ikev2_set_responder (vat_main_t * vam)
13530 unformat_input_t *i = vam->input;
13531 vl_api_ikev2_set_responder_t *mp;
13534 u32 sw_if_index = ~0;
13535 ip4_address_t address;
13537 const char *valid_chars = "a-zA-Z0-9_";
13539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13542 (i, "%U interface %d address %U", unformat_token, valid_chars,
13543 &name, &sw_if_index, unformat_ip4_address, &address))
13544 vec_add1 (name, 0);
13547 errmsg ("parse error '%U'", format_unformat_error, i);
13552 if (!vec_len (name))
13554 errmsg ("profile name must be specified");
13558 if (vec_len (name) > 64)
13560 errmsg ("profile name too long");
13564 M (IKEV2_SET_RESPONDER, mp);
13566 clib_memcpy (mp->name, name, vec_len (name));
13569 mp->sw_if_index = sw_if_index;
13570 clib_memcpy (mp->address, &address, sizeof (address));
13578 api_ikev2_set_ike_transforms (vat_main_t * vam)
13580 unformat_input_t *i = vam->input;
13581 vl_api_ikev2_set_ike_transforms_t *mp;
13584 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13586 const char *valid_chars = "a-zA-Z0-9_";
13588 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13590 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13591 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13592 vec_add1 (name, 0);
13595 errmsg ("parse error '%U'", format_unformat_error, i);
13600 if (!vec_len (name))
13602 errmsg ("profile name must be specified");
13606 if (vec_len (name) > 64)
13608 errmsg ("profile name too long");
13612 M (IKEV2_SET_IKE_TRANSFORMS, mp);
13614 clib_memcpy (mp->name, name, vec_len (name));
13616 mp->crypto_alg = crypto_alg;
13617 mp->crypto_key_size = crypto_key_size;
13618 mp->integ_alg = integ_alg;
13619 mp->dh_group = dh_group;
13628 api_ikev2_set_esp_transforms (vat_main_t * vam)
13630 unformat_input_t *i = vam->input;
13631 vl_api_ikev2_set_esp_transforms_t *mp;
13634 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13636 const char *valid_chars = "a-zA-Z0-9_";
13638 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13640 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13641 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13642 vec_add1 (name, 0);
13645 errmsg ("parse error '%U'", format_unformat_error, i);
13650 if (!vec_len (name))
13652 errmsg ("profile name must be specified");
13656 if (vec_len (name) > 64)
13658 errmsg ("profile name too long");
13662 M (IKEV2_SET_ESP_TRANSFORMS, mp);
13664 clib_memcpy (mp->name, name, vec_len (name));
13666 mp->crypto_alg = crypto_alg;
13667 mp->crypto_key_size = crypto_key_size;
13668 mp->integ_alg = integ_alg;
13669 mp->dh_group = dh_group;
13677 api_ikev2_set_sa_lifetime (vat_main_t * vam)
13679 unformat_input_t *i = vam->input;
13680 vl_api_ikev2_set_sa_lifetime_t *mp;
13683 u64 lifetime, lifetime_maxdata;
13684 u32 lifetime_jitter, handover;
13686 const char *valid_chars = "a-zA-Z0-9_";
13688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13690 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
13691 &lifetime, &lifetime_jitter, &handover,
13692 &lifetime_maxdata))
13693 vec_add1 (name, 0);
13696 errmsg ("parse error '%U'", format_unformat_error, i);
13701 if (!vec_len (name))
13703 errmsg ("profile name must be specified");
13707 if (vec_len (name) > 64)
13709 errmsg ("profile name too long");
13713 M (IKEV2_SET_SA_LIFETIME, mp);
13715 clib_memcpy (mp->name, name, vec_len (name));
13717 mp->lifetime = lifetime;
13718 mp->lifetime_jitter = lifetime_jitter;
13719 mp->handover = handover;
13720 mp->lifetime_maxdata = lifetime_maxdata;
13728 api_ikev2_initiate_sa_init (vat_main_t * vam)
13730 unformat_input_t *i = vam->input;
13731 vl_api_ikev2_initiate_sa_init_t *mp;
13735 const char *valid_chars = "a-zA-Z0-9_";
13737 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13739 if (unformat (i, "%U", unformat_token, valid_chars, &name))
13740 vec_add1 (name, 0);
13743 errmsg ("parse error '%U'", format_unformat_error, i);
13748 if (!vec_len (name))
13750 errmsg ("profile name must be specified");
13754 if (vec_len (name) > 64)
13756 errmsg ("profile name too long");
13760 M (IKEV2_INITIATE_SA_INIT, mp);
13762 clib_memcpy (mp->name, name, vec_len (name));
13771 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
13773 unformat_input_t *i = vam->input;
13774 vl_api_ikev2_initiate_del_ike_sa_t *mp;
13779 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13781 if (unformat (i, "%lx", &ispi))
13785 errmsg ("parse error '%U'", format_unformat_error, i);
13790 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
13800 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13802 unformat_input_t *i = vam->input;
13803 vl_api_ikev2_initiate_del_child_sa_t *mp;
13808 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13810 if (unformat (i, "%x", &ispi))
13814 errmsg ("parse error '%U'", format_unformat_error, i);
13819 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13829 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13831 unformat_input_t *i = vam->input;
13832 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13837 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13839 if (unformat (i, "%x", &ispi))
13843 errmsg ("parse error '%U'", format_unformat_error, i);
13848 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
13861 api_map_add_domain (vat_main_t * vam)
13863 unformat_input_t *i = vam->input;
13864 vl_api_map_add_domain_t *mp;
13866 ip4_address_t ip4_prefix;
13867 ip6_address_t ip6_prefix;
13868 ip6_address_t ip6_src;
13869 u32 num_m_args = 0;
13870 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
13871 0, psid_length = 0;
13872 u8 is_translation = 0;
13874 u32 ip6_src_len = 128;
13877 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13879 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
13880 &ip4_prefix, &ip4_prefix_len))
13882 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
13883 &ip6_prefix, &ip6_prefix_len))
13887 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
13890 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
13892 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
13894 else if (unformat (i, "psid-offset %d", &psid_offset))
13896 else if (unformat (i, "psid-len %d", &psid_length))
13898 else if (unformat (i, "mtu %d", &mtu))
13900 else if (unformat (i, "map-t"))
13901 is_translation = 1;
13904 clib_warning ("parse error '%U'", format_unformat_error, i);
13909 if (num_m_args < 3)
13911 errmsg ("mandatory argument(s) missing");
13915 /* Construct the API message */
13916 M (MAP_ADD_DOMAIN, mp);
13918 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
13919 mp->ip4_prefix_len = ip4_prefix_len;
13921 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
13922 mp->ip6_prefix_len = ip6_prefix_len;
13924 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
13925 mp->ip6_src_prefix_len = ip6_src_len;
13927 mp->ea_bits_len = ea_bits_len;
13928 mp->psid_offset = psid_offset;
13929 mp->psid_length = psid_length;
13930 mp->is_translation = is_translation;
13931 mp->mtu = htons (mtu);
13936 /* Wait for a reply, return good/bad news */
13942 api_map_del_domain (vat_main_t * vam)
13944 unformat_input_t *i = vam->input;
13945 vl_api_map_del_domain_t *mp;
13947 u32 num_m_args = 0;
13951 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13953 if (unformat (i, "index %d", &index))
13957 clib_warning ("parse error '%U'", format_unformat_error, i);
13962 if (num_m_args != 1)
13964 errmsg ("mandatory argument(s) missing");
13968 /* Construct the API message */
13969 M (MAP_DEL_DOMAIN, mp);
13971 mp->index = ntohl (index);
13976 /* Wait for a reply, return good/bad news */
13982 api_map_add_del_rule (vat_main_t * vam)
13984 unformat_input_t *i = vam->input;
13985 vl_api_map_add_del_rule_t *mp;
13987 ip6_address_t ip6_dst;
13988 u32 num_m_args = 0, index, psid = 0;
13991 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13993 if (unformat (i, "index %d", &index))
13995 else if (unformat (i, "psid %d", &psid))
13997 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13999 else if (unformat (i, "del"))
14005 clib_warning ("parse error '%U'", format_unformat_error, i);
14010 /* Construct the API message */
14011 M (MAP_ADD_DEL_RULE, mp);
14013 mp->index = ntohl (index);
14014 mp->is_add = is_add;
14015 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
14016 mp->psid = ntohs (psid);
14021 /* Wait for a reply, return good/bad news */
14027 api_map_domain_dump (vat_main_t * vam)
14029 vl_api_map_domain_dump_t *mp;
14030 vl_api_control_ping_t *mp_ping;
14033 /* Construct the API message */
14034 M (MAP_DOMAIN_DUMP, mp);
14039 /* Use a control ping for synchronization */
14040 M (CONTROL_PING, mp_ping);
14048 api_map_rule_dump (vat_main_t * vam)
14050 unformat_input_t *i = vam->input;
14051 vl_api_map_rule_dump_t *mp;
14052 vl_api_control_ping_t *mp_ping;
14053 u32 domain_index = ~0;
14056 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14058 if (unformat (i, "index %u", &domain_index))
14064 if (domain_index == ~0)
14066 clib_warning ("parse error: domain index expected");
14070 /* Construct the API message */
14071 M (MAP_RULE_DUMP, mp);
14073 mp->domain_index = htonl (domain_index);
14078 /* Use a control ping for synchronization */
14079 M (CONTROL_PING, mp_ping);
14086 static void vl_api_map_add_domain_reply_t_handler
14087 (vl_api_map_add_domain_reply_t * mp)
14089 vat_main_t *vam = &vat_main;
14090 i32 retval = ntohl (mp->retval);
14092 if (vam->async_mode)
14094 vam->async_errors += (retval < 0);
14098 vam->retval = retval;
14099 vam->result_ready = 1;
14103 static void vl_api_map_add_domain_reply_t_handler_json
14104 (vl_api_map_add_domain_reply_t * mp)
14106 vat_main_t *vam = &vat_main;
14107 vat_json_node_t node;
14109 vat_json_init_object (&node);
14110 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
14111 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
14113 vat_json_print (vam->ofp, &node);
14114 vat_json_free (&node);
14116 vam->retval = ntohl (mp->retval);
14117 vam->result_ready = 1;
14121 api_get_first_msg_id (vat_main_t * vam)
14123 vl_api_get_first_msg_id_t *mp;
14124 unformat_input_t *i = vam->input;
14129 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14131 if (unformat (i, "client %s", &name))
14139 errmsg ("missing client name");
14142 vec_add1 (name, 0);
14144 if (vec_len (name) > 63)
14146 errmsg ("client name too long");
14150 M (GET_FIRST_MSG_ID, mp);
14151 clib_memcpy (mp->name, name, vec_len (name));
14158 api_cop_interface_enable_disable (vat_main_t * vam)
14160 unformat_input_t *line_input = vam->input;
14161 vl_api_cop_interface_enable_disable_t *mp;
14162 u32 sw_if_index = ~0;
14163 u8 enable_disable = 1;
14166 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14168 if (unformat (line_input, "disable"))
14169 enable_disable = 0;
14170 if (unformat (line_input, "enable"))
14171 enable_disable = 1;
14172 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14173 vam, &sw_if_index))
14175 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14181 if (sw_if_index == ~0)
14183 errmsg ("missing interface name or sw_if_index");
14187 /* Construct the API message */
14188 M (COP_INTERFACE_ENABLE_DISABLE, mp);
14189 mp->sw_if_index = ntohl (sw_if_index);
14190 mp->enable_disable = enable_disable;
14194 /* Wait for the reply */
14200 api_cop_whitelist_enable_disable (vat_main_t * vam)
14202 unformat_input_t *line_input = vam->input;
14203 vl_api_cop_whitelist_enable_disable_t *mp;
14204 u32 sw_if_index = ~0;
14205 u8 ip4 = 0, ip6 = 0, default_cop = 0;
14209 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14211 if (unformat (line_input, "ip4"))
14213 else if (unformat (line_input, "ip6"))
14215 else if (unformat (line_input, "default"))
14217 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14218 vam, &sw_if_index))
14220 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14222 else if (unformat (line_input, "fib-id %d", &fib_id))
14228 if (sw_if_index == ~0)
14230 errmsg ("missing interface name or sw_if_index");
14234 /* Construct the API message */
14235 M (COP_WHITELIST_ENABLE_DISABLE, mp);
14236 mp->sw_if_index = ntohl (sw_if_index);
14237 mp->fib_id = ntohl (fib_id);
14240 mp->default_cop = default_cop;
14244 /* Wait for the reply */
14250 api_get_node_graph (vat_main_t * vam)
14252 vl_api_get_node_graph_t *mp;
14255 M (GET_NODE_GRAPH, mp);
14259 /* Wait for the reply */
14265 /** Used for parsing LISP eids */
14266 typedef CLIB_PACKED(struct{
14267 u8 addr[16]; /**< eid address */
14268 u32 len; /**< prefix length if IP */
14269 u8 type; /**< type of eid */
14274 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14276 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14278 memset (a, 0, sizeof (a[0]));
14280 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
14282 a->type = 0; /* ipv4 type */
14284 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
14286 a->type = 1; /* ipv6 type */
14288 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
14290 a->type = 2; /* mac type */
14292 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
14294 a->type = 3; /* NSH type */
14295 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
14296 nsh->spi = clib_host_to_net_u32 (nsh->spi);
14303 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
14312 lisp_eid_size_vat (u8 type)
14329 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
14331 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
14335 api_one_add_del_locator_set (vat_main_t * vam)
14337 unformat_input_t *input = vam->input;
14338 vl_api_one_add_del_locator_set_t *mp;
14340 u8 *locator_set_name = NULL;
14341 u8 locator_set_name_set = 0;
14342 vl_api_local_locator_t locator, *locators = 0;
14343 u32 sw_if_index, priority, weight;
14347 /* Parse args required to build the message */
14348 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14350 if (unformat (input, "del"))
14354 else if (unformat (input, "locator-set %s", &locator_set_name))
14356 locator_set_name_set = 1;
14358 else if (unformat (input, "sw_if_index %u p %u w %u",
14359 &sw_if_index, &priority, &weight))
14361 locator.sw_if_index = htonl (sw_if_index);
14362 locator.priority = priority;
14363 locator.weight = weight;
14364 vec_add1 (locators, locator);
14368 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14369 &sw_if_index, &priority, &weight))
14371 locator.sw_if_index = htonl (sw_if_index);
14372 locator.priority = priority;
14373 locator.weight = weight;
14374 vec_add1 (locators, locator);
14380 if (locator_set_name_set == 0)
14382 errmsg ("missing locator-set name");
14383 vec_free (locators);
14387 if (vec_len (locator_set_name) > 64)
14389 errmsg ("locator-set name too long");
14390 vec_free (locator_set_name);
14391 vec_free (locators);
14394 vec_add1 (locator_set_name, 0);
14396 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14398 /* Construct the API message */
14399 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14401 mp->is_add = is_add;
14402 clib_memcpy (mp->locator_set_name, locator_set_name,
14403 vec_len (locator_set_name));
14404 vec_free (locator_set_name);
14406 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14408 clib_memcpy (mp->locators, locators, data_len);
14409 vec_free (locators);
14414 /* Wait for a reply... */
14419 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14422 api_one_add_del_locator (vat_main_t * vam)
14424 unformat_input_t *input = vam->input;
14425 vl_api_one_add_del_locator_t *mp;
14426 u32 tmp_if_index = ~0;
14427 u32 sw_if_index = ~0;
14428 u8 sw_if_index_set = 0;
14429 u8 sw_if_index_if_name_set = 0;
14431 u8 priority_set = 0;
14435 u8 *locator_set_name = NULL;
14436 u8 locator_set_name_set = 0;
14439 /* Parse args required to build the message */
14440 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14442 if (unformat (input, "del"))
14446 else if (unformat (input, "locator-set %s", &locator_set_name))
14448 locator_set_name_set = 1;
14450 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14453 sw_if_index_if_name_set = 1;
14454 sw_if_index = tmp_if_index;
14456 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14458 sw_if_index_set = 1;
14459 sw_if_index = tmp_if_index;
14461 else if (unformat (input, "p %d", &priority))
14465 else if (unformat (input, "w %d", &weight))
14473 if (locator_set_name_set == 0)
14475 errmsg ("missing locator-set name");
14479 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14481 errmsg ("missing sw_if_index");
14482 vec_free (locator_set_name);
14486 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14488 errmsg ("cannot use both params interface name and sw_if_index");
14489 vec_free (locator_set_name);
14493 if (priority_set == 0)
14495 errmsg ("missing locator-set priority");
14496 vec_free (locator_set_name);
14500 if (weight_set == 0)
14502 errmsg ("missing locator-set weight");
14503 vec_free (locator_set_name);
14507 if (vec_len (locator_set_name) > 64)
14509 errmsg ("locator-set name too long");
14510 vec_free (locator_set_name);
14513 vec_add1 (locator_set_name, 0);
14515 /* Construct the API message */
14516 M (ONE_ADD_DEL_LOCATOR, mp);
14518 mp->is_add = is_add;
14519 mp->sw_if_index = ntohl (sw_if_index);
14520 mp->priority = priority;
14521 mp->weight = weight;
14522 clib_memcpy (mp->locator_set_name, locator_set_name,
14523 vec_len (locator_set_name));
14524 vec_free (locator_set_name);
14529 /* Wait for a reply... */
14534 #define api_lisp_add_del_locator api_one_add_del_locator
14537 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14539 u32 *key_id = va_arg (*args, u32 *);
14542 if (unformat (input, "%s", &s))
14544 if (!strcmp ((char *) s, "sha1"))
14545 key_id[0] = HMAC_SHA_1_96;
14546 else if (!strcmp ((char *) s, "sha256"))
14547 key_id[0] = HMAC_SHA_256_128;
14550 clib_warning ("invalid key_id: '%s'", s);
14551 key_id[0] = HMAC_NO_KEY;
14562 api_one_add_del_local_eid (vat_main_t * vam)
14564 unformat_input_t *input = vam->input;
14565 vl_api_one_add_del_local_eid_t *mp;
14568 lisp_eid_vat_t _eid, *eid = &_eid;
14569 u8 *locator_set_name = 0;
14570 u8 locator_set_name_set = 0;
14576 /* Parse args required to build the message */
14577 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14579 if (unformat (input, "del"))
14583 else if (unformat (input, "vni %d", &vni))
14587 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14591 else if (unformat (input, "locator-set %s", &locator_set_name))
14593 locator_set_name_set = 1;
14595 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14597 else if (unformat (input, "secret-key %_%v%_", &key))
14603 if (locator_set_name_set == 0)
14605 errmsg ("missing locator-set name");
14611 errmsg ("EID address not set!");
14612 vec_free (locator_set_name);
14616 if (key && (0 == key_id))
14618 errmsg ("invalid key_id!");
14622 if (vec_len (key) > 64)
14624 errmsg ("key too long");
14629 if (vec_len (locator_set_name) > 64)
14631 errmsg ("locator-set name too long");
14632 vec_free (locator_set_name);
14635 vec_add1 (locator_set_name, 0);
14637 /* Construct the API message */
14638 M (ONE_ADD_DEL_LOCAL_EID, mp);
14640 mp->is_add = is_add;
14641 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14642 mp->eid_type = eid->type;
14643 mp->prefix_len = eid->len;
14644 mp->vni = clib_host_to_net_u32 (vni);
14645 mp->key_id = clib_host_to_net_u16 (key_id);
14646 clib_memcpy (mp->locator_set_name, locator_set_name,
14647 vec_len (locator_set_name));
14648 clib_memcpy (mp->key, key, vec_len (key));
14650 vec_free (locator_set_name);
14656 /* Wait for a reply... */
14661 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14664 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14666 u32 dp_table = 0, vni = 0;;
14667 unformat_input_t *input = vam->input;
14668 vl_api_gpe_add_del_fwd_entry_t *mp;
14670 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14671 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14672 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14673 u32 action = ~0, w;
14674 ip4_address_t rmt_rloc4, lcl_rloc4;
14675 ip6_address_t rmt_rloc6, lcl_rloc6;
14676 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14679 memset (&rloc, 0, sizeof (rloc));
14681 /* Parse args required to build the message */
14682 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14684 if (unformat (input, "del"))
14686 else if (unformat (input, "add"))
14688 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14692 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14696 else if (unformat (input, "vrf %d", &dp_table))
14698 else if (unformat (input, "bd %d", &dp_table))
14700 else if (unformat (input, "vni %d", &vni))
14702 else if (unformat (input, "w %d", &w))
14706 errmsg ("No RLOC configured for setting priority/weight!");
14709 curr_rloc->weight = w;
14711 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14712 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14716 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
14718 vec_add1 (lcl_locs, rloc);
14720 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
14721 vec_add1 (rmt_locs, rloc);
14722 /* weight saved in rmt loc */
14723 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14725 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14726 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14729 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
14731 vec_add1 (lcl_locs, rloc);
14733 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
14734 vec_add1 (rmt_locs, rloc);
14735 /* weight saved in rmt loc */
14736 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14738 else if (unformat (input, "action %d", &action))
14744 clib_warning ("parse error '%U'", format_unformat_error, input);
14751 errmsg ("remote eid addresses not set");
14755 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14757 errmsg ("eid types don't match");
14761 if (0 == rmt_locs && (u32) ~ 0 == action)
14763 errmsg ("action not set for negative mapping");
14767 /* Construct the API message */
14768 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14769 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14771 mp->is_add = is_add;
14772 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14773 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14774 mp->eid_type = rmt_eid->type;
14775 mp->dp_table = clib_host_to_net_u32 (dp_table);
14776 mp->vni = clib_host_to_net_u32 (vni);
14777 mp->rmt_len = rmt_eid->len;
14778 mp->lcl_len = lcl_eid->len;
14779 mp->action = action;
14781 if (0 != rmt_locs && 0 != lcl_locs)
14783 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14784 clib_memcpy (mp->locs, lcl_locs,
14785 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14787 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14788 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14789 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14791 vec_free (lcl_locs);
14792 vec_free (rmt_locs);
14797 /* Wait for a reply... */
14803 api_one_add_del_map_server (vat_main_t * vam)
14805 unformat_input_t *input = vam->input;
14806 vl_api_one_add_del_map_server_t *mp;
14810 ip4_address_t ipv4;
14811 ip6_address_t ipv6;
14814 /* Parse args required to build the message */
14815 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14817 if (unformat (input, "del"))
14821 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14825 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14833 if (ipv4_set && ipv6_set)
14835 errmsg ("both eid v4 and v6 addresses set");
14839 if (!ipv4_set && !ipv6_set)
14841 errmsg ("eid addresses not set");
14845 /* Construct the API message */
14846 M (ONE_ADD_DEL_MAP_SERVER, mp);
14848 mp->is_add = is_add;
14852 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14857 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14863 /* Wait for a reply... */
14868 #define api_lisp_add_del_map_server api_one_add_del_map_server
14871 api_one_add_del_map_resolver (vat_main_t * vam)
14873 unformat_input_t *input = vam->input;
14874 vl_api_one_add_del_map_resolver_t *mp;
14878 ip4_address_t ipv4;
14879 ip6_address_t ipv6;
14882 /* Parse args required to build the message */
14883 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14885 if (unformat (input, "del"))
14889 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14893 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14901 if (ipv4_set && ipv6_set)
14903 errmsg ("both eid v4 and v6 addresses set");
14907 if (!ipv4_set && !ipv6_set)
14909 errmsg ("eid addresses not set");
14913 /* Construct the API message */
14914 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14916 mp->is_add = is_add;
14920 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14925 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14931 /* Wait for a reply... */
14936 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14939 api_lisp_gpe_enable_disable (vat_main_t * vam)
14941 unformat_input_t *input = vam->input;
14942 vl_api_gpe_enable_disable_t *mp;
14947 /* Parse args required to build the message */
14948 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14950 if (unformat (input, "enable"))
14955 else if (unformat (input, "disable"))
14966 errmsg ("Value not set");
14970 /* Construct the API message */
14971 M (GPE_ENABLE_DISABLE, mp);
14978 /* Wait for a reply... */
14984 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14986 unformat_input_t *input = vam->input;
14987 vl_api_one_rloc_probe_enable_disable_t *mp;
14992 /* Parse args required to build the message */
14993 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14995 if (unformat (input, "enable"))
15000 else if (unformat (input, "disable"))
15008 errmsg ("Value not set");
15012 /* Construct the API message */
15013 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15015 mp->is_enabled = is_en;
15020 /* Wait for a reply... */
15025 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15028 api_one_map_register_enable_disable (vat_main_t * vam)
15030 unformat_input_t *input = vam->input;
15031 vl_api_one_map_register_enable_disable_t *mp;
15036 /* Parse args required to build the message */
15037 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15039 if (unformat (input, "enable"))
15044 else if (unformat (input, "disable"))
15052 errmsg ("Value not set");
15056 /* Construct the API message */
15057 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15059 mp->is_enabled = is_en;
15064 /* Wait for a reply... */
15069 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15072 api_one_enable_disable (vat_main_t * vam)
15074 unformat_input_t *input = vam->input;
15075 vl_api_one_enable_disable_t *mp;
15080 /* Parse args required to build the message */
15081 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15083 if (unformat (input, "enable"))
15088 else if (unformat (input, "disable"))
15098 errmsg ("Value not set");
15102 /* Construct the API message */
15103 M (ONE_ENABLE_DISABLE, mp);
15110 /* Wait for a reply... */
15115 #define api_lisp_enable_disable api_one_enable_disable
15118 api_show_one_map_register_state (vat_main_t * vam)
15120 vl_api_show_one_map_register_state_t *mp;
15123 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
15128 /* wait for reply */
15133 #define api_show_lisp_map_register_state api_show_one_map_register_state
15136 api_show_one_rloc_probe_state (vat_main_t * vam)
15138 vl_api_show_one_rloc_probe_state_t *mp;
15141 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
15146 /* wait for reply */
15151 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
15154 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15156 vl_api_one_add_del_l2_arp_entry_t *mp;
15157 unformat_input_t *input = vam->input;
15162 u8 mac[6] = { 0, };
15163 u32 ip4 = 0, bd = ~0;
15166 /* Parse args required to build the message */
15167 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15169 if (unformat (input, "del"))
15171 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15173 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15175 else if (unformat (input, "bd %d", &bd))
15179 errmsg ("parse error '%U'", format_unformat_error, input);
15184 if (!bd_set || !ip_set || (!mac_set && is_add))
15186 errmsg ("Missing BD, IP or MAC!");
15190 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15191 mp->is_add = is_add;
15192 clib_memcpy (mp->mac, mac, 6);
15193 mp->bd = clib_host_to_net_u32 (bd);
15199 /* wait for reply */
15205 api_one_l2_arp_bd_get (vat_main_t * vam)
15207 vl_api_one_l2_arp_bd_get_t *mp;
15210 M (ONE_L2_ARP_BD_GET, mp);
15215 /* wait for reply */
15221 api_one_l2_arp_entries_get (vat_main_t * vam)
15223 vl_api_one_l2_arp_entries_get_t *mp;
15224 unformat_input_t *input = vam->input;
15229 /* Parse args required to build the message */
15230 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15232 if (unformat (input, "bd %d", &bd))
15236 errmsg ("parse error '%U'", format_unformat_error, input);
15243 errmsg ("Expected bridge domain!");
15247 M (ONE_L2_ARP_ENTRIES_GET, mp);
15248 mp->bd = clib_host_to_net_u32 (bd);
15253 /* wait for reply */
15259 api_one_stats_enable_disable (vat_main_t * vam)
15261 vl_api_one_stats_enable_disable_t *mp;
15262 unformat_input_t *input = vam->input;
15267 /* Parse args required to build the message */
15268 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15270 if (unformat (input, "enable"))
15275 else if (unformat (input, "disable"))
15285 errmsg ("Value not set");
15289 M (ONE_STATS_ENABLE_DISABLE, mp);
15295 /* wait for reply */
15301 api_show_one_stats_enable_disable (vat_main_t * vam)
15303 vl_api_show_one_stats_enable_disable_t *mp;
15306 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
15311 /* wait for reply */
15317 api_show_one_map_request_mode (vat_main_t * vam)
15319 vl_api_show_one_map_request_mode_t *mp;
15322 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
15327 /* wait for reply */
15332 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
15335 api_one_map_request_mode (vat_main_t * vam)
15337 unformat_input_t *input = vam->input;
15338 vl_api_one_map_request_mode_t *mp;
15342 /* Parse args required to build the message */
15343 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15345 if (unformat (input, "dst-only"))
15347 else if (unformat (input, "src-dst"))
15351 errmsg ("parse error '%U'", format_unformat_error, input);
15356 M (ONE_MAP_REQUEST_MODE, mp);
15363 /* wait for reply */
15368 #define api_lisp_map_request_mode api_one_map_request_mode
15371 * Enable/disable ONE proxy ITR.
15373 * @param vam vpp API test context
15374 * @return return code
15377 api_one_pitr_set_locator_set (vat_main_t * vam)
15379 u8 ls_name_set = 0;
15380 unformat_input_t *input = vam->input;
15381 vl_api_one_pitr_set_locator_set_t *mp;
15386 /* Parse args required to build the message */
15387 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15389 if (unformat (input, "del"))
15391 else if (unformat (input, "locator-set %s", &ls_name))
15395 errmsg ("parse error '%U'", format_unformat_error, input);
15402 errmsg ("locator-set name not set!");
15406 M (ONE_PITR_SET_LOCATOR_SET, mp);
15408 mp->is_add = is_add;
15409 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15410 vec_free (ls_name);
15415 /* wait for reply */
15420 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
15423 api_one_nsh_set_locator_set (vat_main_t * vam)
15425 u8 ls_name_set = 0;
15426 unformat_input_t *input = vam->input;
15427 vl_api_one_nsh_set_locator_set_t *mp;
15432 /* Parse args required to build the message */
15433 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15435 if (unformat (input, "del"))
15437 else if (unformat (input, "ls %s", &ls_name))
15441 errmsg ("parse error '%U'", format_unformat_error, input);
15446 if (!ls_name_set && is_add)
15448 errmsg ("locator-set name not set!");
15452 M (ONE_NSH_SET_LOCATOR_SET, mp);
15454 mp->is_add = is_add;
15455 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15456 vec_free (ls_name);
15461 /* wait for reply */
15467 api_show_one_pitr (vat_main_t * vam)
15469 vl_api_show_one_pitr_t *mp;
15472 if (!vam->json_output)
15474 print (vam->ofp, "%=20s", "lisp status:");
15477 M (SHOW_ONE_PITR, mp);
15481 /* Wait for a reply... */
15486 #define api_show_lisp_pitr api_show_one_pitr
15489 api_one_use_petr (vat_main_t * vam)
15491 unformat_input_t *input = vam->input;
15492 vl_api_one_use_petr_t *mp;
15497 memset (&ip, 0, sizeof (ip));
15499 /* Parse args required to build the message */
15500 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15502 if (unformat (input, "disable"))
15505 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
15508 ip_addr_version (&ip) = IP4;
15511 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
15514 ip_addr_version (&ip) = IP6;
15518 errmsg ("parse error '%U'", format_unformat_error, input);
15523 M (ONE_USE_PETR, mp);
15525 mp->is_add = is_add;
15528 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
15530 clib_memcpy (mp->address, &ip, 4);
15532 clib_memcpy (mp->address, &ip, 16);
15538 /* wait for reply */
15543 #define api_lisp_use_petr api_one_use_petr
15546 api_show_one_nsh_mapping (vat_main_t * vam)
15548 vl_api_show_one_use_petr_t *mp;
15551 if (!vam->json_output)
15553 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
15556 M (SHOW_ONE_NSH_MAPPING, mp);
15560 /* Wait for a reply... */
15566 api_show_one_use_petr (vat_main_t * vam)
15568 vl_api_show_one_use_petr_t *mp;
15571 if (!vam->json_output)
15573 print (vam->ofp, "%=20s", "Proxy-ETR status:");
15576 M (SHOW_ONE_USE_PETR, mp);
15580 /* Wait for a reply... */
15585 #define api_show_lisp_use_petr api_show_one_use_petr
15588 * Add/delete mapping between vni and vrf
15591 api_one_eid_table_add_del_map (vat_main_t * vam)
15593 unformat_input_t *input = vam->input;
15594 vl_api_one_eid_table_add_del_map_t *mp;
15595 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15596 u32 vni, vrf, bd_index;
15599 /* Parse args required to build the message */
15600 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15602 if (unformat (input, "del"))
15604 else if (unformat (input, "vrf %d", &vrf))
15606 else if (unformat (input, "bd_index %d", &bd_index))
15608 else if (unformat (input, "vni %d", &vni))
15614 if (!vni_set || (!vrf_set && !bd_index_set))
15616 errmsg ("missing arguments!");
15620 if (vrf_set && bd_index_set)
15622 errmsg ("error: both vrf and bd entered!");
15626 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15628 mp->is_add = is_add;
15629 mp->vni = htonl (vni);
15630 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15631 mp->is_l2 = bd_index_set;
15636 /* wait for reply */
15641 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15644 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15646 u32 *action = va_arg (*args, u32 *);
15649 if (unformat (input, "%s", &s))
15651 if (!strcmp ((char *) s, "no-action"))
15653 else if (!strcmp ((char *) s, "natively-forward"))
15655 else if (!strcmp ((char *) s, "send-map-request"))
15657 else if (!strcmp ((char *) s, "drop"))
15661 clib_warning ("invalid action: '%s'", s);
15673 * Add/del remote mapping to/from ONE control plane
15675 * @param vam vpp API test context
15676 * @return return code
15679 api_one_add_del_remote_mapping (vat_main_t * vam)
15681 unformat_input_t *input = vam->input;
15682 vl_api_one_add_del_remote_mapping_t *mp;
15684 lisp_eid_vat_t _eid, *eid = &_eid;
15685 lisp_eid_vat_t _seid, *seid = &_seid;
15686 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15687 u32 action = ~0, p, w, data_len;
15688 ip4_address_t rloc4;
15689 ip6_address_t rloc6;
15690 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15693 memset (&rloc, 0, sizeof (rloc));
15695 /* Parse args required to build the message */
15696 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15698 if (unformat (input, "del-all"))
15702 else if (unformat (input, "del"))
15706 else if (unformat (input, "add"))
15710 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15714 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15718 else if (unformat (input, "vni %d", &vni))
15722 else if (unformat (input, "p %d w %d", &p, &w))
15726 errmsg ("No RLOC configured for setting priority/weight!");
15729 curr_rloc->priority = p;
15730 curr_rloc->weight = w;
15732 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15735 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
15736 vec_add1 (rlocs, rloc);
15737 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15739 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15742 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
15743 vec_add1 (rlocs, rloc);
15744 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15746 else if (unformat (input, "action %U",
15747 unformat_negative_mapping_action, &action))
15753 clib_warning ("parse error '%U'", format_unformat_error, input);
15760 errmsg ("missing params!");
15764 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15766 errmsg ("no action set for negative map-reply!");
15770 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15772 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15773 mp->is_add = is_add;
15774 mp->vni = htonl (vni);
15775 mp->action = (u8) action;
15776 mp->is_src_dst = seid_set;
15777 mp->eid_len = eid->len;
15778 mp->seid_len = seid->len;
15779 mp->del_all = del_all;
15780 mp->eid_type = eid->type;
15781 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15782 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
15784 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15785 clib_memcpy (mp->rlocs, rlocs, data_len);
15791 /* Wait for a reply... */
15796 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15799 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15800 * forwarding entries in data-plane accordingly.
15802 * @param vam vpp API test context
15803 * @return return code
15806 api_one_add_del_adjacency (vat_main_t * vam)
15808 unformat_input_t *input = vam->input;
15809 vl_api_one_add_del_adjacency_t *mp;
15811 ip4_address_t leid4, reid4;
15812 ip6_address_t leid6, reid6;
15813 u8 reid_mac[6] = { 0 };
15814 u8 leid_mac[6] = { 0 };
15815 u8 reid_type, leid_type;
15816 u32 leid_len = 0, reid_len = 0, len;
15820 leid_type = reid_type = (u8) ~ 0;
15822 /* Parse args required to build the message */
15823 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15825 if (unformat (input, "del"))
15829 else if (unformat (input, "add"))
15833 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
15836 reid_type = 0; /* ipv4 */
15839 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
15842 reid_type = 1; /* ipv6 */
15845 else if (unformat (input, "reid %U", unformat_ethernet_address,
15848 reid_type = 2; /* mac */
15850 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
15853 leid_type = 0; /* ipv4 */
15856 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
15859 leid_type = 1; /* ipv6 */
15862 else if (unformat (input, "leid %U", unformat_ethernet_address,
15865 leid_type = 2; /* mac */
15867 else if (unformat (input, "vni %d", &vni))
15873 errmsg ("parse error '%U'", format_unformat_error, input);
15878 if ((u8) ~ 0 == reid_type)
15880 errmsg ("missing params!");
15884 if (leid_type != reid_type)
15886 errmsg ("remote and local EIDs are of different types!");
15890 M (ONE_ADD_DEL_ADJACENCY, mp);
15891 mp->is_add = is_add;
15892 mp->vni = htonl (vni);
15893 mp->leid_len = leid_len;
15894 mp->reid_len = reid_len;
15895 mp->eid_type = reid_type;
15897 switch (mp->eid_type)
15900 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
15901 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
15904 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
15905 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
15908 clib_memcpy (mp->leid, leid_mac, 6);
15909 clib_memcpy (mp->reid, reid_mac, 6);
15912 errmsg ("unknown EID type %d!", mp->eid_type);
15919 /* Wait for a reply... */
15924 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
15927 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
15929 u32 *mode = va_arg (*args, u32 *);
15931 if (unformat (input, "lisp"))
15933 else if (unformat (input, "vxlan"))
15942 api_gpe_get_encap_mode (vat_main_t * vam)
15944 vl_api_gpe_get_encap_mode_t *mp;
15947 /* Construct the API message */
15948 M (GPE_GET_ENCAP_MODE, mp);
15953 /* Wait for a reply... */
15959 api_gpe_set_encap_mode (vat_main_t * vam)
15961 unformat_input_t *input = vam->input;
15962 vl_api_gpe_set_encap_mode_t *mp;
15966 /* Parse args required to build the message */
15967 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15969 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
15975 /* Construct the API message */
15976 M (GPE_SET_ENCAP_MODE, mp);
15983 /* Wait for a reply... */
15989 api_lisp_gpe_add_del_iface (vat_main_t * vam)
15991 unformat_input_t *input = vam->input;
15992 vl_api_gpe_add_del_iface_t *mp;
15993 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
15994 u32 dp_table = 0, vni = 0;
15997 /* Parse args required to build the message */
15998 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16000 if (unformat (input, "up"))
16005 else if (unformat (input, "down"))
16010 else if (unformat (input, "table_id %d", &dp_table))
16014 else if (unformat (input, "bd_id %d", &dp_table))
16019 else if (unformat (input, "vni %d", &vni))
16027 if (action_set == 0)
16029 errmsg ("Action not set");
16032 if (dp_table_set == 0 || vni_set == 0)
16034 errmsg ("vni and dp_table must be set");
16038 /* Construct the API message */
16039 M (GPE_ADD_DEL_IFACE, mp);
16041 mp->is_add = is_add;
16042 mp->dp_table = clib_host_to_net_u32 (dp_table);
16044 mp->vni = clib_host_to_net_u32 (vni);
16049 /* Wait for a reply... */
16055 * Add/del map request itr rlocs from ONE control plane and updates
16057 * @param vam vpp API test context
16058 * @return return code
16061 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
16063 unformat_input_t *input = vam->input;
16064 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
16065 u8 *locator_set_name = 0;
16066 u8 locator_set_name_set = 0;
16070 /* Parse args required to build the message */
16071 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16073 if (unformat (input, "del"))
16077 else if (unformat (input, "%_%v%_", &locator_set_name))
16079 locator_set_name_set = 1;
16083 clib_warning ("parse error '%U'", format_unformat_error, input);
16088 if (is_add && !locator_set_name_set)
16090 errmsg ("itr-rloc is not set!");
16094 if (is_add && vec_len (locator_set_name) > 64)
16096 errmsg ("itr-rloc locator-set name too long");
16097 vec_free (locator_set_name);
16101 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
16102 mp->is_add = is_add;
16105 clib_memcpy (mp->locator_set_name, locator_set_name,
16106 vec_len (locator_set_name));
16110 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
16112 vec_free (locator_set_name);
16117 /* Wait for a reply... */
16122 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
16125 api_one_locator_dump (vat_main_t * vam)
16127 unformat_input_t *input = vam->input;
16128 vl_api_one_locator_dump_t *mp;
16129 vl_api_control_ping_t *mp_ping;
16130 u8 is_index_set = 0, is_name_set = 0;
16135 /* Parse args required to build the message */
16136 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16138 if (unformat (input, "ls_name %_%v%_", &ls_name))
16142 else if (unformat (input, "ls_index %d", &ls_index))
16148 errmsg ("parse error '%U'", format_unformat_error, input);
16153 if (!is_index_set && !is_name_set)
16155 errmsg ("error: expected one of index or name!");
16159 if (is_index_set && is_name_set)
16161 errmsg ("error: only one param expected!");
16165 if (vec_len (ls_name) > 62)
16167 errmsg ("error: locator set name too long!");
16171 if (!vam->json_output)
16173 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
16176 M (ONE_LOCATOR_DUMP, mp);
16177 mp->is_index_set = is_index_set;
16180 mp->ls_index = clib_host_to_net_u32 (ls_index);
16183 vec_add1 (ls_name, 0);
16184 strncpy ((char *) mp->ls_name, (char *) ls_name,
16185 sizeof (mp->ls_name) - 1);
16191 /* Use a control ping for synchronization */
16192 M (CONTROL_PING, mp_ping);
16195 /* Wait for a reply... */
16200 #define api_lisp_locator_dump api_one_locator_dump
16203 api_one_locator_set_dump (vat_main_t * vam)
16205 vl_api_one_locator_set_dump_t *mp;
16206 vl_api_control_ping_t *mp_ping;
16207 unformat_input_t *input = vam->input;
16211 /* Parse args required to build the message */
16212 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16214 if (unformat (input, "local"))
16218 else if (unformat (input, "remote"))
16224 errmsg ("parse error '%U'", format_unformat_error, input);
16229 if (!vam->json_output)
16231 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
16234 M (ONE_LOCATOR_SET_DUMP, mp);
16236 mp->filter = filter;
16241 /* Use a control ping for synchronization */
16242 M (CONTROL_PING, mp_ping);
16245 /* Wait for a reply... */
16250 #define api_lisp_locator_set_dump api_one_locator_set_dump
16253 api_one_eid_table_map_dump (vat_main_t * vam)
16257 unformat_input_t *input = vam->input;
16258 vl_api_one_eid_table_map_dump_t *mp;
16259 vl_api_control_ping_t *mp_ping;
16262 /* Parse args required to build the message */
16263 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16265 if (unformat (input, "l2"))
16270 else if (unformat (input, "l3"))
16277 errmsg ("parse error '%U'", format_unformat_error, input);
16284 errmsg ("expected one of 'l2' or 'l3' parameter!");
16288 if (!vam->json_output)
16290 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
16293 M (ONE_EID_TABLE_MAP_DUMP, mp);
16299 /* Use a control ping for synchronization */
16300 M (CONTROL_PING, mp_ping);
16303 /* Wait for a reply... */
16308 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
16311 api_one_eid_table_vni_dump (vat_main_t * vam)
16313 vl_api_one_eid_table_vni_dump_t *mp;
16314 vl_api_control_ping_t *mp_ping;
16317 if (!vam->json_output)
16319 print (vam->ofp, "VNI");
16322 M (ONE_EID_TABLE_VNI_DUMP, mp);
16327 /* Use a control ping for synchronization */
16328 M (CONTROL_PING, mp_ping);
16331 /* Wait for a reply... */
16336 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
16339 api_one_eid_table_dump (vat_main_t * vam)
16341 unformat_input_t *i = vam->input;
16342 vl_api_one_eid_table_dump_t *mp;
16343 vl_api_control_ping_t *mp_ping;
16344 struct in_addr ip4;
16345 struct in6_addr ip6;
16347 u8 eid_type = ~0, eid_set = 0;
16348 u32 prefix_length = ~0, t, vni = 0;
16351 lisp_nsh_api_t nsh;
16353 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16355 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
16361 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
16367 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
16372 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
16377 else if (unformat (i, "vni %d", &t))
16381 else if (unformat (i, "local"))
16385 else if (unformat (i, "remote"))
16391 errmsg ("parse error '%U'", format_unformat_error, i);
16396 if (!vam->json_output)
16398 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
16399 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
16402 M (ONE_EID_TABLE_DUMP, mp);
16404 mp->filter = filter;
16408 mp->vni = htonl (vni);
16409 mp->eid_type = eid_type;
16413 mp->prefix_length = prefix_length;
16414 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
16417 mp->prefix_length = prefix_length;
16418 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
16421 clib_memcpy (mp->eid, mac, sizeof (mac));
16424 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
16427 errmsg ("unknown EID type %d!", eid_type);
16435 /* Use a control ping for synchronization */
16436 M (CONTROL_PING, mp_ping);
16439 /* Wait for a reply... */
16444 #define api_lisp_eid_table_dump api_one_eid_table_dump
16447 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
16449 unformat_input_t *i = vam->input;
16450 vl_api_gpe_fwd_entries_get_t *mp;
16455 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16457 if (unformat (i, "vni %d", &vni))
16463 errmsg ("parse error '%U'", format_unformat_error, i);
16470 errmsg ("vni not set!");
16474 if (!vam->json_output)
16476 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
16480 M (GPE_FWD_ENTRIES_GET, mp);
16481 mp->vni = clib_host_to_net_u32 (vni);
16486 /* Wait for a reply... */
16491 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
16492 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
16493 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
16494 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
16495 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
16496 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
16497 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
16498 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
16501 api_one_adjacencies_get (vat_main_t * vam)
16503 unformat_input_t *i = vam->input;
16504 vl_api_one_adjacencies_get_t *mp;
16509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16511 if (unformat (i, "vni %d", &vni))
16517 errmsg ("parse error '%U'", format_unformat_error, i);
16524 errmsg ("vni not set!");
16528 if (!vam->json_output)
16530 print (vam->ofp, "%s %40s", "leid", "reid");
16533 M (ONE_ADJACENCIES_GET, mp);
16534 mp->vni = clib_host_to_net_u32 (vni);
16539 /* Wait for a reply... */
16544 #define api_lisp_adjacencies_get api_one_adjacencies_get
16547 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
16549 unformat_input_t *i = vam->input;
16550 vl_api_gpe_native_fwd_rpaths_get_t *mp;
16552 u8 ip_family_set = 0, is_ip4 = 1;
16554 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16556 if (unformat (i, "ip4"))
16561 else if (unformat (i, "ip6"))
16568 errmsg ("parse error '%U'", format_unformat_error, i);
16573 if (!ip_family_set)
16575 errmsg ("ip family not set!");
16579 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
16580 mp->is_ip4 = is_ip4;
16585 /* Wait for a reply... */
16591 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
16593 vl_api_gpe_fwd_entry_vnis_get_t *mp;
16596 if (!vam->json_output)
16598 print (vam->ofp, "VNIs");
16601 M (GPE_FWD_ENTRY_VNIS_GET, mp);
16606 /* Wait for a reply... */
16612 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
16614 unformat_input_t *i = vam->input;
16615 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
16617 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
16618 struct in_addr ip4;
16619 struct in6_addr ip6;
16620 u32 table_id = 0, nh_sw_if_index = ~0;
16622 memset (&ip4, 0, sizeof (ip4));
16623 memset (&ip6, 0, sizeof (ip6));
16625 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16627 if (unformat (i, "del"))
16629 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
16630 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16635 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
16636 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16641 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
16645 nh_sw_if_index = ~0;
16647 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
16651 nh_sw_if_index = ~0;
16653 else if (unformat (i, "table %d", &table_id))
16657 errmsg ("parse error '%U'", format_unformat_error, i);
16664 errmsg ("nh addr not set!");
16668 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
16669 mp->is_add = is_add;
16670 mp->table_id = clib_host_to_net_u32 (table_id);
16671 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
16672 mp->is_ip4 = is_ip4;
16674 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
16676 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
16681 /* Wait for a reply... */
16687 api_one_map_server_dump (vat_main_t * vam)
16689 vl_api_one_map_server_dump_t *mp;
16690 vl_api_control_ping_t *mp_ping;
16693 if (!vam->json_output)
16695 print (vam->ofp, "%=20s", "Map server");
16698 M (ONE_MAP_SERVER_DUMP, mp);
16702 /* Use a control ping for synchronization */
16703 M (CONTROL_PING, mp_ping);
16706 /* Wait for a reply... */
16711 #define api_lisp_map_server_dump api_one_map_server_dump
16714 api_one_map_resolver_dump (vat_main_t * vam)
16716 vl_api_one_map_resolver_dump_t *mp;
16717 vl_api_control_ping_t *mp_ping;
16720 if (!vam->json_output)
16722 print (vam->ofp, "%=20s", "Map resolver");
16725 M (ONE_MAP_RESOLVER_DUMP, mp);
16729 /* Use a control ping for synchronization */
16730 M (CONTROL_PING, mp_ping);
16733 /* Wait for a reply... */
16738 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
16741 api_one_stats_flush (vat_main_t * vam)
16743 vl_api_one_stats_flush_t *mp;
16746 M (ONE_STATS_FLUSH, mp);
16753 api_one_stats_dump (vat_main_t * vam)
16755 vl_api_one_stats_dump_t *mp;
16756 vl_api_control_ping_t *mp_ping;
16759 M (ONE_STATS_DUMP, mp);
16763 /* Use a control ping for synchronization */
16764 M (CONTROL_PING, mp_ping);
16767 /* Wait for a reply... */
16773 api_show_one_status (vat_main_t * vam)
16775 vl_api_show_one_status_t *mp;
16778 if (!vam->json_output)
16780 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
16783 M (SHOW_ONE_STATUS, mp);
16786 /* Wait for a reply... */
16791 #define api_show_lisp_status api_show_one_status
16794 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
16796 vl_api_gpe_fwd_entry_path_dump_t *mp;
16797 vl_api_control_ping_t *mp_ping;
16798 unformat_input_t *i = vam->input;
16799 u32 fwd_entry_index = ~0;
16802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16804 if (unformat (i, "index %d", &fwd_entry_index))
16810 if (~0 == fwd_entry_index)
16812 errmsg ("no index specified!");
16816 if (!vam->json_output)
16818 print (vam->ofp, "first line");
16821 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
16825 /* Use a control ping for synchronization */
16826 M (CONTROL_PING, mp_ping);
16829 /* Wait for a reply... */
16835 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
16837 vl_api_one_get_map_request_itr_rlocs_t *mp;
16840 if (!vam->json_output)
16842 print (vam->ofp, "%=20s", "itr-rlocs:");
16845 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
16848 /* Wait for a reply... */
16853 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
16856 api_af_packet_create (vat_main_t * vam)
16858 unformat_input_t *i = vam->input;
16859 vl_api_af_packet_create_t *mp;
16860 u8 *host_if_name = 0;
16862 u8 random_hw_addr = 1;
16865 memset (hw_addr, 0, sizeof (hw_addr));
16867 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16869 if (unformat (i, "name %s", &host_if_name))
16870 vec_add1 (host_if_name, 0);
16871 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16872 random_hw_addr = 0;
16877 if (!vec_len (host_if_name))
16879 errmsg ("host-interface name must be specified");
16883 if (vec_len (host_if_name) > 64)
16885 errmsg ("host-interface name too long");
16889 M (AF_PACKET_CREATE, mp);
16891 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16892 clib_memcpy (mp->hw_addr, hw_addr, 6);
16893 mp->use_random_hw_addr = random_hw_addr;
16894 vec_free (host_if_name);
16902 fprintf (vam->ofp ? vam->ofp : stderr,
16903 " new sw_if_index = %d\n", vam->sw_if_index);
16910 api_af_packet_delete (vat_main_t * vam)
16912 unformat_input_t *i = vam->input;
16913 vl_api_af_packet_delete_t *mp;
16914 u8 *host_if_name = 0;
16917 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16919 if (unformat (i, "name %s", &host_if_name))
16920 vec_add1 (host_if_name, 0);
16925 if (!vec_len (host_if_name))
16927 errmsg ("host-interface name must be specified");
16931 if (vec_len (host_if_name) > 64)
16933 errmsg ("host-interface name too long");
16937 M (AF_PACKET_DELETE, mp);
16939 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16940 vec_free (host_if_name);
16948 api_policer_add_del (vat_main_t * vam)
16950 unformat_input_t *i = vam->input;
16951 vl_api_policer_add_del_t *mp;
16961 u8 color_aware = 0;
16962 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
16965 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
16966 conform_action.dscp = 0;
16967 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
16968 exceed_action.dscp = 0;
16969 violate_action.action_type = SSE2_QOS_ACTION_DROP;
16970 violate_action.dscp = 0;
16972 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16974 if (unformat (i, "del"))
16976 else if (unformat (i, "name %s", &name))
16977 vec_add1 (name, 0);
16978 else if (unformat (i, "cir %u", &cir))
16980 else if (unformat (i, "eir %u", &eir))
16982 else if (unformat (i, "cb %u", &cb))
16984 else if (unformat (i, "eb %u", &eb))
16986 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
16989 else if (unformat (i, "round_type %U", unformat_policer_round_type,
16992 else if (unformat (i, "type %U", unformat_policer_type, &type))
16994 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
16997 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
17000 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
17003 else if (unformat (i, "color-aware"))
17009 if (!vec_len (name))
17011 errmsg ("policer name must be specified");
17015 if (vec_len (name) > 64)
17017 errmsg ("policer name too long");
17021 M (POLICER_ADD_DEL, mp);
17023 clib_memcpy (mp->name, name, vec_len (name));
17025 mp->is_add = is_add;
17030 mp->rate_type = rate_type;
17031 mp->round_type = round_type;
17033 mp->conform_action_type = conform_action.action_type;
17034 mp->conform_dscp = conform_action.dscp;
17035 mp->exceed_action_type = exceed_action.action_type;
17036 mp->exceed_dscp = exceed_action.dscp;
17037 mp->violate_action_type = violate_action.action_type;
17038 mp->violate_dscp = violate_action.dscp;
17039 mp->color_aware = color_aware;
17047 api_policer_dump (vat_main_t * vam)
17049 unformat_input_t *i = vam->input;
17050 vl_api_policer_dump_t *mp;
17051 vl_api_control_ping_t *mp_ping;
17052 u8 *match_name = 0;
17053 u8 match_name_valid = 0;
17056 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17058 if (unformat (i, "name %s", &match_name))
17060 vec_add1 (match_name, 0);
17061 match_name_valid = 1;
17067 M (POLICER_DUMP, mp);
17068 mp->match_name_valid = match_name_valid;
17069 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
17070 vec_free (match_name);
17074 /* Use a control ping for synchronization */
17075 M (CONTROL_PING, mp_ping);
17078 /* Wait for a reply... */
17084 api_policer_classify_set_interface (vat_main_t * vam)
17086 unformat_input_t *i = vam->input;
17087 vl_api_policer_classify_set_interface_t *mp;
17089 int sw_if_index_set;
17090 u32 ip4_table_index = ~0;
17091 u32 ip6_table_index = ~0;
17092 u32 l2_table_index = ~0;
17096 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17098 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17099 sw_if_index_set = 1;
17100 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17101 sw_if_index_set = 1;
17102 else if (unformat (i, "del"))
17104 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17106 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17108 else if (unformat (i, "l2-table %d", &l2_table_index))
17112 clib_warning ("parse error '%U'", format_unformat_error, i);
17117 if (sw_if_index_set == 0)
17119 errmsg ("missing interface name or sw_if_index");
17123 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
17125 mp->sw_if_index = ntohl (sw_if_index);
17126 mp->ip4_table_index = ntohl (ip4_table_index);
17127 mp->ip6_table_index = ntohl (ip6_table_index);
17128 mp->l2_table_index = ntohl (l2_table_index);
17129 mp->is_add = is_add;
17137 api_policer_classify_dump (vat_main_t * vam)
17139 unformat_input_t *i = vam->input;
17140 vl_api_policer_classify_dump_t *mp;
17141 vl_api_control_ping_t *mp_ping;
17142 u8 type = POLICER_CLASSIFY_N_TABLES;
17145 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
17149 errmsg ("classify table type must be specified");
17153 if (!vam->json_output)
17155 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17158 M (POLICER_CLASSIFY_DUMP, mp);
17163 /* Use a control ping for synchronization */
17164 M (CONTROL_PING, mp_ping);
17167 /* Wait for a reply... */
17173 api_netmap_create (vat_main_t * vam)
17175 unformat_input_t *i = vam->input;
17176 vl_api_netmap_create_t *mp;
17179 u8 random_hw_addr = 1;
17184 memset (hw_addr, 0, sizeof (hw_addr));
17186 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17188 if (unformat (i, "name %s", &if_name))
17189 vec_add1 (if_name, 0);
17190 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17191 random_hw_addr = 0;
17192 else if (unformat (i, "pipe"))
17194 else if (unformat (i, "master"))
17196 else if (unformat (i, "slave"))
17202 if (!vec_len (if_name))
17204 errmsg ("interface name must be specified");
17208 if (vec_len (if_name) > 64)
17210 errmsg ("interface name too long");
17214 M (NETMAP_CREATE, mp);
17216 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
17217 clib_memcpy (mp->hw_addr, hw_addr, 6);
17218 mp->use_random_hw_addr = random_hw_addr;
17219 mp->is_pipe = is_pipe;
17220 mp->is_master = is_master;
17221 vec_free (if_name);
17229 api_netmap_delete (vat_main_t * vam)
17231 unformat_input_t *i = vam->input;
17232 vl_api_netmap_delete_t *mp;
17236 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17238 if (unformat (i, "name %s", &if_name))
17239 vec_add1 (if_name, 0);
17244 if (!vec_len (if_name))
17246 errmsg ("interface name must be specified");
17250 if (vec_len (if_name) > 64)
17252 errmsg ("interface name too long");
17256 M (NETMAP_DELETE, mp);
17258 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
17259 vec_free (if_name);
17267 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
17269 if (fp->afi == IP46_TYPE_IP6)
17271 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17272 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17273 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17274 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17275 format_ip6_address, fp->next_hop);
17276 else if (fp->afi == IP46_TYPE_IP4)
17278 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17279 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17280 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17281 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17282 format_ip4_address, fp->next_hop);
17286 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
17287 vl_api_fib_path2_t * fp)
17289 struct in_addr ip4;
17290 struct in6_addr ip6;
17292 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17293 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17294 vat_json_object_add_uint (node, "is_local", fp->is_local);
17295 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17296 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17297 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17298 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17299 if (fp->afi == IP46_TYPE_IP4)
17301 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17302 vat_json_object_add_ip4 (node, "next_hop", ip4);
17304 else if (fp->afi == IP46_TYPE_IP6)
17306 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17307 vat_json_object_add_ip6 (node, "next_hop", ip6);
17312 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
17314 vat_main_t *vam = &vat_main;
17315 int count = ntohl (mp->mt_count);
17316 vl_api_fib_path2_t *fp;
17319 print (vam->ofp, "[%d]: sw_if_index %d via:",
17320 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
17322 for (i = 0; i < count; i++)
17324 vl_api_mpls_fib_path_print (vam, fp);
17328 print (vam->ofp, "");
17331 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
17332 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
17335 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
17337 vat_main_t *vam = &vat_main;
17338 vat_json_node_t *node = NULL;
17339 int count = ntohl (mp->mt_count);
17340 vl_api_fib_path2_t *fp;
17343 if (VAT_JSON_ARRAY != vam->json_tree.type)
17345 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17346 vat_json_init_array (&vam->json_tree);
17348 node = vat_json_array_add (&vam->json_tree);
17350 vat_json_init_object (node);
17351 vat_json_object_add_uint (node, "tunnel_index",
17352 ntohl (mp->mt_tunnel_index));
17353 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
17355 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
17358 for (i = 0; i < count; i++)
17360 vl_api_mpls_fib_path_json_print (node, fp);
17366 api_mpls_tunnel_dump (vat_main_t * vam)
17368 vl_api_mpls_tunnel_dump_t *mp;
17369 vl_api_control_ping_t *mp_ping;
17373 /* Parse args required to build the message */
17374 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
17376 if (!unformat (vam->input, "tunnel_index %d", &index))
17383 print (vam->ofp, " tunnel_index %d", index);
17385 M (MPLS_TUNNEL_DUMP, mp);
17386 mp->tunnel_index = htonl (index);
17389 /* Use a control ping for synchronization */
17390 M (CONTROL_PING, mp_ping);
17397 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
17398 #define vl_api_mpls_fib_details_t_print vl_noop_handler
17402 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
17404 vat_main_t *vam = &vat_main;
17405 int count = ntohl (mp->count);
17406 vl_api_fib_path2_t *fp;
17410 "table-id %d, label %u, ess_bit %u",
17411 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
17413 for (i = 0; i < count; i++)
17415 vl_api_mpls_fib_path_print (vam, fp);
17420 static void vl_api_mpls_fib_details_t_handler_json
17421 (vl_api_mpls_fib_details_t * mp)
17423 vat_main_t *vam = &vat_main;
17424 int count = ntohl (mp->count);
17425 vat_json_node_t *node = NULL;
17426 vl_api_fib_path2_t *fp;
17429 if (VAT_JSON_ARRAY != vam->json_tree.type)
17431 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17432 vat_json_init_array (&vam->json_tree);
17434 node = vat_json_array_add (&vam->json_tree);
17436 vat_json_init_object (node);
17437 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17438 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
17439 vat_json_object_add_uint (node, "label", ntohl (mp->label));
17440 vat_json_object_add_uint (node, "path_count", count);
17442 for (i = 0; i < count; i++)
17444 vl_api_mpls_fib_path_json_print (node, fp);
17450 api_mpls_fib_dump (vat_main_t * vam)
17452 vl_api_mpls_fib_dump_t *mp;
17453 vl_api_control_ping_t *mp_ping;
17456 M (MPLS_FIB_DUMP, mp);
17459 /* Use a control ping for synchronization */
17460 M (CONTROL_PING, mp_ping);
17467 #define vl_api_ip_fib_details_t_endian vl_noop_handler
17468 #define vl_api_ip_fib_details_t_print vl_noop_handler
17471 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
17473 vat_main_t *vam = &vat_main;
17474 int count = ntohl (mp->count);
17475 vl_api_fib_path_t *fp;
17479 "table-id %d, prefix %U/%d",
17480 ntohl (mp->table_id), format_ip4_address, mp->address,
17481 mp->address_length);
17483 for (i = 0; i < count; i++)
17485 if (fp->afi == IP46_TYPE_IP6)
17487 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17488 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17489 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17490 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17491 format_ip6_address, fp->next_hop);
17492 else if (fp->afi == IP46_TYPE_IP4)
17494 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17495 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17496 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17497 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17498 format_ip4_address, fp->next_hop);
17503 static void vl_api_ip_fib_details_t_handler_json
17504 (vl_api_ip_fib_details_t * mp)
17506 vat_main_t *vam = &vat_main;
17507 int count = ntohl (mp->count);
17508 vat_json_node_t *node = NULL;
17509 struct in_addr ip4;
17510 struct in6_addr ip6;
17511 vl_api_fib_path_t *fp;
17514 if (VAT_JSON_ARRAY != vam->json_tree.type)
17516 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17517 vat_json_init_array (&vam->json_tree);
17519 node = vat_json_array_add (&vam->json_tree);
17521 vat_json_init_object (node);
17522 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17523 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
17524 vat_json_object_add_ip4 (node, "prefix", ip4);
17525 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17526 vat_json_object_add_uint (node, "path_count", count);
17528 for (i = 0; i < count; i++)
17530 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17531 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17532 vat_json_object_add_uint (node, "is_local", fp->is_local);
17533 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17534 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17535 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17536 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17537 if (fp->afi == IP46_TYPE_IP4)
17539 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17540 vat_json_object_add_ip4 (node, "next_hop", ip4);
17542 else if (fp->afi == IP46_TYPE_IP6)
17544 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17545 vat_json_object_add_ip6 (node, "next_hop", ip6);
17551 api_ip_fib_dump (vat_main_t * vam)
17553 vl_api_ip_fib_dump_t *mp;
17554 vl_api_control_ping_t *mp_ping;
17557 M (IP_FIB_DUMP, mp);
17560 /* Use a control ping for synchronization */
17561 M (CONTROL_PING, mp_ping);
17569 api_ip_mfib_dump (vat_main_t * vam)
17571 vl_api_ip_mfib_dump_t *mp;
17572 vl_api_control_ping_t *mp_ping;
17575 M (IP_MFIB_DUMP, mp);
17578 /* Use a control ping for synchronization */
17579 M (CONTROL_PING, mp_ping);
17586 static void vl_api_ip_neighbor_details_t_handler
17587 (vl_api_ip_neighbor_details_t * mp)
17589 vat_main_t *vam = &vat_main;
17591 print (vam->ofp, "%c %U %U",
17592 (mp->is_static) ? 'S' : 'D',
17593 format_ethernet_address, &mp->mac_address,
17594 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
17598 static void vl_api_ip_neighbor_details_t_handler_json
17599 (vl_api_ip_neighbor_details_t * mp)
17602 vat_main_t *vam = &vat_main;
17603 vat_json_node_t *node;
17604 struct in_addr ip4;
17605 struct in6_addr ip6;
17607 if (VAT_JSON_ARRAY != vam->json_tree.type)
17609 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17610 vat_json_init_array (&vam->json_tree);
17612 node = vat_json_array_add (&vam->json_tree);
17614 vat_json_init_object (node);
17615 vat_json_object_add_string_copy (node, "flag",
17616 (mp->is_static) ? (u8 *) "static" : (u8 *)
17619 vat_json_object_add_string_copy (node, "link_layer",
17620 format (0, "%U", format_ethernet_address,
17621 &mp->mac_address));
17625 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
17626 vat_json_object_add_ip6 (node, "ip_address", ip6);
17630 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
17631 vat_json_object_add_ip4 (node, "ip_address", ip4);
17636 api_ip_neighbor_dump (vat_main_t * vam)
17638 unformat_input_t *i = vam->input;
17639 vl_api_ip_neighbor_dump_t *mp;
17640 vl_api_control_ping_t *mp_ping;
17642 u32 sw_if_index = ~0;
17645 /* Parse args required to build the message */
17646 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17648 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17650 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17652 else if (unformat (i, "ip6"))
17658 if (sw_if_index == ~0)
17660 errmsg ("missing interface name or sw_if_index");
17664 M (IP_NEIGHBOR_DUMP, mp);
17665 mp->is_ipv6 = (u8) is_ipv6;
17666 mp->sw_if_index = ntohl (sw_if_index);
17669 /* Use a control ping for synchronization */
17670 M (CONTROL_PING, mp_ping);
17677 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
17678 #define vl_api_ip6_fib_details_t_print vl_noop_handler
17681 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
17683 vat_main_t *vam = &vat_main;
17684 int count = ntohl (mp->count);
17685 vl_api_fib_path_t *fp;
17689 "table-id %d, prefix %U/%d",
17690 ntohl (mp->table_id), format_ip6_address, mp->address,
17691 mp->address_length);
17693 for (i = 0; i < count; i++)
17695 if (fp->afi == IP46_TYPE_IP6)
17697 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17698 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17699 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17700 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17701 format_ip6_address, fp->next_hop);
17702 else if (fp->afi == IP46_TYPE_IP4)
17704 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17705 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17706 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17707 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17708 format_ip4_address, fp->next_hop);
17713 static void vl_api_ip6_fib_details_t_handler_json
17714 (vl_api_ip6_fib_details_t * mp)
17716 vat_main_t *vam = &vat_main;
17717 int count = ntohl (mp->count);
17718 vat_json_node_t *node = NULL;
17719 struct in_addr ip4;
17720 struct in6_addr ip6;
17721 vl_api_fib_path_t *fp;
17724 if (VAT_JSON_ARRAY != vam->json_tree.type)
17726 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17727 vat_json_init_array (&vam->json_tree);
17729 node = vat_json_array_add (&vam->json_tree);
17731 vat_json_init_object (node);
17732 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17733 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
17734 vat_json_object_add_ip6 (node, "prefix", ip6);
17735 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17736 vat_json_object_add_uint (node, "path_count", count);
17738 for (i = 0; i < count; i++)
17740 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17741 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17742 vat_json_object_add_uint (node, "is_local", fp->is_local);
17743 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17744 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17745 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17746 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17747 if (fp->afi == IP46_TYPE_IP4)
17749 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17750 vat_json_object_add_ip4 (node, "next_hop", ip4);
17752 else if (fp->afi == IP46_TYPE_IP6)
17754 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17755 vat_json_object_add_ip6 (node, "next_hop", ip6);
17761 api_ip6_fib_dump (vat_main_t * vam)
17763 vl_api_ip6_fib_dump_t *mp;
17764 vl_api_control_ping_t *mp_ping;
17767 M (IP6_FIB_DUMP, mp);
17770 /* Use a control ping for synchronization */
17771 M (CONTROL_PING, mp_ping);
17779 api_ip6_mfib_dump (vat_main_t * vam)
17781 vl_api_ip6_mfib_dump_t *mp;
17782 vl_api_control_ping_t *mp_ping;
17785 M (IP6_MFIB_DUMP, mp);
17788 /* Use a control ping for synchronization */
17789 M (CONTROL_PING, mp_ping);
17797 api_classify_table_ids (vat_main_t * vam)
17799 vl_api_classify_table_ids_t *mp;
17802 /* Construct the API message */
17803 M (CLASSIFY_TABLE_IDS, mp);
17812 api_classify_table_by_interface (vat_main_t * vam)
17814 unformat_input_t *input = vam->input;
17815 vl_api_classify_table_by_interface_t *mp;
17817 u32 sw_if_index = ~0;
17819 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17821 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17823 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17828 if (sw_if_index == ~0)
17830 errmsg ("missing interface name or sw_if_index");
17834 /* Construct the API message */
17835 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
17837 mp->sw_if_index = ntohl (sw_if_index);
17845 api_classify_table_info (vat_main_t * vam)
17847 unformat_input_t *input = vam->input;
17848 vl_api_classify_table_info_t *mp;
17852 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17854 if (unformat (input, "table_id %d", &table_id))
17859 if (table_id == ~0)
17861 errmsg ("missing table id");
17865 /* Construct the API message */
17866 M (CLASSIFY_TABLE_INFO, mp);
17868 mp->table_id = ntohl (table_id);
17876 api_classify_session_dump (vat_main_t * vam)
17878 unformat_input_t *input = vam->input;
17879 vl_api_classify_session_dump_t *mp;
17880 vl_api_control_ping_t *mp_ping;
17884 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17886 if (unformat (input, "table_id %d", &table_id))
17891 if (table_id == ~0)
17893 errmsg ("missing table id");
17897 /* Construct the API message */
17898 M (CLASSIFY_SESSION_DUMP, mp);
17900 mp->table_id = ntohl (table_id);
17903 /* Use a control ping for synchronization */
17904 M (CONTROL_PING, mp_ping);
17912 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
17914 vat_main_t *vam = &vat_main;
17916 print (vam->ofp, "collector_address %U, collector_port %d, "
17917 "src_address %U, vrf_id %d, path_mtu %u, "
17918 "template_interval %u, udp_checksum %d",
17919 format_ip4_address, mp->collector_address,
17920 ntohs (mp->collector_port),
17921 format_ip4_address, mp->src_address,
17922 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
17923 ntohl (mp->template_interval), mp->udp_checksum);
17926 vam->result_ready = 1;
17930 vl_api_ipfix_exporter_details_t_handler_json
17931 (vl_api_ipfix_exporter_details_t * mp)
17933 vat_main_t *vam = &vat_main;
17934 vat_json_node_t node;
17935 struct in_addr collector_address;
17936 struct in_addr src_address;
17938 vat_json_init_object (&node);
17939 clib_memcpy (&collector_address, &mp->collector_address,
17940 sizeof (collector_address));
17941 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
17942 vat_json_object_add_uint (&node, "collector_port",
17943 ntohs (mp->collector_port));
17944 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
17945 vat_json_object_add_ip4 (&node, "src_address", src_address);
17946 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
17947 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
17948 vat_json_object_add_uint (&node, "template_interval",
17949 ntohl (mp->template_interval));
17950 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
17952 vat_json_print (vam->ofp, &node);
17953 vat_json_free (&node);
17955 vam->result_ready = 1;
17959 api_ipfix_exporter_dump (vat_main_t * vam)
17961 vl_api_ipfix_exporter_dump_t *mp;
17964 /* Construct the API message */
17965 M (IPFIX_EXPORTER_DUMP, mp);
17974 api_ipfix_classify_stream_dump (vat_main_t * vam)
17976 vl_api_ipfix_classify_stream_dump_t *mp;
17979 /* Construct the API message */
17980 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
17991 vl_api_ipfix_classify_stream_details_t_handler
17992 (vl_api_ipfix_classify_stream_details_t * mp)
17994 vat_main_t *vam = &vat_main;
17995 print (vam->ofp, "domain_id %d, src_port %d",
17996 ntohl (mp->domain_id), ntohs (mp->src_port));
17998 vam->result_ready = 1;
18002 vl_api_ipfix_classify_stream_details_t_handler_json
18003 (vl_api_ipfix_classify_stream_details_t * mp)
18005 vat_main_t *vam = &vat_main;
18006 vat_json_node_t node;
18008 vat_json_init_object (&node);
18009 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
18010 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
18012 vat_json_print (vam->ofp, &node);
18013 vat_json_free (&node);
18015 vam->result_ready = 1;
18019 api_ipfix_classify_table_dump (vat_main_t * vam)
18021 vl_api_ipfix_classify_table_dump_t *mp;
18022 vl_api_control_ping_t *mp_ping;
18025 if (!vam->json_output)
18027 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
18028 "transport_protocol");
18031 /* Construct the API message */
18032 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
18037 /* Use a control ping for synchronization */
18038 M (CONTROL_PING, mp_ping);
18046 vl_api_ipfix_classify_table_details_t_handler
18047 (vl_api_ipfix_classify_table_details_t * mp)
18049 vat_main_t *vam = &vat_main;
18050 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
18051 mp->transport_protocol);
18055 vl_api_ipfix_classify_table_details_t_handler_json
18056 (vl_api_ipfix_classify_table_details_t * mp)
18058 vat_json_node_t *node = NULL;
18059 vat_main_t *vam = &vat_main;
18061 if (VAT_JSON_ARRAY != vam->json_tree.type)
18063 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18064 vat_json_init_array (&vam->json_tree);
18067 node = vat_json_array_add (&vam->json_tree);
18068 vat_json_init_object (node);
18070 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
18071 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
18072 vat_json_object_add_uint (node, "transport_protocol",
18073 mp->transport_protocol);
18077 api_sw_interface_span_enable_disable (vat_main_t * vam)
18079 unformat_input_t *i = vam->input;
18080 vl_api_sw_interface_span_enable_disable_t *mp;
18081 u32 src_sw_if_index = ~0;
18082 u32 dst_sw_if_index = ~0;
18086 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18089 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
18091 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
18095 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
18097 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
18099 else if (unformat (i, "disable"))
18101 else if (unformat (i, "rx"))
18103 else if (unformat (i, "tx"))
18105 else if (unformat (i, "both"))
18111 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
18113 mp->sw_if_index_from = htonl (src_sw_if_index);
18114 mp->sw_if_index_to = htonl (dst_sw_if_index);
18123 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
18126 vat_main_t *vam = &vat_main;
18127 u8 *sw_if_from_name = 0;
18128 u8 *sw_if_to_name = 0;
18129 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18130 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18131 char *states[] = { "none", "rx", "tx", "both" };
18135 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18137 if ((u32) p->value[0] == sw_if_index_from)
18139 sw_if_from_name = (u8 *)(p->key);
18143 if ((u32) p->value[0] == sw_if_index_to)
18145 sw_if_to_name = (u8 *)(p->key);
18146 if (sw_if_from_name)
18151 print (vam->ofp, "%20s => %20s (%s)",
18152 sw_if_from_name, sw_if_to_name, states[mp->state]);
18156 vl_api_sw_interface_span_details_t_handler_json
18157 (vl_api_sw_interface_span_details_t * mp)
18159 vat_main_t *vam = &vat_main;
18160 vat_json_node_t *node = NULL;
18161 u8 *sw_if_from_name = 0;
18162 u8 *sw_if_to_name = 0;
18163 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18164 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18168 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18170 if ((u32) p->value[0] == sw_if_index_from)
18172 sw_if_from_name = (u8 *)(p->key);
18176 if ((u32) p->value[0] == sw_if_index_to)
18178 sw_if_to_name = (u8 *)(p->key);
18179 if (sw_if_from_name)
18185 if (VAT_JSON_ARRAY != vam->json_tree.type)
18187 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18188 vat_json_init_array (&vam->json_tree);
18190 node = vat_json_array_add (&vam->json_tree);
18192 vat_json_init_object (node);
18193 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
18194 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
18195 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
18196 if (0 != sw_if_to_name)
18198 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
18200 vat_json_object_add_uint (node, "state", mp->state);
18204 api_sw_interface_span_dump (vat_main_t * vam)
18206 vl_api_sw_interface_span_dump_t *mp;
18207 vl_api_control_ping_t *mp_ping;
18210 M (SW_INTERFACE_SPAN_DUMP, mp);
18213 /* Use a control ping for synchronization */
18214 M (CONTROL_PING, mp_ping);
18222 api_pg_create_interface (vat_main_t * vam)
18224 unformat_input_t *input = vam->input;
18225 vl_api_pg_create_interface_t *mp;
18229 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18231 if (unformat (input, "if_id %d", &if_id))
18238 errmsg ("missing pg interface index");
18242 /* Construct the API message */
18243 M (PG_CREATE_INTERFACE, mp);
18245 mp->interface_id = ntohl (if_id);
18253 api_pg_capture (vat_main_t * vam)
18255 unformat_input_t *input = vam->input;
18256 vl_api_pg_capture_t *mp;
18261 u8 pcap_file_set = 0;
18264 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18266 if (unformat (input, "if_id %d", &if_id))
18268 else if (unformat (input, "pcap %s", &pcap_file))
18270 else if (unformat (input, "count %d", &count))
18272 else if (unformat (input, "disable"))
18279 errmsg ("missing pg interface index");
18282 if (pcap_file_set > 0)
18284 if (vec_len (pcap_file) > 255)
18286 errmsg ("pcap file name is too long");
18291 u32 name_len = vec_len (pcap_file);
18292 /* Construct the API message */
18293 M (PG_CAPTURE, mp);
18295 mp->interface_id = ntohl (if_id);
18296 mp->is_enabled = enable;
18297 mp->count = ntohl (count);
18298 mp->pcap_name_length = ntohl (name_len);
18299 if (pcap_file_set != 0)
18301 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
18303 vec_free (pcap_file);
18311 api_pg_enable_disable (vat_main_t * vam)
18313 unformat_input_t *input = vam->input;
18314 vl_api_pg_enable_disable_t *mp;
18317 u8 stream_name_set = 0;
18318 u8 *stream_name = 0;
18320 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18322 if (unformat (input, "stream %s", &stream_name))
18323 stream_name_set = 1;
18324 else if (unformat (input, "disable"))
18330 if (stream_name_set > 0)
18332 if (vec_len (stream_name) > 255)
18334 errmsg ("stream name too long");
18339 u32 name_len = vec_len (stream_name);
18340 /* Construct the API message */
18341 M (PG_ENABLE_DISABLE, mp);
18343 mp->is_enabled = enable;
18344 if (stream_name_set != 0)
18346 mp->stream_name_length = ntohl (name_len);
18347 clib_memcpy (mp->stream_name, stream_name, name_len);
18349 vec_free (stream_name);
18357 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
18359 unformat_input_t *input = vam->input;
18360 vl_api_ip_source_and_port_range_check_add_del_t *mp;
18362 u16 *low_ports = 0;
18363 u16 *high_ports = 0;
18366 ip4_address_t ip4_addr;
18367 ip6_address_t ip6_addr;
18376 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18378 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
18384 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
18389 else if (unformat (input, "vrf %d", &vrf_id))
18391 else if (unformat (input, "del"))
18393 else if (unformat (input, "port %d", &tmp))
18395 if (tmp == 0 || tmp > 65535)
18397 errmsg ("port %d out of range", tmp);
18401 this_hi = this_low + 1;
18402 vec_add1 (low_ports, this_low);
18403 vec_add1 (high_ports, this_hi);
18405 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
18407 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
18409 errmsg ("incorrect range parameters");
18413 /* Note: in debug CLI +1 is added to high before
18414 passing to real fn that does "the work"
18415 (ip_source_and_port_range_check_add_del).
18416 This fn is a wrapper around the binary API fn a
18417 control plane will call, which expects this increment
18418 to have occurred. Hence letting the binary API control
18419 plane fn do the increment for consistency between VAT
18420 and other control planes.
18423 vec_add1 (low_ports, this_low);
18424 vec_add1 (high_ports, this_hi);
18430 if (prefix_set == 0)
18432 errmsg ("<address>/<mask> not specified");
18438 errmsg ("VRF ID required, not specified");
18445 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18449 if (vec_len (low_ports) == 0)
18451 errmsg ("At least one port or port range required");
18455 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
18457 mp->is_add = is_add;
18462 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
18467 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
18470 mp->mask_length = length;
18471 mp->number_of_ranges = vec_len (low_ports);
18473 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
18474 vec_free (low_ports);
18476 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
18477 vec_free (high_ports);
18479 mp->vrf_id = ntohl (vrf_id);
18487 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
18489 unformat_input_t *input = vam->input;
18490 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
18491 u32 sw_if_index = ~0;
18493 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
18494 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
18498 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18500 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18502 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18504 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
18506 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
18508 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
18510 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
18512 else if (unformat (input, "del"))
18518 if (sw_if_index == ~0)
18520 errmsg ("Interface required but not specified");
18526 errmsg ("VRF ID required but not specified");
18530 if (tcp_out_vrf_id == 0
18531 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
18534 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18538 /* Construct the API message */
18539 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
18541 mp->sw_if_index = ntohl (sw_if_index);
18542 mp->is_add = is_add;
18543 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
18544 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
18545 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
18546 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
18551 /* Wait for a reply... */
18557 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
18559 unformat_input_t *i = vam->input;
18560 vl_api_ipsec_gre_add_del_tunnel_t *mp;
18561 u32 local_sa_id = 0;
18562 u32 remote_sa_id = 0;
18563 ip4_address_t src_address;
18564 ip4_address_t dst_address;
18568 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18570 if (unformat (i, "local_sa %d", &local_sa_id))
18572 else if (unformat (i, "remote_sa %d", &remote_sa_id))
18574 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
18576 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
18578 else if (unformat (i, "del"))
18582 clib_warning ("parse error '%U'", format_unformat_error, i);
18587 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
18589 mp->local_sa_id = ntohl (local_sa_id);
18590 mp->remote_sa_id = ntohl (remote_sa_id);
18591 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
18592 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
18593 mp->is_add = is_add;
18601 api_punt (vat_main_t * vam)
18603 unformat_input_t *i = vam->input;
18611 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18613 if (unformat (i, "ip %d", &ipv))
18615 else if (unformat (i, "protocol %d", &protocol))
18617 else if (unformat (i, "port %d", &port))
18619 else if (unformat (i, "del"))
18623 clib_warning ("parse error '%U'", format_unformat_error, i);
18630 mp->is_add = (u8) is_add;
18631 mp->ipv = (u8) ipv;
18632 mp->l4_protocol = (u8) protocol;
18633 mp->l4_port = htons ((u16) port);
18640 static void vl_api_ipsec_gre_tunnel_details_t_handler
18641 (vl_api_ipsec_gre_tunnel_details_t * mp)
18643 vat_main_t *vam = &vat_main;
18645 print (vam->ofp, "%11d%15U%15U%14d%14d",
18646 ntohl (mp->sw_if_index),
18647 format_ip4_address, &mp->src_address,
18648 format_ip4_address, &mp->dst_address,
18649 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
18652 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
18653 (vl_api_ipsec_gre_tunnel_details_t * mp)
18655 vat_main_t *vam = &vat_main;
18656 vat_json_node_t *node = NULL;
18657 struct in_addr ip4;
18659 if (VAT_JSON_ARRAY != vam->json_tree.type)
18661 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18662 vat_json_init_array (&vam->json_tree);
18664 node = vat_json_array_add (&vam->json_tree);
18666 vat_json_init_object (node);
18667 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18668 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
18669 vat_json_object_add_ip4 (node, "src_address", ip4);
18670 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
18671 vat_json_object_add_ip4 (node, "dst_address", ip4);
18672 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
18673 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
18677 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
18679 unformat_input_t *i = vam->input;
18680 vl_api_ipsec_gre_tunnel_dump_t *mp;
18681 vl_api_control_ping_t *mp_ping;
18683 u8 sw_if_index_set = 0;
18686 /* Parse args required to build the message */
18687 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18689 if (unformat (i, "sw_if_index %d", &sw_if_index))
18690 sw_if_index_set = 1;
18695 if (sw_if_index_set == 0)
18700 if (!vam->json_output)
18702 print (vam->ofp, "%11s%15s%15s%14s%14s",
18703 "sw_if_index", "src_address", "dst_address",
18704 "local_sa_id", "remote_sa_id");
18707 /* Get list of gre-tunnel interfaces */
18708 M (IPSEC_GRE_TUNNEL_DUMP, mp);
18710 mp->sw_if_index = htonl (sw_if_index);
18714 /* Use a control ping for synchronization */
18715 M (CONTROL_PING, mp_ping);
18723 api_delete_subif (vat_main_t * vam)
18725 unformat_input_t *i = vam->input;
18726 vl_api_delete_subif_t *mp;
18727 u32 sw_if_index = ~0;
18730 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18732 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18734 if (unformat (i, "sw_if_index %d", &sw_if_index))
18740 if (sw_if_index == ~0)
18742 errmsg ("missing sw_if_index");
18746 /* Construct the API message */
18747 M (DELETE_SUBIF, mp);
18748 mp->sw_if_index = ntohl (sw_if_index);
18755 #define foreach_pbb_vtr_op \
18756 _("disable", L2_VTR_DISABLED) \
18757 _("pop", L2_VTR_POP_2) \
18758 _("push", L2_VTR_PUSH_2)
18761 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
18763 unformat_input_t *i = vam->input;
18764 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
18765 u32 sw_if_index = ~0, vtr_op = ~0;
18766 u16 outer_tag = ~0;
18767 u8 dmac[6], smac[6];
18768 u8 dmac_set = 0, smac_set = 0;
18774 /* Shut up coverity */
18775 memset (dmac, 0, sizeof (dmac));
18776 memset (smac, 0, sizeof (smac));
18778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18780 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18782 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18784 else if (unformat (i, "vtr_op %d", &vtr_op))
18786 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
18789 else if (unformat (i, "translate_pbb_stag"))
18791 if (unformat (i, "%d", &tmp))
18793 vtr_op = L2_VTR_TRANSLATE_2_1;
18799 ("translate_pbb_stag operation requires outer tag definition");
18803 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
18805 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
18807 else if (unformat (i, "sid %d", &sid))
18809 else if (unformat (i, "vlanid %d", &tmp))
18813 clib_warning ("parse error '%U'", format_unformat_error, i);
18818 if ((sw_if_index == ~0) || (vtr_op == ~0))
18820 errmsg ("missing sw_if_index or vtr operation");
18823 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
18824 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
18827 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
18831 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
18832 mp->sw_if_index = ntohl (sw_if_index);
18833 mp->vtr_op = ntohl (vtr_op);
18834 mp->outer_tag = ntohs (outer_tag);
18835 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
18836 clib_memcpy (mp->b_smac, smac, sizeof (smac));
18837 mp->b_vlanid = ntohs (vlanid);
18838 mp->i_sid = ntohl (sid);
18846 api_flow_classify_set_interface (vat_main_t * vam)
18848 unformat_input_t *i = vam->input;
18849 vl_api_flow_classify_set_interface_t *mp;
18851 int sw_if_index_set;
18852 u32 ip4_table_index = ~0;
18853 u32 ip6_table_index = ~0;
18857 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18859 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18860 sw_if_index_set = 1;
18861 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18862 sw_if_index_set = 1;
18863 else if (unformat (i, "del"))
18865 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18867 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18871 clib_warning ("parse error '%U'", format_unformat_error, i);
18876 if (sw_if_index_set == 0)
18878 errmsg ("missing interface name or sw_if_index");
18882 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
18884 mp->sw_if_index = ntohl (sw_if_index);
18885 mp->ip4_table_index = ntohl (ip4_table_index);
18886 mp->ip6_table_index = ntohl (ip6_table_index);
18887 mp->is_add = is_add;
18895 api_flow_classify_dump (vat_main_t * vam)
18897 unformat_input_t *i = vam->input;
18898 vl_api_flow_classify_dump_t *mp;
18899 vl_api_control_ping_t *mp_ping;
18900 u8 type = FLOW_CLASSIFY_N_TABLES;
18903 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
18907 errmsg ("classify table type must be specified");
18911 if (!vam->json_output)
18913 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18916 M (FLOW_CLASSIFY_DUMP, mp);
18921 /* Use a control ping for synchronization */
18922 M (CONTROL_PING, mp_ping);
18925 /* Wait for a reply... */
18931 api_feature_enable_disable (vat_main_t * vam)
18933 unformat_input_t *i = vam->input;
18934 vl_api_feature_enable_disable_t *mp;
18936 u8 *feature_name = 0;
18937 u32 sw_if_index = ~0;
18941 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18943 if (unformat (i, "arc_name %s", &arc_name))
18945 else if (unformat (i, "feature_name %s", &feature_name))
18948 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18950 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18952 else if (unformat (i, "disable"))
18960 errmsg ("missing arc name");
18963 if (vec_len (arc_name) > 63)
18965 errmsg ("arc name too long");
18968 if (feature_name == 0)
18970 errmsg ("missing feature name");
18973 if (vec_len (feature_name) > 63)
18975 errmsg ("feature name too long");
18978 if (sw_if_index == ~0)
18980 errmsg ("missing interface name or sw_if_index");
18984 /* Construct the API message */
18985 M (FEATURE_ENABLE_DISABLE, mp);
18986 mp->sw_if_index = ntohl (sw_if_index);
18987 mp->enable = enable;
18988 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
18989 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
18990 vec_free (arc_name);
18991 vec_free (feature_name);
18999 api_sw_interface_tag_add_del (vat_main_t * vam)
19001 unformat_input_t *i = vam->input;
19002 vl_api_sw_interface_tag_add_del_t *mp;
19003 u32 sw_if_index = ~0;
19008 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19010 if (unformat (i, "tag %s", &tag))
19012 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19014 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19016 else if (unformat (i, "del"))
19022 if (sw_if_index == ~0)
19024 errmsg ("missing interface name or sw_if_index");
19028 if (enable && (tag == 0))
19030 errmsg ("no tag specified");
19034 /* Construct the API message */
19035 M (SW_INTERFACE_TAG_ADD_DEL, mp);
19036 mp->sw_if_index = ntohl (sw_if_index);
19037 mp->is_add = enable;
19039 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
19047 static void vl_api_l2_xconnect_details_t_handler
19048 (vl_api_l2_xconnect_details_t * mp)
19050 vat_main_t *vam = &vat_main;
19052 print (vam->ofp, "%15d%15d",
19053 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
19056 static void vl_api_l2_xconnect_details_t_handler_json
19057 (vl_api_l2_xconnect_details_t * mp)
19059 vat_main_t *vam = &vat_main;
19060 vat_json_node_t *node = NULL;
19062 if (VAT_JSON_ARRAY != vam->json_tree.type)
19064 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19065 vat_json_init_array (&vam->json_tree);
19067 node = vat_json_array_add (&vam->json_tree);
19069 vat_json_init_object (node);
19070 vat_json_object_add_uint (node, "rx_sw_if_index",
19071 ntohl (mp->rx_sw_if_index));
19072 vat_json_object_add_uint (node, "tx_sw_if_index",
19073 ntohl (mp->tx_sw_if_index));
19077 api_l2_xconnect_dump (vat_main_t * vam)
19079 vl_api_l2_xconnect_dump_t *mp;
19080 vl_api_control_ping_t *mp_ping;
19083 if (!vam->json_output)
19085 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
19088 M (L2_XCONNECT_DUMP, mp);
19092 /* Use a control ping for synchronization */
19093 M (CONTROL_PING, mp_ping);
19101 api_sw_interface_set_mtu (vat_main_t * vam)
19103 unformat_input_t *i = vam->input;
19104 vl_api_sw_interface_set_mtu_t *mp;
19105 u32 sw_if_index = ~0;
19109 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19111 if (unformat (i, "mtu %d", &mtu))
19113 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19115 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19121 if (sw_if_index == ~0)
19123 errmsg ("missing interface name or sw_if_index");
19129 errmsg ("no mtu specified");
19133 /* Construct the API message */
19134 M (SW_INTERFACE_SET_MTU, mp);
19135 mp->sw_if_index = ntohl (sw_if_index);
19136 mp->mtu = ntohs ((u16) mtu);
19144 api_p2p_ethernet_add (vat_main_t * vam)
19146 unformat_input_t *i = vam->input;
19147 vl_api_p2p_ethernet_add_t *mp;
19148 u32 parent_if_index = ~0;
19153 memset (remote_mac, 0, sizeof (remote_mac));
19154 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19156 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19158 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19162 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19166 clib_warning ("parse error '%U'", format_unformat_error, i);
19171 if (parent_if_index == ~0)
19173 errmsg ("missing interface name or sw_if_index");
19178 errmsg ("missing remote mac address");
19182 M (P2P_ETHERNET_ADD, mp);
19183 mp->parent_if_index = ntohl (parent_if_index);
19184 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19192 api_p2p_ethernet_del (vat_main_t * vam)
19194 unformat_input_t *i = vam->input;
19195 vl_api_p2p_ethernet_del_t *mp;
19196 u32 parent_if_index = ~0;
19201 memset (remote_mac, 0, sizeof (remote_mac));
19202 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19204 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19206 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19210 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19214 clib_warning ("parse error '%U'", format_unformat_error, i);
19219 if (parent_if_index == ~0)
19221 errmsg ("missing interface name or sw_if_index");
19226 errmsg ("missing remote mac address");
19230 M (P2P_ETHERNET_DEL, mp);
19231 mp->parent_if_index = ntohl (parent_if_index);
19232 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19240 api_lldp_config (vat_main_t * vam)
19242 unformat_input_t *i = vam->input;
19243 vl_api_lldp_config_t *mp;
19245 int tx_interval = 0;
19246 u8 *sys_name = NULL;
19249 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19251 if (unformat (i, "system-name %s", &sys_name))
19253 else if (unformat (i, "tx-hold %d", &tx_hold))
19255 else if (unformat (i, "tx-interval %d", &tx_interval))
19259 clib_warning ("parse error '%U'", format_unformat_error, i);
19264 vec_add1 (sys_name, 0);
19266 M (LLDP_CONFIG, mp);
19267 mp->tx_hold = htonl (tx_hold);
19268 mp->tx_interval = htonl (tx_interval);
19269 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
19270 vec_free (sys_name);
19278 api_sw_interface_set_lldp (vat_main_t * vam)
19280 unformat_input_t *i = vam->input;
19281 vl_api_sw_interface_set_lldp_t *mp;
19282 u32 sw_if_index = ~0;
19284 u8 *port_desc = NULL;
19287 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19289 if (unformat (i, "disable"))
19292 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19294 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19296 else if (unformat (i, "port-desc %s", &port_desc))
19302 if (sw_if_index == ~0)
19304 errmsg ("missing interface name or sw_if_index");
19308 /* Construct the API message */
19309 vec_add1 (port_desc, 0);
19310 M (SW_INTERFACE_SET_LLDP, mp);
19311 mp->sw_if_index = ntohl (sw_if_index);
19312 mp->enable = enable;
19313 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
19314 vec_free (port_desc);
19322 q_or_quit (vat_main_t * vam)
19324 #if VPP_API_TEST_BUILTIN == 0
19325 longjmp (vam->jump_buf, 1);
19327 return 0; /* not so much */
19331 q (vat_main_t * vam)
19333 return q_or_quit (vam);
19337 quit (vat_main_t * vam)
19339 return q_or_quit (vam);
19343 comment (vat_main_t * vam)
19349 cmd_cmp (void *a1, void *a2)
19354 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
19358 help (vat_main_t * vam)
19363 unformat_input_t *i = vam->input;
19366 if (unformat (i, "%s", &name))
19370 vec_add1 (name, 0);
19372 hs = hash_get_mem (vam->help_by_name, name);
19374 print (vam->ofp, "usage: %s %s", name, hs[0]);
19376 print (vam->ofp, "No such msg / command '%s'", name);
19381 print (vam->ofp, "Help is available for the following:");
19384 hash_foreach_pair (p, vam->function_by_name,
19386 vec_add1 (cmds, (u8 *)(p->key));
19390 vec_sort_with_function (cmds, cmd_cmp);
19392 for (j = 0; j < vec_len (cmds); j++)
19393 print (vam->ofp, "%s", cmds[j]);
19400 set (vat_main_t * vam)
19402 u8 *name = 0, *value = 0;
19403 unformat_input_t *i = vam->input;
19405 if (unformat (i, "%s", &name))
19407 /* The input buffer is a vector, not a string. */
19408 value = vec_dup (i->buffer);
19409 vec_delete (value, i->index, 0);
19410 /* Almost certainly has a trailing newline */
19411 if (value[vec_len (value) - 1] == '\n')
19412 value[vec_len (value) - 1] = 0;
19413 /* Make sure it's a proper string, one way or the other */
19414 vec_add1 (value, 0);
19415 (void) clib_macro_set_value (&vam->macro_main,
19416 (char *) name, (char *) value);
19419 errmsg ("usage: set <name> <value>");
19427 unset (vat_main_t * vam)
19431 if (unformat (vam->input, "%s", &name))
19432 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
19433 errmsg ("unset: %s wasn't set", name);
19446 macro_sort_cmp (void *a1, void *a2)
19448 macro_sort_t *s1 = a1;
19449 macro_sort_t *s2 = a2;
19451 return strcmp ((char *) (s1->name), (char *) (s2->name));
19455 dump_macro_table (vat_main_t * vam)
19457 macro_sort_t *sort_me = 0, *sm;
19462 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
19464 vec_add2 (sort_me, sm, 1);
19465 sm->name = (u8 *)(p->key);
19466 sm->value = (u8 *) (p->value[0]);
19470 vec_sort_with_function (sort_me, macro_sort_cmp);
19472 if (vec_len (sort_me))
19473 print (vam->ofp, "%-15s%s", "Name", "Value");
19475 print (vam->ofp, "The macro table is empty...");
19477 for (i = 0; i < vec_len (sort_me); i++)
19478 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
19483 dump_node_table (vat_main_t * vam)
19486 vlib_node_t *node, *next_node;
19488 if (vec_len (vam->graph_nodes) == 0)
19490 print (vam->ofp, "Node table empty, issue get_node_graph...");
19494 for (i = 0; i < vec_len (vam->graph_nodes); i++)
19496 node = vam->graph_nodes[i];
19497 print (vam->ofp, "[%d] %s", i, node->name);
19498 for (j = 0; j < vec_len (node->next_nodes); j++)
19500 if (node->next_nodes[j] != ~0)
19502 next_node = vam->graph_nodes[node->next_nodes[j]];
19503 print (vam->ofp, " [%d] %s", j, next_node->name);
19511 value_sort_cmp (void *a1, void *a2)
19513 name_sort_t *n1 = a1;
19514 name_sort_t *n2 = a2;
19516 if (n1->value < n2->value)
19518 if (n1->value > n2->value)
19525 dump_msg_api_table (vat_main_t * vam)
19527 api_main_t *am = &api_main;
19528 name_sort_t *nses = 0, *ns;
19533 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
19535 vec_add2 (nses, ns, 1);
19536 ns->name = (u8 *)(hp->key);
19537 ns->value = (u32) hp->value[0];
19541 vec_sort_with_function (nses, value_sort_cmp);
19543 for (i = 0; i < vec_len (nses); i++)
19544 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
19550 get_msg_id (vat_main_t * vam)
19555 if (unformat (vam->input, "%s", &name_and_crc))
19557 message_index = vl_api_get_msg_index (name_and_crc);
19558 if (message_index == ~0)
19560 print (vam->ofp, " '%s' not found", name_and_crc);
19563 print (vam->ofp, " '%s' has message index %d",
19564 name_and_crc, message_index);
19567 errmsg ("name_and_crc required...");
19572 search_node_table (vat_main_t * vam)
19574 unformat_input_t *line_input = vam->input;
19577 vlib_node_t *node, *next_node;
19580 if (vam->graph_node_index_by_name == 0)
19582 print (vam->ofp, "Node table empty, issue get_node_graph...");
19586 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
19588 if (unformat (line_input, "%s", &node_to_find))
19590 vec_add1 (node_to_find, 0);
19591 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
19594 print (vam->ofp, "%s not found...", node_to_find);
19597 node = vam->graph_nodes[p[0]];
19598 print (vam->ofp, "[%d] %s", p[0], node->name);
19599 for (j = 0; j < vec_len (node->next_nodes); j++)
19601 if (node->next_nodes[j] != ~0)
19603 next_node = vam->graph_nodes[node->next_nodes[j]];
19604 print (vam->ofp, " [%d] %s", j, next_node->name);
19611 clib_warning ("parse error '%U'", format_unformat_error,
19617 vec_free (node_to_find);
19626 script (vat_main_t * vam)
19628 #if (VPP_API_TEST_BUILTIN==0)
19630 char *save_current_file;
19631 unformat_input_t save_input;
19632 jmp_buf save_jump_buf;
19633 u32 save_line_number;
19635 FILE *new_fp, *save_ifp;
19637 if (unformat (vam->input, "%s", &s))
19639 new_fp = fopen ((char *) s, "r");
19642 errmsg ("Couldn't open script file %s", s);
19649 errmsg ("Missing script name");
19653 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
19654 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
19655 save_ifp = vam->ifp;
19656 save_line_number = vam->input_line_number;
19657 save_current_file = (char *) vam->current_file;
19659 vam->input_line_number = 0;
19661 vam->current_file = s;
19664 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
19665 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
19666 vam->ifp = save_ifp;
19667 vam->input_line_number = save_line_number;
19668 vam->current_file = (u8 *) save_current_file;
19673 clib_warning ("use the exec command...");
19679 echo (vat_main_t * vam)
19681 print (vam->ofp, "%v", vam->input->buffer);
19685 /* List of API message constructors, CLI names map to api_xxx */
19686 #define foreach_vpe_api_msg \
19687 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
19688 _(sw_interface_dump,"") \
19689 _(sw_interface_set_flags, \
19690 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
19691 _(sw_interface_add_del_address, \
19692 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
19693 _(sw_interface_set_table, \
19694 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
19695 _(sw_interface_set_mpls_enable, \
19696 "<intfc> | sw_if_index [disable | dis]") \
19697 _(sw_interface_set_vpath, \
19698 "<intfc> | sw_if_index <id> enable | disable") \
19699 _(sw_interface_set_vxlan_bypass, \
19700 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
19701 _(sw_interface_set_l2_xconnect, \
19702 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
19703 "enable | disable") \
19704 _(sw_interface_set_l2_bridge, \
19705 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
19706 "[shg <split-horizon-group>] [bvi]\n" \
19707 "enable | disable") \
19708 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
19709 _(bridge_domain_add_del, \
19710 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [mac-age 0-255] [del]\n") \
19711 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
19713 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
19714 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
19715 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
19717 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
19719 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
19721 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
19723 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
19725 "<vpp-if-name> | sw_if_index <id>") \
19726 _(sw_interface_tap_dump, "") \
19727 _(ip_add_del_route, \
19728 "<addr>/<mask> via <addr> [table-id <n>]\n" \
19729 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
19730 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
19731 "[multipath] [count <n>]") \
19732 _(ip_mroute_add_del, \
19733 "<src> <grp>/<mask> [table-id <n>]\n" \
19734 "[<intfc> | sw_if_index <id>] [local] [del]") \
19735 _(mpls_route_add_del, \
19736 "<label> <eos> via <addr> [table-id <n>]\n" \
19737 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
19738 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
19739 "[multipath] [count <n>]") \
19740 _(mpls_ip_bind_unbind, \
19741 "<label> <addr/len>") \
19742 _(mpls_tunnel_add_del, \
19743 " via <addr> [table-id <n>]\n" \
19744 "sw_if_index <id>] [l2] [del]") \
19745 _(proxy_arp_add_del, \
19746 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
19747 _(proxy_arp_intfc_enable_disable, \
19748 "<intfc> | sw_if_index <id> enable | disable") \
19749 _(sw_interface_set_unnumbered, \
19750 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
19751 _(ip_neighbor_add_del, \
19752 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
19753 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
19754 _(reset_vrf, "vrf <id> [ipv6]") \
19755 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
19756 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
19757 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
19758 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
19759 "[outer_vlan_id_any][inner_vlan_id_any]") \
19760 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
19761 _(reset_fib, "vrf <n> [ipv6]") \
19762 _(dhcp_proxy_config, \
19763 "svr <v46-address> src <v46-address>\n" \
19764 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
19765 _(dhcp_proxy_set_vss, \
19766 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
19767 _(dhcp_proxy_dump, "ip6") \
19768 _(dhcp_client_config, \
19769 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
19770 _(set_ip_flow_hash, \
19771 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
19772 _(sw_interface_ip6_enable_disable, \
19773 "<intfc> | sw_if_index <id> enable | disable") \
19774 _(sw_interface_ip6_set_link_local_address, \
19775 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
19776 _(ip6nd_proxy_add_del, \
19777 "<intfc> | sw_if_index <id> <ip6-address>") \
19778 _(ip6nd_proxy_dump, "") \
19779 _(sw_interface_ip6nd_ra_prefix, \
19780 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
19781 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
19782 "[nolink] [isno]") \
19783 _(sw_interface_ip6nd_ra_config, \
19784 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
19785 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
19786 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
19787 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
19788 _(l2_patch_add_del, \
19789 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
19790 "enable | disable") \
19791 _(sr_localsid_add_del, \
19792 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
19793 "fib-table <num> (end.psp) sw_if_index <num>") \
19794 _(classify_add_del_table, \
19795 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
19796 " [del] [del-chain] mask <mask-value>\n" \
19797 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
19798 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
19799 _(classify_add_del_session, \
19800 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
19801 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
19802 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
19803 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
19804 _(classify_set_interface_ip_table, \
19805 "<intfc> | sw_if_index <nn> table <nn>") \
19806 _(classify_set_interface_l2_tables, \
19807 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19808 " [other-table <nn>]") \
19809 _(get_node_index, "node <node-name") \
19810 _(add_node_next, "node <node-name> next <next-node-name>") \
19811 _(l2tpv3_create_tunnel, \
19812 "client_address <ip6-addr> our_address <ip6-addr>\n" \
19813 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
19814 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
19815 _(l2tpv3_set_tunnel_cookies, \
19816 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
19817 "[new_remote_cookie <nn>]\n") \
19818 _(l2tpv3_interface_enable_disable, \
19819 "<intfc> | sw_if_index <nn> enable | disable") \
19820 _(l2tpv3_set_lookup_key, \
19821 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
19822 _(sw_if_l2tpv3_tunnel_dump, "") \
19823 _(vxlan_add_del_tunnel, \
19824 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
19825 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
19826 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
19827 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19828 _(gre_add_del_tunnel, \
19829 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
19830 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19831 _(l2_fib_clear_table, "") \
19832 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
19833 _(l2_interface_vlan_tag_rewrite, \
19834 "<intfc> | sw_if_index <nn> \n" \
19835 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
19836 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
19837 _(create_vhost_user_if, \
19838 "socket <filename> [server] [renumber <dev_instance>] " \
19839 "[mac <mac_address>]") \
19840 _(modify_vhost_user_if, \
19841 "<intfc> | sw_if_index <nn> socket <filename>\n" \
19842 "[server] [renumber <dev_instance>]") \
19843 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
19844 _(sw_interface_vhost_user_dump, "") \
19845 _(show_version, "") \
19846 _(vxlan_gpe_add_del_tunnel, \
19847 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
19848 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
19849 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
19850 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
19851 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19852 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
19853 _(interface_name_renumber, \
19854 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
19855 _(input_acl_set_interface, \
19856 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19857 " [l2-table <nn>] [del]") \
19858 _(want_ip4_arp_events, "address <ip4-address> [del]") \
19859 _(want_ip6_nd_events, "address <ip6-address> [del]") \
19860 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
19861 _(ip_dump, "ipv4 | ipv6") \
19862 _(ipsec_spd_add_del, "spd_id <n> [del]") \
19863 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
19865 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
19866 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
19867 " integ_alg <alg> integ_key <hex>") \
19868 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
19869 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
19870 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
19871 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
19872 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
19873 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
19874 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
19875 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
19876 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
19877 _(ikev2_profile_add_del, "name <profile_name> [del]") \
19878 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
19879 "(auth_data 0x<data> | auth_data <data>)") \
19880 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
19881 "(id_data 0x<data> | id_data <data>) (local|remote)") \
19882 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
19883 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
19884 "(local|remote)") \
19885 _(ikev2_set_local_key, "file <absolute_file_path>") \
19886 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
19887 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
19888 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
19889 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
19890 _(ikev2_initiate_sa_init, "<profile_name>") \
19891 _(ikev2_initiate_del_ike_sa, "<ispi>") \
19892 _(ikev2_initiate_del_child_sa, "<ispi>") \
19893 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
19894 _(delete_loopback,"sw_if_index <nn>") \
19895 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
19896 _(map_add_domain, \
19897 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
19898 "ip6-src <ip6addr> " \
19899 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
19900 _(map_del_domain, "index <n>") \
19901 _(map_add_del_rule, \
19902 "index <n> psid <n> dst <ip6addr> [del]") \
19903 _(map_domain_dump, "") \
19904 _(map_rule_dump, "index <map-domain>") \
19905 _(want_interface_events, "enable|disable") \
19906 _(want_stats,"enable|disable") \
19907 _(get_first_msg_id, "client <name>") \
19908 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
19909 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
19910 "fib-id <nn> [ip4][ip6][default]") \
19911 _(get_node_graph, " ") \
19912 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
19913 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
19914 _(ioam_disable, "") \
19915 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
19916 " sw_if_index <sw_if_index> p <priority> " \
19917 "w <weight>] [del]") \
19918 _(one_add_del_locator, "locator-set <locator_name> " \
19919 "iface <intf> | sw_if_index <sw_if_index> " \
19920 "p <priority> w <weight> [del]") \
19921 _(one_add_del_local_eid,"vni <vni> eid " \
19922 "<ipv4|ipv6>/<prefix> | <L2 address> " \
19923 "locator-set <locator_name> [del]" \
19924 "[key-id sha1|sha256 secret-key <secret-key>]")\
19925 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
19926 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
19927 _(one_enable_disable, "enable|disable") \
19928 _(one_map_register_enable_disable, "enable|disable") \
19929 _(one_rloc_probe_enable_disable, "enable|disable") \
19930 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
19932 "rloc <locator> p <prio> " \
19933 "w <weight> [rloc <loc> ... ] " \
19934 "action <action> [del-all]") \
19935 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
19937 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
19938 _(one_use_petr, "ip-address> | disable") \
19939 _(one_map_request_mode, "src-dst|dst-only") \
19940 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
19941 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
19942 _(one_locator_set_dump, "[local | remote]") \
19943 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
19944 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
19945 "[local] | [remote]") \
19946 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
19947 _(one_l2_arp_bd_get, "") \
19948 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
19949 _(one_stats_enable_disable, "enable|disalbe") \
19950 _(show_one_stats_enable_disable, "") \
19951 _(one_eid_table_vni_dump, "") \
19952 _(one_eid_table_map_dump, "l2|l3") \
19953 _(one_map_resolver_dump, "") \
19954 _(one_map_server_dump, "") \
19955 _(one_adjacencies_get, "vni <vni>") \
19956 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
19957 _(show_one_rloc_probe_state, "") \
19958 _(show_one_map_register_state, "") \
19959 _(show_one_status, "") \
19960 _(one_stats_dump, "") \
19961 _(one_stats_flush, "") \
19962 _(one_get_map_request_itr_rlocs, "") \
19963 _(show_one_nsh_mapping, "") \
19964 _(show_one_pitr, "") \
19965 _(show_one_use_petr, "") \
19966 _(show_one_map_request_mode, "") \
19967 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
19968 " sw_if_index <sw_if_index> p <priority> " \
19969 "w <weight>] [del]") \
19970 _(lisp_add_del_locator, "locator-set <locator_name> " \
19971 "iface <intf> | sw_if_index <sw_if_index> " \
19972 "p <priority> w <weight> [del]") \
19973 _(lisp_add_del_local_eid,"vni <vni> eid " \
19974 "<ipv4|ipv6>/<prefix> | <L2 address> " \
19975 "locator-set <locator_name> [del]" \
19976 "[key-id sha1|sha256 secret-key <secret-key>]") \
19977 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
19978 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
19979 _(lisp_enable_disable, "enable|disable") \
19980 _(lisp_map_register_enable_disable, "enable|disable") \
19981 _(lisp_rloc_probe_enable_disable, "enable|disable") \
19982 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
19984 "rloc <locator> p <prio> " \
19985 "w <weight> [rloc <loc> ... ] " \
19986 "action <action> [del-all]") \
19987 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
19989 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
19990 _(lisp_use_petr, "<ip-address> | disable") \
19991 _(lisp_map_request_mode, "src-dst|dst-only") \
19992 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
19993 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
19994 _(lisp_locator_set_dump, "[local | remote]") \
19995 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
19996 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
19997 "[local] | [remote]") \
19998 _(lisp_eid_table_vni_dump, "") \
19999 _(lisp_eid_table_map_dump, "l2|l3") \
20000 _(lisp_map_resolver_dump, "") \
20001 _(lisp_map_server_dump, "") \
20002 _(lisp_adjacencies_get, "vni <vni>") \
20003 _(gpe_fwd_entry_vnis_get, "") \
20004 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
20005 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
20006 "[table <table-id>]") \
20007 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
20008 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
20009 _(gpe_set_encap_mode, "lisp|vxlan") \
20010 _(gpe_get_encap_mode, "") \
20011 _(lisp_gpe_add_del_iface, "up|down") \
20012 _(lisp_gpe_enable_disable, "enable|disable") \
20013 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
20014 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
20015 _(show_lisp_rloc_probe_state, "") \
20016 _(show_lisp_map_register_state, "") \
20017 _(show_lisp_status, "") \
20018 _(lisp_get_map_request_itr_rlocs, "") \
20019 _(show_lisp_pitr, "") \
20020 _(show_lisp_use_petr, "") \
20021 _(show_lisp_map_request_mode, "") \
20022 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
20023 _(af_packet_delete, "name <host interface name>") \
20024 _(policer_add_del, "name <policer name> <params> [del]") \
20025 _(policer_dump, "[name <policer name>]") \
20026 _(policer_classify_set_interface, \
20027 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20028 " [l2-table <nn>] [del]") \
20029 _(policer_classify_dump, "type [ip4|ip6|l2]") \
20030 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
20031 "[master|slave]") \
20032 _(netmap_delete, "name <interface name>") \
20033 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
20034 _(mpls_fib_dump, "") \
20035 _(classify_table_ids, "") \
20036 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
20037 _(classify_table_info, "table_id <nn>") \
20038 _(classify_session_dump, "table_id <nn>") \
20039 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
20040 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
20041 "[template_interval <nn>] [udp_checksum]") \
20042 _(ipfix_exporter_dump, "") \
20043 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
20044 _(ipfix_classify_stream_dump, "") \
20045 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
20046 _(ipfix_classify_table_dump, "") \
20047 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
20048 _(sw_interface_span_dump, "") \
20049 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
20050 _(pg_create_interface, "if_id <nn>") \
20051 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
20052 _(pg_enable_disable, "[stream <id>] disable") \
20053 _(ip_source_and_port_range_check_add_del, \
20054 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
20055 _(ip_source_and_port_range_check_interface_add_del, \
20056 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
20057 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
20058 _(ipsec_gre_add_del_tunnel, \
20059 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
20060 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
20061 _(delete_subif,"<intfc> | sw_if_index <nn>") \
20062 _(l2_interface_pbb_tag_rewrite, \
20063 "<intfc> | sw_if_index <nn> \n" \
20064 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
20065 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
20066 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
20067 _(flow_classify_set_interface, \
20068 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
20069 _(flow_classify_dump, "type [ip4|ip6]") \
20070 _(ip_fib_dump, "") \
20071 _(ip_mfib_dump, "") \
20072 _(ip6_fib_dump, "") \
20073 _(ip6_mfib_dump, "") \
20074 _(feature_enable_disable, "arc_name <arc_name> " \
20075 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
20076 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
20078 _(l2_xconnect_dump, "") \
20079 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
20080 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
20081 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
20082 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
20083 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
20084 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
20085 _(sw_interface_set_lldp, \
20086 "<intfc> | sw_if_index <nn> [port-desc <description>] [disable]")
20088 /* List of command functions, CLI names map directly to functions */
20089 #define foreach_cli_function \
20090 _(comment, "usage: comment <ignore-rest-of-line>") \
20091 _(dump_interface_table, "usage: dump_interface_table") \
20092 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
20093 _(dump_ipv4_table, "usage: dump_ipv4_table") \
20094 _(dump_ipv6_table, "usage: dump_ipv6_table") \
20095 _(dump_stats_table, "usage: dump_stats_table") \
20096 _(dump_macro_table, "usage: dump_macro_table ") \
20097 _(dump_node_table, "usage: dump_node_table") \
20098 _(dump_msg_api_table, "usage: dump_msg_api_table") \
20099 _(get_msg_id, "usage: get_msg_id name_and_crc") \
20100 _(echo, "usage: echo <message>") \
20101 _(exec, "usage: exec <vpe-debug-CLI-command>") \
20102 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
20103 _(help, "usage: help") \
20104 _(q, "usage: quit") \
20105 _(quit, "usage: quit") \
20106 _(search_node_table, "usage: search_node_table <name>...") \
20107 _(set, "usage: set <variable-name> <value>") \
20108 _(script, "usage: script <file-name>") \
20109 _(unset, "usage: unset <variable-name>")
20112 static void vl_api_##n##_t_handler_uni \
20113 (vl_api_##n##_t * mp) \
20115 vat_main_t * vam = &vat_main; \
20116 if (vam->json_output) { \
20117 vl_api_##n##_t_handler_json(mp); \
20119 vl_api_##n##_t_handler(mp); \
20122 foreach_vpe_api_reply_msg;
20123 #if VPP_API_TEST_BUILTIN == 0
20124 foreach_standalone_reply_msg;
20129 vat_api_hookup (vat_main_t * vam)
20132 vl_msg_api_set_handlers(VL_API_##N, #n, \
20133 vl_api_##n##_t_handler_uni, \
20135 vl_api_##n##_t_endian, \
20136 vl_api_##n##_t_print, \
20137 sizeof(vl_api_##n##_t), 1);
20138 foreach_vpe_api_reply_msg;
20139 #if VPP_API_TEST_BUILTIN == 0
20140 foreach_standalone_reply_msg;
20144 #if (VPP_API_TEST_BUILTIN==0)
20145 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
20147 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
20149 vam->function_by_name = hash_create_string (0, sizeof (uword));
20151 vam->help_by_name = hash_create_string (0, sizeof (uword));
20154 /* API messages we can send */
20155 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
20156 foreach_vpe_api_msg;
20160 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
20161 foreach_vpe_api_msg;
20164 /* CLI functions */
20165 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
20166 foreach_cli_function;
20170 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
20171 foreach_cli_function;
20175 #if VPP_API_TEST_BUILTIN
20176 static clib_error_t *
20177 vat_api_hookup_shim (vlib_main_t * vm)
20179 vat_api_hookup (&vat_main);
20183 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
20187 * fd.io coding-style-patch-verification: ON
20190 * eval: (c-set-style "gnu")