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_gre_add_del_tunnel_reply_t_handler
1799 (vl_api_gre_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_gre_add_del_tunnel_reply_t_handler_json
1816 (vl_api_gre_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_create_vhost_user_if_reply_t_handler
1833 (vl_api_create_vhost_user_if_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_create_vhost_user_if_reply_t_handler_json
1850 (vl_api_create_vhost_user_if_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_ip_address_details_t_handler
1867 (vl_api_ip_address_details_t * mp)
1869 vat_main_t *vam = &vat_main;
1870 static ip_address_details_t empty_ip_address_details = { {0} };
1871 ip_address_details_t *address = NULL;
1872 ip_details_t *current_ip_details = NULL;
1873 ip_details_t *details = NULL;
1875 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1877 if (!details || vam->current_sw_if_index >= vec_len (details)
1878 || !details[vam->current_sw_if_index].present)
1880 errmsg ("ip address details arrived but not stored");
1881 errmsg ("ip_dump should be called first");
1885 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1887 #define addresses (current_ip_details->addr)
1889 vec_validate_init_empty (addresses, vec_len (addresses),
1890 empty_ip_address_details);
1892 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1894 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1895 address->prefix_length = mp->prefix_length;
1899 static void vl_api_ip_address_details_t_handler_json
1900 (vl_api_ip_address_details_t * mp)
1902 vat_main_t *vam = &vat_main;
1903 vat_json_node_t *node = NULL;
1904 struct in6_addr ip6;
1907 if (VAT_JSON_ARRAY != vam->json_tree.type)
1909 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1910 vat_json_init_array (&vam->json_tree);
1912 node = vat_json_array_add (&vam->json_tree);
1914 vat_json_init_object (node);
1917 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1918 vat_json_object_add_ip6 (node, "ip", ip6);
1922 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1923 vat_json_object_add_ip4 (node, "ip", ip4);
1925 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1929 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1931 vat_main_t *vam = &vat_main;
1932 static ip_details_t empty_ip_details = { 0 };
1933 ip_details_t *ip = NULL;
1934 u32 sw_if_index = ~0;
1936 sw_if_index = ntohl (mp->sw_if_index);
1938 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1939 sw_if_index, empty_ip_details);
1941 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1948 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1950 vat_main_t *vam = &vat_main;
1952 if (VAT_JSON_ARRAY != vam->json_tree.type)
1954 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1955 vat_json_init_array (&vam->json_tree);
1957 vat_json_array_add_uint (&vam->json_tree,
1958 clib_net_to_host_u32 (mp->sw_if_index));
1961 static void vl_api_map_domain_details_t_handler_json
1962 (vl_api_map_domain_details_t * mp)
1964 vat_json_node_t *node = NULL;
1965 vat_main_t *vam = &vat_main;
1966 struct in6_addr ip6;
1969 if (VAT_JSON_ARRAY != vam->json_tree.type)
1971 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1972 vat_json_init_array (&vam->json_tree);
1975 node = vat_json_array_add (&vam->json_tree);
1976 vat_json_init_object (node);
1978 vat_json_object_add_uint (node, "domain_index",
1979 clib_net_to_host_u32 (mp->domain_index));
1980 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1981 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1982 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1983 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1984 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1985 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1986 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1987 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1988 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1989 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1990 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1991 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1992 vat_json_object_add_uint (node, "flags", mp->flags);
1993 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1994 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1997 static void vl_api_map_domain_details_t_handler
1998 (vl_api_map_domain_details_t * mp)
2000 vat_main_t *vam = &vat_main;
2002 if (mp->is_translation)
2005 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2006 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2007 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2008 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2009 clib_net_to_host_u32 (mp->domain_index));
2014 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2015 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2016 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2017 format_ip6_address, mp->ip6_src,
2018 clib_net_to_host_u32 (mp->domain_index));
2020 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2021 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2022 mp->is_translation ? "map-t" : "");
2025 static void vl_api_map_rule_details_t_handler_json
2026 (vl_api_map_rule_details_t * mp)
2028 struct in6_addr ip6;
2029 vat_json_node_t *node = NULL;
2030 vat_main_t *vam = &vat_main;
2032 if (VAT_JSON_ARRAY != vam->json_tree.type)
2034 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2035 vat_json_init_array (&vam->json_tree);
2038 node = vat_json_array_add (&vam->json_tree);
2039 vat_json_init_object (node);
2041 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2042 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2043 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2047 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2049 vat_main_t *vam = &vat_main;
2050 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2051 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2055 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2057 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2058 "router_addr %U host_mac %U",
2059 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2060 format_ip4_address, &mp->host_address,
2061 format_ip4_address, &mp->router_address,
2062 format_ethernet_address, mp->host_mac);
2065 static void vl_api_dhcp_compl_event_t_handler_json
2066 (vl_api_dhcp_compl_event_t * mp)
2068 /* JSON output not supported */
2072 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2075 vat_main_t *vam = &vat_main;
2076 static u64 default_counter = 0;
2078 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2080 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2081 sw_if_index, default_counter);
2082 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2086 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2087 interface_counter_t counter)
2089 vat_main_t *vam = &vat_main;
2090 static interface_counter_t default_counter = { 0, };
2092 vec_validate_init_empty (vam->combined_interface_counters,
2093 vnet_counter_type, NULL);
2094 vec_validate_init_empty (vam->combined_interface_counters
2095 [vnet_counter_type], sw_if_index, default_counter);
2096 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2099 static void vl_api_vnet_interface_simple_counters_t_handler
2100 (vl_api_vnet_interface_simple_counters_t * mp)
2105 static void vl_api_vnet_interface_combined_counters_t_handler
2106 (vl_api_vnet_interface_combined_counters_t * mp)
2111 static void vl_api_vnet_interface_simple_counters_t_handler_json
2112 (vl_api_vnet_interface_simple_counters_t * mp)
2117 u32 first_sw_if_index;
2120 count = ntohl (mp->count);
2121 first_sw_if_index = ntohl (mp->first_sw_if_index);
2123 v_packets = (u64 *) & mp->data;
2124 for (i = 0; i < count; i++)
2126 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2127 set_simple_interface_counter (mp->vnet_counter_type,
2128 first_sw_if_index + i, packets);
2133 static void vl_api_vnet_interface_combined_counters_t_handler_json
2134 (vl_api_vnet_interface_combined_counters_t * mp)
2136 interface_counter_t counter;
2138 u32 first_sw_if_index;
2142 count = ntohl (mp->count);
2143 first_sw_if_index = ntohl (mp->first_sw_if_index);
2145 v = (vlib_counter_t *) & mp->data;
2146 for (i = 0; i < count; i++)
2149 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2151 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2152 set_combined_interface_counter (mp->vnet_counter_type,
2153 first_sw_if_index + i, counter);
2159 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2161 vat_main_t *vam = &vat_main;
2164 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2166 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2175 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2177 vat_main_t *vam = &vat_main;
2180 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2182 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2190 static void vl_api_vnet_ip4_fib_counters_t_handler
2191 (vl_api_vnet_ip4_fib_counters_t * mp)
2196 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2197 (vl_api_vnet_ip4_fib_counters_t * mp)
2199 vat_main_t *vam = &vat_main;
2200 vl_api_ip4_fib_counter_t *v;
2201 ip4_fib_counter_t *counter;
2208 vrf_id = ntohl (mp->vrf_id);
2209 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2210 if (~0 == vrf_index)
2212 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2213 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2214 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2215 vec_validate (vam->ip4_fib_counters, vrf_index);
2216 vam->ip4_fib_counters[vrf_index] = NULL;
2219 vec_free (vam->ip4_fib_counters[vrf_index]);
2220 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2221 count = ntohl (mp->count);
2222 for (i = 0; i < count; i++)
2224 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2225 counter = &vam->ip4_fib_counters[vrf_index][i];
2226 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2227 counter->address = ip4;
2228 counter->address_length = v->address_length;
2229 counter->packets = clib_net_to_host_u64 (v->packets);
2230 counter->bytes = clib_net_to_host_u64 (v->bytes);
2235 static void vl_api_vnet_ip4_nbr_counters_t_handler
2236 (vl_api_vnet_ip4_nbr_counters_t * mp)
2241 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2242 (vl_api_vnet_ip4_nbr_counters_t * mp)
2244 vat_main_t *vam = &vat_main;
2245 vl_api_ip4_nbr_counter_t *v;
2246 ip4_nbr_counter_t *counter;
2251 sw_if_index = ntohl (mp->sw_if_index);
2252 count = ntohl (mp->count);
2253 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2256 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2258 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2259 for (i = 0; i < count; i++)
2261 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2262 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2263 counter->address.s_addr = v->address;
2264 counter->packets = clib_net_to_host_u64 (v->packets);
2265 counter->bytes = clib_net_to_host_u64 (v->bytes);
2266 counter->linkt = v->link_type;
2271 static void vl_api_vnet_ip6_fib_counters_t_handler
2272 (vl_api_vnet_ip6_fib_counters_t * mp)
2277 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2278 (vl_api_vnet_ip6_fib_counters_t * mp)
2280 vat_main_t *vam = &vat_main;
2281 vl_api_ip6_fib_counter_t *v;
2282 ip6_fib_counter_t *counter;
2283 struct in6_addr ip6;
2289 vrf_id = ntohl (mp->vrf_id);
2290 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2291 if (~0 == vrf_index)
2293 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2294 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2295 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2296 vec_validate (vam->ip6_fib_counters, vrf_index);
2297 vam->ip6_fib_counters[vrf_index] = NULL;
2300 vec_free (vam->ip6_fib_counters[vrf_index]);
2301 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2302 count = ntohl (mp->count);
2303 for (i = 0; i < count; i++)
2305 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2306 counter = &vam->ip6_fib_counters[vrf_index][i];
2307 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2308 counter->address = ip6;
2309 counter->address_length = v->address_length;
2310 counter->packets = clib_net_to_host_u64 (v->packets);
2311 counter->bytes = clib_net_to_host_u64 (v->bytes);
2316 static void vl_api_vnet_ip6_nbr_counters_t_handler
2317 (vl_api_vnet_ip6_nbr_counters_t * mp)
2322 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2323 (vl_api_vnet_ip6_nbr_counters_t * mp)
2325 vat_main_t *vam = &vat_main;
2326 vl_api_ip6_nbr_counter_t *v;
2327 ip6_nbr_counter_t *counter;
2328 struct in6_addr ip6;
2333 sw_if_index = ntohl (mp->sw_if_index);
2334 count = ntohl (mp->count);
2335 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2338 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2340 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2341 for (i = 0; i < count; i++)
2343 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2344 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2345 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2346 counter->address = ip6;
2347 counter->packets = clib_net_to_host_u64 (v->packets);
2348 counter->bytes = clib_net_to_host_u64 (v->bytes);
2353 static void vl_api_get_first_msg_id_reply_t_handler
2354 (vl_api_get_first_msg_id_reply_t * mp)
2356 vat_main_t *vam = &vat_main;
2357 i32 retval = ntohl (mp->retval);
2359 if (vam->async_mode)
2361 vam->async_errors += (retval < 0);
2365 vam->retval = retval;
2366 vam->result_ready = 1;
2370 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2374 static void vl_api_get_first_msg_id_reply_t_handler_json
2375 (vl_api_get_first_msg_id_reply_t * mp)
2377 vat_main_t *vam = &vat_main;
2378 vat_json_node_t node;
2380 vat_json_init_object (&node);
2381 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2382 vat_json_object_add_uint (&node, "first_msg_id",
2383 (uint) ntohs (mp->first_msg_id));
2385 vat_json_print (vam->ofp, &node);
2386 vat_json_free (&node);
2388 vam->retval = ntohl (mp->retval);
2389 vam->result_ready = 1;
2392 static void vl_api_get_node_graph_reply_t_handler
2393 (vl_api_get_node_graph_reply_t * mp)
2395 vat_main_t *vam = &vat_main;
2396 api_main_t *am = &api_main;
2397 i32 retval = ntohl (mp->retval);
2398 u8 *pvt_copy, *reply;
2403 if (vam->async_mode)
2405 vam->async_errors += (retval < 0);
2409 vam->retval = retval;
2410 vam->result_ready = 1;
2413 /* "Should never happen..." */
2417 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2418 pvt_copy = vec_dup (reply);
2420 /* Toss the shared-memory original... */
2421 pthread_mutex_lock (&am->vlib_rp->mutex);
2422 oldheap = svm_push_data_heap (am->vlib_rp);
2426 svm_pop_heap (oldheap);
2427 pthread_mutex_unlock (&am->vlib_rp->mutex);
2429 if (vam->graph_nodes)
2431 hash_free (vam->graph_node_index_by_name);
2433 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2435 node = vam->graph_nodes[i];
2436 vec_free (node->name);
2437 vec_free (node->next_nodes);
2440 vec_free (vam->graph_nodes);
2443 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2444 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2445 vec_free (pvt_copy);
2447 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2449 node = vam->graph_nodes[i];
2450 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2454 static void vl_api_get_node_graph_reply_t_handler_json
2455 (vl_api_get_node_graph_reply_t * mp)
2457 vat_main_t *vam = &vat_main;
2458 api_main_t *am = &api_main;
2460 vat_json_node_t node;
2463 /* $$$$ make this real? */
2464 vat_json_init_object (&node);
2465 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2466 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2468 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2470 /* Toss the shared-memory original... */
2471 pthread_mutex_lock (&am->vlib_rp->mutex);
2472 oldheap = svm_push_data_heap (am->vlib_rp);
2476 svm_pop_heap (oldheap);
2477 pthread_mutex_unlock (&am->vlib_rp->mutex);
2479 vat_json_print (vam->ofp, &node);
2480 vat_json_free (&node);
2482 vam->retval = ntohl (mp->retval);
2483 vam->result_ready = 1;
2487 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2489 vat_main_t *vam = &vat_main;
2494 s = format (s, "%=16d%=16d%=16d",
2495 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2499 s = format (s, "%=16U%=16d%=16d",
2500 mp->is_ipv6 ? format_ip6_address :
2502 mp->ip_address, mp->priority, mp->weight);
2505 print (vam->ofp, "%v", s);
2510 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2512 vat_main_t *vam = &vat_main;
2513 vat_json_node_t *node = NULL;
2514 struct in6_addr ip6;
2517 if (VAT_JSON_ARRAY != vam->json_tree.type)
2519 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2520 vat_json_init_array (&vam->json_tree);
2522 node = vat_json_array_add (&vam->json_tree);
2523 vat_json_init_object (node);
2525 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2526 vat_json_object_add_uint (node, "priority", mp->priority);
2527 vat_json_object_add_uint (node, "weight", mp->weight);
2530 vat_json_object_add_uint (node, "sw_if_index",
2531 clib_net_to_host_u32 (mp->sw_if_index));
2536 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2537 vat_json_object_add_ip6 (node, "address", ip6);
2541 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2542 vat_json_object_add_ip4 (node, "address", ip4);
2548 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2551 vat_main_t *vam = &vat_main;
2554 ls_name = format (0, "%s", mp->ls_name);
2556 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2562 vl_api_one_locator_set_details_t_handler_json
2563 (vl_api_one_locator_set_details_t * mp)
2565 vat_main_t *vam = &vat_main;
2566 vat_json_node_t *node = 0;
2569 ls_name = format (0, "%s", mp->ls_name);
2570 vec_add1 (ls_name, 0);
2572 if (VAT_JSON_ARRAY != vam->json_tree.type)
2574 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2575 vat_json_init_array (&vam->json_tree);
2577 node = vat_json_array_add (&vam->json_tree);
2579 vat_json_init_object (node);
2580 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2581 vat_json_object_add_uint (node, "ls_index",
2582 clib_net_to_host_u32 (mp->ls_index));
2590 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2593 unformat_nsh_address (unformat_input_t * input, va_list * args)
2595 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2596 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2600 format_nsh_address_vat (u8 * s, va_list * args)
2602 nsh_t *a = va_arg (*args, nsh_t *);
2603 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2607 format_lisp_flat_eid (u8 * s, va_list * args)
2609 u32 type = va_arg (*args, u32);
2610 u8 *eid = va_arg (*args, u8 *);
2611 u32 eid_len = va_arg (*args, u32);
2616 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2618 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2620 return format (s, "%U", format_ethernet_address, eid);
2622 return format (s, "%U", format_nsh_address_vat, eid);
2628 format_lisp_eid_vat (u8 * s, va_list * args)
2630 u32 type = va_arg (*args, u32);
2631 u8 *eid = va_arg (*args, u8 *);
2632 u32 eid_len = va_arg (*args, u32);
2633 u8 *seid = va_arg (*args, u8 *);
2634 u32 seid_len = va_arg (*args, u32);
2635 u32 is_src_dst = va_arg (*args, u32);
2638 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2640 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2646 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2648 vat_main_t *vam = &vat_main;
2649 u8 *s = 0, *eid = 0;
2651 if (~0 == mp->locator_set_index)
2652 s = format (0, "action: %d", mp->action);
2654 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2656 eid = format (0, "%U", format_lisp_eid_vat,
2660 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2663 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2664 clib_net_to_host_u32 (mp->vni),
2666 mp->is_local ? "local" : "remote",
2667 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2668 clib_net_to_host_u16 (mp->key_id), mp->key);
2675 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2678 vat_main_t *vam = &vat_main;
2679 vat_json_node_t *node = 0;
2682 if (VAT_JSON_ARRAY != vam->json_tree.type)
2684 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2685 vat_json_init_array (&vam->json_tree);
2687 node = vat_json_array_add (&vam->json_tree);
2689 vat_json_init_object (node);
2690 if (~0 == mp->locator_set_index)
2691 vat_json_object_add_uint (node, "action", mp->action);
2693 vat_json_object_add_uint (node, "locator_set_index",
2694 clib_net_to_host_u32 (mp->locator_set_index));
2696 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2697 if (mp->eid_type == 3)
2699 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
2700 vat_json_init_object (nsh_json);
2701 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
2702 vat_json_object_add_uint (nsh_json, "spi",
2703 clib_net_to_host_u32 (nsh->spi));
2704 vat_json_object_add_uint (nsh_json, "si", nsh->si);
2708 eid = format (0, "%U", format_lisp_eid_vat,
2712 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2714 vat_json_object_add_string_copy (node, "eid", eid);
2717 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2718 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2719 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2723 vat_json_object_add_uint (node, "key_id",
2724 clib_net_to_host_u16 (mp->key_id));
2725 vat_json_object_add_string_copy (node, "key", mp->key);
2730 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
2732 vat_main_t *vam = &vat_main;
2733 u8 *seid = 0, *deid = 0;
2734 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2736 deid = format (0, "%U", format_lisp_eid_vat,
2737 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2739 seid = format (0, "%U", format_lisp_eid_vat,
2740 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2746 format_ip_address_fcn = format_ip4_address;
2748 format_ip_address_fcn = format_ip6_address;
2751 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
2752 clib_net_to_host_u32 (mp->vni),
2754 format_ip_address_fcn, mp->lloc,
2755 format_ip_address_fcn, mp->rloc,
2756 clib_net_to_host_u32 (mp->pkt_count),
2757 clib_net_to_host_u32 (mp->bytes));
2764 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
2766 struct in6_addr ip6;
2768 vat_main_t *vam = &vat_main;
2769 vat_json_node_t *node = 0;
2770 u8 *deid = 0, *seid = 0;
2772 if (VAT_JSON_ARRAY != vam->json_tree.type)
2774 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2775 vat_json_init_array (&vam->json_tree);
2777 node = vat_json_array_add (&vam->json_tree);
2779 vat_json_init_object (node);
2780 deid = format (0, "%U", format_lisp_eid_vat,
2781 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2783 seid = format (0, "%U", format_lisp_eid_vat,
2784 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2789 vat_json_object_add_string_copy (node, "seid", seid);
2790 vat_json_object_add_string_copy (node, "deid", deid);
2791 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2795 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
2796 vat_json_object_add_ip4 (node, "lloc", ip4);
2797 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
2798 vat_json_object_add_ip4 (node, "rloc", ip4);
2802 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
2803 vat_json_object_add_ip6 (node, "lloc", ip6);
2804 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
2805 vat_json_object_add_ip6 (node, "rloc", ip6);
2807 vat_json_object_add_uint (node, "pkt_count",
2808 clib_net_to_host_u32 (mp->pkt_count));
2809 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
2816 vl_api_one_eid_table_map_details_t_handler
2817 (vl_api_one_eid_table_map_details_t * mp)
2819 vat_main_t *vam = &vat_main;
2821 u8 *line = format (0, "%=10d%=10d",
2822 clib_net_to_host_u32 (mp->vni),
2823 clib_net_to_host_u32 (mp->dp_table));
2824 print (vam->ofp, "%v", line);
2829 vl_api_one_eid_table_map_details_t_handler_json
2830 (vl_api_one_eid_table_map_details_t * mp)
2832 vat_main_t *vam = &vat_main;
2833 vat_json_node_t *node = NULL;
2835 if (VAT_JSON_ARRAY != vam->json_tree.type)
2837 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2838 vat_json_init_array (&vam->json_tree);
2840 node = vat_json_array_add (&vam->json_tree);
2841 vat_json_init_object (node);
2842 vat_json_object_add_uint (node, "dp_table",
2843 clib_net_to_host_u32 (mp->dp_table));
2844 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2848 vl_api_one_eid_table_vni_details_t_handler
2849 (vl_api_one_eid_table_vni_details_t * mp)
2851 vat_main_t *vam = &vat_main;
2853 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2854 print (vam->ofp, "%v", line);
2859 vl_api_one_eid_table_vni_details_t_handler_json
2860 (vl_api_one_eid_table_vni_details_t * mp)
2862 vat_main_t *vam = &vat_main;
2863 vat_json_node_t *node = NULL;
2865 if (VAT_JSON_ARRAY != vam->json_tree.type)
2867 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2868 vat_json_init_array (&vam->json_tree);
2870 node = vat_json_array_add (&vam->json_tree);
2871 vat_json_init_object (node);
2872 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2876 vl_api_show_one_map_register_state_reply_t_handler
2877 (vl_api_show_one_map_register_state_reply_t * mp)
2879 vat_main_t *vam = &vat_main;
2880 int retval = clib_net_to_host_u32 (mp->retval);
2882 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2884 vam->retval = retval;
2885 vam->result_ready = 1;
2889 vl_api_show_one_map_register_state_reply_t_handler_json
2890 (vl_api_show_one_map_register_state_reply_t * mp)
2892 vat_main_t *vam = &vat_main;
2893 vat_json_node_t _node, *node = &_node;
2894 int retval = clib_net_to_host_u32 (mp->retval);
2896 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2898 vat_json_init_object (node);
2899 vat_json_object_add_string_copy (node, "state", s);
2901 vat_json_print (vam->ofp, node);
2902 vat_json_free (node);
2904 vam->retval = retval;
2905 vam->result_ready = 1;
2910 vl_api_show_one_rloc_probe_state_reply_t_handler
2911 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2913 vat_main_t *vam = &vat_main;
2914 int retval = clib_net_to_host_u32 (mp->retval);
2919 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2921 vam->retval = retval;
2922 vam->result_ready = 1;
2926 vl_api_show_one_rloc_probe_state_reply_t_handler_json
2927 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2929 vat_main_t *vam = &vat_main;
2930 vat_json_node_t _node, *node = &_node;
2931 int retval = clib_net_to_host_u32 (mp->retval);
2933 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2934 vat_json_init_object (node);
2935 vat_json_object_add_string_copy (node, "state", s);
2937 vat_json_print (vam->ofp, node);
2938 vat_json_free (node);
2940 vam->retval = retval;
2941 vam->result_ready = 1;
2946 vl_api_show_one_stats_enable_disable_reply_t_handler
2947 (vl_api_show_one_stats_enable_disable_reply_t * mp)
2949 vat_main_t *vam = &vat_main;
2950 int retval = clib_net_to_host_u32 (mp->retval);
2955 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
2957 vam->retval = retval;
2958 vam->result_ready = 1;
2962 vl_api_show_one_stats_enable_disable_reply_t_handler_json
2963 (vl_api_show_one_stats_enable_disable_reply_t * mp)
2965 vat_main_t *vam = &vat_main;
2966 vat_json_node_t _node, *node = &_node;
2967 int retval = clib_net_to_host_u32 (mp->retval);
2969 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
2970 vat_json_init_object (node);
2971 vat_json_object_add_string_copy (node, "state", s);
2973 vat_json_print (vam->ofp, node);
2974 vat_json_free (node);
2976 vam->retval = retval;
2977 vam->result_ready = 1;
2982 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
2984 e->dp_table = clib_net_to_host_u32 (e->dp_table);
2985 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
2986 e->vni = clib_net_to_host_u32 (e->vni);
2990 gpe_fwd_entries_get_reply_t_net_to_host
2991 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2995 mp->count = clib_net_to_host_u32 (mp->count);
2996 for (i = 0; i < mp->count; i++)
2998 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3003 format_gpe_encap_mode (u8 * s, va_list * args)
3005 u32 mode = va_arg (*args, u32);
3010 return format (s, "lisp");
3012 return format (s, "vxlan");
3018 vl_api_gpe_get_encap_mode_reply_t_handler
3019 (vl_api_gpe_get_encap_mode_reply_t * mp)
3021 vat_main_t *vam = &vat_main;
3023 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3024 vam->retval = ntohl (mp->retval);
3025 vam->result_ready = 1;
3029 vl_api_gpe_get_encap_mode_reply_t_handler_json
3030 (vl_api_gpe_get_encap_mode_reply_t * mp)
3032 vat_main_t *vam = &vat_main;
3033 vat_json_node_t node;
3035 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3036 vec_add1 (encap_mode, 0);
3038 vat_json_init_object (&node);
3039 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3041 vec_free (encap_mode);
3042 vat_json_print (vam->ofp, &node);
3043 vat_json_free (&node);
3045 vam->retval = ntohl (mp->retval);
3046 vam->result_ready = 1;
3050 vl_api_gpe_fwd_entry_path_details_t_handler
3051 (vl_api_gpe_fwd_entry_path_details_t * mp)
3053 vat_main_t *vam = &vat_main;
3054 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3056 if (mp->lcl_loc.is_ip4)
3057 format_ip_address_fcn = format_ip4_address;
3059 format_ip_address_fcn = format_ip6_address;
3061 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3062 format_ip_address_fcn, &mp->lcl_loc,
3063 format_ip_address_fcn, &mp->rmt_loc);
3067 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3069 struct in6_addr ip6;
3074 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3075 vat_json_object_add_ip4 (n, "address", ip4);
3079 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3080 vat_json_object_add_ip6 (n, "address", ip6);
3082 vat_json_object_add_uint (n, "weight", loc->weight);
3086 vl_api_gpe_fwd_entry_path_details_t_handler_json
3087 (vl_api_gpe_fwd_entry_path_details_t * mp)
3089 vat_main_t *vam = &vat_main;
3090 vat_json_node_t *node = NULL;
3091 vat_json_node_t *loc_node;
3093 if (VAT_JSON_ARRAY != vam->json_tree.type)
3095 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3096 vat_json_init_array (&vam->json_tree);
3098 node = vat_json_array_add (&vam->json_tree);
3099 vat_json_init_object (node);
3101 loc_node = vat_json_object_add (node, "local_locator");
3102 vat_json_init_object (loc_node);
3103 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3105 loc_node = vat_json_object_add (node, "remote_locator");
3106 vat_json_init_object (loc_node);
3107 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3111 vl_api_gpe_fwd_entries_get_reply_t_handler
3112 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3114 vat_main_t *vam = &vat_main;
3116 int retval = clib_net_to_host_u32 (mp->retval);
3117 vl_api_gpe_fwd_entry_t *e;
3122 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3124 for (i = 0; i < mp->count; i++)
3126 e = &mp->entries[i];
3127 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3128 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3129 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3133 vam->retval = retval;
3134 vam->result_ready = 1;
3138 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3139 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3142 vat_main_t *vam = &vat_main;
3143 vat_json_node_t *e = 0, root;
3145 int retval = clib_net_to_host_u32 (mp->retval);
3146 vl_api_gpe_fwd_entry_t *fwd;
3151 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3152 vat_json_init_array (&root);
3154 for (i = 0; i < mp->count; i++)
3156 e = vat_json_array_add (&root);
3157 fwd = &mp->entries[i];
3159 vat_json_init_object (e);
3160 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3161 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3162 vat_json_object_add_int (e, "vni", fwd->vni);
3163 vat_json_object_add_int (e, "action", fwd->action);
3165 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3166 fwd->leid_prefix_len);
3168 vat_json_object_add_string_copy (e, "leid", s);
3171 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3172 fwd->reid_prefix_len);
3174 vat_json_object_add_string_copy (e, "reid", s);
3178 vat_json_print (vam->ofp, &root);
3179 vat_json_free (&root);
3182 vam->retval = retval;
3183 vam->result_ready = 1;
3187 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3188 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3190 vat_main_t *vam = &vat_main;
3192 int retval = clib_net_to_host_u32 (mp->retval);
3193 vl_api_gpe_native_fwd_rpath_t *r;
3198 n = clib_net_to_host_u32 (mp->count);
3200 for (i = 0; i < n; i++)
3202 r = &mp->entries[i];
3203 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3204 clib_net_to_host_u32 (r->fib_index),
3205 clib_net_to_host_u32 (r->nh_sw_if_index),
3206 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3210 vam->retval = retval;
3211 vam->result_ready = 1;
3215 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3216 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3218 vat_main_t *vam = &vat_main;
3219 vat_json_node_t root, *e;
3221 int retval = clib_net_to_host_u32 (mp->retval);
3222 vl_api_gpe_native_fwd_rpath_t *r;
3228 n = clib_net_to_host_u32 (mp->count);
3229 vat_json_init_array (&root);
3231 for (i = 0; i < n; i++)
3233 e = vat_json_array_add (&root);
3234 vat_json_init_object (e);
3235 r = &mp->entries[i];
3237 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3240 vat_json_object_add_string_copy (e, "ip4", s);
3243 vat_json_object_add_uint (e, "fib_index",
3244 clib_net_to_host_u32 (r->fib_index));
3245 vat_json_object_add_uint (e, "nh_sw_if_index",
3246 clib_net_to_host_u32 (r->nh_sw_if_index));
3249 vat_json_print (vam->ofp, &root);
3250 vat_json_free (&root);
3253 vam->retval = retval;
3254 vam->result_ready = 1;
3258 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3259 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3261 vat_main_t *vam = &vat_main;
3263 int retval = clib_net_to_host_u32 (mp->retval);
3268 n = clib_net_to_host_u32 (mp->count);
3270 for (i = 0; i < n; i++)
3271 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3274 vam->retval = retval;
3275 vam->result_ready = 1;
3279 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3280 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3282 vat_main_t *vam = &vat_main;
3283 vat_json_node_t root;
3285 int retval = clib_net_to_host_u32 (mp->retval);
3290 n = clib_net_to_host_u32 (mp->count);
3291 vat_json_init_array (&root);
3293 for (i = 0; i < n; i++)
3294 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3296 vat_json_print (vam->ofp, &root);
3297 vat_json_free (&root);
3300 vam->retval = retval;
3301 vam->result_ready = 1;
3305 vl_api_one_l2_arp_entries_get_reply_t_handler
3306 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3308 vat_main_t *vam = &vat_main;
3310 int retval = clib_net_to_host_u32 (mp->retval);
3315 n = clib_net_to_host_u32 (mp->count);
3317 for (i = 0; i < n; i++)
3318 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3319 format_ethernet_address, mp->entries[i].mac);
3322 vam->retval = retval;
3323 vam->result_ready = 1;
3327 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3328 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3331 vat_main_t *vam = &vat_main;
3332 vat_json_node_t *e = 0, root;
3334 int retval = clib_net_to_host_u32 (mp->retval);
3335 vl_api_one_l2_arp_entry_t *arp_entry;
3340 n = clib_net_to_host_u32 (mp->count);
3341 vat_json_init_array (&root);
3343 for (i = 0; i < n; i++)
3345 e = vat_json_array_add (&root);
3346 arp_entry = &mp->entries[i];
3348 vat_json_init_object (e);
3349 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3352 vat_json_object_add_string_copy (e, "mac", s);
3355 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3357 vat_json_object_add_string_copy (e, "ip4", s);
3361 vat_json_print (vam->ofp, &root);
3362 vat_json_free (&root);
3365 vam->retval = retval;
3366 vam->result_ready = 1;
3370 vl_api_one_l2_arp_bd_get_reply_t_handler
3371 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3373 vat_main_t *vam = &vat_main;
3375 int retval = clib_net_to_host_u32 (mp->retval);
3380 n = clib_net_to_host_u32 (mp->count);
3382 for (i = 0; i < n; i++)
3384 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3388 vam->retval = retval;
3389 vam->result_ready = 1;
3393 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3394 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3396 vat_main_t *vam = &vat_main;
3397 vat_json_node_t root;
3399 int retval = clib_net_to_host_u32 (mp->retval);
3404 n = clib_net_to_host_u32 (mp->count);
3405 vat_json_init_array (&root);
3407 for (i = 0; i < n; i++)
3409 vat_json_array_add_uint (&root,
3410 clib_net_to_host_u32 (mp->bridge_domains[i]));
3413 vat_json_print (vam->ofp, &root);
3414 vat_json_free (&root);
3417 vam->retval = retval;
3418 vam->result_ready = 1;
3422 vl_api_one_adjacencies_get_reply_t_handler
3423 (vl_api_one_adjacencies_get_reply_t * mp)
3425 vat_main_t *vam = &vat_main;
3427 int retval = clib_net_to_host_u32 (mp->retval);
3428 vl_api_one_adjacency_t *a;
3433 n = clib_net_to_host_u32 (mp->count);
3435 for (i = 0; i < n; i++)
3437 a = &mp->adjacencies[i];
3438 print (vam->ofp, "%U %40U",
3439 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3440 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3444 vam->retval = retval;
3445 vam->result_ready = 1;
3449 vl_api_one_adjacencies_get_reply_t_handler_json
3450 (vl_api_one_adjacencies_get_reply_t * mp)
3453 vat_main_t *vam = &vat_main;
3454 vat_json_node_t *e = 0, root;
3456 int retval = clib_net_to_host_u32 (mp->retval);
3457 vl_api_one_adjacency_t *a;
3462 n = clib_net_to_host_u32 (mp->count);
3463 vat_json_init_array (&root);
3465 for (i = 0; i < n; i++)
3467 e = vat_json_array_add (&root);
3468 a = &mp->adjacencies[i];
3470 vat_json_init_object (e);
3471 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3472 a->leid_prefix_len);
3474 vat_json_object_add_string_copy (e, "leid", s);
3477 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3478 a->reid_prefix_len);
3480 vat_json_object_add_string_copy (e, "reid", s);
3484 vat_json_print (vam->ofp, &root);
3485 vat_json_free (&root);
3488 vam->retval = retval;
3489 vam->result_ready = 1;
3493 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3495 vat_main_t *vam = &vat_main;
3497 print (vam->ofp, "%=20U",
3498 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3503 vl_api_one_map_server_details_t_handler_json
3504 (vl_api_one_map_server_details_t * mp)
3506 vat_main_t *vam = &vat_main;
3507 vat_json_node_t *node = NULL;
3508 struct in6_addr ip6;
3511 if (VAT_JSON_ARRAY != vam->json_tree.type)
3513 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3514 vat_json_init_array (&vam->json_tree);
3516 node = vat_json_array_add (&vam->json_tree);
3518 vat_json_init_object (node);
3521 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3522 vat_json_object_add_ip6 (node, "map-server", ip6);
3526 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3527 vat_json_object_add_ip4 (node, "map-server", ip4);
3532 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3535 vat_main_t *vam = &vat_main;
3537 print (vam->ofp, "%=20U",
3538 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3543 vl_api_one_map_resolver_details_t_handler_json
3544 (vl_api_one_map_resolver_details_t * mp)
3546 vat_main_t *vam = &vat_main;
3547 vat_json_node_t *node = NULL;
3548 struct in6_addr ip6;
3551 if (VAT_JSON_ARRAY != vam->json_tree.type)
3553 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3554 vat_json_init_array (&vam->json_tree);
3556 node = vat_json_array_add (&vam->json_tree);
3558 vat_json_init_object (node);
3561 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3562 vat_json_object_add_ip6 (node, "map resolver", ip6);
3566 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3567 vat_json_object_add_ip4 (node, "map resolver", ip4);
3572 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3574 vat_main_t *vam = &vat_main;
3575 i32 retval = ntohl (mp->retval);
3579 print (vam->ofp, "feature: %s\ngpe: %s",
3580 mp->feature_status ? "enabled" : "disabled",
3581 mp->gpe_status ? "enabled" : "disabled");
3584 vam->retval = retval;
3585 vam->result_ready = 1;
3589 vl_api_show_one_status_reply_t_handler_json
3590 (vl_api_show_one_status_reply_t * mp)
3592 vat_main_t *vam = &vat_main;
3593 vat_json_node_t node;
3594 u8 *gpe_status = NULL;
3595 u8 *feature_status = NULL;
3597 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3598 feature_status = format (0, "%s",
3599 mp->feature_status ? "enabled" : "disabled");
3600 vec_add1 (gpe_status, 0);
3601 vec_add1 (feature_status, 0);
3603 vat_json_init_object (&node);
3604 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3605 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3607 vec_free (gpe_status);
3608 vec_free (feature_status);
3610 vat_json_print (vam->ofp, &node);
3611 vat_json_free (&node);
3613 vam->retval = ntohl (mp->retval);
3614 vam->result_ready = 1;
3618 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3619 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3621 vat_main_t *vam = &vat_main;
3622 i32 retval = ntohl (mp->retval);
3626 print (vam->ofp, "%=20s", mp->locator_set_name);
3629 vam->retval = retval;
3630 vam->result_ready = 1;
3634 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3635 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3637 vat_main_t *vam = &vat_main;
3638 vat_json_node_t *node = NULL;
3640 if (VAT_JSON_ARRAY != vam->json_tree.type)
3642 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3643 vat_json_init_array (&vam->json_tree);
3645 node = vat_json_array_add (&vam->json_tree);
3647 vat_json_init_object (node);
3648 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3650 vat_json_print (vam->ofp, node);
3651 vat_json_free (node);
3653 vam->retval = ntohl (mp->retval);
3654 vam->result_ready = 1;
3658 format_lisp_map_request_mode (u8 * s, va_list * args)
3660 u32 mode = va_arg (*args, u32);
3665 return format (0, "dst-only");
3667 return format (0, "src-dst");
3673 vl_api_show_one_map_request_mode_reply_t_handler
3674 (vl_api_show_one_map_request_mode_reply_t * mp)
3676 vat_main_t *vam = &vat_main;
3677 i32 retval = ntohl (mp->retval);
3681 u32 mode = mp->mode;
3682 print (vam->ofp, "map_request_mode: %U",
3683 format_lisp_map_request_mode, mode);
3686 vam->retval = retval;
3687 vam->result_ready = 1;
3691 vl_api_show_one_map_request_mode_reply_t_handler_json
3692 (vl_api_show_one_map_request_mode_reply_t * mp)
3694 vat_main_t *vam = &vat_main;
3695 vat_json_node_t node;
3700 s = format (0, "%U", format_lisp_map_request_mode, mode);
3703 vat_json_init_object (&node);
3704 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3705 vat_json_print (vam->ofp, &node);
3706 vat_json_free (&node);
3709 vam->retval = ntohl (mp->retval);
3710 vam->result_ready = 1;
3714 vl_api_show_one_use_petr_reply_t_handler
3715 (vl_api_show_one_use_petr_reply_t * mp)
3717 vat_main_t *vam = &vat_main;
3718 i32 retval = ntohl (mp->retval);
3722 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
3725 print (vam->ofp, "Proxy-ETR address; %U",
3726 mp->is_ip4 ? format_ip4_address : format_ip6_address,
3731 vam->retval = retval;
3732 vam->result_ready = 1;
3736 vl_api_show_one_use_petr_reply_t_handler_json
3737 (vl_api_show_one_use_petr_reply_t * mp)
3739 vat_main_t *vam = &vat_main;
3740 vat_json_node_t node;
3743 struct in6_addr ip6;
3745 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3746 vec_add1 (status, 0);
3748 vat_json_init_object (&node);
3749 vat_json_object_add_string_copy (&node, "status", status);
3754 clib_memcpy (&ip6, mp->address, sizeof (ip6));
3755 vat_json_object_add_ip6 (&node, "address", ip6);
3759 clib_memcpy (&ip4, mp->address, sizeof (ip4));
3760 vat_json_object_add_ip4 (&node, "address", ip4);
3766 vat_json_print (vam->ofp, &node);
3767 vat_json_free (&node);
3769 vam->retval = ntohl (mp->retval);
3770 vam->result_ready = 1;
3774 vl_api_show_one_nsh_mapping_reply_t_handler
3775 (vl_api_show_one_nsh_mapping_reply_t * mp)
3777 vat_main_t *vam = &vat_main;
3778 i32 retval = ntohl (mp->retval);
3782 print (vam->ofp, "%-20s%-16s",
3783 mp->is_set ? "set" : "not-set",
3784 mp->is_set ? (char *) mp->locator_set_name : "");
3787 vam->retval = retval;
3788 vam->result_ready = 1;
3792 vl_api_show_one_nsh_mapping_reply_t_handler_json
3793 (vl_api_show_one_nsh_mapping_reply_t * mp)
3795 vat_main_t *vam = &vat_main;
3796 vat_json_node_t node;
3799 status = format (0, "%s", mp->is_set ? "yes" : "no");
3800 vec_add1 (status, 0);
3802 vat_json_init_object (&node);
3803 vat_json_object_add_string_copy (&node, "is_set", status);
3806 vat_json_object_add_string_copy (&node, "locator_set",
3807 mp->locator_set_name);
3812 vat_json_print (vam->ofp, &node);
3813 vat_json_free (&node);
3815 vam->retval = ntohl (mp->retval);
3816 vam->result_ready = 1;
3820 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3822 vat_main_t *vam = &vat_main;
3823 i32 retval = ntohl (mp->retval);
3827 print (vam->ofp, "%-20s%-16s",
3828 mp->status ? "enabled" : "disabled",
3829 mp->status ? (char *) mp->locator_set_name : "");
3832 vam->retval = retval;
3833 vam->result_ready = 1;
3837 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3839 vat_main_t *vam = &vat_main;
3840 vat_json_node_t node;
3843 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3844 vec_add1 (status, 0);
3846 vat_json_init_object (&node);
3847 vat_json_object_add_string_copy (&node, "status", status);
3850 vat_json_object_add_string_copy (&node, "locator_set",
3851 mp->locator_set_name);
3856 vat_json_print (vam->ofp, &node);
3857 vat_json_free (&node);
3859 vam->retval = ntohl (mp->retval);
3860 vam->result_ready = 1;
3864 format_policer_type (u8 * s, va_list * va)
3866 u32 i = va_arg (*va, u32);
3868 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3869 s = format (s, "1r2c");
3870 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3871 s = format (s, "1r3c");
3872 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3873 s = format (s, "2r3c-2698");
3874 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3875 s = format (s, "2r3c-4115");
3876 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3877 s = format (s, "2r3c-mef5cf1");
3879 s = format (s, "ILLEGAL");
3884 format_policer_rate_type (u8 * s, va_list * va)
3886 u32 i = va_arg (*va, u32);
3888 if (i == SSE2_QOS_RATE_KBPS)
3889 s = format (s, "kbps");
3890 else if (i == SSE2_QOS_RATE_PPS)
3891 s = format (s, "pps");
3893 s = format (s, "ILLEGAL");
3898 format_policer_round_type (u8 * s, va_list * va)
3900 u32 i = va_arg (*va, u32);
3902 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3903 s = format (s, "closest");
3904 else if (i == SSE2_QOS_ROUND_TO_UP)
3905 s = format (s, "up");
3906 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3907 s = format (s, "down");
3909 s = format (s, "ILLEGAL");
3914 format_policer_action_type (u8 * s, va_list * va)
3916 u32 i = va_arg (*va, u32);
3918 if (i == SSE2_QOS_ACTION_DROP)
3919 s = format (s, "drop");
3920 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3921 s = format (s, "transmit");
3922 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3923 s = format (s, "mark-and-transmit");
3925 s = format (s, "ILLEGAL");
3930 format_dscp (u8 * s, va_list * va)
3932 u32 i = va_arg (*va, u32);
3937 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3941 return format (s, "ILLEGAL");
3943 s = format (s, "%s", t);
3948 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3950 vat_main_t *vam = &vat_main;
3951 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3953 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3954 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3956 conform_dscp_str = format (0, "");
3958 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3959 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3961 exceed_dscp_str = format (0, "");
3963 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3964 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3966 violate_dscp_str = format (0, "");
3968 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3969 "rate type %U, round type %U, %s rate, %s color-aware, "
3970 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3971 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3972 "conform action %U%s, exceed action %U%s, violate action %U%s",
3974 format_policer_type, mp->type,
3977 clib_net_to_host_u64 (mp->cb),
3978 clib_net_to_host_u64 (mp->eb),
3979 format_policer_rate_type, mp->rate_type,
3980 format_policer_round_type, mp->round_type,
3981 mp->single_rate ? "single" : "dual",
3982 mp->color_aware ? "is" : "not",
3983 ntohl (mp->cir_tokens_per_period),
3984 ntohl (mp->pir_tokens_per_period),
3986 ntohl (mp->current_limit),
3987 ntohl (mp->current_bucket),
3988 ntohl (mp->extended_limit),
3989 ntohl (mp->extended_bucket),
3990 clib_net_to_host_u64 (mp->last_update_time),
3991 format_policer_action_type, mp->conform_action_type,
3993 format_policer_action_type, mp->exceed_action_type,
3995 format_policer_action_type, mp->violate_action_type,
3998 vec_free (conform_dscp_str);
3999 vec_free (exceed_dscp_str);
4000 vec_free (violate_dscp_str);
4003 static void vl_api_policer_details_t_handler_json
4004 (vl_api_policer_details_t * mp)
4006 vat_main_t *vam = &vat_main;
4007 vat_json_node_t *node;
4008 u8 *rate_type_str, *round_type_str, *type_str;
4009 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4011 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4013 format (0, "%U", format_policer_round_type, mp->round_type);
4014 type_str = format (0, "%U", format_policer_type, mp->type);
4015 conform_action_str = format (0, "%U", format_policer_action_type,
4016 mp->conform_action_type);
4017 exceed_action_str = format (0, "%U", format_policer_action_type,
4018 mp->exceed_action_type);
4019 violate_action_str = format (0, "%U", format_policer_action_type,
4020 mp->violate_action_type);
4022 if (VAT_JSON_ARRAY != vam->json_tree.type)
4024 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4025 vat_json_init_array (&vam->json_tree);
4027 node = vat_json_array_add (&vam->json_tree);
4029 vat_json_init_object (node);
4030 vat_json_object_add_string_copy (node, "name", mp->name);
4031 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4032 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4033 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4034 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4035 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4036 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4037 vat_json_object_add_string_copy (node, "type", type_str);
4038 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4039 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4040 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4041 vat_json_object_add_uint (node, "cir_tokens_per_period",
4042 ntohl (mp->cir_tokens_per_period));
4043 vat_json_object_add_uint (node, "eir_tokens_per_period",
4044 ntohl (mp->pir_tokens_per_period));
4045 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4046 vat_json_object_add_uint (node, "current_bucket",
4047 ntohl (mp->current_bucket));
4048 vat_json_object_add_uint (node, "extended_limit",
4049 ntohl (mp->extended_limit));
4050 vat_json_object_add_uint (node, "extended_bucket",
4051 ntohl (mp->extended_bucket));
4052 vat_json_object_add_uint (node, "last_update_time",
4053 ntohl (mp->last_update_time));
4054 vat_json_object_add_string_copy (node, "conform_action",
4055 conform_action_str);
4056 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4058 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4059 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4060 vec_free (dscp_str);
4062 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4063 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4065 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4066 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4067 vec_free (dscp_str);
4069 vat_json_object_add_string_copy (node, "violate_action",
4070 violate_action_str);
4071 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4073 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4074 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4075 vec_free (dscp_str);
4078 vec_free (rate_type_str);
4079 vec_free (round_type_str);
4080 vec_free (type_str);
4081 vec_free (conform_action_str);
4082 vec_free (exceed_action_str);
4083 vec_free (violate_action_str);
4087 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4090 vat_main_t *vam = &vat_main;
4091 int i, count = ntohl (mp->count);
4094 print (vam->ofp, "classify table ids (%d) : ", count);
4095 for (i = 0; i < count; i++)
4097 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4098 print (vam->ofp, (i < count - 1) ? "," : "");
4100 vam->retval = ntohl (mp->retval);
4101 vam->result_ready = 1;
4105 vl_api_classify_table_ids_reply_t_handler_json
4106 (vl_api_classify_table_ids_reply_t * mp)
4108 vat_main_t *vam = &vat_main;
4109 int i, count = ntohl (mp->count);
4113 vat_json_node_t node;
4115 vat_json_init_object (&node);
4116 for (i = 0; i < count; i++)
4118 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4120 vat_json_print (vam->ofp, &node);
4121 vat_json_free (&node);
4123 vam->retval = ntohl (mp->retval);
4124 vam->result_ready = 1;
4128 vl_api_classify_table_by_interface_reply_t_handler
4129 (vl_api_classify_table_by_interface_reply_t * mp)
4131 vat_main_t *vam = &vat_main;
4134 table_id = ntohl (mp->l2_table_id);
4136 print (vam->ofp, "l2 table id : %d", table_id);
4138 print (vam->ofp, "l2 table id : No input ACL tables configured");
4139 table_id = ntohl (mp->ip4_table_id);
4141 print (vam->ofp, "ip4 table id : %d", table_id);
4143 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4144 table_id = ntohl (mp->ip6_table_id);
4146 print (vam->ofp, "ip6 table id : %d", table_id);
4148 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4149 vam->retval = ntohl (mp->retval);
4150 vam->result_ready = 1;
4154 vl_api_classify_table_by_interface_reply_t_handler_json
4155 (vl_api_classify_table_by_interface_reply_t * mp)
4157 vat_main_t *vam = &vat_main;
4158 vat_json_node_t node;
4160 vat_json_init_object (&node);
4162 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4163 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4164 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4166 vat_json_print (vam->ofp, &node);
4167 vat_json_free (&node);
4169 vam->retval = ntohl (mp->retval);
4170 vam->result_ready = 1;
4173 static void vl_api_policer_add_del_reply_t_handler
4174 (vl_api_policer_add_del_reply_t * mp)
4176 vat_main_t *vam = &vat_main;
4177 i32 retval = ntohl (mp->retval);
4178 if (vam->async_mode)
4180 vam->async_errors += (retval < 0);
4184 vam->retval = retval;
4185 vam->result_ready = 1;
4186 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4188 * Note: this is just barely thread-safe, depends on
4189 * the main thread spinning waiting for an answer...
4191 errmsg ("policer index %d", ntohl (mp->policer_index));
4195 static void vl_api_policer_add_del_reply_t_handler_json
4196 (vl_api_policer_add_del_reply_t * mp)
4198 vat_main_t *vam = &vat_main;
4199 vat_json_node_t node;
4201 vat_json_init_object (&node);
4202 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4203 vat_json_object_add_uint (&node, "policer_index",
4204 ntohl (mp->policer_index));
4206 vat_json_print (vam->ofp, &node);
4207 vat_json_free (&node);
4209 vam->retval = ntohl (mp->retval);
4210 vam->result_ready = 1;
4213 /* Format hex dump. */
4215 format_hex_bytes (u8 * s, va_list * va)
4217 u8 *bytes = va_arg (*va, u8 *);
4218 int n_bytes = va_arg (*va, int);
4221 /* Print short or long form depending on byte count. */
4222 uword short_form = n_bytes <= 32;
4223 uword indent = format_get_indent (s);
4228 for (i = 0; i < n_bytes; i++)
4230 if (!short_form && (i % 32) == 0)
4231 s = format (s, "%08x: ", i);
4232 s = format (s, "%02x", bytes[i]);
4233 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4234 s = format (s, "\n%U", format_white_space, indent);
4241 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4244 vat_main_t *vam = &vat_main;
4245 i32 retval = ntohl (mp->retval);
4248 print (vam->ofp, "classify table info :");
4249 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4250 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4251 ntohl (mp->miss_next_index));
4252 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4253 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4254 ntohl (mp->match_n_vectors));
4255 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4256 ntohl (mp->mask_length));
4258 vam->retval = retval;
4259 vam->result_ready = 1;
4263 vl_api_classify_table_info_reply_t_handler_json
4264 (vl_api_classify_table_info_reply_t * mp)
4266 vat_main_t *vam = &vat_main;
4267 vat_json_node_t node;
4269 i32 retval = ntohl (mp->retval);
4272 vat_json_init_object (&node);
4274 vat_json_object_add_int (&node, "sessions",
4275 ntohl (mp->active_sessions));
4276 vat_json_object_add_int (&node, "nexttbl",
4277 ntohl (mp->next_table_index));
4278 vat_json_object_add_int (&node, "nextnode",
4279 ntohl (mp->miss_next_index));
4280 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4281 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4282 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4283 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4284 ntohl (mp->mask_length), 0);
4285 vat_json_object_add_string_copy (&node, "mask", s);
4287 vat_json_print (vam->ofp, &node);
4288 vat_json_free (&node);
4290 vam->retval = ntohl (mp->retval);
4291 vam->result_ready = 1;
4295 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4298 vat_main_t *vam = &vat_main;
4300 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4301 ntohl (mp->hit_next_index), ntohl (mp->advance),
4302 ntohl (mp->opaque_index));
4303 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4304 ntohl (mp->match_length));
4308 vl_api_classify_session_details_t_handler_json
4309 (vl_api_classify_session_details_t * mp)
4311 vat_main_t *vam = &vat_main;
4312 vat_json_node_t *node = NULL;
4314 if (VAT_JSON_ARRAY != vam->json_tree.type)
4316 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4317 vat_json_init_array (&vam->json_tree);
4319 node = vat_json_array_add (&vam->json_tree);
4321 vat_json_init_object (node);
4322 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4323 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4324 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4326 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4328 vat_json_object_add_string_copy (node, "match", s);
4331 static void vl_api_pg_create_interface_reply_t_handler
4332 (vl_api_pg_create_interface_reply_t * mp)
4334 vat_main_t *vam = &vat_main;
4336 vam->retval = ntohl (mp->retval);
4337 vam->result_ready = 1;
4340 static void vl_api_pg_create_interface_reply_t_handler_json
4341 (vl_api_pg_create_interface_reply_t * mp)
4343 vat_main_t *vam = &vat_main;
4344 vat_json_node_t node;
4346 i32 retval = ntohl (mp->retval);
4349 vat_json_init_object (&node);
4351 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4353 vat_json_print (vam->ofp, &node);
4354 vat_json_free (&node);
4356 vam->retval = ntohl (mp->retval);
4357 vam->result_ready = 1;
4360 static void vl_api_policer_classify_details_t_handler
4361 (vl_api_policer_classify_details_t * mp)
4363 vat_main_t *vam = &vat_main;
4365 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4366 ntohl (mp->table_index));
4369 static void vl_api_policer_classify_details_t_handler_json
4370 (vl_api_policer_classify_details_t * mp)
4372 vat_main_t *vam = &vat_main;
4373 vat_json_node_t *node;
4375 if (VAT_JSON_ARRAY != vam->json_tree.type)
4377 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4378 vat_json_init_array (&vam->json_tree);
4380 node = vat_json_array_add (&vam->json_tree);
4382 vat_json_init_object (node);
4383 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4384 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4387 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4388 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4390 vat_main_t *vam = &vat_main;
4391 i32 retval = ntohl (mp->retval);
4392 if (vam->async_mode)
4394 vam->async_errors += (retval < 0);
4398 vam->retval = retval;
4399 vam->sw_if_index = ntohl (mp->sw_if_index);
4400 vam->result_ready = 1;
4404 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4405 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4407 vat_main_t *vam = &vat_main;
4408 vat_json_node_t node;
4410 vat_json_init_object (&node);
4411 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4412 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4414 vat_json_print (vam->ofp, &node);
4415 vat_json_free (&node);
4417 vam->retval = ntohl (mp->retval);
4418 vam->result_ready = 1;
4421 static void vl_api_flow_classify_details_t_handler
4422 (vl_api_flow_classify_details_t * mp)
4424 vat_main_t *vam = &vat_main;
4426 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4427 ntohl (mp->table_index));
4430 static void vl_api_flow_classify_details_t_handler_json
4431 (vl_api_flow_classify_details_t * mp)
4433 vat_main_t *vam = &vat_main;
4434 vat_json_node_t *node;
4436 if (VAT_JSON_ARRAY != vam->json_tree.type)
4438 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4439 vat_json_init_array (&vam->json_tree);
4441 node = vat_json_array_add (&vam->json_tree);
4443 vat_json_init_object (node);
4444 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4445 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4448 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
4449 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
4450 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
4451 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
4452 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4453 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4454 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4455 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4456 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4457 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4458 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4459 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4460 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4461 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4462 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
4463 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
4464 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
4465 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
4468 * Generate boilerplate reply handlers, which
4469 * dig the return value out of the xxx_reply_t API message,
4470 * stick it into vam->retval, and set vam->result_ready
4472 * Could also do this by pointing N message decode slots at
4473 * a single function, but that could break in subtle ways.
4476 #define foreach_standard_reply_retval_handler \
4477 _(sw_interface_set_flags_reply) \
4478 _(sw_interface_add_del_address_reply) \
4479 _(sw_interface_set_table_reply) \
4480 _(sw_interface_set_mpls_enable_reply) \
4481 _(sw_interface_set_vpath_reply) \
4482 _(sw_interface_set_vxlan_bypass_reply) \
4483 _(sw_interface_set_l2_bridge_reply) \
4484 _(bridge_domain_add_del_reply) \
4485 _(sw_interface_set_l2_xconnect_reply) \
4486 _(l2fib_add_del_reply) \
4487 _(l2fib_flush_int_reply) \
4488 _(l2fib_flush_bd_reply) \
4489 _(ip_add_del_route_reply) \
4490 _(ip_mroute_add_del_reply) \
4491 _(mpls_route_add_del_reply) \
4492 _(mpls_ip_bind_unbind_reply) \
4493 _(proxy_arp_add_del_reply) \
4494 _(proxy_arp_intfc_enable_disable_reply) \
4495 _(sw_interface_set_unnumbered_reply) \
4496 _(ip_neighbor_add_del_reply) \
4497 _(reset_vrf_reply) \
4498 _(oam_add_del_reply) \
4499 _(reset_fib_reply) \
4500 _(dhcp_proxy_config_reply) \
4501 _(dhcp_proxy_set_vss_reply) \
4502 _(dhcp_client_config_reply) \
4503 _(set_ip_flow_hash_reply) \
4504 _(sw_interface_ip6_enable_disable_reply) \
4505 _(sw_interface_ip6_set_link_local_address_reply) \
4506 _(ip6nd_proxy_add_del_reply) \
4507 _(sw_interface_ip6nd_ra_prefix_reply) \
4508 _(sw_interface_ip6nd_ra_config_reply) \
4509 _(set_arp_neighbor_limit_reply) \
4510 _(l2_patch_add_del_reply) \
4511 _(sr_policy_add_reply) \
4512 _(sr_policy_mod_reply) \
4513 _(sr_policy_del_reply) \
4514 _(sr_localsid_add_del_reply) \
4515 _(sr_steering_add_del_reply) \
4516 _(classify_add_del_session_reply) \
4517 _(classify_set_interface_ip_table_reply) \
4518 _(classify_set_interface_l2_tables_reply) \
4519 _(l2tpv3_set_tunnel_cookies_reply) \
4520 _(l2tpv3_interface_enable_disable_reply) \
4521 _(l2tpv3_set_lookup_key_reply) \
4522 _(l2_fib_clear_table_reply) \
4523 _(l2_interface_efp_filter_reply) \
4524 _(l2_interface_vlan_tag_rewrite_reply) \
4525 _(modify_vhost_user_if_reply) \
4526 _(delete_vhost_user_if_reply) \
4527 _(want_ip4_arp_events_reply) \
4528 _(want_ip6_nd_events_reply) \
4529 _(input_acl_set_interface_reply) \
4530 _(ipsec_spd_add_del_reply) \
4531 _(ipsec_interface_add_del_spd_reply) \
4532 _(ipsec_spd_add_del_entry_reply) \
4533 _(ipsec_sad_add_del_entry_reply) \
4534 _(ipsec_sa_set_key_reply) \
4535 _(ipsec_tunnel_if_add_del_reply) \
4536 _(ikev2_profile_add_del_reply) \
4537 _(ikev2_profile_set_auth_reply) \
4538 _(ikev2_profile_set_id_reply) \
4539 _(ikev2_profile_set_ts_reply) \
4540 _(ikev2_set_local_key_reply) \
4541 _(ikev2_set_responder_reply) \
4542 _(ikev2_set_ike_transforms_reply) \
4543 _(ikev2_set_esp_transforms_reply) \
4544 _(ikev2_set_sa_lifetime_reply) \
4545 _(ikev2_initiate_sa_init_reply) \
4546 _(ikev2_initiate_del_ike_sa_reply) \
4547 _(ikev2_initiate_del_child_sa_reply) \
4548 _(ikev2_initiate_rekey_child_sa_reply) \
4549 _(delete_loopback_reply) \
4550 _(bd_ip_mac_add_del_reply) \
4551 _(map_del_domain_reply) \
4552 _(map_add_del_rule_reply) \
4553 _(want_interface_events_reply) \
4554 _(want_stats_reply) \
4555 _(cop_interface_enable_disable_reply) \
4556 _(cop_whitelist_enable_disable_reply) \
4557 _(sw_interface_clear_stats_reply) \
4558 _(ioam_enable_reply) \
4559 _(ioam_disable_reply) \
4560 _(one_add_del_locator_reply) \
4561 _(one_add_del_local_eid_reply) \
4562 _(one_add_del_remote_mapping_reply) \
4563 _(one_add_del_adjacency_reply) \
4564 _(one_add_del_map_resolver_reply) \
4565 _(one_add_del_map_server_reply) \
4566 _(one_enable_disable_reply) \
4567 _(one_rloc_probe_enable_disable_reply) \
4568 _(one_map_register_enable_disable_reply) \
4569 _(one_pitr_set_locator_set_reply) \
4570 _(one_map_request_mode_reply) \
4571 _(one_add_del_map_request_itr_rlocs_reply) \
4572 _(one_eid_table_add_del_map_reply) \
4573 _(one_use_petr_reply) \
4574 _(one_stats_enable_disable_reply) \
4575 _(one_add_del_l2_arp_entry_reply) \
4576 _(one_stats_flush_reply) \
4577 _(gpe_enable_disable_reply) \
4578 _(gpe_set_encap_mode_reply) \
4579 _(gpe_add_del_iface_reply) \
4580 _(gpe_add_del_native_fwd_rpath_reply) \
4581 _(vxlan_gpe_add_del_tunnel_reply) \
4582 _(af_packet_delete_reply) \
4583 _(policer_classify_set_interface_reply) \
4584 _(netmap_create_reply) \
4585 _(netmap_delete_reply) \
4586 _(set_ipfix_exporter_reply) \
4587 _(set_ipfix_classify_stream_reply) \
4588 _(ipfix_classify_table_add_del_reply) \
4589 _(flow_classify_set_interface_reply) \
4590 _(sw_interface_span_enable_disable_reply) \
4591 _(pg_capture_reply) \
4592 _(pg_enable_disable_reply) \
4593 _(ip_source_and_port_range_check_add_del_reply) \
4594 _(ip_source_and_port_range_check_interface_add_del_reply)\
4595 _(delete_subif_reply) \
4596 _(l2_interface_pbb_tag_rewrite_reply) \
4598 _(feature_enable_disable_reply) \
4599 _(sw_interface_tag_add_del_reply) \
4600 _(sw_interface_set_mtu_reply) \
4601 _(p2p_ethernet_add_reply) \
4602 _(p2p_ethernet_del_reply)
4605 static void vl_api_##n##_t_handler \
4606 (vl_api_##n##_t * mp) \
4608 vat_main_t * vam = &vat_main; \
4609 i32 retval = ntohl(mp->retval); \
4610 if (vam->async_mode) { \
4611 vam->async_errors += (retval < 0); \
4613 vam->retval = retval; \
4614 vam->result_ready = 1; \
4617 foreach_standard_reply_retval_handler;
4621 static void vl_api_##n##_t_handler_json \
4622 (vl_api_##n##_t * mp) \
4624 vat_main_t * vam = &vat_main; \
4625 vat_json_node_t node; \
4626 vat_json_init_object(&node); \
4627 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4628 vat_json_print(vam->ofp, &node); \
4629 vam->retval = ntohl(mp->retval); \
4630 vam->result_ready = 1; \
4632 foreach_standard_reply_retval_handler;
4636 * Table of message reply handlers, must include boilerplate handlers
4640 #define foreach_vpe_api_reply_msg \
4641 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4642 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4643 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4644 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4645 _(CONTROL_PING_REPLY, control_ping_reply) \
4646 _(CLI_REPLY, cli_reply) \
4647 _(CLI_INBAND_REPLY, cli_inband_reply) \
4648 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4649 sw_interface_add_del_address_reply) \
4650 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4651 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4652 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4653 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4654 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4655 sw_interface_set_l2_xconnect_reply) \
4656 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4657 sw_interface_set_l2_bridge_reply) \
4658 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4659 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4660 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
4661 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4662 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
4663 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
4664 _(L2_FLAGS_REPLY, l2_flags_reply) \
4665 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4666 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4667 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4668 _(TAP_DELETE_REPLY, tap_delete_reply) \
4669 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4670 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4671 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4672 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4673 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4674 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4675 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4676 proxy_arp_intfc_enable_disable_reply) \
4677 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4678 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4679 sw_interface_set_unnumbered_reply) \
4680 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4681 _(RESET_VRF_REPLY, reset_vrf_reply) \
4682 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4683 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4684 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4685 _(RESET_FIB_REPLY, reset_fib_reply) \
4686 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4687 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4688 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4689 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4690 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4691 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4692 sw_interface_ip6_enable_disable_reply) \
4693 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4694 sw_interface_ip6_set_link_local_address_reply) \
4695 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
4696 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
4697 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4698 sw_interface_ip6nd_ra_prefix_reply) \
4699 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4700 sw_interface_ip6nd_ra_config_reply) \
4701 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4702 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4703 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4704 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4705 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4706 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4707 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4708 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4709 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4710 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4711 classify_set_interface_ip_table_reply) \
4712 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4713 classify_set_interface_l2_tables_reply) \
4714 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4715 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4716 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4717 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4718 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4719 l2tpv3_interface_enable_disable_reply) \
4720 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4721 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4722 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4723 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4724 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4725 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4726 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4727 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4728 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4729 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4730 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4731 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4732 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4733 _(SHOW_VERSION_REPLY, show_version_reply) \
4734 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
4735 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4736 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4737 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4738 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4739 _(IP4_ARP_EVENT, ip4_arp_event) \
4740 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4741 _(IP6_ND_EVENT, ip6_nd_event) \
4742 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4743 _(IP_ADDRESS_DETAILS, ip_address_details) \
4744 _(IP_DETAILS, ip_details) \
4745 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4746 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4747 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4748 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4749 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4750 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
4751 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4752 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4753 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4754 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4755 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4756 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4757 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4758 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4759 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4760 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4761 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4762 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4763 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4764 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4765 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4766 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4767 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4768 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4769 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4770 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4771 _(MAP_RULE_DETAILS, map_rule_details) \
4772 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4773 _(WANT_STATS_REPLY, want_stats_reply) \
4774 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4775 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4776 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4777 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4778 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4779 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4780 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4781 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4782 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4783 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4784 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4785 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4786 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4787 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4788 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4789 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4790 one_map_register_enable_disable_reply) \
4791 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4792 one_rloc_probe_enable_disable_reply) \
4793 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4794 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
4795 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4796 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4797 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4798 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4799 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4800 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4801 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4802 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4803 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4804 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4805 _(ONE_STATS_DETAILS, one_stats_details) \
4806 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
4807 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
4808 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
4809 show_one_stats_enable_disable_reply) \
4810 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
4811 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
4812 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
4813 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4814 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4815 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4816 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4817 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4818 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
4819 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4820 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
4821 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
4822 gpe_add_del_native_fwd_rpath_reply) \
4823 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4824 gpe_fwd_entry_path_details) \
4825 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4826 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4827 one_add_del_map_request_itr_rlocs_reply) \
4828 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4829 one_get_map_request_itr_rlocs_reply) \
4830 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
4831 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4832 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
4833 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4834 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4835 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4836 show_one_map_register_state_reply) \
4837 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4838 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4839 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4840 _(POLICER_DETAILS, policer_details) \
4841 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4842 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4843 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4844 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4845 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4846 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4847 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4848 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4849 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4850 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4851 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4852 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4853 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4854 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4855 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4856 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4857 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4858 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4859 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4860 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4861 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4862 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4863 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4864 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4865 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4866 ip_source_and_port_range_check_add_del_reply) \
4867 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4868 ip_source_and_port_range_check_interface_add_del_reply) \
4869 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4870 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4871 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4872 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4873 _(PUNT_REPLY, punt_reply) \
4874 _(IP_FIB_DETAILS, ip_fib_details) \
4875 _(IP6_FIB_DETAILS, ip6_fib_details) \
4876 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4877 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4878 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4879 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4880 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4881 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
4882 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
4883 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply)
4885 #define foreach_standalone_reply_msg \
4886 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4887 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
4888 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
4889 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4890 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4891 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4892 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
4901 #define STR_VTR_OP_CASE(op) \
4902 case L2_VTR_ ## op: \
4906 str_vtr_op (u32 vtr_op)
4910 STR_VTR_OP_CASE (DISABLED);
4911 STR_VTR_OP_CASE (PUSH_1);
4912 STR_VTR_OP_CASE (PUSH_2);
4913 STR_VTR_OP_CASE (POP_1);
4914 STR_VTR_OP_CASE (POP_2);
4915 STR_VTR_OP_CASE (TRANSLATE_1_1);
4916 STR_VTR_OP_CASE (TRANSLATE_1_2);
4917 STR_VTR_OP_CASE (TRANSLATE_2_1);
4918 STR_VTR_OP_CASE (TRANSLATE_2_2);
4925 dump_sub_interface_table (vat_main_t * vam)
4927 const sw_interface_subif_t *sub = NULL;
4929 if (vam->json_output)
4932 ("JSON output supported only for VPE API calls and dump_stats_table");
4937 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4938 "Interface", "sw_if_index",
4939 "sub id", "dot1ad", "tags", "outer id",
4940 "inner id", "exact", "default", "outer any", "inner any");
4942 vec_foreach (sub, vam->sw_if_subif_table)
4945 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4946 sub->interface_name,
4948 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4949 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4950 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4951 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4952 if (sub->vtr_op != L2_VTR_DISABLED)
4955 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4956 "tag1: %d tag2: %d ]",
4957 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4958 sub->vtr_tag1, sub->vtr_tag2);
4966 name_sort_cmp (void *a1, void *a2)
4968 name_sort_t *n1 = a1;
4969 name_sort_t *n2 = a2;
4971 return strcmp ((char *) n1->name, (char *) n2->name);
4975 dump_interface_table (vat_main_t * vam)
4978 name_sort_t *nses = 0, *ns;
4980 if (vam->json_output)
4983 ("JSON output supported only for VPE API calls and dump_stats_table");
4988 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4990 vec_add2 (nses, ns, 1);
4991 ns->name = (u8 *)(p->key);
4992 ns->value = (u32) p->value[0];
4996 vec_sort_with_function (nses, name_sort_cmp);
4998 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4999 vec_foreach (ns, nses)
5001 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5008 dump_ip_table (vat_main_t * vam, int is_ipv6)
5010 const ip_details_t *det = NULL;
5011 const ip_address_details_t *address = NULL;
5014 print (vam->ofp, "%-12s", "sw_if_index");
5016 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5023 print (vam->ofp, "%-12d", i);
5024 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5029 vec_foreach (address, det->addr)
5033 is_ipv6 ? format_ip6_address : format_ip4_address,
5034 address->ip, address->prefix_length);
5042 dump_ipv4_table (vat_main_t * vam)
5044 if (vam->json_output)
5047 ("JSON output supported only for VPE API calls and dump_stats_table");
5051 return dump_ip_table (vam, 0);
5055 dump_ipv6_table (vat_main_t * vam)
5057 if (vam->json_output)
5060 ("JSON output supported only for VPE API calls and dump_stats_table");
5064 return dump_ip_table (vam, 1);
5068 counter_type_to_str (u8 counter_type, u8 is_combined)
5072 switch (counter_type)
5074 case VNET_INTERFACE_COUNTER_DROP:
5076 case VNET_INTERFACE_COUNTER_PUNT:
5078 case VNET_INTERFACE_COUNTER_IP4:
5080 case VNET_INTERFACE_COUNTER_IP6:
5082 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5084 case VNET_INTERFACE_COUNTER_RX_MISS:
5086 case VNET_INTERFACE_COUNTER_RX_ERROR:
5088 case VNET_INTERFACE_COUNTER_TX_ERROR:
5091 return "INVALID-COUNTER-TYPE";
5096 switch (counter_type)
5098 case VNET_INTERFACE_COUNTER_RX:
5100 case VNET_INTERFACE_COUNTER_TX:
5103 return "INVALID-COUNTER-TYPE";
5109 dump_stats_table (vat_main_t * vam)
5111 vat_json_node_t node;
5112 vat_json_node_t *msg_array;
5113 vat_json_node_t *msg;
5114 vat_json_node_t *counter_array;
5115 vat_json_node_t *counter;
5116 interface_counter_t c;
5118 ip4_fib_counter_t *c4;
5119 ip6_fib_counter_t *c6;
5120 ip4_nbr_counter_t *n4;
5121 ip6_nbr_counter_t *n6;
5124 if (!vam->json_output)
5126 clib_warning ("dump_stats_table supported only in JSON format");
5130 vat_json_init_object (&node);
5132 /* interface counters */
5133 msg_array = vat_json_object_add (&node, "interface_counters");
5134 vat_json_init_array (msg_array);
5135 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5137 msg = vat_json_array_add (msg_array);
5138 vat_json_init_object (msg);
5139 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5140 (u8 *) counter_type_to_str (i, 0));
5141 vat_json_object_add_int (msg, "is_combined", 0);
5142 counter_array = vat_json_object_add (msg, "data");
5143 vat_json_init_array (counter_array);
5144 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5146 packets = vam->simple_interface_counters[i][j];
5147 vat_json_array_add_uint (counter_array, packets);
5150 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5152 msg = vat_json_array_add (msg_array);
5153 vat_json_init_object (msg);
5154 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5155 (u8 *) counter_type_to_str (i, 1));
5156 vat_json_object_add_int (msg, "is_combined", 1);
5157 counter_array = vat_json_object_add (msg, "data");
5158 vat_json_init_array (counter_array);
5159 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5161 c = vam->combined_interface_counters[i][j];
5162 counter = vat_json_array_add (counter_array);
5163 vat_json_init_object (counter);
5164 vat_json_object_add_uint (counter, "packets", c.packets);
5165 vat_json_object_add_uint (counter, "bytes", c.bytes);
5169 /* ip4 fib counters */
5170 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5171 vat_json_init_array (msg_array);
5172 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5174 msg = vat_json_array_add (msg_array);
5175 vat_json_init_object (msg);
5176 vat_json_object_add_uint (msg, "vrf_id",
5177 vam->ip4_fib_counters_vrf_id_by_index[i]);
5178 counter_array = vat_json_object_add (msg, "c");
5179 vat_json_init_array (counter_array);
5180 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5182 counter = vat_json_array_add (counter_array);
5183 vat_json_init_object (counter);
5184 c4 = &vam->ip4_fib_counters[i][j];
5185 vat_json_object_add_ip4 (counter, "address", c4->address);
5186 vat_json_object_add_uint (counter, "address_length",
5187 c4->address_length);
5188 vat_json_object_add_uint (counter, "packets", c4->packets);
5189 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5193 /* ip6 fib counters */
5194 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5195 vat_json_init_array (msg_array);
5196 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5198 msg = vat_json_array_add (msg_array);
5199 vat_json_init_object (msg);
5200 vat_json_object_add_uint (msg, "vrf_id",
5201 vam->ip6_fib_counters_vrf_id_by_index[i]);
5202 counter_array = vat_json_object_add (msg, "c");
5203 vat_json_init_array (counter_array);
5204 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5206 counter = vat_json_array_add (counter_array);
5207 vat_json_init_object (counter);
5208 c6 = &vam->ip6_fib_counters[i][j];
5209 vat_json_object_add_ip6 (counter, "address", c6->address);
5210 vat_json_object_add_uint (counter, "address_length",
5211 c6->address_length);
5212 vat_json_object_add_uint (counter, "packets", c6->packets);
5213 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5217 /* ip4 nbr counters */
5218 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5219 vat_json_init_array (msg_array);
5220 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5222 msg = vat_json_array_add (msg_array);
5223 vat_json_init_object (msg);
5224 vat_json_object_add_uint (msg, "sw_if_index", i);
5225 counter_array = vat_json_object_add (msg, "c");
5226 vat_json_init_array (counter_array);
5227 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5229 counter = vat_json_array_add (counter_array);
5230 vat_json_init_object (counter);
5231 n4 = &vam->ip4_nbr_counters[i][j];
5232 vat_json_object_add_ip4 (counter, "address", n4->address);
5233 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5234 vat_json_object_add_uint (counter, "packets", n4->packets);
5235 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5239 /* ip6 nbr counters */
5240 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5241 vat_json_init_array (msg_array);
5242 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5244 msg = vat_json_array_add (msg_array);
5245 vat_json_init_object (msg);
5246 vat_json_object_add_uint (msg, "sw_if_index", i);
5247 counter_array = vat_json_object_add (msg, "c");
5248 vat_json_init_array (counter_array);
5249 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5251 counter = vat_json_array_add (counter_array);
5252 vat_json_init_object (counter);
5253 n6 = &vam->ip6_nbr_counters[i][j];
5254 vat_json_object_add_ip6 (counter, "address", n6->address);
5255 vat_json_object_add_uint (counter, "packets", n6->packets);
5256 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5260 vat_json_print (vam->ofp, &node);
5261 vat_json_free (&node);
5267 exec (vat_main_t * vam)
5269 api_main_t *am = &api_main;
5274 unformat_input_t *i = vam->input;
5276 if (vec_len (i->buffer) == 0)
5279 if (vam->exec_mode == 0 && unformat (i, "mode"))
5284 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5294 * Copy cmd into shared memory.
5295 * In order for the CLI command to work, it
5296 * must be a vector ending in \n, not a C-string ending
5299 pthread_mutex_lock (&am->vlib_rp->mutex);
5300 oldheap = svm_push_data_heap (am->vlib_rp);
5302 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
5303 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
5305 svm_pop_heap (oldheap);
5306 pthread_mutex_unlock (&am->vlib_rp->mutex);
5308 mp->cmd_in_shmem = pointer_to_uword (cmd);
5310 timeout = vat_time_now (vam) + 10.0;
5312 while (vat_time_now (vam) < timeout)
5314 if (vam->result_ready == 1)
5317 if (vam->shmem_result != NULL)
5318 print (vam->ofp, "%s", vam->shmem_result);
5319 pthread_mutex_lock (&am->vlib_rp->mutex);
5320 oldheap = svm_push_data_heap (am->vlib_rp);
5322 free_me = (u8 *) vam->shmem_result;
5325 svm_pop_heap (oldheap);
5326 pthread_mutex_unlock (&am->vlib_rp->mutex);
5334 * Future replacement of exec() that passes CLI buffers directly in
5335 * the API messages instead of an additional shared memory area.
5338 exec_inband (vat_main_t * vam)
5340 vl_api_cli_inband_t *mp;
5341 unformat_input_t *i = vam->input;
5344 if (vec_len (i->buffer) == 0)
5347 if (vam->exec_mode == 0 && unformat (i, "mode"))
5352 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5359 * In order for the CLI command to work, it
5360 * must be a vector ending in \n, not a C-string ending
5363 u32 len = vec_len (vam->input->buffer);
5364 M2 (CLI_INBAND, mp, len);
5365 clib_memcpy (mp->cmd, vam->input->buffer, len);
5366 mp->length = htonl (len);
5369 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
5374 api_create_loopback (vat_main_t * vam)
5376 unformat_input_t *i = vam->input;
5377 vl_api_create_loopback_t *mp;
5378 vl_api_create_loopback_instance_t *mp_lbi;
5381 u8 is_specified = 0;
5382 u32 user_instance = 0;
5385 memset (mac_address, 0, sizeof (mac_address));
5387 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5389 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5391 if (unformat (i, "instance %d", &user_instance))
5399 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5400 mp_lbi->is_specified = is_specified;
5402 mp_lbi->user_instance = htonl (user_instance);
5404 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5409 /* Construct the API message */
5410 M (CREATE_LOOPBACK, mp);
5412 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5421 api_delete_loopback (vat_main_t * vam)
5423 unformat_input_t *i = vam->input;
5424 vl_api_delete_loopback_t *mp;
5425 u32 sw_if_index = ~0;
5428 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5430 if (unformat (i, "sw_if_index %d", &sw_if_index))
5436 if (sw_if_index == ~0)
5438 errmsg ("missing sw_if_index");
5442 /* Construct the API message */
5443 M (DELETE_LOOPBACK, mp);
5444 mp->sw_if_index = ntohl (sw_if_index);
5452 api_want_stats (vat_main_t * vam)
5454 unformat_input_t *i = vam->input;
5455 vl_api_want_stats_t *mp;
5459 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5461 if (unformat (i, "enable"))
5463 else if (unformat (i, "disable"))
5471 errmsg ("missing enable|disable");
5476 mp->enable_disable = enable;
5484 api_want_interface_events (vat_main_t * vam)
5486 unformat_input_t *i = vam->input;
5487 vl_api_want_interface_events_t *mp;
5491 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5493 if (unformat (i, "enable"))
5495 else if (unformat (i, "disable"))
5503 errmsg ("missing enable|disable");
5507 M (WANT_INTERFACE_EVENTS, mp);
5508 mp->enable_disable = enable;
5510 vam->interface_event_display = enable;
5518 /* Note: non-static, called once to set up the initial intfc table */
5520 api_sw_interface_dump (vat_main_t * vam)
5522 vl_api_sw_interface_dump_t *mp;
5523 vl_api_control_ping_t *mp_ping;
5525 name_sort_t *nses = 0, *ns;
5526 sw_interface_subif_t *sub = NULL;
5529 /* Toss the old name table */
5531 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5533 vec_add2 (nses, ns, 1);
5534 ns->name = (u8 *)(p->key);
5535 ns->value = (u32) p->value[0];
5539 hash_free (vam->sw_if_index_by_interface_name);
5541 vec_foreach (ns, nses) vec_free (ns->name);
5545 vec_foreach (sub, vam->sw_if_subif_table)
5547 vec_free (sub->interface_name);
5549 vec_free (vam->sw_if_subif_table);
5551 /* recreate the interface name hash table */
5552 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5554 /* Get list of ethernets */
5555 M (SW_INTERFACE_DUMP, mp);
5556 mp->name_filter_valid = 1;
5557 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
5560 /* and local / loopback interfaces */
5561 M (SW_INTERFACE_DUMP, mp);
5562 mp->name_filter_valid = 1;
5563 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
5566 /* and packet-generator interfaces */
5567 M (SW_INTERFACE_DUMP, mp);
5568 mp->name_filter_valid = 1;
5569 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
5572 /* and vxlan-gpe tunnel interfaces */
5573 M (SW_INTERFACE_DUMP, mp);
5574 mp->name_filter_valid = 1;
5575 strncpy ((char *) mp->name_filter, "vxlan_gpe",
5576 sizeof (mp->name_filter) - 1);
5579 /* and vxlan tunnel interfaces */
5580 M (SW_INTERFACE_DUMP, mp);
5581 mp->name_filter_valid = 1;
5582 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
5585 /* and host (af_packet) interfaces */
5586 M (SW_INTERFACE_DUMP, mp);
5587 mp->name_filter_valid = 1;
5588 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
5591 /* and l2tpv3 tunnel interfaces */
5592 M (SW_INTERFACE_DUMP, mp);
5593 mp->name_filter_valid = 1;
5594 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
5595 sizeof (mp->name_filter) - 1);
5598 /* and GRE tunnel interfaces */
5599 M (SW_INTERFACE_DUMP, mp);
5600 mp->name_filter_valid = 1;
5601 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
5604 /* and LISP-GPE interfaces */
5605 M (SW_INTERFACE_DUMP, mp);
5606 mp->name_filter_valid = 1;
5607 strncpy ((char *) mp->name_filter, "lisp_gpe",
5608 sizeof (mp->name_filter) - 1);
5611 /* and IPSEC tunnel interfaces */
5612 M (SW_INTERFACE_DUMP, mp);
5613 mp->name_filter_valid = 1;
5614 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
5617 /* Use a control ping for synchronization */
5618 M (CONTROL_PING, mp_ping);
5626 api_sw_interface_set_flags (vat_main_t * vam)
5628 unformat_input_t *i = vam->input;
5629 vl_api_sw_interface_set_flags_t *mp;
5631 u8 sw_if_index_set = 0;
5632 u8 admin_up = 0, link_up = 0;
5635 /* Parse args required to build the message */
5636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5638 if (unformat (i, "admin-up"))
5640 else if (unformat (i, "admin-down"))
5642 else if (unformat (i, "link-up"))
5644 else if (unformat (i, "link-down"))
5647 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5648 sw_if_index_set = 1;
5649 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5650 sw_if_index_set = 1;
5655 if (sw_if_index_set == 0)
5657 errmsg ("missing interface name or sw_if_index");
5661 /* Construct the API message */
5662 M (SW_INTERFACE_SET_FLAGS, mp);
5663 mp->sw_if_index = ntohl (sw_if_index);
5664 mp->admin_up_down = admin_up;
5665 mp->link_up_down = link_up;
5670 /* Wait for a reply, return the good/bad news... */
5676 api_sw_interface_clear_stats (vat_main_t * vam)
5678 unformat_input_t *i = vam->input;
5679 vl_api_sw_interface_clear_stats_t *mp;
5681 u8 sw_if_index_set = 0;
5684 /* Parse args required to build the message */
5685 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5687 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5688 sw_if_index_set = 1;
5689 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5690 sw_if_index_set = 1;
5695 /* Construct the API message */
5696 M (SW_INTERFACE_CLEAR_STATS, mp);
5698 if (sw_if_index_set == 1)
5699 mp->sw_if_index = ntohl (sw_if_index);
5701 mp->sw_if_index = ~0;
5706 /* Wait for a reply, return the good/bad news... */
5712 api_sw_interface_add_del_address (vat_main_t * vam)
5714 unformat_input_t *i = vam->input;
5715 vl_api_sw_interface_add_del_address_t *mp;
5717 u8 sw_if_index_set = 0;
5718 u8 is_add = 1, del_all = 0;
5719 u32 address_length = 0;
5720 u8 v4_address_set = 0;
5721 u8 v6_address_set = 0;
5722 ip4_address_t v4address;
5723 ip6_address_t v6address;
5726 /* Parse args required to build the message */
5727 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5729 if (unformat (i, "del-all"))
5731 else if (unformat (i, "del"))
5734 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5735 sw_if_index_set = 1;
5736 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5737 sw_if_index_set = 1;
5738 else if (unformat (i, "%U/%d",
5739 unformat_ip4_address, &v4address, &address_length))
5741 else if (unformat (i, "%U/%d",
5742 unformat_ip6_address, &v6address, &address_length))
5748 if (sw_if_index_set == 0)
5750 errmsg ("missing interface name or sw_if_index");
5753 if (v4_address_set && v6_address_set)
5755 errmsg ("both v4 and v6 addresses set");
5758 if (!v4_address_set && !v6_address_set && !del_all)
5760 errmsg ("no addresses set");
5764 /* Construct the API message */
5765 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5767 mp->sw_if_index = ntohl (sw_if_index);
5768 mp->is_add = is_add;
5769 mp->del_all = del_all;
5773 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5777 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5779 mp->address_length = address_length;
5784 /* Wait for a reply, return good/bad news */
5790 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5792 unformat_input_t *i = vam->input;
5793 vl_api_sw_interface_set_mpls_enable_t *mp;
5795 u8 sw_if_index_set = 0;
5799 /* Parse args required to build the message */
5800 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5802 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5803 sw_if_index_set = 1;
5804 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5805 sw_if_index_set = 1;
5806 else if (unformat (i, "disable"))
5808 else if (unformat (i, "dis"))
5814 if (sw_if_index_set == 0)
5816 errmsg ("missing interface name or sw_if_index");
5820 /* Construct the API message */
5821 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5823 mp->sw_if_index = ntohl (sw_if_index);
5824 mp->enable = enable;
5829 /* Wait for a reply... */
5835 api_sw_interface_set_table (vat_main_t * vam)
5837 unformat_input_t *i = vam->input;
5838 vl_api_sw_interface_set_table_t *mp;
5839 u32 sw_if_index, vrf_id = 0;
5840 u8 sw_if_index_set = 0;
5844 /* Parse args required to build the message */
5845 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5847 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5848 sw_if_index_set = 1;
5849 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5850 sw_if_index_set = 1;
5851 else if (unformat (i, "vrf %d", &vrf_id))
5853 else if (unformat (i, "ipv6"))
5859 if (sw_if_index_set == 0)
5861 errmsg ("missing interface name or sw_if_index");
5865 /* Construct the API message */
5866 M (SW_INTERFACE_SET_TABLE, mp);
5868 mp->sw_if_index = ntohl (sw_if_index);
5869 mp->is_ipv6 = is_ipv6;
5870 mp->vrf_id = ntohl (vrf_id);
5875 /* Wait for a reply... */
5880 static void vl_api_sw_interface_get_table_reply_t_handler
5881 (vl_api_sw_interface_get_table_reply_t * mp)
5883 vat_main_t *vam = &vat_main;
5885 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5887 vam->retval = ntohl (mp->retval);
5888 vam->result_ready = 1;
5892 static void vl_api_sw_interface_get_table_reply_t_handler_json
5893 (vl_api_sw_interface_get_table_reply_t * mp)
5895 vat_main_t *vam = &vat_main;
5896 vat_json_node_t node;
5898 vat_json_init_object (&node);
5899 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5900 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5902 vat_json_print (vam->ofp, &node);
5903 vat_json_free (&node);
5905 vam->retval = ntohl (mp->retval);
5906 vam->result_ready = 1;
5910 api_sw_interface_get_table (vat_main_t * vam)
5912 unformat_input_t *i = vam->input;
5913 vl_api_sw_interface_get_table_t *mp;
5915 u8 sw_if_index_set = 0;
5919 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5921 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5922 sw_if_index_set = 1;
5923 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5924 sw_if_index_set = 1;
5925 else if (unformat (i, "ipv6"))
5931 if (sw_if_index_set == 0)
5933 errmsg ("missing interface name or sw_if_index");
5937 M (SW_INTERFACE_GET_TABLE, mp);
5938 mp->sw_if_index = htonl (sw_if_index);
5939 mp->is_ipv6 = is_ipv6;
5947 api_sw_interface_set_vpath (vat_main_t * vam)
5949 unformat_input_t *i = vam->input;
5950 vl_api_sw_interface_set_vpath_t *mp;
5951 u32 sw_if_index = 0;
5952 u8 sw_if_index_set = 0;
5956 /* Parse args required to build the message */
5957 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5959 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5960 sw_if_index_set = 1;
5961 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5962 sw_if_index_set = 1;
5963 else if (unformat (i, "enable"))
5965 else if (unformat (i, "disable"))
5971 if (sw_if_index_set == 0)
5973 errmsg ("missing interface name or sw_if_index");
5977 /* Construct the API message */
5978 M (SW_INTERFACE_SET_VPATH, mp);
5980 mp->sw_if_index = ntohl (sw_if_index);
5981 mp->enable = is_enable;
5986 /* Wait for a reply... */
5992 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5994 unformat_input_t *i = vam->input;
5995 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5996 u32 sw_if_index = 0;
5997 u8 sw_if_index_set = 0;
6002 /* Parse args required to build the message */
6003 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6005 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6006 sw_if_index_set = 1;
6007 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6008 sw_if_index_set = 1;
6009 else if (unformat (i, "enable"))
6011 else if (unformat (i, "disable"))
6013 else if (unformat (i, "ip4"))
6015 else if (unformat (i, "ip6"))
6021 if (sw_if_index_set == 0)
6023 errmsg ("missing interface name or sw_if_index");
6027 /* Construct the API message */
6028 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6030 mp->sw_if_index = ntohl (sw_if_index);
6031 mp->enable = is_enable;
6032 mp->is_ipv6 = is_ipv6;
6037 /* Wait for a reply... */
6043 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6045 unformat_input_t *i = vam->input;
6046 vl_api_sw_interface_set_l2_xconnect_t *mp;
6048 u8 rx_sw_if_index_set = 0;
6050 u8 tx_sw_if_index_set = 0;
6054 /* Parse args required to build the message */
6055 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6057 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6058 rx_sw_if_index_set = 1;
6059 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6060 tx_sw_if_index_set = 1;
6061 else if (unformat (i, "rx"))
6063 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6065 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6067 rx_sw_if_index_set = 1;
6072 else if (unformat (i, "tx"))
6074 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6076 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6078 tx_sw_if_index_set = 1;
6083 else if (unformat (i, "enable"))
6085 else if (unformat (i, "disable"))
6091 if (rx_sw_if_index_set == 0)
6093 errmsg ("missing rx interface name or rx_sw_if_index");
6097 if (enable && (tx_sw_if_index_set == 0))
6099 errmsg ("missing tx interface name or tx_sw_if_index");
6103 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6105 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6106 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6107 mp->enable = enable;
6115 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6117 unformat_input_t *i = vam->input;
6118 vl_api_sw_interface_set_l2_bridge_t *mp;
6120 u8 rx_sw_if_index_set = 0;
6128 /* Parse args required to build the message */
6129 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6131 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6132 rx_sw_if_index_set = 1;
6133 else if (unformat (i, "bd_id %d", &bd_id))
6137 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6138 rx_sw_if_index_set = 1;
6139 else if (unformat (i, "shg %d", &shg))
6141 else if (unformat (i, "bvi"))
6143 else if (unformat (i, "enable"))
6145 else if (unformat (i, "disable"))
6151 if (rx_sw_if_index_set == 0)
6153 errmsg ("missing rx interface name or sw_if_index");
6157 if (enable && (bd_id_set == 0))
6159 errmsg ("missing bridge domain");
6163 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6165 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6166 mp->bd_id = ntohl (bd_id);
6169 mp->enable = enable;
6177 api_bridge_domain_dump (vat_main_t * vam)
6179 unformat_input_t *i = vam->input;
6180 vl_api_bridge_domain_dump_t *mp;
6181 vl_api_control_ping_t *mp_ping;
6185 /* Parse args required to build the message */
6186 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6188 if (unformat (i, "bd_id %d", &bd_id))
6194 M (BRIDGE_DOMAIN_DUMP, mp);
6195 mp->bd_id = ntohl (bd_id);
6198 /* Use a control ping for synchronization */
6199 M (CONTROL_PING, mp_ping);
6207 api_bridge_domain_add_del (vat_main_t * vam)
6209 unformat_input_t *i = vam->input;
6210 vl_api_bridge_domain_add_del_t *mp;
6213 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6217 /* Parse args required to build the message */
6218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6220 if (unformat (i, "bd_id %d", &bd_id))
6222 else if (unformat (i, "flood %d", &flood))
6224 else if (unformat (i, "uu-flood %d", &uu_flood))
6226 else if (unformat (i, "forward %d", &forward))
6228 else if (unformat (i, "learn %d", &learn))
6230 else if (unformat (i, "arp-term %d", &arp_term))
6232 else if (unformat (i, "mac-age %d", &mac_age))
6234 else if (unformat (i, "del"))
6237 flood = uu_flood = forward = learn = 0;
6245 errmsg ("missing bridge domain");
6251 errmsg ("mac age must be less than 256 ");
6255 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6257 mp->bd_id = ntohl (bd_id);
6259 mp->uu_flood = uu_flood;
6260 mp->forward = forward;
6262 mp->arp_term = arp_term;
6263 mp->is_add = is_add;
6264 mp->mac_age = (u8) mac_age;
6272 api_l2fib_flush_bd (vat_main_t * vam)
6274 unformat_input_t *i = vam->input;
6275 vl_api_l2fib_flush_bd_t *mp;
6279 /* Parse args required to build the message */
6280 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6282 if (unformat (i, "bd_id %d", &bd_id));
6289 errmsg ("missing bridge domain");
6293 M (L2FIB_FLUSH_BD, mp);
6295 mp->bd_id = htonl (bd_id);
6303 api_l2fib_flush_int (vat_main_t * vam)
6305 unformat_input_t *i = vam->input;
6306 vl_api_l2fib_flush_int_t *mp;
6307 u32 sw_if_index = ~0;
6310 /* Parse args required to build the message */
6311 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6313 if (unformat (i, "sw_if_index %d", &sw_if_index));
6315 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6320 if (sw_if_index == ~0)
6322 errmsg ("missing interface name or sw_if_index");
6326 M (L2FIB_FLUSH_INT, mp);
6328 mp->sw_if_index = ntohl (sw_if_index);
6336 api_l2fib_add_del (vat_main_t * vam)
6338 unformat_input_t *i = vam->input;
6339 vl_api_l2fib_add_del_t *mp;
6345 u32 sw_if_index = ~0;
6346 u8 sw_if_index_set = 0;
6355 /* Parse args required to build the message */
6356 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6358 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6360 else if (unformat (i, "bd_id %d", &bd_id))
6362 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6363 sw_if_index_set = 1;
6364 else if (unformat (i, "sw_if"))
6366 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6369 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6370 sw_if_index_set = 1;
6375 else if (unformat (i, "static"))
6377 else if (unformat (i, "filter"))
6382 else if (unformat (i, "bvi"))
6387 else if (unformat (i, "del"))
6389 else if (unformat (i, "count %d", &count))
6397 errmsg ("missing mac address");
6403 errmsg ("missing bridge domain");
6407 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6409 errmsg ("missing interface name or sw_if_index");
6415 /* Turn on async mode */
6416 vam->async_mode = 1;
6417 vam->async_errors = 0;
6418 before = vat_time_now (vam);
6421 for (j = 0; j < count; j++)
6423 M (L2FIB_ADD_DEL, mp);
6426 mp->bd_id = ntohl (bd_id);
6427 mp->is_add = is_add;
6431 mp->sw_if_index = ntohl (sw_if_index);
6432 mp->static_mac = static_mac;
6433 mp->filter_mac = filter_mac;
6434 mp->bvi_mac = bvi_mac;
6436 increment_mac_address (&mac);
6443 vl_api_control_ping_t *mp_ping;
6446 /* Shut off async mode */
6447 vam->async_mode = 0;
6449 M (CONTROL_PING, mp_ping);
6452 timeout = vat_time_now (vam) + 1.0;
6453 while (vat_time_now (vam) < timeout)
6454 if (vam->result_ready == 1)
6459 if (vam->retval == -99)
6462 if (vam->async_errors > 0)
6464 errmsg ("%d asynchronous errors", vam->async_errors);
6467 vam->async_errors = 0;
6468 after = vat_time_now (vam);
6470 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6471 count, after - before, count / (after - before));
6477 /* Wait for a reply... */
6481 /* Return the good/bad news */
6482 return (vam->retval);
6486 api_bridge_domain_set_mac_age (vat_main_t * vam)
6488 unformat_input_t *i = vam->input;
6489 vl_api_bridge_domain_set_mac_age_t *mp;
6494 /* Parse args required to build the message */
6495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6497 if (unformat (i, "bd_id %d", &bd_id));
6498 else if (unformat (i, "mac-age %d", &mac_age));
6505 errmsg ("missing bridge domain");
6511 errmsg ("mac age must be less than 256 ");
6515 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6517 mp->bd_id = htonl (bd_id);
6518 mp->mac_age = (u8) mac_age;
6526 api_l2_flags (vat_main_t * vam)
6528 unformat_input_t *i = vam->input;
6529 vl_api_l2_flags_t *mp;
6531 u32 feature_bitmap = 0;
6532 u8 sw_if_index_set = 0;
6535 /* Parse args required to build the message */
6536 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6538 if (unformat (i, "sw_if_index %d", &sw_if_index))
6539 sw_if_index_set = 1;
6540 else if (unformat (i, "sw_if"))
6542 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6545 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6546 sw_if_index_set = 1;
6551 else if (unformat (i, "learn"))
6552 feature_bitmap |= L2INPUT_FEAT_LEARN;
6553 else if (unformat (i, "forward"))
6554 feature_bitmap |= L2INPUT_FEAT_FWD;
6555 else if (unformat (i, "flood"))
6556 feature_bitmap |= L2INPUT_FEAT_FLOOD;
6557 else if (unformat (i, "uu-flood"))
6558 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
6563 if (sw_if_index_set == 0)
6565 errmsg ("missing interface name or sw_if_index");
6571 mp->sw_if_index = ntohl (sw_if_index);
6572 mp->feature_bitmap = ntohl (feature_bitmap);
6580 api_bridge_flags (vat_main_t * vam)
6582 unformat_input_t *i = vam->input;
6583 vl_api_bridge_flags_t *mp;
6590 /* Parse args required to build the message */
6591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6593 if (unformat (i, "bd_id %d", &bd_id))
6595 else if (unformat (i, "learn"))
6597 else if (unformat (i, "forward"))
6599 else if (unformat (i, "flood"))
6601 else if (unformat (i, "uu-flood"))
6602 flags |= L2_UU_FLOOD;
6603 else if (unformat (i, "arp-term"))
6604 flags |= L2_ARP_TERM;
6605 else if (unformat (i, "off"))
6607 else if (unformat (i, "disable"))
6615 errmsg ("missing bridge domain");
6619 M (BRIDGE_FLAGS, mp);
6621 mp->bd_id = ntohl (bd_id);
6622 mp->feature_bitmap = ntohl (flags);
6623 mp->is_set = is_set;
6631 api_bd_ip_mac_add_del (vat_main_t * vam)
6633 unformat_input_t *i = vam->input;
6634 vl_api_bd_ip_mac_add_del_t *mp;
6641 ip4_address_t v4addr;
6642 ip6_address_t v6addr;
6647 /* Parse args required to build the message */
6648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6650 if (unformat (i, "bd_id %d", &bd_id))
6654 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6658 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6663 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6667 else if (unformat (i, "del"))
6675 errmsg ("missing bridge domain");
6678 else if (ip_set == 0)
6680 errmsg ("missing IP address");
6683 else if (mac_set == 0)
6685 errmsg ("missing MAC address");
6689 M (BD_IP_MAC_ADD_DEL, mp);
6691 mp->bd_id = ntohl (bd_id);
6692 mp->is_ipv6 = is_ipv6;
6693 mp->is_add = is_add;
6695 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6697 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6698 clib_memcpy (mp->mac_address, macaddr, 6);
6705 api_tap_connect (vat_main_t * vam)
6707 unformat_input_t *i = vam->input;
6708 vl_api_tap_connect_t *mp;
6714 ip4_address_t ip4_address;
6716 int ip4_address_set = 0;
6717 ip6_address_t ip6_address;
6719 int ip6_address_set = 0;
6722 memset (mac_address, 0, sizeof (mac_address));
6724 /* Parse args required to build the message */
6725 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6727 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6731 else if (unformat (i, "random-mac"))
6733 else if (unformat (i, "tapname %s", &tap_name))
6735 else if (unformat (i, "tag %s", &tag))
6737 else if (unformat (i, "address %U/%d",
6738 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6739 ip4_address_set = 1;
6740 else if (unformat (i, "address %U/%d",
6741 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6742 ip6_address_set = 1;
6749 errmsg ("missing tap name");
6752 if (vec_len (tap_name) > 63)
6754 errmsg ("tap name too long");
6757 vec_add1 (tap_name, 0);
6759 if (vec_len (tag) > 63)
6761 errmsg ("tag too long");
6765 /* Construct the API message */
6766 M (TAP_CONNECT, mp);
6768 mp->use_random_mac = random_mac;
6769 clib_memcpy (mp->mac_address, mac_address, 6);
6770 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6772 clib_memcpy (mp->tag, tag, vec_len (tag));
6774 if (ip4_address_set)
6776 mp->ip4_address_set = 1;
6777 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6778 mp->ip4_mask_width = ip4_mask_width;
6780 if (ip6_address_set)
6782 mp->ip6_address_set = 1;
6783 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6784 mp->ip6_mask_width = ip6_mask_width;
6787 vec_free (tap_name);
6793 /* Wait for a reply... */
6799 api_tap_modify (vat_main_t * vam)
6801 unformat_input_t *i = vam->input;
6802 vl_api_tap_modify_t *mp;
6807 u32 sw_if_index = ~0;
6808 u8 sw_if_index_set = 0;
6811 memset (mac_address, 0, sizeof (mac_address));
6813 /* Parse args required to build the message */
6814 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6816 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6817 sw_if_index_set = 1;
6818 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6819 sw_if_index_set = 1;
6820 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6824 else if (unformat (i, "random-mac"))
6826 else if (unformat (i, "tapname %s", &tap_name))
6832 if (sw_if_index_set == 0)
6834 errmsg ("missing vpp interface name");
6839 errmsg ("missing tap name");
6842 if (vec_len (tap_name) > 63)
6844 errmsg ("tap name too long");
6846 vec_add1 (tap_name, 0);
6848 /* Construct the API message */
6851 mp->use_random_mac = random_mac;
6852 mp->sw_if_index = ntohl (sw_if_index);
6853 clib_memcpy (mp->mac_address, mac_address, 6);
6854 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6855 vec_free (tap_name);
6860 /* Wait for a reply... */
6866 api_tap_delete (vat_main_t * vam)
6868 unformat_input_t *i = vam->input;
6869 vl_api_tap_delete_t *mp;
6870 u32 sw_if_index = ~0;
6871 u8 sw_if_index_set = 0;
6874 /* Parse args required to build the message */
6875 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6877 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6878 sw_if_index_set = 1;
6879 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6880 sw_if_index_set = 1;
6885 if (sw_if_index_set == 0)
6887 errmsg ("missing vpp interface name");
6891 /* Construct the API message */
6894 mp->sw_if_index = ntohl (sw_if_index);
6899 /* Wait for a reply... */
6905 api_ip_add_del_route (vat_main_t * vam)
6907 unformat_input_t *i = vam->input;
6908 vl_api_ip_add_del_route_t *mp;
6909 u32 sw_if_index = ~0, vrf_id = 0;
6911 u8 is_local = 0, is_drop = 0;
6912 u8 is_unreach = 0, is_prohibit = 0;
6913 u8 create_vrf_if_needed = 0;
6915 u32 next_hop_weight = 1;
6917 u8 is_multipath = 0;
6919 u8 address_length_set = 0;
6920 u32 next_hop_table_id = 0;
6921 u32 resolve_attempts = 0;
6922 u32 dst_address_length = 0;
6923 u8 next_hop_set = 0;
6924 ip4_address_t v4_dst_address, v4_next_hop_address;
6925 ip6_address_t v6_dst_address, v6_next_hop_address;
6929 u32 random_add_del = 0;
6930 u32 *random_vector = 0;
6932 u32 random_seed = 0xdeaddabe;
6933 u32 classify_table_index = ~0;
6935 u8 resolve_host = 0, resolve_attached = 0;
6936 mpls_label_t *next_hop_out_label_stack = NULL;
6937 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6938 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6940 /* Parse args required to build the message */
6941 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6943 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6945 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6947 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6952 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6957 else if (unformat (i, "/%d", &dst_address_length))
6959 address_length_set = 1;
6962 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6963 &v4_next_hop_address))
6967 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6968 &v6_next_hop_address))
6972 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6974 else if (unformat (i, "weight %d", &next_hop_weight))
6976 else if (unformat (i, "drop"))
6980 else if (unformat (i, "null-send-unreach"))
6984 else if (unformat (i, "null-send-prohibit"))
6988 else if (unformat (i, "local"))
6992 else if (unformat (i, "classify %d", &classify_table_index))
6996 else if (unformat (i, "del"))
6998 else if (unformat (i, "add"))
7000 else if (unformat (i, "not-last"))
7002 else if (unformat (i, "resolve-via-host"))
7004 else if (unformat (i, "resolve-via-attached"))
7005 resolve_attached = 1;
7006 else if (unformat (i, "multipath"))
7008 else if (unformat (i, "vrf %d", &vrf_id))
7010 else if (unformat (i, "create-vrf"))
7011 create_vrf_if_needed = 1;
7012 else if (unformat (i, "count %d", &count))
7014 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7016 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7018 else if (unformat (i, "out-label %d", &next_hop_out_label))
7019 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7020 else if (unformat (i, "via-label %d", &next_hop_via_label))
7022 else if (unformat (i, "random"))
7024 else if (unformat (i, "seed %d", &random_seed))
7028 clib_warning ("parse error '%U'", format_unformat_error, i);
7033 if (!next_hop_set && !is_drop && !is_local &&
7034 !is_classify && !is_unreach && !is_prohibit &&
7035 MPLS_LABEL_INVALID == next_hop_via_label)
7038 ("next hop / local / drop / unreach / prohibit / classify not set");
7042 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7044 errmsg ("next hop and next-hop via label set");
7047 if (address_set == 0)
7049 errmsg ("missing addresses");
7053 if (address_length_set == 0)
7055 errmsg ("missing address length");
7059 /* Generate a pile of unique, random routes */
7062 u32 this_random_address;
7063 random_hash = hash_create (count, sizeof (uword));
7065 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7066 for (j = 0; j <= count; j++)
7070 this_random_address = random_u32 (&random_seed);
7071 this_random_address =
7072 clib_host_to_net_u32 (this_random_address);
7074 while (hash_get (random_hash, this_random_address));
7075 vec_add1 (random_vector, this_random_address);
7076 hash_set (random_hash, this_random_address, 1);
7078 hash_free (random_hash);
7079 v4_dst_address.as_u32 = random_vector[0];
7084 /* Turn on async mode */
7085 vam->async_mode = 1;
7086 vam->async_errors = 0;
7087 before = vat_time_now (vam);
7090 for (j = 0; j < count; j++)
7092 /* Construct the API message */
7093 M2 (IP_ADD_DEL_ROUTE, mp,
7094 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7096 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7097 mp->table_id = ntohl (vrf_id);
7098 mp->create_vrf_if_needed = create_vrf_if_needed;
7100 mp->is_add = is_add;
7101 mp->is_drop = is_drop;
7102 mp->is_unreach = is_unreach;
7103 mp->is_prohibit = is_prohibit;
7104 mp->is_ipv6 = is_ipv6;
7105 mp->is_local = is_local;
7106 mp->is_classify = is_classify;
7107 mp->is_multipath = is_multipath;
7108 mp->is_resolve_host = resolve_host;
7109 mp->is_resolve_attached = resolve_attached;
7110 mp->not_last = not_last;
7111 mp->next_hop_weight = next_hop_weight;
7112 mp->dst_address_length = dst_address_length;
7113 mp->next_hop_table_id = ntohl (next_hop_table_id);
7114 mp->classify_table_index = ntohl (classify_table_index);
7115 mp->next_hop_via_label = ntohl (next_hop_via_label);
7116 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7117 if (0 != mp->next_hop_n_out_labels)
7119 memcpy (mp->next_hop_out_label_stack,
7120 next_hop_out_label_stack,
7121 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7122 vec_free (next_hop_out_label_stack);
7127 clib_memcpy (mp->dst_address, &v6_dst_address,
7128 sizeof (v6_dst_address));
7130 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
7131 sizeof (v6_next_hop_address));
7132 increment_v6_address (&v6_dst_address);
7136 clib_memcpy (mp->dst_address, &v4_dst_address,
7137 sizeof (v4_dst_address));
7139 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
7140 sizeof (v4_next_hop_address));
7142 v4_dst_address.as_u32 = random_vector[j + 1];
7144 increment_v4_address (&v4_dst_address);
7148 /* If we receive SIGTERM, stop now... */
7153 /* When testing multiple add/del ops, use a control-ping to sync */
7156 vl_api_control_ping_t *mp_ping;
7160 /* Shut off async mode */
7161 vam->async_mode = 0;
7163 M (CONTROL_PING, mp_ping);
7166 timeout = vat_time_now (vam) + 1.0;
7167 while (vat_time_now (vam) < timeout)
7168 if (vam->result_ready == 1)
7173 if (vam->retval == -99)
7176 if (vam->async_errors > 0)
7178 errmsg ("%d asynchronous errors", vam->async_errors);
7181 vam->async_errors = 0;
7182 after = vat_time_now (vam);
7184 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7188 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7189 count, after - before, count / (after - before));
7195 /* Wait for a reply... */
7200 /* Return the good/bad news */
7201 return (vam->retval);
7205 api_ip_mroute_add_del (vat_main_t * vam)
7207 unformat_input_t *i = vam->input;
7208 vl_api_ip_mroute_add_del_t *mp;
7209 u32 sw_if_index = ~0, vrf_id = 0;
7212 u8 create_vrf_if_needed = 0;
7215 u32 grp_address_length = 0;
7216 ip4_address_t v4_grp_address, v4_src_address;
7217 ip6_address_t v6_grp_address, v6_src_address;
7218 mfib_itf_flags_t iflags = 0;
7219 mfib_entry_flags_t eflags = 0;
7222 /* Parse args required to build the message */
7223 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7225 if (unformat (i, "sw_if_index %d", &sw_if_index))
7227 else if (unformat (i, "%U %U",
7228 unformat_ip4_address, &v4_src_address,
7229 unformat_ip4_address, &v4_grp_address))
7231 grp_address_length = 64;
7235 else if (unformat (i, "%U %U",
7236 unformat_ip6_address, &v6_src_address,
7237 unformat_ip6_address, &v6_grp_address))
7239 grp_address_length = 256;
7243 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7245 memset (&v4_src_address, 0, sizeof (v4_src_address));
7246 grp_address_length = 32;
7250 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7252 memset (&v6_src_address, 0, sizeof (v6_src_address));
7253 grp_address_length = 128;
7257 else if (unformat (i, "/%d", &grp_address_length))
7259 else if (unformat (i, "local"))
7263 else if (unformat (i, "del"))
7265 else if (unformat (i, "add"))
7267 else if (unformat (i, "vrf %d", &vrf_id))
7269 else if (unformat (i, "create-vrf"))
7270 create_vrf_if_needed = 1;
7271 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7273 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7277 clib_warning ("parse error '%U'", format_unformat_error, i);
7282 if (address_set == 0)
7284 errmsg ("missing addresses\n");
7288 /* Construct the API message */
7289 M (IP_MROUTE_ADD_DEL, mp);
7291 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7292 mp->table_id = ntohl (vrf_id);
7293 mp->create_vrf_if_needed = create_vrf_if_needed;
7295 mp->is_add = is_add;
7296 mp->is_ipv6 = is_ipv6;
7297 mp->is_local = is_local;
7298 mp->itf_flags = ntohl (iflags);
7299 mp->entry_flags = ntohl (eflags);
7300 mp->grp_address_length = grp_address_length;
7301 mp->grp_address_length = ntohs (mp->grp_address_length);
7305 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7306 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7310 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7311 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7317 /* Wait for a reply... */
7323 api_mpls_route_add_del (vat_main_t * vam)
7325 unformat_input_t *i = vam->input;
7326 vl_api_mpls_route_add_del_t *mp;
7327 u32 sw_if_index = ~0, table_id = 0;
7328 u8 create_table_if_needed = 0;
7330 u32 next_hop_weight = 1;
7331 u8 is_multipath = 0;
7332 u32 next_hop_table_id = 0;
7333 u8 next_hop_set = 0;
7334 ip4_address_t v4_next_hop_address = {
7337 ip6_address_t v6_next_hop_address = { {0} };
7341 u32 classify_table_index = ~0;
7343 u8 resolve_host = 0, resolve_attached = 0;
7344 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7345 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7346 mpls_label_t *next_hop_out_label_stack = NULL;
7347 mpls_label_t local_label = MPLS_LABEL_INVALID;
7349 u8 next_hop_proto_is_ip4 = 1;
7351 /* Parse args required to build the message */
7352 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7354 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7356 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7358 else if (unformat (i, "%d", &local_label))
7360 else if (unformat (i, "eos"))
7362 else if (unformat (i, "non-eos"))
7364 else if (unformat (i, "via %U", unformat_ip4_address,
7365 &v4_next_hop_address))
7368 next_hop_proto_is_ip4 = 1;
7370 else if (unformat (i, "via %U", unformat_ip6_address,
7371 &v6_next_hop_address))
7374 next_hop_proto_is_ip4 = 0;
7376 else if (unformat (i, "weight %d", &next_hop_weight))
7378 else if (unformat (i, "create-table"))
7379 create_table_if_needed = 1;
7380 else if (unformat (i, "classify %d", &classify_table_index))
7384 else if (unformat (i, "del"))
7386 else if (unformat (i, "add"))
7388 else if (unformat (i, "resolve-via-host"))
7390 else if (unformat (i, "resolve-via-attached"))
7391 resolve_attached = 1;
7392 else if (unformat (i, "multipath"))
7394 else if (unformat (i, "count %d", &count))
7396 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
7399 next_hop_proto_is_ip4 = 1;
7401 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
7404 next_hop_proto_is_ip4 = 0;
7406 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7408 else if (unformat (i, "via-label %d", &next_hop_via_label))
7410 else if (unformat (i, "out-label %d", &next_hop_out_label))
7411 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7414 clib_warning ("parse error '%U'", format_unformat_error, i);
7419 if (!next_hop_set && !is_classify)
7421 errmsg ("next hop / classify not set");
7425 if (MPLS_LABEL_INVALID == local_label)
7427 errmsg ("missing label");
7433 /* Turn on async mode */
7434 vam->async_mode = 1;
7435 vam->async_errors = 0;
7436 before = vat_time_now (vam);
7439 for (j = 0; j < count; j++)
7441 /* Construct the API message */
7442 M2 (MPLS_ROUTE_ADD_DEL, mp,
7443 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7445 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
7446 mp->mr_table_id = ntohl (table_id);
7447 mp->mr_create_table_if_needed = create_table_if_needed;
7449 mp->mr_is_add = is_add;
7450 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7451 mp->mr_is_classify = is_classify;
7452 mp->mr_is_multipath = is_multipath;
7453 mp->mr_is_resolve_host = resolve_host;
7454 mp->mr_is_resolve_attached = resolve_attached;
7455 mp->mr_next_hop_weight = next_hop_weight;
7456 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
7457 mp->mr_classify_table_index = ntohl (classify_table_index);
7458 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
7459 mp->mr_label = ntohl (local_label);
7460 mp->mr_eos = is_eos;
7462 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7463 if (0 != mp->mr_next_hop_n_out_labels)
7465 memcpy (mp->mr_next_hop_out_label_stack,
7466 next_hop_out_label_stack,
7467 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7468 vec_free (next_hop_out_label_stack);
7473 if (next_hop_proto_is_ip4)
7475 clib_memcpy (mp->mr_next_hop,
7476 &v4_next_hop_address,
7477 sizeof (v4_next_hop_address));
7481 clib_memcpy (mp->mr_next_hop,
7482 &v6_next_hop_address,
7483 sizeof (v6_next_hop_address));
7490 /* If we receive SIGTERM, stop now... */
7495 /* When testing multiple add/del ops, use a control-ping to sync */
7498 vl_api_control_ping_t *mp_ping;
7502 /* Shut off async mode */
7503 vam->async_mode = 0;
7505 M (CONTROL_PING, mp_ping);
7508 timeout = vat_time_now (vam) + 1.0;
7509 while (vat_time_now (vam) < timeout)
7510 if (vam->result_ready == 1)
7515 if (vam->retval == -99)
7518 if (vam->async_errors > 0)
7520 errmsg ("%d asynchronous errors", vam->async_errors);
7523 vam->async_errors = 0;
7524 after = vat_time_now (vam);
7526 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7530 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7531 count, after - before, count / (after - before));
7537 /* Wait for a reply... */
7542 /* Return the good/bad news */
7543 return (vam->retval);
7547 api_mpls_ip_bind_unbind (vat_main_t * vam)
7549 unformat_input_t *i = vam->input;
7550 vl_api_mpls_ip_bind_unbind_t *mp;
7551 u32 ip_table_id = 0;
7552 u8 create_table_if_needed = 0;
7555 ip4_address_t v4_address;
7556 ip6_address_t v6_address;
7559 mpls_label_t local_label = MPLS_LABEL_INVALID;
7562 /* Parse args required to build the message */
7563 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7565 if (unformat (i, "%U/%d", unformat_ip4_address,
7566 &v4_address, &address_length))
7571 else if (unformat (i, "%U/%d", unformat_ip6_address,
7572 &v6_address, &address_length))
7577 else if (unformat (i, "%d", &local_label))
7579 else if (unformat (i, "create-table"))
7580 create_table_if_needed = 1;
7581 else if (unformat (i, "table-id %d", &ip_table_id))
7583 else if (unformat (i, "unbind"))
7585 else if (unformat (i, "bind"))
7589 clib_warning ("parse error '%U'", format_unformat_error, i);
7596 errmsg ("IP addres not set");
7600 if (MPLS_LABEL_INVALID == local_label)
7602 errmsg ("missing label");
7606 /* Construct the API message */
7607 M (MPLS_IP_BIND_UNBIND, mp);
7609 mp->mb_create_table_if_needed = create_table_if_needed;
7610 mp->mb_is_bind = is_bind;
7611 mp->mb_is_ip4 = is_ip4;
7612 mp->mb_ip_table_id = ntohl (ip_table_id);
7613 mp->mb_mpls_table_id = 0;
7614 mp->mb_label = ntohl (local_label);
7615 mp->mb_address_length = address_length;
7618 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7620 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7625 /* Wait for a reply... */
7631 api_proxy_arp_add_del (vat_main_t * vam)
7633 unformat_input_t *i = vam->input;
7634 vl_api_proxy_arp_add_del_t *mp;
7637 ip4_address_t lo, hi;
7641 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7643 if (unformat (i, "vrf %d", &vrf_id))
7645 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7646 unformat_ip4_address, &hi))
7648 else if (unformat (i, "del"))
7652 clib_warning ("parse error '%U'", format_unformat_error, i);
7659 errmsg ("address range not set");
7663 M (PROXY_ARP_ADD_DEL, mp);
7665 mp->vrf_id = ntohl (vrf_id);
7666 mp->is_add = is_add;
7667 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7668 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7676 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7678 unformat_input_t *i = vam->input;
7679 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7682 u8 sw_if_index_set = 0;
7685 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7687 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7688 sw_if_index_set = 1;
7689 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7690 sw_if_index_set = 1;
7691 else if (unformat (i, "enable"))
7693 else if (unformat (i, "disable"))
7697 clib_warning ("parse error '%U'", format_unformat_error, i);
7702 if (sw_if_index_set == 0)
7704 errmsg ("missing interface name or sw_if_index");
7708 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7710 mp->sw_if_index = ntohl (sw_if_index);
7711 mp->enable_disable = enable;
7719 api_mpls_tunnel_add_del (vat_main_t * vam)
7721 unformat_input_t *i = vam->input;
7722 vl_api_mpls_tunnel_add_del_t *mp;
7726 u32 sw_if_index = ~0;
7727 u32 next_hop_sw_if_index = ~0;
7728 u32 next_hop_proto_is_ip4 = 1;
7730 u32 next_hop_table_id = 0;
7731 ip4_address_t v4_next_hop_address = {
7734 ip6_address_t v6_next_hop_address = { {0} };
7735 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7740 if (unformat (i, "add"))
7742 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7744 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7746 else if (unformat (i, "via %U",
7747 unformat_ip4_address, &v4_next_hop_address))
7749 next_hop_proto_is_ip4 = 1;
7751 else if (unformat (i, "via %U",
7752 unformat_ip6_address, &v6_next_hop_address))
7754 next_hop_proto_is_ip4 = 0;
7756 else if (unformat (i, "l2-only"))
7758 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7760 else if (unformat (i, "out-label %d", &next_hop_out_label))
7761 vec_add1 (labels, ntohl (next_hop_out_label));
7764 clib_warning ("parse error '%U'", format_unformat_error, i);
7769 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7771 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7772 mp->mt_sw_if_index = ntohl (sw_if_index);
7773 mp->mt_is_add = is_add;
7774 mp->mt_l2_only = l2_only;
7775 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7776 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7778 mp->mt_next_hop_n_out_labels = vec_len (labels);
7780 if (0 != mp->mt_next_hop_n_out_labels)
7782 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7783 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7787 if (next_hop_proto_is_ip4)
7789 clib_memcpy (mp->mt_next_hop,
7790 &v4_next_hop_address, sizeof (v4_next_hop_address));
7794 clib_memcpy (mp->mt_next_hop,
7795 &v6_next_hop_address, sizeof (v6_next_hop_address));
7804 api_sw_interface_set_unnumbered (vat_main_t * vam)
7806 unformat_input_t *i = vam->input;
7807 vl_api_sw_interface_set_unnumbered_t *mp;
7809 u32 unnum_sw_index = ~0;
7811 u8 sw_if_index_set = 0;
7814 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7816 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7817 sw_if_index_set = 1;
7818 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7819 sw_if_index_set = 1;
7820 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7822 else if (unformat (i, "del"))
7826 clib_warning ("parse error '%U'", format_unformat_error, i);
7831 if (sw_if_index_set == 0)
7833 errmsg ("missing interface name or sw_if_index");
7837 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7839 mp->sw_if_index = ntohl (sw_if_index);
7840 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7841 mp->is_add = is_add;
7849 api_ip_neighbor_add_del (vat_main_t * vam)
7851 unformat_input_t *i = vam->input;
7852 vl_api_ip_neighbor_add_del_t *mp;
7854 u8 sw_if_index_set = 0;
7857 u8 is_no_fib_entry = 0;
7860 u8 v4_address_set = 0;
7861 u8 v6_address_set = 0;
7862 ip4_address_t v4address;
7863 ip6_address_t v6address;
7866 memset (mac_address, 0, sizeof (mac_address));
7868 /* Parse args required to build the message */
7869 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7871 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7875 else if (unformat (i, "del"))
7878 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7879 sw_if_index_set = 1;
7880 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7881 sw_if_index_set = 1;
7882 else if (unformat (i, "is_static"))
7884 else if (unformat (i, "no-fib-entry"))
7885 is_no_fib_entry = 1;
7886 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7888 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7892 clib_warning ("parse error '%U'", format_unformat_error, i);
7897 if (sw_if_index_set == 0)
7899 errmsg ("missing interface name or sw_if_index");
7902 if (v4_address_set && v6_address_set)
7904 errmsg ("both v4 and v6 addresses set");
7907 if (!v4_address_set && !v6_address_set)
7909 errmsg ("no address set");
7913 /* Construct the API message */
7914 M (IP_NEIGHBOR_ADD_DEL, mp);
7916 mp->sw_if_index = ntohl (sw_if_index);
7917 mp->is_add = is_add;
7918 mp->is_static = is_static;
7919 mp->is_no_adj_fib = is_no_fib_entry;
7921 clib_memcpy (mp->mac_address, mac_address, 6);
7925 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7929 /* mp->is_ipv6 = 0; via memset in M macro above */
7930 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7936 /* Wait for a reply, return good/bad news */
7942 api_reset_vrf (vat_main_t * vam)
7944 unformat_input_t *i = vam->input;
7945 vl_api_reset_vrf_t *mp;
7951 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7953 if (unformat (i, "vrf %d", &vrf_id))
7955 else if (unformat (i, "ipv6"))
7959 clib_warning ("parse error '%U'", format_unformat_error, i);
7964 if (vrf_id_set == 0)
7966 errmsg ("missing vrf id");
7972 mp->vrf_id = ntohl (vrf_id);
7973 mp->is_ipv6 = is_ipv6;
7981 api_create_vlan_subif (vat_main_t * vam)
7983 unformat_input_t *i = vam->input;
7984 vl_api_create_vlan_subif_t *mp;
7986 u8 sw_if_index_set = 0;
7991 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7993 if (unformat (i, "sw_if_index %d", &sw_if_index))
7994 sw_if_index_set = 1;
7996 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7997 sw_if_index_set = 1;
7998 else if (unformat (i, "vlan %d", &vlan_id))
8002 clib_warning ("parse error '%U'", format_unformat_error, i);
8007 if (sw_if_index_set == 0)
8009 errmsg ("missing interface name or sw_if_index");
8013 if (vlan_id_set == 0)
8015 errmsg ("missing vlan_id");
8018 M (CREATE_VLAN_SUBIF, mp);
8020 mp->sw_if_index = ntohl (sw_if_index);
8021 mp->vlan_id = ntohl (vlan_id);
8028 #define foreach_create_subif_bit \
8035 _(outer_vlan_id_any) \
8036 _(inner_vlan_id_any)
8039 api_create_subif (vat_main_t * vam)
8041 unformat_input_t *i = vam->input;
8042 vl_api_create_subif_t *mp;
8044 u8 sw_if_index_set = 0;
8051 u32 exact_match = 0;
8052 u32 default_sub = 0;
8053 u32 outer_vlan_id_any = 0;
8054 u32 inner_vlan_id_any = 0;
8056 u16 outer_vlan_id = 0;
8057 u16 inner_vlan_id = 0;
8060 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8062 if (unformat (i, "sw_if_index %d", &sw_if_index))
8063 sw_if_index_set = 1;
8065 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8066 sw_if_index_set = 1;
8067 else if (unformat (i, "sub_id %d", &sub_id))
8069 else if (unformat (i, "outer_vlan_id %d", &tmp))
8070 outer_vlan_id = tmp;
8071 else if (unformat (i, "inner_vlan_id %d", &tmp))
8072 inner_vlan_id = tmp;
8074 #define _(a) else if (unformat (i, #a)) a = 1 ;
8075 foreach_create_subif_bit
8079 clib_warning ("parse error '%U'", format_unformat_error, i);
8084 if (sw_if_index_set == 0)
8086 errmsg ("missing interface name or sw_if_index");
8090 if (sub_id_set == 0)
8092 errmsg ("missing sub_id");
8095 M (CREATE_SUBIF, mp);
8097 mp->sw_if_index = ntohl (sw_if_index);
8098 mp->sub_id = ntohl (sub_id);
8100 #define _(a) mp->a = a;
8101 foreach_create_subif_bit;
8104 mp->outer_vlan_id = ntohs (outer_vlan_id);
8105 mp->inner_vlan_id = ntohs (inner_vlan_id);
8113 api_oam_add_del (vat_main_t * vam)
8115 unformat_input_t *i = vam->input;
8116 vl_api_oam_add_del_t *mp;
8119 ip4_address_t src, dst;
8124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8126 if (unformat (i, "vrf %d", &vrf_id))
8128 else if (unformat (i, "src %U", unformat_ip4_address, &src))
8130 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
8132 else if (unformat (i, "del"))
8136 clib_warning ("parse error '%U'", format_unformat_error, i);
8143 errmsg ("missing src addr");
8149 errmsg ("missing dst addr");
8153 M (OAM_ADD_DEL, mp);
8155 mp->vrf_id = ntohl (vrf_id);
8156 mp->is_add = is_add;
8157 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
8158 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8166 api_reset_fib (vat_main_t * vam)
8168 unformat_input_t *i = vam->input;
8169 vl_api_reset_fib_t *mp;
8175 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8177 if (unformat (i, "vrf %d", &vrf_id))
8179 else if (unformat (i, "ipv6"))
8183 clib_warning ("parse error '%U'", format_unformat_error, i);
8188 if (vrf_id_set == 0)
8190 errmsg ("missing vrf id");
8196 mp->vrf_id = ntohl (vrf_id);
8197 mp->is_ipv6 = is_ipv6;
8205 api_dhcp_proxy_config (vat_main_t * vam)
8207 unformat_input_t *i = vam->input;
8208 vl_api_dhcp_proxy_config_t *mp;
8210 u32 server_vrf_id = 0;
8212 u8 v4_address_set = 0;
8213 u8 v6_address_set = 0;
8214 ip4_address_t v4address;
8215 ip6_address_t v6address;
8216 u8 v4_src_address_set = 0;
8217 u8 v6_src_address_set = 0;
8218 ip4_address_t v4srcaddress;
8219 ip6_address_t v6srcaddress;
8222 /* Parse args required to build the message */
8223 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8225 if (unformat (i, "del"))
8227 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8229 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8231 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8233 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8235 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8236 v4_src_address_set = 1;
8237 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8238 v6_src_address_set = 1;
8243 if (v4_address_set && v6_address_set)
8245 errmsg ("both v4 and v6 server addresses set");
8248 if (!v4_address_set && !v6_address_set)
8250 errmsg ("no server addresses set");
8254 if (v4_src_address_set && v6_src_address_set)
8256 errmsg ("both v4 and v6 src addresses set");
8259 if (!v4_src_address_set && !v6_src_address_set)
8261 errmsg ("no src addresses set");
8265 if (!(v4_src_address_set && v4_address_set) &&
8266 !(v6_src_address_set && v6_address_set))
8268 errmsg ("no matching server and src addresses set");
8272 /* Construct the API message */
8273 M (DHCP_PROXY_CONFIG, mp);
8275 mp->is_add = is_add;
8276 mp->rx_vrf_id = ntohl (rx_vrf_id);
8277 mp->server_vrf_id = ntohl (server_vrf_id);
8281 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
8282 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
8286 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
8287 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
8293 /* Wait for a reply, return good/bad news */
8298 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
8299 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
8302 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
8304 vat_main_t *vam = &vat_main;
8305 u32 i, count = mp->count;
8306 vl_api_dhcp_server_t *s;
8310 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8311 ntohl (mp->rx_vrf_id),
8312 format_ip6_address, mp->dhcp_src_address,
8313 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8316 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8317 ntohl (mp->rx_vrf_id),
8318 format_ip4_address, mp->dhcp_src_address,
8319 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8321 for (i = 0; i < count; i++)
8323 s = &mp->servers[i];
8327 " Server Table-ID %d, Server Address %U",
8328 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
8331 " Server Table-ID %d, Server Address %U",
8332 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
8336 static void vl_api_dhcp_proxy_details_t_handler_json
8337 (vl_api_dhcp_proxy_details_t * mp)
8339 vat_main_t *vam = &vat_main;
8340 vat_json_node_t *node = NULL;
8341 u32 i, count = mp->count;
8343 struct in6_addr ip6;
8344 vl_api_dhcp_server_t *s;
8346 if (VAT_JSON_ARRAY != vam->json_tree.type)
8348 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8349 vat_json_init_array (&vam->json_tree);
8351 node = vat_json_array_add (&vam->json_tree);
8353 vat_json_init_object (node);
8354 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
8355 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
8356 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
8360 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
8361 vat_json_object_add_ip6 (node, "src_address", ip6);
8365 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
8366 vat_json_object_add_ip4 (node, "src_address", ip4);
8369 for (i = 0; i < count; i++)
8371 s = &mp->servers[i];
8373 vat_json_object_add_uint (node, "server-table-id",
8374 ntohl (s->server_vrf_id));
8378 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
8379 vat_json_object_add_ip4 (node, "src_address", ip4);
8383 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
8384 vat_json_object_add_ip6 (node, "server_address", ip6);
8390 api_dhcp_proxy_dump (vat_main_t * vam)
8392 unformat_input_t *i = vam->input;
8393 vl_api_control_ping_t *mp_ping;
8394 vl_api_dhcp_proxy_dump_t *mp;
8398 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8400 if (unformat (i, "ipv6"))
8404 clib_warning ("parse error '%U'", format_unformat_error, i);
8409 M (DHCP_PROXY_DUMP, mp);
8411 mp->is_ip6 = is_ipv6;
8414 /* Use a control ping for synchronization */
8415 M (CONTROL_PING, mp_ping);
8423 api_dhcp_proxy_set_vss (vat_main_t * vam)
8425 unformat_input_t *i = vam->input;
8426 vl_api_dhcp_proxy_set_vss_t *mp;
8437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8439 if (unformat (i, "tbl_id %d", &tbl_id))
8441 if (unformat (i, "fib_id %d", &fib_id))
8443 if (unformat (i, "oui %d", &oui))
8445 else if (unformat (i, "ipv6"))
8447 else if (unformat (i, "del"))
8451 clib_warning ("parse error '%U'", format_unformat_error, i);
8456 if (tbl_id_set == 0)
8458 errmsg ("missing tbl id");
8462 if (fib_id_set == 0)
8464 errmsg ("missing fib id");
8469 errmsg ("missing oui");
8473 M (DHCP_PROXY_SET_VSS, mp);
8474 mp->tbl_id = ntohl (tbl_id);
8475 mp->fib_id = ntohl (fib_id);
8476 mp->oui = ntohl (oui);
8477 mp->is_ipv6 = is_ipv6;
8478 mp->is_add = is_add;
8486 api_dhcp_client_config (vat_main_t * vam)
8488 unformat_input_t *i = vam->input;
8489 vl_api_dhcp_client_config_t *mp;
8491 u8 sw_if_index_set = 0;
8494 u8 disable_event = 0;
8497 /* Parse args required to build the message */
8498 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8500 if (unformat (i, "del"))
8503 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8504 sw_if_index_set = 1;
8505 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8506 sw_if_index_set = 1;
8507 else if (unformat (i, "hostname %s", &hostname))
8509 else if (unformat (i, "disable_event"))
8515 if (sw_if_index_set == 0)
8517 errmsg ("missing interface name or sw_if_index");
8521 if (vec_len (hostname) > 63)
8523 errmsg ("hostname too long");
8525 vec_add1 (hostname, 0);
8527 /* Construct the API message */
8528 M (DHCP_CLIENT_CONFIG, mp);
8530 mp->sw_if_index = htonl (sw_if_index);
8531 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
8532 vec_free (hostname);
8533 mp->is_add = is_add;
8534 mp->want_dhcp_event = disable_event ? 0 : 1;
8535 mp->pid = htonl (getpid ());
8540 /* Wait for a reply, return good/bad news */
8546 api_set_ip_flow_hash (vat_main_t * vam)
8548 unformat_input_t *i = vam->input;
8549 vl_api_set_ip_flow_hash_t *mp;
8561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8563 if (unformat (i, "vrf %d", &vrf_id))
8565 else if (unformat (i, "ipv6"))
8567 else if (unformat (i, "src"))
8569 else if (unformat (i, "dst"))
8571 else if (unformat (i, "sport"))
8573 else if (unformat (i, "dport"))
8575 else if (unformat (i, "proto"))
8577 else if (unformat (i, "reverse"))
8582 clib_warning ("parse error '%U'", format_unformat_error, i);
8587 if (vrf_id_set == 0)
8589 errmsg ("missing vrf id");
8593 M (SET_IP_FLOW_HASH, mp);
8599 mp->reverse = reverse;
8600 mp->vrf_id = ntohl (vrf_id);
8601 mp->is_ipv6 = is_ipv6;
8609 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8611 unformat_input_t *i = vam->input;
8612 vl_api_sw_interface_ip6_enable_disable_t *mp;
8614 u8 sw_if_index_set = 0;
8618 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8620 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8621 sw_if_index_set = 1;
8622 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8623 sw_if_index_set = 1;
8624 else if (unformat (i, "enable"))
8626 else if (unformat (i, "disable"))
8630 clib_warning ("parse error '%U'", format_unformat_error, i);
8635 if (sw_if_index_set == 0)
8637 errmsg ("missing interface name or sw_if_index");
8641 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8643 mp->sw_if_index = ntohl (sw_if_index);
8644 mp->enable = enable;
8652 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8654 unformat_input_t *i = vam->input;
8655 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8657 u8 sw_if_index_set = 0;
8658 u8 v6_address_set = 0;
8659 ip6_address_t v6address;
8662 /* Parse args required to build the message */
8663 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8665 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8666 sw_if_index_set = 1;
8667 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8668 sw_if_index_set = 1;
8669 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8675 if (sw_if_index_set == 0)
8677 errmsg ("missing interface name or sw_if_index");
8680 if (!v6_address_set)
8682 errmsg ("no address set");
8686 /* Construct the API message */
8687 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8689 mp->sw_if_index = ntohl (sw_if_index);
8690 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8695 /* Wait for a reply, return good/bad news */
8701 api_ip6nd_proxy_add_del (vat_main_t * vam)
8703 unformat_input_t *i = vam->input;
8704 vl_api_ip6nd_proxy_add_del_t *mp;
8705 u32 sw_if_index = ~0;
8706 u8 v6_address_set = 0;
8707 ip6_address_t v6address;
8711 /* Parse args required to build the message */
8712 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8714 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8716 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8718 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8720 if (unformat (i, "del"))
8724 clib_warning ("parse error '%U'", format_unformat_error, i);
8729 if (sw_if_index == ~0)
8731 errmsg ("missing interface name or sw_if_index");
8734 if (!v6_address_set)
8736 errmsg ("no address set");
8740 /* Construct the API message */
8741 M (IP6ND_PROXY_ADD_DEL, mp);
8743 mp->is_del = is_del;
8744 mp->sw_if_index = ntohl (sw_if_index);
8745 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8750 /* Wait for a reply, return good/bad news */
8756 api_ip6nd_proxy_dump (vat_main_t * vam)
8758 vl_api_ip6nd_proxy_dump_t *mp;
8759 vl_api_control_ping_t *mp_ping;
8762 M (IP6ND_PROXY_DUMP, mp);
8766 /* Use a control ping for synchronization */
8767 M (CONTROL_PING, mp_ping);
8774 static void vl_api_ip6nd_proxy_details_t_handler
8775 (vl_api_ip6nd_proxy_details_t * mp)
8777 vat_main_t *vam = &vat_main;
8779 print (vam->ofp, "host %U sw_if_index %d",
8780 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
8783 static void vl_api_ip6nd_proxy_details_t_handler_json
8784 (vl_api_ip6nd_proxy_details_t * mp)
8786 vat_main_t *vam = &vat_main;
8787 struct in6_addr ip6;
8788 vat_json_node_t *node = NULL;
8790 if (VAT_JSON_ARRAY != vam->json_tree.type)
8792 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8793 vat_json_init_array (&vam->json_tree);
8795 node = vat_json_array_add (&vam->json_tree);
8797 vat_json_init_object (node);
8798 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
8800 clib_memcpy (&ip6, mp->address, sizeof (ip6));
8801 vat_json_object_add_ip6 (node, "host", ip6);
8805 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8807 unformat_input_t *i = vam->input;
8808 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8810 u8 sw_if_index_set = 0;
8811 u32 address_length = 0;
8812 u8 v6_address_set = 0;
8813 ip6_address_t v6address;
8815 u8 no_advertise = 0;
8817 u8 no_autoconfig = 0;
8820 u32 val_lifetime = 0;
8821 u32 pref_lifetime = 0;
8824 /* Parse args required to build the message */
8825 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8827 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8828 sw_if_index_set = 1;
8829 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8830 sw_if_index_set = 1;
8831 else if (unformat (i, "%U/%d",
8832 unformat_ip6_address, &v6address, &address_length))
8834 else if (unformat (i, "val_life %d", &val_lifetime))
8836 else if (unformat (i, "pref_life %d", &pref_lifetime))
8838 else if (unformat (i, "def"))
8840 else if (unformat (i, "noadv"))
8842 else if (unformat (i, "offl"))
8844 else if (unformat (i, "noauto"))
8846 else if (unformat (i, "nolink"))
8848 else if (unformat (i, "isno"))
8852 clib_warning ("parse error '%U'", format_unformat_error, i);
8857 if (sw_if_index_set == 0)
8859 errmsg ("missing interface name or sw_if_index");
8862 if (!v6_address_set)
8864 errmsg ("no address set");
8868 /* Construct the API message */
8869 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8871 mp->sw_if_index = ntohl (sw_if_index);
8872 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8873 mp->address_length = address_length;
8874 mp->use_default = use_default;
8875 mp->no_advertise = no_advertise;
8876 mp->off_link = off_link;
8877 mp->no_autoconfig = no_autoconfig;
8878 mp->no_onlink = no_onlink;
8880 mp->val_lifetime = ntohl (val_lifetime);
8881 mp->pref_lifetime = ntohl (pref_lifetime);
8886 /* Wait for a reply, return good/bad news */
8892 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8894 unformat_input_t *i = vam->input;
8895 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8897 u8 sw_if_index_set = 0;
8902 u8 send_unicast = 0;
8905 u8 default_router = 0;
8906 u32 max_interval = 0;
8907 u32 min_interval = 0;
8909 u32 initial_count = 0;
8910 u32 initial_interval = 0;
8914 /* Parse args required to build the message */
8915 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8917 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8918 sw_if_index_set = 1;
8919 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8920 sw_if_index_set = 1;
8921 else if (unformat (i, "maxint %d", &max_interval))
8923 else if (unformat (i, "minint %d", &min_interval))
8925 else if (unformat (i, "life %d", &lifetime))
8927 else if (unformat (i, "count %d", &initial_count))
8929 else if (unformat (i, "interval %d", &initial_interval))
8931 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8933 else if (unformat (i, "managed"))
8935 else if (unformat (i, "other"))
8937 else if (unformat (i, "ll"))
8939 else if (unformat (i, "send"))
8941 else if (unformat (i, "cease"))
8943 else if (unformat (i, "isno"))
8945 else if (unformat (i, "def"))
8949 clib_warning ("parse error '%U'", format_unformat_error, i);
8954 if (sw_if_index_set == 0)
8956 errmsg ("missing interface name or sw_if_index");
8960 /* Construct the API message */
8961 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8963 mp->sw_if_index = ntohl (sw_if_index);
8964 mp->max_interval = ntohl (max_interval);
8965 mp->min_interval = ntohl (min_interval);
8966 mp->lifetime = ntohl (lifetime);
8967 mp->initial_count = ntohl (initial_count);
8968 mp->initial_interval = ntohl (initial_interval);
8969 mp->suppress = suppress;
8970 mp->managed = managed;
8972 mp->ll_option = ll_option;
8973 mp->send_unicast = send_unicast;
8976 mp->default_router = default_router;
8981 /* Wait for a reply, return good/bad news */
8987 api_set_arp_neighbor_limit (vat_main_t * vam)
8989 unformat_input_t *i = vam->input;
8990 vl_api_set_arp_neighbor_limit_t *mp;
8996 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8998 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9000 else if (unformat (i, "ipv6"))
9004 clib_warning ("parse error '%U'", format_unformat_error, i);
9011 errmsg ("missing limit value");
9015 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9017 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9018 mp->is_ipv6 = is_ipv6;
9026 api_l2_patch_add_del (vat_main_t * vam)
9028 unformat_input_t *i = vam->input;
9029 vl_api_l2_patch_add_del_t *mp;
9031 u8 rx_sw_if_index_set = 0;
9033 u8 tx_sw_if_index_set = 0;
9037 /* Parse args required to build the message */
9038 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9040 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9041 rx_sw_if_index_set = 1;
9042 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9043 tx_sw_if_index_set = 1;
9044 else if (unformat (i, "rx"))
9046 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9048 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9050 rx_sw_if_index_set = 1;
9055 else if (unformat (i, "tx"))
9057 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9059 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9061 tx_sw_if_index_set = 1;
9066 else if (unformat (i, "del"))
9072 if (rx_sw_if_index_set == 0)
9074 errmsg ("missing rx interface name or rx_sw_if_index");
9078 if (tx_sw_if_index_set == 0)
9080 errmsg ("missing tx interface name or tx_sw_if_index");
9084 M (L2_PATCH_ADD_DEL, mp);
9086 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9087 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9088 mp->is_add = is_add;
9096 u8 localsid_addr[16];
9105 api_sr_localsid_add_del (vat_main_t * vam)
9107 unformat_input_t *i = vam->input;
9108 vl_api_sr_localsid_add_del_t *mp;
9111 ip6_address_t localsid;
9115 u32 fib_table = ~(u32) 0;
9116 ip6_address_t next_hop;
9118 bool nexthop_set = 0;
9122 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9124 if (unformat (i, "del"))
9126 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9127 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
9129 else if (unformat (i, "behavior %u", &behavior));
9130 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9131 else if (unformat (i, "fib-table %u", &fib_table));
9132 else if (unformat (i, "end.psp %u", &behavior));
9137 M (SR_LOCALSID_ADD_DEL, mp);
9139 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
9141 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
9142 mp->behavior = behavior;
9143 mp->sw_if_index = ntohl (sw_if_index);
9144 mp->fib_table = ntohl (fib_table);
9145 mp->end_psp = end_psp;
9146 mp->is_del = is_del;
9154 api_ioam_enable (vat_main_t * vam)
9156 unformat_input_t *input = vam->input;
9157 vl_api_ioam_enable_t *mp;
9159 int has_trace_option = 0;
9160 int has_pot_option = 0;
9161 int has_seqno_option = 0;
9162 int has_analyse_option = 0;
9165 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9167 if (unformat (input, "trace"))
9168 has_trace_option = 1;
9169 else if (unformat (input, "pot"))
9171 else if (unformat (input, "seqno"))
9172 has_seqno_option = 1;
9173 else if (unformat (input, "analyse"))
9174 has_analyse_option = 1;
9178 M (IOAM_ENABLE, mp);
9179 mp->id = htons (id);
9180 mp->seqno = has_seqno_option;
9181 mp->analyse = has_analyse_option;
9182 mp->pot_enable = has_pot_option;
9183 mp->trace_enable = has_trace_option;
9192 api_ioam_disable (vat_main_t * vam)
9194 vl_api_ioam_disable_t *mp;
9197 M (IOAM_DISABLE, mp);
9203 #define foreach_tcp_proto_field \
9207 #define foreach_udp_proto_field \
9211 #define foreach_ip4_proto_field \
9223 u16 src_port, dst_port;
9226 #if VPP_API_TEST_BUILTIN == 0
9228 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9230 u8 **maskp = va_arg (*args, u8 **);
9232 u8 found_something = 0;
9235 #define _(a) u8 a=0;
9236 foreach_tcp_proto_field;
9239 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9242 #define _(a) else if (unformat (input, #a)) a=1;
9243 foreach_tcp_proto_field
9249 #define _(a) found_something += a;
9250 foreach_tcp_proto_field;
9253 if (found_something == 0)
9256 vec_validate (mask, sizeof (*tcp) - 1);
9258 tcp = (tcp_header_t *) mask;
9260 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9261 foreach_tcp_proto_field;
9269 unformat_udp_mask (unformat_input_t * input, va_list * args)
9271 u8 **maskp = va_arg (*args, u8 **);
9273 u8 found_something = 0;
9276 #define _(a) u8 a=0;
9277 foreach_udp_proto_field;
9280 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9283 #define _(a) else if (unformat (input, #a)) a=1;
9284 foreach_udp_proto_field
9290 #define _(a) found_something += a;
9291 foreach_udp_proto_field;
9294 if (found_something == 0)
9297 vec_validate (mask, sizeof (*udp) - 1);
9299 udp = (udp_header_t *) mask;
9301 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
9302 foreach_udp_proto_field;
9310 unformat_l4_mask (unformat_input_t * input, va_list * args)
9312 u8 **maskp = va_arg (*args, u8 **);
9313 u16 src_port = 0, dst_port = 0;
9314 tcpudp_header_t *tcpudp;
9316 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9318 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9320 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9322 else if (unformat (input, "src_port"))
9324 else if (unformat (input, "dst_port"))
9330 if (!src_port && !dst_port)
9334 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9336 tcpudp = (tcpudp_header_t *) mask;
9337 tcpudp->src_port = src_port;
9338 tcpudp->dst_port = dst_port;
9346 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9348 u8 **maskp = va_arg (*args, u8 **);
9350 u8 found_something = 0;
9353 #define _(a) u8 a=0;
9354 foreach_ip4_proto_field;
9360 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9362 if (unformat (input, "version"))
9364 else if (unformat (input, "hdr_length"))
9366 else if (unformat (input, "src"))
9368 else if (unformat (input, "dst"))
9370 else if (unformat (input, "proto"))
9373 #define _(a) else if (unformat (input, #a)) a=1;
9374 foreach_ip4_proto_field
9380 #define _(a) found_something += a;
9381 foreach_ip4_proto_field;
9384 if (found_something == 0)
9387 vec_validate (mask, sizeof (*ip) - 1);
9389 ip = (ip4_header_t *) mask;
9391 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9392 foreach_ip4_proto_field;
9395 ip->ip_version_and_header_length = 0;
9398 ip->ip_version_and_header_length |= 0xF0;
9401 ip->ip_version_and_header_length |= 0x0F;
9407 #define foreach_ip6_proto_field \
9415 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9417 u8 **maskp = va_arg (*args, u8 **);
9419 u8 found_something = 0;
9421 u32 ip_version_traffic_class_and_flow_label;
9423 #define _(a) u8 a=0;
9424 foreach_ip6_proto_field;
9427 u8 traffic_class = 0;
9430 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9432 if (unformat (input, "version"))
9434 else if (unformat (input, "traffic-class"))
9436 else if (unformat (input, "flow-label"))
9438 else if (unformat (input, "src"))
9440 else if (unformat (input, "dst"))
9442 else if (unformat (input, "proto"))
9445 #define _(a) else if (unformat (input, #a)) a=1;
9446 foreach_ip6_proto_field
9452 #define _(a) found_something += a;
9453 foreach_ip6_proto_field;
9456 if (found_something == 0)
9459 vec_validate (mask, sizeof (*ip) - 1);
9461 ip = (ip6_header_t *) mask;
9463 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9464 foreach_ip6_proto_field;
9467 ip_version_traffic_class_and_flow_label = 0;
9470 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9473 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9476 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9478 ip->ip_version_traffic_class_and_flow_label =
9479 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9486 unformat_l3_mask (unformat_input_t * input, va_list * args)
9488 u8 **maskp = va_arg (*args, u8 **);
9490 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9492 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9494 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9503 unformat_l2_mask (unformat_input_t * input, va_list * args)
9505 u8 **maskp = va_arg (*args, u8 **);
9520 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9522 if (unformat (input, "src"))
9524 else if (unformat (input, "dst"))
9526 else if (unformat (input, "proto"))
9528 else if (unformat (input, "tag1"))
9530 else if (unformat (input, "tag2"))
9532 else if (unformat (input, "ignore-tag1"))
9534 else if (unformat (input, "ignore-tag2"))
9536 else if (unformat (input, "cos1"))
9538 else if (unformat (input, "cos2"))
9540 else if (unformat (input, "dot1q"))
9542 else if (unformat (input, "dot1ad"))
9547 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9548 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9551 if (tag1 || ignore_tag1 || cos1 || dot1q)
9553 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9556 vec_validate (mask, len - 1);
9559 memset (mask, 0xff, 6);
9562 memset (mask + 6, 0xff, 6);
9566 /* inner vlan tag */
9575 mask[21] = mask[20] = 0xff;
9596 mask[16] = mask[17] = 0xff;
9606 mask[12] = mask[13] = 0xff;
9613 unformat_classify_mask (unformat_input_t * input, va_list * args)
9615 u8 **maskp = va_arg (*args, u8 **);
9616 u32 *skipp = va_arg (*args, u32 *);
9617 u32 *matchp = va_arg (*args, u32 *);
9625 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9627 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9629 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9631 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9633 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9647 if (mask || l2 || l3 || l4)
9651 /* "With a free Ethernet header in every package" */
9653 vec_validate (l2, 13);
9657 vec_append (mask, l3);
9662 vec_append (mask, l4);
9667 /* Scan forward looking for the first significant mask octet */
9668 for (i = 0; i < vec_len (mask); i++)
9672 /* compute (skip, match) params */
9673 *skipp = i / sizeof (u32x4);
9674 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9676 /* Pad mask to an even multiple of the vector size */
9677 while (vec_len (mask) % sizeof (u32x4))
9680 match = vec_len (mask) / sizeof (u32x4);
9682 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9684 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9685 if (*tmp || *(tmp + 1))
9690 clib_warning ("BUG: match 0");
9692 _vec_len (mask) = match * sizeof (u32x4);
9702 #endif /* VPP_API_TEST_BUILTIN */
9704 #define foreach_l2_next \
9706 _(ethernet, ETHERNET_INPUT) \
9711 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9713 u32 *miss_next_indexp = va_arg (*args, u32 *);
9718 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9722 if (unformat (input, "%d", &tmp))
9731 *miss_next_indexp = next_index;
9735 #define foreach_ip_next \
9741 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9743 u32 *miss_next_indexp = va_arg (*args, u32 *);
9748 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9752 if (unformat (input, "%d", &tmp))
9761 *miss_next_indexp = next_index;
9765 #define foreach_acl_next \
9769 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9771 u32 *miss_next_indexp = va_arg (*args, u32 *);
9776 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9780 if (unformat (input, "permit"))
9785 else if (unformat (input, "%d", &tmp))
9794 *miss_next_indexp = next_index;
9799 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9801 u32 *r = va_arg (*args, u32 *);
9803 if (unformat (input, "conform-color"))
9804 *r = POLICE_CONFORM;
9805 else if (unformat (input, "exceed-color"))
9814 api_classify_add_del_table (vat_main_t * vam)
9816 unformat_input_t *i = vam->input;
9817 vl_api_classify_add_del_table_t *mp;
9824 u32 table_index = ~0;
9825 u32 next_table_index = ~0;
9826 u32 miss_next_index = ~0;
9827 u32 memory_size = 32 << 20;
9829 u32 current_data_flag = 0;
9830 int current_data_offset = 0;
9833 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9835 if (unformat (i, "del"))
9837 else if (unformat (i, "del-chain"))
9842 else if (unformat (i, "buckets %d", &nbuckets))
9844 else if (unformat (i, "memory_size %d", &memory_size))
9846 else if (unformat (i, "skip %d", &skip))
9848 else if (unformat (i, "match %d", &match))
9850 else if (unformat (i, "table %d", &table_index))
9852 else if (unformat (i, "mask %U", unformat_classify_mask,
9853 &mask, &skip, &match))
9855 else if (unformat (i, "next-table %d", &next_table_index))
9857 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9860 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9863 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9866 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9868 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9874 if (is_add && mask == 0)
9876 errmsg ("Mask required");
9880 if (is_add && skip == ~0)
9882 errmsg ("skip count required");
9886 if (is_add && match == ~0)
9888 errmsg ("match count required");
9892 if (!is_add && table_index == ~0)
9894 errmsg ("table index required for delete");
9898 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9900 mp->is_add = is_add;
9901 mp->del_chain = del_chain;
9902 mp->table_index = ntohl (table_index);
9903 mp->nbuckets = ntohl (nbuckets);
9904 mp->memory_size = ntohl (memory_size);
9905 mp->skip_n_vectors = ntohl (skip);
9906 mp->match_n_vectors = ntohl (match);
9907 mp->next_table_index = ntohl (next_table_index);
9908 mp->miss_next_index = ntohl (miss_next_index);
9909 mp->current_data_flag = ntohl (current_data_flag);
9910 mp->current_data_offset = ntohl (current_data_offset);
9911 clib_memcpy (mp->mask, mask, vec_len (mask));
9920 #if VPP_API_TEST_BUILTIN == 0
9922 unformat_l4_match (unformat_input_t * input, va_list * args)
9924 u8 **matchp = va_arg (*args, u8 **);
9926 u8 *proto_header = 0;
9932 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9934 if (unformat (input, "src_port %d", &src_port))
9936 else if (unformat (input, "dst_port %d", &dst_port))
9942 h.src_port = clib_host_to_net_u16 (src_port);
9943 h.dst_port = clib_host_to_net_u16 (dst_port);
9944 vec_validate (proto_header, sizeof (h) - 1);
9945 memcpy (proto_header, &h, sizeof (h));
9947 *matchp = proto_header;
9953 unformat_ip4_match (unformat_input_t * input, va_list * args)
9955 u8 **matchp = va_arg (*args, u8 **);
9962 int src = 0, dst = 0;
9963 ip4_address_t src_val, dst_val;
9970 int fragment_id = 0;
9971 u32 fragment_id_val;
9977 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9979 if (unformat (input, "version %d", &version_val))
9981 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9983 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9985 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9987 else if (unformat (input, "proto %d", &proto_val))
9989 else if (unformat (input, "tos %d", &tos_val))
9991 else if (unformat (input, "length %d", &length_val))
9993 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9995 else if (unformat (input, "ttl %d", &ttl_val))
9997 else if (unformat (input, "checksum %d", &checksum_val))
10003 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10004 + ttl + checksum == 0)
10008 * Aligned because we use the real comparison functions
10010 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10012 ip = (ip4_header_t *) match;
10014 /* These are realistically matched in practice */
10016 ip->src_address.as_u32 = src_val.as_u32;
10019 ip->dst_address.as_u32 = dst_val.as_u32;
10022 ip->protocol = proto_val;
10025 /* These are not, but they're included for completeness */
10027 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10030 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10036 ip->length = clib_host_to_net_u16 (length_val);
10042 ip->checksum = clib_host_to_net_u16 (checksum_val);
10049 unformat_ip6_match (unformat_input_t * input, va_list * args)
10051 u8 **matchp = va_arg (*args, u8 **);
10056 u8 traffic_class = 0;
10057 u32 traffic_class_val = 0;
10060 int src = 0, dst = 0;
10061 ip6_address_t src_val, dst_val;
10064 int payload_length = 0;
10065 u32 payload_length_val;
10068 u32 ip_version_traffic_class_and_flow_label;
10070 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10072 if (unformat (input, "version %d", &version_val))
10074 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10076 else if (unformat (input, "flow_label %d", &flow_label_val))
10078 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10080 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10082 else if (unformat (input, "proto %d", &proto_val))
10084 else if (unformat (input, "payload_length %d", &payload_length_val))
10085 payload_length = 1;
10086 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10092 if (version + traffic_class + flow_label + src + dst + proto +
10093 payload_length + hop_limit == 0)
10097 * Aligned because we use the real comparison functions
10099 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10101 ip = (ip6_header_t *) match;
10104 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10107 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10110 ip->protocol = proto_val;
10112 ip_version_traffic_class_and_flow_label = 0;
10115 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10118 ip_version_traffic_class_and_flow_label |=
10119 (traffic_class_val & 0xFF) << 20;
10122 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10124 ip->ip_version_traffic_class_and_flow_label =
10125 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10127 if (payload_length)
10128 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10131 ip->hop_limit = hop_limit_val;
10138 unformat_l3_match (unformat_input_t * input, va_list * args)
10140 u8 **matchp = va_arg (*args, u8 **);
10142 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10144 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10146 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10155 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10157 u8 *tagp = va_arg (*args, u8 *);
10160 if (unformat (input, "%d", &tag))
10162 tagp[0] = (tag >> 8) & 0x0F;
10163 tagp[1] = tag & 0xFF;
10171 unformat_l2_match (unformat_input_t * input, va_list * args)
10173 u8 **matchp = va_arg (*args, u8 **);
10186 u8 ignore_tag1 = 0;
10187 u8 ignore_tag2 = 0;
10193 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10195 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10198 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10200 else if (unformat (input, "proto %U",
10201 unformat_ethernet_type_host_byte_order, &proto_val))
10203 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10205 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10207 else if (unformat (input, "ignore-tag1"))
10209 else if (unformat (input, "ignore-tag2"))
10211 else if (unformat (input, "cos1 %d", &cos1_val))
10213 else if (unformat (input, "cos2 %d", &cos2_val))
10218 if ((src + dst + proto + tag1 + tag2 +
10219 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10222 if (tag1 || ignore_tag1 || cos1)
10224 if (tag2 || ignore_tag2 || cos2)
10227 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10230 clib_memcpy (match, dst_val, 6);
10233 clib_memcpy (match + 6, src_val, 6);
10237 /* inner vlan tag */
10238 match[19] = tag2_val[1];
10239 match[18] = tag2_val[0];
10241 match[18] |= (cos2_val & 0x7) << 5;
10244 match[21] = proto_val & 0xff;
10245 match[20] = proto_val >> 8;
10249 match[15] = tag1_val[1];
10250 match[14] = tag1_val[0];
10253 match[14] |= (cos1_val & 0x7) << 5;
10259 match[15] = tag1_val[1];
10260 match[14] = tag1_val[0];
10263 match[17] = proto_val & 0xff;
10264 match[16] = proto_val >> 8;
10267 match[14] |= (cos1_val & 0x7) << 5;
10273 match[18] |= (cos2_val & 0x7) << 5;
10275 match[14] |= (cos1_val & 0x7) << 5;
10278 match[13] = proto_val & 0xff;
10279 match[12] = proto_val >> 8;
10288 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10290 u8 **matchp = va_arg (*args, u8 **);
10291 u32 skip_n_vectors = va_arg (*args, u32);
10292 u32 match_n_vectors = va_arg (*args, u32);
10299 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10301 if (unformat (input, "hex %U", unformat_hex_string, &match))
10303 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10305 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10307 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10321 if (match || l2 || l3 || l4)
10323 if (l2 || l3 || l4)
10325 /* "Win a free Ethernet header in every packet" */
10327 vec_validate_aligned (l2, 13, sizeof (u32x4));
10331 vec_append_aligned (match, l3, sizeof (u32x4));
10336 vec_append_aligned (match, l4, sizeof (u32x4));
10341 /* Make sure the vector is big enough even if key is all 0's */
10342 vec_validate_aligned
10343 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10346 /* Set size, include skipped vectors */
10347 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10358 api_classify_add_del_session (vat_main_t * vam)
10360 unformat_input_t *i = vam->input;
10361 vl_api_classify_add_del_session_t *mp;
10363 u32 table_index = ~0;
10364 u32 hit_next_index = ~0;
10365 u32 opaque_index = ~0;
10368 u32 skip_n_vectors = 0;
10369 u32 match_n_vectors = 0;
10375 * Warning: you have to supply skip_n and match_n
10376 * because the API client cant simply look at the classify
10380 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10382 if (unformat (i, "del"))
10384 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10387 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10390 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10393 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10395 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10397 else if (unformat (i, "opaque-index %d", &opaque_index))
10399 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10401 else if (unformat (i, "match_n %d", &match_n_vectors))
10403 else if (unformat (i, "match %U", api_unformat_classify_match,
10404 &match, skip_n_vectors, match_n_vectors))
10406 else if (unformat (i, "advance %d", &advance))
10408 else if (unformat (i, "table-index %d", &table_index))
10410 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10412 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10414 else if (unformat (i, "action %d", &action))
10416 else if (unformat (i, "metadata %d", &metadata))
10422 if (table_index == ~0)
10424 errmsg ("Table index required");
10428 if (is_add && match == 0)
10430 errmsg ("Match value required");
10434 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10436 mp->is_add = is_add;
10437 mp->table_index = ntohl (table_index);
10438 mp->hit_next_index = ntohl (hit_next_index);
10439 mp->opaque_index = ntohl (opaque_index);
10440 mp->advance = ntohl (advance);
10441 mp->action = action;
10442 mp->metadata = ntohl (metadata);
10443 clib_memcpy (mp->match, match, vec_len (match));
10452 api_classify_set_interface_ip_table (vat_main_t * vam)
10454 unformat_input_t *i = vam->input;
10455 vl_api_classify_set_interface_ip_table_t *mp;
10457 int sw_if_index_set;
10458 u32 table_index = ~0;
10462 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10464 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10465 sw_if_index_set = 1;
10466 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10467 sw_if_index_set = 1;
10468 else if (unformat (i, "table %d", &table_index))
10472 clib_warning ("parse error '%U'", format_unformat_error, i);
10477 if (sw_if_index_set == 0)
10479 errmsg ("missing interface name or sw_if_index");
10484 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10486 mp->sw_if_index = ntohl (sw_if_index);
10487 mp->table_index = ntohl (table_index);
10488 mp->is_ipv6 = is_ipv6;
10496 api_classify_set_interface_l2_tables (vat_main_t * vam)
10498 unformat_input_t *i = vam->input;
10499 vl_api_classify_set_interface_l2_tables_t *mp;
10501 int sw_if_index_set;
10502 u32 ip4_table_index = ~0;
10503 u32 ip6_table_index = ~0;
10504 u32 other_table_index = ~0;
10508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10510 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10511 sw_if_index_set = 1;
10512 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10513 sw_if_index_set = 1;
10514 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10516 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10518 else if (unformat (i, "other-table %d", &other_table_index))
10520 else if (unformat (i, "is-input %d", &is_input))
10524 clib_warning ("parse error '%U'", format_unformat_error, i);
10529 if (sw_if_index_set == 0)
10531 errmsg ("missing interface name or sw_if_index");
10536 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10538 mp->sw_if_index = ntohl (sw_if_index);
10539 mp->ip4_table_index = ntohl (ip4_table_index);
10540 mp->ip6_table_index = ntohl (ip6_table_index);
10541 mp->other_table_index = ntohl (other_table_index);
10542 mp->is_input = (u8) is_input;
10550 api_set_ipfix_exporter (vat_main_t * vam)
10552 unformat_input_t *i = vam->input;
10553 vl_api_set_ipfix_exporter_t *mp;
10554 ip4_address_t collector_address;
10555 u8 collector_address_set = 0;
10556 u32 collector_port = ~0;
10557 ip4_address_t src_address;
10558 u8 src_address_set = 0;
10561 u32 template_interval = ~0;
10562 u8 udp_checksum = 0;
10565 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10567 if (unformat (i, "collector_address %U", unformat_ip4_address,
10568 &collector_address))
10569 collector_address_set = 1;
10570 else if (unformat (i, "collector_port %d", &collector_port))
10572 else if (unformat (i, "src_address %U", unformat_ip4_address,
10574 src_address_set = 1;
10575 else if (unformat (i, "vrf_id %d", &vrf_id))
10577 else if (unformat (i, "path_mtu %d", &path_mtu))
10579 else if (unformat (i, "template_interval %d", &template_interval))
10581 else if (unformat (i, "udp_checksum"))
10587 if (collector_address_set == 0)
10589 errmsg ("collector_address required");
10593 if (src_address_set == 0)
10595 errmsg ("src_address required");
10599 M (SET_IPFIX_EXPORTER, mp);
10601 memcpy (mp->collector_address, collector_address.data,
10602 sizeof (collector_address.data));
10603 mp->collector_port = htons ((u16) collector_port);
10604 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10605 mp->vrf_id = htonl (vrf_id);
10606 mp->path_mtu = htonl (path_mtu);
10607 mp->template_interval = htonl (template_interval);
10608 mp->udp_checksum = udp_checksum;
10616 api_set_ipfix_classify_stream (vat_main_t * vam)
10618 unformat_input_t *i = vam->input;
10619 vl_api_set_ipfix_classify_stream_t *mp;
10621 u32 src_port = UDP_DST_PORT_ipfix;
10624 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10626 if (unformat (i, "domain %d", &domain_id))
10628 else if (unformat (i, "src_port %d", &src_port))
10632 errmsg ("unknown input `%U'", format_unformat_error, i);
10637 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10639 mp->domain_id = htonl (domain_id);
10640 mp->src_port = htons ((u16) src_port);
10648 api_ipfix_classify_table_add_del (vat_main_t * vam)
10650 unformat_input_t *i = vam->input;
10651 vl_api_ipfix_classify_table_add_del_t *mp;
10653 u32 classify_table_index = ~0;
10655 u8 transport_protocol = 255;
10658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10660 if (unformat (i, "add"))
10662 else if (unformat (i, "del"))
10664 else if (unformat (i, "table %d", &classify_table_index))
10666 else if (unformat (i, "ip4"))
10668 else if (unformat (i, "ip6"))
10670 else if (unformat (i, "tcp"))
10671 transport_protocol = 6;
10672 else if (unformat (i, "udp"))
10673 transport_protocol = 17;
10676 errmsg ("unknown input `%U'", format_unformat_error, i);
10683 errmsg ("expecting: add|del");
10686 if (classify_table_index == ~0)
10688 errmsg ("classifier table not specified");
10691 if (ip_version == 0)
10693 errmsg ("IP version not specified");
10697 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10699 mp->is_add = is_add;
10700 mp->table_id = htonl (classify_table_index);
10701 mp->ip_version = ip_version;
10702 mp->transport_protocol = transport_protocol;
10710 api_get_node_index (vat_main_t * vam)
10712 unformat_input_t *i = vam->input;
10713 vl_api_get_node_index_t *mp;
10717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10719 if (unformat (i, "node %s", &name))
10726 errmsg ("node name required");
10729 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10731 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10735 M (GET_NODE_INDEX, mp);
10736 clib_memcpy (mp->node_name, name, vec_len (name));
10745 api_get_next_index (vat_main_t * vam)
10747 unformat_input_t *i = vam->input;
10748 vl_api_get_next_index_t *mp;
10749 u8 *node_name = 0, *next_node_name = 0;
10752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10754 if (unformat (i, "node-name %s", &node_name))
10756 else if (unformat (i, "next-node-name %s", &next_node_name))
10760 if (node_name == 0)
10762 errmsg ("node name required");
10765 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10767 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10771 if (next_node_name == 0)
10773 errmsg ("next node name required");
10776 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10778 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10782 M (GET_NEXT_INDEX, mp);
10783 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10784 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10785 vec_free (node_name);
10786 vec_free (next_node_name);
10794 api_add_node_next (vat_main_t * vam)
10796 unformat_input_t *i = vam->input;
10797 vl_api_add_node_next_t *mp;
10802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10804 if (unformat (i, "node %s", &name))
10806 else if (unformat (i, "next %s", &next))
10813 errmsg ("node name required");
10816 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10818 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10823 errmsg ("next node required");
10826 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10828 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10832 M (ADD_NODE_NEXT, mp);
10833 clib_memcpy (mp->node_name, name, vec_len (name));
10834 clib_memcpy (mp->next_name, next, vec_len (next));
10844 api_l2tpv3_create_tunnel (vat_main_t * vam)
10846 unformat_input_t *i = vam->input;
10847 ip6_address_t client_address, our_address;
10848 int client_address_set = 0;
10849 int our_address_set = 0;
10850 u32 local_session_id = 0;
10851 u32 remote_session_id = 0;
10852 u64 local_cookie = 0;
10853 u64 remote_cookie = 0;
10854 u8 l2_sublayer_present = 0;
10855 vl_api_l2tpv3_create_tunnel_t *mp;
10858 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10860 if (unformat (i, "client_address %U", unformat_ip6_address,
10862 client_address_set = 1;
10863 else if (unformat (i, "our_address %U", unformat_ip6_address,
10865 our_address_set = 1;
10866 else if (unformat (i, "local_session_id %d", &local_session_id))
10868 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10870 else if (unformat (i, "local_cookie %lld", &local_cookie))
10872 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10874 else if (unformat (i, "l2-sublayer-present"))
10875 l2_sublayer_present = 1;
10880 if (client_address_set == 0)
10882 errmsg ("client_address required");
10886 if (our_address_set == 0)
10888 errmsg ("our_address required");
10892 M (L2TPV3_CREATE_TUNNEL, mp);
10894 clib_memcpy (mp->client_address, client_address.as_u8,
10895 sizeof (mp->client_address));
10897 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10899 mp->local_session_id = ntohl (local_session_id);
10900 mp->remote_session_id = ntohl (remote_session_id);
10901 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10902 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10903 mp->l2_sublayer_present = l2_sublayer_present;
10912 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10914 unformat_input_t *i = vam->input;
10916 u8 sw_if_index_set = 0;
10917 u64 new_local_cookie = 0;
10918 u64 new_remote_cookie = 0;
10919 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10922 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10924 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10925 sw_if_index_set = 1;
10926 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10927 sw_if_index_set = 1;
10928 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10930 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10936 if (sw_if_index_set == 0)
10938 errmsg ("missing interface name or sw_if_index");
10942 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10944 mp->sw_if_index = ntohl (sw_if_index);
10945 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10946 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10954 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10956 unformat_input_t *i = vam->input;
10957 vl_api_l2tpv3_interface_enable_disable_t *mp;
10959 u8 sw_if_index_set = 0;
10960 u8 enable_disable = 1;
10963 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10965 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10966 sw_if_index_set = 1;
10967 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10968 sw_if_index_set = 1;
10969 else if (unformat (i, "enable"))
10970 enable_disable = 1;
10971 else if (unformat (i, "disable"))
10972 enable_disable = 0;
10977 if (sw_if_index_set == 0)
10979 errmsg ("missing interface name or sw_if_index");
10983 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10985 mp->sw_if_index = ntohl (sw_if_index);
10986 mp->enable_disable = enable_disable;
10994 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10996 unformat_input_t *i = vam->input;
10997 vl_api_l2tpv3_set_lookup_key_t *mp;
11001 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11003 if (unformat (i, "lookup_v6_src"))
11004 key = L2T_LOOKUP_SRC_ADDRESS;
11005 else if (unformat (i, "lookup_v6_dst"))
11006 key = L2T_LOOKUP_DST_ADDRESS;
11007 else if (unformat (i, "lookup_session_id"))
11008 key = L2T_LOOKUP_SESSION_ID;
11013 if (key == (u8) ~ 0)
11015 errmsg ("l2tp session lookup key unset");
11019 M (L2TPV3_SET_LOOKUP_KEY, mp);
11028 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11029 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11031 vat_main_t *vam = &vat_main;
11033 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11034 format_ip6_address, mp->our_address,
11035 format_ip6_address, mp->client_address,
11036 clib_net_to_host_u32 (mp->sw_if_index));
11039 " local cookies %016llx %016llx remote cookie %016llx",
11040 clib_net_to_host_u64 (mp->local_cookie[0]),
11041 clib_net_to_host_u64 (mp->local_cookie[1]),
11042 clib_net_to_host_u64 (mp->remote_cookie));
11044 print (vam->ofp, " local session-id %d remote session-id %d",
11045 clib_net_to_host_u32 (mp->local_session_id),
11046 clib_net_to_host_u32 (mp->remote_session_id));
11048 print (vam->ofp, " l2 specific sublayer %s\n",
11049 mp->l2_sublayer_present ? "preset" : "absent");
11053 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11054 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11056 vat_main_t *vam = &vat_main;
11057 vat_json_node_t *node = NULL;
11058 struct in6_addr addr;
11060 if (VAT_JSON_ARRAY != vam->json_tree.type)
11062 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11063 vat_json_init_array (&vam->json_tree);
11065 node = vat_json_array_add (&vam->json_tree);
11067 vat_json_init_object (node);
11069 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11070 vat_json_object_add_ip6 (node, "our_address", addr);
11071 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11072 vat_json_object_add_ip6 (node, "client_address", addr);
11074 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11075 vat_json_init_array (lc);
11076 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11077 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11078 vat_json_object_add_uint (node, "remote_cookie",
11079 clib_net_to_host_u64 (mp->remote_cookie));
11081 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11082 vat_json_object_add_uint (node, "local_session_id",
11083 clib_net_to_host_u32 (mp->local_session_id));
11084 vat_json_object_add_uint (node, "remote_session_id",
11085 clib_net_to_host_u32 (mp->remote_session_id));
11086 vat_json_object_add_string_copy (node, "l2_sublayer",
11087 mp->l2_sublayer_present ? (u8 *) "present"
11088 : (u8 *) "absent");
11092 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11094 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11095 vl_api_control_ping_t *mp_ping;
11098 /* Get list of l2tpv3-tunnel interfaces */
11099 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11102 /* Use a control ping for synchronization */
11103 M (CONTROL_PING, mp_ping);
11111 static void vl_api_sw_interface_tap_details_t_handler
11112 (vl_api_sw_interface_tap_details_t * mp)
11114 vat_main_t *vam = &vat_main;
11116 print (vam->ofp, "%-16s %d",
11117 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
11120 static void vl_api_sw_interface_tap_details_t_handler_json
11121 (vl_api_sw_interface_tap_details_t * mp)
11123 vat_main_t *vam = &vat_main;
11124 vat_json_node_t *node = NULL;
11126 if (VAT_JSON_ARRAY != vam->json_tree.type)
11128 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11129 vat_json_init_array (&vam->json_tree);
11131 node = vat_json_array_add (&vam->json_tree);
11133 vat_json_init_object (node);
11134 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11135 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11139 api_sw_interface_tap_dump (vat_main_t * vam)
11141 vl_api_sw_interface_tap_dump_t *mp;
11142 vl_api_control_ping_t *mp_ping;
11145 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
11146 /* Get list of tap interfaces */
11147 M (SW_INTERFACE_TAP_DUMP, mp);
11150 /* Use a control ping for synchronization */
11151 M (CONTROL_PING, mp_ping);
11158 static uword unformat_vxlan_decap_next
11159 (unformat_input_t * input, va_list * args)
11161 u32 *result = va_arg (*args, u32 *);
11164 if (unformat (input, "l2"))
11165 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11166 else if (unformat (input, "%d", &tmp))
11174 api_vxlan_add_del_tunnel (vat_main_t * vam)
11176 unformat_input_t *line_input = vam->input;
11177 vl_api_vxlan_add_del_tunnel_t *mp;
11178 ip46_address_t src, dst;
11180 u8 ipv4_set = 0, ipv6_set = 0;
11184 u32 mcast_sw_if_index = ~0;
11185 u32 encap_vrf_id = 0;
11186 u32 decap_next_index = ~0;
11190 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11191 memset (&src, 0, sizeof src);
11192 memset (&dst, 0, sizeof dst);
11194 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11196 if (unformat (line_input, "del"))
11199 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11205 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11211 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11217 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11222 else if (unformat (line_input, "group %U %U",
11223 unformat_ip4_address, &dst.ip4,
11224 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11226 grp_set = dst_set = 1;
11229 else if (unformat (line_input, "group %U",
11230 unformat_ip4_address, &dst.ip4))
11232 grp_set = dst_set = 1;
11235 else if (unformat (line_input, "group %U %U",
11236 unformat_ip6_address, &dst.ip6,
11237 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11239 grp_set = dst_set = 1;
11242 else if (unformat (line_input, "group %U",
11243 unformat_ip6_address, &dst.ip6))
11245 grp_set = dst_set = 1;
11249 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11251 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11253 else if (unformat (line_input, "decap-next %U",
11254 unformat_vxlan_decap_next, &decap_next_index))
11256 else if (unformat (line_input, "vni %d", &vni))
11260 errmsg ("parse error '%U'", format_unformat_error, line_input);
11267 errmsg ("tunnel src address not specified");
11272 errmsg ("tunnel dst address not specified");
11276 if (grp_set && !ip46_address_is_multicast (&dst))
11278 errmsg ("tunnel group address not multicast");
11281 if (grp_set && mcast_sw_if_index == ~0)
11283 errmsg ("tunnel nonexistent multicast device");
11286 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11288 errmsg ("tunnel dst address must be unicast");
11293 if (ipv4_set && ipv6_set)
11295 errmsg ("both IPv4 and IPv6 addresses specified");
11299 if ((vni == 0) || (vni >> 24))
11301 errmsg ("vni not specified or out of range");
11305 M (VXLAN_ADD_DEL_TUNNEL, mp);
11309 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
11310 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
11314 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
11315 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
11317 mp->encap_vrf_id = ntohl (encap_vrf_id);
11318 mp->decap_next_index = ntohl (decap_next_index);
11319 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11320 mp->vni = ntohl (vni);
11321 mp->is_add = is_add;
11322 mp->is_ipv6 = ipv6_set;
11329 static void vl_api_vxlan_tunnel_details_t_handler
11330 (vl_api_vxlan_tunnel_details_t * mp)
11332 vat_main_t *vam = &vat_main;
11333 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
11334 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
11336 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
11337 ntohl (mp->sw_if_index),
11338 format_ip46_address, &src, IP46_TYPE_ANY,
11339 format_ip46_address, &dst, IP46_TYPE_ANY,
11340 ntohl (mp->encap_vrf_id),
11341 ntohl (mp->decap_next_index), ntohl (mp->vni),
11342 ntohl (mp->mcast_sw_if_index));
11345 static void vl_api_vxlan_tunnel_details_t_handler_json
11346 (vl_api_vxlan_tunnel_details_t * mp)
11348 vat_main_t *vam = &vat_main;
11349 vat_json_node_t *node = NULL;
11351 if (VAT_JSON_ARRAY != vam->json_tree.type)
11353 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11354 vat_json_init_array (&vam->json_tree);
11356 node = vat_json_array_add (&vam->json_tree);
11358 vat_json_init_object (node);
11359 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11362 struct in6_addr ip6;
11364 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
11365 vat_json_object_add_ip6 (node, "src_address", ip6);
11366 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
11367 vat_json_object_add_ip6 (node, "dst_address", ip6);
11371 struct in_addr ip4;
11373 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
11374 vat_json_object_add_ip4 (node, "src_address", ip4);
11375 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
11376 vat_json_object_add_ip4 (node, "dst_address", ip4);
11378 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11379 vat_json_object_add_uint (node, "decap_next_index",
11380 ntohl (mp->decap_next_index));
11381 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11382 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11383 vat_json_object_add_uint (node, "mcast_sw_if_index",
11384 ntohl (mp->mcast_sw_if_index));
11388 api_vxlan_tunnel_dump (vat_main_t * vam)
11390 unformat_input_t *i = vam->input;
11391 vl_api_vxlan_tunnel_dump_t *mp;
11392 vl_api_control_ping_t *mp_ping;
11394 u8 sw_if_index_set = 0;
11397 /* Parse args required to build the message */
11398 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11400 if (unformat (i, "sw_if_index %d", &sw_if_index))
11401 sw_if_index_set = 1;
11406 if (sw_if_index_set == 0)
11411 if (!vam->json_output)
11413 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
11414 "sw_if_index", "src_address", "dst_address",
11415 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11418 /* Get list of vxlan-tunnel interfaces */
11419 M (VXLAN_TUNNEL_DUMP, mp);
11421 mp->sw_if_index = htonl (sw_if_index);
11425 /* Use a control ping for synchronization */
11426 M (CONTROL_PING, mp_ping);
11434 api_gre_add_del_tunnel (vat_main_t * vam)
11436 unformat_input_t *line_input = vam->input;
11437 vl_api_gre_add_del_tunnel_t *mp;
11438 ip4_address_t src4, dst4;
11439 ip6_address_t src6, dst6;
11446 u32 outer_fib_id = 0;
11449 memset (&src4, 0, sizeof src4);
11450 memset (&dst4, 0, sizeof dst4);
11451 memset (&src6, 0, sizeof src6);
11452 memset (&dst6, 0, sizeof dst6);
11454 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11456 if (unformat (line_input, "del"))
11458 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
11463 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
11468 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
11473 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
11478 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
11480 else if (unformat (line_input, "teb"))
11484 errmsg ("parse error '%U'", format_unformat_error, line_input);
11491 errmsg ("tunnel src address not specified");
11496 errmsg ("tunnel dst address not specified");
11499 if (ipv4_set && ipv6_set)
11501 errmsg ("both IPv4 and IPv6 addresses specified");
11506 M (GRE_ADD_DEL_TUNNEL, mp);
11510 clib_memcpy (&mp->src_address, &src4, 4);
11511 clib_memcpy (&mp->dst_address, &dst4, 4);
11515 clib_memcpy (&mp->src_address, &src6, 16);
11516 clib_memcpy (&mp->dst_address, &dst6, 16);
11518 mp->outer_fib_id = ntohl (outer_fib_id);
11519 mp->is_add = is_add;
11521 mp->is_ipv6 = ipv6_set;
11528 static void vl_api_gre_tunnel_details_t_handler
11529 (vl_api_gre_tunnel_details_t * mp)
11531 vat_main_t *vam = &vat_main;
11532 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
11533 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
11535 print (vam->ofp, "%11d%24U%24U%6d%14d",
11536 ntohl (mp->sw_if_index),
11537 format_ip46_address, &src, IP46_TYPE_ANY,
11538 format_ip46_address, &dst, IP46_TYPE_ANY,
11539 mp->teb, ntohl (mp->outer_fib_id));
11542 static void vl_api_gre_tunnel_details_t_handler_json
11543 (vl_api_gre_tunnel_details_t * mp)
11545 vat_main_t *vam = &vat_main;
11546 vat_json_node_t *node = NULL;
11547 struct in_addr ip4;
11548 struct in6_addr ip6;
11550 if (VAT_JSON_ARRAY != vam->json_tree.type)
11552 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11553 vat_json_init_array (&vam->json_tree);
11555 node = vat_json_array_add (&vam->json_tree);
11557 vat_json_init_object (node);
11558 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11561 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11562 vat_json_object_add_ip4 (node, "src_address", ip4);
11563 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11564 vat_json_object_add_ip4 (node, "dst_address", ip4);
11568 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
11569 vat_json_object_add_ip6 (node, "src_address", ip6);
11570 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
11571 vat_json_object_add_ip6 (node, "dst_address", ip6);
11573 vat_json_object_add_uint (node, "teb", mp->teb);
11574 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11575 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
11579 api_gre_tunnel_dump (vat_main_t * vam)
11581 unformat_input_t *i = vam->input;
11582 vl_api_gre_tunnel_dump_t *mp;
11583 vl_api_control_ping_t *mp_ping;
11585 u8 sw_if_index_set = 0;
11588 /* Parse args required to build the message */
11589 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11591 if (unformat (i, "sw_if_index %d", &sw_if_index))
11592 sw_if_index_set = 1;
11597 if (sw_if_index_set == 0)
11602 if (!vam->json_output)
11604 print (vam->ofp, "%11s%24s%24s%6s%14s",
11605 "sw_if_index", "src_address", "dst_address", "teb",
11609 /* Get list of gre-tunnel interfaces */
11610 M (GRE_TUNNEL_DUMP, mp);
11612 mp->sw_if_index = htonl (sw_if_index);
11616 /* Use a control ping for synchronization */
11617 M (CONTROL_PING, mp_ping);
11625 api_l2_fib_clear_table (vat_main_t * vam)
11627 // unformat_input_t * i = vam->input;
11628 vl_api_l2_fib_clear_table_t *mp;
11631 M (L2_FIB_CLEAR_TABLE, mp);
11639 api_l2_interface_efp_filter (vat_main_t * vam)
11641 unformat_input_t *i = vam->input;
11642 vl_api_l2_interface_efp_filter_t *mp;
11645 u8 sw_if_index_set = 0;
11648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11650 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11651 sw_if_index_set = 1;
11652 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11653 sw_if_index_set = 1;
11654 else if (unformat (i, "enable"))
11656 else if (unformat (i, "disable"))
11660 clib_warning ("parse error '%U'", format_unformat_error, i);
11665 if (sw_if_index_set == 0)
11667 errmsg ("missing sw_if_index");
11671 M (L2_INTERFACE_EFP_FILTER, mp);
11673 mp->sw_if_index = ntohl (sw_if_index);
11674 mp->enable_disable = enable;
11681 #define foreach_vtr_op \
11682 _("disable", L2_VTR_DISABLED) \
11683 _("push-1", L2_VTR_PUSH_1) \
11684 _("push-2", L2_VTR_PUSH_2) \
11685 _("pop-1", L2_VTR_POP_1) \
11686 _("pop-2", L2_VTR_POP_2) \
11687 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11688 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11689 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11690 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11693 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11695 unformat_input_t *i = vam->input;
11696 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11698 u8 sw_if_index_set = 0;
11701 u32 push_dot1q = 1;
11706 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11708 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11709 sw_if_index_set = 1;
11710 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11711 sw_if_index_set = 1;
11712 else if (unformat (i, "vtr_op %d", &vtr_op))
11714 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11717 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11719 else if (unformat (i, "tag1 %d", &tag1))
11721 else if (unformat (i, "tag2 %d", &tag2))
11725 clib_warning ("parse error '%U'", format_unformat_error, i);
11730 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11732 errmsg ("missing vtr operation or sw_if_index");
11736 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11737 mp->sw_if_index = ntohl (sw_if_index);
11738 mp->vtr_op = ntohl (vtr_op);
11739 mp->push_dot1q = ntohl (push_dot1q);
11740 mp->tag1 = ntohl (tag1);
11741 mp->tag2 = ntohl (tag2);
11749 api_create_vhost_user_if (vat_main_t * vam)
11751 unformat_input_t *i = vam->input;
11752 vl_api_create_vhost_user_if_t *mp;
11755 u8 file_name_set = 0;
11756 u32 custom_dev_instance = ~0;
11758 u8 use_custom_mac = 0;
11762 /* Shut up coverity */
11763 memset (hwaddr, 0, sizeof (hwaddr));
11765 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11767 if (unformat (i, "socket %s", &file_name))
11771 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11773 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11774 use_custom_mac = 1;
11775 else if (unformat (i, "server"))
11777 else if (unformat (i, "tag %s", &tag))
11783 if (file_name_set == 0)
11785 errmsg ("missing socket file name");
11789 if (vec_len (file_name) > 255)
11791 errmsg ("socket file name too long");
11794 vec_add1 (file_name, 0);
11796 M (CREATE_VHOST_USER_IF, mp);
11798 mp->is_server = is_server;
11799 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11800 vec_free (file_name);
11801 if (custom_dev_instance != ~0)
11804 mp->custom_dev_instance = ntohl (custom_dev_instance);
11806 mp->use_custom_mac = use_custom_mac;
11807 clib_memcpy (mp->mac_address, hwaddr, 6);
11809 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11818 api_modify_vhost_user_if (vat_main_t * vam)
11820 unformat_input_t *i = vam->input;
11821 vl_api_modify_vhost_user_if_t *mp;
11824 u8 file_name_set = 0;
11825 u32 custom_dev_instance = ~0;
11826 u8 sw_if_index_set = 0;
11827 u32 sw_if_index = (u32) ~ 0;
11830 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11832 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11833 sw_if_index_set = 1;
11834 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11835 sw_if_index_set = 1;
11836 else if (unformat (i, "socket %s", &file_name))
11840 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11842 else if (unformat (i, "server"))
11848 if (sw_if_index_set == 0)
11850 errmsg ("missing sw_if_index or interface name");
11854 if (file_name_set == 0)
11856 errmsg ("missing socket file name");
11860 if (vec_len (file_name) > 255)
11862 errmsg ("socket file name too long");
11865 vec_add1 (file_name, 0);
11867 M (MODIFY_VHOST_USER_IF, mp);
11869 mp->sw_if_index = ntohl (sw_if_index);
11870 mp->is_server = is_server;
11871 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11872 vec_free (file_name);
11873 if (custom_dev_instance != ~0)
11876 mp->custom_dev_instance = ntohl (custom_dev_instance);
11885 api_delete_vhost_user_if (vat_main_t * vam)
11887 unformat_input_t *i = vam->input;
11888 vl_api_delete_vhost_user_if_t *mp;
11889 u32 sw_if_index = ~0;
11890 u8 sw_if_index_set = 0;
11893 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11895 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11896 sw_if_index_set = 1;
11897 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11898 sw_if_index_set = 1;
11903 if (sw_if_index_set == 0)
11905 errmsg ("missing sw_if_index or interface name");
11910 M (DELETE_VHOST_USER_IF, mp);
11912 mp->sw_if_index = ntohl (sw_if_index);
11919 static void vl_api_sw_interface_vhost_user_details_t_handler
11920 (vl_api_sw_interface_vhost_user_details_t * mp)
11922 vat_main_t *vam = &vat_main;
11924 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11925 (char *) mp->interface_name,
11926 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11927 clib_net_to_host_u64 (mp->features), mp->is_server,
11928 ntohl (mp->num_regions), (char *) mp->sock_filename);
11929 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11932 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11933 (vl_api_sw_interface_vhost_user_details_t * mp)
11935 vat_main_t *vam = &vat_main;
11936 vat_json_node_t *node = NULL;
11938 if (VAT_JSON_ARRAY != vam->json_tree.type)
11940 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11941 vat_json_init_array (&vam->json_tree);
11943 node = vat_json_array_add (&vam->json_tree);
11945 vat_json_init_object (node);
11946 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11947 vat_json_object_add_string_copy (node, "interface_name",
11948 mp->interface_name);
11949 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11950 ntohl (mp->virtio_net_hdr_sz));
11951 vat_json_object_add_uint (node, "features",
11952 clib_net_to_host_u64 (mp->features));
11953 vat_json_object_add_uint (node, "is_server", mp->is_server);
11954 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11955 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11956 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11960 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11962 vl_api_sw_interface_vhost_user_dump_t *mp;
11963 vl_api_control_ping_t *mp_ping;
11966 "Interface name idx hdr_sz features server regions filename");
11968 /* Get list of vhost-user interfaces */
11969 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11972 /* Use a control ping for synchronization */
11973 M (CONTROL_PING, mp_ping);
11981 api_show_version (vat_main_t * vam)
11983 vl_api_show_version_t *mp;
11986 M (SHOW_VERSION, mp);
11995 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11997 unformat_input_t *line_input = vam->input;
11998 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11999 ip4_address_t local4, remote4;
12000 ip6_address_t local6, remote6;
12002 u8 ipv4_set = 0, ipv6_set = 0;
12005 u32 encap_vrf_id = 0;
12006 u32 decap_vrf_id = 0;
12012 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12014 if (unformat (line_input, "del"))
12016 else if (unformat (line_input, "local %U",
12017 unformat_ip4_address, &local4))
12022 else if (unformat (line_input, "remote %U",
12023 unformat_ip4_address, &remote4))
12028 else if (unformat (line_input, "local %U",
12029 unformat_ip6_address, &local6))
12034 else if (unformat (line_input, "remote %U",
12035 unformat_ip6_address, &remote6))
12040 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12042 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
12044 else if (unformat (line_input, "vni %d", &vni))
12046 else if (unformat (line_input, "next-ip4"))
12048 else if (unformat (line_input, "next-ip6"))
12050 else if (unformat (line_input, "next-ethernet"))
12052 else if (unformat (line_input, "next-nsh"))
12056 errmsg ("parse error '%U'", format_unformat_error, line_input);
12061 if (local_set == 0)
12063 errmsg ("tunnel local address not specified");
12066 if (remote_set == 0)
12068 errmsg ("tunnel remote address not specified");
12071 if (ipv4_set && ipv6_set)
12073 errmsg ("both IPv4 and IPv6 addresses specified");
12079 errmsg ("vni not specified");
12083 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
12088 clib_memcpy (&mp->local, &local6, sizeof (local6));
12089 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
12093 clib_memcpy (&mp->local, &local4, sizeof (local4));
12094 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
12097 mp->encap_vrf_id = ntohl (encap_vrf_id);
12098 mp->decap_vrf_id = ntohl (decap_vrf_id);
12099 mp->protocol = protocol;
12100 mp->vni = ntohl (vni);
12101 mp->is_add = is_add;
12102 mp->is_ipv6 = ipv6_set;
12109 static void vl_api_vxlan_gpe_tunnel_details_t_handler
12110 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12112 vat_main_t *vam = &vat_main;
12114 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
12115 ntohl (mp->sw_if_index),
12116 format_ip46_address, &(mp->local[0]),
12117 format_ip46_address, &(mp->remote[0]),
12119 ntohl (mp->protocol),
12120 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
12123 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
12124 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12126 vat_main_t *vam = &vat_main;
12127 vat_json_node_t *node = NULL;
12128 struct in_addr ip4;
12129 struct in6_addr ip6;
12131 if (VAT_JSON_ARRAY != vam->json_tree.type)
12133 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12134 vat_json_init_array (&vam->json_tree);
12136 node = vat_json_array_add (&vam->json_tree);
12138 vat_json_init_object (node);
12139 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12142 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
12143 vat_json_object_add_ip6 (node, "local", ip6);
12144 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
12145 vat_json_object_add_ip6 (node, "remote", ip6);
12149 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
12150 vat_json_object_add_ip4 (node, "local", ip4);
12151 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
12152 vat_json_object_add_ip4 (node, "remote", ip4);
12154 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12155 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
12156 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12157 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
12158 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12162 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
12164 unformat_input_t *i = vam->input;
12165 vl_api_vxlan_gpe_tunnel_dump_t *mp;
12166 vl_api_control_ping_t *mp_ping;
12168 u8 sw_if_index_set = 0;
12171 /* Parse args required to build the message */
12172 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12174 if (unformat (i, "sw_if_index %d", &sw_if_index))
12175 sw_if_index_set = 1;
12180 if (sw_if_index_set == 0)
12185 if (!vam->json_output)
12187 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
12188 "sw_if_index", "local", "remote", "vni",
12189 "protocol", "encap_vrf_id", "decap_vrf_id");
12192 /* Get list of vxlan-tunnel interfaces */
12193 M (VXLAN_GPE_TUNNEL_DUMP, mp);
12195 mp->sw_if_index = htonl (sw_if_index);
12199 /* Use a control ping for synchronization */
12200 M (CONTROL_PING, mp_ping);
12208 format_l2_fib_mac_address (u8 * s, va_list * args)
12210 u8 *a = va_arg (*args, u8 *);
12212 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
12213 a[2], a[3], a[4], a[5], a[6], a[7]);
12216 static void vl_api_l2_fib_table_details_t_handler
12217 (vl_api_l2_fib_table_details_t * mp)
12219 vat_main_t *vam = &vat_main;
12221 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
12223 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
12224 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
12228 static void vl_api_l2_fib_table_details_t_handler_json
12229 (vl_api_l2_fib_table_details_t * mp)
12231 vat_main_t *vam = &vat_main;
12232 vat_json_node_t *node = NULL;
12234 if (VAT_JSON_ARRAY != vam->json_tree.type)
12236 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12237 vat_json_init_array (&vam->json_tree);
12239 node = vat_json_array_add (&vam->json_tree);
12241 vat_json_init_object (node);
12242 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
12243 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
12244 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12245 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
12246 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
12247 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
12251 api_l2_fib_table_dump (vat_main_t * vam)
12253 unformat_input_t *i = vam->input;
12254 vl_api_l2_fib_table_dump_t *mp;
12255 vl_api_control_ping_t *mp_ping;
12260 /* Parse args required to build the message */
12261 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12263 if (unformat (i, "bd_id %d", &bd_id))
12269 if (bd_id_set == 0)
12271 errmsg ("missing bridge domain");
12275 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
12277 /* Get list of l2 fib entries */
12278 M (L2_FIB_TABLE_DUMP, mp);
12280 mp->bd_id = ntohl (bd_id);
12283 /* Use a control ping for synchronization */
12284 M (CONTROL_PING, mp_ping);
12293 api_interface_name_renumber (vat_main_t * vam)
12295 unformat_input_t *line_input = vam->input;
12296 vl_api_interface_name_renumber_t *mp;
12297 u32 sw_if_index = ~0;
12298 u32 new_show_dev_instance = ~0;
12301 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12303 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
12306 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12308 else if (unformat (line_input, "new_show_dev_instance %d",
12309 &new_show_dev_instance))
12315 if (sw_if_index == ~0)
12317 errmsg ("missing interface name or sw_if_index");
12321 if (new_show_dev_instance == ~0)
12323 errmsg ("missing new_show_dev_instance");
12327 M (INTERFACE_NAME_RENUMBER, mp);
12329 mp->sw_if_index = ntohl (sw_if_index);
12330 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
12338 api_want_ip4_arp_events (vat_main_t * vam)
12340 unformat_input_t *line_input = vam->input;
12341 vl_api_want_ip4_arp_events_t *mp;
12342 ip4_address_t address;
12343 int address_set = 0;
12344 u32 enable_disable = 1;
12347 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12349 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
12351 else if (unformat (line_input, "del"))
12352 enable_disable = 0;
12357 if (address_set == 0)
12359 errmsg ("missing addresses");
12363 M (WANT_IP4_ARP_EVENTS, mp);
12364 mp->enable_disable = enable_disable;
12365 mp->pid = htonl (getpid ());
12366 mp->address = address.as_u32;
12374 api_want_ip6_nd_events (vat_main_t * vam)
12376 unformat_input_t *line_input = vam->input;
12377 vl_api_want_ip6_nd_events_t *mp;
12378 ip6_address_t address;
12379 int address_set = 0;
12380 u32 enable_disable = 1;
12383 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12385 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
12387 else if (unformat (line_input, "del"))
12388 enable_disable = 0;
12393 if (address_set == 0)
12395 errmsg ("missing addresses");
12399 M (WANT_IP6_ND_EVENTS, mp);
12400 mp->enable_disable = enable_disable;
12401 mp->pid = htonl (getpid ());
12402 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
12410 api_input_acl_set_interface (vat_main_t * vam)
12412 unformat_input_t *i = vam->input;
12413 vl_api_input_acl_set_interface_t *mp;
12415 int sw_if_index_set;
12416 u32 ip4_table_index = ~0;
12417 u32 ip6_table_index = ~0;
12418 u32 l2_table_index = ~0;
12422 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12424 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12425 sw_if_index_set = 1;
12426 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12427 sw_if_index_set = 1;
12428 else if (unformat (i, "del"))
12430 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12432 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12434 else if (unformat (i, "l2-table %d", &l2_table_index))
12438 clib_warning ("parse error '%U'", format_unformat_error, i);
12443 if (sw_if_index_set == 0)
12445 errmsg ("missing interface name or sw_if_index");
12449 M (INPUT_ACL_SET_INTERFACE, mp);
12451 mp->sw_if_index = ntohl (sw_if_index);
12452 mp->ip4_table_index = ntohl (ip4_table_index);
12453 mp->ip6_table_index = ntohl (ip6_table_index);
12454 mp->l2_table_index = ntohl (l2_table_index);
12455 mp->is_add = is_add;
12463 api_ip_address_dump (vat_main_t * vam)
12465 unformat_input_t *i = vam->input;
12466 vl_api_ip_address_dump_t *mp;
12467 vl_api_control_ping_t *mp_ping;
12468 u32 sw_if_index = ~0;
12469 u8 sw_if_index_set = 0;
12474 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12476 if (unformat (i, "sw_if_index %d", &sw_if_index))
12477 sw_if_index_set = 1;
12479 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12480 sw_if_index_set = 1;
12481 else if (unformat (i, "ipv4"))
12483 else if (unformat (i, "ipv6"))
12489 if (ipv4_set && ipv6_set)
12491 errmsg ("ipv4 and ipv6 flags cannot be both set");
12495 if ((!ipv4_set) && (!ipv6_set))
12497 errmsg ("no ipv4 nor ipv6 flag set");
12501 if (sw_if_index_set == 0)
12503 errmsg ("missing interface name or sw_if_index");
12507 vam->current_sw_if_index = sw_if_index;
12508 vam->is_ipv6 = ipv6_set;
12510 M (IP_ADDRESS_DUMP, mp);
12511 mp->sw_if_index = ntohl (sw_if_index);
12512 mp->is_ipv6 = ipv6_set;
12515 /* Use a control ping for synchronization */
12516 M (CONTROL_PING, mp_ping);
12524 api_ip_dump (vat_main_t * vam)
12526 vl_api_ip_dump_t *mp;
12527 vl_api_control_ping_t *mp_ping;
12528 unformat_input_t *in = vam->input;
12535 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
12537 if (unformat (in, "ipv4"))
12539 else if (unformat (in, "ipv6"))
12545 if (ipv4_set && ipv6_set)
12547 errmsg ("ipv4 and ipv6 flags cannot be both set");
12551 if ((!ipv4_set) && (!ipv6_set))
12553 errmsg ("no ipv4 nor ipv6 flag set");
12557 is_ipv6 = ipv6_set;
12558 vam->is_ipv6 = is_ipv6;
12560 /* free old data */
12561 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12563 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12565 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12568 mp->is_ipv6 = ipv6_set;
12571 /* Use a control ping for synchronization */
12572 M (CONTROL_PING, mp_ping);
12580 api_ipsec_spd_add_del (vat_main_t * vam)
12582 unformat_input_t *i = vam->input;
12583 vl_api_ipsec_spd_add_del_t *mp;
12588 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12590 if (unformat (i, "spd_id %d", &spd_id))
12592 else if (unformat (i, "del"))
12596 clib_warning ("parse error '%U'", format_unformat_error, i);
12602 errmsg ("spd_id must be set");
12606 M (IPSEC_SPD_ADD_DEL, mp);
12608 mp->spd_id = ntohl (spd_id);
12609 mp->is_add = is_add;
12617 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12619 unformat_input_t *i = vam->input;
12620 vl_api_ipsec_interface_add_del_spd_t *mp;
12622 u8 sw_if_index_set = 0;
12623 u32 spd_id = (u32) ~ 0;
12627 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12629 if (unformat (i, "del"))
12631 else if (unformat (i, "spd_id %d", &spd_id))
12634 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12635 sw_if_index_set = 1;
12636 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12637 sw_if_index_set = 1;
12640 clib_warning ("parse error '%U'", format_unformat_error, i);
12646 if (spd_id == (u32) ~ 0)
12648 errmsg ("spd_id must be set");
12652 if (sw_if_index_set == 0)
12654 errmsg ("missing interface name or sw_if_index");
12658 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12660 mp->spd_id = ntohl (spd_id);
12661 mp->sw_if_index = ntohl (sw_if_index);
12662 mp->is_add = is_add;
12670 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12672 unformat_input_t *i = vam->input;
12673 vl_api_ipsec_spd_add_del_entry_t *mp;
12674 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12675 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12677 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12678 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12679 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12680 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12683 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12684 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12685 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12686 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12687 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12688 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12690 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12692 if (unformat (i, "del"))
12694 if (unformat (i, "outbound"))
12696 if (unformat (i, "inbound"))
12698 else if (unformat (i, "spd_id %d", &spd_id))
12700 else if (unformat (i, "sa_id %d", &sa_id))
12702 else if (unformat (i, "priority %d", &priority))
12704 else if (unformat (i, "protocol %d", &protocol))
12706 else if (unformat (i, "lport_start %d", &lport_start))
12708 else if (unformat (i, "lport_stop %d", &lport_stop))
12710 else if (unformat (i, "rport_start %d", &rport_start))
12712 else if (unformat (i, "rport_stop %d", &rport_stop))
12716 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12722 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12729 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12735 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12742 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12748 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12755 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12761 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12767 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12769 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12771 clib_warning ("unsupported action: 'resolve'");
12777 clib_warning ("parse error '%U'", format_unformat_error, i);
12783 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12785 mp->spd_id = ntohl (spd_id);
12786 mp->priority = ntohl (priority);
12787 mp->is_outbound = is_outbound;
12789 mp->is_ipv6 = is_ipv6;
12790 if (is_ipv6 || is_ip_any)
12792 clib_memcpy (mp->remote_address_start, &raddr6_start,
12793 sizeof (ip6_address_t));
12794 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12795 sizeof (ip6_address_t));
12796 clib_memcpy (mp->local_address_start, &laddr6_start,
12797 sizeof (ip6_address_t));
12798 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12799 sizeof (ip6_address_t));
12803 clib_memcpy (mp->remote_address_start, &raddr4_start,
12804 sizeof (ip4_address_t));
12805 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12806 sizeof (ip4_address_t));
12807 clib_memcpy (mp->local_address_start, &laddr4_start,
12808 sizeof (ip4_address_t));
12809 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12810 sizeof (ip4_address_t));
12812 mp->protocol = (u8) protocol;
12813 mp->local_port_start = ntohs ((u16) lport_start);
12814 mp->local_port_stop = ntohs ((u16) lport_stop);
12815 mp->remote_port_start = ntohs ((u16) rport_start);
12816 mp->remote_port_stop = ntohs ((u16) rport_stop);
12817 mp->policy = (u8) policy;
12818 mp->sa_id = ntohl (sa_id);
12819 mp->is_add = is_add;
12820 mp->is_ip_any = is_ip_any;
12827 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12829 unformat_input_t *i = vam->input;
12830 vl_api_ipsec_sad_add_del_entry_t *mp;
12831 u32 sad_id = 0, spi = 0;
12832 u8 *ck = 0, *ik = 0;
12835 u8 protocol = IPSEC_PROTOCOL_AH;
12836 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12837 u32 crypto_alg = 0, integ_alg = 0;
12838 ip4_address_t tun_src4;
12839 ip4_address_t tun_dst4;
12840 ip6_address_t tun_src6;
12841 ip6_address_t tun_dst6;
12844 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12846 if (unformat (i, "del"))
12848 else if (unformat (i, "sad_id %d", &sad_id))
12850 else if (unformat (i, "spi %d", &spi))
12852 else if (unformat (i, "esp"))
12853 protocol = IPSEC_PROTOCOL_ESP;
12854 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12857 is_tunnel_ipv6 = 0;
12859 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12862 is_tunnel_ipv6 = 0;
12864 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12867 is_tunnel_ipv6 = 1;
12869 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12872 is_tunnel_ipv6 = 1;
12876 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12878 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12879 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12881 clib_warning ("unsupported crypto-alg: '%U'",
12882 format_ipsec_crypto_alg, crypto_alg);
12886 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12890 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12892 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12893 integ_alg >= IPSEC_INTEG_N_ALG)
12895 clib_warning ("unsupported integ-alg: '%U'",
12896 format_ipsec_integ_alg, integ_alg);
12900 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12904 clib_warning ("parse error '%U'", format_unformat_error, i);
12910 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12912 mp->sad_id = ntohl (sad_id);
12913 mp->is_add = is_add;
12914 mp->protocol = protocol;
12915 mp->spi = ntohl (spi);
12916 mp->is_tunnel = is_tunnel;
12917 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12918 mp->crypto_algorithm = crypto_alg;
12919 mp->integrity_algorithm = integ_alg;
12920 mp->crypto_key_length = vec_len (ck);
12921 mp->integrity_key_length = vec_len (ik);
12923 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12924 mp->crypto_key_length = sizeof (mp->crypto_key);
12926 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12927 mp->integrity_key_length = sizeof (mp->integrity_key);
12930 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12932 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12936 if (is_tunnel_ipv6)
12938 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12939 sizeof (ip6_address_t));
12940 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12941 sizeof (ip6_address_t));
12945 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12946 sizeof (ip4_address_t));
12947 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12948 sizeof (ip4_address_t));
12958 api_ipsec_sa_set_key (vat_main_t * vam)
12960 unformat_input_t *i = vam->input;
12961 vl_api_ipsec_sa_set_key_t *mp;
12963 u8 *ck = 0, *ik = 0;
12966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12968 if (unformat (i, "sa_id %d", &sa_id))
12970 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12972 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12976 clib_warning ("parse error '%U'", format_unformat_error, i);
12981 M (IPSEC_SA_SET_KEY, mp);
12983 mp->sa_id = ntohl (sa_id);
12984 mp->crypto_key_length = vec_len (ck);
12985 mp->integrity_key_length = vec_len (ik);
12987 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12988 mp->crypto_key_length = sizeof (mp->crypto_key);
12990 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12991 mp->integrity_key_length = sizeof (mp->integrity_key);
12994 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12996 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13004 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
13006 unformat_input_t *i = vam->input;
13007 vl_api_ipsec_tunnel_if_add_del_t *mp;
13008 u32 local_spi = 0, remote_spi = 0;
13009 u32 crypto_alg = 0, integ_alg = 0;
13010 u8 *lck = NULL, *rck = NULL;
13011 u8 *lik = NULL, *rik = NULL;
13012 ip4_address_t local_ip = { {0} };
13013 ip4_address_t remote_ip = { {0} };
13016 u8 anti_replay = 0;
13019 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13021 if (unformat (i, "del"))
13023 else if (unformat (i, "esn"))
13025 else if (unformat (i, "anti_replay"))
13027 else if (unformat (i, "local_spi %d", &local_spi))
13029 else if (unformat (i, "remote_spi %d", &remote_spi))
13031 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
13033 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
13035 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
13038 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
13040 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
13042 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
13046 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13048 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13049 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13051 errmsg ("unsupported crypto-alg: '%U'\n",
13052 format_ipsec_crypto_alg, crypto_alg);
13058 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13060 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13061 integ_alg >= IPSEC_INTEG_N_ALG)
13063 errmsg ("unsupported integ-alg: '%U'\n",
13064 format_ipsec_integ_alg, integ_alg);
13070 errmsg ("parse error '%U'\n", format_unformat_error, i);
13075 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
13077 mp->is_add = is_add;
13079 mp->anti_replay = anti_replay;
13081 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
13082 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
13084 mp->local_spi = htonl (local_spi);
13085 mp->remote_spi = htonl (remote_spi);
13086 mp->crypto_alg = (u8) crypto_alg;
13088 mp->local_crypto_key_len = 0;
13091 mp->local_crypto_key_len = vec_len (lck);
13092 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
13093 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
13094 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
13097 mp->remote_crypto_key_len = 0;
13100 mp->remote_crypto_key_len = vec_len (rck);
13101 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
13102 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
13103 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
13106 mp->integ_alg = (u8) integ_alg;
13108 mp->local_integ_key_len = 0;
13111 mp->local_integ_key_len = vec_len (lik);
13112 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
13113 mp->local_integ_key_len = sizeof (mp->local_integ_key);
13114 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
13117 mp->remote_integ_key_len = 0;
13120 mp->remote_integ_key_len = vec_len (rik);
13121 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
13122 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
13123 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
13132 api_ikev2_profile_add_del (vat_main_t * vam)
13134 unformat_input_t *i = vam->input;
13135 vl_api_ikev2_profile_add_del_t *mp;
13140 const char *valid_chars = "a-zA-Z0-9_";
13142 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13144 if (unformat (i, "del"))
13146 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13147 vec_add1 (name, 0);
13150 errmsg ("parse error '%U'", format_unformat_error, i);
13155 if (!vec_len (name))
13157 errmsg ("profile name must be specified");
13161 if (vec_len (name) > 64)
13163 errmsg ("profile name too long");
13167 M (IKEV2_PROFILE_ADD_DEL, mp);
13169 clib_memcpy (mp->name, name, vec_len (name));
13170 mp->is_add = is_add;
13179 api_ikev2_profile_set_auth (vat_main_t * vam)
13181 unformat_input_t *i = vam->input;
13182 vl_api_ikev2_profile_set_auth_t *mp;
13185 u32 auth_method = 0;
13189 const char *valid_chars = "a-zA-Z0-9_";
13191 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13193 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13194 vec_add1 (name, 0);
13195 else if (unformat (i, "auth_method %U",
13196 unformat_ikev2_auth_method, &auth_method))
13198 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
13200 else if (unformat (i, "auth_data %v", &data))
13204 errmsg ("parse error '%U'", format_unformat_error, i);
13209 if (!vec_len (name))
13211 errmsg ("profile name must be specified");
13215 if (vec_len (name) > 64)
13217 errmsg ("profile name too long");
13221 if (!vec_len (data))
13223 errmsg ("auth_data must be specified");
13229 errmsg ("auth_method must be specified");
13233 M (IKEV2_PROFILE_SET_AUTH, mp);
13235 mp->is_hex = is_hex;
13236 mp->auth_method = (u8) auth_method;
13237 mp->data_len = vec_len (data);
13238 clib_memcpy (mp->name, name, vec_len (name));
13239 clib_memcpy (mp->data, data, vec_len (data));
13249 api_ikev2_profile_set_id (vat_main_t * vam)
13251 unformat_input_t *i = vam->input;
13252 vl_api_ikev2_profile_set_id_t *mp;
13260 const char *valid_chars = "a-zA-Z0-9_";
13262 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13264 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13265 vec_add1 (name, 0);
13266 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
13268 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
13270 data = vec_new (u8, 4);
13271 clib_memcpy (data, ip4.as_u8, 4);
13273 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
13275 else if (unformat (i, "id_data %v", &data))
13277 else if (unformat (i, "local"))
13279 else if (unformat (i, "remote"))
13283 errmsg ("parse error '%U'", format_unformat_error, i);
13288 if (!vec_len (name))
13290 errmsg ("profile name must be specified");
13294 if (vec_len (name) > 64)
13296 errmsg ("profile name too long");
13300 if (!vec_len (data))
13302 errmsg ("id_data must be specified");
13308 errmsg ("id_type must be specified");
13312 M (IKEV2_PROFILE_SET_ID, mp);
13314 mp->is_local = is_local;
13315 mp->id_type = (u8) id_type;
13316 mp->data_len = vec_len (data);
13317 clib_memcpy (mp->name, name, vec_len (name));
13318 clib_memcpy (mp->data, data, vec_len (data));
13328 api_ikev2_profile_set_ts (vat_main_t * vam)
13330 unformat_input_t *i = vam->input;
13331 vl_api_ikev2_profile_set_ts_t *mp;
13334 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
13335 ip4_address_t start_addr, end_addr;
13337 const char *valid_chars = "a-zA-Z0-9_";
13340 start_addr.as_u32 = 0;
13341 end_addr.as_u32 = (u32) ~ 0;
13343 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13345 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13346 vec_add1 (name, 0);
13347 else if (unformat (i, "protocol %d", &proto))
13349 else if (unformat (i, "start_port %d", &start_port))
13351 else if (unformat (i, "end_port %d", &end_port))
13354 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
13356 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
13358 else if (unformat (i, "local"))
13360 else if (unformat (i, "remote"))
13364 errmsg ("parse error '%U'", format_unformat_error, i);
13369 if (!vec_len (name))
13371 errmsg ("profile name must be specified");
13375 if (vec_len (name) > 64)
13377 errmsg ("profile name too long");
13381 M (IKEV2_PROFILE_SET_TS, mp);
13383 mp->is_local = is_local;
13384 mp->proto = (u8) proto;
13385 mp->start_port = (u16) start_port;
13386 mp->end_port = (u16) end_port;
13387 mp->start_addr = start_addr.as_u32;
13388 mp->end_addr = end_addr.as_u32;
13389 clib_memcpy (mp->name, name, vec_len (name));
13398 api_ikev2_set_local_key (vat_main_t * vam)
13400 unformat_input_t *i = vam->input;
13401 vl_api_ikev2_set_local_key_t *mp;
13405 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13407 if (unformat (i, "file %v", &file))
13408 vec_add1 (file, 0);
13411 errmsg ("parse error '%U'", format_unformat_error, i);
13416 if (!vec_len (file))
13418 errmsg ("RSA key file must be specified");
13422 if (vec_len (file) > 256)
13424 errmsg ("file name too long");
13428 M (IKEV2_SET_LOCAL_KEY, mp);
13430 clib_memcpy (mp->key_file, file, vec_len (file));
13439 api_ikev2_set_responder (vat_main_t * vam)
13441 unformat_input_t *i = vam->input;
13442 vl_api_ikev2_set_responder_t *mp;
13445 u32 sw_if_index = ~0;
13446 ip4_address_t address;
13448 const char *valid_chars = "a-zA-Z0-9_";
13450 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13453 (i, "%U interface %d address %U", unformat_token, valid_chars,
13454 &name, &sw_if_index, unformat_ip4_address, &address))
13455 vec_add1 (name, 0);
13458 errmsg ("parse error '%U'", format_unformat_error, i);
13463 if (!vec_len (name))
13465 errmsg ("profile name must be specified");
13469 if (vec_len (name) > 64)
13471 errmsg ("profile name too long");
13475 M (IKEV2_SET_RESPONDER, mp);
13477 clib_memcpy (mp->name, name, vec_len (name));
13480 mp->sw_if_index = sw_if_index;
13481 clib_memcpy (mp->address, &address, sizeof (address));
13489 api_ikev2_set_ike_transforms (vat_main_t * vam)
13491 unformat_input_t *i = vam->input;
13492 vl_api_ikev2_set_ike_transforms_t *mp;
13495 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13497 const char *valid_chars = "a-zA-Z0-9_";
13499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13501 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13502 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13503 vec_add1 (name, 0);
13506 errmsg ("parse error '%U'", format_unformat_error, i);
13511 if (!vec_len (name))
13513 errmsg ("profile name must be specified");
13517 if (vec_len (name) > 64)
13519 errmsg ("profile name too long");
13523 M (IKEV2_SET_IKE_TRANSFORMS, mp);
13525 clib_memcpy (mp->name, name, vec_len (name));
13527 mp->crypto_alg = crypto_alg;
13528 mp->crypto_key_size = crypto_key_size;
13529 mp->integ_alg = integ_alg;
13530 mp->dh_group = dh_group;
13539 api_ikev2_set_esp_transforms (vat_main_t * vam)
13541 unformat_input_t *i = vam->input;
13542 vl_api_ikev2_set_esp_transforms_t *mp;
13545 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13547 const char *valid_chars = "a-zA-Z0-9_";
13549 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13551 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13552 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13553 vec_add1 (name, 0);
13556 errmsg ("parse error '%U'", format_unformat_error, i);
13561 if (!vec_len (name))
13563 errmsg ("profile name must be specified");
13567 if (vec_len (name) > 64)
13569 errmsg ("profile name too long");
13573 M (IKEV2_SET_ESP_TRANSFORMS, mp);
13575 clib_memcpy (mp->name, name, vec_len (name));
13577 mp->crypto_alg = crypto_alg;
13578 mp->crypto_key_size = crypto_key_size;
13579 mp->integ_alg = integ_alg;
13580 mp->dh_group = dh_group;
13588 api_ikev2_set_sa_lifetime (vat_main_t * vam)
13590 unformat_input_t *i = vam->input;
13591 vl_api_ikev2_set_sa_lifetime_t *mp;
13594 u64 lifetime, lifetime_maxdata;
13595 u32 lifetime_jitter, handover;
13597 const char *valid_chars = "a-zA-Z0-9_";
13599 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13601 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
13602 &lifetime, &lifetime_jitter, &handover,
13603 &lifetime_maxdata))
13604 vec_add1 (name, 0);
13607 errmsg ("parse error '%U'", format_unformat_error, i);
13612 if (!vec_len (name))
13614 errmsg ("profile name must be specified");
13618 if (vec_len (name) > 64)
13620 errmsg ("profile name too long");
13624 M (IKEV2_SET_SA_LIFETIME, mp);
13626 clib_memcpy (mp->name, name, vec_len (name));
13628 mp->lifetime = lifetime;
13629 mp->lifetime_jitter = lifetime_jitter;
13630 mp->handover = handover;
13631 mp->lifetime_maxdata = lifetime_maxdata;
13639 api_ikev2_initiate_sa_init (vat_main_t * vam)
13641 unformat_input_t *i = vam->input;
13642 vl_api_ikev2_initiate_sa_init_t *mp;
13646 const char *valid_chars = "a-zA-Z0-9_";
13648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13650 if (unformat (i, "%U", unformat_token, valid_chars, &name))
13651 vec_add1 (name, 0);
13654 errmsg ("parse error '%U'", format_unformat_error, i);
13659 if (!vec_len (name))
13661 errmsg ("profile name must be specified");
13665 if (vec_len (name) > 64)
13667 errmsg ("profile name too long");
13671 M (IKEV2_INITIATE_SA_INIT, mp);
13673 clib_memcpy (mp->name, name, vec_len (name));
13682 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
13684 unformat_input_t *i = vam->input;
13685 vl_api_ikev2_initiate_del_ike_sa_t *mp;
13690 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13692 if (unformat (i, "%lx", &ispi))
13696 errmsg ("parse error '%U'", format_unformat_error, i);
13701 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
13711 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13713 unformat_input_t *i = vam->input;
13714 vl_api_ikev2_initiate_del_child_sa_t *mp;
13719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13721 if (unformat (i, "%x", &ispi))
13725 errmsg ("parse error '%U'", format_unformat_error, i);
13730 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13740 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13742 unformat_input_t *i = vam->input;
13743 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13748 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13750 if (unformat (i, "%x", &ispi))
13754 errmsg ("parse error '%U'", format_unformat_error, i);
13759 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
13772 api_map_add_domain (vat_main_t * vam)
13774 unformat_input_t *i = vam->input;
13775 vl_api_map_add_domain_t *mp;
13777 ip4_address_t ip4_prefix;
13778 ip6_address_t ip6_prefix;
13779 ip6_address_t ip6_src;
13780 u32 num_m_args = 0;
13781 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
13782 0, psid_length = 0;
13783 u8 is_translation = 0;
13785 u32 ip6_src_len = 128;
13788 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13790 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
13791 &ip4_prefix, &ip4_prefix_len))
13793 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
13794 &ip6_prefix, &ip6_prefix_len))
13798 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
13801 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
13803 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
13805 else if (unformat (i, "psid-offset %d", &psid_offset))
13807 else if (unformat (i, "psid-len %d", &psid_length))
13809 else if (unformat (i, "mtu %d", &mtu))
13811 else if (unformat (i, "map-t"))
13812 is_translation = 1;
13815 clib_warning ("parse error '%U'", format_unformat_error, i);
13820 if (num_m_args < 3)
13822 errmsg ("mandatory argument(s) missing");
13826 /* Construct the API message */
13827 M (MAP_ADD_DOMAIN, mp);
13829 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
13830 mp->ip4_prefix_len = ip4_prefix_len;
13832 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
13833 mp->ip6_prefix_len = ip6_prefix_len;
13835 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
13836 mp->ip6_src_prefix_len = ip6_src_len;
13838 mp->ea_bits_len = ea_bits_len;
13839 mp->psid_offset = psid_offset;
13840 mp->psid_length = psid_length;
13841 mp->is_translation = is_translation;
13842 mp->mtu = htons (mtu);
13847 /* Wait for a reply, return good/bad news */
13853 api_map_del_domain (vat_main_t * vam)
13855 unformat_input_t *i = vam->input;
13856 vl_api_map_del_domain_t *mp;
13858 u32 num_m_args = 0;
13862 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13864 if (unformat (i, "index %d", &index))
13868 clib_warning ("parse error '%U'", format_unformat_error, i);
13873 if (num_m_args != 1)
13875 errmsg ("mandatory argument(s) missing");
13879 /* Construct the API message */
13880 M (MAP_DEL_DOMAIN, mp);
13882 mp->index = ntohl (index);
13887 /* Wait for a reply, return good/bad news */
13893 api_map_add_del_rule (vat_main_t * vam)
13895 unformat_input_t *i = vam->input;
13896 vl_api_map_add_del_rule_t *mp;
13898 ip6_address_t ip6_dst;
13899 u32 num_m_args = 0, index, psid = 0;
13902 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13904 if (unformat (i, "index %d", &index))
13906 else if (unformat (i, "psid %d", &psid))
13908 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13910 else if (unformat (i, "del"))
13916 clib_warning ("parse error '%U'", format_unformat_error, i);
13921 /* Construct the API message */
13922 M (MAP_ADD_DEL_RULE, mp);
13924 mp->index = ntohl (index);
13925 mp->is_add = is_add;
13926 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13927 mp->psid = ntohs (psid);
13932 /* Wait for a reply, return good/bad news */
13938 api_map_domain_dump (vat_main_t * vam)
13940 vl_api_map_domain_dump_t *mp;
13941 vl_api_control_ping_t *mp_ping;
13944 /* Construct the API message */
13945 M (MAP_DOMAIN_DUMP, mp);
13950 /* Use a control ping for synchronization */
13951 M (CONTROL_PING, mp_ping);
13959 api_map_rule_dump (vat_main_t * vam)
13961 unformat_input_t *i = vam->input;
13962 vl_api_map_rule_dump_t *mp;
13963 vl_api_control_ping_t *mp_ping;
13964 u32 domain_index = ~0;
13967 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13969 if (unformat (i, "index %u", &domain_index))
13975 if (domain_index == ~0)
13977 clib_warning ("parse error: domain index expected");
13981 /* Construct the API message */
13982 M (MAP_RULE_DUMP, mp);
13984 mp->domain_index = htonl (domain_index);
13989 /* Use a control ping for synchronization */
13990 M (CONTROL_PING, mp_ping);
13997 static void vl_api_map_add_domain_reply_t_handler
13998 (vl_api_map_add_domain_reply_t * mp)
14000 vat_main_t *vam = &vat_main;
14001 i32 retval = ntohl (mp->retval);
14003 if (vam->async_mode)
14005 vam->async_errors += (retval < 0);
14009 vam->retval = retval;
14010 vam->result_ready = 1;
14014 static void vl_api_map_add_domain_reply_t_handler_json
14015 (vl_api_map_add_domain_reply_t * mp)
14017 vat_main_t *vam = &vat_main;
14018 vat_json_node_t node;
14020 vat_json_init_object (&node);
14021 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
14022 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
14024 vat_json_print (vam->ofp, &node);
14025 vat_json_free (&node);
14027 vam->retval = ntohl (mp->retval);
14028 vam->result_ready = 1;
14032 api_get_first_msg_id (vat_main_t * vam)
14034 vl_api_get_first_msg_id_t *mp;
14035 unformat_input_t *i = vam->input;
14040 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14042 if (unformat (i, "client %s", &name))
14050 errmsg ("missing client name");
14053 vec_add1 (name, 0);
14055 if (vec_len (name) > 63)
14057 errmsg ("client name too long");
14061 M (GET_FIRST_MSG_ID, mp);
14062 clib_memcpy (mp->name, name, vec_len (name));
14069 api_cop_interface_enable_disable (vat_main_t * vam)
14071 unformat_input_t *line_input = vam->input;
14072 vl_api_cop_interface_enable_disable_t *mp;
14073 u32 sw_if_index = ~0;
14074 u8 enable_disable = 1;
14077 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14079 if (unformat (line_input, "disable"))
14080 enable_disable = 0;
14081 if (unformat (line_input, "enable"))
14082 enable_disable = 1;
14083 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14084 vam, &sw_if_index))
14086 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14092 if (sw_if_index == ~0)
14094 errmsg ("missing interface name or sw_if_index");
14098 /* Construct the API message */
14099 M (COP_INTERFACE_ENABLE_DISABLE, mp);
14100 mp->sw_if_index = ntohl (sw_if_index);
14101 mp->enable_disable = enable_disable;
14105 /* Wait for the reply */
14111 api_cop_whitelist_enable_disable (vat_main_t * vam)
14113 unformat_input_t *line_input = vam->input;
14114 vl_api_cop_whitelist_enable_disable_t *mp;
14115 u32 sw_if_index = ~0;
14116 u8 ip4 = 0, ip6 = 0, default_cop = 0;
14120 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14122 if (unformat (line_input, "ip4"))
14124 else if (unformat (line_input, "ip6"))
14126 else if (unformat (line_input, "default"))
14128 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14129 vam, &sw_if_index))
14131 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14133 else if (unformat (line_input, "fib-id %d", &fib_id))
14139 if (sw_if_index == ~0)
14141 errmsg ("missing interface name or sw_if_index");
14145 /* Construct the API message */
14146 M (COP_WHITELIST_ENABLE_DISABLE, mp);
14147 mp->sw_if_index = ntohl (sw_if_index);
14148 mp->fib_id = ntohl (fib_id);
14151 mp->default_cop = default_cop;
14155 /* Wait for the reply */
14161 api_get_node_graph (vat_main_t * vam)
14163 vl_api_get_node_graph_t *mp;
14166 M (GET_NODE_GRAPH, mp);
14170 /* Wait for the reply */
14176 /** Used for parsing LISP eids */
14177 typedef CLIB_PACKED(struct{
14178 u8 addr[16]; /**< eid address */
14179 u32 len; /**< prefix length if IP */
14180 u8 type; /**< type of eid */
14185 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14187 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14189 memset (a, 0, sizeof (a[0]));
14191 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
14193 a->type = 0; /* ipv4 type */
14195 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
14197 a->type = 1; /* ipv6 type */
14199 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
14201 a->type = 2; /* mac type */
14203 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
14205 a->type = 3; /* NSH type */
14206 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
14207 nsh->spi = clib_host_to_net_u32 (nsh->spi);
14214 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
14223 lisp_eid_size_vat (u8 type)
14240 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
14242 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
14246 api_one_add_del_locator_set (vat_main_t * vam)
14248 unformat_input_t *input = vam->input;
14249 vl_api_one_add_del_locator_set_t *mp;
14251 u8 *locator_set_name = NULL;
14252 u8 locator_set_name_set = 0;
14253 vl_api_local_locator_t locator, *locators = 0;
14254 u32 sw_if_index, priority, weight;
14258 /* Parse args required to build the message */
14259 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14261 if (unformat (input, "del"))
14265 else if (unformat (input, "locator-set %s", &locator_set_name))
14267 locator_set_name_set = 1;
14269 else if (unformat (input, "sw_if_index %u p %u w %u",
14270 &sw_if_index, &priority, &weight))
14272 locator.sw_if_index = htonl (sw_if_index);
14273 locator.priority = priority;
14274 locator.weight = weight;
14275 vec_add1 (locators, locator);
14279 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14280 &sw_if_index, &priority, &weight))
14282 locator.sw_if_index = htonl (sw_if_index);
14283 locator.priority = priority;
14284 locator.weight = weight;
14285 vec_add1 (locators, locator);
14291 if (locator_set_name_set == 0)
14293 errmsg ("missing locator-set name");
14294 vec_free (locators);
14298 if (vec_len (locator_set_name) > 64)
14300 errmsg ("locator-set name too long");
14301 vec_free (locator_set_name);
14302 vec_free (locators);
14305 vec_add1 (locator_set_name, 0);
14307 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14309 /* Construct the API message */
14310 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14312 mp->is_add = is_add;
14313 clib_memcpy (mp->locator_set_name, locator_set_name,
14314 vec_len (locator_set_name));
14315 vec_free (locator_set_name);
14317 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14319 clib_memcpy (mp->locators, locators, data_len);
14320 vec_free (locators);
14325 /* Wait for a reply... */
14330 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14333 api_one_add_del_locator (vat_main_t * vam)
14335 unformat_input_t *input = vam->input;
14336 vl_api_one_add_del_locator_t *mp;
14337 u32 tmp_if_index = ~0;
14338 u32 sw_if_index = ~0;
14339 u8 sw_if_index_set = 0;
14340 u8 sw_if_index_if_name_set = 0;
14342 u8 priority_set = 0;
14346 u8 *locator_set_name = NULL;
14347 u8 locator_set_name_set = 0;
14350 /* Parse args required to build the message */
14351 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14353 if (unformat (input, "del"))
14357 else if (unformat (input, "locator-set %s", &locator_set_name))
14359 locator_set_name_set = 1;
14361 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14364 sw_if_index_if_name_set = 1;
14365 sw_if_index = tmp_if_index;
14367 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14369 sw_if_index_set = 1;
14370 sw_if_index = tmp_if_index;
14372 else if (unformat (input, "p %d", &priority))
14376 else if (unformat (input, "w %d", &weight))
14384 if (locator_set_name_set == 0)
14386 errmsg ("missing locator-set name");
14390 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14392 errmsg ("missing sw_if_index");
14393 vec_free (locator_set_name);
14397 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14399 errmsg ("cannot use both params interface name and sw_if_index");
14400 vec_free (locator_set_name);
14404 if (priority_set == 0)
14406 errmsg ("missing locator-set priority");
14407 vec_free (locator_set_name);
14411 if (weight_set == 0)
14413 errmsg ("missing locator-set weight");
14414 vec_free (locator_set_name);
14418 if (vec_len (locator_set_name) > 64)
14420 errmsg ("locator-set name too long");
14421 vec_free (locator_set_name);
14424 vec_add1 (locator_set_name, 0);
14426 /* Construct the API message */
14427 M (ONE_ADD_DEL_LOCATOR, mp);
14429 mp->is_add = is_add;
14430 mp->sw_if_index = ntohl (sw_if_index);
14431 mp->priority = priority;
14432 mp->weight = weight;
14433 clib_memcpy (mp->locator_set_name, locator_set_name,
14434 vec_len (locator_set_name));
14435 vec_free (locator_set_name);
14440 /* Wait for a reply... */
14445 #define api_lisp_add_del_locator api_one_add_del_locator
14448 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14450 u32 *key_id = va_arg (*args, u32 *);
14453 if (unformat (input, "%s", &s))
14455 if (!strcmp ((char *) s, "sha1"))
14456 key_id[0] = HMAC_SHA_1_96;
14457 else if (!strcmp ((char *) s, "sha256"))
14458 key_id[0] = HMAC_SHA_256_128;
14461 clib_warning ("invalid key_id: '%s'", s);
14462 key_id[0] = HMAC_NO_KEY;
14473 api_one_add_del_local_eid (vat_main_t * vam)
14475 unformat_input_t *input = vam->input;
14476 vl_api_one_add_del_local_eid_t *mp;
14479 lisp_eid_vat_t _eid, *eid = &_eid;
14480 u8 *locator_set_name = 0;
14481 u8 locator_set_name_set = 0;
14487 /* Parse args required to build the message */
14488 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14490 if (unformat (input, "del"))
14494 else if (unformat (input, "vni %d", &vni))
14498 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14502 else if (unformat (input, "locator-set %s", &locator_set_name))
14504 locator_set_name_set = 1;
14506 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14508 else if (unformat (input, "secret-key %_%v%_", &key))
14514 if (locator_set_name_set == 0)
14516 errmsg ("missing locator-set name");
14522 errmsg ("EID address not set!");
14523 vec_free (locator_set_name);
14527 if (key && (0 == key_id))
14529 errmsg ("invalid key_id!");
14533 if (vec_len (key) > 64)
14535 errmsg ("key too long");
14540 if (vec_len (locator_set_name) > 64)
14542 errmsg ("locator-set name too long");
14543 vec_free (locator_set_name);
14546 vec_add1 (locator_set_name, 0);
14548 /* Construct the API message */
14549 M (ONE_ADD_DEL_LOCAL_EID, mp);
14551 mp->is_add = is_add;
14552 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14553 mp->eid_type = eid->type;
14554 mp->prefix_len = eid->len;
14555 mp->vni = clib_host_to_net_u32 (vni);
14556 mp->key_id = clib_host_to_net_u16 (key_id);
14557 clib_memcpy (mp->locator_set_name, locator_set_name,
14558 vec_len (locator_set_name));
14559 clib_memcpy (mp->key, key, vec_len (key));
14561 vec_free (locator_set_name);
14567 /* Wait for a reply... */
14572 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14575 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14577 u32 dp_table = 0, vni = 0;;
14578 unformat_input_t *input = vam->input;
14579 vl_api_gpe_add_del_fwd_entry_t *mp;
14581 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14582 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14583 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14584 u32 action = ~0, w;
14585 ip4_address_t rmt_rloc4, lcl_rloc4;
14586 ip6_address_t rmt_rloc6, lcl_rloc6;
14587 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14590 memset (&rloc, 0, sizeof (rloc));
14592 /* Parse args required to build the message */
14593 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14595 if (unformat (input, "del"))
14597 else if (unformat (input, "add"))
14599 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14603 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14607 else if (unformat (input, "vrf %d", &dp_table))
14609 else if (unformat (input, "bd %d", &dp_table))
14611 else if (unformat (input, "vni %d", &vni))
14613 else if (unformat (input, "w %d", &w))
14617 errmsg ("No RLOC configured for setting priority/weight!");
14620 curr_rloc->weight = w;
14622 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14623 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14627 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
14629 vec_add1 (lcl_locs, rloc);
14631 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
14632 vec_add1 (rmt_locs, rloc);
14633 /* weight saved in rmt loc */
14634 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14636 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14637 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14640 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
14642 vec_add1 (lcl_locs, rloc);
14644 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
14645 vec_add1 (rmt_locs, rloc);
14646 /* weight saved in rmt loc */
14647 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14649 else if (unformat (input, "action %d", &action))
14655 clib_warning ("parse error '%U'", format_unformat_error, input);
14662 errmsg ("remote eid addresses not set");
14666 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14668 errmsg ("eid types don't match");
14672 if (0 == rmt_locs && (u32) ~ 0 == action)
14674 errmsg ("action not set for negative mapping");
14678 /* Construct the API message */
14679 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14680 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14682 mp->is_add = is_add;
14683 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14684 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14685 mp->eid_type = rmt_eid->type;
14686 mp->dp_table = clib_host_to_net_u32 (dp_table);
14687 mp->vni = clib_host_to_net_u32 (vni);
14688 mp->rmt_len = rmt_eid->len;
14689 mp->lcl_len = lcl_eid->len;
14690 mp->action = action;
14692 if (0 != rmt_locs && 0 != lcl_locs)
14694 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14695 clib_memcpy (mp->locs, lcl_locs,
14696 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14698 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14699 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14700 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14702 vec_free (lcl_locs);
14703 vec_free (rmt_locs);
14708 /* Wait for a reply... */
14714 api_one_add_del_map_server (vat_main_t * vam)
14716 unformat_input_t *input = vam->input;
14717 vl_api_one_add_del_map_server_t *mp;
14721 ip4_address_t ipv4;
14722 ip6_address_t ipv6;
14725 /* Parse args required to build the message */
14726 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14728 if (unformat (input, "del"))
14732 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14736 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14744 if (ipv4_set && ipv6_set)
14746 errmsg ("both eid v4 and v6 addresses set");
14750 if (!ipv4_set && !ipv6_set)
14752 errmsg ("eid addresses not set");
14756 /* Construct the API message */
14757 M (ONE_ADD_DEL_MAP_SERVER, mp);
14759 mp->is_add = is_add;
14763 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14768 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14774 /* Wait for a reply... */
14779 #define api_lisp_add_del_map_server api_one_add_del_map_server
14782 api_one_add_del_map_resolver (vat_main_t * vam)
14784 unformat_input_t *input = vam->input;
14785 vl_api_one_add_del_map_resolver_t *mp;
14789 ip4_address_t ipv4;
14790 ip6_address_t ipv6;
14793 /* Parse args required to build the message */
14794 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14796 if (unformat (input, "del"))
14800 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14804 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14812 if (ipv4_set && ipv6_set)
14814 errmsg ("both eid v4 and v6 addresses set");
14818 if (!ipv4_set && !ipv6_set)
14820 errmsg ("eid addresses not set");
14824 /* Construct the API message */
14825 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14827 mp->is_add = is_add;
14831 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14836 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14842 /* Wait for a reply... */
14847 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14850 api_lisp_gpe_enable_disable (vat_main_t * vam)
14852 unformat_input_t *input = vam->input;
14853 vl_api_gpe_enable_disable_t *mp;
14858 /* Parse args required to build the message */
14859 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14861 if (unformat (input, "enable"))
14866 else if (unformat (input, "disable"))
14877 errmsg ("Value not set");
14881 /* Construct the API message */
14882 M (GPE_ENABLE_DISABLE, mp);
14889 /* Wait for a reply... */
14895 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14897 unformat_input_t *input = vam->input;
14898 vl_api_one_rloc_probe_enable_disable_t *mp;
14903 /* Parse args required to build the message */
14904 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14906 if (unformat (input, "enable"))
14911 else if (unformat (input, "disable"))
14919 errmsg ("Value not set");
14923 /* Construct the API message */
14924 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14926 mp->is_enabled = is_en;
14931 /* Wait for a reply... */
14936 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14939 api_one_map_register_enable_disable (vat_main_t * vam)
14941 unformat_input_t *input = vam->input;
14942 vl_api_one_map_register_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"))
14963 errmsg ("Value not set");
14967 /* Construct the API message */
14968 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14970 mp->is_enabled = is_en;
14975 /* Wait for a reply... */
14980 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14983 api_one_enable_disable (vat_main_t * vam)
14985 unformat_input_t *input = vam->input;
14986 vl_api_one_enable_disable_t *mp;
14991 /* Parse args required to build the message */
14992 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14994 if (unformat (input, "enable"))
14999 else if (unformat (input, "disable"))
15009 errmsg ("Value not set");
15013 /* Construct the API message */
15014 M (ONE_ENABLE_DISABLE, mp);
15021 /* Wait for a reply... */
15026 #define api_lisp_enable_disable api_one_enable_disable
15029 api_show_one_map_register_state (vat_main_t * vam)
15031 vl_api_show_one_map_register_state_t *mp;
15034 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
15039 /* wait for reply */
15044 #define api_show_lisp_map_register_state api_show_one_map_register_state
15047 api_show_one_rloc_probe_state (vat_main_t * vam)
15049 vl_api_show_one_rloc_probe_state_t *mp;
15052 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
15057 /* wait for reply */
15062 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
15065 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15067 vl_api_one_add_del_l2_arp_entry_t *mp;
15068 unformat_input_t *input = vam->input;
15073 u8 mac[6] = { 0, };
15074 u32 ip4 = 0, bd = ~0;
15077 /* Parse args required to build the message */
15078 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15080 if (unformat (input, "del"))
15082 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15084 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15086 else if (unformat (input, "bd %d", &bd))
15090 errmsg ("parse error '%U'", format_unformat_error, input);
15095 if (!bd_set || !ip_set || (!mac_set && is_add))
15097 errmsg ("Missing BD, IP or MAC!");
15101 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15102 mp->is_add = is_add;
15103 clib_memcpy (mp->mac, mac, 6);
15104 mp->bd = clib_host_to_net_u32 (bd);
15110 /* wait for reply */
15116 api_one_l2_arp_bd_get (vat_main_t * vam)
15118 vl_api_one_l2_arp_bd_get_t *mp;
15121 M (ONE_L2_ARP_BD_GET, mp);
15126 /* wait for reply */
15132 api_one_l2_arp_entries_get (vat_main_t * vam)
15134 vl_api_one_l2_arp_entries_get_t *mp;
15135 unformat_input_t *input = vam->input;
15140 /* Parse args required to build the message */
15141 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15143 if (unformat (input, "bd %d", &bd))
15147 errmsg ("parse error '%U'", format_unformat_error, input);
15154 errmsg ("Expected bridge domain!");
15158 M (ONE_L2_ARP_ENTRIES_GET, mp);
15159 mp->bd = clib_host_to_net_u32 (bd);
15164 /* wait for reply */
15170 api_one_stats_enable_disable (vat_main_t * vam)
15172 vl_api_one_stats_enable_disable_t *mp;
15173 unformat_input_t *input = vam->input;
15178 /* Parse args required to build the message */
15179 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15181 if (unformat (input, "enable"))
15186 else if (unformat (input, "disable"))
15196 errmsg ("Value not set");
15200 M (ONE_STATS_ENABLE_DISABLE, mp);
15206 /* wait for reply */
15212 api_show_one_stats_enable_disable (vat_main_t * vam)
15214 vl_api_show_one_stats_enable_disable_t *mp;
15217 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
15222 /* wait for reply */
15228 api_show_one_map_request_mode (vat_main_t * vam)
15230 vl_api_show_one_map_request_mode_t *mp;
15233 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
15238 /* wait for reply */
15243 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
15246 api_one_map_request_mode (vat_main_t * vam)
15248 unformat_input_t *input = vam->input;
15249 vl_api_one_map_request_mode_t *mp;
15253 /* Parse args required to build the message */
15254 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15256 if (unformat (input, "dst-only"))
15258 else if (unformat (input, "src-dst"))
15262 errmsg ("parse error '%U'", format_unformat_error, input);
15267 M (ONE_MAP_REQUEST_MODE, mp);
15274 /* wait for reply */
15279 #define api_lisp_map_request_mode api_one_map_request_mode
15282 * Enable/disable ONE proxy ITR.
15284 * @param vam vpp API test context
15285 * @return return code
15288 api_one_pitr_set_locator_set (vat_main_t * vam)
15290 u8 ls_name_set = 0;
15291 unformat_input_t *input = vam->input;
15292 vl_api_one_pitr_set_locator_set_t *mp;
15297 /* Parse args required to build the message */
15298 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15300 if (unformat (input, "del"))
15302 else if (unformat (input, "locator-set %s", &ls_name))
15306 errmsg ("parse error '%U'", format_unformat_error, input);
15313 errmsg ("locator-set name not set!");
15317 M (ONE_PITR_SET_LOCATOR_SET, mp);
15319 mp->is_add = is_add;
15320 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15321 vec_free (ls_name);
15326 /* wait for reply */
15331 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
15334 api_one_nsh_set_locator_set (vat_main_t * vam)
15336 u8 ls_name_set = 0;
15337 unformat_input_t *input = vam->input;
15338 vl_api_one_nsh_set_locator_set_t *mp;
15343 /* Parse args required to build the message */
15344 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15346 if (unformat (input, "del"))
15348 else if (unformat (input, "ls %s", &ls_name))
15352 errmsg ("parse error '%U'", format_unformat_error, input);
15357 if (!ls_name_set && is_add)
15359 errmsg ("locator-set name not set!");
15363 M (ONE_NSH_SET_LOCATOR_SET, mp);
15365 mp->is_add = is_add;
15366 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15367 vec_free (ls_name);
15372 /* wait for reply */
15378 api_show_one_pitr (vat_main_t * vam)
15380 vl_api_show_one_pitr_t *mp;
15383 if (!vam->json_output)
15385 print (vam->ofp, "%=20s", "lisp status:");
15388 M (SHOW_ONE_PITR, mp);
15392 /* Wait for a reply... */
15397 #define api_show_lisp_pitr api_show_one_pitr
15400 api_one_use_petr (vat_main_t * vam)
15402 unformat_input_t *input = vam->input;
15403 vl_api_one_use_petr_t *mp;
15408 memset (&ip, 0, sizeof (ip));
15410 /* Parse args required to build the message */
15411 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15413 if (unformat (input, "disable"))
15416 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
15419 ip_addr_version (&ip) = IP4;
15422 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
15425 ip_addr_version (&ip) = IP6;
15429 errmsg ("parse error '%U'", format_unformat_error, input);
15434 M (ONE_USE_PETR, mp);
15436 mp->is_add = is_add;
15439 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
15441 clib_memcpy (mp->address, &ip, 4);
15443 clib_memcpy (mp->address, &ip, 16);
15449 /* wait for reply */
15454 #define api_lisp_use_petr api_one_use_petr
15457 api_show_one_nsh_mapping (vat_main_t * vam)
15459 vl_api_show_one_use_petr_t *mp;
15462 if (!vam->json_output)
15464 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
15467 M (SHOW_ONE_NSH_MAPPING, mp);
15471 /* Wait for a reply... */
15477 api_show_one_use_petr (vat_main_t * vam)
15479 vl_api_show_one_use_petr_t *mp;
15482 if (!vam->json_output)
15484 print (vam->ofp, "%=20s", "Proxy-ETR status:");
15487 M (SHOW_ONE_USE_PETR, mp);
15491 /* Wait for a reply... */
15496 #define api_show_lisp_use_petr api_show_one_use_petr
15499 * Add/delete mapping between vni and vrf
15502 api_one_eid_table_add_del_map (vat_main_t * vam)
15504 unformat_input_t *input = vam->input;
15505 vl_api_one_eid_table_add_del_map_t *mp;
15506 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15507 u32 vni, vrf, bd_index;
15510 /* Parse args required to build the message */
15511 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15513 if (unformat (input, "del"))
15515 else if (unformat (input, "vrf %d", &vrf))
15517 else if (unformat (input, "bd_index %d", &bd_index))
15519 else if (unformat (input, "vni %d", &vni))
15525 if (!vni_set || (!vrf_set && !bd_index_set))
15527 errmsg ("missing arguments!");
15531 if (vrf_set && bd_index_set)
15533 errmsg ("error: both vrf and bd entered!");
15537 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15539 mp->is_add = is_add;
15540 mp->vni = htonl (vni);
15541 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15542 mp->is_l2 = bd_index_set;
15547 /* wait for reply */
15552 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15555 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15557 u32 *action = va_arg (*args, u32 *);
15560 if (unformat (input, "%s", &s))
15562 if (!strcmp ((char *) s, "no-action"))
15564 else if (!strcmp ((char *) s, "natively-forward"))
15566 else if (!strcmp ((char *) s, "send-map-request"))
15568 else if (!strcmp ((char *) s, "drop"))
15572 clib_warning ("invalid action: '%s'", s);
15584 * Add/del remote mapping to/from ONE control plane
15586 * @param vam vpp API test context
15587 * @return return code
15590 api_one_add_del_remote_mapping (vat_main_t * vam)
15592 unformat_input_t *input = vam->input;
15593 vl_api_one_add_del_remote_mapping_t *mp;
15595 lisp_eid_vat_t _eid, *eid = &_eid;
15596 lisp_eid_vat_t _seid, *seid = &_seid;
15597 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15598 u32 action = ~0, p, w, data_len;
15599 ip4_address_t rloc4;
15600 ip6_address_t rloc6;
15601 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15604 memset (&rloc, 0, sizeof (rloc));
15606 /* Parse args required to build the message */
15607 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15609 if (unformat (input, "del-all"))
15613 else if (unformat (input, "del"))
15617 else if (unformat (input, "add"))
15621 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15625 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15629 else if (unformat (input, "vni %d", &vni))
15633 else if (unformat (input, "p %d w %d", &p, &w))
15637 errmsg ("No RLOC configured for setting priority/weight!");
15640 curr_rloc->priority = p;
15641 curr_rloc->weight = w;
15643 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15646 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
15647 vec_add1 (rlocs, rloc);
15648 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15650 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15653 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
15654 vec_add1 (rlocs, rloc);
15655 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15657 else if (unformat (input, "action %U",
15658 unformat_negative_mapping_action, &action))
15664 clib_warning ("parse error '%U'", format_unformat_error, input);
15671 errmsg ("missing params!");
15675 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15677 errmsg ("no action set for negative map-reply!");
15681 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15683 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15684 mp->is_add = is_add;
15685 mp->vni = htonl (vni);
15686 mp->action = (u8) action;
15687 mp->is_src_dst = seid_set;
15688 mp->eid_len = eid->len;
15689 mp->seid_len = seid->len;
15690 mp->del_all = del_all;
15691 mp->eid_type = eid->type;
15692 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15693 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
15695 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15696 clib_memcpy (mp->rlocs, rlocs, data_len);
15702 /* Wait for a reply... */
15707 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15710 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15711 * forwarding entries in data-plane accordingly.
15713 * @param vam vpp API test context
15714 * @return return code
15717 api_one_add_del_adjacency (vat_main_t * vam)
15719 unformat_input_t *input = vam->input;
15720 vl_api_one_add_del_adjacency_t *mp;
15722 ip4_address_t leid4, reid4;
15723 ip6_address_t leid6, reid6;
15724 u8 reid_mac[6] = { 0 };
15725 u8 leid_mac[6] = { 0 };
15726 u8 reid_type, leid_type;
15727 u32 leid_len = 0, reid_len = 0, len;
15731 leid_type = reid_type = (u8) ~ 0;
15733 /* Parse args required to build the message */
15734 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15736 if (unformat (input, "del"))
15740 else if (unformat (input, "add"))
15744 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
15747 reid_type = 0; /* ipv4 */
15750 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
15753 reid_type = 1; /* ipv6 */
15756 else if (unformat (input, "reid %U", unformat_ethernet_address,
15759 reid_type = 2; /* mac */
15761 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
15764 leid_type = 0; /* ipv4 */
15767 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
15770 leid_type = 1; /* ipv6 */
15773 else if (unformat (input, "leid %U", unformat_ethernet_address,
15776 leid_type = 2; /* mac */
15778 else if (unformat (input, "vni %d", &vni))
15784 errmsg ("parse error '%U'", format_unformat_error, input);
15789 if ((u8) ~ 0 == reid_type)
15791 errmsg ("missing params!");
15795 if (leid_type != reid_type)
15797 errmsg ("remote and local EIDs are of different types!");
15801 M (ONE_ADD_DEL_ADJACENCY, mp);
15802 mp->is_add = is_add;
15803 mp->vni = htonl (vni);
15804 mp->leid_len = leid_len;
15805 mp->reid_len = reid_len;
15806 mp->eid_type = reid_type;
15808 switch (mp->eid_type)
15811 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
15812 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
15815 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
15816 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
15819 clib_memcpy (mp->leid, leid_mac, 6);
15820 clib_memcpy (mp->reid, reid_mac, 6);
15823 errmsg ("unknown EID type %d!", mp->eid_type);
15830 /* Wait for a reply... */
15835 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
15838 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
15840 u32 *mode = va_arg (*args, u32 *);
15842 if (unformat (input, "lisp"))
15844 else if (unformat (input, "vxlan"))
15853 api_gpe_get_encap_mode (vat_main_t * vam)
15855 vl_api_gpe_get_encap_mode_t *mp;
15858 /* Construct the API message */
15859 M (GPE_GET_ENCAP_MODE, mp);
15864 /* Wait for a reply... */
15870 api_gpe_set_encap_mode (vat_main_t * vam)
15872 unformat_input_t *input = vam->input;
15873 vl_api_gpe_set_encap_mode_t *mp;
15877 /* Parse args required to build the message */
15878 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15880 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
15886 /* Construct the API message */
15887 M (GPE_SET_ENCAP_MODE, mp);
15894 /* Wait for a reply... */
15900 api_lisp_gpe_add_del_iface (vat_main_t * vam)
15902 unformat_input_t *input = vam->input;
15903 vl_api_gpe_add_del_iface_t *mp;
15904 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
15905 u32 dp_table = 0, vni = 0;
15908 /* Parse args required to build the message */
15909 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15911 if (unformat (input, "up"))
15916 else if (unformat (input, "down"))
15921 else if (unformat (input, "table_id %d", &dp_table))
15925 else if (unformat (input, "bd_id %d", &dp_table))
15930 else if (unformat (input, "vni %d", &vni))
15938 if (action_set == 0)
15940 errmsg ("Action not set");
15943 if (dp_table_set == 0 || vni_set == 0)
15945 errmsg ("vni and dp_table must be set");
15949 /* Construct the API message */
15950 M (GPE_ADD_DEL_IFACE, mp);
15952 mp->is_add = is_add;
15953 mp->dp_table = dp_table;
15960 /* Wait for a reply... */
15966 * Add/del map request itr rlocs from ONE control plane and updates
15968 * @param vam vpp API test context
15969 * @return return code
15972 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
15974 unformat_input_t *input = vam->input;
15975 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
15976 u8 *locator_set_name = 0;
15977 u8 locator_set_name_set = 0;
15981 /* Parse args required to build the message */
15982 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15984 if (unformat (input, "del"))
15988 else if (unformat (input, "%_%v%_", &locator_set_name))
15990 locator_set_name_set = 1;
15994 clib_warning ("parse error '%U'", format_unformat_error, input);
15999 if (is_add && !locator_set_name_set)
16001 errmsg ("itr-rloc is not set!");
16005 if (is_add && vec_len (locator_set_name) > 64)
16007 errmsg ("itr-rloc locator-set name too long");
16008 vec_free (locator_set_name);
16012 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
16013 mp->is_add = is_add;
16016 clib_memcpy (mp->locator_set_name, locator_set_name,
16017 vec_len (locator_set_name));
16021 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
16023 vec_free (locator_set_name);
16028 /* Wait for a reply... */
16033 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
16036 api_one_locator_dump (vat_main_t * vam)
16038 unformat_input_t *input = vam->input;
16039 vl_api_one_locator_dump_t *mp;
16040 vl_api_control_ping_t *mp_ping;
16041 u8 is_index_set = 0, is_name_set = 0;
16046 /* Parse args required to build the message */
16047 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16049 if (unformat (input, "ls_name %_%v%_", &ls_name))
16053 else if (unformat (input, "ls_index %d", &ls_index))
16059 errmsg ("parse error '%U'", format_unformat_error, input);
16064 if (!is_index_set && !is_name_set)
16066 errmsg ("error: expected one of index or name!");
16070 if (is_index_set && is_name_set)
16072 errmsg ("error: only one param expected!");
16076 if (vec_len (ls_name) > 62)
16078 errmsg ("error: locator set name too long!");
16082 if (!vam->json_output)
16084 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
16087 M (ONE_LOCATOR_DUMP, mp);
16088 mp->is_index_set = is_index_set;
16091 mp->ls_index = clib_host_to_net_u32 (ls_index);
16094 vec_add1 (ls_name, 0);
16095 strncpy ((char *) mp->ls_name, (char *) ls_name,
16096 sizeof (mp->ls_name) - 1);
16102 /* Use a control ping for synchronization */
16103 M (CONTROL_PING, mp_ping);
16106 /* Wait for a reply... */
16111 #define api_lisp_locator_dump api_one_locator_dump
16114 api_one_locator_set_dump (vat_main_t * vam)
16116 vl_api_one_locator_set_dump_t *mp;
16117 vl_api_control_ping_t *mp_ping;
16118 unformat_input_t *input = vam->input;
16122 /* Parse args required to build the message */
16123 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16125 if (unformat (input, "local"))
16129 else if (unformat (input, "remote"))
16135 errmsg ("parse error '%U'", format_unformat_error, input);
16140 if (!vam->json_output)
16142 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
16145 M (ONE_LOCATOR_SET_DUMP, mp);
16147 mp->filter = filter;
16152 /* Use a control ping for synchronization */
16153 M (CONTROL_PING, mp_ping);
16156 /* Wait for a reply... */
16161 #define api_lisp_locator_set_dump api_one_locator_set_dump
16164 api_one_eid_table_map_dump (vat_main_t * vam)
16168 unformat_input_t *input = vam->input;
16169 vl_api_one_eid_table_map_dump_t *mp;
16170 vl_api_control_ping_t *mp_ping;
16173 /* Parse args required to build the message */
16174 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16176 if (unformat (input, "l2"))
16181 else if (unformat (input, "l3"))
16188 errmsg ("parse error '%U'", format_unformat_error, input);
16195 errmsg ("expected one of 'l2' or 'l3' parameter!");
16199 if (!vam->json_output)
16201 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
16204 M (ONE_EID_TABLE_MAP_DUMP, mp);
16210 /* Use a control ping for synchronization */
16211 M (CONTROL_PING, mp_ping);
16214 /* Wait for a reply... */
16219 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
16222 api_one_eid_table_vni_dump (vat_main_t * vam)
16224 vl_api_one_eid_table_vni_dump_t *mp;
16225 vl_api_control_ping_t *mp_ping;
16228 if (!vam->json_output)
16230 print (vam->ofp, "VNI");
16233 M (ONE_EID_TABLE_VNI_DUMP, mp);
16238 /* Use a control ping for synchronization */
16239 M (CONTROL_PING, mp_ping);
16242 /* Wait for a reply... */
16247 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
16250 api_one_eid_table_dump (vat_main_t * vam)
16252 unformat_input_t *i = vam->input;
16253 vl_api_one_eid_table_dump_t *mp;
16254 vl_api_control_ping_t *mp_ping;
16255 struct in_addr ip4;
16256 struct in6_addr ip6;
16258 u8 eid_type = ~0, eid_set = 0;
16259 u32 prefix_length = ~0, t, vni = 0;
16262 lisp_nsh_api_t nsh;
16264 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16266 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
16272 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
16278 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
16283 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
16288 else if (unformat (i, "vni %d", &t))
16292 else if (unformat (i, "local"))
16296 else if (unformat (i, "remote"))
16302 errmsg ("parse error '%U'", format_unformat_error, i);
16307 if (!vam->json_output)
16309 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
16310 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
16313 M (ONE_EID_TABLE_DUMP, mp);
16315 mp->filter = filter;
16319 mp->vni = htonl (vni);
16320 mp->eid_type = eid_type;
16324 mp->prefix_length = prefix_length;
16325 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
16328 mp->prefix_length = prefix_length;
16329 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
16332 clib_memcpy (mp->eid, mac, sizeof (mac));
16335 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
16338 errmsg ("unknown EID type %d!", eid_type);
16346 /* Use a control ping for synchronization */
16347 M (CONTROL_PING, mp_ping);
16350 /* Wait for a reply... */
16355 #define api_lisp_eid_table_dump api_one_eid_table_dump
16358 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
16360 unformat_input_t *i = vam->input;
16361 vl_api_gpe_fwd_entries_get_t *mp;
16366 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16368 if (unformat (i, "vni %d", &vni))
16374 errmsg ("parse error '%U'", format_unformat_error, i);
16381 errmsg ("vni not set!");
16385 if (!vam->json_output)
16387 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
16391 M (GPE_FWD_ENTRIES_GET, mp);
16392 mp->vni = clib_host_to_net_u32 (vni);
16397 /* Wait for a reply... */
16402 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
16403 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
16404 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
16405 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
16406 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
16407 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
16408 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
16409 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
16412 api_one_adjacencies_get (vat_main_t * vam)
16414 unformat_input_t *i = vam->input;
16415 vl_api_one_adjacencies_get_t *mp;
16420 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16422 if (unformat (i, "vni %d", &vni))
16428 errmsg ("parse error '%U'", format_unformat_error, i);
16435 errmsg ("vni not set!");
16439 if (!vam->json_output)
16441 print (vam->ofp, "%s %40s", "leid", "reid");
16444 M (ONE_ADJACENCIES_GET, mp);
16445 mp->vni = clib_host_to_net_u32 (vni);
16450 /* Wait for a reply... */
16455 #define api_lisp_adjacencies_get api_one_adjacencies_get
16458 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
16460 unformat_input_t *i = vam->input;
16461 vl_api_gpe_native_fwd_rpaths_get_t *mp;
16463 u8 ip_family_set = 0, is_ip4 = 1;
16465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16467 if (unformat (i, "ip4"))
16472 else if (unformat (i, "ip6"))
16479 errmsg ("parse error '%U'", format_unformat_error, i);
16484 if (!ip_family_set)
16486 errmsg ("ip family not set!");
16490 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
16491 mp->is_ip4 = is_ip4;
16496 /* Wait for a reply... */
16502 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
16504 vl_api_gpe_fwd_entry_vnis_get_t *mp;
16507 if (!vam->json_output)
16509 print (vam->ofp, "VNIs");
16512 M (GPE_FWD_ENTRY_VNIS_GET, mp);
16517 /* Wait for a reply... */
16523 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
16525 unformat_input_t *i = vam->input;
16526 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
16528 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
16529 struct in_addr ip4;
16530 struct in6_addr ip6;
16531 u32 table_id = 0, nh_sw_if_index = ~0;
16533 memset (&ip4, 0, sizeof (ip4));
16534 memset (&ip6, 0, sizeof (ip6));
16536 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16538 if (unformat (i, "del"))
16540 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
16541 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16546 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
16547 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16552 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
16556 nh_sw_if_index = ~0;
16558 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
16562 nh_sw_if_index = ~0;
16564 else if (unformat (i, "table %d", &table_id))
16568 errmsg ("parse error '%U'", format_unformat_error, i);
16575 errmsg ("nh addr not set!");
16579 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
16580 mp->is_add = is_add;
16581 mp->table_id = clib_host_to_net_u32 (table_id);
16582 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
16583 mp->is_ip4 = is_ip4;
16585 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
16587 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
16592 /* Wait for a reply... */
16598 api_one_map_server_dump (vat_main_t * vam)
16600 vl_api_one_map_server_dump_t *mp;
16601 vl_api_control_ping_t *mp_ping;
16604 if (!vam->json_output)
16606 print (vam->ofp, "%=20s", "Map server");
16609 M (ONE_MAP_SERVER_DUMP, mp);
16613 /* Use a control ping for synchronization */
16614 M (CONTROL_PING, mp_ping);
16617 /* Wait for a reply... */
16622 #define api_lisp_map_server_dump api_one_map_server_dump
16625 api_one_map_resolver_dump (vat_main_t * vam)
16627 vl_api_one_map_resolver_dump_t *mp;
16628 vl_api_control_ping_t *mp_ping;
16631 if (!vam->json_output)
16633 print (vam->ofp, "%=20s", "Map resolver");
16636 M (ONE_MAP_RESOLVER_DUMP, mp);
16640 /* Use a control ping for synchronization */
16641 M (CONTROL_PING, mp_ping);
16644 /* Wait for a reply... */
16649 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
16652 api_one_stats_flush (vat_main_t * vam)
16654 vl_api_one_stats_flush_t *mp;
16657 M (ONE_STATS_FLUSH, mp);
16664 api_one_stats_dump (vat_main_t * vam)
16666 vl_api_one_stats_dump_t *mp;
16667 vl_api_control_ping_t *mp_ping;
16670 M (ONE_STATS_DUMP, mp);
16674 /* Use a control ping for synchronization */
16675 M (CONTROL_PING, mp_ping);
16678 /* Wait for a reply... */
16684 api_show_one_status (vat_main_t * vam)
16686 vl_api_show_one_status_t *mp;
16689 if (!vam->json_output)
16691 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
16694 M (SHOW_ONE_STATUS, mp);
16697 /* Wait for a reply... */
16702 #define api_show_lisp_status api_show_one_status
16705 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
16707 vl_api_gpe_fwd_entry_path_dump_t *mp;
16708 vl_api_control_ping_t *mp_ping;
16709 unformat_input_t *i = vam->input;
16710 u32 fwd_entry_index = ~0;
16713 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16715 if (unformat (i, "index %d", &fwd_entry_index))
16721 if (~0 == fwd_entry_index)
16723 errmsg ("no index specified!");
16727 if (!vam->json_output)
16729 print (vam->ofp, "first line");
16732 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
16736 /* Use a control ping for synchronization */
16737 M (CONTROL_PING, mp_ping);
16740 /* Wait for a reply... */
16746 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
16748 vl_api_one_get_map_request_itr_rlocs_t *mp;
16751 if (!vam->json_output)
16753 print (vam->ofp, "%=20s", "itr-rlocs:");
16756 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
16759 /* Wait for a reply... */
16764 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
16767 api_af_packet_create (vat_main_t * vam)
16769 unformat_input_t *i = vam->input;
16770 vl_api_af_packet_create_t *mp;
16771 u8 *host_if_name = 0;
16773 u8 random_hw_addr = 1;
16776 memset (hw_addr, 0, sizeof (hw_addr));
16778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16780 if (unformat (i, "name %s", &host_if_name))
16781 vec_add1 (host_if_name, 0);
16782 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16783 random_hw_addr = 0;
16788 if (!vec_len (host_if_name))
16790 errmsg ("host-interface name must be specified");
16794 if (vec_len (host_if_name) > 64)
16796 errmsg ("host-interface name too long");
16800 M (AF_PACKET_CREATE, mp);
16802 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16803 clib_memcpy (mp->hw_addr, hw_addr, 6);
16804 mp->use_random_hw_addr = random_hw_addr;
16805 vec_free (host_if_name);
16813 fprintf (vam->ofp ? vam->ofp : stderr,
16814 " new sw_if_index = %d\n", vam->sw_if_index);
16821 api_af_packet_delete (vat_main_t * vam)
16823 unformat_input_t *i = vam->input;
16824 vl_api_af_packet_delete_t *mp;
16825 u8 *host_if_name = 0;
16828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16830 if (unformat (i, "name %s", &host_if_name))
16831 vec_add1 (host_if_name, 0);
16836 if (!vec_len (host_if_name))
16838 errmsg ("host-interface name must be specified");
16842 if (vec_len (host_if_name) > 64)
16844 errmsg ("host-interface name too long");
16848 M (AF_PACKET_DELETE, mp);
16850 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16851 vec_free (host_if_name);
16859 api_policer_add_del (vat_main_t * vam)
16861 unformat_input_t *i = vam->input;
16862 vl_api_policer_add_del_t *mp;
16872 u8 color_aware = 0;
16873 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
16876 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
16877 conform_action.dscp = 0;
16878 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
16879 exceed_action.dscp = 0;
16880 violate_action.action_type = SSE2_QOS_ACTION_DROP;
16881 violate_action.dscp = 0;
16883 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16885 if (unformat (i, "del"))
16887 else if (unformat (i, "name %s", &name))
16888 vec_add1 (name, 0);
16889 else if (unformat (i, "cir %u", &cir))
16891 else if (unformat (i, "eir %u", &eir))
16893 else if (unformat (i, "cb %u", &cb))
16895 else if (unformat (i, "eb %u", &eb))
16897 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
16900 else if (unformat (i, "round_type %U", unformat_policer_round_type,
16903 else if (unformat (i, "type %U", unformat_policer_type, &type))
16905 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
16908 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
16911 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
16914 else if (unformat (i, "color-aware"))
16920 if (!vec_len (name))
16922 errmsg ("policer name must be specified");
16926 if (vec_len (name) > 64)
16928 errmsg ("policer name too long");
16932 M (POLICER_ADD_DEL, mp);
16934 clib_memcpy (mp->name, name, vec_len (name));
16936 mp->is_add = is_add;
16941 mp->rate_type = rate_type;
16942 mp->round_type = round_type;
16944 mp->conform_action_type = conform_action.action_type;
16945 mp->conform_dscp = conform_action.dscp;
16946 mp->exceed_action_type = exceed_action.action_type;
16947 mp->exceed_dscp = exceed_action.dscp;
16948 mp->violate_action_type = violate_action.action_type;
16949 mp->violate_dscp = violate_action.dscp;
16950 mp->color_aware = color_aware;
16958 api_policer_dump (vat_main_t * vam)
16960 unformat_input_t *i = vam->input;
16961 vl_api_policer_dump_t *mp;
16962 vl_api_control_ping_t *mp_ping;
16963 u8 *match_name = 0;
16964 u8 match_name_valid = 0;
16967 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16969 if (unformat (i, "name %s", &match_name))
16971 vec_add1 (match_name, 0);
16972 match_name_valid = 1;
16978 M (POLICER_DUMP, mp);
16979 mp->match_name_valid = match_name_valid;
16980 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
16981 vec_free (match_name);
16985 /* Use a control ping for synchronization */
16986 M (CONTROL_PING, mp_ping);
16989 /* Wait for a reply... */
16995 api_policer_classify_set_interface (vat_main_t * vam)
16997 unformat_input_t *i = vam->input;
16998 vl_api_policer_classify_set_interface_t *mp;
17000 int sw_if_index_set;
17001 u32 ip4_table_index = ~0;
17002 u32 ip6_table_index = ~0;
17003 u32 l2_table_index = ~0;
17007 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17009 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17010 sw_if_index_set = 1;
17011 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17012 sw_if_index_set = 1;
17013 else if (unformat (i, "del"))
17015 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17017 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17019 else if (unformat (i, "l2-table %d", &l2_table_index))
17023 clib_warning ("parse error '%U'", format_unformat_error, i);
17028 if (sw_if_index_set == 0)
17030 errmsg ("missing interface name or sw_if_index");
17034 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
17036 mp->sw_if_index = ntohl (sw_if_index);
17037 mp->ip4_table_index = ntohl (ip4_table_index);
17038 mp->ip6_table_index = ntohl (ip6_table_index);
17039 mp->l2_table_index = ntohl (l2_table_index);
17040 mp->is_add = is_add;
17048 api_policer_classify_dump (vat_main_t * vam)
17050 unformat_input_t *i = vam->input;
17051 vl_api_policer_classify_dump_t *mp;
17052 vl_api_control_ping_t *mp_ping;
17053 u8 type = POLICER_CLASSIFY_N_TABLES;
17056 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
17060 errmsg ("classify table type must be specified");
17064 if (!vam->json_output)
17066 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17069 M (POLICER_CLASSIFY_DUMP, mp);
17074 /* Use a control ping for synchronization */
17075 M (CONTROL_PING, mp_ping);
17078 /* Wait for a reply... */
17084 api_netmap_create (vat_main_t * vam)
17086 unformat_input_t *i = vam->input;
17087 vl_api_netmap_create_t *mp;
17090 u8 random_hw_addr = 1;
17095 memset (hw_addr, 0, sizeof (hw_addr));
17097 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17099 if (unformat (i, "name %s", &if_name))
17100 vec_add1 (if_name, 0);
17101 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17102 random_hw_addr = 0;
17103 else if (unformat (i, "pipe"))
17105 else if (unformat (i, "master"))
17107 else if (unformat (i, "slave"))
17113 if (!vec_len (if_name))
17115 errmsg ("interface name must be specified");
17119 if (vec_len (if_name) > 64)
17121 errmsg ("interface name too long");
17125 M (NETMAP_CREATE, mp);
17127 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
17128 clib_memcpy (mp->hw_addr, hw_addr, 6);
17129 mp->use_random_hw_addr = random_hw_addr;
17130 mp->is_pipe = is_pipe;
17131 mp->is_master = is_master;
17132 vec_free (if_name);
17140 api_netmap_delete (vat_main_t * vam)
17142 unformat_input_t *i = vam->input;
17143 vl_api_netmap_delete_t *mp;
17147 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17149 if (unformat (i, "name %s", &if_name))
17150 vec_add1 (if_name, 0);
17155 if (!vec_len (if_name))
17157 errmsg ("interface name must be specified");
17161 if (vec_len (if_name) > 64)
17163 errmsg ("interface name too long");
17167 M (NETMAP_DELETE, mp);
17169 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
17170 vec_free (if_name);
17178 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
17180 if (fp->afi == IP46_TYPE_IP6)
17182 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17183 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17184 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17185 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17186 format_ip6_address, fp->next_hop);
17187 else if (fp->afi == IP46_TYPE_IP4)
17189 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17190 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17191 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17192 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17193 format_ip4_address, fp->next_hop);
17197 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
17198 vl_api_fib_path2_t * fp)
17200 struct in_addr ip4;
17201 struct in6_addr ip6;
17203 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17204 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17205 vat_json_object_add_uint (node, "is_local", fp->is_local);
17206 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17207 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17208 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17209 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17210 if (fp->afi == IP46_TYPE_IP4)
17212 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17213 vat_json_object_add_ip4 (node, "next_hop", ip4);
17215 else if (fp->afi == IP46_TYPE_IP6)
17217 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17218 vat_json_object_add_ip6 (node, "next_hop", ip6);
17223 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
17225 vat_main_t *vam = &vat_main;
17226 int count = ntohl (mp->mt_count);
17227 vl_api_fib_path2_t *fp;
17230 print (vam->ofp, "[%d]: sw_if_index %d via:",
17231 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
17233 for (i = 0; i < count; i++)
17235 vl_api_mpls_fib_path_print (vam, fp);
17239 print (vam->ofp, "");
17242 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
17243 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
17246 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
17248 vat_main_t *vam = &vat_main;
17249 vat_json_node_t *node = NULL;
17250 int count = ntohl (mp->mt_count);
17251 vl_api_fib_path2_t *fp;
17254 if (VAT_JSON_ARRAY != vam->json_tree.type)
17256 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17257 vat_json_init_array (&vam->json_tree);
17259 node = vat_json_array_add (&vam->json_tree);
17261 vat_json_init_object (node);
17262 vat_json_object_add_uint (node, "tunnel_index",
17263 ntohl (mp->mt_tunnel_index));
17264 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
17266 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
17269 for (i = 0; i < count; i++)
17271 vl_api_mpls_fib_path_json_print (node, fp);
17277 api_mpls_tunnel_dump (vat_main_t * vam)
17279 vl_api_mpls_tunnel_dump_t *mp;
17280 vl_api_control_ping_t *mp_ping;
17284 /* Parse args required to build the message */
17285 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
17287 if (!unformat (vam->input, "tunnel_index %d", &index))
17294 print (vam->ofp, " tunnel_index %d", index);
17296 M (MPLS_TUNNEL_DUMP, mp);
17297 mp->tunnel_index = htonl (index);
17300 /* Use a control ping for synchronization */
17301 M (CONTROL_PING, mp_ping);
17308 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
17309 #define vl_api_mpls_fib_details_t_print vl_noop_handler
17313 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
17315 vat_main_t *vam = &vat_main;
17316 int count = ntohl (mp->count);
17317 vl_api_fib_path2_t *fp;
17321 "table-id %d, label %u, ess_bit %u",
17322 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
17324 for (i = 0; i < count; i++)
17326 vl_api_mpls_fib_path_print (vam, fp);
17331 static void vl_api_mpls_fib_details_t_handler_json
17332 (vl_api_mpls_fib_details_t * mp)
17334 vat_main_t *vam = &vat_main;
17335 int count = ntohl (mp->count);
17336 vat_json_node_t *node = NULL;
17337 vl_api_fib_path2_t *fp;
17340 if (VAT_JSON_ARRAY != vam->json_tree.type)
17342 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17343 vat_json_init_array (&vam->json_tree);
17345 node = vat_json_array_add (&vam->json_tree);
17347 vat_json_init_object (node);
17348 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17349 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
17350 vat_json_object_add_uint (node, "label", ntohl (mp->label));
17351 vat_json_object_add_uint (node, "path_count", count);
17353 for (i = 0; i < count; i++)
17355 vl_api_mpls_fib_path_json_print (node, fp);
17361 api_mpls_fib_dump (vat_main_t * vam)
17363 vl_api_mpls_fib_dump_t *mp;
17364 vl_api_control_ping_t *mp_ping;
17367 M (MPLS_FIB_DUMP, mp);
17370 /* Use a control ping for synchronization */
17371 M (CONTROL_PING, mp_ping);
17378 #define vl_api_ip_fib_details_t_endian vl_noop_handler
17379 #define vl_api_ip_fib_details_t_print vl_noop_handler
17382 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
17384 vat_main_t *vam = &vat_main;
17385 int count = ntohl (mp->count);
17386 vl_api_fib_path_t *fp;
17390 "table-id %d, prefix %U/%d",
17391 ntohl (mp->table_id), format_ip4_address, mp->address,
17392 mp->address_length);
17394 for (i = 0; i < count; i++)
17396 if (fp->afi == IP46_TYPE_IP6)
17398 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17399 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17400 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17401 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17402 format_ip6_address, fp->next_hop);
17403 else if (fp->afi == IP46_TYPE_IP4)
17405 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17406 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17407 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17408 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17409 format_ip4_address, fp->next_hop);
17414 static void vl_api_ip_fib_details_t_handler_json
17415 (vl_api_ip_fib_details_t * mp)
17417 vat_main_t *vam = &vat_main;
17418 int count = ntohl (mp->count);
17419 vat_json_node_t *node = NULL;
17420 struct in_addr ip4;
17421 struct in6_addr ip6;
17422 vl_api_fib_path_t *fp;
17425 if (VAT_JSON_ARRAY != vam->json_tree.type)
17427 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17428 vat_json_init_array (&vam->json_tree);
17430 node = vat_json_array_add (&vam->json_tree);
17432 vat_json_init_object (node);
17433 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17434 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
17435 vat_json_object_add_ip4 (node, "prefix", ip4);
17436 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17437 vat_json_object_add_uint (node, "path_count", count);
17439 for (i = 0; i < count; i++)
17441 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17442 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17443 vat_json_object_add_uint (node, "is_local", fp->is_local);
17444 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17445 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17446 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17447 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17448 if (fp->afi == IP46_TYPE_IP4)
17450 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17451 vat_json_object_add_ip4 (node, "next_hop", ip4);
17453 else if (fp->afi == IP46_TYPE_IP6)
17455 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17456 vat_json_object_add_ip6 (node, "next_hop", ip6);
17462 api_ip_fib_dump (vat_main_t * vam)
17464 vl_api_ip_fib_dump_t *mp;
17465 vl_api_control_ping_t *mp_ping;
17468 M (IP_FIB_DUMP, mp);
17471 /* Use a control ping for synchronization */
17472 M (CONTROL_PING, mp_ping);
17480 api_ip_mfib_dump (vat_main_t * vam)
17482 vl_api_ip_mfib_dump_t *mp;
17483 vl_api_control_ping_t *mp_ping;
17486 M (IP_MFIB_DUMP, mp);
17489 /* Use a control ping for synchronization */
17490 M (CONTROL_PING, mp_ping);
17497 static void vl_api_ip_neighbor_details_t_handler
17498 (vl_api_ip_neighbor_details_t * mp)
17500 vat_main_t *vam = &vat_main;
17502 print (vam->ofp, "%c %U %U",
17503 (mp->is_static) ? 'S' : 'D',
17504 format_ethernet_address, &mp->mac_address,
17505 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
17509 static void vl_api_ip_neighbor_details_t_handler_json
17510 (vl_api_ip_neighbor_details_t * mp)
17513 vat_main_t *vam = &vat_main;
17514 vat_json_node_t *node;
17515 struct in_addr ip4;
17516 struct in6_addr ip6;
17518 if (VAT_JSON_ARRAY != vam->json_tree.type)
17520 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17521 vat_json_init_array (&vam->json_tree);
17523 node = vat_json_array_add (&vam->json_tree);
17525 vat_json_init_object (node);
17526 vat_json_object_add_string_copy (node, "flag",
17527 (mp->is_static) ? (u8 *) "static" : (u8 *)
17530 vat_json_object_add_string_copy (node, "link_layer",
17531 format (0, "%U", format_ethernet_address,
17532 &mp->mac_address));
17536 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
17537 vat_json_object_add_ip6 (node, "ip_address", ip6);
17541 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
17542 vat_json_object_add_ip4 (node, "ip_address", ip4);
17547 api_ip_neighbor_dump (vat_main_t * vam)
17549 unformat_input_t *i = vam->input;
17550 vl_api_ip_neighbor_dump_t *mp;
17551 vl_api_control_ping_t *mp_ping;
17553 u32 sw_if_index = ~0;
17556 /* Parse args required to build the message */
17557 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17559 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17561 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17563 else if (unformat (i, "ip6"))
17569 if (sw_if_index == ~0)
17571 errmsg ("missing interface name or sw_if_index");
17575 M (IP_NEIGHBOR_DUMP, mp);
17576 mp->is_ipv6 = (u8) is_ipv6;
17577 mp->sw_if_index = ntohl (sw_if_index);
17580 /* Use a control ping for synchronization */
17581 M (CONTROL_PING, mp_ping);
17588 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
17589 #define vl_api_ip6_fib_details_t_print vl_noop_handler
17592 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
17594 vat_main_t *vam = &vat_main;
17595 int count = ntohl (mp->count);
17596 vl_api_fib_path_t *fp;
17600 "table-id %d, prefix %U/%d",
17601 ntohl (mp->table_id), format_ip6_address, mp->address,
17602 mp->address_length);
17604 for (i = 0; i < count; i++)
17606 if (fp->afi == IP46_TYPE_IP6)
17608 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17609 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17610 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17611 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17612 format_ip6_address, fp->next_hop);
17613 else if (fp->afi == IP46_TYPE_IP4)
17615 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17616 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17617 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17618 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17619 format_ip4_address, fp->next_hop);
17624 static void vl_api_ip6_fib_details_t_handler_json
17625 (vl_api_ip6_fib_details_t * mp)
17627 vat_main_t *vam = &vat_main;
17628 int count = ntohl (mp->count);
17629 vat_json_node_t *node = NULL;
17630 struct in_addr ip4;
17631 struct in6_addr ip6;
17632 vl_api_fib_path_t *fp;
17635 if (VAT_JSON_ARRAY != vam->json_tree.type)
17637 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17638 vat_json_init_array (&vam->json_tree);
17640 node = vat_json_array_add (&vam->json_tree);
17642 vat_json_init_object (node);
17643 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17644 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
17645 vat_json_object_add_ip6 (node, "prefix", ip6);
17646 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17647 vat_json_object_add_uint (node, "path_count", count);
17649 for (i = 0; i < count; i++)
17651 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17652 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17653 vat_json_object_add_uint (node, "is_local", fp->is_local);
17654 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17655 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17656 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17657 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17658 if (fp->afi == IP46_TYPE_IP4)
17660 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17661 vat_json_object_add_ip4 (node, "next_hop", ip4);
17663 else if (fp->afi == IP46_TYPE_IP6)
17665 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17666 vat_json_object_add_ip6 (node, "next_hop", ip6);
17672 api_ip6_fib_dump (vat_main_t * vam)
17674 vl_api_ip6_fib_dump_t *mp;
17675 vl_api_control_ping_t *mp_ping;
17678 M (IP6_FIB_DUMP, mp);
17681 /* Use a control ping for synchronization */
17682 M (CONTROL_PING, mp_ping);
17690 api_ip6_mfib_dump (vat_main_t * vam)
17692 vl_api_ip6_mfib_dump_t *mp;
17693 vl_api_control_ping_t *mp_ping;
17696 M (IP6_MFIB_DUMP, mp);
17699 /* Use a control ping for synchronization */
17700 M (CONTROL_PING, mp_ping);
17708 api_classify_table_ids (vat_main_t * vam)
17710 vl_api_classify_table_ids_t *mp;
17713 /* Construct the API message */
17714 M (CLASSIFY_TABLE_IDS, mp);
17723 api_classify_table_by_interface (vat_main_t * vam)
17725 unformat_input_t *input = vam->input;
17726 vl_api_classify_table_by_interface_t *mp;
17728 u32 sw_if_index = ~0;
17730 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17732 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17734 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17739 if (sw_if_index == ~0)
17741 errmsg ("missing interface name or sw_if_index");
17745 /* Construct the API message */
17746 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
17748 mp->sw_if_index = ntohl (sw_if_index);
17756 api_classify_table_info (vat_main_t * vam)
17758 unformat_input_t *input = vam->input;
17759 vl_api_classify_table_info_t *mp;
17763 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17765 if (unformat (input, "table_id %d", &table_id))
17770 if (table_id == ~0)
17772 errmsg ("missing table id");
17776 /* Construct the API message */
17777 M (CLASSIFY_TABLE_INFO, mp);
17779 mp->table_id = ntohl (table_id);
17787 api_classify_session_dump (vat_main_t * vam)
17789 unformat_input_t *input = vam->input;
17790 vl_api_classify_session_dump_t *mp;
17791 vl_api_control_ping_t *mp_ping;
17795 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17797 if (unformat (input, "table_id %d", &table_id))
17802 if (table_id == ~0)
17804 errmsg ("missing table id");
17808 /* Construct the API message */
17809 M (CLASSIFY_SESSION_DUMP, mp);
17811 mp->table_id = ntohl (table_id);
17814 /* Use a control ping for synchronization */
17815 M (CONTROL_PING, mp_ping);
17823 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
17825 vat_main_t *vam = &vat_main;
17827 print (vam->ofp, "collector_address %U, collector_port %d, "
17828 "src_address %U, vrf_id %d, path_mtu %u, "
17829 "template_interval %u, udp_checksum %d",
17830 format_ip4_address, mp->collector_address,
17831 ntohs (mp->collector_port),
17832 format_ip4_address, mp->src_address,
17833 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
17834 ntohl (mp->template_interval), mp->udp_checksum);
17837 vam->result_ready = 1;
17841 vl_api_ipfix_exporter_details_t_handler_json
17842 (vl_api_ipfix_exporter_details_t * mp)
17844 vat_main_t *vam = &vat_main;
17845 vat_json_node_t node;
17846 struct in_addr collector_address;
17847 struct in_addr src_address;
17849 vat_json_init_object (&node);
17850 clib_memcpy (&collector_address, &mp->collector_address,
17851 sizeof (collector_address));
17852 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
17853 vat_json_object_add_uint (&node, "collector_port",
17854 ntohs (mp->collector_port));
17855 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
17856 vat_json_object_add_ip4 (&node, "src_address", src_address);
17857 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
17858 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
17859 vat_json_object_add_uint (&node, "template_interval",
17860 ntohl (mp->template_interval));
17861 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
17863 vat_json_print (vam->ofp, &node);
17864 vat_json_free (&node);
17866 vam->result_ready = 1;
17870 api_ipfix_exporter_dump (vat_main_t * vam)
17872 vl_api_ipfix_exporter_dump_t *mp;
17875 /* Construct the API message */
17876 M (IPFIX_EXPORTER_DUMP, mp);
17885 api_ipfix_classify_stream_dump (vat_main_t * vam)
17887 vl_api_ipfix_classify_stream_dump_t *mp;
17890 /* Construct the API message */
17891 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
17902 vl_api_ipfix_classify_stream_details_t_handler
17903 (vl_api_ipfix_classify_stream_details_t * mp)
17905 vat_main_t *vam = &vat_main;
17906 print (vam->ofp, "domain_id %d, src_port %d",
17907 ntohl (mp->domain_id), ntohs (mp->src_port));
17909 vam->result_ready = 1;
17913 vl_api_ipfix_classify_stream_details_t_handler_json
17914 (vl_api_ipfix_classify_stream_details_t * mp)
17916 vat_main_t *vam = &vat_main;
17917 vat_json_node_t node;
17919 vat_json_init_object (&node);
17920 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
17921 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
17923 vat_json_print (vam->ofp, &node);
17924 vat_json_free (&node);
17926 vam->result_ready = 1;
17930 api_ipfix_classify_table_dump (vat_main_t * vam)
17932 vl_api_ipfix_classify_table_dump_t *mp;
17933 vl_api_control_ping_t *mp_ping;
17936 if (!vam->json_output)
17938 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
17939 "transport_protocol");
17942 /* Construct the API message */
17943 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
17948 /* Use a control ping for synchronization */
17949 M (CONTROL_PING, mp_ping);
17957 vl_api_ipfix_classify_table_details_t_handler
17958 (vl_api_ipfix_classify_table_details_t * mp)
17960 vat_main_t *vam = &vat_main;
17961 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
17962 mp->transport_protocol);
17966 vl_api_ipfix_classify_table_details_t_handler_json
17967 (vl_api_ipfix_classify_table_details_t * mp)
17969 vat_json_node_t *node = NULL;
17970 vat_main_t *vam = &vat_main;
17972 if (VAT_JSON_ARRAY != vam->json_tree.type)
17974 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17975 vat_json_init_array (&vam->json_tree);
17978 node = vat_json_array_add (&vam->json_tree);
17979 vat_json_init_object (node);
17981 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
17982 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
17983 vat_json_object_add_uint (node, "transport_protocol",
17984 mp->transport_protocol);
17988 api_sw_interface_span_enable_disable (vat_main_t * vam)
17990 unformat_input_t *i = vam->input;
17991 vl_api_sw_interface_span_enable_disable_t *mp;
17992 u32 src_sw_if_index = ~0;
17993 u32 dst_sw_if_index = ~0;
17997 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18000 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
18002 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
18006 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
18008 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
18010 else if (unformat (i, "disable"))
18012 else if (unformat (i, "rx"))
18014 else if (unformat (i, "tx"))
18016 else if (unformat (i, "both"))
18022 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
18024 mp->sw_if_index_from = htonl (src_sw_if_index);
18025 mp->sw_if_index_to = htonl (dst_sw_if_index);
18034 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
18037 vat_main_t *vam = &vat_main;
18038 u8 *sw_if_from_name = 0;
18039 u8 *sw_if_to_name = 0;
18040 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18041 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18042 char *states[] = { "none", "rx", "tx", "both" };
18046 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18048 if ((u32) p->value[0] == sw_if_index_from)
18050 sw_if_from_name = (u8 *)(p->key);
18054 if ((u32) p->value[0] == sw_if_index_to)
18056 sw_if_to_name = (u8 *)(p->key);
18057 if (sw_if_from_name)
18062 print (vam->ofp, "%20s => %20s (%s)",
18063 sw_if_from_name, sw_if_to_name, states[mp->state]);
18067 vl_api_sw_interface_span_details_t_handler_json
18068 (vl_api_sw_interface_span_details_t * mp)
18070 vat_main_t *vam = &vat_main;
18071 vat_json_node_t *node = NULL;
18072 u8 *sw_if_from_name = 0;
18073 u8 *sw_if_to_name = 0;
18074 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18075 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18079 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18081 if ((u32) p->value[0] == sw_if_index_from)
18083 sw_if_from_name = (u8 *)(p->key);
18087 if ((u32) p->value[0] == sw_if_index_to)
18089 sw_if_to_name = (u8 *)(p->key);
18090 if (sw_if_from_name)
18096 if (VAT_JSON_ARRAY != vam->json_tree.type)
18098 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18099 vat_json_init_array (&vam->json_tree);
18101 node = vat_json_array_add (&vam->json_tree);
18103 vat_json_init_object (node);
18104 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
18105 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
18106 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
18107 if (0 != sw_if_to_name)
18109 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
18111 vat_json_object_add_uint (node, "state", mp->state);
18115 api_sw_interface_span_dump (vat_main_t * vam)
18117 vl_api_sw_interface_span_dump_t *mp;
18118 vl_api_control_ping_t *mp_ping;
18121 M (SW_INTERFACE_SPAN_DUMP, mp);
18124 /* Use a control ping for synchronization */
18125 M (CONTROL_PING, mp_ping);
18133 api_pg_create_interface (vat_main_t * vam)
18135 unformat_input_t *input = vam->input;
18136 vl_api_pg_create_interface_t *mp;
18140 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18142 if (unformat (input, "if_id %d", &if_id))
18149 errmsg ("missing pg interface index");
18153 /* Construct the API message */
18154 M (PG_CREATE_INTERFACE, mp);
18156 mp->interface_id = ntohl (if_id);
18164 api_pg_capture (vat_main_t * vam)
18166 unformat_input_t *input = vam->input;
18167 vl_api_pg_capture_t *mp;
18172 u8 pcap_file_set = 0;
18175 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18177 if (unformat (input, "if_id %d", &if_id))
18179 else if (unformat (input, "pcap %s", &pcap_file))
18181 else if (unformat (input, "count %d", &count))
18183 else if (unformat (input, "disable"))
18190 errmsg ("missing pg interface index");
18193 if (pcap_file_set > 0)
18195 if (vec_len (pcap_file) > 255)
18197 errmsg ("pcap file name is too long");
18202 u32 name_len = vec_len (pcap_file);
18203 /* Construct the API message */
18204 M (PG_CAPTURE, mp);
18206 mp->interface_id = ntohl (if_id);
18207 mp->is_enabled = enable;
18208 mp->count = ntohl (count);
18209 mp->pcap_name_length = ntohl (name_len);
18210 if (pcap_file_set != 0)
18212 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
18214 vec_free (pcap_file);
18222 api_pg_enable_disable (vat_main_t * vam)
18224 unformat_input_t *input = vam->input;
18225 vl_api_pg_enable_disable_t *mp;
18228 u8 stream_name_set = 0;
18229 u8 *stream_name = 0;
18231 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18233 if (unformat (input, "stream %s", &stream_name))
18234 stream_name_set = 1;
18235 else if (unformat (input, "disable"))
18241 if (stream_name_set > 0)
18243 if (vec_len (stream_name) > 255)
18245 errmsg ("stream name too long");
18250 u32 name_len = vec_len (stream_name);
18251 /* Construct the API message */
18252 M (PG_ENABLE_DISABLE, mp);
18254 mp->is_enabled = enable;
18255 if (stream_name_set != 0)
18257 mp->stream_name_length = ntohl (name_len);
18258 clib_memcpy (mp->stream_name, stream_name, name_len);
18260 vec_free (stream_name);
18268 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
18270 unformat_input_t *input = vam->input;
18271 vl_api_ip_source_and_port_range_check_add_del_t *mp;
18273 u16 *low_ports = 0;
18274 u16 *high_ports = 0;
18277 ip4_address_t ip4_addr;
18278 ip6_address_t ip6_addr;
18287 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18289 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
18295 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
18300 else if (unformat (input, "vrf %d", &vrf_id))
18302 else if (unformat (input, "del"))
18304 else if (unformat (input, "port %d", &tmp))
18306 if (tmp == 0 || tmp > 65535)
18308 errmsg ("port %d out of range", tmp);
18312 this_hi = this_low + 1;
18313 vec_add1 (low_ports, this_low);
18314 vec_add1 (high_ports, this_hi);
18316 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
18318 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
18320 errmsg ("incorrect range parameters");
18324 /* Note: in debug CLI +1 is added to high before
18325 passing to real fn that does "the work"
18326 (ip_source_and_port_range_check_add_del).
18327 This fn is a wrapper around the binary API fn a
18328 control plane will call, which expects this increment
18329 to have occurred. Hence letting the binary API control
18330 plane fn do the increment for consistency between VAT
18331 and other control planes.
18334 vec_add1 (low_ports, this_low);
18335 vec_add1 (high_ports, this_hi);
18341 if (prefix_set == 0)
18343 errmsg ("<address>/<mask> not specified");
18349 errmsg ("VRF ID required, not specified");
18356 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18360 if (vec_len (low_ports) == 0)
18362 errmsg ("At least one port or port range required");
18366 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
18368 mp->is_add = is_add;
18373 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
18378 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
18381 mp->mask_length = length;
18382 mp->number_of_ranges = vec_len (low_ports);
18384 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
18385 vec_free (low_ports);
18387 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
18388 vec_free (high_ports);
18390 mp->vrf_id = ntohl (vrf_id);
18398 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
18400 unformat_input_t *input = vam->input;
18401 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
18402 u32 sw_if_index = ~0;
18404 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
18405 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
18409 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18411 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18413 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18415 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
18417 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
18419 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
18421 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
18423 else if (unformat (input, "del"))
18429 if (sw_if_index == ~0)
18431 errmsg ("Interface required but not specified");
18437 errmsg ("VRF ID required but not specified");
18441 if (tcp_out_vrf_id == 0
18442 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
18445 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18449 /* Construct the API message */
18450 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
18452 mp->sw_if_index = ntohl (sw_if_index);
18453 mp->is_add = is_add;
18454 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
18455 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
18456 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
18457 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
18462 /* Wait for a reply... */
18468 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
18470 unformat_input_t *i = vam->input;
18471 vl_api_ipsec_gre_add_del_tunnel_t *mp;
18472 u32 local_sa_id = 0;
18473 u32 remote_sa_id = 0;
18474 ip4_address_t src_address;
18475 ip4_address_t dst_address;
18479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18481 if (unformat (i, "local_sa %d", &local_sa_id))
18483 else if (unformat (i, "remote_sa %d", &remote_sa_id))
18485 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
18487 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
18489 else if (unformat (i, "del"))
18493 clib_warning ("parse error '%U'", format_unformat_error, i);
18498 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
18500 mp->local_sa_id = ntohl (local_sa_id);
18501 mp->remote_sa_id = ntohl (remote_sa_id);
18502 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
18503 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
18504 mp->is_add = is_add;
18512 api_punt (vat_main_t * vam)
18514 unformat_input_t *i = vam->input;
18522 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18524 if (unformat (i, "ip %d", &ipv))
18526 else if (unformat (i, "protocol %d", &protocol))
18528 else if (unformat (i, "port %d", &port))
18530 else if (unformat (i, "del"))
18534 clib_warning ("parse error '%U'", format_unformat_error, i);
18541 mp->is_add = (u8) is_add;
18542 mp->ipv = (u8) ipv;
18543 mp->l4_protocol = (u8) protocol;
18544 mp->l4_port = htons ((u16) port);
18551 static void vl_api_ipsec_gre_tunnel_details_t_handler
18552 (vl_api_ipsec_gre_tunnel_details_t * mp)
18554 vat_main_t *vam = &vat_main;
18556 print (vam->ofp, "%11d%15U%15U%14d%14d",
18557 ntohl (mp->sw_if_index),
18558 format_ip4_address, &mp->src_address,
18559 format_ip4_address, &mp->dst_address,
18560 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
18563 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
18564 (vl_api_ipsec_gre_tunnel_details_t * mp)
18566 vat_main_t *vam = &vat_main;
18567 vat_json_node_t *node = NULL;
18568 struct in_addr ip4;
18570 if (VAT_JSON_ARRAY != vam->json_tree.type)
18572 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18573 vat_json_init_array (&vam->json_tree);
18575 node = vat_json_array_add (&vam->json_tree);
18577 vat_json_init_object (node);
18578 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18579 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
18580 vat_json_object_add_ip4 (node, "src_address", ip4);
18581 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
18582 vat_json_object_add_ip4 (node, "dst_address", ip4);
18583 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
18584 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
18588 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
18590 unformat_input_t *i = vam->input;
18591 vl_api_ipsec_gre_tunnel_dump_t *mp;
18592 vl_api_control_ping_t *mp_ping;
18594 u8 sw_if_index_set = 0;
18597 /* Parse args required to build the message */
18598 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18600 if (unformat (i, "sw_if_index %d", &sw_if_index))
18601 sw_if_index_set = 1;
18606 if (sw_if_index_set == 0)
18611 if (!vam->json_output)
18613 print (vam->ofp, "%11s%15s%15s%14s%14s",
18614 "sw_if_index", "src_address", "dst_address",
18615 "local_sa_id", "remote_sa_id");
18618 /* Get list of gre-tunnel interfaces */
18619 M (IPSEC_GRE_TUNNEL_DUMP, mp);
18621 mp->sw_if_index = htonl (sw_if_index);
18625 /* Use a control ping for synchronization */
18626 M (CONTROL_PING, mp_ping);
18634 api_delete_subif (vat_main_t * vam)
18636 unformat_input_t *i = vam->input;
18637 vl_api_delete_subif_t *mp;
18638 u32 sw_if_index = ~0;
18641 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18643 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18645 if (unformat (i, "sw_if_index %d", &sw_if_index))
18651 if (sw_if_index == ~0)
18653 errmsg ("missing sw_if_index");
18657 /* Construct the API message */
18658 M (DELETE_SUBIF, mp);
18659 mp->sw_if_index = ntohl (sw_if_index);
18666 #define foreach_pbb_vtr_op \
18667 _("disable", L2_VTR_DISABLED) \
18668 _("pop", L2_VTR_POP_2) \
18669 _("push", L2_VTR_PUSH_2)
18672 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
18674 unformat_input_t *i = vam->input;
18675 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
18676 u32 sw_if_index = ~0, vtr_op = ~0;
18677 u16 outer_tag = ~0;
18678 u8 dmac[6], smac[6];
18679 u8 dmac_set = 0, smac_set = 0;
18685 /* Shut up coverity */
18686 memset (dmac, 0, sizeof (dmac));
18687 memset (smac, 0, sizeof (smac));
18689 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18691 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18693 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18695 else if (unformat (i, "vtr_op %d", &vtr_op))
18697 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
18700 else if (unformat (i, "translate_pbb_stag"))
18702 if (unformat (i, "%d", &tmp))
18704 vtr_op = L2_VTR_TRANSLATE_2_1;
18710 ("translate_pbb_stag operation requires outer tag definition");
18714 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
18716 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
18718 else if (unformat (i, "sid %d", &sid))
18720 else if (unformat (i, "vlanid %d", &tmp))
18724 clib_warning ("parse error '%U'", format_unformat_error, i);
18729 if ((sw_if_index == ~0) || (vtr_op == ~0))
18731 errmsg ("missing sw_if_index or vtr operation");
18734 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
18735 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
18738 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
18742 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
18743 mp->sw_if_index = ntohl (sw_if_index);
18744 mp->vtr_op = ntohl (vtr_op);
18745 mp->outer_tag = ntohs (outer_tag);
18746 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
18747 clib_memcpy (mp->b_smac, smac, sizeof (smac));
18748 mp->b_vlanid = ntohs (vlanid);
18749 mp->i_sid = ntohl (sid);
18757 api_flow_classify_set_interface (vat_main_t * vam)
18759 unformat_input_t *i = vam->input;
18760 vl_api_flow_classify_set_interface_t *mp;
18762 int sw_if_index_set;
18763 u32 ip4_table_index = ~0;
18764 u32 ip6_table_index = ~0;
18768 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18770 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18771 sw_if_index_set = 1;
18772 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18773 sw_if_index_set = 1;
18774 else if (unformat (i, "del"))
18776 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18778 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18782 clib_warning ("parse error '%U'", format_unformat_error, i);
18787 if (sw_if_index_set == 0)
18789 errmsg ("missing interface name or sw_if_index");
18793 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
18795 mp->sw_if_index = ntohl (sw_if_index);
18796 mp->ip4_table_index = ntohl (ip4_table_index);
18797 mp->ip6_table_index = ntohl (ip6_table_index);
18798 mp->is_add = is_add;
18806 api_flow_classify_dump (vat_main_t * vam)
18808 unformat_input_t *i = vam->input;
18809 vl_api_flow_classify_dump_t *mp;
18810 vl_api_control_ping_t *mp_ping;
18811 u8 type = FLOW_CLASSIFY_N_TABLES;
18814 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
18818 errmsg ("classify table type must be specified");
18822 if (!vam->json_output)
18824 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18827 M (FLOW_CLASSIFY_DUMP, mp);
18832 /* Use a control ping for synchronization */
18833 M (CONTROL_PING, mp_ping);
18836 /* Wait for a reply... */
18842 api_feature_enable_disable (vat_main_t * vam)
18844 unformat_input_t *i = vam->input;
18845 vl_api_feature_enable_disable_t *mp;
18847 u8 *feature_name = 0;
18848 u32 sw_if_index = ~0;
18852 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18854 if (unformat (i, "arc_name %s", &arc_name))
18856 else if (unformat (i, "feature_name %s", &feature_name))
18859 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18861 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18863 else if (unformat (i, "disable"))
18871 errmsg ("missing arc name");
18874 if (vec_len (arc_name) > 63)
18876 errmsg ("arc name too long");
18879 if (feature_name == 0)
18881 errmsg ("missing feature name");
18884 if (vec_len (feature_name) > 63)
18886 errmsg ("feature name too long");
18889 if (sw_if_index == ~0)
18891 errmsg ("missing interface name or sw_if_index");
18895 /* Construct the API message */
18896 M (FEATURE_ENABLE_DISABLE, mp);
18897 mp->sw_if_index = ntohl (sw_if_index);
18898 mp->enable = enable;
18899 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
18900 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
18901 vec_free (arc_name);
18902 vec_free (feature_name);
18910 api_sw_interface_tag_add_del (vat_main_t * vam)
18912 unformat_input_t *i = vam->input;
18913 vl_api_sw_interface_tag_add_del_t *mp;
18914 u32 sw_if_index = ~0;
18919 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18921 if (unformat (i, "tag %s", &tag))
18923 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18925 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18927 else if (unformat (i, "del"))
18933 if (sw_if_index == ~0)
18935 errmsg ("missing interface name or sw_if_index");
18939 if (enable && (tag == 0))
18941 errmsg ("no tag specified");
18945 /* Construct the API message */
18946 M (SW_INTERFACE_TAG_ADD_DEL, mp);
18947 mp->sw_if_index = ntohl (sw_if_index);
18948 mp->is_add = enable;
18950 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
18958 static void vl_api_l2_xconnect_details_t_handler
18959 (vl_api_l2_xconnect_details_t * mp)
18961 vat_main_t *vam = &vat_main;
18963 print (vam->ofp, "%15d%15d",
18964 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
18967 static void vl_api_l2_xconnect_details_t_handler_json
18968 (vl_api_l2_xconnect_details_t * mp)
18970 vat_main_t *vam = &vat_main;
18971 vat_json_node_t *node = NULL;
18973 if (VAT_JSON_ARRAY != vam->json_tree.type)
18975 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18976 vat_json_init_array (&vam->json_tree);
18978 node = vat_json_array_add (&vam->json_tree);
18980 vat_json_init_object (node);
18981 vat_json_object_add_uint (node, "rx_sw_if_index",
18982 ntohl (mp->rx_sw_if_index));
18983 vat_json_object_add_uint (node, "tx_sw_if_index",
18984 ntohl (mp->tx_sw_if_index));
18988 api_l2_xconnect_dump (vat_main_t * vam)
18990 vl_api_l2_xconnect_dump_t *mp;
18991 vl_api_control_ping_t *mp_ping;
18994 if (!vam->json_output)
18996 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
18999 M (L2_XCONNECT_DUMP, mp);
19003 /* Use a control ping for synchronization */
19004 M (CONTROL_PING, mp_ping);
19012 api_sw_interface_set_mtu (vat_main_t * vam)
19014 unformat_input_t *i = vam->input;
19015 vl_api_sw_interface_set_mtu_t *mp;
19016 u32 sw_if_index = ~0;
19020 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19022 if (unformat (i, "mtu %d", &mtu))
19024 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19026 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19032 if (sw_if_index == ~0)
19034 errmsg ("missing interface name or sw_if_index");
19040 errmsg ("no mtu specified");
19044 /* Construct the API message */
19045 M (SW_INTERFACE_SET_MTU, mp);
19046 mp->sw_if_index = ntohl (sw_if_index);
19047 mp->mtu = ntohs ((u16) mtu);
19055 api_p2p_ethernet_add (vat_main_t * vam)
19057 unformat_input_t *i = vam->input;
19058 vl_api_p2p_ethernet_add_t *mp;
19059 u32 parent_if_index = ~0;
19064 memset (remote_mac, 0, sizeof (remote_mac));
19065 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19067 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19069 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19073 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19077 clib_warning ("parse error '%U'", format_unformat_error, i);
19082 if (parent_if_index == ~0)
19084 errmsg ("missing interface name or sw_if_index");
19089 errmsg ("missing remote mac address");
19093 M (P2P_ETHERNET_ADD, mp);
19094 mp->parent_if_index = ntohl (parent_if_index);
19095 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19103 api_p2p_ethernet_del (vat_main_t * vam)
19105 unformat_input_t *i = vam->input;
19106 vl_api_p2p_ethernet_del_t *mp;
19107 u32 parent_if_index = ~0;
19112 memset (remote_mac, 0, sizeof (remote_mac));
19113 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19115 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19117 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19121 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19125 clib_warning ("parse error '%U'", format_unformat_error, i);
19130 if (parent_if_index == ~0)
19132 errmsg ("missing interface name or sw_if_index");
19137 errmsg ("missing remote mac address");
19141 M (P2P_ETHERNET_DEL, mp);
19142 mp->parent_if_index = ntohl (parent_if_index);
19143 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19151 q_or_quit (vat_main_t * vam)
19153 #if VPP_API_TEST_BUILTIN == 0
19154 longjmp (vam->jump_buf, 1);
19156 return 0; /* not so much */
19160 q (vat_main_t * vam)
19162 return q_or_quit (vam);
19166 quit (vat_main_t * vam)
19168 return q_or_quit (vam);
19172 comment (vat_main_t * vam)
19178 cmd_cmp (void *a1, void *a2)
19183 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
19187 help (vat_main_t * vam)
19192 unformat_input_t *i = vam->input;
19195 if (unformat (i, "%s", &name))
19199 vec_add1 (name, 0);
19201 hs = hash_get_mem (vam->help_by_name, name);
19203 print (vam->ofp, "usage: %s %s", name, hs[0]);
19205 print (vam->ofp, "No such msg / command '%s'", name);
19210 print (vam->ofp, "Help is available for the following:");
19213 hash_foreach_pair (p, vam->function_by_name,
19215 vec_add1 (cmds, (u8 *)(p->key));
19219 vec_sort_with_function (cmds, cmd_cmp);
19221 for (j = 0; j < vec_len (cmds); j++)
19222 print (vam->ofp, "%s", cmds[j]);
19229 set (vat_main_t * vam)
19231 u8 *name = 0, *value = 0;
19232 unformat_input_t *i = vam->input;
19234 if (unformat (i, "%s", &name))
19236 /* The input buffer is a vector, not a string. */
19237 value = vec_dup (i->buffer);
19238 vec_delete (value, i->index, 0);
19239 /* Almost certainly has a trailing newline */
19240 if (value[vec_len (value) - 1] == '\n')
19241 value[vec_len (value) - 1] = 0;
19242 /* Make sure it's a proper string, one way or the other */
19243 vec_add1 (value, 0);
19244 (void) clib_macro_set_value (&vam->macro_main,
19245 (char *) name, (char *) value);
19248 errmsg ("usage: set <name> <value>");
19256 unset (vat_main_t * vam)
19260 if (unformat (vam->input, "%s", &name))
19261 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
19262 errmsg ("unset: %s wasn't set", name);
19275 macro_sort_cmp (void *a1, void *a2)
19277 macro_sort_t *s1 = a1;
19278 macro_sort_t *s2 = a2;
19280 return strcmp ((char *) (s1->name), (char *) (s2->name));
19284 dump_macro_table (vat_main_t * vam)
19286 macro_sort_t *sort_me = 0, *sm;
19291 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
19293 vec_add2 (sort_me, sm, 1);
19294 sm->name = (u8 *)(p->key);
19295 sm->value = (u8 *) (p->value[0]);
19299 vec_sort_with_function (sort_me, macro_sort_cmp);
19301 if (vec_len (sort_me))
19302 print (vam->ofp, "%-15s%s", "Name", "Value");
19304 print (vam->ofp, "The macro table is empty...");
19306 for (i = 0; i < vec_len (sort_me); i++)
19307 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
19312 dump_node_table (vat_main_t * vam)
19315 vlib_node_t *node, *next_node;
19317 if (vec_len (vam->graph_nodes) == 0)
19319 print (vam->ofp, "Node table empty, issue get_node_graph...");
19323 for (i = 0; i < vec_len (vam->graph_nodes); i++)
19325 node = vam->graph_nodes[i];
19326 print (vam->ofp, "[%d] %s", i, node->name);
19327 for (j = 0; j < vec_len (node->next_nodes); j++)
19329 if (node->next_nodes[j] != ~0)
19331 next_node = vam->graph_nodes[node->next_nodes[j]];
19332 print (vam->ofp, " [%d] %s", j, next_node->name);
19340 value_sort_cmp (void *a1, void *a2)
19342 name_sort_t *n1 = a1;
19343 name_sort_t *n2 = a2;
19345 if (n1->value < n2->value)
19347 if (n1->value > n2->value)
19354 dump_msg_api_table (vat_main_t * vam)
19356 api_main_t *am = &api_main;
19357 name_sort_t *nses = 0, *ns;
19362 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
19364 vec_add2 (nses, ns, 1);
19365 ns->name = (u8 *)(hp->key);
19366 ns->value = (u32) hp->value[0];
19370 vec_sort_with_function (nses, value_sort_cmp);
19372 for (i = 0; i < vec_len (nses); i++)
19373 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
19379 get_msg_id (vat_main_t * vam)
19384 if (unformat (vam->input, "%s", &name_and_crc))
19386 message_index = vl_api_get_msg_index (name_and_crc);
19387 if (message_index == ~0)
19389 print (vam->ofp, " '%s' not found", name_and_crc);
19392 print (vam->ofp, " '%s' has message index %d",
19393 name_and_crc, message_index);
19396 errmsg ("name_and_crc required...");
19401 search_node_table (vat_main_t * vam)
19403 unformat_input_t *line_input = vam->input;
19406 vlib_node_t *node, *next_node;
19409 if (vam->graph_node_index_by_name == 0)
19411 print (vam->ofp, "Node table empty, issue get_node_graph...");
19415 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
19417 if (unformat (line_input, "%s", &node_to_find))
19419 vec_add1 (node_to_find, 0);
19420 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
19423 print (vam->ofp, "%s not found...", node_to_find);
19426 node = vam->graph_nodes[p[0]];
19427 print (vam->ofp, "[%d] %s", p[0], node->name);
19428 for (j = 0; j < vec_len (node->next_nodes); j++)
19430 if (node->next_nodes[j] != ~0)
19432 next_node = vam->graph_nodes[node->next_nodes[j]];
19433 print (vam->ofp, " [%d] %s", j, next_node->name);
19440 clib_warning ("parse error '%U'", format_unformat_error,
19446 vec_free (node_to_find);
19455 script (vat_main_t * vam)
19457 #if (VPP_API_TEST_BUILTIN==0)
19459 char *save_current_file;
19460 unformat_input_t save_input;
19461 jmp_buf save_jump_buf;
19462 u32 save_line_number;
19464 FILE *new_fp, *save_ifp;
19466 if (unformat (vam->input, "%s", &s))
19468 new_fp = fopen ((char *) s, "r");
19471 errmsg ("Couldn't open script file %s", s);
19478 errmsg ("Missing script name");
19482 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
19483 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
19484 save_ifp = vam->ifp;
19485 save_line_number = vam->input_line_number;
19486 save_current_file = (char *) vam->current_file;
19488 vam->input_line_number = 0;
19490 vam->current_file = s;
19493 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
19494 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
19495 vam->ifp = save_ifp;
19496 vam->input_line_number = save_line_number;
19497 vam->current_file = (u8 *) save_current_file;
19502 clib_warning ("use the exec command...");
19508 echo (vat_main_t * vam)
19510 print (vam->ofp, "%v", vam->input->buffer);
19514 /* List of API message constructors, CLI names map to api_xxx */
19515 #define foreach_vpe_api_msg \
19516 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
19517 _(sw_interface_dump,"") \
19518 _(sw_interface_set_flags, \
19519 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
19520 _(sw_interface_add_del_address, \
19521 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
19522 _(sw_interface_set_table, \
19523 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
19524 _(sw_interface_set_mpls_enable, \
19525 "<intfc> | sw_if_index [disable | dis]") \
19526 _(sw_interface_set_vpath, \
19527 "<intfc> | sw_if_index <id> enable | disable") \
19528 _(sw_interface_set_vxlan_bypass, \
19529 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
19530 _(sw_interface_set_l2_xconnect, \
19531 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
19532 "enable | disable") \
19533 _(sw_interface_set_l2_bridge, \
19534 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
19535 "[shg <split-horizon-group>] [bvi]\n" \
19536 "enable | disable") \
19537 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
19538 _(bridge_domain_add_del, \
19539 "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") \
19540 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
19542 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
19543 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
19544 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
19546 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
19548 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
19550 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
19552 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
19554 "<vpp-if-name> | sw_if_index <id>") \
19555 _(sw_interface_tap_dump, "") \
19556 _(ip_add_del_route, \
19557 "<addr>/<mask> via <addr> [table-id <n>]\n" \
19558 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
19559 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
19560 "[multipath] [count <n>]") \
19561 _(ip_mroute_add_del, \
19562 "<src> <grp>/<mask> [table-id <n>]\n" \
19563 "[<intfc> | sw_if_index <id>] [local] [del]") \
19564 _(mpls_route_add_del, \
19565 "<label> <eos> via <addr> [table-id <n>]\n" \
19566 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
19567 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
19568 "[multipath] [count <n>]") \
19569 _(mpls_ip_bind_unbind, \
19570 "<label> <addr/len>") \
19571 _(mpls_tunnel_add_del, \
19572 " via <addr> [table-id <n>]\n" \
19573 "sw_if_index <id>] [l2] [del]") \
19574 _(proxy_arp_add_del, \
19575 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
19576 _(proxy_arp_intfc_enable_disable, \
19577 "<intfc> | sw_if_index <id> enable | disable") \
19578 _(sw_interface_set_unnumbered, \
19579 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
19580 _(ip_neighbor_add_del, \
19581 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
19582 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
19583 _(reset_vrf, "vrf <id> [ipv6]") \
19584 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
19585 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
19586 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
19587 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
19588 "[outer_vlan_id_any][inner_vlan_id_any]") \
19589 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
19590 _(reset_fib, "vrf <n> [ipv6]") \
19591 _(dhcp_proxy_config, \
19592 "svr <v46-address> src <v46-address>\n" \
19593 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
19594 _(dhcp_proxy_set_vss, \
19595 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
19596 _(dhcp_proxy_dump, "ip6") \
19597 _(dhcp_client_config, \
19598 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
19599 _(set_ip_flow_hash, \
19600 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
19601 _(sw_interface_ip6_enable_disable, \
19602 "<intfc> | sw_if_index <id> enable | disable") \
19603 _(sw_interface_ip6_set_link_local_address, \
19604 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
19605 _(ip6nd_proxy_add_del, \
19606 "<intfc> | sw_if_index <id> <ip6-address>") \
19607 _(ip6nd_proxy_dump, "") \
19608 _(sw_interface_ip6nd_ra_prefix, \
19609 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
19610 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
19611 "[nolink] [isno]") \
19612 _(sw_interface_ip6nd_ra_config, \
19613 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
19614 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
19615 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
19616 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
19617 _(l2_patch_add_del, \
19618 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
19619 "enable | disable") \
19620 _(sr_localsid_add_del, \
19621 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
19622 "fib-table <num> (end.psp) sw_if_index <num>") \
19623 _(classify_add_del_table, \
19624 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
19625 " [del] [del-chain] mask <mask-value>\n" \
19626 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
19627 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
19628 _(classify_add_del_session, \
19629 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
19630 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
19631 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
19632 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
19633 _(classify_set_interface_ip_table, \
19634 "<intfc> | sw_if_index <nn> table <nn>") \
19635 _(classify_set_interface_l2_tables, \
19636 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19637 " [other-table <nn>]") \
19638 _(get_node_index, "node <node-name") \
19639 _(add_node_next, "node <node-name> next <next-node-name>") \
19640 _(l2tpv3_create_tunnel, \
19641 "client_address <ip6-addr> our_address <ip6-addr>\n" \
19642 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
19643 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
19644 _(l2tpv3_set_tunnel_cookies, \
19645 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
19646 "[new_remote_cookie <nn>]\n") \
19647 _(l2tpv3_interface_enable_disable, \
19648 "<intfc> | sw_if_index <nn> enable | disable") \
19649 _(l2tpv3_set_lookup_key, \
19650 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
19651 _(sw_if_l2tpv3_tunnel_dump, "") \
19652 _(vxlan_add_del_tunnel, \
19653 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
19654 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
19655 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
19656 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19657 _(gre_add_del_tunnel, \
19658 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
19659 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19660 _(l2_fib_clear_table, "") \
19661 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
19662 _(l2_interface_vlan_tag_rewrite, \
19663 "<intfc> | sw_if_index <nn> \n" \
19664 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
19665 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
19666 _(create_vhost_user_if, \
19667 "socket <filename> [server] [renumber <dev_instance>] " \
19668 "[mac <mac_address>]") \
19669 _(modify_vhost_user_if, \
19670 "<intfc> | sw_if_index <nn> socket <filename>\n" \
19671 "[server] [renumber <dev_instance>]") \
19672 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
19673 _(sw_interface_vhost_user_dump, "") \
19674 _(show_version, "") \
19675 _(vxlan_gpe_add_del_tunnel, \
19676 "local <addr> remote <addr> vni <nn>\n" \
19677 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
19678 "[next-ethernet] [next-nsh]\n") \
19679 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19680 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
19681 _(interface_name_renumber, \
19682 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
19683 _(input_acl_set_interface, \
19684 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19685 " [l2-table <nn>] [del]") \
19686 _(want_ip4_arp_events, "address <ip4-address> [del]") \
19687 _(want_ip6_nd_events, "address <ip6-address> [del]") \
19688 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
19689 _(ip_dump, "ipv4 | ipv6") \
19690 _(ipsec_spd_add_del, "spd_id <n> [del]") \
19691 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
19693 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
19694 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
19695 " integ_alg <alg> integ_key <hex>") \
19696 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
19697 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
19698 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
19699 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
19700 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
19701 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
19702 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
19703 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
19704 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
19705 _(ikev2_profile_add_del, "name <profile_name> [del]") \
19706 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
19707 "(auth_data 0x<data> | auth_data <data>)") \
19708 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
19709 "(id_data 0x<data> | id_data <data>) (local|remote)") \
19710 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
19711 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
19712 "(local|remote)") \
19713 _(ikev2_set_local_key, "file <absolute_file_path>") \
19714 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
19715 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
19716 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
19717 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
19718 _(ikev2_initiate_sa_init, "<profile_name>") \
19719 _(ikev2_initiate_del_ike_sa, "<ispi>") \
19720 _(ikev2_initiate_del_child_sa, "<ispi>") \
19721 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
19722 _(delete_loopback,"sw_if_index <nn>") \
19723 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
19724 _(map_add_domain, \
19725 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
19726 "ip6-src <ip6addr> " \
19727 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
19728 _(map_del_domain, "index <n>") \
19729 _(map_add_del_rule, \
19730 "index <n> psid <n> dst <ip6addr> [del]") \
19731 _(map_domain_dump, "") \
19732 _(map_rule_dump, "index <map-domain>") \
19733 _(want_interface_events, "enable|disable") \
19734 _(want_stats,"enable|disable") \
19735 _(get_first_msg_id, "client <name>") \
19736 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
19737 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
19738 "fib-id <nn> [ip4][ip6][default]") \
19739 _(get_node_graph, " ") \
19740 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
19741 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
19742 _(ioam_disable, "") \
19743 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
19744 " sw_if_index <sw_if_index> p <priority> " \
19745 "w <weight>] [del]") \
19746 _(one_add_del_locator, "locator-set <locator_name> " \
19747 "iface <intf> | sw_if_index <sw_if_index> " \
19748 "p <priority> w <weight> [del]") \
19749 _(one_add_del_local_eid,"vni <vni> eid " \
19750 "<ipv4|ipv6>/<prefix> | <L2 address> " \
19751 "locator-set <locator_name> [del]" \
19752 "[key-id sha1|sha256 secret-key <secret-key>]")\
19753 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
19754 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
19755 _(one_enable_disable, "enable|disable") \
19756 _(one_map_register_enable_disable, "enable|disable") \
19757 _(one_rloc_probe_enable_disable, "enable|disable") \
19758 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
19760 "rloc <locator> p <prio> " \
19761 "w <weight> [rloc <loc> ... ] " \
19762 "action <action> [del-all]") \
19763 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
19765 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
19766 _(one_use_petr, "ip-address> | disable") \
19767 _(one_map_request_mode, "src-dst|dst-only") \
19768 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
19769 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
19770 _(one_locator_set_dump, "[local | remote]") \
19771 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
19772 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
19773 "[local] | [remote]") \
19774 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
19775 _(one_l2_arp_bd_get, "") \
19776 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
19777 _(one_stats_enable_disable, "enable|disalbe") \
19778 _(show_one_stats_enable_disable, "") \
19779 _(one_eid_table_vni_dump, "") \
19780 _(one_eid_table_map_dump, "l2|l3") \
19781 _(one_map_resolver_dump, "") \
19782 _(one_map_server_dump, "") \
19783 _(one_adjacencies_get, "vni <vni>") \
19784 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
19785 _(show_one_rloc_probe_state, "") \
19786 _(show_one_map_register_state, "") \
19787 _(show_one_status, "") \
19788 _(one_stats_dump, "") \
19789 _(one_stats_flush, "") \
19790 _(one_get_map_request_itr_rlocs, "") \
19791 _(show_one_nsh_mapping, "") \
19792 _(show_one_pitr, "") \
19793 _(show_one_use_petr, "") \
19794 _(show_one_map_request_mode, "") \
19795 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
19796 " sw_if_index <sw_if_index> p <priority> " \
19797 "w <weight>] [del]") \
19798 _(lisp_add_del_locator, "locator-set <locator_name> " \
19799 "iface <intf> | sw_if_index <sw_if_index> " \
19800 "p <priority> w <weight> [del]") \
19801 _(lisp_add_del_local_eid,"vni <vni> eid " \
19802 "<ipv4|ipv6>/<prefix> | <L2 address> " \
19803 "locator-set <locator_name> [del]" \
19804 "[key-id sha1|sha256 secret-key <secret-key>]") \
19805 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
19806 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
19807 _(lisp_enable_disable, "enable|disable") \
19808 _(lisp_map_register_enable_disable, "enable|disable") \
19809 _(lisp_rloc_probe_enable_disable, "enable|disable") \
19810 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
19812 "rloc <locator> p <prio> " \
19813 "w <weight> [rloc <loc> ... ] " \
19814 "action <action> [del-all]") \
19815 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
19817 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
19818 _(lisp_use_petr, "<ip-address> | disable") \
19819 _(lisp_map_request_mode, "src-dst|dst-only") \
19820 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
19821 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
19822 _(lisp_locator_set_dump, "[local | remote]") \
19823 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
19824 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
19825 "[local] | [remote]") \
19826 _(lisp_eid_table_vni_dump, "") \
19827 _(lisp_eid_table_map_dump, "l2|l3") \
19828 _(lisp_map_resolver_dump, "") \
19829 _(lisp_map_server_dump, "") \
19830 _(lisp_adjacencies_get, "vni <vni>") \
19831 _(gpe_fwd_entry_vnis_get, "") \
19832 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
19833 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
19834 "[table <table-id>]") \
19835 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
19836 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
19837 _(gpe_set_encap_mode, "lisp|vxlan") \
19838 _(gpe_get_encap_mode, "") \
19839 _(lisp_gpe_add_del_iface, "up|down") \
19840 _(lisp_gpe_enable_disable, "enable|disable") \
19841 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
19842 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
19843 _(show_lisp_rloc_probe_state, "") \
19844 _(show_lisp_map_register_state, "") \
19845 _(show_lisp_status, "") \
19846 _(lisp_get_map_request_itr_rlocs, "") \
19847 _(show_lisp_pitr, "") \
19848 _(show_lisp_use_petr, "") \
19849 _(show_lisp_map_request_mode, "") \
19850 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
19851 _(af_packet_delete, "name <host interface name>") \
19852 _(policer_add_del, "name <policer name> <params> [del]") \
19853 _(policer_dump, "[name <policer name>]") \
19854 _(policer_classify_set_interface, \
19855 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19856 " [l2-table <nn>] [del]") \
19857 _(policer_classify_dump, "type [ip4|ip6|l2]") \
19858 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
19859 "[master|slave]") \
19860 _(netmap_delete, "name <interface name>") \
19861 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
19862 _(mpls_fib_dump, "") \
19863 _(classify_table_ids, "") \
19864 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
19865 _(classify_table_info, "table_id <nn>") \
19866 _(classify_session_dump, "table_id <nn>") \
19867 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
19868 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
19869 "[template_interval <nn>] [udp_checksum]") \
19870 _(ipfix_exporter_dump, "") \
19871 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
19872 _(ipfix_classify_stream_dump, "") \
19873 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
19874 _(ipfix_classify_table_dump, "") \
19875 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
19876 _(sw_interface_span_dump, "") \
19877 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
19878 _(pg_create_interface, "if_id <nn>") \
19879 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
19880 _(pg_enable_disable, "[stream <id>] disable") \
19881 _(ip_source_and_port_range_check_add_del, \
19882 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
19883 _(ip_source_and_port_range_check_interface_add_del, \
19884 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
19885 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
19886 _(ipsec_gre_add_del_tunnel, \
19887 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
19888 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
19889 _(delete_subif,"<intfc> | sw_if_index <nn>") \
19890 _(l2_interface_pbb_tag_rewrite, \
19891 "<intfc> | sw_if_index <nn> \n" \
19892 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
19893 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
19894 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
19895 _(flow_classify_set_interface, \
19896 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
19897 _(flow_classify_dump, "type [ip4|ip6]") \
19898 _(ip_fib_dump, "") \
19899 _(ip_mfib_dump, "") \
19900 _(ip6_fib_dump, "") \
19901 _(ip6_mfib_dump, "") \
19902 _(feature_enable_disable, "arc_name <arc_name> " \
19903 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
19904 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
19906 _(l2_xconnect_dump, "") \
19907 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
19908 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
19909 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
19910 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
19911 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>")
19913 /* List of command functions, CLI names map directly to functions */
19914 #define foreach_cli_function \
19915 _(comment, "usage: comment <ignore-rest-of-line>") \
19916 _(dump_interface_table, "usage: dump_interface_table") \
19917 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
19918 _(dump_ipv4_table, "usage: dump_ipv4_table") \
19919 _(dump_ipv6_table, "usage: dump_ipv6_table") \
19920 _(dump_stats_table, "usage: dump_stats_table") \
19921 _(dump_macro_table, "usage: dump_macro_table ") \
19922 _(dump_node_table, "usage: dump_node_table") \
19923 _(dump_msg_api_table, "usage: dump_msg_api_table") \
19924 _(get_msg_id, "usage: get_msg_id name_and_crc") \
19925 _(echo, "usage: echo <message>") \
19926 _(exec, "usage: exec <vpe-debug-CLI-command>") \
19927 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
19928 _(help, "usage: help") \
19929 _(q, "usage: quit") \
19930 _(quit, "usage: quit") \
19931 _(search_node_table, "usage: search_node_table <name>...") \
19932 _(set, "usage: set <variable-name> <value>") \
19933 _(script, "usage: script <file-name>") \
19934 _(unset, "usage: unset <variable-name>")
19937 static void vl_api_##n##_t_handler_uni \
19938 (vl_api_##n##_t * mp) \
19940 vat_main_t * vam = &vat_main; \
19941 if (vam->json_output) { \
19942 vl_api_##n##_t_handler_json(mp); \
19944 vl_api_##n##_t_handler(mp); \
19947 foreach_vpe_api_reply_msg;
19948 #if VPP_API_TEST_BUILTIN == 0
19949 foreach_standalone_reply_msg;
19954 vat_api_hookup (vat_main_t * vam)
19957 vl_msg_api_set_handlers(VL_API_##N, #n, \
19958 vl_api_##n##_t_handler_uni, \
19960 vl_api_##n##_t_endian, \
19961 vl_api_##n##_t_print, \
19962 sizeof(vl_api_##n##_t), 1);
19963 foreach_vpe_api_reply_msg;
19964 #if VPP_API_TEST_BUILTIN == 0
19965 foreach_standalone_reply_msg;
19969 #if (VPP_API_TEST_BUILTIN==0)
19970 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
19972 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
19974 vam->function_by_name = hash_create_string (0, sizeof (uword));
19976 vam->help_by_name = hash_create_string (0, sizeof (uword));
19979 /* API messages we can send */
19980 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
19981 foreach_vpe_api_msg;
19985 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
19986 foreach_vpe_api_msg;
19989 /* CLI functions */
19990 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
19991 foreach_cli_function;
19995 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
19996 foreach_cli_function;
20000 #if VPP_API_TEST_BUILTIN
20001 static clib_error_t *
20002 vat_api_hookup_shim (vlib_main_t * vm)
20004 vat_api_hookup (&vat_main);
20008 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
20012 * fd.io coding-style-patch-verification: ON
20015 * eval: (c-set-style "gnu")