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;
1698 static void vl_api_one_add_del_locator_set_reply_t_handler
1699 (vl_api_one_add_del_locator_set_reply_t * mp)
1701 vat_main_t *vam = &vat_main;
1702 i32 retval = ntohl (mp->retval);
1703 if (vam->async_mode)
1705 vam->async_errors += (retval < 0);
1709 vam->retval = retval;
1710 vam->result_ready = 1;
1714 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1715 (vl_api_one_add_del_locator_set_reply_t * mp)
1717 vat_main_t *vam = &vat_main;
1718 vat_json_node_t node;
1720 vat_json_init_object (&node);
1721 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1722 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_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_vxlan_add_del_tunnel_reply_t_handler
1732 (vl_api_vxlan_add_del_tunnel_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->sw_if_index = ntohl (mp->sw_if_index);
1744 vam->result_ready = 1;
1748 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1749 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1751 vat_main_t *vam = &vat_main;
1752 vat_json_node_t node;
1754 vat_json_init_object (&node);
1755 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1756 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1758 vat_json_print (vam->ofp, &node);
1759 vat_json_free (&node);
1761 vam->retval = ntohl (mp->retval);
1762 vam->result_ready = 1;
1765 static void vl_api_gre_add_del_tunnel_reply_t_handler
1766 (vl_api_gre_add_del_tunnel_reply_t * mp)
1768 vat_main_t *vam = &vat_main;
1769 i32 retval = ntohl (mp->retval);
1770 if (vam->async_mode)
1772 vam->async_errors += (retval < 0);
1776 vam->retval = retval;
1777 vam->sw_if_index = ntohl (mp->sw_if_index);
1778 vam->result_ready = 1;
1782 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1783 (vl_api_gre_add_del_tunnel_reply_t * mp)
1785 vat_main_t *vam = &vat_main;
1786 vat_json_node_t node;
1788 vat_json_init_object (&node);
1789 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1790 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1792 vat_json_print (vam->ofp, &node);
1793 vat_json_free (&node);
1795 vam->retval = ntohl (mp->retval);
1796 vam->result_ready = 1;
1799 static void vl_api_create_vhost_user_if_reply_t_handler
1800 (vl_api_create_vhost_user_if_reply_t * mp)
1802 vat_main_t *vam = &vat_main;
1803 i32 retval = ntohl (mp->retval);
1804 if (vam->async_mode)
1806 vam->async_errors += (retval < 0);
1810 vam->retval = retval;
1811 vam->sw_if_index = ntohl (mp->sw_if_index);
1812 vam->result_ready = 1;
1816 static void vl_api_create_vhost_user_if_reply_t_handler_json
1817 (vl_api_create_vhost_user_if_reply_t * mp)
1819 vat_main_t *vam = &vat_main;
1820 vat_json_node_t node;
1822 vat_json_init_object (&node);
1823 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1824 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1826 vat_json_print (vam->ofp, &node);
1827 vat_json_free (&node);
1829 vam->retval = ntohl (mp->retval);
1830 vam->result_ready = 1;
1833 static void vl_api_ip_address_details_t_handler
1834 (vl_api_ip_address_details_t * mp)
1836 vat_main_t *vam = &vat_main;
1837 static ip_address_details_t empty_ip_address_details = { {0} };
1838 ip_address_details_t *address = NULL;
1839 ip_details_t *current_ip_details = NULL;
1840 ip_details_t *details = NULL;
1842 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1844 if (!details || vam->current_sw_if_index >= vec_len (details)
1845 || !details[vam->current_sw_if_index].present)
1847 errmsg ("ip address details arrived but not stored");
1848 errmsg ("ip_dump should be called first");
1852 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1854 #define addresses (current_ip_details->addr)
1856 vec_validate_init_empty (addresses, vec_len (addresses),
1857 empty_ip_address_details);
1859 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1861 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1862 address->prefix_length = mp->prefix_length;
1866 static void vl_api_ip_address_details_t_handler_json
1867 (vl_api_ip_address_details_t * mp)
1869 vat_main_t *vam = &vat_main;
1870 vat_json_node_t *node = NULL;
1871 struct in6_addr ip6;
1874 if (VAT_JSON_ARRAY != vam->json_tree.type)
1876 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1877 vat_json_init_array (&vam->json_tree);
1879 node = vat_json_array_add (&vam->json_tree);
1881 vat_json_init_object (node);
1884 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1885 vat_json_object_add_ip6 (node, "ip", ip6);
1889 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1890 vat_json_object_add_ip4 (node, "ip", ip4);
1892 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1896 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1898 vat_main_t *vam = &vat_main;
1899 static ip_details_t empty_ip_details = { 0 };
1900 ip_details_t *ip = NULL;
1901 u32 sw_if_index = ~0;
1903 sw_if_index = ntohl (mp->sw_if_index);
1905 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1906 sw_if_index, empty_ip_details);
1908 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1915 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1917 vat_main_t *vam = &vat_main;
1919 if (VAT_JSON_ARRAY != vam->json_tree.type)
1921 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1922 vat_json_init_array (&vam->json_tree);
1924 vat_json_array_add_uint (&vam->json_tree,
1925 clib_net_to_host_u32 (mp->sw_if_index));
1928 static void vl_api_map_domain_details_t_handler_json
1929 (vl_api_map_domain_details_t * mp)
1931 vat_json_node_t *node = NULL;
1932 vat_main_t *vam = &vat_main;
1933 struct in6_addr ip6;
1936 if (VAT_JSON_ARRAY != vam->json_tree.type)
1938 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1939 vat_json_init_array (&vam->json_tree);
1942 node = vat_json_array_add (&vam->json_tree);
1943 vat_json_init_object (node);
1945 vat_json_object_add_uint (node, "domain_index",
1946 clib_net_to_host_u32 (mp->domain_index));
1947 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1948 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1949 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1950 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1951 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1952 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1953 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1954 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1955 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1956 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1957 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1958 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1959 vat_json_object_add_uint (node, "flags", mp->flags);
1960 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1961 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1964 static void vl_api_map_domain_details_t_handler
1965 (vl_api_map_domain_details_t * mp)
1967 vat_main_t *vam = &vat_main;
1969 if (mp->is_translation)
1972 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
1973 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1974 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1975 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1976 clib_net_to_host_u32 (mp->domain_index));
1981 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
1982 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1983 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1984 format_ip6_address, mp->ip6_src,
1985 clib_net_to_host_u32 (mp->domain_index));
1987 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
1988 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1989 mp->is_translation ? "map-t" : "");
1992 static void vl_api_map_rule_details_t_handler_json
1993 (vl_api_map_rule_details_t * mp)
1995 struct in6_addr ip6;
1996 vat_json_node_t *node = NULL;
1997 vat_main_t *vam = &vat_main;
1999 if (VAT_JSON_ARRAY != vam->json_tree.type)
2001 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2002 vat_json_init_array (&vam->json_tree);
2005 node = vat_json_array_add (&vam->json_tree);
2006 vat_json_init_object (node);
2008 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2009 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2010 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2014 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2016 vat_main_t *vam = &vat_main;
2017 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2018 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2022 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2024 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2025 "router_addr %U host_mac %U",
2026 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2027 format_ip4_address, &mp->host_address,
2028 format_ip4_address, &mp->router_address,
2029 format_ethernet_address, mp->host_mac);
2032 static void vl_api_dhcp_compl_event_t_handler_json
2033 (vl_api_dhcp_compl_event_t * mp)
2035 /* JSON output not supported */
2039 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2042 vat_main_t *vam = &vat_main;
2043 static u64 default_counter = 0;
2045 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2047 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2048 sw_if_index, default_counter);
2049 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2053 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2054 interface_counter_t counter)
2056 vat_main_t *vam = &vat_main;
2057 static interface_counter_t default_counter = { 0, };
2059 vec_validate_init_empty (vam->combined_interface_counters,
2060 vnet_counter_type, NULL);
2061 vec_validate_init_empty (vam->combined_interface_counters
2062 [vnet_counter_type], sw_if_index, default_counter);
2063 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2066 static void vl_api_vnet_interface_simple_counters_t_handler
2067 (vl_api_vnet_interface_simple_counters_t * mp)
2072 static void vl_api_vnet_interface_combined_counters_t_handler
2073 (vl_api_vnet_interface_combined_counters_t * mp)
2078 static void vl_api_vnet_interface_simple_counters_t_handler_json
2079 (vl_api_vnet_interface_simple_counters_t * mp)
2084 u32 first_sw_if_index;
2087 count = ntohl (mp->count);
2088 first_sw_if_index = ntohl (mp->first_sw_if_index);
2090 v_packets = (u64 *) & mp->data;
2091 for (i = 0; i < count; i++)
2093 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2094 set_simple_interface_counter (mp->vnet_counter_type,
2095 first_sw_if_index + i, packets);
2100 static void vl_api_vnet_interface_combined_counters_t_handler_json
2101 (vl_api_vnet_interface_combined_counters_t * mp)
2103 interface_counter_t counter;
2105 u32 first_sw_if_index;
2109 count = ntohl (mp->count);
2110 first_sw_if_index = ntohl (mp->first_sw_if_index);
2112 v = (vlib_counter_t *) & mp->data;
2113 for (i = 0; i < count; i++)
2116 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2118 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2119 set_combined_interface_counter (mp->vnet_counter_type,
2120 first_sw_if_index + i, counter);
2126 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2128 vat_main_t *vam = &vat_main;
2131 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2133 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2142 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2144 vat_main_t *vam = &vat_main;
2147 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2149 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2157 static void vl_api_vnet_ip4_fib_counters_t_handler
2158 (vl_api_vnet_ip4_fib_counters_t * mp)
2163 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2164 (vl_api_vnet_ip4_fib_counters_t * mp)
2166 vat_main_t *vam = &vat_main;
2167 vl_api_ip4_fib_counter_t *v;
2168 ip4_fib_counter_t *counter;
2175 vrf_id = ntohl (mp->vrf_id);
2176 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2177 if (~0 == vrf_index)
2179 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2180 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2181 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2182 vec_validate (vam->ip4_fib_counters, vrf_index);
2183 vam->ip4_fib_counters[vrf_index] = NULL;
2186 vec_free (vam->ip4_fib_counters[vrf_index]);
2187 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2188 count = ntohl (mp->count);
2189 for (i = 0; i < count; i++)
2191 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2192 counter = &vam->ip4_fib_counters[vrf_index][i];
2193 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2194 counter->address = ip4;
2195 counter->address_length = v->address_length;
2196 counter->packets = clib_net_to_host_u64 (v->packets);
2197 counter->bytes = clib_net_to_host_u64 (v->bytes);
2202 static void vl_api_vnet_ip4_nbr_counters_t_handler
2203 (vl_api_vnet_ip4_nbr_counters_t * mp)
2208 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2209 (vl_api_vnet_ip4_nbr_counters_t * mp)
2211 vat_main_t *vam = &vat_main;
2212 vl_api_ip4_nbr_counter_t *v;
2213 ip4_nbr_counter_t *counter;
2218 sw_if_index = ntohl (mp->sw_if_index);
2219 count = ntohl (mp->count);
2220 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2223 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2225 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2226 for (i = 0; i < count; i++)
2228 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2229 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2230 counter->address.s_addr = v->address;
2231 counter->packets = clib_net_to_host_u64 (v->packets);
2232 counter->bytes = clib_net_to_host_u64 (v->bytes);
2233 counter->linkt = v->link_type;
2238 static void vl_api_vnet_ip6_fib_counters_t_handler
2239 (vl_api_vnet_ip6_fib_counters_t * mp)
2244 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2245 (vl_api_vnet_ip6_fib_counters_t * mp)
2247 vat_main_t *vam = &vat_main;
2248 vl_api_ip6_fib_counter_t *v;
2249 ip6_fib_counter_t *counter;
2250 struct in6_addr ip6;
2256 vrf_id = ntohl (mp->vrf_id);
2257 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2258 if (~0 == vrf_index)
2260 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2261 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2262 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2263 vec_validate (vam->ip6_fib_counters, vrf_index);
2264 vam->ip6_fib_counters[vrf_index] = NULL;
2267 vec_free (vam->ip6_fib_counters[vrf_index]);
2268 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2269 count = ntohl (mp->count);
2270 for (i = 0; i < count; i++)
2272 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2273 counter = &vam->ip6_fib_counters[vrf_index][i];
2274 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2275 counter->address = ip6;
2276 counter->address_length = v->address_length;
2277 counter->packets = clib_net_to_host_u64 (v->packets);
2278 counter->bytes = clib_net_to_host_u64 (v->bytes);
2283 static void vl_api_vnet_ip6_nbr_counters_t_handler
2284 (vl_api_vnet_ip6_nbr_counters_t * mp)
2289 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2290 (vl_api_vnet_ip6_nbr_counters_t * mp)
2292 vat_main_t *vam = &vat_main;
2293 vl_api_ip6_nbr_counter_t *v;
2294 ip6_nbr_counter_t *counter;
2295 struct in6_addr ip6;
2300 sw_if_index = ntohl (mp->sw_if_index);
2301 count = ntohl (mp->count);
2302 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2305 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2307 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2308 for (i = 0; i < count; i++)
2310 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2311 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2312 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2313 counter->address = ip6;
2314 counter->packets = clib_net_to_host_u64 (v->packets);
2315 counter->bytes = clib_net_to_host_u64 (v->bytes);
2320 static void vl_api_get_first_msg_id_reply_t_handler
2321 (vl_api_get_first_msg_id_reply_t * mp)
2323 vat_main_t *vam = &vat_main;
2324 i32 retval = ntohl (mp->retval);
2326 if (vam->async_mode)
2328 vam->async_errors += (retval < 0);
2332 vam->retval = retval;
2333 vam->result_ready = 1;
2337 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2341 static void vl_api_get_first_msg_id_reply_t_handler_json
2342 (vl_api_get_first_msg_id_reply_t * mp)
2344 vat_main_t *vam = &vat_main;
2345 vat_json_node_t node;
2347 vat_json_init_object (&node);
2348 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2349 vat_json_object_add_uint (&node, "first_msg_id",
2350 (uint) ntohs (mp->first_msg_id));
2352 vat_json_print (vam->ofp, &node);
2353 vat_json_free (&node);
2355 vam->retval = ntohl (mp->retval);
2356 vam->result_ready = 1;
2359 static void vl_api_get_node_graph_reply_t_handler
2360 (vl_api_get_node_graph_reply_t * mp)
2362 vat_main_t *vam = &vat_main;
2363 api_main_t *am = &api_main;
2364 i32 retval = ntohl (mp->retval);
2365 u8 *pvt_copy, *reply;
2370 if (vam->async_mode)
2372 vam->async_errors += (retval < 0);
2376 vam->retval = retval;
2377 vam->result_ready = 1;
2380 /* "Should never happen..." */
2384 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2385 pvt_copy = vec_dup (reply);
2387 /* Toss the shared-memory original... */
2388 pthread_mutex_lock (&am->vlib_rp->mutex);
2389 oldheap = svm_push_data_heap (am->vlib_rp);
2393 svm_pop_heap (oldheap);
2394 pthread_mutex_unlock (&am->vlib_rp->mutex);
2396 if (vam->graph_nodes)
2398 hash_free (vam->graph_node_index_by_name);
2400 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2402 node = vam->graph_nodes[i];
2403 vec_free (node->name);
2404 vec_free (node->next_nodes);
2407 vec_free (vam->graph_nodes);
2410 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2411 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2412 vec_free (pvt_copy);
2414 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2416 node = vam->graph_nodes[i];
2417 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2421 static void vl_api_get_node_graph_reply_t_handler_json
2422 (vl_api_get_node_graph_reply_t * mp)
2424 vat_main_t *vam = &vat_main;
2425 api_main_t *am = &api_main;
2427 vat_json_node_t node;
2430 /* $$$$ make this real? */
2431 vat_json_init_object (&node);
2432 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2433 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2435 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2437 /* Toss the shared-memory original... */
2438 pthread_mutex_lock (&am->vlib_rp->mutex);
2439 oldheap = svm_push_data_heap (am->vlib_rp);
2443 svm_pop_heap (oldheap);
2444 pthread_mutex_unlock (&am->vlib_rp->mutex);
2446 vat_json_print (vam->ofp, &node);
2447 vat_json_free (&node);
2449 vam->retval = ntohl (mp->retval);
2450 vam->result_ready = 1;
2454 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2456 vat_main_t *vam = &vat_main;
2461 s = format (s, "%=16d%=16d%=16d",
2462 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2466 s = format (s, "%=16U%=16d%=16d",
2467 mp->is_ipv6 ? format_ip6_address :
2469 mp->ip_address, mp->priority, mp->weight);
2472 print (vam->ofp, "%v", s);
2477 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2479 vat_main_t *vam = &vat_main;
2480 vat_json_node_t *node = NULL;
2481 struct in6_addr ip6;
2484 if (VAT_JSON_ARRAY != vam->json_tree.type)
2486 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2487 vat_json_init_array (&vam->json_tree);
2489 node = vat_json_array_add (&vam->json_tree);
2490 vat_json_init_object (node);
2492 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2493 vat_json_object_add_uint (node, "priority", mp->priority);
2494 vat_json_object_add_uint (node, "weight", mp->weight);
2497 vat_json_object_add_uint (node, "sw_if_index",
2498 clib_net_to_host_u32 (mp->sw_if_index));
2503 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2504 vat_json_object_add_ip6 (node, "address", ip6);
2508 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2509 vat_json_object_add_ip4 (node, "address", ip4);
2515 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2518 vat_main_t *vam = &vat_main;
2521 ls_name = format (0, "%s", mp->ls_name);
2523 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2529 vl_api_one_locator_set_details_t_handler_json
2530 (vl_api_one_locator_set_details_t * mp)
2532 vat_main_t *vam = &vat_main;
2533 vat_json_node_t *node = 0;
2536 ls_name = format (0, "%s", mp->ls_name);
2537 vec_add1 (ls_name, 0);
2539 if (VAT_JSON_ARRAY != vam->json_tree.type)
2541 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2542 vat_json_init_array (&vam->json_tree);
2544 node = vat_json_array_add (&vam->json_tree);
2546 vat_json_init_object (node);
2547 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2548 vat_json_object_add_uint (node, "ls_index",
2549 clib_net_to_host_u32 (mp->ls_index));
2554 format_lisp_flat_eid (u8 * s, va_list * args)
2556 u32 type = va_arg (*args, u32);
2557 u8 *eid = va_arg (*args, u8 *);
2558 u32 eid_len = va_arg (*args, u32);
2563 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2565 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2567 return format (s, "%U", format_ethernet_address, eid);
2573 format_lisp_eid_vat (u8 * s, va_list * args)
2575 u32 type = va_arg (*args, u32);
2576 u8 *eid = va_arg (*args, u8 *);
2577 u32 eid_len = va_arg (*args, u32);
2578 u8 *seid = va_arg (*args, u8 *);
2579 u32 seid_len = va_arg (*args, u32);
2580 u32 is_src_dst = va_arg (*args, u32);
2583 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2585 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2591 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2593 vat_main_t *vam = &vat_main;
2594 u8 *s = 0, *eid = 0;
2596 if (~0 == mp->locator_set_index)
2597 s = format (0, "action: %d", mp->action);
2599 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2601 eid = format (0, "%U", format_lisp_eid_vat,
2605 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2608 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2609 clib_net_to_host_u32 (mp->vni),
2611 mp->is_local ? "local" : "remote",
2612 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2613 clib_net_to_host_u16 (mp->key_id), mp->key);
2620 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2623 vat_main_t *vam = &vat_main;
2624 vat_json_node_t *node = 0;
2627 if (VAT_JSON_ARRAY != vam->json_tree.type)
2629 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2630 vat_json_init_array (&vam->json_tree);
2632 node = vat_json_array_add (&vam->json_tree);
2634 vat_json_init_object (node);
2635 if (~0 == mp->locator_set_index)
2636 vat_json_object_add_uint (node, "action", mp->action);
2638 vat_json_object_add_uint (node, "locator_set_index",
2639 clib_net_to_host_u32 (mp->locator_set_index));
2641 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2642 eid = format (0, "%U", format_lisp_eid_vat,
2646 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2648 vat_json_object_add_string_copy (node, "eid", eid);
2649 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2650 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2651 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2655 vat_json_object_add_uint (node, "key_id",
2656 clib_net_to_host_u16 (mp->key_id));
2657 vat_json_object_add_string_copy (node, "key", mp->key);
2663 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
2665 vat_main_t *vam = &vat_main;
2666 u8 *seid = 0, *deid = 0;
2667 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2669 deid = format (0, "%U", format_lisp_eid_vat,
2670 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2672 seid = format (0, "%U", format_lisp_eid_vat,
2673 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2679 format_ip_address_fcn = format_ip4_address;
2681 format_ip_address_fcn = format_ip6_address;
2684 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
2685 clib_net_to_host_u32 (mp->vni),
2687 format_ip_address_fcn, mp->lloc,
2688 format_ip_address_fcn, mp->rloc,
2689 clib_net_to_host_u32 (mp->pkt_count),
2690 clib_net_to_host_u32 (mp->bytes));
2697 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
2699 struct in6_addr ip6;
2701 vat_main_t *vam = &vat_main;
2702 vat_json_node_t *node = 0;
2703 u8 *deid = 0, *seid = 0;
2705 if (VAT_JSON_ARRAY != vam->json_tree.type)
2707 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2708 vat_json_init_array (&vam->json_tree);
2710 node = vat_json_array_add (&vam->json_tree);
2712 vat_json_init_object (node);
2713 deid = format (0, "%U", format_lisp_eid_vat,
2714 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2716 seid = format (0, "%U", format_lisp_eid_vat,
2717 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2722 vat_json_object_add_string_copy (node, "seid", seid);
2723 vat_json_object_add_string_copy (node, "deid", deid);
2724 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2728 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
2729 vat_json_object_add_ip4 (node, "lloc", ip4);
2730 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
2731 vat_json_object_add_ip4 (node, "rloc", ip4);
2735 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
2736 vat_json_object_add_ip6 (node, "lloc", ip6);
2737 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
2738 vat_json_object_add_ip6 (node, "rloc", ip6);
2740 vat_json_object_add_uint (node, "pkt_count",
2741 clib_net_to_host_u32 (mp->pkt_count));
2742 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
2749 vl_api_one_eid_table_map_details_t_handler
2750 (vl_api_one_eid_table_map_details_t * mp)
2752 vat_main_t *vam = &vat_main;
2754 u8 *line = format (0, "%=10d%=10d",
2755 clib_net_to_host_u32 (mp->vni),
2756 clib_net_to_host_u32 (mp->dp_table));
2757 print (vam->ofp, "%v", line);
2762 vl_api_one_eid_table_map_details_t_handler_json
2763 (vl_api_one_eid_table_map_details_t * mp)
2765 vat_main_t *vam = &vat_main;
2766 vat_json_node_t *node = NULL;
2768 if (VAT_JSON_ARRAY != vam->json_tree.type)
2770 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2771 vat_json_init_array (&vam->json_tree);
2773 node = vat_json_array_add (&vam->json_tree);
2774 vat_json_init_object (node);
2775 vat_json_object_add_uint (node, "dp_table",
2776 clib_net_to_host_u32 (mp->dp_table));
2777 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2781 vl_api_one_eid_table_vni_details_t_handler
2782 (vl_api_one_eid_table_vni_details_t * mp)
2784 vat_main_t *vam = &vat_main;
2786 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2787 print (vam->ofp, "%v", line);
2792 vl_api_one_eid_table_vni_details_t_handler_json
2793 (vl_api_one_eid_table_vni_details_t * mp)
2795 vat_main_t *vam = &vat_main;
2796 vat_json_node_t *node = NULL;
2798 if (VAT_JSON_ARRAY != vam->json_tree.type)
2800 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2801 vat_json_init_array (&vam->json_tree);
2803 node = vat_json_array_add (&vam->json_tree);
2804 vat_json_init_object (node);
2805 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2809 vl_api_show_one_map_register_state_reply_t_handler
2810 (vl_api_show_one_map_register_state_reply_t * mp)
2812 vat_main_t *vam = &vat_main;
2813 int retval = clib_net_to_host_u32 (mp->retval);
2815 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2817 vam->retval = retval;
2818 vam->result_ready = 1;
2822 vl_api_show_one_map_register_state_reply_t_handler_json
2823 (vl_api_show_one_map_register_state_reply_t * mp)
2825 vat_main_t *vam = &vat_main;
2826 vat_json_node_t _node, *node = &_node;
2827 int retval = clib_net_to_host_u32 (mp->retval);
2829 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2831 vat_json_init_object (node);
2832 vat_json_object_add_string_copy (node, "state", s);
2834 vat_json_print (vam->ofp, node);
2835 vat_json_free (node);
2837 vam->retval = retval;
2838 vam->result_ready = 1;
2843 vl_api_show_one_rloc_probe_state_reply_t_handler
2844 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2846 vat_main_t *vam = &vat_main;
2847 int retval = clib_net_to_host_u32 (mp->retval);
2852 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2854 vam->retval = retval;
2855 vam->result_ready = 1;
2859 vl_api_show_one_rloc_probe_state_reply_t_handler_json
2860 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2862 vat_main_t *vam = &vat_main;
2863 vat_json_node_t _node, *node = &_node;
2864 int retval = clib_net_to_host_u32 (mp->retval);
2866 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2867 vat_json_init_object (node);
2868 vat_json_object_add_string_copy (node, "state", s);
2870 vat_json_print (vam->ofp, node);
2871 vat_json_free (node);
2873 vam->retval = retval;
2874 vam->result_ready = 1;
2879 vl_api_show_one_stats_enable_disable_reply_t_handler
2880 (vl_api_show_one_stats_enable_disable_reply_t * mp)
2882 vat_main_t *vam = &vat_main;
2883 int retval = clib_net_to_host_u32 (mp->retval);
2888 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
2890 vam->retval = retval;
2891 vam->result_ready = 1;
2895 vl_api_show_one_stats_enable_disable_reply_t_handler_json
2896 (vl_api_show_one_stats_enable_disable_reply_t * mp)
2898 vat_main_t *vam = &vat_main;
2899 vat_json_node_t _node, *node = &_node;
2900 int retval = clib_net_to_host_u32 (mp->retval);
2902 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
2903 vat_json_init_object (node);
2904 vat_json_object_add_string_copy (node, "state", s);
2906 vat_json_print (vam->ofp, node);
2907 vat_json_free (node);
2909 vam->retval = retval;
2910 vam->result_ready = 1;
2915 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
2917 e->dp_table = clib_net_to_host_u32 (e->dp_table);
2918 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
2919 e->vni = clib_net_to_host_u32 (e->vni);
2923 gpe_fwd_entries_get_reply_t_net_to_host
2924 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2928 mp->count = clib_net_to_host_u32 (mp->count);
2929 for (i = 0; i < mp->count; i++)
2931 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
2936 format_gpe_encap_mode (u8 * s, va_list * args)
2938 u32 mode = va_arg (*args, u32);
2943 return format (s, "lisp");
2945 return format (s, "vxlan");
2951 vl_api_gpe_get_encap_mode_reply_t_handler
2952 (vl_api_gpe_get_encap_mode_reply_t * mp)
2954 vat_main_t *vam = &vat_main;
2956 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
2957 vam->retval = ntohl (mp->retval);
2958 vam->result_ready = 1;
2962 vl_api_gpe_get_encap_mode_reply_t_handler_json
2963 (vl_api_gpe_get_encap_mode_reply_t * mp)
2965 vat_main_t *vam = &vat_main;
2966 vat_json_node_t node;
2968 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
2969 vec_add1 (encap_mode, 0);
2971 vat_json_init_object (&node);
2972 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
2974 vec_free (encap_mode);
2975 vat_json_print (vam->ofp, &node);
2976 vat_json_free (&node);
2978 vam->retval = ntohl (mp->retval);
2979 vam->result_ready = 1;
2983 vl_api_gpe_fwd_entry_path_details_t_handler
2984 (vl_api_gpe_fwd_entry_path_details_t * mp)
2986 vat_main_t *vam = &vat_main;
2987 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2989 if (mp->lcl_loc.is_ip4)
2990 format_ip_address_fcn = format_ip4_address;
2992 format_ip_address_fcn = format_ip6_address;
2994 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
2995 format_ip_address_fcn, &mp->lcl_loc,
2996 format_ip_address_fcn, &mp->rmt_loc);
3000 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3002 struct in6_addr ip6;
3007 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3008 vat_json_object_add_ip4 (n, "address", ip4);
3012 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3013 vat_json_object_add_ip6 (n, "address", ip6);
3015 vat_json_object_add_uint (n, "weight", loc->weight);
3019 vl_api_gpe_fwd_entry_path_details_t_handler_json
3020 (vl_api_gpe_fwd_entry_path_details_t * mp)
3022 vat_main_t *vam = &vat_main;
3023 vat_json_node_t *node = NULL;
3024 vat_json_node_t *loc_node;
3026 if (VAT_JSON_ARRAY != vam->json_tree.type)
3028 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3029 vat_json_init_array (&vam->json_tree);
3031 node = vat_json_array_add (&vam->json_tree);
3032 vat_json_init_object (node);
3034 loc_node = vat_json_object_add (node, "local_locator");
3035 vat_json_init_object (loc_node);
3036 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3038 loc_node = vat_json_object_add (node, "remote_locator");
3039 vat_json_init_object (loc_node);
3040 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3044 vl_api_gpe_fwd_entries_get_reply_t_handler
3045 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3047 vat_main_t *vam = &vat_main;
3049 int retval = clib_net_to_host_u32 (mp->retval);
3050 vl_api_gpe_fwd_entry_t *e;
3055 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3057 for (i = 0; i < mp->count; i++)
3059 e = &mp->entries[i];
3060 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3061 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3062 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3066 vam->retval = retval;
3067 vam->result_ready = 1;
3071 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3072 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3075 vat_main_t *vam = &vat_main;
3076 vat_json_node_t *e = 0, root;
3078 int retval = clib_net_to_host_u32 (mp->retval);
3079 vl_api_gpe_fwd_entry_t *fwd;
3084 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3085 vat_json_init_array (&root);
3087 for (i = 0; i < mp->count; i++)
3089 e = vat_json_array_add (&root);
3090 fwd = &mp->entries[i];
3092 vat_json_init_object (e);
3093 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3094 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3095 vat_json_object_add_int (e, "vni", fwd->vni);
3096 vat_json_object_add_int (e, "action", fwd->action);
3098 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3099 fwd->leid_prefix_len);
3101 vat_json_object_add_string_copy (e, "leid", s);
3104 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3105 fwd->reid_prefix_len);
3107 vat_json_object_add_string_copy (e, "reid", s);
3111 vat_json_print (vam->ofp, &root);
3112 vat_json_free (&root);
3115 vam->retval = retval;
3116 vam->result_ready = 1;
3120 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3121 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3123 vat_main_t *vam = &vat_main;
3125 int retval = clib_net_to_host_u32 (mp->retval);
3130 n = clib_net_to_host_u32 (mp->count);
3132 for (i = 0; i < n; i++)
3133 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3136 vam->retval = retval;
3137 vam->result_ready = 1;
3141 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3142 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3144 vat_main_t *vam = &vat_main;
3145 vat_json_node_t root;
3147 int retval = clib_net_to_host_u32 (mp->retval);
3152 n = clib_net_to_host_u32 (mp->count);
3153 vat_json_init_array (&root);
3155 for (i = 0; i < n; i++)
3156 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3158 vat_json_print (vam->ofp, &root);
3159 vat_json_free (&root);
3162 vam->retval = retval;
3163 vam->result_ready = 1;
3167 vl_api_one_adjacencies_get_reply_t_handler
3168 (vl_api_one_adjacencies_get_reply_t * mp)
3170 vat_main_t *vam = &vat_main;
3172 int retval = clib_net_to_host_u32 (mp->retval);
3173 vl_api_one_adjacency_t *a;
3178 n = clib_net_to_host_u32 (mp->count);
3180 for (i = 0; i < n; i++)
3182 a = &mp->adjacencies[i];
3183 print (vam->ofp, "%U %40U",
3184 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3185 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3189 vam->retval = retval;
3190 vam->result_ready = 1;
3194 vl_api_one_adjacencies_get_reply_t_handler_json
3195 (vl_api_one_adjacencies_get_reply_t * mp)
3198 vat_main_t *vam = &vat_main;
3199 vat_json_node_t *e = 0, root;
3201 int retval = clib_net_to_host_u32 (mp->retval);
3202 vl_api_one_adjacency_t *a;
3207 n = clib_net_to_host_u32 (mp->count);
3208 vat_json_init_array (&root);
3210 for (i = 0; i < n; i++)
3212 e = vat_json_array_add (&root);
3213 a = &mp->adjacencies[i];
3215 vat_json_init_object (e);
3216 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3217 a->leid_prefix_len);
3219 vat_json_object_add_string_copy (e, "leid", s);
3222 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3223 a->reid_prefix_len);
3225 vat_json_object_add_string_copy (e, "reid", s);
3229 vat_json_print (vam->ofp, &root);
3230 vat_json_free (&root);
3233 vam->retval = retval;
3234 vam->result_ready = 1;
3238 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3240 vat_main_t *vam = &vat_main;
3242 print (vam->ofp, "%=20U",
3243 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3248 vl_api_one_map_server_details_t_handler_json
3249 (vl_api_one_map_server_details_t * mp)
3251 vat_main_t *vam = &vat_main;
3252 vat_json_node_t *node = NULL;
3253 struct in6_addr ip6;
3256 if (VAT_JSON_ARRAY != vam->json_tree.type)
3258 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3259 vat_json_init_array (&vam->json_tree);
3261 node = vat_json_array_add (&vam->json_tree);
3263 vat_json_init_object (node);
3266 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3267 vat_json_object_add_ip6 (node, "map-server", ip6);
3271 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3272 vat_json_object_add_ip4 (node, "map-server", ip4);
3277 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3280 vat_main_t *vam = &vat_main;
3282 print (vam->ofp, "%=20U",
3283 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3288 vl_api_one_map_resolver_details_t_handler_json
3289 (vl_api_one_map_resolver_details_t * mp)
3291 vat_main_t *vam = &vat_main;
3292 vat_json_node_t *node = NULL;
3293 struct in6_addr ip6;
3296 if (VAT_JSON_ARRAY != vam->json_tree.type)
3298 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3299 vat_json_init_array (&vam->json_tree);
3301 node = vat_json_array_add (&vam->json_tree);
3303 vat_json_init_object (node);
3306 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3307 vat_json_object_add_ip6 (node, "map resolver", ip6);
3311 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3312 vat_json_object_add_ip4 (node, "map resolver", ip4);
3317 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3319 vat_main_t *vam = &vat_main;
3320 i32 retval = ntohl (mp->retval);
3324 print (vam->ofp, "feature: %s\ngpe: %s",
3325 mp->feature_status ? "enabled" : "disabled",
3326 mp->gpe_status ? "enabled" : "disabled");
3329 vam->retval = retval;
3330 vam->result_ready = 1;
3334 vl_api_show_one_status_reply_t_handler_json
3335 (vl_api_show_one_status_reply_t * mp)
3337 vat_main_t *vam = &vat_main;
3338 vat_json_node_t node;
3339 u8 *gpe_status = NULL;
3340 u8 *feature_status = NULL;
3342 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3343 feature_status = format (0, "%s",
3344 mp->feature_status ? "enabled" : "disabled");
3345 vec_add1 (gpe_status, 0);
3346 vec_add1 (feature_status, 0);
3348 vat_json_init_object (&node);
3349 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3350 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3352 vec_free (gpe_status);
3353 vec_free (feature_status);
3355 vat_json_print (vam->ofp, &node);
3356 vat_json_free (&node);
3358 vam->retval = ntohl (mp->retval);
3359 vam->result_ready = 1;
3363 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3364 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3366 vat_main_t *vam = &vat_main;
3367 i32 retval = ntohl (mp->retval);
3371 print (vam->ofp, "%=20s", mp->locator_set_name);
3374 vam->retval = retval;
3375 vam->result_ready = 1;
3379 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3380 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3382 vat_main_t *vam = &vat_main;
3383 vat_json_node_t *node = NULL;
3385 if (VAT_JSON_ARRAY != vam->json_tree.type)
3387 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3388 vat_json_init_array (&vam->json_tree);
3390 node = vat_json_array_add (&vam->json_tree);
3392 vat_json_init_object (node);
3393 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3395 vat_json_print (vam->ofp, node);
3396 vat_json_free (node);
3398 vam->retval = ntohl (mp->retval);
3399 vam->result_ready = 1;
3403 format_lisp_map_request_mode (u8 * s, va_list * args)
3405 u32 mode = va_arg (*args, u32);
3410 return format (0, "dst-only");
3412 return format (0, "src-dst");
3418 vl_api_show_one_map_request_mode_reply_t_handler
3419 (vl_api_show_one_map_request_mode_reply_t * mp)
3421 vat_main_t *vam = &vat_main;
3422 i32 retval = ntohl (mp->retval);
3426 u32 mode = mp->mode;
3427 print (vam->ofp, "map_request_mode: %U",
3428 format_lisp_map_request_mode, mode);
3431 vam->retval = retval;
3432 vam->result_ready = 1;
3436 vl_api_show_one_map_request_mode_reply_t_handler_json
3437 (vl_api_show_one_map_request_mode_reply_t * mp)
3439 vat_main_t *vam = &vat_main;
3440 vat_json_node_t node;
3445 s = format (0, "%U", format_lisp_map_request_mode, mode);
3448 vat_json_init_object (&node);
3449 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3450 vat_json_print (vam->ofp, &node);
3451 vat_json_free (&node);
3454 vam->retval = ntohl (mp->retval);
3455 vam->result_ready = 1;
3459 vl_api_show_one_use_petr_reply_t_handler
3460 (vl_api_show_one_use_petr_reply_t * mp)
3462 vat_main_t *vam = &vat_main;
3463 i32 retval = ntohl (mp->retval);
3467 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
3470 print (vam->ofp, "Proxy-ETR address; %U",
3471 mp->is_ip4 ? format_ip4_address : format_ip6_address,
3476 vam->retval = retval;
3477 vam->result_ready = 1;
3481 vl_api_show_one_use_petr_reply_t_handler_json
3482 (vl_api_show_one_use_petr_reply_t * mp)
3484 vat_main_t *vam = &vat_main;
3485 vat_json_node_t node;
3488 struct in6_addr ip6;
3490 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3491 vec_add1 (status, 0);
3493 vat_json_init_object (&node);
3494 vat_json_object_add_string_copy (&node, "status", status);
3499 clib_memcpy (&ip6, mp->address, sizeof (ip6));
3500 vat_json_object_add_ip6 (&node, "address", ip6);
3504 clib_memcpy (&ip4, mp->address, sizeof (ip4));
3505 vat_json_object_add_ip4 (&node, "address", ip4);
3511 vat_json_print (vam->ofp, &node);
3512 vat_json_free (&node);
3514 vam->retval = ntohl (mp->retval);
3515 vam->result_ready = 1;
3519 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3521 vat_main_t *vam = &vat_main;
3522 i32 retval = ntohl (mp->retval);
3526 print (vam->ofp, "%-20s%-16s",
3527 mp->status ? "enabled" : "disabled",
3528 mp->status ? (char *) mp->locator_set_name : "");
3531 vam->retval = retval;
3532 vam->result_ready = 1;
3536 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3538 vat_main_t *vam = &vat_main;
3539 vat_json_node_t node;
3542 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3543 vec_add1 (status, 0);
3545 vat_json_init_object (&node);
3546 vat_json_object_add_string_copy (&node, "status", status);
3549 vat_json_object_add_string_copy (&node, "locator_set",
3550 mp->locator_set_name);
3555 vat_json_print (vam->ofp, &node);
3556 vat_json_free (&node);
3558 vam->retval = ntohl (mp->retval);
3559 vam->result_ready = 1;
3563 format_policer_type (u8 * s, va_list * va)
3565 u32 i = va_arg (*va, u32);
3567 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3568 s = format (s, "1r2c");
3569 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3570 s = format (s, "1r3c");
3571 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3572 s = format (s, "2r3c-2698");
3573 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3574 s = format (s, "2r3c-4115");
3575 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3576 s = format (s, "2r3c-mef5cf1");
3578 s = format (s, "ILLEGAL");
3583 format_policer_rate_type (u8 * s, va_list * va)
3585 u32 i = va_arg (*va, u32);
3587 if (i == SSE2_QOS_RATE_KBPS)
3588 s = format (s, "kbps");
3589 else if (i == SSE2_QOS_RATE_PPS)
3590 s = format (s, "pps");
3592 s = format (s, "ILLEGAL");
3597 format_policer_round_type (u8 * s, va_list * va)
3599 u32 i = va_arg (*va, u32);
3601 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3602 s = format (s, "closest");
3603 else if (i == SSE2_QOS_ROUND_TO_UP)
3604 s = format (s, "up");
3605 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3606 s = format (s, "down");
3608 s = format (s, "ILLEGAL");
3613 format_policer_action_type (u8 * s, va_list * va)
3615 u32 i = va_arg (*va, u32);
3617 if (i == SSE2_QOS_ACTION_DROP)
3618 s = format (s, "drop");
3619 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3620 s = format (s, "transmit");
3621 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3622 s = format (s, "mark-and-transmit");
3624 s = format (s, "ILLEGAL");
3629 format_dscp (u8 * s, va_list * va)
3631 u32 i = va_arg (*va, u32);
3636 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3640 return format (s, "ILLEGAL");
3642 s = format (s, "%s", t);
3647 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3649 vat_main_t *vam = &vat_main;
3650 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3652 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3653 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3655 conform_dscp_str = format (0, "");
3657 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3658 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3660 exceed_dscp_str = format (0, "");
3662 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3663 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3665 violate_dscp_str = format (0, "");
3667 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3668 "rate type %U, round type %U, %s rate, %s color-aware, "
3669 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3670 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3671 "conform action %U%s, exceed action %U%s, violate action %U%s",
3673 format_policer_type, mp->type,
3676 clib_net_to_host_u64 (mp->cb),
3677 clib_net_to_host_u64 (mp->eb),
3678 format_policer_rate_type, mp->rate_type,
3679 format_policer_round_type, mp->round_type,
3680 mp->single_rate ? "single" : "dual",
3681 mp->color_aware ? "is" : "not",
3682 ntohl (mp->cir_tokens_per_period),
3683 ntohl (mp->pir_tokens_per_period),
3685 ntohl (mp->current_limit),
3686 ntohl (mp->current_bucket),
3687 ntohl (mp->extended_limit),
3688 ntohl (mp->extended_bucket),
3689 clib_net_to_host_u64 (mp->last_update_time),
3690 format_policer_action_type, mp->conform_action_type,
3692 format_policer_action_type, mp->exceed_action_type,
3694 format_policer_action_type, mp->violate_action_type,
3697 vec_free (conform_dscp_str);
3698 vec_free (exceed_dscp_str);
3699 vec_free (violate_dscp_str);
3702 static void vl_api_policer_details_t_handler_json
3703 (vl_api_policer_details_t * mp)
3705 vat_main_t *vam = &vat_main;
3706 vat_json_node_t *node;
3707 u8 *rate_type_str, *round_type_str, *type_str;
3708 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3710 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3712 format (0, "%U", format_policer_round_type, mp->round_type);
3713 type_str = format (0, "%U", format_policer_type, mp->type);
3714 conform_action_str = format (0, "%U", format_policer_action_type,
3715 mp->conform_action_type);
3716 exceed_action_str = format (0, "%U", format_policer_action_type,
3717 mp->exceed_action_type);
3718 violate_action_str = format (0, "%U", format_policer_action_type,
3719 mp->violate_action_type);
3721 if (VAT_JSON_ARRAY != vam->json_tree.type)
3723 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3724 vat_json_init_array (&vam->json_tree);
3726 node = vat_json_array_add (&vam->json_tree);
3728 vat_json_init_object (node);
3729 vat_json_object_add_string_copy (node, "name", mp->name);
3730 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3731 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3732 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
3733 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
3734 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3735 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3736 vat_json_object_add_string_copy (node, "type", type_str);
3737 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3738 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3739 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3740 vat_json_object_add_uint (node, "cir_tokens_per_period",
3741 ntohl (mp->cir_tokens_per_period));
3742 vat_json_object_add_uint (node, "eir_tokens_per_period",
3743 ntohl (mp->pir_tokens_per_period));
3744 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3745 vat_json_object_add_uint (node, "current_bucket",
3746 ntohl (mp->current_bucket));
3747 vat_json_object_add_uint (node, "extended_limit",
3748 ntohl (mp->extended_limit));
3749 vat_json_object_add_uint (node, "extended_bucket",
3750 ntohl (mp->extended_bucket));
3751 vat_json_object_add_uint (node, "last_update_time",
3752 ntohl (mp->last_update_time));
3753 vat_json_object_add_string_copy (node, "conform_action",
3754 conform_action_str);
3755 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3757 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3758 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3759 vec_free (dscp_str);
3761 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3762 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3764 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3765 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3766 vec_free (dscp_str);
3768 vat_json_object_add_string_copy (node, "violate_action",
3769 violate_action_str);
3770 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3772 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3773 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3774 vec_free (dscp_str);
3777 vec_free (rate_type_str);
3778 vec_free (round_type_str);
3779 vec_free (type_str);
3780 vec_free (conform_action_str);
3781 vec_free (exceed_action_str);
3782 vec_free (violate_action_str);
3786 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3789 vat_main_t *vam = &vat_main;
3790 int i, count = ntohl (mp->count);
3793 print (vam->ofp, "classify table ids (%d) : ", count);
3794 for (i = 0; i < count; i++)
3796 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3797 print (vam->ofp, (i < count - 1) ? "," : "");
3799 vam->retval = ntohl (mp->retval);
3800 vam->result_ready = 1;
3804 vl_api_classify_table_ids_reply_t_handler_json
3805 (vl_api_classify_table_ids_reply_t * mp)
3807 vat_main_t *vam = &vat_main;
3808 int i, count = ntohl (mp->count);
3812 vat_json_node_t node;
3814 vat_json_init_object (&node);
3815 for (i = 0; i < count; i++)
3817 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3819 vat_json_print (vam->ofp, &node);
3820 vat_json_free (&node);
3822 vam->retval = ntohl (mp->retval);
3823 vam->result_ready = 1;
3827 vl_api_classify_table_by_interface_reply_t_handler
3828 (vl_api_classify_table_by_interface_reply_t * mp)
3830 vat_main_t *vam = &vat_main;
3833 table_id = ntohl (mp->l2_table_id);
3835 print (vam->ofp, "l2 table id : %d", table_id);
3837 print (vam->ofp, "l2 table id : No input ACL tables configured");
3838 table_id = ntohl (mp->ip4_table_id);
3840 print (vam->ofp, "ip4 table id : %d", table_id);
3842 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3843 table_id = ntohl (mp->ip6_table_id);
3845 print (vam->ofp, "ip6 table id : %d", table_id);
3847 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3848 vam->retval = ntohl (mp->retval);
3849 vam->result_ready = 1;
3853 vl_api_classify_table_by_interface_reply_t_handler_json
3854 (vl_api_classify_table_by_interface_reply_t * mp)
3856 vat_main_t *vam = &vat_main;
3857 vat_json_node_t node;
3859 vat_json_init_object (&node);
3861 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3862 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3863 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3865 vat_json_print (vam->ofp, &node);
3866 vat_json_free (&node);
3868 vam->retval = ntohl (mp->retval);
3869 vam->result_ready = 1;
3872 static void vl_api_policer_add_del_reply_t_handler
3873 (vl_api_policer_add_del_reply_t * mp)
3875 vat_main_t *vam = &vat_main;
3876 i32 retval = ntohl (mp->retval);
3877 if (vam->async_mode)
3879 vam->async_errors += (retval < 0);
3883 vam->retval = retval;
3884 vam->result_ready = 1;
3885 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3887 * Note: this is just barely thread-safe, depends on
3888 * the main thread spinning waiting for an answer...
3890 errmsg ("policer index %d", ntohl (mp->policer_index));
3894 static void vl_api_policer_add_del_reply_t_handler_json
3895 (vl_api_policer_add_del_reply_t * mp)
3897 vat_main_t *vam = &vat_main;
3898 vat_json_node_t node;
3900 vat_json_init_object (&node);
3901 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3902 vat_json_object_add_uint (&node, "policer_index",
3903 ntohl (mp->policer_index));
3905 vat_json_print (vam->ofp, &node);
3906 vat_json_free (&node);
3908 vam->retval = ntohl (mp->retval);
3909 vam->result_ready = 1;
3912 /* Format hex dump. */
3914 format_hex_bytes (u8 * s, va_list * va)
3916 u8 *bytes = va_arg (*va, u8 *);
3917 int n_bytes = va_arg (*va, int);
3920 /* Print short or long form depending on byte count. */
3921 uword short_form = n_bytes <= 32;
3922 uword indent = format_get_indent (s);
3927 for (i = 0; i < n_bytes; i++)
3929 if (!short_form && (i % 32) == 0)
3930 s = format (s, "%08x: ", i);
3931 s = format (s, "%02x", bytes[i]);
3932 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3933 s = format (s, "\n%U", format_white_space, indent);
3940 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3943 vat_main_t *vam = &vat_main;
3944 i32 retval = ntohl (mp->retval);
3947 print (vam->ofp, "classify table info :");
3948 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3949 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3950 ntohl (mp->miss_next_index));
3951 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3952 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3953 ntohl (mp->match_n_vectors));
3954 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3955 ntohl (mp->mask_length));
3957 vam->retval = retval;
3958 vam->result_ready = 1;
3962 vl_api_classify_table_info_reply_t_handler_json
3963 (vl_api_classify_table_info_reply_t * mp)
3965 vat_main_t *vam = &vat_main;
3966 vat_json_node_t node;
3968 i32 retval = ntohl (mp->retval);
3971 vat_json_init_object (&node);
3973 vat_json_object_add_int (&node, "sessions",
3974 ntohl (mp->active_sessions));
3975 vat_json_object_add_int (&node, "nexttbl",
3976 ntohl (mp->next_table_index));
3977 vat_json_object_add_int (&node, "nextnode",
3978 ntohl (mp->miss_next_index));
3979 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3980 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3981 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3982 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3983 ntohl (mp->mask_length), 0);
3984 vat_json_object_add_string_copy (&node, "mask", s);
3986 vat_json_print (vam->ofp, &node);
3987 vat_json_free (&node);
3989 vam->retval = ntohl (mp->retval);
3990 vam->result_ready = 1;
3994 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3997 vat_main_t *vam = &vat_main;
3999 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4000 ntohl (mp->hit_next_index), ntohl (mp->advance),
4001 ntohl (mp->opaque_index));
4002 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4003 ntohl (mp->match_length));
4007 vl_api_classify_session_details_t_handler_json
4008 (vl_api_classify_session_details_t * mp)
4010 vat_main_t *vam = &vat_main;
4011 vat_json_node_t *node = NULL;
4013 if (VAT_JSON_ARRAY != vam->json_tree.type)
4015 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4016 vat_json_init_array (&vam->json_tree);
4018 node = vat_json_array_add (&vam->json_tree);
4020 vat_json_init_object (node);
4021 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4022 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4023 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4025 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4027 vat_json_object_add_string_copy (node, "match", s);
4030 static void vl_api_pg_create_interface_reply_t_handler
4031 (vl_api_pg_create_interface_reply_t * mp)
4033 vat_main_t *vam = &vat_main;
4035 vam->retval = ntohl (mp->retval);
4036 vam->result_ready = 1;
4039 static void vl_api_pg_create_interface_reply_t_handler_json
4040 (vl_api_pg_create_interface_reply_t * mp)
4042 vat_main_t *vam = &vat_main;
4043 vat_json_node_t node;
4045 i32 retval = ntohl (mp->retval);
4048 vat_json_init_object (&node);
4050 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4052 vat_json_print (vam->ofp, &node);
4053 vat_json_free (&node);
4055 vam->retval = ntohl (mp->retval);
4056 vam->result_ready = 1;
4059 static void vl_api_policer_classify_details_t_handler
4060 (vl_api_policer_classify_details_t * mp)
4062 vat_main_t *vam = &vat_main;
4064 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4065 ntohl (mp->table_index));
4068 static void vl_api_policer_classify_details_t_handler_json
4069 (vl_api_policer_classify_details_t * mp)
4071 vat_main_t *vam = &vat_main;
4072 vat_json_node_t *node;
4074 if (VAT_JSON_ARRAY != vam->json_tree.type)
4076 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4077 vat_json_init_array (&vam->json_tree);
4079 node = vat_json_array_add (&vam->json_tree);
4081 vat_json_init_object (node);
4082 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4083 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4086 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4087 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4089 vat_main_t *vam = &vat_main;
4090 i32 retval = ntohl (mp->retval);
4091 if (vam->async_mode)
4093 vam->async_errors += (retval < 0);
4097 vam->retval = retval;
4098 vam->sw_if_index = ntohl (mp->sw_if_index);
4099 vam->result_ready = 1;
4103 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4104 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4106 vat_main_t *vam = &vat_main;
4107 vat_json_node_t node;
4109 vat_json_init_object (&node);
4110 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4111 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4113 vat_json_print (vam->ofp, &node);
4114 vat_json_free (&node);
4116 vam->retval = ntohl (mp->retval);
4117 vam->result_ready = 1;
4120 static void vl_api_flow_classify_details_t_handler
4121 (vl_api_flow_classify_details_t * mp)
4123 vat_main_t *vam = &vat_main;
4125 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4126 ntohl (mp->table_index));
4129 static void vl_api_flow_classify_details_t_handler_json
4130 (vl_api_flow_classify_details_t * mp)
4132 vat_main_t *vam = &vat_main;
4133 vat_json_node_t *node;
4135 if (VAT_JSON_ARRAY != vam->json_tree.type)
4137 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4138 vat_json_init_array (&vam->json_tree);
4140 node = vat_json_array_add (&vam->json_tree);
4142 vat_json_init_object (node);
4143 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4144 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4147 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
4148 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
4149 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
4150 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
4151 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4152 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4153 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4154 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4155 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4156 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4157 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4158 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4159 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4160 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4163 * Generate boilerplate reply handlers, which
4164 * dig the return value out of the xxx_reply_t API message,
4165 * stick it into vam->retval, and set vam->result_ready
4167 * Could also do this by pointing N message decode slots at
4168 * a single function, but that could break in subtle ways.
4171 #define foreach_standard_reply_retval_handler \
4172 _(sw_interface_set_flags_reply) \
4173 _(sw_interface_add_del_address_reply) \
4174 _(sw_interface_set_table_reply) \
4175 _(sw_interface_set_mpls_enable_reply) \
4176 _(sw_interface_set_vpath_reply) \
4177 _(sw_interface_set_vxlan_bypass_reply) \
4178 _(sw_interface_set_l2_bridge_reply) \
4179 _(bridge_domain_add_del_reply) \
4180 _(sw_interface_set_l2_xconnect_reply) \
4181 _(l2fib_add_del_reply) \
4182 _(l2fib_flush_int_reply) \
4183 _(l2fib_flush_bd_reply) \
4184 _(ip_add_del_route_reply) \
4185 _(ip_mroute_add_del_reply) \
4186 _(mpls_route_add_del_reply) \
4187 _(mpls_ip_bind_unbind_reply) \
4188 _(proxy_arp_add_del_reply) \
4189 _(proxy_arp_intfc_enable_disable_reply) \
4190 _(sw_interface_set_unnumbered_reply) \
4191 _(ip_neighbor_add_del_reply) \
4192 _(reset_vrf_reply) \
4193 _(oam_add_del_reply) \
4194 _(reset_fib_reply) \
4195 _(dhcp_proxy_config_reply) \
4196 _(dhcp_proxy_set_vss_reply) \
4197 _(dhcp_client_config_reply) \
4198 _(set_ip_flow_hash_reply) \
4199 _(sw_interface_ip6_enable_disable_reply) \
4200 _(sw_interface_ip6_set_link_local_address_reply) \
4201 _(ip6nd_proxy_add_del_reply) \
4202 _(sw_interface_ip6nd_ra_prefix_reply) \
4203 _(sw_interface_ip6nd_ra_config_reply) \
4204 _(set_arp_neighbor_limit_reply) \
4205 _(l2_patch_add_del_reply) \
4206 _(sr_policy_add_reply) \
4207 _(sr_policy_mod_reply) \
4208 _(sr_policy_del_reply) \
4209 _(sr_localsid_add_del_reply) \
4210 _(sr_steering_add_del_reply) \
4211 _(classify_add_del_session_reply) \
4212 _(classify_set_interface_ip_table_reply) \
4213 _(classify_set_interface_l2_tables_reply) \
4214 _(l2tpv3_set_tunnel_cookies_reply) \
4215 _(l2tpv3_interface_enable_disable_reply) \
4216 _(l2tpv3_set_lookup_key_reply) \
4217 _(l2_fib_clear_table_reply) \
4218 _(l2_interface_efp_filter_reply) \
4219 _(l2_interface_vlan_tag_rewrite_reply) \
4220 _(modify_vhost_user_if_reply) \
4221 _(delete_vhost_user_if_reply) \
4222 _(want_ip4_arp_events_reply) \
4223 _(want_ip6_nd_events_reply) \
4224 _(input_acl_set_interface_reply) \
4225 _(ipsec_spd_add_del_reply) \
4226 _(ipsec_interface_add_del_spd_reply) \
4227 _(ipsec_spd_add_del_entry_reply) \
4228 _(ipsec_sad_add_del_entry_reply) \
4229 _(ipsec_sa_set_key_reply) \
4230 _(ipsec_tunnel_if_add_del_reply) \
4231 _(ikev2_profile_add_del_reply) \
4232 _(ikev2_profile_set_auth_reply) \
4233 _(ikev2_profile_set_id_reply) \
4234 _(ikev2_profile_set_ts_reply) \
4235 _(ikev2_set_local_key_reply) \
4236 _(ikev2_set_responder_reply) \
4237 _(ikev2_set_ike_transforms_reply) \
4238 _(ikev2_set_esp_transforms_reply) \
4239 _(ikev2_set_sa_lifetime_reply) \
4240 _(ikev2_initiate_sa_init_reply) \
4241 _(ikev2_initiate_del_ike_sa_reply) \
4242 _(ikev2_initiate_del_child_sa_reply) \
4243 _(ikev2_initiate_rekey_child_sa_reply) \
4244 _(delete_loopback_reply) \
4245 _(bd_ip_mac_add_del_reply) \
4246 _(map_del_domain_reply) \
4247 _(map_add_del_rule_reply) \
4248 _(want_interface_events_reply) \
4249 _(want_stats_reply) \
4250 _(cop_interface_enable_disable_reply) \
4251 _(cop_whitelist_enable_disable_reply) \
4252 _(sw_interface_clear_stats_reply) \
4253 _(ioam_enable_reply) \
4254 _(ioam_disable_reply) \
4255 _(one_add_del_locator_reply) \
4256 _(one_add_del_local_eid_reply) \
4257 _(one_add_del_remote_mapping_reply) \
4258 _(one_add_del_adjacency_reply) \
4259 _(one_add_del_map_resolver_reply) \
4260 _(one_add_del_map_server_reply) \
4261 _(one_enable_disable_reply) \
4262 _(one_rloc_probe_enable_disable_reply) \
4263 _(one_map_register_enable_disable_reply) \
4264 _(one_pitr_set_locator_set_reply) \
4265 _(one_map_request_mode_reply) \
4266 _(one_add_del_map_request_itr_rlocs_reply) \
4267 _(one_eid_table_add_del_map_reply) \
4268 _(one_use_petr_reply) \
4269 _(one_stats_enable_disable_reply) \
4270 _(one_stats_flush_reply) \
4271 _(gpe_add_del_fwd_entry_reply) \
4272 _(gpe_enable_disable_reply) \
4273 _(gpe_set_encap_mode_reply) \
4274 _(gpe_add_del_iface_reply) \
4275 _(vxlan_gpe_add_del_tunnel_reply) \
4276 _(af_packet_delete_reply) \
4277 _(policer_classify_set_interface_reply) \
4278 _(netmap_create_reply) \
4279 _(netmap_delete_reply) \
4280 _(set_ipfix_exporter_reply) \
4281 _(set_ipfix_classify_stream_reply) \
4282 _(ipfix_classify_table_add_del_reply) \
4283 _(flow_classify_set_interface_reply) \
4284 _(sw_interface_span_enable_disable_reply) \
4285 _(pg_capture_reply) \
4286 _(pg_enable_disable_reply) \
4287 _(ip_source_and_port_range_check_add_del_reply) \
4288 _(ip_source_and_port_range_check_interface_add_del_reply)\
4289 _(delete_subif_reply) \
4290 _(l2_interface_pbb_tag_rewrite_reply) \
4292 _(feature_enable_disable_reply) \
4293 _(sw_interface_tag_add_del_reply) \
4294 _(sw_interface_set_mtu_reply)
4297 static void vl_api_##n##_t_handler \
4298 (vl_api_##n##_t * mp) \
4300 vat_main_t * vam = &vat_main; \
4301 i32 retval = ntohl(mp->retval); \
4302 if (vam->async_mode) { \
4303 vam->async_errors += (retval < 0); \
4305 vam->retval = retval; \
4306 vam->result_ready = 1; \
4309 foreach_standard_reply_retval_handler;
4313 static void vl_api_##n##_t_handler_json \
4314 (vl_api_##n##_t * mp) \
4316 vat_main_t * vam = &vat_main; \
4317 vat_json_node_t node; \
4318 vat_json_init_object(&node); \
4319 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4320 vat_json_print(vam->ofp, &node); \
4321 vam->retval = ntohl(mp->retval); \
4322 vam->result_ready = 1; \
4324 foreach_standard_reply_retval_handler;
4328 * Table of message reply handlers, must include boilerplate handlers
4332 #define foreach_vpe_api_reply_msg \
4333 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4334 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4335 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4336 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4337 _(CONTROL_PING_REPLY, control_ping_reply) \
4338 _(CLI_REPLY, cli_reply) \
4339 _(CLI_INBAND_REPLY, cli_inband_reply) \
4340 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4341 sw_interface_add_del_address_reply) \
4342 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4343 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4344 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4345 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4346 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4347 sw_interface_set_l2_xconnect_reply) \
4348 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4349 sw_interface_set_l2_bridge_reply) \
4350 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4351 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4352 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
4353 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4354 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
4355 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
4356 _(L2_FLAGS_REPLY, l2_flags_reply) \
4357 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4358 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4359 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4360 _(TAP_DELETE_REPLY, tap_delete_reply) \
4361 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4362 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4363 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4364 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4365 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4366 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4367 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4368 proxy_arp_intfc_enable_disable_reply) \
4369 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4370 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4371 sw_interface_set_unnumbered_reply) \
4372 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4373 _(RESET_VRF_REPLY, reset_vrf_reply) \
4374 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4375 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4376 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4377 _(RESET_FIB_REPLY, reset_fib_reply) \
4378 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4379 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4380 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4381 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4382 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4383 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4384 sw_interface_ip6_enable_disable_reply) \
4385 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4386 sw_interface_ip6_set_link_local_address_reply) \
4387 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
4388 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
4389 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4390 sw_interface_ip6nd_ra_prefix_reply) \
4391 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4392 sw_interface_ip6nd_ra_config_reply) \
4393 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4394 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4395 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4396 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4397 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4398 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4399 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4400 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4401 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4402 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4403 classify_set_interface_ip_table_reply) \
4404 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4405 classify_set_interface_l2_tables_reply) \
4406 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4407 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4408 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4409 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4410 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4411 l2tpv3_interface_enable_disable_reply) \
4412 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4413 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4414 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4415 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4416 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4417 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4418 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4419 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4420 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4421 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4422 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4423 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4424 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4425 _(SHOW_VERSION_REPLY, show_version_reply) \
4426 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
4427 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4428 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4429 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4430 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4431 _(IP4_ARP_EVENT, ip4_arp_event) \
4432 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4433 _(IP6_ND_EVENT, ip6_nd_event) \
4434 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4435 _(IP_ADDRESS_DETAILS, ip_address_details) \
4436 _(IP_DETAILS, ip_details) \
4437 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4438 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4439 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4440 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4441 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4442 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
4443 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4444 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4445 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4446 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4447 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4448 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4449 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4450 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4451 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4452 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4453 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4454 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4455 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4456 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4457 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4458 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4459 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4460 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4461 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4462 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4463 _(MAP_RULE_DETAILS, map_rule_details) \
4464 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4465 _(WANT_STATS_REPLY, want_stats_reply) \
4466 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4467 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4468 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4469 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4470 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4471 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4472 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4473 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4474 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4475 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4476 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4477 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4478 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4479 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4480 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4481 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4482 one_map_register_enable_disable_reply) \
4483 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4484 one_rloc_probe_enable_disable_reply) \
4485 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4486 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
4487 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4488 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4489 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4490 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4491 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4492 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4493 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4494 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4495 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4496 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4497 _(ONE_STATS_DETAILS, one_stats_details) \
4498 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
4499 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
4500 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
4501 show_one_stats_enable_disable_reply) \
4502 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4503 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4504 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4505 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4506 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4507 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
4508 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4509 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4510 gpe_fwd_entry_path_details) \
4511 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4512 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4513 one_add_del_map_request_itr_rlocs_reply) \
4514 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4515 one_get_map_request_itr_rlocs_reply) \
4516 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4517 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
4518 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4519 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4520 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4521 show_one_map_register_state_reply) \
4522 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4523 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4524 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4525 _(POLICER_DETAILS, policer_details) \
4526 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4527 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4528 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4529 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4530 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4531 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4532 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4533 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4534 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4535 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4536 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4537 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4538 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4539 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4540 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4541 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4542 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4543 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4544 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4545 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4546 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4547 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4548 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4549 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4550 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4551 ip_source_and_port_range_check_add_del_reply) \
4552 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4553 ip_source_and_port_range_check_interface_add_del_reply) \
4554 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4555 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4556 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4557 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4558 _(PUNT_REPLY, punt_reply) \
4559 _(IP_FIB_DETAILS, ip_fib_details) \
4560 _(IP6_FIB_DETAILS, ip6_fib_details) \
4561 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4562 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4563 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4564 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4565 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4566 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4568 #define foreach_standalone_reply_msg \
4569 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4570 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
4571 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
4572 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4573 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4574 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4575 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
4584 #define STR_VTR_OP_CASE(op) \
4585 case L2_VTR_ ## op: \
4589 str_vtr_op (u32 vtr_op)
4593 STR_VTR_OP_CASE (DISABLED);
4594 STR_VTR_OP_CASE (PUSH_1);
4595 STR_VTR_OP_CASE (PUSH_2);
4596 STR_VTR_OP_CASE (POP_1);
4597 STR_VTR_OP_CASE (POP_2);
4598 STR_VTR_OP_CASE (TRANSLATE_1_1);
4599 STR_VTR_OP_CASE (TRANSLATE_1_2);
4600 STR_VTR_OP_CASE (TRANSLATE_2_1);
4601 STR_VTR_OP_CASE (TRANSLATE_2_2);
4608 dump_sub_interface_table (vat_main_t * vam)
4610 const sw_interface_subif_t *sub = NULL;
4612 if (vam->json_output)
4615 ("JSON output supported only for VPE API calls and dump_stats_table");
4620 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4621 "Interface", "sw_if_index",
4622 "sub id", "dot1ad", "tags", "outer id",
4623 "inner id", "exact", "default", "outer any", "inner any");
4625 vec_foreach (sub, vam->sw_if_subif_table)
4628 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4629 sub->interface_name,
4631 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4632 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4633 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4634 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4635 if (sub->vtr_op != L2_VTR_DISABLED)
4638 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4639 "tag1: %d tag2: %d ]",
4640 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4641 sub->vtr_tag1, sub->vtr_tag2);
4649 name_sort_cmp (void *a1, void *a2)
4651 name_sort_t *n1 = a1;
4652 name_sort_t *n2 = a2;
4654 return strcmp ((char *) n1->name, (char *) n2->name);
4658 dump_interface_table (vat_main_t * vam)
4661 name_sort_t *nses = 0, *ns;
4663 if (vam->json_output)
4666 ("JSON output supported only for VPE API calls and dump_stats_table");
4671 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4673 vec_add2 (nses, ns, 1);
4674 ns->name = (u8 *)(p->key);
4675 ns->value = (u32) p->value[0];
4679 vec_sort_with_function (nses, name_sort_cmp);
4681 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4682 vec_foreach (ns, nses)
4684 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4691 dump_ip_table (vat_main_t * vam, int is_ipv6)
4693 const ip_details_t *det = NULL;
4694 const ip_address_details_t *address = NULL;
4697 print (vam->ofp, "%-12s", "sw_if_index");
4699 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4706 print (vam->ofp, "%-12d", i);
4707 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4712 vec_foreach (address, det->addr)
4716 is_ipv6 ? format_ip6_address : format_ip4_address,
4717 address->ip, address->prefix_length);
4725 dump_ipv4_table (vat_main_t * vam)
4727 if (vam->json_output)
4730 ("JSON output supported only for VPE API calls and dump_stats_table");
4734 return dump_ip_table (vam, 0);
4738 dump_ipv6_table (vat_main_t * vam)
4740 if (vam->json_output)
4743 ("JSON output supported only for VPE API calls and dump_stats_table");
4747 return dump_ip_table (vam, 1);
4751 counter_type_to_str (u8 counter_type, u8 is_combined)
4755 switch (counter_type)
4757 case VNET_INTERFACE_COUNTER_DROP:
4759 case VNET_INTERFACE_COUNTER_PUNT:
4761 case VNET_INTERFACE_COUNTER_IP4:
4763 case VNET_INTERFACE_COUNTER_IP6:
4765 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4767 case VNET_INTERFACE_COUNTER_RX_MISS:
4769 case VNET_INTERFACE_COUNTER_RX_ERROR:
4771 case VNET_INTERFACE_COUNTER_TX_ERROR:
4774 return "INVALID-COUNTER-TYPE";
4779 switch (counter_type)
4781 case VNET_INTERFACE_COUNTER_RX:
4783 case VNET_INTERFACE_COUNTER_TX:
4786 return "INVALID-COUNTER-TYPE";
4792 dump_stats_table (vat_main_t * vam)
4794 vat_json_node_t node;
4795 vat_json_node_t *msg_array;
4796 vat_json_node_t *msg;
4797 vat_json_node_t *counter_array;
4798 vat_json_node_t *counter;
4799 interface_counter_t c;
4801 ip4_fib_counter_t *c4;
4802 ip6_fib_counter_t *c6;
4803 ip4_nbr_counter_t *n4;
4804 ip6_nbr_counter_t *n6;
4807 if (!vam->json_output)
4809 clib_warning ("dump_stats_table supported only in JSON format");
4813 vat_json_init_object (&node);
4815 /* interface counters */
4816 msg_array = vat_json_object_add (&node, "interface_counters");
4817 vat_json_init_array (msg_array);
4818 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4820 msg = vat_json_array_add (msg_array);
4821 vat_json_init_object (msg);
4822 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4823 (u8 *) counter_type_to_str (i, 0));
4824 vat_json_object_add_int (msg, "is_combined", 0);
4825 counter_array = vat_json_object_add (msg, "data");
4826 vat_json_init_array (counter_array);
4827 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4829 packets = vam->simple_interface_counters[i][j];
4830 vat_json_array_add_uint (counter_array, packets);
4833 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4835 msg = vat_json_array_add (msg_array);
4836 vat_json_init_object (msg);
4837 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4838 (u8 *) counter_type_to_str (i, 1));
4839 vat_json_object_add_int (msg, "is_combined", 1);
4840 counter_array = vat_json_object_add (msg, "data");
4841 vat_json_init_array (counter_array);
4842 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4844 c = vam->combined_interface_counters[i][j];
4845 counter = vat_json_array_add (counter_array);
4846 vat_json_init_object (counter);
4847 vat_json_object_add_uint (counter, "packets", c.packets);
4848 vat_json_object_add_uint (counter, "bytes", c.bytes);
4852 /* ip4 fib counters */
4853 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4854 vat_json_init_array (msg_array);
4855 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4857 msg = vat_json_array_add (msg_array);
4858 vat_json_init_object (msg);
4859 vat_json_object_add_uint (msg, "vrf_id",
4860 vam->ip4_fib_counters_vrf_id_by_index[i]);
4861 counter_array = vat_json_object_add (msg, "c");
4862 vat_json_init_array (counter_array);
4863 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4865 counter = vat_json_array_add (counter_array);
4866 vat_json_init_object (counter);
4867 c4 = &vam->ip4_fib_counters[i][j];
4868 vat_json_object_add_ip4 (counter, "address", c4->address);
4869 vat_json_object_add_uint (counter, "address_length",
4870 c4->address_length);
4871 vat_json_object_add_uint (counter, "packets", c4->packets);
4872 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4876 /* ip6 fib counters */
4877 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4878 vat_json_init_array (msg_array);
4879 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4881 msg = vat_json_array_add (msg_array);
4882 vat_json_init_object (msg);
4883 vat_json_object_add_uint (msg, "vrf_id",
4884 vam->ip6_fib_counters_vrf_id_by_index[i]);
4885 counter_array = vat_json_object_add (msg, "c");
4886 vat_json_init_array (counter_array);
4887 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4889 counter = vat_json_array_add (counter_array);
4890 vat_json_init_object (counter);
4891 c6 = &vam->ip6_fib_counters[i][j];
4892 vat_json_object_add_ip6 (counter, "address", c6->address);
4893 vat_json_object_add_uint (counter, "address_length",
4894 c6->address_length);
4895 vat_json_object_add_uint (counter, "packets", c6->packets);
4896 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4900 /* ip4 nbr counters */
4901 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4902 vat_json_init_array (msg_array);
4903 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4905 msg = vat_json_array_add (msg_array);
4906 vat_json_init_object (msg);
4907 vat_json_object_add_uint (msg, "sw_if_index", i);
4908 counter_array = vat_json_object_add (msg, "c");
4909 vat_json_init_array (counter_array);
4910 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4912 counter = vat_json_array_add (counter_array);
4913 vat_json_init_object (counter);
4914 n4 = &vam->ip4_nbr_counters[i][j];
4915 vat_json_object_add_ip4 (counter, "address", n4->address);
4916 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4917 vat_json_object_add_uint (counter, "packets", n4->packets);
4918 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4922 /* ip6 nbr counters */
4923 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4924 vat_json_init_array (msg_array);
4925 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4927 msg = vat_json_array_add (msg_array);
4928 vat_json_init_object (msg);
4929 vat_json_object_add_uint (msg, "sw_if_index", i);
4930 counter_array = vat_json_object_add (msg, "c");
4931 vat_json_init_array (counter_array);
4932 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4934 counter = vat_json_array_add (counter_array);
4935 vat_json_init_object (counter);
4936 n6 = &vam->ip6_nbr_counters[i][j];
4937 vat_json_object_add_ip6 (counter, "address", n6->address);
4938 vat_json_object_add_uint (counter, "packets", n6->packets);
4939 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4943 vat_json_print (vam->ofp, &node);
4944 vat_json_free (&node);
4950 exec (vat_main_t * vam)
4952 api_main_t *am = &api_main;
4957 unformat_input_t *i = vam->input;
4959 if (vec_len (i->buffer) == 0)
4962 if (vam->exec_mode == 0 && unformat (i, "mode"))
4967 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4977 * Copy cmd into shared memory.
4978 * In order for the CLI command to work, it
4979 * must be a vector ending in \n, not a C-string ending
4982 pthread_mutex_lock (&am->vlib_rp->mutex);
4983 oldheap = svm_push_data_heap (am->vlib_rp);
4985 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4986 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4988 svm_pop_heap (oldheap);
4989 pthread_mutex_unlock (&am->vlib_rp->mutex);
4991 mp->cmd_in_shmem = pointer_to_uword (cmd);
4993 timeout = vat_time_now (vam) + 10.0;
4995 while (vat_time_now (vam) < timeout)
4997 if (vam->result_ready == 1)
5000 if (vam->shmem_result != NULL)
5001 print (vam->ofp, "%s", vam->shmem_result);
5002 pthread_mutex_lock (&am->vlib_rp->mutex);
5003 oldheap = svm_push_data_heap (am->vlib_rp);
5005 free_me = (u8 *) vam->shmem_result;
5008 svm_pop_heap (oldheap);
5009 pthread_mutex_unlock (&am->vlib_rp->mutex);
5017 * Future replacement of exec() that passes CLI buffers directly in
5018 * the API messages instead of an additional shared memory area.
5021 exec_inband (vat_main_t * vam)
5023 vl_api_cli_inband_t *mp;
5024 unformat_input_t *i = vam->input;
5027 if (vec_len (i->buffer) == 0)
5030 if (vam->exec_mode == 0 && unformat (i, "mode"))
5035 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5042 * In order for the CLI command to work, it
5043 * must be a vector ending in \n, not a C-string ending
5046 u32 len = vec_len (vam->input->buffer);
5047 M2 (CLI_INBAND, mp, len);
5048 clib_memcpy (mp->cmd, vam->input->buffer, len);
5049 mp->length = htonl (len);
5052 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
5057 api_create_loopback (vat_main_t * vam)
5059 unformat_input_t *i = vam->input;
5060 vl_api_create_loopback_t *mp;
5061 vl_api_create_loopback_instance_t *mp_lbi;
5064 u8 is_specified = 0;
5065 u32 user_instance = 0;
5068 memset (mac_address, 0, sizeof (mac_address));
5070 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5072 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5074 if (unformat (i, "instance %d", &user_instance))
5082 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5083 mp_lbi->is_specified = is_specified;
5085 mp_lbi->user_instance = htonl (user_instance);
5087 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5092 /* Construct the API message */
5093 M (CREATE_LOOPBACK, mp);
5095 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5104 api_delete_loopback (vat_main_t * vam)
5106 unformat_input_t *i = vam->input;
5107 vl_api_delete_loopback_t *mp;
5108 u32 sw_if_index = ~0;
5111 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5113 if (unformat (i, "sw_if_index %d", &sw_if_index))
5119 if (sw_if_index == ~0)
5121 errmsg ("missing sw_if_index");
5125 /* Construct the API message */
5126 M (DELETE_LOOPBACK, mp);
5127 mp->sw_if_index = ntohl (sw_if_index);
5135 api_want_stats (vat_main_t * vam)
5137 unformat_input_t *i = vam->input;
5138 vl_api_want_stats_t *mp;
5142 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5144 if (unformat (i, "enable"))
5146 else if (unformat (i, "disable"))
5154 errmsg ("missing enable|disable");
5159 mp->enable_disable = enable;
5167 api_want_interface_events (vat_main_t * vam)
5169 unformat_input_t *i = vam->input;
5170 vl_api_want_interface_events_t *mp;
5174 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5176 if (unformat (i, "enable"))
5178 else if (unformat (i, "disable"))
5186 errmsg ("missing enable|disable");
5190 M (WANT_INTERFACE_EVENTS, mp);
5191 mp->enable_disable = enable;
5193 vam->interface_event_display = enable;
5201 /* Note: non-static, called once to set up the initial intfc table */
5203 api_sw_interface_dump (vat_main_t * vam)
5205 vl_api_sw_interface_dump_t *mp;
5206 vl_api_control_ping_t *mp_ping;
5208 name_sort_t *nses = 0, *ns;
5209 sw_interface_subif_t *sub = NULL;
5212 /* Toss the old name table */
5214 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5216 vec_add2 (nses, ns, 1);
5217 ns->name = (u8 *)(p->key);
5218 ns->value = (u32) p->value[0];
5222 hash_free (vam->sw_if_index_by_interface_name);
5224 vec_foreach (ns, nses) vec_free (ns->name);
5228 vec_foreach (sub, vam->sw_if_subif_table)
5230 vec_free (sub->interface_name);
5232 vec_free (vam->sw_if_subif_table);
5234 /* recreate the interface name hash table */
5235 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5237 /* Get list of ethernets */
5238 M (SW_INTERFACE_DUMP, mp);
5239 mp->name_filter_valid = 1;
5240 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
5243 /* and local / loopback interfaces */
5244 M (SW_INTERFACE_DUMP, mp);
5245 mp->name_filter_valid = 1;
5246 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
5249 /* and packet-generator interfaces */
5250 M (SW_INTERFACE_DUMP, mp);
5251 mp->name_filter_valid = 1;
5252 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
5255 /* and vxlan-gpe tunnel interfaces */
5256 M (SW_INTERFACE_DUMP, mp);
5257 mp->name_filter_valid = 1;
5258 strncpy ((char *) mp->name_filter, "vxlan_gpe",
5259 sizeof (mp->name_filter) - 1);
5262 /* and vxlan tunnel interfaces */
5263 M (SW_INTERFACE_DUMP, mp);
5264 mp->name_filter_valid = 1;
5265 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
5268 /* and host (af_packet) interfaces */
5269 M (SW_INTERFACE_DUMP, mp);
5270 mp->name_filter_valid = 1;
5271 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
5274 /* and l2tpv3 tunnel interfaces */
5275 M (SW_INTERFACE_DUMP, mp);
5276 mp->name_filter_valid = 1;
5277 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
5278 sizeof (mp->name_filter) - 1);
5281 /* and GRE tunnel interfaces */
5282 M (SW_INTERFACE_DUMP, mp);
5283 mp->name_filter_valid = 1;
5284 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
5287 /* and LISP-GPE interfaces */
5288 M (SW_INTERFACE_DUMP, mp);
5289 mp->name_filter_valid = 1;
5290 strncpy ((char *) mp->name_filter, "lisp_gpe",
5291 sizeof (mp->name_filter) - 1);
5294 /* and IPSEC tunnel interfaces */
5295 M (SW_INTERFACE_DUMP, mp);
5296 mp->name_filter_valid = 1;
5297 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
5300 /* Use a control ping for synchronization */
5301 M (CONTROL_PING, mp_ping);
5309 api_sw_interface_set_flags (vat_main_t * vam)
5311 unformat_input_t *i = vam->input;
5312 vl_api_sw_interface_set_flags_t *mp;
5314 u8 sw_if_index_set = 0;
5315 u8 admin_up = 0, link_up = 0;
5318 /* Parse args required to build the message */
5319 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5321 if (unformat (i, "admin-up"))
5323 else if (unformat (i, "admin-down"))
5325 else if (unformat (i, "link-up"))
5327 else if (unformat (i, "link-down"))
5330 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5331 sw_if_index_set = 1;
5332 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5333 sw_if_index_set = 1;
5338 if (sw_if_index_set == 0)
5340 errmsg ("missing interface name or sw_if_index");
5344 /* Construct the API message */
5345 M (SW_INTERFACE_SET_FLAGS, mp);
5346 mp->sw_if_index = ntohl (sw_if_index);
5347 mp->admin_up_down = admin_up;
5348 mp->link_up_down = link_up;
5353 /* Wait for a reply, return the good/bad news... */
5359 api_sw_interface_clear_stats (vat_main_t * vam)
5361 unformat_input_t *i = vam->input;
5362 vl_api_sw_interface_clear_stats_t *mp;
5364 u8 sw_if_index_set = 0;
5367 /* Parse args required to build the message */
5368 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5370 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5371 sw_if_index_set = 1;
5372 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5373 sw_if_index_set = 1;
5378 /* Construct the API message */
5379 M (SW_INTERFACE_CLEAR_STATS, mp);
5381 if (sw_if_index_set == 1)
5382 mp->sw_if_index = ntohl (sw_if_index);
5384 mp->sw_if_index = ~0;
5389 /* Wait for a reply, return the good/bad news... */
5395 api_sw_interface_add_del_address (vat_main_t * vam)
5397 unformat_input_t *i = vam->input;
5398 vl_api_sw_interface_add_del_address_t *mp;
5400 u8 sw_if_index_set = 0;
5401 u8 is_add = 1, del_all = 0;
5402 u32 address_length = 0;
5403 u8 v4_address_set = 0;
5404 u8 v6_address_set = 0;
5405 ip4_address_t v4address;
5406 ip6_address_t v6address;
5409 /* Parse args required to build the message */
5410 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5412 if (unformat (i, "del-all"))
5414 else if (unformat (i, "del"))
5417 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5418 sw_if_index_set = 1;
5419 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5420 sw_if_index_set = 1;
5421 else if (unformat (i, "%U/%d",
5422 unformat_ip4_address, &v4address, &address_length))
5424 else if (unformat (i, "%U/%d",
5425 unformat_ip6_address, &v6address, &address_length))
5431 if (sw_if_index_set == 0)
5433 errmsg ("missing interface name or sw_if_index");
5436 if (v4_address_set && v6_address_set)
5438 errmsg ("both v4 and v6 addresses set");
5441 if (!v4_address_set && !v6_address_set && !del_all)
5443 errmsg ("no addresses set");
5447 /* Construct the API message */
5448 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5450 mp->sw_if_index = ntohl (sw_if_index);
5451 mp->is_add = is_add;
5452 mp->del_all = del_all;
5456 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5460 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5462 mp->address_length = address_length;
5467 /* Wait for a reply, return good/bad news */
5473 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5475 unformat_input_t *i = vam->input;
5476 vl_api_sw_interface_set_mpls_enable_t *mp;
5478 u8 sw_if_index_set = 0;
5482 /* Parse args required to build the message */
5483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5485 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5486 sw_if_index_set = 1;
5487 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5488 sw_if_index_set = 1;
5489 else if (unformat (i, "disable"))
5491 else if (unformat (i, "dis"))
5497 if (sw_if_index_set == 0)
5499 errmsg ("missing interface name or sw_if_index");
5503 /* Construct the API message */
5504 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5506 mp->sw_if_index = ntohl (sw_if_index);
5507 mp->enable = enable;
5512 /* Wait for a reply... */
5518 api_sw_interface_set_table (vat_main_t * vam)
5520 unformat_input_t *i = vam->input;
5521 vl_api_sw_interface_set_table_t *mp;
5522 u32 sw_if_index, vrf_id = 0;
5523 u8 sw_if_index_set = 0;
5527 /* Parse args required to build the message */
5528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5530 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5531 sw_if_index_set = 1;
5532 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5533 sw_if_index_set = 1;
5534 else if (unformat (i, "vrf %d", &vrf_id))
5536 else if (unformat (i, "ipv6"))
5542 if (sw_if_index_set == 0)
5544 errmsg ("missing interface name or sw_if_index");
5548 /* Construct the API message */
5549 M (SW_INTERFACE_SET_TABLE, mp);
5551 mp->sw_if_index = ntohl (sw_if_index);
5552 mp->is_ipv6 = is_ipv6;
5553 mp->vrf_id = ntohl (vrf_id);
5558 /* Wait for a reply... */
5563 static void vl_api_sw_interface_get_table_reply_t_handler
5564 (vl_api_sw_interface_get_table_reply_t * mp)
5566 vat_main_t *vam = &vat_main;
5568 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5570 vam->retval = ntohl (mp->retval);
5571 vam->result_ready = 1;
5575 static void vl_api_sw_interface_get_table_reply_t_handler_json
5576 (vl_api_sw_interface_get_table_reply_t * mp)
5578 vat_main_t *vam = &vat_main;
5579 vat_json_node_t node;
5581 vat_json_init_object (&node);
5582 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5583 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5585 vat_json_print (vam->ofp, &node);
5586 vat_json_free (&node);
5588 vam->retval = ntohl (mp->retval);
5589 vam->result_ready = 1;
5593 api_sw_interface_get_table (vat_main_t * vam)
5595 unformat_input_t *i = vam->input;
5596 vl_api_sw_interface_get_table_t *mp;
5598 u8 sw_if_index_set = 0;
5602 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5604 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5605 sw_if_index_set = 1;
5606 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5607 sw_if_index_set = 1;
5608 else if (unformat (i, "ipv6"))
5614 if (sw_if_index_set == 0)
5616 errmsg ("missing interface name or sw_if_index");
5620 M (SW_INTERFACE_GET_TABLE, mp);
5621 mp->sw_if_index = htonl (sw_if_index);
5622 mp->is_ipv6 = is_ipv6;
5630 api_sw_interface_set_vpath (vat_main_t * vam)
5632 unformat_input_t *i = vam->input;
5633 vl_api_sw_interface_set_vpath_t *mp;
5634 u32 sw_if_index = 0;
5635 u8 sw_if_index_set = 0;
5639 /* Parse args required to build the message */
5640 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5642 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5643 sw_if_index_set = 1;
5644 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5645 sw_if_index_set = 1;
5646 else if (unformat (i, "enable"))
5648 else if (unformat (i, "disable"))
5654 if (sw_if_index_set == 0)
5656 errmsg ("missing interface name or sw_if_index");
5660 /* Construct the API message */
5661 M (SW_INTERFACE_SET_VPATH, mp);
5663 mp->sw_if_index = ntohl (sw_if_index);
5664 mp->enable = is_enable;
5669 /* Wait for a reply... */
5675 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5677 unformat_input_t *i = vam->input;
5678 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5679 u32 sw_if_index = 0;
5680 u8 sw_if_index_set = 0;
5685 /* Parse args required to build the message */
5686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5688 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5689 sw_if_index_set = 1;
5690 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5691 sw_if_index_set = 1;
5692 else if (unformat (i, "enable"))
5694 else if (unformat (i, "disable"))
5696 else if (unformat (i, "ip4"))
5698 else if (unformat (i, "ip6"))
5704 if (sw_if_index_set == 0)
5706 errmsg ("missing interface name or sw_if_index");
5710 /* Construct the API message */
5711 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5713 mp->sw_if_index = ntohl (sw_if_index);
5714 mp->enable = is_enable;
5715 mp->is_ipv6 = is_ipv6;
5720 /* Wait for a reply... */
5726 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5728 unformat_input_t *i = vam->input;
5729 vl_api_sw_interface_set_l2_xconnect_t *mp;
5731 u8 rx_sw_if_index_set = 0;
5733 u8 tx_sw_if_index_set = 0;
5737 /* Parse args required to build the message */
5738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5740 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5741 rx_sw_if_index_set = 1;
5742 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5743 tx_sw_if_index_set = 1;
5744 else if (unformat (i, "rx"))
5746 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5748 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5750 rx_sw_if_index_set = 1;
5755 else if (unformat (i, "tx"))
5757 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5759 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5761 tx_sw_if_index_set = 1;
5766 else if (unformat (i, "enable"))
5768 else if (unformat (i, "disable"))
5774 if (rx_sw_if_index_set == 0)
5776 errmsg ("missing rx interface name or rx_sw_if_index");
5780 if (enable && (tx_sw_if_index_set == 0))
5782 errmsg ("missing tx interface name or tx_sw_if_index");
5786 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5788 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5789 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5790 mp->enable = enable;
5798 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5800 unformat_input_t *i = vam->input;
5801 vl_api_sw_interface_set_l2_bridge_t *mp;
5803 u8 rx_sw_if_index_set = 0;
5811 /* Parse args required to build the message */
5812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5814 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5815 rx_sw_if_index_set = 1;
5816 else if (unformat (i, "bd_id %d", &bd_id))
5820 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5821 rx_sw_if_index_set = 1;
5822 else if (unformat (i, "shg %d", &shg))
5824 else if (unformat (i, "bvi"))
5826 else if (unformat (i, "enable"))
5828 else if (unformat (i, "disable"))
5834 if (rx_sw_if_index_set == 0)
5836 errmsg ("missing rx interface name or sw_if_index");
5840 if (enable && (bd_id_set == 0))
5842 errmsg ("missing bridge domain");
5846 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
5848 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5849 mp->bd_id = ntohl (bd_id);
5852 mp->enable = enable;
5860 api_bridge_domain_dump (vat_main_t * vam)
5862 unformat_input_t *i = vam->input;
5863 vl_api_bridge_domain_dump_t *mp;
5864 vl_api_control_ping_t *mp_ping;
5868 /* Parse args required to build the message */
5869 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5871 if (unformat (i, "bd_id %d", &bd_id))
5877 M (BRIDGE_DOMAIN_DUMP, mp);
5878 mp->bd_id = ntohl (bd_id);
5881 /* Use a control ping for synchronization */
5882 M (CONTROL_PING, mp_ping);
5890 api_bridge_domain_add_del (vat_main_t * vam)
5892 unformat_input_t *i = vam->input;
5893 vl_api_bridge_domain_add_del_t *mp;
5896 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5900 /* Parse args required to build the message */
5901 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5903 if (unformat (i, "bd_id %d", &bd_id))
5905 else if (unformat (i, "flood %d", &flood))
5907 else if (unformat (i, "uu-flood %d", &uu_flood))
5909 else if (unformat (i, "forward %d", &forward))
5911 else if (unformat (i, "learn %d", &learn))
5913 else if (unformat (i, "arp-term %d", &arp_term))
5915 else if (unformat (i, "mac-age %d", &mac_age))
5917 else if (unformat (i, "del"))
5920 flood = uu_flood = forward = learn = 0;
5928 errmsg ("missing bridge domain");
5934 errmsg ("mac age must be less than 256 ");
5938 M (BRIDGE_DOMAIN_ADD_DEL, mp);
5940 mp->bd_id = ntohl (bd_id);
5942 mp->uu_flood = uu_flood;
5943 mp->forward = forward;
5945 mp->arp_term = arp_term;
5946 mp->is_add = is_add;
5947 mp->mac_age = (u8) mac_age;
5955 api_l2fib_flush_bd (vat_main_t * vam)
5957 unformat_input_t *i = vam->input;
5958 vl_api_l2fib_flush_bd_t *mp;
5962 /* Parse args required to build the message */
5963 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5965 if (unformat (i, "bd_id %d", &bd_id));
5972 errmsg ("missing bridge domain");
5976 M (L2FIB_FLUSH_BD, mp);
5978 mp->bd_id = htonl (bd_id);
5986 api_l2fib_flush_int (vat_main_t * vam)
5988 unformat_input_t *i = vam->input;
5989 vl_api_l2fib_flush_int_t *mp;
5990 u32 sw_if_index = ~0;
5993 /* Parse args required to build the message */
5994 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5996 if (unformat (i, "sw_if_index %d", &sw_if_index));
5998 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6003 if (sw_if_index == ~0)
6005 errmsg ("missing interface name or sw_if_index");
6009 M (L2FIB_FLUSH_INT, mp);
6011 mp->sw_if_index = ntohl (sw_if_index);
6019 api_l2fib_add_del (vat_main_t * vam)
6021 unformat_input_t *i = vam->input;
6022 vl_api_l2fib_add_del_t *mp;
6028 u32 sw_if_index = ~0;
6029 u8 sw_if_index_set = 0;
6038 /* Parse args required to build the message */
6039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6041 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6043 else if (unformat (i, "bd_id %d", &bd_id))
6045 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6046 sw_if_index_set = 1;
6047 else if (unformat (i, "sw_if"))
6049 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6052 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6053 sw_if_index_set = 1;
6058 else if (unformat (i, "static"))
6060 else if (unformat (i, "filter"))
6065 else if (unformat (i, "bvi"))
6070 else if (unformat (i, "del"))
6072 else if (unformat (i, "count %d", &count))
6080 errmsg ("missing mac address");
6086 errmsg ("missing bridge domain");
6090 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6092 errmsg ("missing interface name or sw_if_index");
6098 /* Turn on async mode */
6099 vam->async_mode = 1;
6100 vam->async_errors = 0;
6101 before = vat_time_now (vam);
6104 for (j = 0; j < count; j++)
6106 M (L2FIB_ADD_DEL, mp);
6109 mp->bd_id = ntohl (bd_id);
6110 mp->is_add = is_add;
6114 mp->sw_if_index = ntohl (sw_if_index);
6115 mp->static_mac = static_mac;
6116 mp->filter_mac = filter_mac;
6117 mp->bvi_mac = bvi_mac;
6119 increment_mac_address (&mac);
6126 vl_api_control_ping_t *mp_ping;
6129 /* Shut off async mode */
6130 vam->async_mode = 0;
6132 M (CONTROL_PING, mp_ping);
6135 timeout = vat_time_now (vam) + 1.0;
6136 while (vat_time_now (vam) < timeout)
6137 if (vam->result_ready == 1)
6142 if (vam->retval == -99)
6145 if (vam->async_errors > 0)
6147 errmsg ("%d asynchronous errors", vam->async_errors);
6150 vam->async_errors = 0;
6151 after = vat_time_now (vam);
6153 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6154 count, after - before, count / (after - before));
6160 /* Wait for a reply... */
6164 /* Return the good/bad news */
6165 return (vam->retval);
6169 api_bridge_domain_set_mac_age (vat_main_t * vam)
6171 unformat_input_t *i = vam->input;
6172 vl_api_bridge_domain_set_mac_age_t *mp;
6177 /* Parse args required to build the message */
6178 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6180 if (unformat (i, "bd_id %d", &bd_id));
6181 else if (unformat (i, "mac-age %d", &mac_age));
6188 errmsg ("missing bridge domain");
6194 errmsg ("mac age must be less than 256 ");
6198 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6200 mp->bd_id = htonl (bd_id);
6201 mp->mac_age = (u8) mac_age;
6209 api_l2_flags (vat_main_t * vam)
6211 unformat_input_t *i = vam->input;
6212 vl_api_l2_flags_t *mp;
6214 u32 feature_bitmap = 0;
6215 u8 sw_if_index_set = 0;
6218 /* Parse args required to build the message */
6219 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6221 if (unformat (i, "sw_if_index %d", &sw_if_index))
6222 sw_if_index_set = 1;
6223 else if (unformat (i, "sw_if"))
6225 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6228 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6229 sw_if_index_set = 1;
6234 else if (unformat (i, "learn"))
6235 feature_bitmap |= L2INPUT_FEAT_LEARN;
6236 else if (unformat (i, "forward"))
6237 feature_bitmap |= L2INPUT_FEAT_FWD;
6238 else if (unformat (i, "flood"))
6239 feature_bitmap |= L2INPUT_FEAT_FLOOD;
6240 else if (unformat (i, "uu-flood"))
6241 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
6246 if (sw_if_index_set == 0)
6248 errmsg ("missing interface name or sw_if_index");
6254 mp->sw_if_index = ntohl (sw_if_index);
6255 mp->feature_bitmap = ntohl (feature_bitmap);
6263 api_bridge_flags (vat_main_t * vam)
6265 unformat_input_t *i = vam->input;
6266 vl_api_bridge_flags_t *mp;
6273 /* Parse args required to build the message */
6274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6276 if (unformat (i, "bd_id %d", &bd_id))
6278 else if (unformat (i, "learn"))
6280 else if (unformat (i, "forward"))
6282 else if (unformat (i, "flood"))
6284 else if (unformat (i, "uu-flood"))
6285 flags |= L2_UU_FLOOD;
6286 else if (unformat (i, "arp-term"))
6287 flags |= L2_ARP_TERM;
6288 else if (unformat (i, "off"))
6290 else if (unformat (i, "disable"))
6298 errmsg ("missing bridge domain");
6302 M (BRIDGE_FLAGS, mp);
6304 mp->bd_id = ntohl (bd_id);
6305 mp->feature_bitmap = ntohl (flags);
6306 mp->is_set = is_set;
6314 api_bd_ip_mac_add_del (vat_main_t * vam)
6316 unformat_input_t *i = vam->input;
6317 vl_api_bd_ip_mac_add_del_t *mp;
6324 ip4_address_t v4addr;
6325 ip6_address_t v6addr;
6330 /* Parse args required to build the message */
6331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6333 if (unformat (i, "bd_id %d", &bd_id))
6337 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6341 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6346 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6350 else if (unformat (i, "del"))
6358 errmsg ("missing bridge domain");
6361 else if (ip_set == 0)
6363 errmsg ("missing IP address");
6366 else if (mac_set == 0)
6368 errmsg ("missing MAC address");
6372 M (BD_IP_MAC_ADD_DEL, mp);
6374 mp->bd_id = ntohl (bd_id);
6375 mp->is_ipv6 = is_ipv6;
6376 mp->is_add = is_add;
6378 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6380 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6381 clib_memcpy (mp->mac_address, macaddr, 6);
6388 api_tap_connect (vat_main_t * vam)
6390 unformat_input_t *i = vam->input;
6391 vl_api_tap_connect_t *mp;
6397 ip4_address_t ip4_address;
6399 int ip4_address_set = 0;
6400 ip6_address_t ip6_address;
6402 int ip6_address_set = 0;
6405 memset (mac_address, 0, sizeof (mac_address));
6407 /* Parse args required to build the message */
6408 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6410 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6414 else if (unformat (i, "random-mac"))
6416 else if (unformat (i, "tapname %s", &tap_name))
6418 else if (unformat (i, "tag %s", &tag))
6420 else if (unformat (i, "address %U/%d",
6421 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6422 ip4_address_set = 1;
6423 else if (unformat (i, "address %U/%d",
6424 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6425 ip6_address_set = 1;
6432 errmsg ("missing tap name");
6435 if (vec_len (tap_name) > 63)
6437 errmsg ("tap name too long");
6440 vec_add1 (tap_name, 0);
6442 if (vec_len (tag) > 63)
6444 errmsg ("tag too long");
6448 /* Construct the API message */
6449 M (TAP_CONNECT, mp);
6451 mp->use_random_mac = random_mac;
6452 clib_memcpy (mp->mac_address, mac_address, 6);
6453 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6455 clib_memcpy (mp->tag, tag, vec_len (tag));
6457 if (ip4_address_set)
6459 mp->ip4_address_set = 1;
6460 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6461 mp->ip4_mask_width = ip4_mask_width;
6463 if (ip6_address_set)
6465 mp->ip6_address_set = 1;
6466 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6467 mp->ip6_mask_width = ip6_mask_width;
6470 vec_free (tap_name);
6476 /* Wait for a reply... */
6482 api_tap_modify (vat_main_t * vam)
6484 unformat_input_t *i = vam->input;
6485 vl_api_tap_modify_t *mp;
6490 u32 sw_if_index = ~0;
6491 u8 sw_if_index_set = 0;
6494 memset (mac_address, 0, sizeof (mac_address));
6496 /* Parse args required to build the message */
6497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6499 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6500 sw_if_index_set = 1;
6501 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6502 sw_if_index_set = 1;
6503 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6507 else if (unformat (i, "random-mac"))
6509 else if (unformat (i, "tapname %s", &tap_name))
6515 if (sw_if_index_set == 0)
6517 errmsg ("missing vpp interface name");
6522 errmsg ("missing tap name");
6525 if (vec_len (tap_name) > 63)
6527 errmsg ("tap name too long");
6529 vec_add1 (tap_name, 0);
6531 /* Construct the API message */
6534 mp->use_random_mac = random_mac;
6535 mp->sw_if_index = ntohl (sw_if_index);
6536 clib_memcpy (mp->mac_address, mac_address, 6);
6537 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6538 vec_free (tap_name);
6543 /* Wait for a reply... */
6549 api_tap_delete (vat_main_t * vam)
6551 unformat_input_t *i = vam->input;
6552 vl_api_tap_delete_t *mp;
6553 u32 sw_if_index = ~0;
6554 u8 sw_if_index_set = 0;
6557 /* Parse args required to build the message */
6558 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6560 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6561 sw_if_index_set = 1;
6562 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6563 sw_if_index_set = 1;
6568 if (sw_if_index_set == 0)
6570 errmsg ("missing vpp interface name");
6574 /* Construct the API message */
6577 mp->sw_if_index = ntohl (sw_if_index);
6582 /* Wait for a reply... */
6588 api_ip_add_del_route (vat_main_t * vam)
6590 unformat_input_t *i = vam->input;
6591 vl_api_ip_add_del_route_t *mp;
6592 u32 sw_if_index = ~0, vrf_id = 0;
6594 u8 is_local = 0, is_drop = 0;
6595 u8 is_unreach = 0, is_prohibit = 0;
6596 u8 create_vrf_if_needed = 0;
6598 u32 next_hop_weight = 1;
6600 u8 is_multipath = 0;
6602 u8 address_length_set = 0;
6603 u32 next_hop_table_id = 0;
6604 u32 resolve_attempts = 0;
6605 u32 dst_address_length = 0;
6606 u8 next_hop_set = 0;
6607 ip4_address_t v4_dst_address, v4_next_hop_address;
6608 ip6_address_t v6_dst_address, v6_next_hop_address;
6612 u32 random_add_del = 0;
6613 u32 *random_vector = 0;
6615 u32 random_seed = 0xdeaddabe;
6616 u32 classify_table_index = ~0;
6618 u8 resolve_host = 0, resolve_attached = 0;
6619 mpls_label_t *next_hop_out_label_stack = NULL;
6620 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6621 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6623 /* Parse args required to build the message */
6624 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6626 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6628 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6630 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6635 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6640 else if (unformat (i, "/%d", &dst_address_length))
6642 address_length_set = 1;
6645 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6646 &v4_next_hop_address))
6650 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6651 &v6_next_hop_address))
6655 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6657 else if (unformat (i, "weight %d", &next_hop_weight))
6659 else if (unformat (i, "drop"))
6663 else if (unformat (i, "null-send-unreach"))
6667 else if (unformat (i, "null-send-prohibit"))
6671 else if (unformat (i, "local"))
6675 else if (unformat (i, "classify %d", &classify_table_index))
6679 else if (unformat (i, "del"))
6681 else if (unformat (i, "add"))
6683 else if (unformat (i, "not-last"))
6685 else if (unformat (i, "resolve-via-host"))
6687 else if (unformat (i, "resolve-via-attached"))
6688 resolve_attached = 1;
6689 else if (unformat (i, "multipath"))
6691 else if (unformat (i, "vrf %d", &vrf_id))
6693 else if (unformat (i, "create-vrf"))
6694 create_vrf_if_needed = 1;
6695 else if (unformat (i, "count %d", &count))
6697 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6699 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6701 else if (unformat (i, "out-label %d", &next_hop_out_label))
6702 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6703 else if (unformat (i, "via-label %d", &next_hop_via_label))
6705 else if (unformat (i, "random"))
6707 else if (unformat (i, "seed %d", &random_seed))
6711 clib_warning ("parse error '%U'", format_unformat_error, i);
6716 if (!next_hop_set && !is_drop && !is_local &&
6717 !is_classify && !is_unreach && !is_prohibit &&
6718 MPLS_LABEL_INVALID == next_hop_via_label)
6721 ("next hop / local / drop / unreach / prohibit / classify not set");
6725 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6727 errmsg ("next hop and next-hop via label set");
6730 if (address_set == 0)
6732 errmsg ("missing addresses");
6736 if (address_length_set == 0)
6738 errmsg ("missing address length");
6742 /* Generate a pile of unique, random routes */
6745 u32 this_random_address;
6746 random_hash = hash_create (count, sizeof (uword));
6748 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6749 for (j = 0; j <= count; j++)
6753 this_random_address = random_u32 (&random_seed);
6754 this_random_address =
6755 clib_host_to_net_u32 (this_random_address);
6757 while (hash_get (random_hash, this_random_address));
6758 vec_add1 (random_vector, this_random_address);
6759 hash_set (random_hash, this_random_address, 1);
6761 hash_free (random_hash);
6762 v4_dst_address.as_u32 = random_vector[0];
6767 /* Turn on async mode */
6768 vam->async_mode = 1;
6769 vam->async_errors = 0;
6770 before = vat_time_now (vam);
6773 for (j = 0; j < count; j++)
6775 /* Construct the API message */
6776 M2 (IP_ADD_DEL_ROUTE, mp,
6777 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6779 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6780 mp->table_id = ntohl (vrf_id);
6781 mp->create_vrf_if_needed = create_vrf_if_needed;
6783 mp->is_add = is_add;
6784 mp->is_drop = is_drop;
6785 mp->is_unreach = is_unreach;
6786 mp->is_prohibit = is_prohibit;
6787 mp->is_ipv6 = is_ipv6;
6788 mp->is_local = is_local;
6789 mp->is_classify = is_classify;
6790 mp->is_multipath = is_multipath;
6791 mp->is_resolve_host = resolve_host;
6792 mp->is_resolve_attached = resolve_attached;
6793 mp->not_last = not_last;
6794 mp->next_hop_weight = next_hop_weight;
6795 mp->dst_address_length = dst_address_length;
6796 mp->next_hop_table_id = ntohl (next_hop_table_id);
6797 mp->classify_table_index = ntohl (classify_table_index);
6798 mp->next_hop_via_label = ntohl (next_hop_via_label);
6799 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6800 if (0 != mp->next_hop_n_out_labels)
6802 memcpy (mp->next_hop_out_label_stack,
6803 next_hop_out_label_stack,
6804 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6805 vec_free (next_hop_out_label_stack);
6810 clib_memcpy (mp->dst_address, &v6_dst_address,
6811 sizeof (v6_dst_address));
6813 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6814 sizeof (v6_next_hop_address));
6815 increment_v6_address (&v6_dst_address);
6819 clib_memcpy (mp->dst_address, &v4_dst_address,
6820 sizeof (v4_dst_address));
6822 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6823 sizeof (v4_next_hop_address));
6825 v4_dst_address.as_u32 = random_vector[j + 1];
6827 increment_v4_address (&v4_dst_address);
6831 /* If we receive SIGTERM, stop now... */
6836 /* When testing multiple add/del ops, use a control-ping to sync */
6839 vl_api_control_ping_t *mp_ping;
6843 /* Shut off async mode */
6844 vam->async_mode = 0;
6846 M (CONTROL_PING, mp_ping);
6849 timeout = vat_time_now (vam) + 1.0;
6850 while (vat_time_now (vam) < timeout)
6851 if (vam->result_ready == 1)
6856 if (vam->retval == -99)
6859 if (vam->async_errors > 0)
6861 errmsg ("%d asynchronous errors", vam->async_errors);
6864 vam->async_errors = 0;
6865 after = vat_time_now (vam);
6867 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6871 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6872 count, after - before, count / (after - before));
6878 /* Wait for a reply... */
6883 /* Return the good/bad news */
6884 return (vam->retval);
6888 api_ip_mroute_add_del (vat_main_t * vam)
6890 unformat_input_t *i = vam->input;
6891 vl_api_ip_mroute_add_del_t *mp;
6892 u32 sw_if_index = ~0, vrf_id = 0;
6895 u8 create_vrf_if_needed = 0;
6898 u32 grp_address_length = 0;
6899 ip4_address_t v4_grp_address, v4_src_address;
6900 ip6_address_t v6_grp_address, v6_src_address;
6901 mfib_itf_flags_t iflags = 0;
6902 mfib_entry_flags_t eflags = 0;
6905 /* Parse args required to build the message */
6906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6908 if (unformat (i, "sw_if_index %d", &sw_if_index))
6910 else if (unformat (i, "%U %U",
6911 unformat_ip4_address, &v4_src_address,
6912 unformat_ip4_address, &v4_grp_address))
6914 grp_address_length = 64;
6918 else if (unformat (i, "%U %U",
6919 unformat_ip6_address, &v6_src_address,
6920 unformat_ip6_address, &v6_grp_address))
6922 grp_address_length = 256;
6926 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
6928 memset (&v4_src_address, 0, sizeof (v4_src_address));
6929 grp_address_length = 32;
6933 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
6935 memset (&v6_src_address, 0, sizeof (v6_src_address));
6936 grp_address_length = 128;
6940 else if (unformat (i, "/%d", &grp_address_length))
6942 else if (unformat (i, "local"))
6946 else if (unformat (i, "del"))
6948 else if (unformat (i, "add"))
6950 else if (unformat (i, "vrf %d", &vrf_id))
6952 else if (unformat (i, "create-vrf"))
6953 create_vrf_if_needed = 1;
6954 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
6956 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
6960 clib_warning ("parse error '%U'", format_unformat_error, i);
6965 if (address_set == 0)
6967 errmsg ("missing addresses\n");
6971 /* Construct the API message */
6972 M (IP_MROUTE_ADD_DEL, mp);
6974 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6975 mp->table_id = ntohl (vrf_id);
6976 mp->create_vrf_if_needed = create_vrf_if_needed;
6978 mp->is_add = is_add;
6979 mp->is_ipv6 = is_ipv6;
6980 mp->is_local = is_local;
6981 mp->itf_flags = ntohl (iflags);
6982 mp->entry_flags = ntohl (eflags);
6983 mp->grp_address_length = grp_address_length;
6984 mp->grp_address_length = ntohs (mp->grp_address_length);
6988 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
6989 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
6993 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
6994 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7000 /* Wait for a reply... */
7006 api_mpls_route_add_del (vat_main_t * vam)
7008 unformat_input_t *i = vam->input;
7009 vl_api_mpls_route_add_del_t *mp;
7010 u32 sw_if_index = ~0, table_id = 0;
7011 u8 create_table_if_needed = 0;
7013 u32 next_hop_weight = 1;
7014 u8 is_multipath = 0;
7015 u32 next_hop_table_id = 0;
7016 u8 next_hop_set = 0;
7017 ip4_address_t v4_next_hop_address = {
7020 ip6_address_t v6_next_hop_address = { {0} };
7024 u32 classify_table_index = ~0;
7026 u8 resolve_host = 0, resolve_attached = 0;
7027 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7028 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7029 mpls_label_t *next_hop_out_label_stack = NULL;
7030 mpls_label_t local_label = MPLS_LABEL_INVALID;
7032 u8 next_hop_proto_is_ip4 = 1;
7034 /* Parse args required to build the message */
7035 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7037 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7039 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7041 else if (unformat (i, "%d", &local_label))
7043 else if (unformat (i, "eos"))
7045 else if (unformat (i, "non-eos"))
7047 else if (unformat (i, "via %U", unformat_ip4_address,
7048 &v4_next_hop_address))
7051 next_hop_proto_is_ip4 = 1;
7053 else if (unformat (i, "via %U", unformat_ip6_address,
7054 &v6_next_hop_address))
7057 next_hop_proto_is_ip4 = 0;
7059 else if (unformat (i, "weight %d", &next_hop_weight))
7061 else if (unformat (i, "create-table"))
7062 create_table_if_needed = 1;
7063 else if (unformat (i, "classify %d", &classify_table_index))
7067 else if (unformat (i, "del"))
7069 else if (unformat (i, "add"))
7071 else if (unformat (i, "resolve-via-host"))
7073 else if (unformat (i, "resolve-via-attached"))
7074 resolve_attached = 1;
7075 else if (unformat (i, "multipath"))
7077 else if (unformat (i, "count %d", &count))
7079 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
7082 next_hop_proto_is_ip4 = 1;
7084 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
7087 next_hop_proto_is_ip4 = 0;
7089 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7091 else if (unformat (i, "via-label %d", &next_hop_via_label))
7093 else if (unformat (i, "out-label %d", &next_hop_out_label))
7094 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7097 clib_warning ("parse error '%U'", format_unformat_error, i);
7102 if (!next_hop_set && !is_classify)
7104 errmsg ("next hop / classify not set");
7108 if (MPLS_LABEL_INVALID == local_label)
7110 errmsg ("missing label");
7116 /* Turn on async mode */
7117 vam->async_mode = 1;
7118 vam->async_errors = 0;
7119 before = vat_time_now (vam);
7122 for (j = 0; j < count; j++)
7124 /* Construct the API message */
7125 M2 (MPLS_ROUTE_ADD_DEL, mp,
7126 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7128 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
7129 mp->mr_table_id = ntohl (table_id);
7130 mp->mr_create_table_if_needed = create_table_if_needed;
7132 mp->mr_is_add = is_add;
7133 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7134 mp->mr_is_classify = is_classify;
7135 mp->mr_is_multipath = is_multipath;
7136 mp->mr_is_resolve_host = resolve_host;
7137 mp->mr_is_resolve_attached = resolve_attached;
7138 mp->mr_next_hop_weight = next_hop_weight;
7139 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
7140 mp->mr_classify_table_index = ntohl (classify_table_index);
7141 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
7142 mp->mr_label = ntohl (local_label);
7143 mp->mr_eos = is_eos;
7145 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7146 if (0 != mp->mr_next_hop_n_out_labels)
7148 memcpy (mp->mr_next_hop_out_label_stack,
7149 next_hop_out_label_stack,
7150 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7151 vec_free (next_hop_out_label_stack);
7156 if (next_hop_proto_is_ip4)
7158 clib_memcpy (mp->mr_next_hop,
7159 &v4_next_hop_address,
7160 sizeof (v4_next_hop_address));
7164 clib_memcpy (mp->mr_next_hop,
7165 &v6_next_hop_address,
7166 sizeof (v6_next_hop_address));
7173 /* If we receive SIGTERM, stop now... */
7178 /* When testing multiple add/del ops, use a control-ping to sync */
7181 vl_api_control_ping_t *mp_ping;
7185 /* Shut off async mode */
7186 vam->async_mode = 0;
7188 M (CONTROL_PING, mp_ping);
7191 timeout = vat_time_now (vam) + 1.0;
7192 while (vat_time_now (vam) < timeout)
7193 if (vam->result_ready == 1)
7198 if (vam->retval == -99)
7201 if (vam->async_errors > 0)
7203 errmsg ("%d asynchronous errors", vam->async_errors);
7206 vam->async_errors = 0;
7207 after = vat_time_now (vam);
7209 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7213 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7214 count, after - before, count / (after - before));
7220 /* Wait for a reply... */
7225 /* Return the good/bad news */
7226 return (vam->retval);
7230 api_mpls_ip_bind_unbind (vat_main_t * vam)
7232 unformat_input_t *i = vam->input;
7233 vl_api_mpls_ip_bind_unbind_t *mp;
7234 u32 ip_table_id = 0;
7235 u8 create_table_if_needed = 0;
7238 ip4_address_t v4_address;
7239 ip6_address_t v6_address;
7242 mpls_label_t local_label = MPLS_LABEL_INVALID;
7245 /* Parse args required to build the message */
7246 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7248 if (unformat (i, "%U/%d", unformat_ip4_address,
7249 &v4_address, &address_length))
7254 else if (unformat (i, "%U/%d", unformat_ip6_address,
7255 &v6_address, &address_length))
7260 else if (unformat (i, "%d", &local_label))
7262 else if (unformat (i, "create-table"))
7263 create_table_if_needed = 1;
7264 else if (unformat (i, "table-id %d", &ip_table_id))
7266 else if (unformat (i, "unbind"))
7268 else if (unformat (i, "bind"))
7272 clib_warning ("parse error '%U'", format_unformat_error, i);
7279 errmsg ("IP addres not set");
7283 if (MPLS_LABEL_INVALID == local_label)
7285 errmsg ("missing label");
7289 /* Construct the API message */
7290 M (MPLS_IP_BIND_UNBIND, mp);
7292 mp->mb_create_table_if_needed = create_table_if_needed;
7293 mp->mb_is_bind = is_bind;
7294 mp->mb_is_ip4 = is_ip4;
7295 mp->mb_ip_table_id = ntohl (ip_table_id);
7296 mp->mb_mpls_table_id = 0;
7297 mp->mb_label = ntohl (local_label);
7298 mp->mb_address_length = address_length;
7301 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7303 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7308 /* Wait for a reply... */
7314 api_proxy_arp_add_del (vat_main_t * vam)
7316 unformat_input_t *i = vam->input;
7317 vl_api_proxy_arp_add_del_t *mp;
7320 ip4_address_t lo, hi;
7324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7326 if (unformat (i, "vrf %d", &vrf_id))
7328 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7329 unformat_ip4_address, &hi))
7331 else if (unformat (i, "del"))
7335 clib_warning ("parse error '%U'", format_unformat_error, i);
7342 errmsg ("address range not set");
7346 M (PROXY_ARP_ADD_DEL, mp);
7348 mp->vrf_id = ntohl (vrf_id);
7349 mp->is_add = is_add;
7350 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7351 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7359 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7361 unformat_input_t *i = vam->input;
7362 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7365 u8 sw_if_index_set = 0;
7368 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7370 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7371 sw_if_index_set = 1;
7372 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7373 sw_if_index_set = 1;
7374 else if (unformat (i, "enable"))
7376 else if (unformat (i, "disable"))
7380 clib_warning ("parse error '%U'", format_unformat_error, i);
7385 if (sw_if_index_set == 0)
7387 errmsg ("missing interface name or sw_if_index");
7391 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7393 mp->sw_if_index = ntohl (sw_if_index);
7394 mp->enable_disable = enable;
7402 api_mpls_tunnel_add_del (vat_main_t * vam)
7404 unformat_input_t *i = vam->input;
7405 vl_api_mpls_tunnel_add_del_t *mp;
7409 u32 sw_if_index = ~0;
7410 u32 next_hop_sw_if_index = ~0;
7411 u32 next_hop_proto_is_ip4 = 1;
7413 u32 next_hop_table_id = 0;
7414 ip4_address_t v4_next_hop_address = {
7417 ip6_address_t v6_next_hop_address = { {0} };
7418 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7421 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7423 if (unformat (i, "add"))
7425 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7427 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7429 else if (unformat (i, "via %U",
7430 unformat_ip4_address, &v4_next_hop_address))
7432 next_hop_proto_is_ip4 = 1;
7434 else if (unformat (i, "via %U",
7435 unformat_ip6_address, &v6_next_hop_address))
7437 next_hop_proto_is_ip4 = 0;
7439 else if (unformat (i, "l2-only"))
7441 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7443 else if (unformat (i, "out-label %d", &next_hop_out_label))
7444 vec_add1 (labels, ntohl (next_hop_out_label));
7447 clib_warning ("parse error '%U'", format_unformat_error, i);
7452 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7454 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7455 mp->mt_sw_if_index = ntohl (sw_if_index);
7456 mp->mt_is_add = is_add;
7457 mp->mt_l2_only = l2_only;
7458 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7459 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7461 mp->mt_next_hop_n_out_labels = vec_len (labels);
7463 if (0 != mp->mt_next_hop_n_out_labels)
7465 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7466 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7470 if (next_hop_proto_is_ip4)
7472 clib_memcpy (mp->mt_next_hop,
7473 &v4_next_hop_address, sizeof (v4_next_hop_address));
7477 clib_memcpy (mp->mt_next_hop,
7478 &v6_next_hop_address, sizeof (v6_next_hop_address));
7487 api_sw_interface_set_unnumbered (vat_main_t * vam)
7489 unformat_input_t *i = vam->input;
7490 vl_api_sw_interface_set_unnumbered_t *mp;
7492 u32 unnum_sw_index = ~0;
7494 u8 sw_if_index_set = 0;
7497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7499 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7500 sw_if_index_set = 1;
7501 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7502 sw_if_index_set = 1;
7503 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7505 else if (unformat (i, "del"))
7509 clib_warning ("parse error '%U'", format_unformat_error, i);
7514 if (sw_if_index_set == 0)
7516 errmsg ("missing interface name or sw_if_index");
7520 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7522 mp->sw_if_index = ntohl (sw_if_index);
7523 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7524 mp->is_add = is_add;
7532 api_ip_neighbor_add_del (vat_main_t * vam)
7534 unformat_input_t *i = vam->input;
7535 vl_api_ip_neighbor_add_del_t *mp;
7537 u8 sw_if_index_set = 0;
7540 u8 is_no_fib_entry = 0;
7543 u8 v4_address_set = 0;
7544 u8 v6_address_set = 0;
7545 ip4_address_t v4address;
7546 ip6_address_t v6address;
7549 memset (mac_address, 0, sizeof (mac_address));
7551 /* Parse args required to build the message */
7552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7554 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7558 else if (unformat (i, "del"))
7561 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7562 sw_if_index_set = 1;
7563 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7564 sw_if_index_set = 1;
7565 else if (unformat (i, "is_static"))
7567 else if (unformat (i, "no-fib-entry"))
7568 is_no_fib_entry = 1;
7569 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7571 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7575 clib_warning ("parse error '%U'", format_unformat_error, i);
7580 if (sw_if_index_set == 0)
7582 errmsg ("missing interface name or sw_if_index");
7585 if (v4_address_set && v6_address_set)
7587 errmsg ("both v4 and v6 addresses set");
7590 if (!v4_address_set && !v6_address_set)
7592 errmsg ("no address set");
7596 /* Construct the API message */
7597 M (IP_NEIGHBOR_ADD_DEL, mp);
7599 mp->sw_if_index = ntohl (sw_if_index);
7600 mp->is_add = is_add;
7601 mp->is_static = is_static;
7602 mp->is_no_adj_fib = is_no_fib_entry;
7604 clib_memcpy (mp->mac_address, mac_address, 6);
7608 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7612 /* mp->is_ipv6 = 0; via memset in M macro above */
7613 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7619 /* Wait for a reply, return good/bad news */
7625 api_reset_vrf (vat_main_t * vam)
7627 unformat_input_t *i = vam->input;
7628 vl_api_reset_vrf_t *mp;
7634 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7636 if (unformat (i, "vrf %d", &vrf_id))
7638 else if (unformat (i, "ipv6"))
7642 clib_warning ("parse error '%U'", format_unformat_error, i);
7647 if (vrf_id_set == 0)
7649 errmsg ("missing vrf id");
7655 mp->vrf_id = ntohl (vrf_id);
7656 mp->is_ipv6 = is_ipv6;
7664 api_create_vlan_subif (vat_main_t * vam)
7666 unformat_input_t *i = vam->input;
7667 vl_api_create_vlan_subif_t *mp;
7669 u8 sw_if_index_set = 0;
7674 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7676 if (unformat (i, "sw_if_index %d", &sw_if_index))
7677 sw_if_index_set = 1;
7679 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7680 sw_if_index_set = 1;
7681 else if (unformat (i, "vlan %d", &vlan_id))
7685 clib_warning ("parse error '%U'", format_unformat_error, i);
7690 if (sw_if_index_set == 0)
7692 errmsg ("missing interface name or sw_if_index");
7696 if (vlan_id_set == 0)
7698 errmsg ("missing vlan_id");
7701 M (CREATE_VLAN_SUBIF, mp);
7703 mp->sw_if_index = ntohl (sw_if_index);
7704 mp->vlan_id = ntohl (vlan_id);
7711 #define foreach_create_subif_bit \
7718 _(outer_vlan_id_any) \
7719 _(inner_vlan_id_any)
7722 api_create_subif (vat_main_t * vam)
7724 unformat_input_t *i = vam->input;
7725 vl_api_create_subif_t *mp;
7727 u8 sw_if_index_set = 0;
7734 u32 exact_match = 0;
7735 u32 default_sub = 0;
7736 u32 outer_vlan_id_any = 0;
7737 u32 inner_vlan_id_any = 0;
7739 u16 outer_vlan_id = 0;
7740 u16 inner_vlan_id = 0;
7743 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7745 if (unformat (i, "sw_if_index %d", &sw_if_index))
7746 sw_if_index_set = 1;
7748 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7749 sw_if_index_set = 1;
7750 else if (unformat (i, "sub_id %d", &sub_id))
7752 else if (unformat (i, "outer_vlan_id %d", &tmp))
7753 outer_vlan_id = tmp;
7754 else if (unformat (i, "inner_vlan_id %d", &tmp))
7755 inner_vlan_id = tmp;
7757 #define _(a) else if (unformat (i, #a)) a = 1 ;
7758 foreach_create_subif_bit
7762 clib_warning ("parse error '%U'", format_unformat_error, i);
7767 if (sw_if_index_set == 0)
7769 errmsg ("missing interface name or sw_if_index");
7773 if (sub_id_set == 0)
7775 errmsg ("missing sub_id");
7778 M (CREATE_SUBIF, mp);
7780 mp->sw_if_index = ntohl (sw_if_index);
7781 mp->sub_id = ntohl (sub_id);
7783 #define _(a) mp->a = a;
7784 foreach_create_subif_bit;
7787 mp->outer_vlan_id = ntohs (outer_vlan_id);
7788 mp->inner_vlan_id = ntohs (inner_vlan_id);
7796 api_oam_add_del (vat_main_t * vam)
7798 unformat_input_t *i = vam->input;
7799 vl_api_oam_add_del_t *mp;
7802 ip4_address_t src, dst;
7807 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7809 if (unformat (i, "vrf %d", &vrf_id))
7811 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7813 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7815 else if (unformat (i, "del"))
7819 clib_warning ("parse error '%U'", format_unformat_error, i);
7826 errmsg ("missing src addr");
7832 errmsg ("missing dst addr");
7836 M (OAM_ADD_DEL, mp);
7838 mp->vrf_id = ntohl (vrf_id);
7839 mp->is_add = is_add;
7840 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7841 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7849 api_reset_fib (vat_main_t * vam)
7851 unformat_input_t *i = vam->input;
7852 vl_api_reset_fib_t *mp;
7858 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7860 if (unformat (i, "vrf %d", &vrf_id))
7862 else if (unformat (i, "ipv6"))
7866 clib_warning ("parse error '%U'", format_unformat_error, i);
7871 if (vrf_id_set == 0)
7873 errmsg ("missing vrf id");
7879 mp->vrf_id = ntohl (vrf_id);
7880 mp->is_ipv6 = is_ipv6;
7888 api_dhcp_proxy_config (vat_main_t * vam)
7890 unformat_input_t *i = vam->input;
7891 vl_api_dhcp_proxy_config_t *mp;
7893 u32 server_vrf_id = 0;
7895 u8 v4_address_set = 0;
7896 u8 v6_address_set = 0;
7897 ip4_address_t v4address;
7898 ip6_address_t v6address;
7899 u8 v4_src_address_set = 0;
7900 u8 v6_src_address_set = 0;
7901 ip4_address_t v4srcaddress;
7902 ip6_address_t v6srcaddress;
7905 /* Parse args required to build the message */
7906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7908 if (unformat (i, "del"))
7910 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7912 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7914 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7916 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7918 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7919 v4_src_address_set = 1;
7920 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7921 v6_src_address_set = 1;
7926 if (v4_address_set && v6_address_set)
7928 errmsg ("both v4 and v6 server addresses set");
7931 if (!v4_address_set && !v6_address_set)
7933 errmsg ("no server addresses set");
7937 if (v4_src_address_set && v6_src_address_set)
7939 errmsg ("both v4 and v6 src addresses set");
7942 if (!v4_src_address_set && !v6_src_address_set)
7944 errmsg ("no src addresses set");
7948 if (!(v4_src_address_set && v4_address_set) &&
7949 !(v6_src_address_set && v6_address_set))
7951 errmsg ("no matching server and src addresses set");
7955 /* Construct the API message */
7956 M (DHCP_PROXY_CONFIG, mp);
7958 mp->is_add = is_add;
7959 mp->rx_vrf_id = ntohl (rx_vrf_id);
7960 mp->server_vrf_id = ntohl (server_vrf_id);
7964 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7965 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7969 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7970 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7976 /* Wait for a reply, return good/bad news */
7981 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
7982 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
7985 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
7987 vat_main_t *vam = &vat_main;
7988 u32 i, count = mp->count;
7989 vl_api_dhcp_server_t *s;
7993 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7994 ntohl (mp->rx_vrf_id),
7995 format_ip6_address, mp->dhcp_src_address,
7996 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7999 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8000 ntohl (mp->rx_vrf_id),
8001 format_ip4_address, mp->dhcp_src_address,
8002 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8004 for (i = 0; i < count; i++)
8006 s = &mp->servers[i];
8010 " Server Table-ID %d, Server Address %U",
8011 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
8014 " Server Table-ID %d, Server Address %U",
8015 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
8019 static void vl_api_dhcp_proxy_details_t_handler_json
8020 (vl_api_dhcp_proxy_details_t * mp)
8022 vat_main_t *vam = &vat_main;
8023 vat_json_node_t *node = NULL;
8024 u32 i, count = mp->count;
8026 struct in6_addr ip6;
8027 vl_api_dhcp_server_t *s;
8029 if (VAT_JSON_ARRAY != vam->json_tree.type)
8031 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8032 vat_json_init_array (&vam->json_tree);
8034 node = vat_json_array_add (&vam->json_tree);
8036 vat_json_init_object (node);
8037 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
8038 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
8039 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
8043 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
8044 vat_json_object_add_ip6 (node, "src_address", ip6);
8048 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
8049 vat_json_object_add_ip4 (node, "src_address", ip4);
8052 for (i = 0; i < count; i++)
8054 s = &mp->servers[i];
8056 vat_json_object_add_uint (node, "server-table-id",
8057 ntohl (s->server_vrf_id));
8061 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
8062 vat_json_object_add_ip4 (node, "src_address", ip4);
8066 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
8067 vat_json_object_add_ip6 (node, "server_address", ip6);
8073 api_dhcp_proxy_dump (vat_main_t * vam)
8075 unformat_input_t *i = vam->input;
8076 vl_api_control_ping_t *mp_ping;
8077 vl_api_dhcp_proxy_dump_t *mp;
8081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8083 if (unformat (i, "ipv6"))
8087 clib_warning ("parse error '%U'", format_unformat_error, i);
8092 M (DHCP_PROXY_DUMP, mp);
8094 mp->is_ip6 = is_ipv6;
8097 /* Use a control ping for synchronization */
8098 M (CONTROL_PING, mp_ping);
8106 api_dhcp_proxy_set_vss (vat_main_t * vam)
8108 unformat_input_t *i = vam->input;
8109 vl_api_dhcp_proxy_set_vss_t *mp;
8120 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8122 if (unformat (i, "tbl_id %d", &tbl_id))
8124 if (unformat (i, "fib_id %d", &fib_id))
8126 if (unformat (i, "oui %d", &oui))
8128 else if (unformat (i, "ipv6"))
8130 else if (unformat (i, "del"))
8134 clib_warning ("parse error '%U'", format_unformat_error, i);
8139 if (tbl_id_set == 0)
8141 errmsg ("missing tbl id");
8145 if (fib_id_set == 0)
8147 errmsg ("missing fib id");
8152 errmsg ("missing oui");
8156 M (DHCP_PROXY_SET_VSS, mp);
8157 mp->tbl_id = ntohl (tbl_id);
8158 mp->fib_id = ntohl (fib_id);
8159 mp->oui = ntohl (oui);
8160 mp->is_ipv6 = is_ipv6;
8161 mp->is_add = is_add;
8169 api_dhcp_client_config (vat_main_t * vam)
8171 unformat_input_t *i = vam->input;
8172 vl_api_dhcp_client_config_t *mp;
8174 u8 sw_if_index_set = 0;
8177 u8 disable_event = 0;
8180 /* Parse args required to build the message */
8181 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8183 if (unformat (i, "del"))
8186 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8187 sw_if_index_set = 1;
8188 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8189 sw_if_index_set = 1;
8190 else if (unformat (i, "hostname %s", &hostname))
8192 else if (unformat (i, "disable_event"))
8198 if (sw_if_index_set == 0)
8200 errmsg ("missing interface name or sw_if_index");
8204 if (vec_len (hostname) > 63)
8206 errmsg ("hostname too long");
8208 vec_add1 (hostname, 0);
8210 /* Construct the API message */
8211 M (DHCP_CLIENT_CONFIG, mp);
8213 mp->sw_if_index = htonl (sw_if_index);
8214 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
8215 vec_free (hostname);
8216 mp->is_add = is_add;
8217 mp->want_dhcp_event = disable_event ? 0 : 1;
8218 mp->pid = htonl (getpid ());
8223 /* Wait for a reply, return good/bad news */
8229 api_set_ip_flow_hash (vat_main_t * vam)
8231 unformat_input_t *i = vam->input;
8232 vl_api_set_ip_flow_hash_t *mp;
8244 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8246 if (unformat (i, "vrf %d", &vrf_id))
8248 else if (unformat (i, "ipv6"))
8250 else if (unformat (i, "src"))
8252 else if (unformat (i, "dst"))
8254 else if (unformat (i, "sport"))
8256 else if (unformat (i, "dport"))
8258 else if (unformat (i, "proto"))
8260 else if (unformat (i, "reverse"))
8265 clib_warning ("parse error '%U'", format_unformat_error, i);
8270 if (vrf_id_set == 0)
8272 errmsg ("missing vrf id");
8276 M (SET_IP_FLOW_HASH, mp);
8282 mp->reverse = reverse;
8283 mp->vrf_id = ntohl (vrf_id);
8284 mp->is_ipv6 = is_ipv6;
8292 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8294 unformat_input_t *i = vam->input;
8295 vl_api_sw_interface_ip6_enable_disable_t *mp;
8297 u8 sw_if_index_set = 0;
8301 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8303 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8304 sw_if_index_set = 1;
8305 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8306 sw_if_index_set = 1;
8307 else if (unformat (i, "enable"))
8309 else if (unformat (i, "disable"))
8313 clib_warning ("parse error '%U'", format_unformat_error, i);
8318 if (sw_if_index_set == 0)
8320 errmsg ("missing interface name or sw_if_index");
8324 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8326 mp->sw_if_index = ntohl (sw_if_index);
8327 mp->enable = enable;
8335 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8337 unformat_input_t *i = vam->input;
8338 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8340 u8 sw_if_index_set = 0;
8341 u8 v6_address_set = 0;
8342 ip6_address_t v6address;
8345 /* Parse args required to build the message */
8346 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8348 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8349 sw_if_index_set = 1;
8350 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8351 sw_if_index_set = 1;
8352 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8358 if (sw_if_index_set == 0)
8360 errmsg ("missing interface name or sw_if_index");
8363 if (!v6_address_set)
8365 errmsg ("no address set");
8369 /* Construct the API message */
8370 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8372 mp->sw_if_index = ntohl (sw_if_index);
8373 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8378 /* Wait for a reply, return good/bad news */
8384 api_ip6nd_proxy_add_del (vat_main_t * vam)
8386 unformat_input_t *i = vam->input;
8387 vl_api_ip6nd_proxy_add_del_t *mp;
8388 u32 sw_if_index = ~0;
8389 u8 v6_address_set = 0;
8390 ip6_address_t v6address;
8394 /* Parse args required to build the message */
8395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8397 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8399 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8401 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8403 if (unformat (i, "del"))
8407 clib_warning ("parse error '%U'", format_unformat_error, i);
8412 if (sw_if_index == ~0)
8414 errmsg ("missing interface name or sw_if_index");
8417 if (!v6_address_set)
8419 errmsg ("no address set");
8423 /* Construct the API message */
8424 M (IP6ND_PROXY_ADD_DEL, mp);
8426 mp->is_del = is_del;
8427 mp->sw_if_index = ntohl (sw_if_index);
8428 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8433 /* Wait for a reply, return good/bad news */
8439 api_ip6nd_proxy_dump (vat_main_t * vam)
8441 vl_api_ip6nd_proxy_dump_t *mp;
8442 vl_api_control_ping_t *mp_ping;
8445 M (IP6ND_PROXY_DUMP, mp);
8449 /* Use a control ping for synchronization */
8450 M (CONTROL_PING, mp_ping);
8457 static void vl_api_ip6nd_proxy_details_t_handler
8458 (vl_api_ip6nd_proxy_details_t * mp)
8460 vat_main_t *vam = &vat_main;
8462 print (vam->ofp, "host %U sw_if_index %d",
8463 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
8466 static void vl_api_ip6nd_proxy_details_t_handler_json
8467 (vl_api_ip6nd_proxy_details_t * mp)
8469 vat_main_t *vam = &vat_main;
8470 struct in6_addr ip6;
8471 vat_json_node_t *node = NULL;
8473 if (VAT_JSON_ARRAY != vam->json_tree.type)
8475 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8476 vat_json_init_array (&vam->json_tree);
8478 node = vat_json_array_add (&vam->json_tree);
8480 vat_json_init_object (node);
8481 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
8483 clib_memcpy (&ip6, mp->address, sizeof (ip6));
8484 vat_json_object_add_ip6 (node, "host", ip6);
8488 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8490 unformat_input_t *i = vam->input;
8491 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8493 u8 sw_if_index_set = 0;
8494 u32 address_length = 0;
8495 u8 v6_address_set = 0;
8496 ip6_address_t v6address;
8498 u8 no_advertise = 0;
8500 u8 no_autoconfig = 0;
8503 u32 val_lifetime = 0;
8504 u32 pref_lifetime = 0;
8507 /* Parse args required to build the message */
8508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8510 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8511 sw_if_index_set = 1;
8512 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8513 sw_if_index_set = 1;
8514 else if (unformat (i, "%U/%d",
8515 unformat_ip6_address, &v6address, &address_length))
8517 else if (unformat (i, "val_life %d", &val_lifetime))
8519 else if (unformat (i, "pref_life %d", &pref_lifetime))
8521 else if (unformat (i, "def"))
8523 else if (unformat (i, "noadv"))
8525 else if (unformat (i, "offl"))
8527 else if (unformat (i, "noauto"))
8529 else if (unformat (i, "nolink"))
8531 else if (unformat (i, "isno"))
8535 clib_warning ("parse error '%U'", format_unformat_error, i);
8540 if (sw_if_index_set == 0)
8542 errmsg ("missing interface name or sw_if_index");
8545 if (!v6_address_set)
8547 errmsg ("no address set");
8551 /* Construct the API message */
8552 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8554 mp->sw_if_index = ntohl (sw_if_index);
8555 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8556 mp->address_length = address_length;
8557 mp->use_default = use_default;
8558 mp->no_advertise = no_advertise;
8559 mp->off_link = off_link;
8560 mp->no_autoconfig = no_autoconfig;
8561 mp->no_onlink = no_onlink;
8563 mp->val_lifetime = ntohl (val_lifetime);
8564 mp->pref_lifetime = ntohl (pref_lifetime);
8569 /* Wait for a reply, return good/bad news */
8575 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8577 unformat_input_t *i = vam->input;
8578 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8580 u8 sw_if_index_set = 0;
8585 u8 send_unicast = 0;
8588 u8 default_router = 0;
8589 u32 max_interval = 0;
8590 u32 min_interval = 0;
8592 u32 initial_count = 0;
8593 u32 initial_interval = 0;
8597 /* Parse args required to build the message */
8598 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8600 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8601 sw_if_index_set = 1;
8602 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8603 sw_if_index_set = 1;
8604 else if (unformat (i, "maxint %d", &max_interval))
8606 else if (unformat (i, "minint %d", &min_interval))
8608 else if (unformat (i, "life %d", &lifetime))
8610 else if (unformat (i, "count %d", &initial_count))
8612 else if (unformat (i, "interval %d", &initial_interval))
8614 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8616 else if (unformat (i, "managed"))
8618 else if (unformat (i, "other"))
8620 else if (unformat (i, "ll"))
8622 else if (unformat (i, "send"))
8624 else if (unformat (i, "cease"))
8626 else if (unformat (i, "isno"))
8628 else if (unformat (i, "def"))
8632 clib_warning ("parse error '%U'", format_unformat_error, i);
8637 if (sw_if_index_set == 0)
8639 errmsg ("missing interface name or sw_if_index");
8643 /* Construct the API message */
8644 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8646 mp->sw_if_index = ntohl (sw_if_index);
8647 mp->max_interval = ntohl (max_interval);
8648 mp->min_interval = ntohl (min_interval);
8649 mp->lifetime = ntohl (lifetime);
8650 mp->initial_count = ntohl (initial_count);
8651 mp->initial_interval = ntohl (initial_interval);
8652 mp->suppress = suppress;
8653 mp->managed = managed;
8655 mp->ll_option = ll_option;
8656 mp->send_unicast = send_unicast;
8659 mp->default_router = default_router;
8664 /* Wait for a reply, return good/bad news */
8670 api_set_arp_neighbor_limit (vat_main_t * vam)
8672 unformat_input_t *i = vam->input;
8673 vl_api_set_arp_neighbor_limit_t *mp;
8679 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8681 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8683 else if (unformat (i, "ipv6"))
8687 clib_warning ("parse error '%U'", format_unformat_error, i);
8694 errmsg ("missing limit value");
8698 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8700 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8701 mp->is_ipv6 = is_ipv6;
8709 api_l2_patch_add_del (vat_main_t * vam)
8711 unformat_input_t *i = vam->input;
8712 vl_api_l2_patch_add_del_t *mp;
8714 u8 rx_sw_if_index_set = 0;
8716 u8 tx_sw_if_index_set = 0;
8720 /* Parse args required to build the message */
8721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8723 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8724 rx_sw_if_index_set = 1;
8725 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8726 tx_sw_if_index_set = 1;
8727 else if (unformat (i, "rx"))
8729 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8731 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8733 rx_sw_if_index_set = 1;
8738 else if (unformat (i, "tx"))
8740 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8742 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8744 tx_sw_if_index_set = 1;
8749 else if (unformat (i, "del"))
8755 if (rx_sw_if_index_set == 0)
8757 errmsg ("missing rx interface name or rx_sw_if_index");
8761 if (tx_sw_if_index_set == 0)
8763 errmsg ("missing tx interface name or tx_sw_if_index");
8767 M (L2_PATCH_ADD_DEL, mp);
8769 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8770 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8771 mp->is_add = is_add;
8779 u8 localsid_addr[16];
8788 api_sr_localsid_add_del (vat_main_t * vam)
8790 unformat_input_t *i = vam->input;
8791 vl_api_sr_localsid_add_del_t *mp;
8794 ip6_address_t localsid;
8798 u32 fib_table = ~(u32) 0;
8799 ip6_address_t next_hop;
8801 bool nexthop_set = 0;
8805 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8807 if (unformat (i, "del"))
8809 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
8810 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
8812 else if (unformat (i, "behavior %u", &behavior));
8813 else if (unformat (i, "sw_if_index %u", &sw_if_index));
8814 else if (unformat (i, "fib-table %u", &fib_table));
8815 else if (unformat (i, "end.psp %u", &behavior));
8820 M (SR_LOCALSID_ADD_DEL, mp);
8822 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
8824 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
8825 mp->behavior = behavior;
8826 mp->sw_if_index = ntohl (sw_if_index);
8827 mp->fib_table = ntohl (fib_table);
8828 mp->end_psp = end_psp;
8829 mp->is_del = is_del;
8837 api_ioam_enable (vat_main_t * vam)
8839 unformat_input_t *input = vam->input;
8840 vl_api_ioam_enable_t *mp;
8842 int has_trace_option = 0;
8843 int has_pot_option = 0;
8844 int has_seqno_option = 0;
8845 int has_analyse_option = 0;
8848 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8850 if (unformat (input, "trace"))
8851 has_trace_option = 1;
8852 else if (unformat (input, "pot"))
8854 else if (unformat (input, "seqno"))
8855 has_seqno_option = 1;
8856 else if (unformat (input, "analyse"))
8857 has_analyse_option = 1;
8861 M (IOAM_ENABLE, mp);
8862 mp->id = htons (id);
8863 mp->seqno = has_seqno_option;
8864 mp->analyse = has_analyse_option;
8865 mp->pot_enable = has_pot_option;
8866 mp->trace_enable = has_trace_option;
8875 api_ioam_disable (vat_main_t * vam)
8877 vl_api_ioam_disable_t *mp;
8880 M (IOAM_DISABLE, mp);
8886 #define foreach_tcp_proto_field \
8890 #define foreach_udp_proto_field \
8894 #define foreach_ip4_proto_field \
8906 u16 src_port, dst_port;
8909 #if VPP_API_TEST_BUILTIN == 0
8911 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8913 u8 **maskp = va_arg (*args, u8 **);
8915 u8 found_something = 0;
8918 #define _(a) u8 a=0;
8919 foreach_tcp_proto_field;
8922 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8925 #define _(a) else if (unformat (input, #a)) a=1;
8926 foreach_tcp_proto_field
8932 #define _(a) found_something += a;
8933 foreach_tcp_proto_field;
8936 if (found_something == 0)
8939 vec_validate (mask, sizeof (*tcp) - 1);
8941 tcp = (tcp_header_t *) mask;
8943 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8944 foreach_tcp_proto_field;
8952 unformat_udp_mask (unformat_input_t * input, va_list * args)
8954 u8 **maskp = va_arg (*args, u8 **);
8956 u8 found_something = 0;
8959 #define _(a) u8 a=0;
8960 foreach_udp_proto_field;
8963 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8966 #define _(a) else if (unformat (input, #a)) a=1;
8967 foreach_udp_proto_field
8973 #define _(a) found_something += a;
8974 foreach_udp_proto_field;
8977 if (found_something == 0)
8980 vec_validate (mask, sizeof (*udp) - 1);
8982 udp = (udp_header_t *) mask;
8984 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8985 foreach_udp_proto_field;
8993 unformat_l4_mask (unformat_input_t * input, va_list * args)
8995 u8 **maskp = va_arg (*args, u8 **);
8996 u16 src_port = 0, dst_port = 0;
8997 tcpudp_header_t *tcpudp;
8999 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9001 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9003 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9005 else if (unformat (input, "src_port"))
9007 else if (unformat (input, "dst_port"))
9013 if (!src_port && !dst_port)
9017 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9019 tcpudp = (tcpudp_header_t *) mask;
9020 tcpudp->src_port = src_port;
9021 tcpudp->dst_port = dst_port;
9029 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9031 u8 **maskp = va_arg (*args, u8 **);
9033 u8 found_something = 0;
9036 #define _(a) u8 a=0;
9037 foreach_ip4_proto_field;
9043 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9045 if (unformat (input, "version"))
9047 else if (unformat (input, "hdr_length"))
9049 else if (unformat (input, "src"))
9051 else if (unformat (input, "dst"))
9053 else if (unformat (input, "proto"))
9056 #define _(a) else if (unformat (input, #a)) a=1;
9057 foreach_ip4_proto_field
9063 #define _(a) found_something += a;
9064 foreach_ip4_proto_field;
9067 if (found_something == 0)
9070 vec_validate (mask, sizeof (*ip) - 1);
9072 ip = (ip4_header_t *) mask;
9074 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9075 foreach_ip4_proto_field;
9078 ip->ip_version_and_header_length = 0;
9081 ip->ip_version_and_header_length |= 0xF0;
9084 ip->ip_version_and_header_length |= 0x0F;
9090 #define foreach_ip6_proto_field \
9098 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9100 u8 **maskp = va_arg (*args, u8 **);
9102 u8 found_something = 0;
9104 u32 ip_version_traffic_class_and_flow_label;
9106 #define _(a) u8 a=0;
9107 foreach_ip6_proto_field;
9110 u8 traffic_class = 0;
9113 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9115 if (unformat (input, "version"))
9117 else if (unformat (input, "traffic-class"))
9119 else if (unformat (input, "flow-label"))
9121 else if (unformat (input, "src"))
9123 else if (unformat (input, "dst"))
9125 else if (unformat (input, "proto"))
9128 #define _(a) else if (unformat (input, #a)) a=1;
9129 foreach_ip6_proto_field
9135 #define _(a) found_something += a;
9136 foreach_ip6_proto_field;
9139 if (found_something == 0)
9142 vec_validate (mask, sizeof (*ip) - 1);
9144 ip = (ip6_header_t *) mask;
9146 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9147 foreach_ip6_proto_field;
9150 ip_version_traffic_class_and_flow_label = 0;
9153 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9156 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9159 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9161 ip->ip_version_traffic_class_and_flow_label =
9162 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9169 unformat_l3_mask (unformat_input_t * input, va_list * args)
9171 u8 **maskp = va_arg (*args, u8 **);
9173 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9175 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9177 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9186 unformat_l2_mask (unformat_input_t * input, va_list * args)
9188 u8 **maskp = va_arg (*args, u8 **);
9203 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9205 if (unformat (input, "src"))
9207 else if (unformat (input, "dst"))
9209 else if (unformat (input, "proto"))
9211 else if (unformat (input, "tag1"))
9213 else if (unformat (input, "tag2"))
9215 else if (unformat (input, "ignore-tag1"))
9217 else if (unformat (input, "ignore-tag2"))
9219 else if (unformat (input, "cos1"))
9221 else if (unformat (input, "cos2"))
9223 else if (unformat (input, "dot1q"))
9225 else if (unformat (input, "dot1ad"))
9230 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9231 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9234 if (tag1 || ignore_tag1 || cos1 || dot1q)
9236 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9239 vec_validate (mask, len - 1);
9242 memset (mask, 0xff, 6);
9245 memset (mask + 6, 0xff, 6);
9249 /* inner vlan tag */
9258 mask[21] = mask[20] = 0xff;
9279 mask[16] = mask[17] = 0xff;
9289 mask[12] = mask[13] = 0xff;
9296 unformat_classify_mask (unformat_input_t * input, va_list * args)
9298 u8 **maskp = va_arg (*args, u8 **);
9299 u32 *skipp = va_arg (*args, u32 *);
9300 u32 *matchp = va_arg (*args, u32 *);
9308 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9310 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9312 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9314 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9316 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9330 if (mask || l2 || l3 || l4)
9334 /* "With a free Ethernet header in every package" */
9336 vec_validate (l2, 13);
9340 vec_append (mask, l3);
9345 vec_append (mask, l4);
9350 /* Scan forward looking for the first significant mask octet */
9351 for (i = 0; i < vec_len (mask); i++)
9355 /* compute (skip, match) params */
9356 *skipp = i / sizeof (u32x4);
9357 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9359 /* Pad mask to an even multiple of the vector size */
9360 while (vec_len (mask) % sizeof (u32x4))
9363 match = vec_len (mask) / sizeof (u32x4);
9365 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9367 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9368 if (*tmp || *(tmp + 1))
9373 clib_warning ("BUG: match 0");
9375 _vec_len (mask) = match * sizeof (u32x4);
9385 #endif /* VPP_API_TEST_BUILTIN */
9387 #define foreach_l2_next \
9389 _(ethernet, ETHERNET_INPUT) \
9394 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9396 u32 *miss_next_indexp = va_arg (*args, u32 *);
9401 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9405 if (unformat (input, "%d", &tmp))
9414 *miss_next_indexp = next_index;
9418 #define foreach_ip_next \
9424 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9426 u32 *miss_next_indexp = va_arg (*args, u32 *);
9431 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9435 if (unformat (input, "%d", &tmp))
9444 *miss_next_indexp = next_index;
9448 #define foreach_acl_next \
9452 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9454 u32 *miss_next_indexp = va_arg (*args, u32 *);
9459 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9463 if (unformat (input, "permit"))
9468 else if (unformat (input, "%d", &tmp))
9477 *miss_next_indexp = next_index;
9482 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9484 u32 *r = va_arg (*args, u32 *);
9486 if (unformat (input, "conform-color"))
9487 *r = POLICE_CONFORM;
9488 else if (unformat (input, "exceed-color"))
9497 api_classify_add_del_table (vat_main_t * vam)
9499 unformat_input_t *i = vam->input;
9500 vl_api_classify_add_del_table_t *mp;
9507 u32 table_index = ~0;
9508 u32 next_table_index = ~0;
9509 u32 miss_next_index = ~0;
9510 u32 memory_size = 32 << 20;
9512 u32 current_data_flag = 0;
9513 int current_data_offset = 0;
9516 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9518 if (unformat (i, "del"))
9520 else if (unformat (i, "del-chain"))
9525 else if (unformat (i, "buckets %d", &nbuckets))
9527 else if (unformat (i, "memory_size %d", &memory_size))
9529 else if (unformat (i, "skip %d", &skip))
9531 else if (unformat (i, "match %d", &match))
9533 else if (unformat (i, "table %d", &table_index))
9535 else if (unformat (i, "mask %U", unformat_classify_mask,
9536 &mask, &skip, &match))
9538 else if (unformat (i, "next-table %d", &next_table_index))
9540 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9543 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9546 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9549 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9551 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9557 if (is_add && mask == 0)
9559 errmsg ("Mask required");
9563 if (is_add && skip == ~0)
9565 errmsg ("skip count required");
9569 if (is_add && match == ~0)
9571 errmsg ("match count required");
9575 if (!is_add && table_index == ~0)
9577 errmsg ("table index required for delete");
9581 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9583 mp->is_add = is_add;
9584 mp->del_chain = del_chain;
9585 mp->table_index = ntohl (table_index);
9586 mp->nbuckets = ntohl (nbuckets);
9587 mp->memory_size = ntohl (memory_size);
9588 mp->skip_n_vectors = ntohl (skip);
9589 mp->match_n_vectors = ntohl (match);
9590 mp->next_table_index = ntohl (next_table_index);
9591 mp->miss_next_index = ntohl (miss_next_index);
9592 mp->current_data_flag = ntohl (current_data_flag);
9593 mp->current_data_offset = ntohl (current_data_offset);
9594 clib_memcpy (mp->mask, mask, vec_len (mask));
9603 #if VPP_API_TEST_BUILTIN == 0
9605 unformat_l4_match (unformat_input_t * input, va_list * args)
9607 u8 **matchp = va_arg (*args, u8 **);
9609 u8 *proto_header = 0;
9615 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9617 if (unformat (input, "src_port %d", &src_port))
9619 else if (unformat (input, "dst_port %d", &dst_port))
9625 h.src_port = clib_host_to_net_u16 (src_port);
9626 h.dst_port = clib_host_to_net_u16 (dst_port);
9627 vec_validate (proto_header, sizeof (h) - 1);
9628 memcpy (proto_header, &h, sizeof (h));
9630 *matchp = proto_header;
9636 unformat_ip4_match (unformat_input_t * input, va_list * args)
9638 u8 **matchp = va_arg (*args, u8 **);
9645 int src = 0, dst = 0;
9646 ip4_address_t src_val, dst_val;
9653 int fragment_id = 0;
9654 u32 fragment_id_val;
9660 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9662 if (unformat (input, "version %d", &version_val))
9664 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9666 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9668 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9670 else if (unformat (input, "proto %d", &proto_val))
9672 else if (unformat (input, "tos %d", &tos_val))
9674 else if (unformat (input, "length %d", &length_val))
9676 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9678 else if (unformat (input, "ttl %d", &ttl_val))
9680 else if (unformat (input, "checksum %d", &checksum_val))
9686 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9687 + ttl + checksum == 0)
9691 * Aligned because we use the real comparison functions
9693 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9695 ip = (ip4_header_t *) match;
9697 /* These are realistically matched in practice */
9699 ip->src_address.as_u32 = src_val.as_u32;
9702 ip->dst_address.as_u32 = dst_val.as_u32;
9705 ip->protocol = proto_val;
9708 /* These are not, but they're included for completeness */
9710 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9713 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9719 ip->length = clib_host_to_net_u16 (length_val);
9725 ip->checksum = clib_host_to_net_u16 (checksum_val);
9732 unformat_ip6_match (unformat_input_t * input, va_list * args)
9734 u8 **matchp = va_arg (*args, u8 **);
9739 u8 traffic_class = 0;
9740 u32 traffic_class_val = 0;
9743 int src = 0, dst = 0;
9744 ip6_address_t src_val, dst_val;
9747 int payload_length = 0;
9748 u32 payload_length_val;
9751 u32 ip_version_traffic_class_and_flow_label;
9753 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9755 if (unformat (input, "version %d", &version_val))
9757 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9759 else if (unformat (input, "flow_label %d", &flow_label_val))
9761 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9763 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9765 else if (unformat (input, "proto %d", &proto_val))
9767 else if (unformat (input, "payload_length %d", &payload_length_val))
9769 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9775 if (version + traffic_class + flow_label + src + dst + proto +
9776 payload_length + hop_limit == 0)
9780 * Aligned because we use the real comparison functions
9782 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9784 ip = (ip6_header_t *) match;
9787 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9790 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9793 ip->protocol = proto_val;
9795 ip_version_traffic_class_and_flow_label = 0;
9798 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9801 ip_version_traffic_class_and_flow_label |=
9802 (traffic_class_val & 0xFF) << 20;
9805 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9807 ip->ip_version_traffic_class_and_flow_label =
9808 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9811 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9814 ip->hop_limit = hop_limit_val;
9821 unformat_l3_match (unformat_input_t * input, va_list * args)
9823 u8 **matchp = va_arg (*args, u8 **);
9825 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9827 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9829 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9838 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9840 u8 *tagp = va_arg (*args, u8 *);
9843 if (unformat (input, "%d", &tag))
9845 tagp[0] = (tag >> 8) & 0x0F;
9846 tagp[1] = tag & 0xFF;
9854 unformat_l2_match (unformat_input_t * input, va_list * args)
9856 u8 **matchp = va_arg (*args, u8 **);
9876 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9878 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9881 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9883 else if (unformat (input, "proto %U",
9884 unformat_ethernet_type_host_byte_order, &proto_val))
9886 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9888 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9890 else if (unformat (input, "ignore-tag1"))
9892 else if (unformat (input, "ignore-tag2"))
9894 else if (unformat (input, "cos1 %d", &cos1_val))
9896 else if (unformat (input, "cos2 %d", &cos2_val))
9901 if ((src + dst + proto + tag1 + tag2 +
9902 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9905 if (tag1 || ignore_tag1 || cos1)
9907 if (tag2 || ignore_tag2 || cos2)
9910 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9913 clib_memcpy (match, dst_val, 6);
9916 clib_memcpy (match + 6, src_val, 6);
9920 /* inner vlan tag */
9921 match[19] = tag2_val[1];
9922 match[18] = tag2_val[0];
9924 match[18] |= (cos2_val & 0x7) << 5;
9927 match[21] = proto_val & 0xff;
9928 match[20] = proto_val >> 8;
9932 match[15] = tag1_val[1];
9933 match[14] = tag1_val[0];
9936 match[14] |= (cos1_val & 0x7) << 5;
9942 match[15] = tag1_val[1];
9943 match[14] = tag1_val[0];
9946 match[17] = proto_val & 0xff;
9947 match[16] = proto_val >> 8;
9950 match[14] |= (cos1_val & 0x7) << 5;
9956 match[18] |= (cos2_val & 0x7) << 5;
9958 match[14] |= (cos1_val & 0x7) << 5;
9961 match[13] = proto_val & 0xff;
9962 match[12] = proto_val >> 8;
9971 api_unformat_classify_match (unformat_input_t * input, va_list * args)
9973 u8 **matchp = va_arg (*args, u8 **);
9974 u32 skip_n_vectors = va_arg (*args, u32);
9975 u32 match_n_vectors = va_arg (*args, u32);
9982 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9984 if (unformat (input, "hex %U", unformat_hex_string, &match))
9986 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9988 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9990 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10004 if (match || l2 || l3 || l4)
10006 if (l2 || l3 || l4)
10008 /* "Win a free Ethernet header in every packet" */
10010 vec_validate_aligned (l2, 13, sizeof (u32x4));
10014 vec_append_aligned (match, l3, sizeof (u32x4));
10019 vec_append_aligned (match, l4, sizeof (u32x4));
10024 /* Make sure the vector is big enough even if key is all 0's */
10025 vec_validate_aligned
10026 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10029 /* Set size, include skipped vectors */
10030 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10041 api_classify_add_del_session (vat_main_t * vam)
10043 unformat_input_t *i = vam->input;
10044 vl_api_classify_add_del_session_t *mp;
10046 u32 table_index = ~0;
10047 u32 hit_next_index = ~0;
10048 u32 opaque_index = ~0;
10051 u32 skip_n_vectors = 0;
10052 u32 match_n_vectors = 0;
10058 * Warning: you have to supply skip_n and match_n
10059 * because the API client cant simply look at the classify
10063 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10065 if (unformat (i, "del"))
10067 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10070 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10073 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10076 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10078 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10080 else if (unformat (i, "opaque-index %d", &opaque_index))
10082 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10084 else if (unformat (i, "match_n %d", &match_n_vectors))
10086 else if (unformat (i, "match %U", api_unformat_classify_match,
10087 &match, skip_n_vectors, match_n_vectors))
10089 else if (unformat (i, "advance %d", &advance))
10091 else if (unformat (i, "table-index %d", &table_index))
10093 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10095 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10097 else if (unformat (i, "action %d", &action))
10099 else if (unformat (i, "metadata %d", &metadata))
10105 if (table_index == ~0)
10107 errmsg ("Table index required");
10111 if (is_add && match == 0)
10113 errmsg ("Match value required");
10117 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10119 mp->is_add = is_add;
10120 mp->table_index = ntohl (table_index);
10121 mp->hit_next_index = ntohl (hit_next_index);
10122 mp->opaque_index = ntohl (opaque_index);
10123 mp->advance = ntohl (advance);
10124 mp->action = action;
10125 mp->metadata = ntohl (metadata);
10126 clib_memcpy (mp->match, match, vec_len (match));
10135 api_classify_set_interface_ip_table (vat_main_t * vam)
10137 unformat_input_t *i = vam->input;
10138 vl_api_classify_set_interface_ip_table_t *mp;
10140 int sw_if_index_set;
10141 u32 table_index = ~0;
10145 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10147 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10148 sw_if_index_set = 1;
10149 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10150 sw_if_index_set = 1;
10151 else if (unformat (i, "table %d", &table_index))
10155 clib_warning ("parse error '%U'", format_unformat_error, i);
10160 if (sw_if_index_set == 0)
10162 errmsg ("missing interface name or sw_if_index");
10167 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10169 mp->sw_if_index = ntohl (sw_if_index);
10170 mp->table_index = ntohl (table_index);
10171 mp->is_ipv6 = is_ipv6;
10179 api_classify_set_interface_l2_tables (vat_main_t * vam)
10181 unformat_input_t *i = vam->input;
10182 vl_api_classify_set_interface_l2_tables_t *mp;
10184 int sw_if_index_set;
10185 u32 ip4_table_index = ~0;
10186 u32 ip6_table_index = ~0;
10187 u32 other_table_index = ~0;
10191 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10193 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10194 sw_if_index_set = 1;
10195 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10196 sw_if_index_set = 1;
10197 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10199 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10201 else if (unformat (i, "other-table %d", &other_table_index))
10203 else if (unformat (i, "is-input %d", &is_input))
10207 clib_warning ("parse error '%U'", format_unformat_error, i);
10212 if (sw_if_index_set == 0)
10214 errmsg ("missing interface name or sw_if_index");
10219 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10221 mp->sw_if_index = ntohl (sw_if_index);
10222 mp->ip4_table_index = ntohl (ip4_table_index);
10223 mp->ip6_table_index = ntohl (ip6_table_index);
10224 mp->other_table_index = ntohl (other_table_index);
10225 mp->is_input = (u8) is_input;
10233 api_set_ipfix_exporter (vat_main_t * vam)
10235 unformat_input_t *i = vam->input;
10236 vl_api_set_ipfix_exporter_t *mp;
10237 ip4_address_t collector_address;
10238 u8 collector_address_set = 0;
10239 u32 collector_port = ~0;
10240 ip4_address_t src_address;
10241 u8 src_address_set = 0;
10244 u32 template_interval = ~0;
10245 u8 udp_checksum = 0;
10248 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10250 if (unformat (i, "collector_address %U", unformat_ip4_address,
10251 &collector_address))
10252 collector_address_set = 1;
10253 else if (unformat (i, "collector_port %d", &collector_port))
10255 else if (unformat (i, "src_address %U", unformat_ip4_address,
10257 src_address_set = 1;
10258 else if (unformat (i, "vrf_id %d", &vrf_id))
10260 else if (unformat (i, "path_mtu %d", &path_mtu))
10262 else if (unformat (i, "template_interval %d", &template_interval))
10264 else if (unformat (i, "udp_checksum"))
10270 if (collector_address_set == 0)
10272 errmsg ("collector_address required");
10276 if (src_address_set == 0)
10278 errmsg ("src_address required");
10282 M (SET_IPFIX_EXPORTER, mp);
10284 memcpy (mp->collector_address, collector_address.data,
10285 sizeof (collector_address.data));
10286 mp->collector_port = htons ((u16) collector_port);
10287 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10288 mp->vrf_id = htonl (vrf_id);
10289 mp->path_mtu = htonl (path_mtu);
10290 mp->template_interval = htonl (template_interval);
10291 mp->udp_checksum = udp_checksum;
10299 api_set_ipfix_classify_stream (vat_main_t * vam)
10301 unformat_input_t *i = vam->input;
10302 vl_api_set_ipfix_classify_stream_t *mp;
10304 u32 src_port = UDP_DST_PORT_ipfix;
10307 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10309 if (unformat (i, "domain %d", &domain_id))
10311 else if (unformat (i, "src_port %d", &src_port))
10315 errmsg ("unknown input `%U'", format_unformat_error, i);
10320 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10322 mp->domain_id = htonl (domain_id);
10323 mp->src_port = htons ((u16) src_port);
10331 api_ipfix_classify_table_add_del (vat_main_t * vam)
10333 unformat_input_t *i = vam->input;
10334 vl_api_ipfix_classify_table_add_del_t *mp;
10336 u32 classify_table_index = ~0;
10338 u8 transport_protocol = 255;
10341 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10343 if (unformat (i, "add"))
10345 else if (unformat (i, "del"))
10347 else if (unformat (i, "table %d", &classify_table_index))
10349 else if (unformat (i, "ip4"))
10351 else if (unformat (i, "ip6"))
10353 else if (unformat (i, "tcp"))
10354 transport_protocol = 6;
10355 else if (unformat (i, "udp"))
10356 transport_protocol = 17;
10359 errmsg ("unknown input `%U'", format_unformat_error, i);
10366 errmsg ("expecting: add|del");
10369 if (classify_table_index == ~0)
10371 errmsg ("classifier table not specified");
10374 if (ip_version == 0)
10376 errmsg ("IP version not specified");
10380 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10382 mp->is_add = is_add;
10383 mp->table_id = htonl (classify_table_index);
10384 mp->ip_version = ip_version;
10385 mp->transport_protocol = transport_protocol;
10393 api_get_node_index (vat_main_t * vam)
10395 unformat_input_t *i = vam->input;
10396 vl_api_get_node_index_t *mp;
10400 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10402 if (unformat (i, "node %s", &name))
10409 errmsg ("node name required");
10412 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10414 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10418 M (GET_NODE_INDEX, mp);
10419 clib_memcpy (mp->node_name, name, vec_len (name));
10428 api_get_next_index (vat_main_t * vam)
10430 unformat_input_t *i = vam->input;
10431 vl_api_get_next_index_t *mp;
10432 u8 *node_name = 0, *next_node_name = 0;
10435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10437 if (unformat (i, "node-name %s", &node_name))
10439 else if (unformat (i, "next-node-name %s", &next_node_name))
10443 if (node_name == 0)
10445 errmsg ("node name required");
10448 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10450 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10454 if (next_node_name == 0)
10456 errmsg ("next node name required");
10459 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10461 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10465 M (GET_NEXT_INDEX, mp);
10466 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10467 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10468 vec_free (node_name);
10469 vec_free (next_node_name);
10477 api_add_node_next (vat_main_t * vam)
10479 unformat_input_t *i = vam->input;
10480 vl_api_add_node_next_t *mp;
10485 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10487 if (unformat (i, "node %s", &name))
10489 else if (unformat (i, "next %s", &next))
10496 errmsg ("node name required");
10499 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10501 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10506 errmsg ("next node required");
10509 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10511 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10515 M (ADD_NODE_NEXT, mp);
10516 clib_memcpy (mp->node_name, name, vec_len (name));
10517 clib_memcpy (mp->next_name, next, vec_len (next));
10527 api_l2tpv3_create_tunnel (vat_main_t * vam)
10529 unformat_input_t *i = vam->input;
10530 ip6_address_t client_address, our_address;
10531 int client_address_set = 0;
10532 int our_address_set = 0;
10533 u32 local_session_id = 0;
10534 u32 remote_session_id = 0;
10535 u64 local_cookie = 0;
10536 u64 remote_cookie = 0;
10537 u8 l2_sublayer_present = 0;
10538 vl_api_l2tpv3_create_tunnel_t *mp;
10541 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10543 if (unformat (i, "client_address %U", unformat_ip6_address,
10545 client_address_set = 1;
10546 else if (unformat (i, "our_address %U", unformat_ip6_address,
10548 our_address_set = 1;
10549 else if (unformat (i, "local_session_id %d", &local_session_id))
10551 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10553 else if (unformat (i, "local_cookie %lld", &local_cookie))
10555 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10557 else if (unformat (i, "l2-sublayer-present"))
10558 l2_sublayer_present = 1;
10563 if (client_address_set == 0)
10565 errmsg ("client_address required");
10569 if (our_address_set == 0)
10571 errmsg ("our_address required");
10575 M (L2TPV3_CREATE_TUNNEL, mp);
10577 clib_memcpy (mp->client_address, client_address.as_u8,
10578 sizeof (mp->client_address));
10580 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10582 mp->local_session_id = ntohl (local_session_id);
10583 mp->remote_session_id = ntohl (remote_session_id);
10584 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10585 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10586 mp->l2_sublayer_present = l2_sublayer_present;
10595 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10597 unformat_input_t *i = vam->input;
10599 u8 sw_if_index_set = 0;
10600 u64 new_local_cookie = 0;
10601 u64 new_remote_cookie = 0;
10602 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10605 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10607 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10608 sw_if_index_set = 1;
10609 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10610 sw_if_index_set = 1;
10611 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10613 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10619 if (sw_if_index_set == 0)
10621 errmsg ("missing interface name or sw_if_index");
10625 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10627 mp->sw_if_index = ntohl (sw_if_index);
10628 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10629 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10637 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10639 unformat_input_t *i = vam->input;
10640 vl_api_l2tpv3_interface_enable_disable_t *mp;
10642 u8 sw_if_index_set = 0;
10643 u8 enable_disable = 1;
10646 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10648 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10649 sw_if_index_set = 1;
10650 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10651 sw_if_index_set = 1;
10652 else if (unformat (i, "enable"))
10653 enable_disable = 1;
10654 else if (unformat (i, "disable"))
10655 enable_disable = 0;
10660 if (sw_if_index_set == 0)
10662 errmsg ("missing interface name or sw_if_index");
10666 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10668 mp->sw_if_index = ntohl (sw_if_index);
10669 mp->enable_disable = enable_disable;
10677 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10679 unformat_input_t *i = vam->input;
10680 vl_api_l2tpv3_set_lookup_key_t *mp;
10684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10686 if (unformat (i, "lookup_v6_src"))
10687 key = L2T_LOOKUP_SRC_ADDRESS;
10688 else if (unformat (i, "lookup_v6_dst"))
10689 key = L2T_LOOKUP_DST_ADDRESS;
10690 else if (unformat (i, "lookup_session_id"))
10691 key = L2T_LOOKUP_SESSION_ID;
10696 if (key == (u8) ~ 0)
10698 errmsg ("l2tp session lookup key unset");
10702 M (L2TPV3_SET_LOOKUP_KEY, mp);
10711 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10712 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10714 vat_main_t *vam = &vat_main;
10716 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10717 format_ip6_address, mp->our_address,
10718 format_ip6_address, mp->client_address,
10719 clib_net_to_host_u32 (mp->sw_if_index));
10722 " local cookies %016llx %016llx remote cookie %016llx",
10723 clib_net_to_host_u64 (mp->local_cookie[0]),
10724 clib_net_to_host_u64 (mp->local_cookie[1]),
10725 clib_net_to_host_u64 (mp->remote_cookie));
10727 print (vam->ofp, " local session-id %d remote session-id %d",
10728 clib_net_to_host_u32 (mp->local_session_id),
10729 clib_net_to_host_u32 (mp->remote_session_id));
10731 print (vam->ofp, " l2 specific sublayer %s\n",
10732 mp->l2_sublayer_present ? "preset" : "absent");
10736 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10737 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10739 vat_main_t *vam = &vat_main;
10740 vat_json_node_t *node = NULL;
10741 struct in6_addr addr;
10743 if (VAT_JSON_ARRAY != vam->json_tree.type)
10745 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10746 vat_json_init_array (&vam->json_tree);
10748 node = vat_json_array_add (&vam->json_tree);
10750 vat_json_init_object (node);
10752 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10753 vat_json_object_add_ip6 (node, "our_address", addr);
10754 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10755 vat_json_object_add_ip6 (node, "client_address", addr);
10757 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10758 vat_json_init_array (lc);
10759 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10760 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10761 vat_json_object_add_uint (node, "remote_cookie",
10762 clib_net_to_host_u64 (mp->remote_cookie));
10764 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10765 vat_json_object_add_uint (node, "local_session_id",
10766 clib_net_to_host_u32 (mp->local_session_id));
10767 vat_json_object_add_uint (node, "remote_session_id",
10768 clib_net_to_host_u32 (mp->remote_session_id));
10769 vat_json_object_add_string_copy (node, "l2_sublayer",
10770 mp->l2_sublayer_present ? (u8 *) "present"
10771 : (u8 *) "absent");
10775 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10777 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10778 vl_api_control_ping_t *mp_ping;
10781 /* Get list of l2tpv3-tunnel interfaces */
10782 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10785 /* Use a control ping for synchronization */
10786 M (CONTROL_PING, mp_ping);
10794 static void vl_api_sw_interface_tap_details_t_handler
10795 (vl_api_sw_interface_tap_details_t * mp)
10797 vat_main_t *vam = &vat_main;
10799 print (vam->ofp, "%-16s %d",
10800 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10803 static void vl_api_sw_interface_tap_details_t_handler_json
10804 (vl_api_sw_interface_tap_details_t * mp)
10806 vat_main_t *vam = &vat_main;
10807 vat_json_node_t *node = NULL;
10809 if (VAT_JSON_ARRAY != vam->json_tree.type)
10811 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10812 vat_json_init_array (&vam->json_tree);
10814 node = vat_json_array_add (&vam->json_tree);
10816 vat_json_init_object (node);
10817 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10818 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10822 api_sw_interface_tap_dump (vat_main_t * vam)
10824 vl_api_sw_interface_tap_dump_t *mp;
10825 vl_api_control_ping_t *mp_ping;
10828 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10829 /* Get list of tap interfaces */
10830 M (SW_INTERFACE_TAP_DUMP, mp);
10833 /* Use a control ping for synchronization */
10834 M (CONTROL_PING, mp_ping);
10841 static uword unformat_vxlan_decap_next
10842 (unformat_input_t * input, va_list * args)
10844 u32 *result = va_arg (*args, u32 *);
10847 if (unformat (input, "l2"))
10848 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10849 else if (unformat (input, "%d", &tmp))
10857 api_vxlan_add_del_tunnel (vat_main_t * vam)
10859 unformat_input_t *line_input = vam->input;
10860 vl_api_vxlan_add_del_tunnel_t *mp;
10861 ip46_address_t src, dst;
10863 u8 ipv4_set = 0, ipv6_set = 0;
10867 u32 mcast_sw_if_index = ~0;
10868 u32 encap_vrf_id = 0;
10869 u32 decap_next_index = ~0;
10873 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10874 memset (&src, 0, sizeof src);
10875 memset (&dst, 0, sizeof dst);
10877 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10879 if (unformat (line_input, "del"))
10882 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10888 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10894 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10900 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10905 else if (unformat (line_input, "group %U %U",
10906 unformat_ip4_address, &dst.ip4,
10907 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10909 grp_set = dst_set = 1;
10912 else if (unformat (line_input, "group %U",
10913 unformat_ip4_address, &dst.ip4))
10915 grp_set = dst_set = 1;
10918 else if (unformat (line_input, "group %U %U",
10919 unformat_ip6_address, &dst.ip6,
10920 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10922 grp_set = dst_set = 1;
10925 else if (unformat (line_input, "group %U",
10926 unformat_ip6_address, &dst.ip6))
10928 grp_set = dst_set = 1;
10932 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10934 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10936 else if (unformat (line_input, "decap-next %U",
10937 unformat_vxlan_decap_next, &decap_next_index))
10939 else if (unformat (line_input, "vni %d", &vni))
10943 errmsg ("parse error '%U'", format_unformat_error, line_input);
10950 errmsg ("tunnel src address not specified");
10955 errmsg ("tunnel dst address not specified");
10959 if (grp_set && !ip46_address_is_multicast (&dst))
10961 errmsg ("tunnel group address not multicast");
10964 if (grp_set && mcast_sw_if_index == ~0)
10966 errmsg ("tunnel nonexistent multicast device");
10969 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10971 errmsg ("tunnel dst address must be unicast");
10976 if (ipv4_set && ipv6_set)
10978 errmsg ("both IPv4 and IPv6 addresses specified");
10982 if ((vni == 0) || (vni >> 24))
10984 errmsg ("vni not specified or out of range");
10988 M (VXLAN_ADD_DEL_TUNNEL, mp);
10992 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10993 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10997 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10998 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
11000 mp->encap_vrf_id = ntohl (encap_vrf_id);
11001 mp->decap_next_index = ntohl (decap_next_index);
11002 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11003 mp->vni = ntohl (vni);
11004 mp->is_add = is_add;
11005 mp->is_ipv6 = ipv6_set;
11012 static void vl_api_vxlan_tunnel_details_t_handler
11013 (vl_api_vxlan_tunnel_details_t * mp)
11015 vat_main_t *vam = &vat_main;
11016 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
11017 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
11019 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
11020 ntohl (mp->sw_if_index),
11021 format_ip46_address, &src, IP46_TYPE_ANY,
11022 format_ip46_address, &dst, IP46_TYPE_ANY,
11023 ntohl (mp->encap_vrf_id),
11024 ntohl (mp->decap_next_index), ntohl (mp->vni),
11025 ntohl (mp->mcast_sw_if_index));
11028 static void vl_api_vxlan_tunnel_details_t_handler_json
11029 (vl_api_vxlan_tunnel_details_t * mp)
11031 vat_main_t *vam = &vat_main;
11032 vat_json_node_t *node = NULL;
11034 if (VAT_JSON_ARRAY != vam->json_tree.type)
11036 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11037 vat_json_init_array (&vam->json_tree);
11039 node = vat_json_array_add (&vam->json_tree);
11041 vat_json_init_object (node);
11042 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11045 struct in6_addr ip6;
11047 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
11048 vat_json_object_add_ip6 (node, "src_address", ip6);
11049 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
11050 vat_json_object_add_ip6 (node, "dst_address", ip6);
11054 struct in_addr ip4;
11056 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
11057 vat_json_object_add_ip4 (node, "src_address", ip4);
11058 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
11059 vat_json_object_add_ip4 (node, "dst_address", ip4);
11061 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11062 vat_json_object_add_uint (node, "decap_next_index",
11063 ntohl (mp->decap_next_index));
11064 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11065 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11066 vat_json_object_add_uint (node, "mcast_sw_if_index",
11067 ntohl (mp->mcast_sw_if_index));
11071 api_vxlan_tunnel_dump (vat_main_t * vam)
11073 unformat_input_t *i = vam->input;
11074 vl_api_vxlan_tunnel_dump_t *mp;
11075 vl_api_control_ping_t *mp_ping;
11077 u8 sw_if_index_set = 0;
11080 /* Parse args required to build the message */
11081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11083 if (unformat (i, "sw_if_index %d", &sw_if_index))
11084 sw_if_index_set = 1;
11089 if (sw_if_index_set == 0)
11094 if (!vam->json_output)
11096 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
11097 "sw_if_index", "src_address", "dst_address",
11098 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11101 /* Get list of vxlan-tunnel interfaces */
11102 M (VXLAN_TUNNEL_DUMP, mp);
11104 mp->sw_if_index = htonl (sw_if_index);
11108 /* Use a control ping for synchronization */
11109 M (CONTROL_PING, mp_ping);
11117 api_gre_add_del_tunnel (vat_main_t * vam)
11119 unformat_input_t *line_input = vam->input;
11120 vl_api_gre_add_del_tunnel_t *mp;
11121 ip4_address_t src4, dst4;
11122 ip6_address_t src6, dst6;
11129 u32 outer_fib_id = 0;
11132 memset (&src4, 0, sizeof src4);
11133 memset (&dst4, 0, sizeof dst4);
11134 memset (&src6, 0, sizeof src6);
11135 memset (&dst6, 0, sizeof dst6);
11137 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11139 if (unformat (line_input, "del"))
11141 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
11146 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
11151 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
11156 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
11161 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
11163 else if (unformat (line_input, "teb"))
11167 errmsg ("parse error '%U'", format_unformat_error, line_input);
11174 errmsg ("tunnel src address not specified");
11179 errmsg ("tunnel dst address not specified");
11182 if (ipv4_set && ipv6_set)
11184 errmsg ("both IPv4 and IPv6 addresses specified");
11189 M (GRE_ADD_DEL_TUNNEL, mp);
11193 clib_memcpy (&mp->src_address, &src4, 4);
11194 clib_memcpy (&mp->dst_address, &dst4, 4);
11198 clib_memcpy (&mp->src_address, &src6, 16);
11199 clib_memcpy (&mp->dst_address, &dst6, 16);
11201 mp->outer_fib_id = ntohl (outer_fib_id);
11202 mp->is_add = is_add;
11204 mp->is_ipv6 = ipv6_set;
11211 static void vl_api_gre_tunnel_details_t_handler
11212 (vl_api_gre_tunnel_details_t * mp)
11214 vat_main_t *vam = &vat_main;
11215 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
11216 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
11218 print (vam->ofp, "%11d%24U%24U%6d%14d",
11219 ntohl (mp->sw_if_index),
11220 format_ip46_address, &src, IP46_TYPE_ANY,
11221 format_ip46_address, &dst, IP46_TYPE_ANY,
11222 mp->teb, ntohl (mp->outer_fib_id));
11225 static void vl_api_gre_tunnel_details_t_handler_json
11226 (vl_api_gre_tunnel_details_t * mp)
11228 vat_main_t *vam = &vat_main;
11229 vat_json_node_t *node = NULL;
11230 struct in_addr ip4;
11231 struct in6_addr ip6;
11233 if (VAT_JSON_ARRAY != vam->json_tree.type)
11235 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11236 vat_json_init_array (&vam->json_tree);
11238 node = vat_json_array_add (&vam->json_tree);
11240 vat_json_init_object (node);
11241 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11244 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11245 vat_json_object_add_ip4 (node, "src_address", ip4);
11246 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11247 vat_json_object_add_ip4 (node, "dst_address", ip4);
11251 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
11252 vat_json_object_add_ip6 (node, "src_address", ip6);
11253 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
11254 vat_json_object_add_ip6 (node, "dst_address", ip6);
11256 vat_json_object_add_uint (node, "teb", mp->teb);
11257 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11258 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
11262 api_gre_tunnel_dump (vat_main_t * vam)
11264 unformat_input_t *i = vam->input;
11265 vl_api_gre_tunnel_dump_t *mp;
11266 vl_api_control_ping_t *mp_ping;
11268 u8 sw_if_index_set = 0;
11271 /* Parse args required to build the message */
11272 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11274 if (unformat (i, "sw_if_index %d", &sw_if_index))
11275 sw_if_index_set = 1;
11280 if (sw_if_index_set == 0)
11285 if (!vam->json_output)
11287 print (vam->ofp, "%11s%24s%24s%6s%14s",
11288 "sw_if_index", "src_address", "dst_address", "teb",
11292 /* Get list of gre-tunnel interfaces */
11293 M (GRE_TUNNEL_DUMP, mp);
11295 mp->sw_if_index = htonl (sw_if_index);
11299 /* Use a control ping for synchronization */
11300 M (CONTROL_PING, mp_ping);
11308 api_l2_fib_clear_table (vat_main_t * vam)
11310 // unformat_input_t * i = vam->input;
11311 vl_api_l2_fib_clear_table_t *mp;
11314 M (L2_FIB_CLEAR_TABLE, mp);
11322 api_l2_interface_efp_filter (vat_main_t * vam)
11324 unformat_input_t *i = vam->input;
11325 vl_api_l2_interface_efp_filter_t *mp;
11328 u8 sw_if_index_set = 0;
11331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11333 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11334 sw_if_index_set = 1;
11335 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11336 sw_if_index_set = 1;
11337 else if (unformat (i, "enable"))
11339 else if (unformat (i, "disable"))
11343 clib_warning ("parse error '%U'", format_unformat_error, i);
11348 if (sw_if_index_set == 0)
11350 errmsg ("missing sw_if_index");
11354 M (L2_INTERFACE_EFP_FILTER, mp);
11356 mp->sw_if_index = ntohl (sw_if_index);
11357 mp->enable_disable = enable;
11364 #define foreach_vtr_op \
11365 _("disable", L2_VTR_DISABLED) \
11366 _("push-1", L2_VTR_PUSH_1) \
11367 _("push-2", L2_VTR_PUSH_2) \
11368 _("pop-1", L2_VTR_POP_1) \
11369 _("pop-2", L2_VTR_POP_2) \
11370 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11371 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11372 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11373 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11376 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11378 unformat_input_t *i = vam->input;
11379 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11381 u8 sw_if_index_set = 0;
11384 u32 push_dot1q = 1;
11389 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11391 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11392 sw_if_index_set = 1;
11393 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11394 sw_if_index_set = 1;
11395 else if (unformat (i, "vtr_op %d", &vtr_op))
11397 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11400 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11402 else if (unformat (i, "tag1 %d", &tag1))
11404 else if (unformat (i, "tag2 %d", &tag2))
11408 clib_warning ("parse error '%U'", format_unformat_error, i);
11413 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11415 errmsg ("missing vtr operation or sw_if_index");
11419 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11420 mp->sw_if_index = ntohl (sw_if_index);
11421 mp->vtr_op = ntohl (vtr_op);
11422 mp->push_dot1q = ntohl (push_dot1q);
11423 mp->tag1 = ntohl (tag1);
11424 mp->tag2 = ntohl (tag2);
11432 api_create_vhost_user_if (vat_main_t * vam)
11434 unformat_input_t *i = vam->input;
11435 vl_api_create_vhost_user_if_t *mp;
11438 u8 file_name_set = 0;
11439 u32 custom_dev_instance = ~0;
11441 u8 use_custom_mac = 0;
11445 /* Shut up coverity */
11446 memset (hwaddr, 0, sizeof (hwaddr));
11448 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11450 if (unformat (i, "socket %s", &file_name))
11454 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11456 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11457 use_custom_mac = 1;
11458 else if (unformat (i, "server"))
11460 else if (unformat (i, "tag %s", &tag))
11466 if (file_name_set == 0)
11468 errmsg ("missing socket file name");
11472 if (vec_len (file_name) > 255)
11474 errmsg ("socket file name too long");
11477 vec_add1 (file_name, 0);
11479 M (CREATE_VHOST_USER_IF, mp);
11481 mp->is_server = is_server;
11482 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11483 vec_free (file_name);
11484 if (custom_dev_instance != ~0)
11487 mp->custom_dev_instance = ntohl (custom_dev_instance);
11489 mp->use_custom_mac = use_custom_mac;
11490 clib_memcpy (mp->mac_address, hwaddr, 6);
11492 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11501 api_modify_vhost_user_if (vat_main_t * vam)
11503 unformat_input_t *i = vam->input;
11504 vl_api_modify_vhost_user_if_t *mp;
11507 u8 file_name_set = 0;
11508 u32 custom_dev_instance = ~0;
11509 u8 sw_if_index_set = 0;
11510 u32 sw_if_index = (u32) ~ 0;
11513 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11515 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11516 sw_if_index_set = 1;
11517 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11518 sw_if_index_set = 1;
11519 else if (unformat (i, "socket %s", &file_name))
11523 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11525 else if (unformat (i, "server"))
11531 if (sw_if_index_set == 0)
11533 errmsg ("missing sw_if_index or interface name");
11537 if (file_name_set == 0)
11539 errmsg ("missing socket file name");
11543 if (vec_len (file_name) > 255)
11545 errmsg ("socket file name too long");
11548 vec_add1 (file_name, 0);
11550 M (MODIFY_VHOST_USER_IF, mp);
11552 mp->sw_if_index = ntohl (sw_if_index);
11553 mp->is_server = is_server;
11554 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11555 vec_free (file_name);
11556 if (custom_dev_instance != ~0)
11559 mp->custom_dev_instance = ntohl (custom_dev_instance);
11568 api_delete_vhost_user_if (vat_main_t * vam)
11570 unformat_input_t *i = vam->input;
11571 vl_api_delete_vhost_user_if_t *mp;
11572 u32 sw_if_index = ~0;
11573 u8 sw_if_index_set = 0;
11576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11578 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11579 sw_if_index_set = 1;
11580 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11581 sw_if_index_set = 1;
11586 if (sw_if_index_set == 0)
11588 errmsg ("missing sw_if_index or interface name");
11593 M (DELETE_VHOST_USER_IF, mp);
11595 mp->sw_if_index = ntohl (sw_if_index);
11602 static void vl_api_sw_interface_vhost_user_details_t_handler
11603 (vl_api_sw_interface_vhost_user_details_t * mp)
11605 vat_main_t *vam = &vat_main;
11607 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11608 (char *) mp->interface_name,
11609 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11610 clib_net_to_host_u64 (mp->features), mp->is_server,
11611 ntohl (mp->num_regions), (char *) mp->sock_filename);
11612 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11615 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11616 (vl_api_sw_interface_vhost_user_details_t * mp)
11618 vat_main_t *vam = &vat_main;
11619 vat_json_node_t *node = NULL;
11621 if (VAT_JSON_ARRAY != vam->json_tree.type)
11623 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11624 vat_json_init_array (&vam->json_tree);
11626 node = vat_json_array_add (&vam->json_tree);
11628 vat_json_init_object (node);
11629 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11630 vat_json_object_add_string_copy (node, "interface_name",
11631 mp->interface_name);
11632 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11633 ntohl (mp->virtio_net_hdr_sz));
11634 vat_json_object_add_uint (node, "features",
11635 clib_net_to_host_u64 (mp->features));
11636 vat_json_object_add_uint (node, "is_server", mp->is_server);
11637 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11638 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11639 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11643 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11645 vl_api_sw_interface_vhost_user_dump_t *mp;
11646 vl_api_control_ping_t *mp_ping;
11649 "Interface name idx hdr_sz features server regions filename");
11651 /* Get list of vhost-user interfaces */
11652 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11655 /* Use a control ping for synchronization */
11656 M (CONTROL_PING, mp_ping);
11664 api_show_version (vat_main_t * vam)
11666 vl_api_show_version_t *mp;
11669 M (SHOW_VERSION, mp);
11678 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11680 unformat_input_t *line_input = vam->input;
11681 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11682 ip4_address_t local4, remote4;
11683 ip6_address_t local6, remote6;
11685 u8 ipv4_set = 0, ipv6_set = 0;
11688 u32 encap_vrf_id = 0;
11689 u32 decap_vrf_id = 0;
11695 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11697 if (unformat (line_input, "del"))
11699 else if (unformat (line_input, "local %U",
11700 unformat_ip4_address, &local4))
11705 else if (unformat (line_input, "remote %U",
11706 unformat_ip4_address, &remote4))
11711 else if (unformat (line_input, "local %U",
11712 unformat_ip6_address, &local6))
11717 else if (unformat (line_input, "remote %U",
11718 unformat_ip6_address, &remote6))
11723 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11725 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11727 else if (unformat (line_input, "vni %d", &vni))
11729 else if (unformat (line_input, "next-ip4"))
11731 else if (unformat (line_input, "next-ip6"))
11733 else if (unformat (line_input, "next-ethernet"))
11735 else if (unformat (line_input, "next-nsh"))
11739 errmsg ("parse error '%U'", format_unformat_error, line_input);
11744 if (local_set == 0)
11746 errmsg ("tunnel local address not specified");
11749 if (remote_set == 0)
11751 errmsg ("tunnel remote address not specified");
11754 if (ipv4_set && ipv6_set)
11756 errmsg ("both IPv4 and IPv6 addresses specified");
11762 errmsg ("vni not specified");
11766 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11771 clib_memcpy (&mp->local, &local6, sizeof (local6));
11772 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11776 clib_memcpy (&mp->local, &local4, sizeof (local4));
11777 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11780 mp->encap_vrf_id = ntohl (encap_vrf_id);
11781 mp->decap_vrf_id = ntohl (decap_vrf_id);
11782 mp->protocol = protocol;
11783 mp->vni = ntohl (vni);
11784 mp->is_add = is_add;
11785 mp->is_ipv6 = ipv6_set;
11792 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11793 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11795 vat_main_t *vam = &vat_main;
11797 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11798 ntohl (mp->sw_if_index),
11799 format_ip46_address, &(mp->local[0]),
11800 format_ip46_address, &(mp->remote[0]),
11802 ntohl (mp->protocol),
11803 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11806 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11807 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11809 vat_main_t *vam = &vat_main;
11810 vat_json_node_t *node = NULL;
11811 struct in_addr ip4;
11812 struct in6_addr ip6;
11814 if (VAT_JSON_ARRAY != vam->json_tree.type)
11816 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11817 vat_json_init_array (&vam->json_tree);
11819 node = vat_json_array_add (&vam->json_tree);
11821 vat_json_init_object (node);
11822 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11825 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11826 vat_json_object_add_ip6 (node, "local", ip6);
11827 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11828 vat_json_object_add_ip6 (node, "remote", ip6);
11832 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11833 vat_json_object_add_ip4 (node, "local", ip4);
11834 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11835 vat_json_object_add_ip4 (node, "remote", ip4);
11837 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11838 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11839 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11840 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11841 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11845 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11847 unformat_input_t *i = vam->input;
11848 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11849 vl_api_control_ping_t *mp_ping;
11851 u8 sw_if_index_set = 0;
11854 /* Parse args required to build the message */
11855 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11857 if (unformat (i, "sw_if_index %d", &sw_if_index))
11858 sw_if_index_set = 1;
11863 if (sw_if_index_set == 0)
11868 if (!vam->json_output)
11870 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11871 "sw_if_index", "local", "remote", "vni",
11872 "protocol", "encap_vrf_id", "decap_vrf_id");
11875 /* Get list of vxlan-tunnel interfaces */
11876 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11878 mp->sw_if_index = htonl (sw_if_index);
11882 /* Use a control ping for synchronization */
11883 M (CONTROL_PING, mp_ping);
11891 format_l2_fib_mac_address (u8 * s, va_list * args)
11893 u8 *a = va_arg (*args, u8 *);
11895 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11896 a[2], a[3], a[4], a[5], a[6], a[7]);
11899 static void vl_api_l2_fib_table_details_t_handler
11900 (vl_api_l2_fib_table_details_t * mp)
11902 vat_main_t *vam = &vat_main;
11904 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11906 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11907 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11911 static void vl_api_l2_fib_table_details_t_handler_json
11912 (vl_api_l2_fib_table_details_t * mp)
11914 vat_main_t *vam = &vat_main;
11915 vat_json_node_t *node = NULL;
11917 if (VAT_JSON_ARRAY != vam->json_tree.type)
11919 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11920 vat_json_init_array (&vam->json_tree);
11922 node = vat_json_array_add (&vam->json_tree);
11924 vat_json_init_object (node);
11925 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11926 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11927 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11928 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11929 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11930 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11934 api_l2_fib_table_dump (vat_main_t * vam)
11936 unformat_input_t *i = vam->input;
11937 vl_api_l2_fib_table_dump_t *mp;
11938 vl_api_control_ping_t *mp_ping;
11943 /* Parse args required to build the message */
11944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11946 if (unformat (i, "bd_id %d", &bd_id))
11952 if (bd_id_set == 0)
11954 errmsg ("missing bridge domain");
11958 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11960 /* Get list of l2 fib entries */
11961 M (L2_FIB_TABLE_DUMP, mp);
11963 mp->bd_id = ntohl (bd_id);
11966 /* Use a control ping for synchronization */
11967 M (CONTROL_PING, mp_ping);
11976 api_interface_name_renumber (vat_main_t * vam)
11978 unformat_input_t *line_input = vam->input;
11979 vl_api_interface_name_renumber_t *mp;
11980 u32 sw_if_index = ~0;
11981 u32 new_show_dev_instance = ~0;
11984 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11986 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11989 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11991 else if (unformat (line_input, "new_show_dev_instance %d",
11992 &new_show_dev_instance))
11998 if (sw_if_index == ~0)
12000 errmsg ("missing interface name or sw_if_index");
12004 if (new_show_dev_instance == ~0)
12006 errmsg ("missing new_show_dev_instance");
12010 M (INTERFACE_NAME_RENUMBER, mp);
12012 mp->sw_if_index = ntohl (sw_if_index);
12013 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
12021 api_want_ip4_arp_events (vat_main_t * vam)
12023 unformat_input_t *line_input = vam->input;
12024 vl_api_want_ip4_arp_events_t *mp;
12025 ip4_address_t address;
12026 int address_set = 0;
12027 u32 enable_disable = 1;
12030 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12032 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
12034 else if (unformat (line_input, "del"))
12035 enable_disable = 0;
12040 if (address_set == 0)
12042 errmsg ("missing addresses");
12046 M (WANT_IP4_ARP_EVENTS, mp);
12047 mp->enable_disable = enable_disable;
12048 mp->pid = htonl (getpid ());
12049 mp->address = address.as_u32;
12057 api_want_ip6_nd_events (vat_main_t * vam)
12059 unformat_input_t *line_input = vam->input;
12060 vl_api_want_ip6_nd_events_t *mp;
12061 ip6_address_t address;
12062 int address_set = 0;
12063 u32 enable_disable = 1;
12066 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12068 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
12070 else if (unformat (line_input, "del"))
12071 enable_disable = 0;
12076 if (address_set == 0)
12078 errmsg ("missing addresses");
12082 M (WANT_IP6_ND_EVENTS, mp);
12083 mp->enable_disable = enable_disable;
12084 mp->pid = htonl (getpid ());
12085 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
12093 api_input_acl_set_interface (vat_main_t * vam)
12095 unformat_input_t *i = vam->input;
12096 vl_api_input_acl_set_interface_t *mp;
12098 int sw_if_index_set;
12099 u32 ip4_table_index = ~0;
12100 u32 ip6_table_index = ~0;
12101 u32 l2_table_index = ~0;
12105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12107 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12108 sw_if_index_set = 1;
12109 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12110 sw_if_index_set = 1;
12111 else if (unformat (i, "del"))
12113 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12115 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12117 else if (unformat (i, "l2-table %d", &l2_table_index))
12121 clib_warning ("parse error '%U'", format_unformat_error, i);
12126 if (sw_if_index_set == 0)
12128 errmsg ("missing interface name or sw_if_index");
12132 M (INPUT_ACL_SET_INTERFACE, mp);
12134 mp->sw_if_index = ntohl (sw_if_index);
12135 mp->ip4_table_index = ntohl (ip4_table_index);
12136 mp->ip6_table_index = ntohl (ip6_table_index);
12137 mp->l2_table_index = ntohl (l2_table_index);
12138 mp->is_add = is_add;
12146 api_ip_address_dump (vat_main_t * vam)
12148 unformat_input_t *i = vam->input;
12149 vl_api_ip_address_dump_t *mp;
12150 vl_api_control_ping_t *mp_ping;
12151 u32 sw_if_index = ~0;
12152 u8 sw_if_index_set = 0;
12157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12159 if (unformat (i, "sw_if_index %d", &sw_if_index))
12160 sw_if_index_set = 1;
12162 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12163 sw_if_index_set = 1;
12164 else if (unformat (i, "ipv4"))
12166 else if (unformat (i, "ipv6"))
12172 if (ipv4_set && ipv6_set)
12174 errmsg ("ipv4 and ipv6 flags cannot be both set");
12178 if ((!ipv4_set) && (!ipv6_set))
12180 errmsg ("no ipv4 nor ipv6 flag set");
12184 if (sw_if_index_set == 0)
12186 errmsg ("missing interface name or sw_if_index");
12190 vam->current_sw_if_index = sw_if_index;
12191 vam->is_ipv6 = ipv6_set;
12193 M (IP_ADDRESS_DUMP, mp);
12194 mp->sw_if_index = ntohl (sw_if_index);
12195 mp->is_ipv6 = ipv6_set;
12198 /* Use a control ping for synchronization */
12199 M (CONTROL_PING, mp_ping);
12207 api_ip_dump (vat_main_t * vam)
12209 vl_api_ip_dump_t *mp;
12210 vl_api_control_ping_t *mp_ping;
12211 unformat_input_t *in = vam->input;
12218 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
12220 if (unformat (in, "ipv4"))
12222 else if (unformat (in, "ipv6"))
12228 if (ipv4_set && ipv6_set)
12230 errmsg ("ipv4 and ipv6 flags cannot be both set");
12234 if ((!ipv4_set) && (!ipv6_set))
12236 errmsg ("no ipv4 nor ipv6 flag set");
12240 is_ipv6 = ipv6_set;
12241 vam->is_ipv6 = is_ipv6;
12243 /* free old data */
12244 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12246 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12248 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12251 mp->is_ipv6 = ipv6_set;
12254 /* Use a control ping for synchronization */
12255 M (CONTROL_PING, mp_ping);
12263 api_ipsec_spd_add_del (vat_main_t * vam)
12265 unformat_input_t *i = vam->input;
12266 vl_api_ipsec_spd_add_del_t *mp;
12271 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12273 if (unformat (i, "spd_id %d", &spd_id))
12275 else if (unformat (i, "del"))
12279 clib_warning ("parse error '%U'", format_unformat_error, i);
12285 errmsg ("spd_id must be set");
12289 M (IPSEC_SPD_ADD_DEL, mp);
12291 mp->spd_id = ntohl (spd_id);
12292 mp->is_add = is_add;
12300 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12302 unformat_input_t *i = vam->input;
12303 vl_api_ipsec_interface_add_del_spd_t *mp;
12305 u8 sw_if_index_set = 0;
12306 u32 spd_id = (u32) ~ 0;
12310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12312 if (unformat (i, "del"))
12314 else if (unformat (i, "spd_id %d", &spd_id))
12317 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12318 sw_if_index_set = 1;
12319 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12320 sw_if_index_set = 1;
12323 clib_warning ("parse error '%U'", format_unformat_error, i);
12329 if (spd_id == (u32) ~ 0)
12331 errmsg ("spd_id must be set");
12335 if (sw_if_index_set == 0)
12337 errmsg ("missing interface name or sw_if_index");
12341 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12343 mp->spd_id = ntohl (spd_id);
12344 mp->sw_if_index = ntohl (sw_if_index);
12345 mp->is_add = is_add;
12353 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12355 unformat_input_t *i = vam->input;
12356 vl_api_ipsec_spd_add_del_entry_t *mp;
12357 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12358 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12360 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12361 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12362 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12363 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12366 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12367 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12368 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12369 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12370 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12371 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12373 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12375 if (unformat (i, "del"))
12377 if (unformat (i, "outbound"))
12379 if (unformat (i, "inbound"))
12381 else if (unformat (i, "spd_id %d", &spd_id))
12383 else if (unformat (i, "sa_id %d", &sa_id))
12385 else if (unformat (i, "priority %d", &priority))
12387 else if (unformat (i, "protocol %d", &protocol))
12389 else if (unformat (i, "lport_start %d", &lport_start))
12391 else if (unformat (i, "lport_stop %d", &lport_stop))
12393 else if (unformat (i, "rport_start %d", &rport_start))
12395 else if (unformat (i, "rport_stop %d", &rport_stop))
12399 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12405 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12412 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12418 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12425 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12431 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12438 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12444 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12450 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12452 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12454 clib_warning ("unsupported action: 'resolve'");
12460 clib_warning ("parse error '%U'", format_unformat_error, i);
12466 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12468 mp->spd_id = ntohl (spd_id);
12469 mp->priority = ntohl (priority);
12470 mp->is_outbound = is_outbound;
12472 mp->is_ipv6 = is_ipv6;
12473 if (is_ipv6 || is_ip_any)
12475 clib_memcpy (mp->remote_address_start, &raddr6_start,
12476 sizeof (ip6_address_t));
12477 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12478 sizeof (ip6_address_t));
12479 clib_memcpy (mp->local_address_start, &laddr6_start,
12480 sizeof (ip6_address_t));
12481 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12482 sizeof (ip6_address_t));
12486 clib_memcpy (mp->remote_address_start, &raddr4_start,
12487 sizeof (ip4_address_t));
12488 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12489 sizeof (ip4_address_t));
12490 clib_memcpy (mp->local_address_start, &laddr4_start,
12491 sizeof (ip4_address_t));
12492 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12493 sizeof (ip4_address_t));
12495 mp->protocol = (u8) protocol;
12496 mp->local_port_start = ntohs ((u16) lport_start);
12497 mp->local_port_stop = ntohs ((u16) lport_stop);
12498 mp->remote_port_start = ntohs ((u16) rport_start);
12499 mp->remote_port_stop = ntohs ((u16) rport_stop);
12500 mp->policy = (u8) policy;
12501 mp->sa_id = ntohl (sa_id);
12502 mp->is_add = is_add;
12503 mp->is_ip_any = is_ip_any;
12510 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12512 unformat_input_t *i = vam->input;
12513 vl_api_ipsec_sad_add_del_entry_t *mp;
12514 u32 sad_id = 0, spi = 0;
12515 u8 *ck = 0, *ik = 0;
12518 u8 protocol = IPSEC_PROTOCOL_AH;
12519 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12520 u32 crypto_alg = 0, integ_alg = 0;
12521 ip4_address_t tun_src4;
12522 ip4_address_t tun_dst4;
12523 ip6_address_t tun_src6;
12524 ip6_address_t tun_dst6;
12527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12529 if (unformat (i, "del"))
12531 else if (unformat (i, "sad_id %d", &sad_id))
12533 else if (unformat (i, "spi %d", &spi))
12535 else if (unformat (i, "esp"))
12536 protocol = IPSEC_PROTOCOL_ESP;
12537 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12540 is_tunnel_ipv6 = 0;
12542 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12545 is_tunnel_ipv6 = 0;
12547 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12550 is_tunnel_ipv6 = 1;
12552 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12555 is_tunnel_ipv6 = 1;
12559 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12561 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12562 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12564 clib_warning ("unsupported crypto-alg: '%U'",
12565 format_ipsec_crypto_alg, crypto_alg);
12569 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12573 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12575 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12576 integ_alg >= IPSEC_INTEG_N_ALG)
12578 clib_warning ("unsupported integ-alg: '%U'",
12579 format_ipsec_integ_alg, integ_alg);
12583 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12587 clib_warning ("parse error '%U'", format_unformat_error, i);
12593 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12595 mp->sad_id = ntohl (sad_id);
12596 mp->is_add = is_add;
12597 mp->protocol = protocol;
12598 mp->spi = ntohl (spi);
12599 mp->is_tunnel = is_tunnel;
12600 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12601 mp->crypto_algorithm = crypto_alg;
12602 mp->integrity_algorithm = integ_alg;
12603 mp->crypto_key_length = vec_len (ck);
12604 mp->integrity_key_length = vec_len (ik);
12606 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12607 mp->crypto_key_length = sizeof (mp->crypto_key);
12609 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12610 mp->integrity_key_length = sizeof (mp->integrity_key);
12613 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12615 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12619 if (is_tunnel_ipv6)
12621 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12622 sizeof (ip6_address_t));
12623 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12624 sizeof (ip6_address_t));
12628 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12629 sizeof (ip4_address_t));
12630 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12631 sizeof (ip4_address_t));
12641 api_ipsec_sa_set_key (vat_main_t * vam)
12643 unformat_input_t *i = vam->input;
12644 vl_api_ipsec_sa_set_key_t *mp;
12646 u8 *ck = 0, *ik = 0;
12649 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12651 if (unformat (i, "sa_id %d", &sa_id))
12653 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12655 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12659 clib_warning ("parse error '%U'", format_unformat_error, i);
12664 M (IPSEC_SA_SET_KEY, mp);
12666 mp->sa_id = ntohl (sa_id);
12667 mp->crypto_key_length = vec_len (ck);
12668 mp->integrity_key_length = vec_len (ik);
12670 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12671 mp->crypto_key_length = sizeof (mp->crypto_key);
12673 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12674 mp->integrity_key_length = sizeof (mp->integrity_key);
12677 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12679 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12687 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
12689 unformat_input_t *i = vam->input;
12690 vl_api_ipsec_tunnel_if_add_del_t *mp;
12691 u32 local_spi = 0, remote_spi = 0;
12692 u32 crypto_alg = 0, integ_alg = 0;
12693 u8 *lck = NULL, *rck = NULL;
12694 u8 *lik = NULL, *rik = NULL;
12695 ip4_address_t local_ip = { {0} };
12696 ip4_address_t remote_ip = { {0} };
12699 u8 anti_replay = 0;
12702 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12704 if (unformat (i, "del"))
12706 else if (unformat (i, "esn"))
12708 else if (unformat (i, "anti_replay"))
12710 else if (unformat (i, "local_spi %d", &local_spi))
12712 else if (unformat (i, "remote_spi %d", &remote_spi))
12714 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
12716 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
12718 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
12721 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
12723 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
12725 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
12729 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12731 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12732 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12734 errmsg ("unsupported crypto-alg: '%U'\n",
12735 format_ipsec_crypto_alg, crypto_alg);
12741 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12743 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12744 integ_alg >= IPSEC_INTEG_N_ALG)
12746 errmsg ("unsupported integ-alg: '%U'\n",
12747 format_ipsec_integ_alg, integ_alg);
12753 errmsg ("parse error '%U'\n", format_unformat_error, i);
12758 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
12760 mp->is_add = is_add;
12762 mp->anti_replay = anti_replay;
12764 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
12765 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
12767 mp->local_spi = htonl (local_spi);
12768 mp->remote_spi = htonl (remote_spi);
12769 mp->crypto_alg = (u8) crypto_alg;
12771 mp->local_crypto_key_len = 0;
12774 mp->local_crypto_key_len = vec_len (lck);
12775 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
12776 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
12777 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
12780 mp->remote_crypto_key_len = 0;
12783 mp->remote_crypto_key_len = vec_len (rck);
12784 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
12785 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
12786 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
12789 mp->integ_alg = (u8) integ_alg;
12791 mp->local_integ_key_len = 0;
12794 mp->local_integ_key_len = vec_len (lik);
12795 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
12796 mp->local_integ_key_len = sizeof (mp->local_integ_key);
12797 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
12800 mp->remote_integ_key_len = 0;
12803 mp->remote_integ_key_len = vec_len (rik);
12804 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
12805 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
12806 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
12815 api_ikev2_profile_add_del (vat_main_t * vam)
12817 unformat_input_t *i = vam->input;
12818 vl_api_ikev2_profile_add_del_t *mp;
12823 const char *valid_chars = "a-zA-Z0-9_";
12825 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12827 if (unformat (i, "del"))
12829 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12830 vec_add1 (name, 0);
12833 errmsg ("parse error '%U'", format_unformat_error, i);
12838 if (!vec_len (name))
12840 errmsg ("profile name must be specified");
12844 if (vec_len (name) > 64)
12846 errmsg ("profile name too long");
12850 M (IKEV2_PROFILE_ADD_DEL, mp);
12852 clib_memcpy (mp->name, name, vec_len (name));
12853 mp->is_add = is_add;
12862 api_ikev2_profile_set_auth (vat_main_t * vam)
12864 unformat_input_t *i = vam->input;
12865 vl_api_ikev2_profile_set_auth_t *mp;
12868 u32 auth_method = 0;
12872 const char *valid_chars = "a-zA-Z0-9_";
12874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12876 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12877 vec_add1 (name, 0);
12878 else if (unformat (i, "auth_method %U",
12879 unformat_ikev2_auth_method, &auth_method))
12881 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12883 else if (unformat (i, "auth_data %v", &data))
12887 errmsg ("parse error '%U'", format_unformat_error, i);
12892 if (!vec_len (name))
12894 errmsg ("profile name must be specified");
12898 if (vec_len (name) > 64)
12900 errmsg ("profile name too long");
12904 if (!vec_len (data))
12906 errmsg ("auth_data must be specified");
12912 errmsg ("auth_method must be specified");
12916 M (IKEV2_PROFILE_SET_AUTH, mp);
12918 mp->is_hex = is_hex;
12919 mp->auth_method = (u8) auth_method;
12920 mp->data_len = vec_len (data);
12921 clib_memcpy (mp->name, name, vec_len (name));
12922 clib_memcpy (mp->data, data, vec_len (data));
12932 api_ikev2_profile_set_id (vat_main_t * vam)
12934 unformat_input_t *i = vam->input;
12935 vl_api_ikev2_profile_set_id_t *mp;
12943 const char *valid_chars = "a-zA-Z0-9_";
12945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12947 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12948 vec_add1 (name, 0);
12949 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12951 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12953 data = vec_new (u8, 4);
12954 clib_memcpy (data, ip4.as_u8, 4);
12956 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12958 else if (unformat (i, "id_data %v", &data))
12960 else if (unformat (i, "local"))
12962 else if (unformat (i, "remote"))
12966 errmsg ("parse error '%U'", format_unformat_error, i);
12971 if (!vec_len (name))
12973 errmsg ("profile name must be specified");
12977 if (vec_len (name) > 64)
12979 errmsg ("profile name too long");
12983 if (!vec_len (data))
12985 errmsg ("id_data must be specified");
12991 errmsg ("id_type must be specified");
12995 M (IKEV2_PROFILE_SET_ID, mp);
12997 mp->is_local = is_local;
12998 mp->id_type = (u8) id_type;
12999 mp->data_len = vec_len (data);
13000 clib_memcpy (mp->name, name, vec_len (name));
13001 clib_memcpy (mp->data, data, vec_len (data));
13011 api_ikev2_profile_set_ts (vat_main_t * vam)
13013 unformat_input_t *i = vam->input;
13014 vl_api_ikev2_profile_set_ts_t *mp;
13017 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
13018 ip4_address_t start_addr, end_addr;
13020 const char *valid_chars = "a-zA-Z0-9_";
13023 start_addr.as_u32 = 0;
13024 end_addr.as_u32 = (u32) ~ 0;
13026 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13028 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13029 vec_add1 (name, 0);
13030 else if (unformat (i, "protocol %d", &proto))
13032 else if (unformat (i, "start_port %d", &start_port))
13034 else if (unformat (i, "end_port %d", &end_port))
13037 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
13039 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
13041 else if (unformat (i, "local"))
13043 else if (unformat (i, "remote"))
13047 errmsg ("parse error '%U'", format_unformat_error, i);
13052 if (!vec_len (name))
13054 errmsg ("profile name must be specified");
13058 if (vec_len (name) > 64)
13060 errmsg ("profile name too long");
13064 M (IKEV2_PROFILE_SET_TS, mp);
13066 mp->is_local = is_local;
13067 mp->proto = (u8) proto;
13068 mp->start_port = (u16) start_port;
13069 mp->end_port = (u16) end_port;
13070 mp->start_addr = start_addr.as_u32;
13071 mp->end_addr = end_addr.as_u32;
13072 clib_memcpy (mp->name, name, vec_len (name));
13081 api_ikev2_set_local_key (vat_main_t * vam)
13083 unformat_input_t *i = vam->input;
13084 vl_api_ikev2_set_local_key_t *mp;
13088 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13090 if (unformat (i, "file %v", &file))
13091 vec_add1 (file, 0);
13094 errmsg ("parse error '%U'", format_unformat_error, i);
13099 if (!vec_len (file))
13101 errmsg ("RSA key file must be specified");
13105 if (vec_len (file) > 256)
13107 errmsg ("file name too long");
13111 M (IKEV2_SET_LOCAL_KEY, mp);
13113 clib_memcpy (mp->key_file, file, vec_len (file));
13122 api_ikev2_set_responder (vat_main_t * vam)
13124 unformat_input_t *i = vam->input;
13125 vl_api_ikev2_set_responder_t *mp;
13128 u32 sw_if_index = ~0;
13129 ip4_address_t address;
13131 const char *valid_chars = "a-zA-Z0-9_";
13133 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13136 (i, "%U interface %d address %U", unformat_token, valid_chars,
13137 &name, &sw_if_index, unformat_ip4_address, &address))
13138 vec_add1 (name, 0);
13141 errmsg ("parse error '%U'", format_unformat_error, i);
13146 if (!vec_len (name))
13148 errmsg ("profile name must be specified");
13152 if (vec_len (name) > 64)
13154 errmsg ("profile name too long");
13158 M (IKEV2_SET_RESPONDER, mp);
13160 clib_memcpy (mp->name, name, vec_len (name));
13163 mp->sw_if_index = sw_if_index;
13164 clib_memcpy (mp->address, &address, sizeof (address));
13172 api_ikev2_set_ike_transforms (vat_main_t * vam)
13174 unformat_input_t *i = vam->input;
13175 vl_api_ikev2_set_ike_transforms_t *mp;
13178 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13180 const char *valid_chars = "a-zA-Z0-9_";
13182 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13184 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13185 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13186 vec_add1 (name, 0);
13189 errmsg ("parse error '%U'", format_unformat_error, i);
13194 if (!vec_len (name))
13196 errmsg ("profile name must be specified");
13200 if (vec_len (name) > 64)
13202 errmsg ("profile name too long");
13206 M (IKEV2_SET_IKE_TRANSFORMS, mp);
13208 clib_memcpy (mp->name, name, vec_len (name));
13210 mp->crypto_alg = crypto_alg;
13211 mp->crypto_key_size = crypto_key_size;
13212 mp->integ_alg = integ_alg;
13213 mp->dh_group = dh_group;
13222 api_ikev2_set_esp_transforms (vat_main_t * vam)
13224 unformat_input_t *i = vam->input;
13225 vl_api_ikev2_set_esp_transforms_t *mp;
13228 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13230 const char *valid_chars = "a-zA-Z0-9_";
13232 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13234 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13235 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13236 vec_add1 (name, 0);
13239 errmsg ("parse error '%U'", format_unformat_error, i);
13244 if (!vec_len (name))
13246 errmsg ("profile name must be specified");
13250 if (vec_len (name) > 64)
13252 errmsg ("profile name too long");
13256 M (IKEV2_SET_ESP_TRANSFORMS, mp);
13258 clib_memcpy (mp->name, name, vec_len (name));
13260 mp->crypto_alg = crypto_alg;
13261 mp->crypto_key_size = crypto_key_size;
13262 mp->integ_alg = integ_alg;
13263 mp->dh_group = dh_group;
13271 api_ikev2_set_sa_lifetime (vat_main_t * vam)
13273 unformat_input_t *i = vam->input;
13274 vl_api_ikev2_set_sa_lifetime_t *mp;
13277 u64 lifetime, lifetime_maxdata;
13278 u32 lifetime_jitter, handover;
13280 const char *valid_chars = "a-zA-Z0-9_";
13282 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13284 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
13285 &lifetime, &lifetime_jitter, &handover,
13286 &lifetime_maxdata))
13287 vec_add1 (name, 0);
13290 errmsg ("parse error '%U'", format_unformat_error, i);
13295 if (!vec_len (name))
13297 errmsg ("profile name must be specified");
13301 if (vec_len (name) > 64)
13303 errmsg ("profile name too long");
13307 M (IKEV2_SET_SA_LIFETIME, mp);
13309 clib_memcpy (mp->name, name, vec_len (name));
13311 mp->lifetime = lifetime;
13312 mp->lifetime_jitter = lifetime_jitter;
13313 mp->handover = handover;
13314 mp->lifetime_maxdata = lifetime_maxdata;
13322 api_ikev2_initiate_sa_init (vat_main_t * vam)
13324 unformat_input_t *i = vam->input;
13325 vl_api_ikev2_initiate_sa_init_t *mp;
13329 const char *valid_chars = "a-zA-Z0-9_";
13331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13333 if (unformat (i, "%U", unformat_token, valid_chars, &name))
13334 vec_add1 (name, 0);
13337 errmsg ("parse error '%U'", format_unformat_error, i);
13342 if (!vec_len (name))
13344 errmsg ("profile name must be specified");
13348 if (vec_len (name) > 64)
13350 errmsg ("profile name too long");
13354 M (IKEV2_INITIATE_SA_INIT, mp);
13356 clib_memcpy (mp->name, name, vec_len (name));
13365 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
13367 unformat_input_t *i = vam->input;
13368 vl_api_ikev2_initiate_del_ike_sa_t *mp;
13373 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13375 if (unformat (i, "%lx", &ispi))
13379 errmsg ("parse error '%U'", format_unformat_error, i);
13384 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
13394 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13396 unformat_input_t *i = vam->input;
13397 vl_api_ikev2_initiate_del_child_sa_t *mp;
13402 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13404 if (unformat (i, "%x", &ispi))
13408 errmsg ("parse error '%U'", format_unformat_error, i);
13413 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13423 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13425 unformat_input_t *i = vam->input;
13426 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13431 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13433 if (unformat (i, "%x", &ispi))
13437 errmsg ("parse error '%U'", format_unformat_error, i);
13442 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
13455 api_map_add_domain (vat_main_t * vam)
13457 unformat_input_t *i = vam->input;
13458 vl_api_map_add_domain_t *mp;
13460 ip4_address_t ip4_prefix;
13461 ip6_address_t ip6_prefix;
13462 ip6_address_t ip6_src;
13463 u32 num_m_args = 0;
13464 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
13465 0, psid_length = 0;
13466 u8 is_translation = 0;
13468 u32 ip6_src_len = 128;
13471 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13473 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
13474 &ip4_prefix, &ip4_prefix_len))
13476 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
13477 &ip6_prefix, &ip6_prefix_len))
13481 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
13484 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
13486 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
13488 else if (unformat (i, "psid-offset %d", &psid_offset))
13490 else if (unformat (i, "psid-len %d", &psid_length))
13492 else if (unformat (i, "mtu %d", &mtu))
13494 else if (unformat (i, "map-t"))
13495 is_translation = 1;
13498 clib_warning ("parse error '%U'", format_unformat_error, i);
13503 if (num_m_args < 3)
13505 errmsg ("mandatory argument(s) missing");
13509 /* Construct the API message */
13510 M (MAP_ADD_DOMAIN, mp);
13512 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
13513 mp->ip4_prefix_len = ip4_prefix_len;
13515 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
13516 mp->ip6_prefix_len = ip6_prefix_len;
13518 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
13519 mp->ip6_src_prefix_len = ip6_src_len;
13521 mp->ea_bits_len = ea_bits_len;
13522 mp->psid_offset = psid_offset;
13523 mp->psid_length = psid_length;
13524 mp->is_translation = is_translation;
13525 mp->mtu = htons (mtu);
13530 /* Wait for a reply, return good/bad news */
13536 api_map_del_domain (vat_main_t * vam)
13538 unformat_input_t *i = vam->input;
13539 vl_api_map_del_domain_t *mp;
13541 u32 num_m_args = 0;
13545 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13547 if (unformat (i, "index %d", &index))
13551 clib_warning ("parse error '%U'", format_unformat_error, i);
13556 if (num_m_args != 1)
13558 errmsg ("mandatory argument(s) missing");
13562 /* Construct the API message */
13563 M (MAP_DEL_DOMAIN, mp);
13565 mp->index = ntohl (index);
13570 /* Wait for a reply, return good/bad news */
13576 api_map_add_del_rule (vat_main_t * vam)
13578 unformat_input_t *i = vam->input;
13579 vl_api_map_add_del_rule_t *mp;
13581 ip6_address_t ip6_dst;
13582 u32 num_m_args = 0, index, psid = 0;
13585 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13587 if (unformat (i, "index %d", &index))
13589 else if (unformat (i, "psid %d", &psid))
13591 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13593 else if (unformat (i, "del"))
13599 clib_warning ("parse error '%U'", format_unformat_error, i);
13604 /* Construct the API message */
13605 M (MAP_ADD_DEL_RULE, mp);
13607 mp->index = ntohl (index);
13608 mp->is_add = is_add;
13609 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13610 mp->psid = ntohs (psid);
13615 /* Wait for a reply, return good/bad news */
13621 api_map_domain_dump (vat_main_t * vam)
13623 vl_api_map_domain_dump_t *mp;
13624 vl_api_control_ping_t *mp_ping;
13627 /* Construct the API message */
13628 M (MAP_DOMAIN_DUMP, mp);
13633 /* Use a control ping for synchronization */
13634 M (CONTROL_PING, mp_ping);
13642 api_map_rule_dump (vat_main_t * vam)
13644 unformat_input_t *i = vam->input;
13645 vl_api_map_rule_dump_t *mp;
13646 vl_api_control_ping_t *mp_ping;
13647 u32 domain_index = ~0;
13650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13652 if (unformat (i, "index %u", &domain_index))
13658 if (domain_index == ~0)
13660 clib_warning ("parse error: domain index expected");
13664 /* Construct the API message */
13665 M (MAP_RULE_DUMP, mp);
13667 mp->domain_index = htonl (domain_index);
13672 /* Use a control ping for synchronization */
13673 M (CONTROL_PING, mp_ping);
13680 static void vl_api_map_add_domain_reply_t_handler
13681 (vl_api_map_add_domain_reply_t * mp)
13683 vat_main_t *vam = &vat_main;
13684 i32 retval = ntohl (mp->retval);
13686 if (vam->async_mode)
13688 vam->async_errors += (retval < 0);
13692 vam->retval = retval;
13693 vam->result_ready = 1;
13697 static void vl_api_map_add_domain_reply_t_handler_json
13698 (vl_api_map_add_domain_reply_t * mp)
13700 vat_main_t *vam = &vat_main;
13701 vat_json_node_t node;
13703 vat_json_init_object (&node);
13704 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13705 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13707 vat_json_print (vam->ofp, &node);
13708 vat_json_free (&node);
13710 vam->retval = ntohl (mp->retval);
13711 vam->result_ready = 1;
13715 api_get_first_msg_id (vat_main_t * vam)
13717 vl_api_get_first_msg_id_t *mp;
13718 unformat_input_t *i = vam->input;
13723 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13725 if (unformat (i, "client %s", &name))
13733 errmsg ("missing client name");
13736 vec_add1 (name, 0);
13738 if (vec_len (name) > 63)
13740 errmsg ("client name too long");
13744 M (GET_FIRST_MSG_ID, mp);
13745 clib_memcpy (mp->name, name, vec_len (name));
13752 api_cop_interface_enable_disable (vat_main_t * vam)
13754 unformat_input_t *line_input = vam->input;
13755 vl_api_cop_interface_enable_disable_t *mp;
13756 u32 sw_if_index = ~0;
13757 u8 enable_disable = 1;
13760 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13762 if (unformat (line_input, "disable"))
13763 enable_disable = 0;
13764 if (unformat (line_input, "enable"))
13765 enable_disable = 1;
13766 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13767 vam, &sw_if_index))
13769 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13775 if (sw_if_index == ~0)
13777 errmsg ("missing interface name or sw_if_index");
13781 /* Construct the API message */
13782 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13783 mp->sw_if_index = ntohl (sw_if_index);
13784 mp->enable_disable = enable_disable;
13788 /* Wait for the reply */
13794 api_cop_whitelist_enable_disable (vat_main_t * vam)
13796 unformat_input_t *line_input = vam->input;
13797 vl_api_cop_whitelist_enable_disable_t *mp;
13798 u32 sw_if_index = ~0;
13799 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13803 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13805 if (unformat (line_input, "ip4"))
13807 else if (unformat (line_input, "ip6"))
13809 else if (unformat (line_input, "default"))
13811 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13812 vam, &sw_if_index))
13814 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13816 else if (unformat (line_input, "fib-id %d", &fib_id))
13822 if (sw_if_index == ~0)
13824 errmsg ("missing interface name or sw_if_index");
13828 /* Construct the API message */
13829 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13830 mp->sw_if_index = ntohl (sw_if_index);
13831 mp->fib_id = ntohl (fib_id);
13834 mp->default_cop = default_cop;
13838 /* Wait for the reply */
13844 api_get_node_graph (vat_main_t * vam)
13846 vl_api_get_node_graph_t *mp;
13849 M (GET_NODE_GRAPH, mp);
13853 /* Wait for the reply */
13859 /** Used for parsing LISP eids */
13860 typedef CLIB_PACKED(struct{
13861 u8 addr[16]; /**< eid address */
13862 u32 len; /**< prefix length if IP */
13863 u8 type; /**< type of eid */
13868 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13870 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13872 memset (a, 0, sizeof (a[0]));
13874 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13876 a->type = 0; /* ipv4 type */
13878 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13880 a->type = 1; /* ipv6 type */
13882 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13884 a->type = 2; /* mac type */
13891 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13900 lisp_eid_size_vat (u8 type)
13915 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13917 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13921 api_one_add_del_locator_set (vat_main_t * vam)
13923 unformat_input_t *input = vam->input;
13924 vl_api_one_add_del_locator_set_t *mp;
13926 u8 *locator_set_name = NULL;
13927 u8 locator_set_name_set = 0;
13928 vl_api_local_locator_t locator, *locators = 0;
13929 u32 sw_if_index, priority, weight;
13933 /* Parse args required to build the message */
13934 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13936 if (unformat (input, "del"))
13940 else if (unformat (input, "locator-set %s", &locator_set_name))
13942 locator_set_name_set = 1;
13944 else if (unformat (input, "sw_if_index %u p %u w %u",
13945 &sw_if_index, &priority, &weight))
13947 locator.sw_if_index = htonl (sw_if_index);
13948 locator.priority = priority;
13949 locator.weight = weight;
13950 vec_add1 (locators, locator);
13954 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13955 &sw_if_index, &priority, &weight))
13957 locator.sw_if_index = htonl (sw_if_index);
13958 locator.priority = priority;
13959 locator.weight = weight;
13960 vec_add1 (locators, locator);
13966 if (locator_set_name_set == 0)
13968 errmsg ("missing locator-set name");
13969 vec_free (locators);
13973 if (vec_len (locator_set_name) > 64)
13975 errmsg ("locator-set name too long");
13976 vec_free (locator_set_name);
13977 vec_free (locators);
13980 vec_add1 (locator_set_name, 0);
13982 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13984 /* Construct the API message */
13985 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
13987 mp->is_add = is_add;
13988 clib_memcpy (mp->locator_set_name, locator_set_name,
13989 vec_len (locator_set_name));
13990 vec_free (locator_set_name);
13992 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13994 clib_memcpy (mp->locators, locators, data_len);
13995 vec_free (locators);
14000 /* Wait for a reply... */
14005 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14008 api_one_add_del_locator (vat_main_t * vam)
14010 unformat_input_t *input = vam->input;
14011 vl_api_one_add_del_locator_t *mp;
14012 u32 tmp_if_index = ~0;
14013 u32 sw_if_index = ~0;
14014 u8 sw_if_index_set = 0;
14015 u8 sw_if_index_if_name_set = 0;
14017 u8 priority_set = 0;
14021 u8 *locator_set_name = NULL;
14022 u8 locator_set_name_set = 0;
14025 /* Parse args required to build the message */
14026 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14028 if (unformat (input, "del"))
14032 else if (unformat (input, "locator-set %s", &locator_set_name))
14034 locator_set_name_set = 1;
14036 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14039 sw_if_index_if_name_set = 1;
14040 sw_if_index = tmp_if_index;
14042 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14044 sw_if_index_set = 1;
14045 sw_if_index = tmp_if_index;
14047 else if (unformat (input, "p %d", &priority))
14051 else if (unformat (input, "w %d", &weight))
14059 if (locator_set_name_set == 0)
14061 errmsg ("missing locator-set name");
14065 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14067 errmsg ("missing sw_if_index");
14068 vec_free (locator_set_name);
14072 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14074 errmsg ("cannot use both params interface name and sw_if_index");
14075 vec_free (locator_set_name);
14079 if (priority_set == 0)
14081 errmsg ("missing locator-set priority");
14082 vec_free (locator_set_name);
14086 if (weight_set == 0)
14088 errmsg ("missing locator-set weight");
14089 vec_free (locator_set_name);
14093 if (vec_len (locator_set_name) > 64)
14095 errmsg ("locator-set name too long");
14096 vec_free (locator_set_name);
14099 vec_add1 (locator_set_name, 0);
14101 /* Construct the API message */
14102 M (ONE_ADD_DEL_LOCATOR, mp);
14104 mp->is_add = is_add;
14105 mp->sw_if_index = ntohl (sw_if_index);
14106 mp->priority = priority;
14107 mp->weight = weight;
14108 clib_memcpy (mp->locator_set_name, locator_set_name,
14109 vec_len (locator_set_name));
14110 vec_free (locator_set_name);
14115 /* Wait for a reply... */
14120 #define api_lisp_add_del_locator api_one_add_del_locator
14123 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14125 u32 *key_id = va_arg (*args, u32 *);
14128 if (unformat (input, "%s", &s))
14130 if (!strcmp ((char *) s, "sha1"))
14131 key_id[0] = HMAC_SHA_1_96;
14132 else if (!strcmp ((char *) s, "sha256"))
14133 key_id[0] = HMAC_SHA_256_128;
14136 clib_warning ("invalid key_id: '%s'", s);
14137 key_id[0] = HMAC_NO_KEY;
14148 api_one_add_del_local_eid (vat_main_t * vam)
14150 unformat_input_t *input = vam->input;
14151 vl_api_one_add_del_local_eid_t *mp;
14154 lisp_eid_vat_t _eid, *eid = &_eid;
14155 u8 *locator_set_name = 0;
14156 u8 locator_set_name_set = 0;
14162 /* Parse args required to build the message */
14163 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14165 if (unformat (input, "del"))
14169 else if (unformat (input, "vni %d", &vni))
14173 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14177 else if (unformat (input, "locator-set %s", &locator_set_name))
14179 locator_set_name_set = 1;
14181 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14183 else if (unformat (input, "secret-key %_%v%_", &key))
14189 if (locator_set_name_set == 0)
14191 errmsg ("missing locator-set name");
14197 errmsg ("EID address not set!");
14198 vec_free (locator_set_name);
14202 if (key && (0 == key_id))
14204 errmsg ("invalid key_id!");
14208 if (vec_len (key) > 64)
14210 errmsg ("key too long");
14215 if (vec_len (locator_set_name) > 64)
14217 errmsg ("locator-set name too long");
14218 vec_free (locator_set_name);
14221 vec_add1 (locator_set_name, 0);
14223 /* Construct the API message */
14224 M (ONE_ADD_DEL_LOCAL_EID, mp);
14226 mp->is_add = is_add;
14227 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14228 mp->eid_type = eid->type;
14229 mp->prefix_len = eid->len;
14230 mp->vni = clib_host_to_net_u32 (vni);
14231 mp->key_id = clib_host_to_net_u16 (key_id);
14232 clib_memcpy (mp->locator_set_name, locator_set_name,
14233 vec_len (locator_set_name));
14234 clib_memcpy (mp->key, key, vec_len (key));
14236 vec_free (locator_set_name);
14242 /* Wait for a reply... */
14247 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14250 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14252 u32 dp_table = 0, vni = 0;;
14253 unformat_input_t *input = vam->input;
14254 vl_api_gpe_add_del_fwd_entry_t *mp;
14256 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14257 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14258 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14259 u32 action = ~0, w;
14260 ip4_address_t rmt_rloc4, lcl_rloc4;
14261 ip6_address_t rmt_rloc6, lcl_rloc6;
14262 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14265 memset (&rloc, 0, sizeof (rloc));
14267 /* Parse args required to build the message */
14268 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14270 if (unformat (input, "del"))
14272 else if (unformat (input, "add"))
14274 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14278 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14282 else if (unformat (input, "vrf %d", &dp_table))
14284 else if (unformat (input, "bd %d", &dp_table))
14286 else if (unformat (input, "vni %d", &vni))
14288 else if (unformat (input, "w %d", &w))
14292 errmsg ("No RLOC configured for setting priority/weight!");
14295 curr_rloc->weight = w;
14297 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14298 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14302 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
14304 vec_add1 (lcl_locs, rloc);
14306 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
14307 vec_add1 (rmt_locs, rloc);
14308 /* weight saved in rmt loc */
14309 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14311 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14312 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14315 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
14317 vec_add1 (lcl_locs, rloc);
14319 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
14320 vec_add1 (rmt_locs, rloc);
14321 /* weight saved in rmt loc */
14322 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14324 else if (unformat (input, "action %d", &action))
14330 clib_warning ("parse error '%U'", format_unformat_error, input);
14337 errmsg ("remote eid addresses not set");
14341 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14343 errmsg ("eid types don't match");
14347 if (0 == rmt_locs && (u32) ~ 0 == action)
14349 errmsg ("action not set for negative mapping");
14353 /* Construct the API message */
14354 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14355 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14357 mp->is_add = is_add;
14358 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14359 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14360 mp->eid_type = rmt_eid->type;
14361 mp->dp_table = clib_host_to_net_u32 (dp_table);
14362 mp->vni = clib_host_to_net_u32 (vni);
14363 mp->rmt_len = rmt_eid->len;
14364 mp->lcl_len = lcl_eid->len;
14365 mp->action = action;
14367 if (0 != rmt_locs && 0 != lcl_locs)
14369 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14370 clib_memcpy (mp->locs, lcl_locs,
14371 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14373 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14374 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14375 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14377 vec_free (lcl_locs);
14378 vec_free (rmt_locs);
14383 /* Wait for a reply... */
14389 api_one_add_del_map_server (vat_main_t * vam)
14391 unformat_input_t *input = vam->input;
14392 vl_api_one_add_del_map_server_t *mp;
14396 ip4_address_t ipv4;
14397 ip6_address_t ipv6;
14400 /* Parse args required to build the message */
14401 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14403 if (unformat (input, "del"))
14407 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14411 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14419 if (ipv4_set && ipv6_set)
14421 errmsg ("both eid v4 and v6 addresses set");
14425 if (!ipv4_set && !ipv6_set)
14427 errmsg ("eid addresses not set");
14431 /* Construct the API message */
14432 M (ONE_ADD_DEL_MAP_SERVER, mp);
14434 mp->is_add = is_add;
14438 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14443 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14449 /* Wait for a reply... */
14454 #define api_lisp_add_del_map_server api_one_add_del_map_server
14457 api_one_add_del_map_resolver (vat_main_t * vam)
14459 unformat_input_t *input = vam->input;
14460 vl_api_one_add_del_map_resolver_t *mp;
14464 ip4_address_t ipv4;
14465 ip6_address_t ipv6;
14468 /* Parse args required to build the message */
14469 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14471 if (unformat (input, "del"))
14475 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14479 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14487 if (ipv4_set && ipv6_set)
14489 errmsg ("both eid v4 and v6 addresses set");
14493 if (!ipv4_set && !ipv6_set)
14495 errmsg ("eid addresses not set");
14499 /* Construct the API message */
14500 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14502 mp->is_add = is_add;
14506 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14511 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14517 /* Wait for a reply... */
14522 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14525 api_lisp_gpe_enable_disable (vat_main_t * vam)
14527 unformat_input_t *input = vam->input;
14528 vl_api_gpe_enable_disable_t *mp;
14533 /* Parse args required to build the message */
14534 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14536 if (unformat (input, "enable"))
14541 else if (unformat (input, "disable"))
14552 errmsg ("Value not set");
14556 /* Construct the API message */
14557 M (GPE_ENABLE_DISABLE, mp);
14564 /* Wait for a reply... */
14570 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14572 unformat_input_t *input = vam->input;
14573 vl_api_one_rloc_probe_enable_disable_t *mp;
14578 /* Parse args required to build the message */
14579 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14581 if (unformat (input, "enable"))
14586 else if (unformat (input, "disable"))
14594 errmsg ("Value not set");
14598 /* Construct the API message */
14599 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14601 mp->is_enabled = is_en;
14606 /* Wait for a reply... */
14611 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14614 api_one_map_register_enable_disable (vat_main_t * vam)
14616 unformat_input_t *input = vam->input;
14617 vl_api_one_map_register_enable_disable_t *mp;
14622 /* Parse args required to build the message */
14623 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14625 if (unformat (input, "enable"))
14630 else if (unformat (input, "disable"))
14638 errmsg ("Value not set");
14642 /* Construct the API message */
14643 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14645 mp->is_enabled = is_en;
14650 /* Wait for a reply... */
14655 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14658 api_one_enable_disable (vat_main_t * vam)
14660 unformat_input_t *input = vam->input;
14661 vl_api_one_enable_disable_t *mp;
14666 /* Parse args required to build the message */
14667 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14669 if (unformat (input, "enable"))
14674 else if (unformat (input, "disable"))
14684 errmsg ("Value not set");
14688 /* Construct the API message */
14689 M (ONE_ENABLE_DISABLE, mp);
14696 /* Wait for a reply... */
14701 #define api_lisp_enable_disable api_one_enable_disable
14704 api_show_one_map_register_state (vat_main_t * vam)
14706 vl_api_show_one_map_register_state_t *mp;
14709 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14714 /* wait for reply */
14719 #define api_show_lisp_map_register_state api_show_one_map_register_state
14722 api_show_one_rloc_probe_state (vat_main_t * vam)
14724 vl_api_show_one_rloc_probe_state_t *mp;
14727 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14732 /* wait for reply */
14737 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14740 api_one_stats_enable_disable (vat_main_t * vam)
14742 vl_api_one_stats_enable_disable_t *mp;
14743 unformat_input_t *input = vam->input;
14748 /* Parse args required to build the message */
14749 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14751 if (unformat (input, "enable"))
14756 else if (unformat (input, "disable"))
14766 errmsg ("Value not set");
14770 M (ONE_STATS_ENABLE_DISABLE, mp);
14776 /* wait for reply */
14782 api_show_one_stats_enable_disable (vat_main_t * vam)
14784 vl_api_show_one_stats_enable_disable_t *mp;
14787 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
14792 /* wait for reply */
14798 api_show_one_map_request_mode (vat_main_t * vam)
14800 vl_api_show_one_map_request_mode_t *mp;
14803 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
14808 /* wait for reply */
14813 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
14816 api_one_map_request_mode (vat_main_t * vam)
14818 unformat_input_t *input = vam->input;
14819 vl_api_one_map_request_mode_t *mp;
14823 /* Parse args required to build the message */
14824 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14826 if (unformat (input, "dst-only"))
14828 else if (unformat (input, "src-dst"))
14832 errmsg ("parse error '%U'", format_unformat_error, input);
14837 M (ONE_MAP_REQUEST_MODE, mp);
14844 /* wait for reply */
14849 #define api_lisp_map_request_mode api_one_map_request_mode
14852 * Enable/disable ONE proxy ITR.
14854 * @param vam vpp API test context
14855 * @return return code
14858 api_one_pitr_set_locator_set (vat_main_t * vam)
14860 u8 ls_name_set = 0;
14861 unformat_input_t *input = vam->input;
14862 vl_api_one_pitr_set_locator_set_t *mp;
14867 /* Parse args required to build the message */
14868 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14870 if (unformat (input, "del"))
14872 else if (unformat (input, "locator-set %s", &ls_name))
14876 errmsg ("parse error '%U'", format_unformat_error, input);
14883 errmsg ("locator-set name not set!");
14887 M (ONE_PITR_SET_LOCATOR_SET, mp);
14889 mp->is_add = is_add;
14890 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14891 vec_free (ls_name);
14896 /* wait for reply */
14901 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
14904 api_show_one_pitr (vat_main_t * vam)
14906 vl_api_show_one_pitr_t *mp;
14909 if (!vam->json_output)
14911 print (vam->ofp, "%=20s", "lisp status:");
14914 M (SHOW_ONE_PITR, mp);
14918 /* Wait for a reply... */
14923 #define api_show_lisp_pitr api_show_one_pitr
14926 api_one_use_petr (vat_main_t * vam)
14928 unformat_input_t *input = vam->input;
14929 vl_api_one_use_petr_t *mp;
14934 memset (&ip, 0, sizeof (ip));
14936 /* Parse args required to build the message */
14937 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14939 if (unformat (input, "disable"))
14942 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
14945 ip_addr_version (&ip) = IP4;
14948 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
14951 ip_addr_version (&ip) = IP6;
14955 errmsg ("parse error '%U'", format_unformat_error, input);
14960 M (ONE_USE_PETR, mp);
14962 mp->is_add = is_add;
14965 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
14967 clib_memcpy (mp->address, &ip, 4);
14969 clib_memcpy (mp->address, &ip, 16);
14975 /* wait for reply */
14980 #define api_lisp_use_petr api_one_use_petr
14983 api_show_one_use_petr (vat_main_t * vam)
14985 vl_api_show_one_use_petr_t *mp;
14988 if (!vam->json_output)
14990 print (vam->ofp, "%=20s", "Proxy-ETR status:");
14993 M (SHOW_ONE_USE_PETR, mp);
14997 /* Wait for a reply... */
15002 #define api_show_lisp_use_petr api_show_one_use_petr
15005 * Add/delete mapping between vni and vrf
15008 api_one_eid_table_add_del_map (vat_main_t * vam)
15010 unformat_input_t *input = vam->input;
15011 vl_api_one_eid_table_add_del_map_t *mp;
15012 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15013 u32 vni, vrf, bd_index;
15016 /* Parse args required to build the message */
15017 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15019 if (unformat (input, "del"))
15021 else if (unformat (input, "vrf %d", &vrf))
15023 else if (unformat (input, "bd_index %d", &bd_index))
15025 else if (unformat (input, "vni %d", &vni))
15031 if (!vni_set || (!vrf_set && !bd_index_set))
15033 errmsg ("missing arguments!");
15037 if (vrf_set && bd_index_set)
15039 errmsg ("error: both vrf and bd entered!");
15043 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15045 mp->is_add = is_add;
15046 mp->vni = htonl (vni);
15047 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15048 mp->is_l2 = bd_index_set;
15053 /* wait for reply */
15058 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15061 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15063 u32 *action = va_arg (*args, u32 *);
15066 if (unformat (input, "%s", &s))
15068 if (!strcmp ((char *) s, "no-action"))
15070 else if (!strcmp ((char *) s, "natively-forward"))
15072 else if (!strcmp ((char *) s, "send-map-request"))
15074 else if (!strcmp ((char *) s, "drop"))
15078 clib_warning ("invalid action: '%s'", s);
15090 * Add/del remote mapping to/from ONE control plane
15092 * @param vam vpp API test context
15093 * @return return code
15096 api_one_add_del_remote_mapping (vat_main_t * vam)
15098 unformat_input_t *input = vam->input;
15099 vl_api_one_add_del_remote_mapping_t *mp;
15101 lisp_eid_vat_t _eid, *eid = &_eid;
15102 lisp_eid_vat_t _seid, *seid = &_seid;
15103 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15104 u32 action = ~0, p, w, data_len;
15105 ip4_address_t rloc4;
15106 ip6_address_t rloc6;
15107 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15110 memset (&rloc, 0, sizeof (rloc));
15112 /* Parse args required to build the message */
15113 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15115 if (unformat (input, "del-all"))
15119 else if (unformat (input, "del"))
15123 else if (unformat (input, "add"))
15127 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15131 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15135 else if (unformat (input, "vni %d", &vni))
15139 else if (unformat (input, "p %d w %d", &p, &w))
15143 errmsg ("No RLOC configured for setting priority/weight!");
15146 curr_rloc->priority = p;
15147 curr_rloc->weight = w;
15149 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15152 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
15153 vec_add1 (rlocs, rloc);
15154 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15156 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15159 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
15160 vec_add1 (rlocs, rloc);
15161 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15163 else if (unformat (input, "action %U",
15164 unformat_negative_mapping_action, &action))
15170 clib_warning ("parse error '%U'", format_unformat_error, input);
15177 errmsg ("missing params!");
15181 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15183 errmsg ("no action set for negative map-reply!");
15187 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15189 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15190 mp->is_add = is_add;
15191 mp->vni = htonl (vni);
15192 mp->action = (u8) action;
15193 mp->is_src_dst = seid_set;
15194 mp->eid_len = eid->len;
15195 mp->seid_len = seid->len;
15196 mp->del_all = del_all;
15197 mp->eid_type = eid->type;
15198 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15199 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
15201 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15202 clib_memcpy (mp->rlocs, rlocs, data_len);
15208 /* Wait for a reply... */
15213 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15216 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15217 * forwarding entries in data-plane accordingly.
15219 * @param vam vpp API test context
15220 * @return return code
15223 api_one_add_del_adjacency (vat_main_t * vam)
15225 unformat_input_t *input = vam->input;
15226 vl_api_one_add_del_adjacency_t *mp;
15228 ip4_address_t leid4, reid4;
15229 ip6_address_t leid6, reid6;
15230 u8 reid_mac[6] = { 0 };
15231 u8 leid_mac[6] = { 0 };
15232 u8 reid_type, leid_type;
15233 u32 leid_len = 0, reid_len = 0, len;
15237 leid_type = reid_type = (u8) ~ 0;
15239 /* Parse args required to build the message */
15240 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15242 if (unformat (input, "del"))
15246 else if (unformat (input, "add"))
15250 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
15253 reid_type = 0; /* ipv4 */
15256 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
15259 reid_type = 1; /* ipv6 */
15262 else if (unformat (input, "reid %U", unformat_ethernet_address,
15265 reid_type = 2; /* mac */
15267 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
15270 leid_type = 0; /* ipv4 */
15273 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
15276 leid_type = 1; /* ipv6 */
15279 else if (unformat (input, "leid %U", unformat_ethernet_address,
15282 leid_type = 2; /* mac */
15284 else if (unformat (input, "vni %d", &vni))
15290 errmsg ("parse error '%U'", format_unformat_error, input);
15295 if ((u8) ~ 0 == reid_type)
15297 errmsg ("missing params!");
15301 if (leid_type != reid_type)
15303 errmsg ("remote and local EIDs are of different types!");
15307 M (ONE_ADD_DEL_ADJACENCY, mp);
15308 mp->is_add = is_add;
15309 mp->vni = htonl (vni);
15310 mp->leid_len = leid_len;
15311 mp->reid_len = reid_len;
15312 mp->eid_type = reid_type;
15314 switch (mp->eid_type)
15317 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
15318 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
15321 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
15322 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
15325 clib_memcpy (mp->leid, leid_mac, 6);
15326 clib_memcpy (mp->reid, reid_mac, 6);
15329 errmsg ("unknown EID type %d!", mp->eid_type);
15336 /* Wait for a reply... */
15341 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
15344 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
15346 u32 *mode = va_arg (*args, u32 *);
15348 if (unformat (input, "lisp"))
15350 else if (unformat (input, "vxlan"))
15359 api_gpe_get_encap_mode (vat_main_t * vam)
15361 vl_api_gpe_get_encap_mode_t *mp;
15364 /* Construct the API message */
15365 M (GPE_GET_ENCAP_MODE, mp);
15370 /* Wait for a reply... */
15376 api_gpe_set_encap_mode (vat_main_t * vam)
15378 unformat_input_t *input = vam->input;
15379 vl_api_gpe_set_encap_mode_t *mp;
15383 /* Parse args required to build the message */
15384 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15386 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
15392 /* Construct the API message */
15393 M (GPE_SET_ENCAP_MODE, mp);
15400 /* Wait for a reply... */
15406 api_lisp_gpe_add_del_iface (vat_main_t * vam)
15408 unformat_input_t *input = vam->input;
15409 vl_api_gpe_add_del_iface_t *mp;
15410 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
15411 u32 dp_table = 0, vni = 0;
15414 /* Parse args required to build the message */
15415 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15417 if (unformat (input, "up"))
15422 else if (unformat (input, "down"))
15427 else if (unformat (input, "table_id %d", &dp_table))
15431 else if (unformat (input, "bd_id %d", &dp_table))
15436 else if (unformat (input, "vni %d", &vni))
15444 if (action_set == 0)
15446 errmsg ("Action not set");
15449 if (dp_table_set == 0 || vni_set == 0)
15451 errmsg ("vni and dp_table must be set");
15455 /* Construct the API message */
15456 M (GPE_ADD_DEL_IFACE, mp);
15458 mp->is_add = is_add;
15459 mp->dp_table = dp_table;
15466 /* Wait for a reply... */
15472 * Add/del map request itr rlocs from ONE control plane and updates
15474 * @param vam vpp API test context
15475 * @return return code
15478 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
15480 unformat_input_t *input = vam->input;
15481 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
15482 u8 *locator_set_name = 0;
15483 u8 locator_set_name_set = 0;
15487 /* Parse args required to build the message */
15488 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15490 if (unformat (input, "del"))
15494 else if (unformat (input, "%_%v%_", &locator_set_name))
15496 locator_set_name_set = 1;
15500 clib_warning ("parse error '%U'", format_unformat_error, input);
15505 if (is_add && !locator_set_name_set)
15507 errmsg ("itr-rloc is not set!");
15511 if (is_add && vec_len (locator_set_name) > 64)
15513 errmsg ("itr-rloc locator-set name too long");
15514 vec_free (locator_set_name);
15518 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
15519 mp->is_add = is_add;
15522 clib_memcpy (mp->locator_set_name, locator_set_name,
15523 vec_len (locator_set_name));
15527 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
15529 vec_free (locator_set_name);
15534 /* Wait for a reply... */
15539 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
15542 api_one_locator_dump (vat_main_t * vam)
15544 unformat_input_t *input = vam->input;
15545 vl_api_one_locator_dump_t *mp;
15546 vl_api_control_ping_t *mp_ping;
15547 u8 is_index_set = 0, is_name_set = 0;
15552 /* Parse args required to build the message */
15553 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15555 if (unformat (input, "ls_name %_%v%_", &ls_name))
15559 else if (unformat (input, "ls_index %d", &ls_index))
15565 errmsg ("parse error '%U'", format_unformat_error, input);
15570 if (!is_index_set && !is_name_set)
15572 errmsg ("error: expected one of index or name!");
15576 if (is_index_set && is_name_set)
15578 errmsg ("error: only one param expected!");
15582 if (vec_len (ls_name) > 62)
15584 errmsg ("error: locator set name too long!");
15588 if (!vam->json_output)
15590 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
15593 M (ONE_LOCATOR_DUMP, mp);
15594 mp->is_index_set = is_index_set;
15597 mp->ls_index = clib_host_to_net_u32 (ls_index);
15600 vec_add1 (ls_name, 0);
15601 strncpy ((char *) mp->ls_name, (char *) ls_name,
15602 sizeof (mp->ls_name) - 1);
15608 /* Use a control ping for synchronization */
15609 M (CONTROL_PING, mp_ping);
15612 /* Wait for a reply... */
15617 #define api_lisp_locator_dump api_one_locator_dump
15620 api_one_locator_set_dump (vat_main_t * vam)
15622 vl_api_one_locator_set_dump_t *mp;
15623 vl_api_control_ping_t *mp_ping;
15624 unformat_input_t *input = vam->input;
15628 /* Parse args required to build the message */
15629 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15631 if (unformat (input, "local"))
15635 else if (unformat (input, "remote"))
15641 errmsg ("parse error '%U'", format_unformat_error, input);
15646 if (!vam->json_output)
15648 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
15651 M (ONE_LOCATOR_SET_DUMP, mp);
15653 mp->filter = filter;
15658 /* Use a control ping for synchronization */
15659 M (CONTROL_PING, mp_ping);
15662 /* Wait for a reply... */
15667 #define api_lisp_locator_set_dump api_one_locator_set_dump
15670 api_one_eid_table_map_dump (vat_main_t * vam)
15674 unformat_input_t *input = vam->input;
15675 vl_api_one_eid_table_map_dump_t *mp;
15676 vl_api_control_ping_t *mp_ping;
15679 /* Parse args required to build the message */
15680 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15682 if (unformat (input, "l2"))
15687 else if (unformat (input, "l3"))
15694 errmsg ("parse error '%U'", format_unformat_error, input);
15701 errmsg ("expected one of 'l2' or 'l3' parameter!");
15705 if (!vam->json_output)
15707 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
15710 M (ONE_EID_TABLE_MAP_DUMP, mp);
15716 /* Use a control ping for synchronization */
15717 M (CONTROL_PING, mp_ping);
15720 /* Wait for a reply... */
15725 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
15728 api_one_eid_table_vni_dump (vat_main_t * vam)
15730 vl_api_one_eid_table_vni_dump_t *mp;
15731 vl_api_control_ping_t *mp_ping;
15734 if (!vam->json_output)
15736 print (vam->ofp, "VNI");
15739 M (ONE_EID_TABLE_VNI_DUMP, mp);
15744 /* Use a control ping for synchronization */
15745 M (CONTROL_PING, mp_ping);
15748 /* Wait for a reply... */
15753 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
15756 api_one_eid_table_dump (vat_main_t * vam)
15758 unformat_input_t *i = vam->input;
15759 vl_api_one_eid_table_dump_t *mp;
15760 vl_api_control_ping_t *mp_ping;
15761 struct in_addr ip4;
15762 struct in6_addr ip6;
15764 u8 eid_type = ~0, eid_set = 0;
15765 u32 prefix_length = ~0, t, vni = 0;
15769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15771 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
15777 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
15783 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
15788 else if (unformat (i, "vni %d", &t))
15792 else if (unformat (i, "local"))
15796 else if (unformat (i, "remote"))
15802 errmsg ("parse error '%U'", format_unformat_error, i);
15807 if (!vam->json_output)
15809 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
15810 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
15813 M (ONE_EID_TABLE_DUMP, mp);
15815 mp->filter = filter;
15819 mp->vni = htonl (vni);
15820 mp->eid_type = eid_type;
15824 mp->prefix_length = prefix_length;
15825 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
15828 mp->prefix_length = prefix_length;
15829 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
15832 clib_memcpy (mp->eid, mac, sizeof (mac));
15835 errmsg ("unknown EID type %d!", eid_type);
15843 /* Use a control ping for synchronization */
15844 M (CONTROL_PING, mp_ping);
15847 /* Wait for a reply... */
15852 #define api_lisp_eid_table_dump api_one_eid_table_dump
15855 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
15857 unformat_input_t *i = vam->input;
15858 vl_api_gpe_fwd_entries_get_t *mp;
15863 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15865 if (unformat (i, "vni %d", &vni))
15871 errmsg ("parse error '%U'", format_unformat_error, i);
15878 errmsg ("vni not set!");
15882 if (!vam->json_output)
15884 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15888 M (GPE_FWD_ENTRIES_GET, mp);
15889 mp->vni = clib_host_to_net_u32 (vni);
15894 /* Wait for a reply... */
15899 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
15900 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
15901 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15902 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15903 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15904 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
15907 api_one_adjacencies_get (vat_main_t * vam)
15909 unformat_input_t *i = vam->input;
15910 vl_api_one_adjacencies_get_t *mp;
15915 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15917 if (unformat (i, "vni %d", &vni))
15923 errmsg ("parse error '%U'", format_unformat_error, i);
15930 errmsg ("vni not set!");
15934 if (!vam->json_output)
15936 print (vam->ofp, "%s %40s", "leid", "reid");
15939 M (ONE_ADJACENCIES_GET, mp);
15940 mp->vni = clib_host_to_net_u32 (vni);
15945 /* Wait for a reply... */
15950 #define api_lisp_adjacencies_get api_one_adjacencies_get
15953 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
15955 vl_api_gpe_fwd_entry_vnis_get_t *mp;
15958 if (!vam->json_output)
15960 print (vam->ofp, "VNIs");
15963 M (GPE_FWD_ENTRY_VNIS_GET, mp);
15968 /* Wait for a reply... */
15974 api_one_map_server_dump (vat_main_t * vam)
15976 vl_api_one_map_server_dump_t *mp;
15977 vl_api_control_ping_t *mp_ping;
15980 if (!vam->json_output)
15982 print (vam->ofp, "%=20s", "Map server");
15985 M (ONE_MAP_SERVER_DUMP, mp);
15989 /* Use a control ping for synchronization */
15990 M (CONTROL_PING, mp_ping);
15993 /* Wait for a reply... */
15998 #define api_lisp_map_server_dump api_one_map_server_dump
16001 api_one_map_resolver_dump (vat_main_t * vam)
16003 vl_api_one_map_resolver_dump_t *mp;
16004 vl_api_control_ping_t *mp_ping;
16007 if (!vam->json_output)
16009 print (vam->ofp, "%=20s", "Map resolver");
16012 M (ONE_MAP_RESOLVER_DUMP, mp);
16016 /* Use a control ping for synchronization */
16017 M (CONTROL_PING, mp_ping);
16020 /* Wait for a reply... */
16025 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
16028 api_one_stats_flush (vat_main_t * vam)
16030 vl_api_one_stats_flush_t *mp;
16033 M (ONE_STATS_FLUSH, mp);
16040 api_one_stats_dump (vat_main_t * vam)
16042 vl_api_one_stats_dump_t *mp;
16043 vl_api_control_ping_t *mp_ping;
16046 M (ONE_STATS_DUMP, mp);
16050 /* Use a control ping for synchronization */
16051 M (CONTROL_PING, mp_ping);
16054 /* Wait for a reply... */
16060 api_show_one_status (vat_main_t * vam)
16062 vl_api_show_one_status_t *mp;
16065 if (!vam->json_output)
16067 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
16070 M (SHOW_ONE_STATUS, mp);
16073 /* Wait for a reply... */
16078 #define api_show_lisp_status api_show_one_status
16081 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
16083 vl_api_gpe_fwd_entry_path_dump_t *mp;
16084 vl_api_control_ping_t *mp_ping;
16085 unformat_input_t *i = vam->input;
16086 u32 fwd_entry_index = ~0;
16089 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16091 if (unformat (i, "index %d", &fwd_entry_index))
16097 if (~0 == fwd_entry_index)
16099 errmsg ("no index specified!");
16103 if (!vam->json_output)
16105 print (vam->ofp, "first line");
16108 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
16112 /* Use a control ping for synchronization */
16113 M (CONTROL_PING, mp_ping);
16116 /* Wait for a reply... */
16122 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
16124 vl_api_one_get_map_request_itr_rlocs_t *mp;
16127 if (!vam->json_output)
16129 print (vam->ofp, "%=20s", "itr-rlocs:");
16132 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
16135 /* Wait for a reply... */
16140 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
16143 api_af_packet_create (vat_main_t * vam)
16145 unformat_input_t *i = vam->input;
16146 vl_api_af_packet_create_t *mp;
16147 u8 *host_if_name = 0;
16149 u8 random_hw_addr = 1;
16152 memset (hw_addr, 0, sizeof (hw_addr));
16154 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16156 if (unformat (i, "name %s", &host_if_name))
16157 vec_add1 (host_if_name, 0);
16158 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16159 random_hw_addr = 0;
16164 if (!vec_len (host_if_name))
16166 errmsg ("host-interface name must be specified");
16170 if (vec_len (host_if_name) > 64)
16172 errmsg ("host-interface name too long");
16176 M (AF_PACKET_CREATE, mp);
16178 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16179 clib_memcpy (mp->hw_addr, hw_addr, 6);
16180 mp->use_random_hw_addr = random_hw_addr;
16181 vec_free (host_if_name);
16189 fprintf (vam->ofp ? vam->ofp : stderr,
16190 " new sw_if_index = %d\n", vam->sw_if_index);
16197 api_af_packet_delete (vat_main_t * vam)
16199 unformat_input_t *i = vam->input;
16200 vl_api_af_packet_delete_t *mp;
16201 u8 *host_if_name = 0;
16204 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16206 if (unformat (i, "name %s", &host_if_name))
16207 vec_add1 (host_if_name, 0);
16212 if (!vec_len (host_if_name))
16214 errmsg ("host-interface name must be specified");
16218 if (vec_len (host_if_name) > 64)
16220 errmsg ("host-interface name too long");
16224 M (AF_PACKET_DELETE, mp);
16226 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16227 vec_free (host_if_name);
16235 api_policer_add_del (vat_main_t * vam)
16237 unformat_input_t *i = vam->input;
16238 vl_api_policer_add_del_t *mp;
16248 u8 color_aware = 0;
16249 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
16252 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
16253 conform_action.dscp = 0;
16254 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
16255 exceed_action.dscp = 0;
16256 violate_action.action_type = SSE2_QOS_ACTION_DROP;
16257 violate_action.dscp = 0;
16259 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16261 if (unformat (i, "del"))
16263 else if (unformat (i, "name %s", &name))
16264 vec_add1 (name, 0);
16265 else if (unformat (i, "cir %u", &cir))
16267 else if (unformat (i, "eir %u", &eir))
16269 else if (unformat (i, "cb %u", &cb))
16271 else if (unformat (i, "eb %u", &eb))
16273 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
16276 else if (unformat (i, "round_type %U", unformat_policer_round_type,
16279 else if (unformat (i, "type %U", unformat_policer_type, &type))
16281 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
16284 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
16287 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
16290 else if (unformat (i, "color-aware"))
16296 if (!vec_len (name))
16298 errmsg ("policer name must be specified");
16302 if (vec_len (name) > 64)
16304 errmsg ("policer name too long");
16308 M (POLICER_ADD_DEL, mp);
16310 clib_memcpy (mp->name, name, vec_len (name));
16312 mp->is_add = is_add;
16317 mp->rate_type = rate_type;
16318 mp->round_type = round_type;
16320 mp->conform_action_type = conform_action.action_type;
16321 mp->conform_dscp = conform_action.dscp;
16322 mp->exceed_action_type = exceed_action.action_type;
16323 mp->exceed_dscp = exceed_action.dscp;
16324 mp->violate_action_type = violate_action.action_type;
16325 mp->violate_dscp = violate_action.dscp;
16326 mp->color_aware = color_aware;
16334 api_policer_dump (vat_main_t * vam)
16336 unformat_input_t *i = vam->input;
16337 vl_api_policer_dump_t *mp;
16338 vl_api_control_ping_t *mp_ping;
16339 u8 *match_name = 0;
16340 u8 match_name_valid = 0;
16343 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16345 if (unformat (i, "name %s", &match_name))
16347 vec_add1 (match_name, 0);
16348 match_name_valid = 1;
16354 M (POLICER_DUMP, mp);
16355 mp->match_name_valid = match_name_valid;
16356 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
16357 vec_free (match_name);
16361 /* Use a control ping for synchronization */
16362 M (CONTROL_PING, mp_ping);
16365 /* Wait for a reply... */
16371 api_policer_classify_set_interface (vat_main_t * vam)
16373 unformat_input_t *i = vam->input;
16374 vl_api_policer_classify_set_interface_t *mp;
16376 int sw_if_index_set;
16377 u32 ip4_table_index = ~0;
16378 u32 ip6_table_index = ~0;
16379 u32 l2_table_index = ~0;
16383 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16385 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16386 sw_if_index_set = 1;
16387 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16388 sw_if_index_set = 1;
16389 else if (unformat (i, "del"))
16391 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16393 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16395 else if (unformat (i, "l2-table %d", &l2_table_index))
16399 clib_warning ("parse error '%U'", format_unformat_error, i);
16404 if (sw_if_index_set == 0)
16406 errmsg ("missing interface name or sw_if_index");
16410 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
16412 mp->sw_if_index = ntohl (sw_if_index);
16413 mp->ip4_table_index = ntohl (ip4_table_index);
16414 mp->ip6_table_index = ntohl (ip6_table_index);
16415 mp->l2_table_index = ntohl (l2_table_index);
16416 mp->is_add = is_add;
16424 api_policer_classify_dump (vat_main_t * vam)
16426 unformat_input_t *i = vam->input;
16427 vl_api_policer_classify_dump_t *mp;
16428 vl_api_control_ping_t *mp_ping;
16429 u8 type = POLICER_CLASSIFY_N_TABLES;
16432 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
16436 errmsg ("classify table type must be specified");
16440 if (!vam->json_output)
16442 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
16445 M (POLICER_CLASSIFY_DUMP, mp);
16450 /* Use a control ping for synchronization */
16451 M (CONTROL_PING, mp_ping);
16454 /* Wait for a reply... */
16460 api_netmap_create (vat_main_t * vam)
16462 unformat_input_t *i = vam->input;
16463 vl_api_netmap_create_t *mp;
16466 u8 random_hw_addr = 1;
16471 memset (hw_addr, 0, sizeof (hw_addr));
16473 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16475 if (unformat (i, "name %s", &if_name))
16476 vec_add1 (if_name, 0);
16477 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16478 random_hw_addr = 0;
16479 else if (unformat (i, "pipe"))
16481 else if (unformat (i, "master"))
16483 else if (unformat (i, "slave"))
16489 if (!vec_len (if_name))
16491 errmsg ("interface name must be specified");
16495 if (vec_len (if_name) > 64)
16497 errmsg ("interface name too long");
16501 M (NETMAP_CREATE, mp);
16503 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16504 clib_memcpy (mp->hw_addr, hw_addr, 6);
16505 mp->use_random_hw_addr = random_hw_addr;
16506 mp->is_pipe = is_pipe;
16507 mp->is_master = is_master;
16508 vec_free (if_name);
16516 api_netmap_delete (vat_main_t * vam)
16518 unformat_input_t *i = vam->input;
16519 vl_api_netmap_delete_t *mp;
16523 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16525 if (unformat (i, "name %s", &if_name))
16526 vec_add1 (if_name, 0);
16531 if (!vec_len (if_name))
16533 errmsg ("interface name must be specified");
16537 if (vec_len (if_name) > 64)
16539 errmsg ("interface name too long");
16543 M (NETMAP_DELETE, mp);
16545 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16546 vec_free (if_name);
16554 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
16556 if (fp->afi == IP46_TYPE_IP6)
16558 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16559 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16560 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16561 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16562 format_ip6_address, fp->next_hop);
16563 else if (fp->afi == IP46_TYPE_IP4)
16565 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16566 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16567 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16568 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16569 format_ip4_address, fp->next_hop);
16573 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
16574 vl_api_fib_path2_t * fp)
16576 struct in_addr ip4;
16577 struct in6_addr ip6;
16579 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16580 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16581 vat_json_object_add_uint (node, "is_local", fp->is_local);
16582 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16583 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16584 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16585 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16586 if (fp->afi == IP46_TYPE_IP4)
16588 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16589 vat_json_object_add_ip4 (node, "next_hop", ip4);
16591 else if (fp->afi == IP46_TYPE_IP6)
16593 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16594 vat_json_object_add_ip6 (node, "next_hop", ip6);
16599 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
16601 vat_main_t *vam = &vat_main;
16602 int count = ntohl (mp->mt_count);
16603 vl_api_fib_path2_t *fp;
16606 print (vam->ofp, "[%d]: sw_if_index %d via:",
16607 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
16609 for (i = 0; i < count; i++)
16611 vl_api_mpls_fib_path_print (vam, fp);
16615 print (vam->ofp, "");
16618 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
16619 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
16622 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
16624 vat_main_t *vam = &vat_main;
16625 vat_json_node_t *node = NULL;
16626 int count = ntohl (mp->mt_count);
16627 vl_api_fib_path2_t *fp;
16630 if (VAT_JSON_ARRAY != vam->json_tree.type)
16632 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16633 vat_json_init_array (&vam->json_tree);
16635 node = vat_json_array_add (&vam->json_tree);
16637 vat_json_init_object (node);
16638 vat_json_object_add_uint (node, "tunnel_index",
16639 ntohl (mp->mt_tunnel_index));
16640 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
16642 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
16645 for (i = 0; i < count; i++)
16647 vl_api_mpls_fib_path_json_print (node, fp);
16653 api_mpls_tunnel_dump (vat_main_t * vam)
16655 vl_api_mpls_tunnel_dump_t *mp;
16656 vl_api_control_ping_t *mp_ping;
16660 /* Parse args required to build the message */
16661 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
16663 if (!unformat (vam->input, "tunnel_index %d", &index))
16670 print (vam->ofp, " tunnel_index %d", index);
16672 M (MPLS_TUNNEL_DUMP, mp);
16673 mp->tunnel_index = htonl (index);
16676 /* Use a control ping for synchronization */
16677 M (CONTROL_PING, mp_ping);
16684 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
16685 #define vl_api_mpls_fib_details_t_print vl_noop_handler
16689 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
16691 vat_main_t *vam = &vat_main;
16692 int count = ntohl (mp->count);
16693 vl_api_fib_path2_t *fp;
16697 "table-id %d, label %u, ess_bit %u",
16698 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
16700 for (i = 0; i < count; i++)
16702 vl_api_mpls_fib_path_print (vam, fp);
16707 static void vl_api_mpls_fib_details_t_handler_json
16708 (vl_api_mpls_fib_details_t * mp)
16710 vat_main_t *vam = &vat_main;
16711 int count = ntohl (mp->count);
16712 vat_json_node_t *node = NULL;
16713 vl_api_fib_path2_t *fp;
16716 if (VAT_JSON_ARRAY != vam->json_tree.type)
16718 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16719 vat_json_init_array (&vam->json_tree);
16721 node = vat_json_array_add (&vam->json_tree);
16723 vat_json_init_object (node);
16724 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16725 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
16726 vat_json_object_add_uint (node, "label", ntohl (mp->label));
16727 vat_json_object_add_uint (node, "path_count", count);
16729 for (i = 0; i < count; i++)
16731 vl_api_mpls_fib_path_json_print (node, fp);
16737 api_mpls_fib_dump (vat_main_t * vam)
16739 vl_api_mpls_fib_dump_t *mp;
16740 vl_api_control_ping_t *mp_ping;
16743 M (MPLS_FIB_DUMP, mp);
16746 /* Use a control ping for synchronization */
16747 M (CONTROL_PING, mp_ping);
16754 #define vl_api_ip_fib_details_t_endian vl_noop_handler
16755 #define vl_api_ip_fib_details_t_print vl_noop_handler
16758 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
16760 vat_main_t *vam = &vat_main;
16761 int count = ntohl (mp->count);
16762 vl_api_fib_path_t *fp;
16766 "table-id %d, prefix %U/%d",
16767 ntohl (mp->table_id), format_ip4_address, mp->address,
16768 mp->address_length);
16770 for (i = 0; i < count; i++)
16772 if (fp->afi == IP46_TYPE_IP6)
16774 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16775 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16776 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16777 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16778 format_ip6_address, fp->next_hop);
16779 else if (fp->afi == IP46_TYPE_IP4)
16781 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16782 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16783 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16784 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16785 format_ip4_address, fp->next_hop);
16790 static void vl_api_ip_fib_details_t_handler_json
16791 (vl_api_ip_fib_details_t * mp)
16793 vat_main_t *vam = &vat_main;
16794 int count = ntohl (mp->count);
16795 vat_json_node_t *node = NULL;
16796 struct in_addr ip4;
16797 struct in6_addr ip6;
16798 vl_api_fib_path_t *fp;
16801 if (VAT_JSON_ARRAY != vam->json_tree.type)
16803 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16804 vat_json_init_array (&vam->json_tree);
16806 node = vat_json_array_add (&vam->json_tree);
16808 vat_json_init_object (node);
16809 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16810 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
16811 vat_json_object_add_ip4 (node, "prefix", ip4);
16812 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16813 vat_json_object_add_uint (node, "path_count", count);
16815 for (i = 0; i < count; i++)
16817 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16818 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16819 vat_json_object_add_uint (node, "is_local", fp->is_local);
16820 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16821 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16822 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16823 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16824 if (fp->afi == IP46_TYPE_IP4)
16826 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16827 vat_json_object_add_ip4 (node, "next_hop", ip4);
16829 else if (fp->afi == IP46_TYPE_IP6)
16831 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16832 vat_json_object_add_ip6 (node, "next_hop", ip6);
16838 api_ip_fib_dump (vat_main_t * vam)
16840 vl_api_ip_fib_dump_t *mp;
16841 vl_api_control_ping_t *mp_ping;
16844 M (IP_FIB_DUMP, mp);
16847 /* Use a control ping for synchronization */
16848 M (CONTROL_PING, mp_ping);
16856 api_ip_mfib_dump (vat_main_t * vam)
16858 vl_api_ip_mfib_dump_t *mp;
16859 vl_api_control_ping_t *mp_ping;
16862 M (IP_MFIB_DUMP, mp);
16865 /* Use a control ping for synchronization */
16866 M (CONTROL_PING, mp_ping);
16873 static void vl_api_ip_neighbor_details_t_handler
16874 (vl_api_ip_neighbor_details_t * mp)
16876 vat_main_t *vam = &vat_main;
16878 print (vam->ofp, "%c %U %U",
16879 (mp->is_static) ? 'S' : 'D',
16880 format_ethernet_address, &mp->mac_address,
16881 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
16885 static void vl_api_ip_neighbor_details_t_handler_json
16886 (vl_api_ip_neighbor_details_t * mp)
16889 vat_main_t *vam = &vat_main;
16890 vat_json_node_t *node;
16891 struct in_addr ip4;
16892 struct in6_addr ip6;
16894 if (VAT_JSON_ARRAY != vam->json_tree.type)
16896 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16897 vat_json_init_array (&vam->json_tree);
16899 node = vat_json_array_add (&vam->json_tree);
16901 vat_json_init_object (node);
16902 vat_json_object_add_string_copy (node, "flag",
16903 (mp->is_static) ? (u8 *) "static" : (u8 *)
16906 vat_json_object_add_string_copy (node, "link_layer",
16907 format (0, "%U", format_ethernet_address,
16908 &mp->mac_address));
16912 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
16913 vat_json_object_add_ip6 (node, "ip_address", ip6);
16917 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
16918 vat_json_object_add_ip4 (node, "ip_address", ip4);
16923 api_ip_neighbor_dump (vat_main_t * vam)
16925 unformat_input_t *i = vam->input;
16926 vl_api_ip_neighbor_dump_t *mp;
16927 vl_api_control_ping_t *mp_ping;
16929 u32 sw_if_index = ~0;
16932 /* Parse args required to build the message */
16933 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16935 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16937 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16939 else if (unformat (i, "ip6"))
16945 if (sw_if_index == ~0)
16947 errmsg ("missing interface name or sw_if_index");
16951 M (IP_NEIGHBOR_DUMP, mp);
16952 mp->is_ipv6 = (u8) is_ipv6;
16953 mp->sw_if_index = ntohl (sw_if_index);
16956 /* Use a control ping for synchronization */
16957 M (CONTROL_PING, mp_ping);
16964 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
16965 #define vl_api_ip6_fib_details_t_print vl_noop_handler
16968 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
16970 vat_main_t *vam = &vat_main;
16971 int count = ntohl (mp->count);
16972 vl_api_fib_path_t *fp;
16976 "table-id %d, prefix %U/%d",
16977 ntohl (mp->table_id), format_ip6_address, mp->address,
16978 mp->address_length);
16980 for (i = 0; i < count; i++)
16982 if (fp->afi == IP46_TYPE_IP6)
16984 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16985 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16986 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16987 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16988 format_ip6_address, fp->next_hop);
16989 else if (fp->afi == IP46_TYPE_IP4)
16991 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16992 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16993 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16994 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16995 format_ip4_address, fp->next_hop);
17000 static void vl_api_ip6_fib_details_t_handler_json
17001 (vl_api_ip6_fib_details_t * mp)
17003 vat_main_t *vam = &vat_main;
17004 int count = ntohl (mp->count);
17005 vat_json_node_t *node = NULL;
17006 struct in_addr ip4;
17007 struct in6_addr ip6;
17008 vl_api_fib_path_t *fp;
17011 if (VAT_JSON_ARRAY != vam->json_tree.type)
17013 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17014 vat_json_init_array (&vam->json_tree);
17016 node = vat_json_array_add (&vam->json_tree);
17018 vat_json_init_object (node);
17019 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17020 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
17021 vat_json_object_add_ip6 (node, "prefix", ip6);
17022 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17023 vat_json_object_add_uint (node, "path_count", count);
17025 for (i = 0; i < count; i++)
17027 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17028 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17029 vat_json_object_add_uint (node, "is_local", fp->is_local);
17030 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17031 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17032 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17033 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17034 if (fp->afi == IP46_TYPE_IP4)
17036 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17037 vat_json_object_add_ip4 (node, "next_hop", ip4);
17039 else if (fp->afi == IP46_TYPE_IP6)
17041 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17042 vat_json_object_add_ip6 (node, "next_hop", ip6);
17048 api_ip6_fib_dump (vat_main_t * vam)
17050 vl_api_ip6_fib_dump_t *mp;
17051 vl_api_control_ping_t *mp_ping;
17054 M (IP6_FIB_DUMP, mp);
17057 /* Use a control ping for synchronization */
17058 M (CONTROL_PING, mp_ping);
17066 api_ip6_mfib_dump (vat_main_t * vam)
17068 vl_api_ip6_mfib_dump_t *mp;
17069 vl_api_control_ping_t *mp_ping;
17072 M (IP6_MFIB_DUMP, mp);
17075 /* Use a control ping for synchronization */
17076 M (CONTROL_PING, mp_ping);
17084 api_classify_table_ids (vat_main_t * vam)
17086 vl_api_classify_table_ids_t *mp;
17089 /* Construct the API message */
17090 M (CLASSIFY_TABLE_IDS, mp);
17099 api_classify_table_by_interface (vat_main_t * vam)
17101 unformat_input_t *input = vam->input;
17102 vl_api_classify_table_by_interface_t *mp;
17104 u32 sw_if_index = ~0;
17106 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17108 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17110 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17115 if (sw_if_index == ~0)
17117 errmsg ("missing interface name or sw_if_index");
17121 /* Construct the API message */
17122 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
17124 mp->sw_if_index = ntohl (sw_if_index);
17132 api_classify_table_info (vat_main_t * vam)
17134 unformat_input_t *input = vam->input;
17135 vl_api_classify_table_info_t *mp;
17139 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17141 if (unformat (input, "table_id %d", &table_id))
17146 if (table_id == ~0)
17148 errmsg ("missing table id");
17152 /* Construct the API message */
17153 M (CLASSIFY_TABLE_INFO, mp);
17155 mp->table_id = ntohl (table_id);
17163 api_classify_session_dump (vat_main_t * vam)
17165 unformat_input_t *input = vam->input;
17166 vl_api_classify_session_dump_t *mp;
17167 vl_api_control_ping_t *mp_ping;
17171 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17173 if (unformat (input, "table_id %d", &table_id))
17178 if (table_id == ~0)
17180 errmsg ("missing table id");
17184 /* Construct the API message */
17185 M (CLASSIFY_SESSION_DUMP, mp);
17187 mp->table_id = ntohl (table_id);
17190 /* Use a control ping for synchronization */
17191 M (CONTROL_PING, mp_ping);
17199 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
17201 vat_main_t *vam = &vat_main;
17203 print (vam->ofp, "collector_address %U, collector_port %d, "
17204 "src_address %U, vrf_id %d, path_mtu %u, "
17205 "template_interval %u, udp_checksum %d",
17206 format_ip4_address, mp->collector_address,
17207 ntohs (mp->collector_port),
17208 format_ip4_address, mp->src_address,
17209 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
17210 ntohl (mp->template_interval), mp->udp_checksum);
17213 vam->result_ready = 1;
17217 vl_api_ipfix_exporter_details_t_handler_json
17218 (vl_api_ipfix_exporter_details_t * mp)
17220 vat_main_t *vam = &vat_main;
17221 vat_json_node_t node;
17222 struct in_addr collector_address;
17223 struct in_addr src_address;
17225 vat_json_init_object (&node);
17226 clib_memcpy (&collector_address, &mp->collector_address,
17227 sizeof (collector_address));
17228 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
17229 vat_json_object_add_uint (&node, "collector_port",
17230 ntohs (mp->collector_port));
17231 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
17232 vat_json_object_add_ip4 (&node, "src_address", src_address);
17233 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
17234 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
17235 vat_json_object_add_uint (&node, "template_interval",
17236 ntohl (mp->template_interval));
17237 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
17239 vat_json_print (vam->ofp, &node);
17240 vat_json_free (&node);
17242 vam->result_ready = 1;
17246 api_ipfix_exporter_dump (vat_main_t * vam)
17248 vl_api_ipfix_exporter_dump_t *mp;
17251 /* Construct the API message */
17252 M (IPFIX_EXPORTER_DUMP, mp);
17261 api_ipfix_classify_stream_dump (vat_main_t * vam)
17263 vl_api_ipfix_classify_stream_dump_t *mp;
17266 /* Construct the API message */
17267 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
17278 vl_api_ipfix_classify_stream_details_t_handler
17279 (vl_api_ipfix_classify_stream_details_t * mp)
17281 vat_main_t *vam = &vat_main;
17282 print (vam->ofp, "domain_id %d, src_port %d",
17283 ntohl (mp->domain_id), ntohs (mp->src_port));
17285 vam->result_ready = 1;
17289 vl_api_ipfix_classify_stream_details_t_handler_json
17290 (vl_api_ipfix_classify_stream_details_t * mp)
17292 vat_main_t *vam = &vat_main;
17293 vat_json_node_t node;
17295 vat_json_init_object (&node);
17296 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
17297 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
17299 vat_json_print (vam->ofp, &node);
17300 vat_json_free (&node);
17302 vam->result_ready = 1;
17306 api_ipfix_classify_table_dump (vat_main_t * vam)
17308 vl_api_ipfix_classify_table_dump_t *mp;
17309 vl_api_control_ping_t *mp_ping;
17312 if (!vam->json_output)
17314 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
17315 "transport_protocol");
17318 /* Construct the API message */
17319 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
17324 /* Use a control ping for synchronization */
17325 M (CONTROL_PING, mp_ping);
17333 vl_api_ipfix_classify_table_details_t_handler
17334 (vl_api_ipfix_classify_table_details_t * mp)
17336 vat_main_t *vam = &vat_main;
17337 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
17338 mp->transport_protocol);
17342 vl_api_ipfix_classify_table_details_t_handler_json
17343 (vl_api_ipfix_classify_table_details_t * mp)
17345 vat_json_node_t *node = NULL;
17346 vat_main_t *vam = &vat_main;
17348 if (VAT_JSON_ARRAY != vam->json_tree.type)
17350 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17351 vat_json_init_array (&vam->json_tree);
17354 node = vat_json_array_add (&vam->json_tree);
17355 vat_json_init_object (node);
17357 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
17358 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
17359 vat_json_object_add_uint (node, "transport_protocol",
17360 mp->transport_protocol);
17364 api_sw_interface_span_enable_disable (vat_main_t * vam)
17366 unformat_input_t *i = vam->input;
17367 vl_api_sw_interface_span_enable_disable_t *mp;
17368 u32 src_sw_if_index = ~0;
17369 u32 dst_sw_if_index = ~0;
17373 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17376 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
17378 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
17382 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
17384 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
17386 else if (unformat (i, "disable"))
17388 else if (unformat (i, "rx"))
17390 else if (unformat (i, "tx"))
17392 else if (unformat (i, "both"))
17398 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
17400 mp->sw_if_index_from = htonl (src_sw_if_index);
17401 mp->sw_if_index_to = htonl (dst_sw_if_index);
17410 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
17413 vat_main_t *vam = &vat_main;
17414 u8 *sw_if_from_name = 0;
17415 u8 *sw_if_to_name = 0;
17416 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17417 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17418 char *states[] = { "none", "rx", "tx", "both" };
17422 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17424 if ((u32) p->value[0] == sw_if_index_from)
17426 sw_if_from_name = (u8 *)(p->key);
17430 if ((u32) p->value[0] == sw_if_index_to)
17432 sw_if_to_name = (u8 *)(p->key);
17433 if (sw_if_from_name)
17438 print (vam->ofp, "%20s => %20s (%s)",
17439 sw_if_from_name, sw_if_to_name, states[mp->state]);
17443 vl_api_sw_interface_span_details_t_handler_json
17444 (vl_api_sw_interface_span_details_t * mp)
17446 vat_main_t *vam = &vat_main;
17447 vat_json_node_t *node = NULL;
17448 u8 *sw_if_from_name = 0;
17449 u8 *sw_if_to_name = 0;
17450 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17451 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17455 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17457 if ((u32) p->value[0] == sw_if_index_from)
17459 sw_if_from_name = (u8 *)(p->key);
17463 if ((u32) p->value[0] == sw_if_index_to)
17465 sw_if_to_name = (u8 *)(p->key);
17466 if (sw_if_from_name)
17472 if (VAT_JSON_ARRAY != vam->json_tree.type)
17474 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17475 vat_json_init_array (&vam->json_tree);
17477 node = vat_json_array_add (&vam->json_tree);
17479 vat_json_init_object (node);
17480 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
17481 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
17482 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
17483 if (0 != sw_if_to_name)
17485 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
17487 vat_json_object_add_uint (node, "state", mp->state);
17491 api_sw_interface_span_dump (vat_main_t * vam)
17493 vl_api_sw_interface_span_dump_t *mp;
17494 vl_api_control_ping_t *mp_ping;
17497 M (SW_INTERFACE_SPAN_DUMP, mp);
17500 /* Use a control ping for synchronization */
17501 M (CONTROL_PING, mp_ping);
17509 api_pg_create_interface (vat_main_t * vam)
17511 unformat_input_t *input = vam->input;
17512 vl_api_pg_create_interface_t *mp;
17516 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17518 if (unformat (input, "if_id %d", &if_id))
17525 errmsg ("missing pg interface index");
17529 /* Construct the API message */
17530 M (PG_CREATE_INTERFACE, mp);
17532 mp->interface_id = ntohl (if_id);
17540 api_pg_capture (vat_main_t * vam)
17542 unformat_input_t *input = vam->input;
17543 vl_api_pg_capture_t *mp;
17548 u8 pcap_file_set = 0;
17551 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17553 if (unformat (input, "if_id %d", &if_id))
17555 else if (unformat (input, "pcap %s", &pcap_file))
17557 else if (unformat (input, "count %d", &count))
17559 else if (unformat (input, "disable"))
17566 errmsg ("missing pg interface index");
17569 if (pcap_file_set > 0)
17571 if (vec_len (pcap_file) > 255)
17573 errmsg ("pcap file name is too long");
17578 u32 name_len = vec_len (pcap_file);
17579 /* Construct the API message */
17580 M (PG_CAPTURE, mp);
17582 mp->interface_id = ntohl (if_id);
17583 mp->is_enabled = enable;
17584 mp->count = ntohl (count);
17585 mp->pcap_name_length = ntohl (name_len);
17586 if (pcap_file_set != 0)
17588 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
17590 vec_free (pcap_file);
17598 api_pg_enable_disable (vat_main_t * vam)
17600 unformat_input_t *input = vam->input;
17601 vl_api_pg_enable_disable_t *mp;
17604 u8 stream_name_set = 0;
17605 u8 *stream_name = 0;
17607 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17609 if (unformat (input, "stream %s", &stream_name))
17610 stream_name_set = 1;
17611 else if (unformat (input, "disable"))
17617 if (stream_name_set > 0)
17619 if (vec_len (stream_name) > 255)
17621 errmsg ("stream name too long");
17626 u32 name_len = vec_len (stream_name);
17627 /* Construct the API message */
17628 M (PG_ENABLE_DISABLE, mp);
17630 mp->is_enabled = enable;
17631 if (stream_name_set != 0)
17633 mp->stream_name_length = ntohl (name_len);
17634 clib_memcpy (mp->stream_name, stream_name, name_len);
17636 vec_free (stream_name);
17644 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
17646 unformat_input_t *input = vam->input;
17647 vl_api_ip_source_and_port_range_check_add_del_t *mp;
17649 u16 *low_ports = 0;
17650 u16 *high_ports = 0;
17653 ip4_address_t ip4_addr;
17654 ip6_address_t ip6_addr;
17663 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17665 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
17671 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
17676 else if (unformat (input, "vrf %d", &vrf_id))
17678 else if (unformat (input, "del"))
17680 else if (unformat (input, "port %d", &tmp))
17682 if (tmp == 0 || tmp > 65535)
17684 errmsg ("port %d out of range", tmp);
17688 this_hi = this_low + 1;
17689 vec_add1 (low_ports, this_low);
17690 vec_add1 (high_ports, this_hi);
17692 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
17694 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
17696 errmsg ("incorrect range parameters");
17700 /* Note: in debug CLI +1 is added to high before
17701 passing to real fn that does "the work"
17702 (ip_source_and_port_range_check_add_del).
17703 This fn is a wrapper around the binary API fn a
17704 control plane will call, which expects this increment
17705 to have occurred. Hence letting the binary API control
17706 plane fn do the increment for consistency between VAT
17707 and other control planes.
17710 vec_add1 (low_ports, this_low);
17711 vec_add1 (high_ports, this_hi);
17717 if (prefix_set == 0)
17719 errmsg ("<address>/<mask> not specified");
17725 errmsg ("VRF ID required, not specified");
17732 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17736 if (vec_len (low_ports) == 0)
17738 errmsg ("At least one port or port range required");
17742 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
17744 mp->is_add = is_add;
17749 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
17754 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
17757 mp->mask_length = length;
17758 mp->number_of_ranges = vec_len (low_ports);
17760 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
17761 vec_free (low_ports);
17763 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
17764 vec_free (high_ports);
17766 mp->vrf_id = ntohl (vrf_id);
17774 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
17776 unformat_input_t *input = vam->input;
17777 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
17778 u32 sw_if_index = ~0;
17780 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
17781 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
17785 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17787 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17789 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17791 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
17793 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
17795 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
17797 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
17799 else if (unformat (input, "del"))
17805 if (sw_if_index == ~0)
17807 errmsg ("Interface required but not specified");
17813 errmsg ("VRF ID required but not specified");
17817 if (tcp_out_vrf_id == 0
17818 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
17821 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17825 /* Construct the API message */
17826 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
17828 mp->sw_if_index = ntohl (sw_if_index);
17829 mp->is_add = is_add;
17830 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
17831 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
17832 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
17833 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
17838 /* Wait for a reply... */
17844 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
17846 unformat_input_t *i = vam->input;
17847 vl_api_ipsec_gre_add_del_tunnel_t *mp;
17848 u32 local_sa_id = 0;
17849 u32 remote_sa_id = 0;
17850 ip4_address_t src_address;
17851 ip4_address_t dst_address;
17855 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17857 if (unformat (i, "local_sa %d", &local_sa_id))
17859 else if (unformat (i, "remote_sa %d", &remote_sa_id))
17861 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
17863 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
17865 else if (unformat (i, "del"))
17869 clib_warning ("parse error '%U'", format_unformat_error, i);
17874 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
17876 mp->local_sa_id = ntohl (local_sa_id);
17877 mp->remote_sa_id = ntohl (remote_sa_id);
17878 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
17879 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
17880 mp->is_add = is_add;
17888 api_punt (vat_main_t * vam)
17890 unformat_input_t *i = vam->input;
17898 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17900 if (unformat (i, "ip %d", &ipv))
17902 else if (unformat (i, "protocol %d", &protocol))
17904 else if (unformat (i, "port %d", &port))
17906 else if (unformat (i, "del"))
17910 clib_warning ("parse error '%U'", format_unformat_error, i);
17917 mp->is_add = (u8) is_add;
17918 mp->ipv = (u8) ipv;
17919 mp->l4_protocol = (u8) protocol;
17920 mp->l4_port = htons ((u16) port);
17927 static void vl_api_ipsec_gre_tunnel_details_t_handler
17928 (vl_api_ipsec_gre_tunnel_details_t * mp)
17930 vat_main_t *vam = &vat_main;
17932 print (vam->ofp, "%11d%15U%15U%14d%14d",
17933 ntohl (mp->sw_if_index),
17934 format_ip4_address, &mp->src_address,
17935 format_ip4_address, &mp->dst_address,
17936 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
17939 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
17940 (vl_api_ipsec_gre_tunnel_details_t * mp)
17942 vat_main_t *vam = &vat_main;
17943 vat_json_node_t *node = NULL;
17944 struct in_addr ip4;
17946 if (VAT_JSON_ARRAY != vam->json_tree.type)
17948 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17949 vat_json_init_array (&vam->json_tree);
17951 node = vat_json_array_add (&vam->json_tree);
17953 vat_json_init_object (node);
17954 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17955 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
17956 vat_json_object_add_ip4 (node, "src_address", ip4);
17957 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
17958 vat_json_object_add_ip4 (node, "dst_address", ip4);
17959 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
17960 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
17964 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
17966 unformat_input_t *i = vam->input;
17967 vl_api_ipsec_gre_tunnel_dump_t *mp;
17968 vl_api_control_ping_t *mp_ping;
17970 u8 sw_if_index_set = 0;
17973 /* Parse args required to build the message */
17974 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17976 if (unformat (i, "sw_if_index %d", &sw_if_index))
17977 sw_if_index_set = 1;
17982 if (sw_if_index_set == 0)
17987 if (!vam->json_output)
17989 print (vam->ofp, "%11s%15s%15s%14s%14s",
17990 "sw_if_index", "src_address", "dst_address",
17991 "local_sa_id", "remote_sa_id");
17994 /* Get list of gre-tunnel interfaces */
17995 M (IPSEC_GRE_TUNNEL_DUMP, mp);
17997 mp->sw_if_index = htonl (sw_if_index);
18001 /* Use a control ping for synchronization */
18002 M (CONTROL_PING, mp_ping);
18010 api_delete_subif (vat_main_t * vam)
18012 unformat_input_t *i = vam->input;
18013 vl_api_delete_subif_t *mp;
18014 u32 sw_if_index = ~0;
18017 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18019 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18021 if (unformat (i, "sw_if_index %d", &sw_if_index))
18027 if (sw_if_index == ~0)
18029 errmsg ("missing sw_if_index");
18033 /* Construct the API message */
18034 M (DELETE_SUBIF, mp);
18035 mp->sw_if_index = ntohl (sw_if_index);
18042 #define foreach_pbb_vtr_op \
18043 _("disable", L2_VTR_DISABLED) \
18044 _("pop", L2_VTR_POP_2) \
18045 _("push", L2_VTR_PUSH_2)
18048 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
18050 unformat_input_t *i = vam->input;
18051 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
18052 u32 sw_if_index = ~0, vtr_op = ~0;
18053 u16 outer_tag = ~0;
18054 u8 dmac[6], smac[6];
18055 u8 dmac_set = 0, smac_set = 0;
18061 /* Shut up coverity */
18062 memset (dmac, 0, sizeof (dmac));
18063 memset (smac, 0, sizeof (smac));
18065 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18067 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18069 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18071 else if (unformat (i, "vtr_op %d", &vtr_op))
18073 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
18076 else if (unformat (i, "translate_pbb_stag"))
18078 if (unformat (i, "%d", &tmp))
18080 vtr_op = L2_VTR_TRANSLATE_2_1;
18086 ("translate_pbb_stag operation requires outer tag definition");
18090 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
18092 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
18094 else if (unformat (i, "sid %d", &sid))
18096 else if (unformat (i, "vlanid %d", &tmp))
18100 clib_warning ("parse error '%U'", format_unformat_error, i);
18105 if ((sw_if_index == ~0) || (vtr_op == ~0))
18107 errmsg ("missing sw_if_index or vtr operation");
18110 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
18111 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
18114 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
18118 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
18119 mp->sw_if_index = ntohl (sw_if_index);
18120 mp->vtr_op = ntohl (vtr_op);
18121 mp->outer_tag = ntohs (outer_tag);
18122 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
18123 clib_memcpy (mp->b_smac, smac, sizeof (smac));
18124 mp->b_vlanid = ntohs (vlanid);
18125 mp->i_sid = ntohl (sid);
18133 api_flow_classify_set_interface (vat_main_t * vam)
18135 unformat_input_t *i = vam->input;
18136 vl_api_flow_classify_set_interface_t *mp;
18138 int sw_if_index_set;
18139 u32 ip4_table_index = ~0;
18140 u32 ip6_table_index = ~0;
18144 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18146 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18147 sw_if_index_set = 1;
18148 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18149 sw_if_index_set = 1;
18150 else if (unformat (i, "del"))
18152 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18154 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18158 clib_warning ("parse error '%U'", format_unformat_error, i);
18163 if (sw_if_index_set == 0)
18165 errmsg ("missing interface name or sw_if_index");
18169 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
18171 mp->sw_if_index = ntohl (sw_if_index);
18172 mp->ip4_table_index = ntohl (ip4_table_index);
18173 mp->ip6_table_index = ntohl (ip6_table_index);
18174 mp->is_add = is_add;
18182 api_flow_classify_dump (vat_main_t * vam)
18184 unformat_input_t *i = vam->input;
18185 vl_api_flow_classify_dump_t *mp;
18186 vl_api_control_ping_t *mp_ping;
18187 u8 type = FLOW_CLASSIFY_N_TABLES;
18190 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
18194 errmsg ("classify table type must be specified");
18198 if (!vam->json_output)
18200 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18203 M (FLOW_CLASSIFY_DUMP, mp);
18208 /* Use a control ping for synchronization */
18209 M (CONTROL_PING, mp_ping);
18212 /* Wait for a reply... */
18218 api_feature_enable_disable (vat_main_t * vam)
18220 unformat_input_t *i = vam->input;
18221 vl_api_feature_enable_disable_t *mp;
18223 u8 *feature_name = 0;
18224 u32 sw_if_index = ~0;
18228 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18230 if (unformat (i, "arc_name %s", &arc_name))
18232 else if (unformat (i, "feature_name %s", &feature_name))
18235 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18237 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18239 else if (unformat (i, "disable"))
18247 errmsg ("missing arc name");
18250 if (vec_len (arc_name) > 63)
18252 errmsg ("arc name too long");
18255 if (feature_name == 0)
18257 errmsg ("missing feature name");
18260 if (vec_len (feature_name) > 63)
18262 errmsg ("feature name too long");
18265 if (sw_if_index == ~0)
18267 errmsg ("missing interface name or sw_if_index");
18271 /* Construct the API message */
18272 M (FEATURE_ENABLE_DISABLE, mp);
18273 mp->sw_if_index = ntohl (sw_if_index);
18274 mp->enable = enable;
18275 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
18276 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
18277 vec_free (arc_name);
18278 vec_free (feature_name);
18286 api_sw_interface_tag_add_del (vat_main_t * vam)
18288 unformat_input_t *i = vam->input;
18289 vl_api_sw_interface_tag_add_del_t *mp;
18290 u32 sw_if_index = ~0;
18295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18297 if (unformat (i, "tag %s", &tag))
18299 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18301 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18303 else if (unformat (i, "del"))
18309 if (sw_if_index == ~0)
18311 errmsg ("missing interface name or sw_if_index");
18315 if (enable && (tag == 0))
18317 errmsg ("no tag specified");
18321 /* Construct the API message */
18322 M (SW_INTERFACE_TAG_ADD_DEL, mp);
18323 mp->sw_if_index = ntohl (sw_if_index);
18324 mp->is_add = enable;
18326 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
18334 static void vl_api_l2_xconnect_details_t_handler
18335 (vl_api_l2_xconnect_details_t * mp)
18337 vat_main_t *vam = &vat_main;
18339 print (vam->ofp, "%15d%15d",
18340 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
18343 static void vl_api_l2_xconnect_details_t_handler_json
18344 (vl_api_l2_xconnect_details_t * mp)
18346 vat_main_t *vam = &vat_main;
18347 vat_json_node_t *node = NULL;
18349 if (VAT_JSON_ARRAY != vam->json_tree.type)
18351 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18352 vat_json_init_array (&vam->json_tree);
18354 node = vat_json_array_add (&vam->json_tree);
18356 vat_json_init_object (node);
18357 vat_json_object_add_uint (node, "rx_sw_if_index",
18358 ntohl (mp->rx_sw_if_index));
18359 vat_json_object_add_uint (node, "tx_sw_if_index",
18360 ntohl (mp->tx_sw_if_index));
18364 api_l2_xconnect_dump (vat_main_t * vam)
18366 vl_api_l2_xconnect_dump_t *mp;
18367 vl_api_control_ping_t *mp_ping;
18370 if (!vam->json_output)
18372 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
18375 M (L2_XCONNECT_DUMP, mp);
18379 /* Use a control ping for synchronization */
18380 M (CONTROL_PING, mp_ping);
18388 api_sw_interface_set_mtu (vat_main_t * vam)
18390 unformat_input_t *i = vam->input;
18391 vl_api_sw_interface_set_mtu_t *mp;
18392 u32 sw_if_index = ~0;
18396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18398 if (unformat (i, "mtu %d", &mtu))
18400 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18402 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18408 if (sw_if_index == ~0)
18410 errmsg ("missing interface name or sw_if_index");
18416 errmsg ("no mtu specified");
18420 /* Construct the API message */
18421 M (SW_INTERFACE_SET_MTU, mp);
18422 mp->sw_if_index = ntohl (sw_if_index);
18423 mp->mtu = ntohs ((u16) mtu);
18432 q_or_quit (vat_main_t * vam)
18434 #if VPP_API_TEST_BUILTIN == 0
18435 longjmp (vam->jump_buf, 1);
18437 return 0; /* not so much */
18441 q (vat_main_t * vam)
18443 return q_or_quit (vam);
18447 quit (vat_main_t * vam)
18449 return q_or_quit (vam);
18453 comment (vat_main_t * vam)
18459 cmd_cmp (void *a1, void *a2)
18464 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
18468 help (vat_main_t * vam)
18473 unformat_input_t *i = vam->input;
18476 if (unformat (i, "%s", &name))
18480 vec_add1 (name, 0);
18482 hs = hash_get_mem (vam->help_by_name, name);
18484 print (vam->ofp, "usage: %s %s", name, hs[0]);
18486 print (vam->ofp, "No such msg / command '%s'", name);
18491 print (vam->ofp, "Help is available for the following:");
18494 hash_foreach_pair (p, vam->function_by_name,
18496 vec_add1 (cmds, (u8 *)(p->key));
18500 vec_sort_with_function (cmds, cmd_cmp);
18502 for (j = 0; j < vec_len (cmds); j++)
18503 print (vam->ofp, "%s", cmds[j]);
18510 set (vat_main_t * vam)
18512 u8 *name = 0, *value = 0;
18513 unformat_input_t *i = vam->input;
18515 if (unformat (i, "%s", &name))
18517 /* The input buffer is a vector, not a string. */
18518 value = vec_dup (i->buffer);
18519 vec_delete (value, i->index, 0);
18520 /* Almost certainly has a trailing newline */
18521 if (value[vec_len (value) - 1] == '\n')
18522 value[vec_len (value) - 1] = 0;
18523 /* Make sure it's a proper string, one way or the other */
18524 vec_add1 (value, 0);
18525 (void) clib_macro_set_value (&vam->macro_main,
18526 (char *) name, (char *) value);
18529 errmsg ("usage: set <name> <value>");
18537 unset (vat_main_t * vam)
18541 if (unformat (vam->input, "%s", &name))
18542 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
18543 errmsg ("unset: %s wasn't set", name);
18556 macro_sort_cmp (void *a1, void *a2)
18558 macro_sort_t *s1 = a1;
18559 macro_sort_t *s2 = a2;
18561 return strcmp ((char *) (s1->name), (char *) (s2->name));
18565 dump_macro_table (vat_main_t * vam)
18567 macro_sort_t *sort_me = 0, *sm;
18572 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
18574 vec_add2 (sort_me, sm, 1);
18575 sm->name = (u8 *)(p->key);
18576 sm->value = (u8 *) (p->value[0]);
18580 vec_sort_with_function (sort_me, macro_sort_cmp);
18582 if (vec_len (sort_me))
18583 print (vam->ofp, "%-15s%s", "Name", "Value");
18585 print (vam->ofp, "The macro table is empty...");
18587 for (i = 0; i < vec_len (sort_me); i++)
18588 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
18593 dump_node_table (vat_main_t * vam)
18596 vlib_node_t *node, *next_node;
18598 if (vec_len (vam->graph_nodes) == 0)
18600 print (vam->ofp, "Node table empty, issue get_node_graph...");
18604 for (i = 0; i < vec_len (vam->graph_nodes); i++)
18606 node = vam->graph_nodes[i];
18607 print (vam->ofp, "[%d] %s", i, node->name);
18608 for (j = 0; j < vec_len (node->next_nodes); j++)
18610 if (node->next_nodes[j] != ~0)
18612 next_node = vam->graph_nodes[node->next_nodes[j]];
18613 print (vam->ofp, " [%d] %s", j, next_node->name);
18621 value_sort_cmp (void *a1, void *a2)
18623 name_sort_t *n1 = a1;
18624 name_sort_t *n2 = a2;
18626 if (n1->value < n2->value)
18628 if (n1->value > n2->value)
18635 dump_msg_api_table (vat_main_t * vam)
18637 api_main_t *am = &api_main;
18638 name_sort_t *nses = 0, *ns;
18643 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
18645 vec_add2 (nses, ns, 1);
18646 ns->name = (u8 *)(hp->key);
18647 ns->value = (u32) hp->value[0];
18651 vec_sort_with_function (nses, value_sort_cmp);
18653 for (i = 0; i < vec_len (nses); i++)
18654 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
18660 get_msg_id (vat_main_t * vam)
18665 if (unformat (vam->input, "%s", &name_and_crc))
18667 message_index = vl_api_get_msg_index (name_and_crc);
18668 if (message_index == ~0)
18670 print (vam->ofp, " '%s' not found", name_and_crc);
18673 print (vam->ofp, " '%s' has message index %d",
18674 name_and_crc, message_index);
18677 errmsg ("name_and_crc required...");
18682 search_node_table (vat_main_t * vam)
18684 unformat_input_t *line_input = vam->input;
18687 vlib_node_t *node, *next_node;
18690 if (vam->graph_node_index_by_name == 0)
18692 print (vam->ofp, "Node table empty, issue get_node_graph...");
18696 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
18698 if (unformat (line_input, "%s", &node_to_find))
18700 vec_add1 (node_to_find, 0);
18701 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
18704 print (vam->ofp, "%s not found...", node_to_find);
18707 node = vam->graph_nodes[p[0]];
18708 print (vam->ofp, "[%d] %s", p[0], node->name);
18709 for (j = 0; j < vec_len (node->next_nodes); j++)
18711 if (node->next_nodes[j] != ~0)
18713 next_node = vam->graph_nodes[node->next_nodes[j]];
18714 print (vam->ofp, " [%d] %s", j, next_node->name);
18721 clib_warning ("parse error '%U'", format_unformat_error,
18727 vec_free (node_to_find);
18736 script (vat_main_t * vam)
18738 #if (VPP_API_TEST_BUILTIN==0)
18740 char *save_current_file;
18741 unformat_input_t save_input;
18742 jmp_buf save_jump_buf;
18743 u32 save_line_number;
18745 FILE *new_fp, *save_ifp;
18747 if (unformat (vam->input, "%s", &s))
18749 new_fp = fopen ((char *) s, "r");
18752 errmsg ("Couldn't open script file %s", s);
18759 errmsg ("Missing script name");
18763 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
18764 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
18765 save_ifp = vam->ifp;
18766 save_line_number = vam->input_line_number;
18767 save_current_file = (char *) vam->current_file;
18769 vam->input_line_number = 0;
18771 vam->current_file = s;
18774 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
18775 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
18776 vam->ifp = save_ifp;
18777 vam->input_line_number = save_line_number;
18778 vam->current_file = (u8 *) save_current_file;
18783 clib_warning ("use the exec command...");
18789 echo (vat_main_t * vam)
18791 print (vam->ofp, "%v", vam->input->buffer);
18795 /* List of API message constructors, CLI names map to api_xxx */
18796 #define foreach_vpe_api_msg \
18797 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
18798 _(sw_interface_dump,"") \
18799 _(sw_interface_set_flags, \
18800 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
18801 _(sw_interface_add_del_address, \
18802 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
18803 _(sw_interface_set_table, \
18804 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
18805 _(sw_interface_set_mpls_enable, \
18806 "<intfc> | sw_if_index [disable | dis]") \
18807 _(sw_interface_set_vpath, \
18808 "<intfc> | sw_if_index <id> enable | disable") \
18809 _(sw_interface_set_vxlan_bypass, \
18810 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
18811 _(sw_interface_set_l2_xconnect, \
18812 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18813 "enable | disable") \
18814 _(sw_interface_set_l2_bridge, \
18815 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
18816 "[shg <split-horizon-group>] [bvi]\n" \
18817 "enable | disable") \
18818 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
18819 _(bridge_domain_add_del, \
18820 "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") \
18821 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
18823 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
18824 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
18825 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
18827 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
18829 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
18831 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
18833 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
18835 "<vpp-if-name> | sw_if_index <id>") \
18836 _(sw_interface_tap_dump, "") \
18837 _(ip_add_del_route, \
18838 "<addr>/<mask> via <addr> [table-id <n>]\n" \
18839 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18840 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18841 "[multipath] [count <n>]") \
18842 _(ip_mroute_add_del, \
18843 "<src> <grp>/<mask> [table-id <n>]\n" \
18844 "[<intfc> | sw_if_index <id>] [local] [del]") \
18845 _(mpls_route_add_del, \
18846 "<label> <eos> via <addr> [table-id <n>]\n" \
18847 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18848 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18849 "[multipath] [count <n>]") \
18850 _(mpls_ip_bind_unbind, \
18851 "<label> <addr/len>") \
18852 _(mpls_tunnel_add_del, \
18853 " via <addr> [table-id <n>]\n" \
18854 "sw_if_index <id>] [l2] [del]") \
18855 _(proxy_arp_add_del, \
18856 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
18857 _(proxy_arp_intfc_enable_disable, \
18858 "<intfc> | sw_if_index <id> enable | disable") \
18859 _(sw_interface_set_unnumbered, \
18860 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
18861 _(ip_neighbor_add_del, \
18862 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
18863 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
18864 _(reset_vrf, "vrf <id> [ipv6]") \
18865 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
18866 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
18867 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
18868 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
18869 "[outer_vlan_id_any][inner_vlan_id_any]") \
18870 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
18871 _(reset_fib, "vrf <n> [ipv6]") \
18872 _(dhcp_proxy_config, \
18873 "svr <v46-address> src <v46-address>\n" \
18874 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
18875 _(dhcp_proxy_set_vss, \
18876 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
18877 _(dhcp_proxy_dump, "ip6") \
18878 _(dhcp_client_config, \
18879 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
18880 _(set_ip_flow_hash, \
18881 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
18882 _(sw_interface_ip6_enable_disable, \
18883 "<intfc> | sw_if_index <id> enable | disable") \
18884 _(sw_interface_ip6_set_link_local_address, \
18885 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
18886 _(ip6nd_proxy_add_del, \
18887 "<intfc> | sw_if_index <id> <ip6-address>") \
18888 _(ip6nd_proxy_dump, "") \
18889 _(sw_interface_ip6nd_ra_prefix, \
18890 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
18891 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
18892 "[nolink] [isno]") \
18893 _(sw_interface_ip6nd_ra_config, \
18894 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
18895 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
18896 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
18897 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
18898 _(l2_patch_add_del, \
18899 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18900 "enable | disable") \
18901 _(sr_localsid_add_del, \
18902 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
18903 "fib-table <num> (end.psp) sw_if_index <num>") \
18904 _(classify_add_del_table, \
18905 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
18906 " [del] [del-chain] mask <mask-value>\n" \
18907 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
18908 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
18909 _(classify_add_del_session, \
18910 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
18911 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
18912 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
18913 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
18914 _(classify_set_interface_ip_table, \
18915 "<intfc> | sw_if_index <nn> table <nn>") \
18916 _(classify_set_interface_l2_tables, \
18917 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18918 " [other-table <nn>]") \
18919 _(get_node_index, "node <node-name") \
18920 _(add_node_next, "node <node-name> next <next-node-name>") \
18921 _(l2tpv3_create_tunnel, \
18922 "client_address <ip6-addr> our_address <ip6-addr>\n" \
18923 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
18924 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
18925 _(l2tpv3_set_tunnel_cookies, \
18926 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
18927 "[new_remote_cookie <nn>]\n") \
18928 _(l2tpv3_interface_enable_disable, \
18929 "<intfc> | sw_if_index <nn> enable | disable") \
18930 _(l2tpv3_set_lookup_key, \
18931 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
18932 _(sw_if_l2tpv3_tunnel_dump, "") \
18933 _(vxlan_add_del_tunnel, \
18934 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
18935 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
18936 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
18937 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18938 _(gre_add_del_tunnel, \
18939 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
18940 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18941 _(l2_fib_clear_table, "") \
18942 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
18943 _(l2_interface_vlan_tag_rewrite, \
18944 "<intfc> | sw_if_index <nn> \n" \
18945 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
18946 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
18947 _(create_vhost_user_if, \
18948 "socket <filename> [server] [renumber <dev_instance>] " \
18949 "[mac <mac_address>]") \
18950 _(modify_vhost_user_if, \
18951 "<intfc> | sw_if_index <nn> socket <filename>\n" \
18952 "[server] [renumber <dev_instance>]") \
18953 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
18954 _(sw_interface_vhost_user_dump, "") \
18955 _(show_version, "") \
18956 _(vxlan_gpe_add_del_tunnel, \
18957 "local <addr> remote <addr> vni <nn>\n" \
18958 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
18959 "[next-ethernet] [next-nsh]\n") \
18960 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18961 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
18962 _(interface_name_renumber, \
18963 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
18964 _(input_acl_set_interface, \
18965 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18966 " [l2-table <nn>] [del]") \
18967 _(want_ip4_arp_events, "address <ip4-address> [del]") \
18968 _(want_ip6_nd_events, "address <ip6-address> [del]") \
18969 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
18970 _(ip_dump, "ipv4 | ipv6") \
18971 _(ipsec_spd_add_del, "spd_id <n> [del]") \
18972 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
18974 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
18975 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
18976 " integ_alg <alg> integ_key <hex>") \
18977 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
18978 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
18979 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
18980 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
18981 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
18982 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
18983 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
18984 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
18985 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
18986 _(ikev2_profile_add_del, "name <profile_name> [del]") \
18987 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
18988 "(auth_data 0x<data> | auth_data <data>)") \
18989 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
18990 "(id_data 0x<data> | id_data <data>) (local|remote)") \
18991 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
18992 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
18993 "(local|remote)") \
18994 _(ikev2_set_local_key, "file <absolute_file_path>") \
18995 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
18996 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18997 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18998 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
18999 _(ikev2_initiate_sa_init, "<profile_name>") \
19000 _(ikev2_initiate_del_ike_sa, "<ispi>") \
19001 _(ikev2_initiate_del_child_sa, "<ispi>") \
19002 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
19003 _(delete_loopback,"sw_if_index <nn>") \
19004 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
19005 _(map_add_domain, \
19006 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
19007 "ip6-src <ip6addr> " \
19008 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
19009 _(map_del_domain, "index <n>") \
19010 _(map_add_del_rule, \
19011 "index <n> psid <n> dst <ip6addr> [del]") \
19012 _(map_domain_dump, "") \
19013 _(map_rule_dump, "index <map-domain>") \
19014 _(want_interface_events, "enable|disable") \
19015 _(want_stats,"enable|disable") \
19016 _(get_first_msg_id, "client <name>") \
19017 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
19018 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
19019 "fib-id <nn> [ip4][ip6][default]") \
19020 _(get_node_graph, " ") \
19021 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
19022 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
19023 _(ioam_disable, "") \
19024 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
19025 " sw_if_index <sw_if_index> p <priority> " \
19026 "w <weight>] [del]") \
19027 _(one_add_del_locator, "locator-set <locator_name> " \
19028 "iface <intf> | sw_if_index <sw_if_index> " \
19029 "p <priority> w <weight> [del]") \
19030 _(one_add_del_local_eid,"vni <vni> eid " \
19031 "<ipv4|ipv6>/<prefix> | <L2 address> " \
19032 "locator-set <locator_name> [del]" \
19033 "[key-id sha1|sha256 secret-key <secret-key>]")\
19034 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
19035 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
19036 _(one_enable_disable, "enable|disable") \
19037 _(one_map_register_enable_disable, "enable|disable") \
19038 _(one_rloc_probe_enable_disable, "enable|disable") \
19039 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
19041 "rloc <locator> p <prio> " \
19042 "w <weight> [rloc <loc> ... ] " \
19043 "action <action> [del-all]") \
19044 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
19046 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
19047 _(one_use_petr, "ip-address> | disable") \
19048 _(one_map_request_mode, "src-dst|dst-only") \
19049 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
19050 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
19051 _(one_locator_set_dump, "[local | remote]") \
19052 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
19053 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
19054 "[local] | [remote]") \
19055 _(one_stats_enable_disable, "enable|disalbe") \
19056 _(show_one_stats_enable_disable, "") \
19057 _(one_eid_table_vni_dump, "") \
19058 _(one_eid_table_map_dump, "l2|l3") \
19059 _(one_map_resolver_dump, "") \
19060 _(one_map_server_dump, "") \
19061 _(one_adjacencies_get, "vni <vni>") \
19062 _(show_one_rloc_probe_state, "") \
19063 _(show_one_map_register_state, "") \
19064 _(show_one_status, "") \
19065 _(one_stats_dump, "") \
19066 _(one_stats_flush, "") \
19067 _(one_get_map_request_itr_rlocs, "") \
19068 _(show_one_pitr, "") \
19069 _(show_one_use_petr, "") \
19070 _(show_one_map_request_mode, "") \
19071 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
19072 " sw_if_index <sw_if_index> p <priority> " \
19073 "w <weight>] [del]") \
19074 _(lisp_add_del_locator, "locator-set <locator_name> " \
19075 "iface <intf> | sw_if_index <sw_if_index> " \
19076 "p <priority> w <weight> [del]") \
19077 _(lisp_add_del_local_eid,"vni <vni> eid " \
19078 "<ipv4|ipv6>/<prefix> | <L2 address> " \
19079 "locator-set <locator_name> [del]" \
19080 "[key-id sha1|sha256 secret-key <secret-key>]") \
19081 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
19082 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
19083 _(lisp_enable_disable, "enable|disable") \
19084 _(lisp_map_register_enable_disable, "enable|disable") \
19085 _(lisp_rloc_probe_enable_disable, "enable|disable") \
19086 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
19088 "rloc <locator> p <prio> " \
19089 "w <weight> [rloc <loc> ... ] " \
19090 "action <action> [del-all]") \
19091 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
19093 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
19094 _(lisp_use_petr, "<ip-address> | disable") \
19095 _(lisp_map_request_mode, "src-dst|dst-only") \
19096 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
19097 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
19098 _(lisp_locator_set_dump, "[local | remote]") \
19099 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
19100 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
19101 "[local] | [remote]") \
19102 _(lisp_eid_table_vni_dump, "") \
19103 _(lisp_eid_table_map_dump, "l2|l3") \
19104 _(lisp_map_resolver_dump, "") \
19105 _(lisp_map_server_dump, "") \
19106 _(lisp_adjacencies_get, "vni <vni>") \
19107 _(gpe_fwd_entry_vnis_get, "") \
19108 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
19109 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
19110 _(gpe_set_encap_mode, "lisp|vxlan") \
19111 _(gpe_get_encap_mode, "") \
19112 _(lisp_gpe_add_del_iface, "up|down") \
19113 _(lisp_gpe_enable_disable, "enable|disable") \
19114 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
19115 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
19116 _(show_lisp_rloc_probe_state, "") \
19117 _(show_lisp_map_register_state, "") \
19118 _(show_lisp_status, "") \
19119 _(lisp_get_map_request_itr_rlocs, "") \
19120 _(show_lisp_pitr, "") \
19121 _(show_lisp_use_petr, "") \
19122 _(show_lisp_map_request_mode, "") \
19123 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
19124 _(af_packet_delete, "name <host interface name>") \
19125 _(policer_add_del, "name <policer name> <params> [del]") \
19126 _(policer_dump, "[name <policer name>]") \
19127 _(policer_classify_set_interface, \
19128 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19129 " [l2-table <nn>] [del]") \
19130 _(policer_classify_dump, "type [ip4|ip6|l2]") \
19131 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
19132 "[master|slave]") \
19133 _(netmap_delete, "name <interface name>") \
19134 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
19135 _(mpls_fib_dump, "") \
19136 _(classify_table_ids, "") \
19137 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
19138 _(classify_table_info, "table_id <nn>") \
19139 _(classify_session_dump, "table_id <nn>") \
19140 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
19141 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
19142 "[template_interval <nn>] [udp_checksum]") \
19143 _(ipfix_exporter_dump, "") \
19144 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
19145 _(ipfix_classify_stream_dump, "") \
19146 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
19147 _(ipfix_classify_table_dump, "") \
19148 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
19149 _(sw_interface_span_dump, "") \
19150 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
19151 _(pg_create_interface, "if_id <nn>") \
19152 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
19153 _(pg_enable_disable, "[stream <id>] disable") \
19154 _(ip_source_and_port_range_check_add_del, \
19155 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
19156 _(ip_source_and_port_range_check_interface_add_del, \
19157 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
19158 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
19159 _(ipsec_gre_add_del_tunnel, \
19160 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
19161 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
19162 _(delete_subif,"<intfc> | sw_if_index <nn>") \
19163 _(l2_interface_pbb_tag_rewrite, \
19164 "<intfc> | sw_if_index <nn> \n" \
19165 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
19166 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
19167 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
19168 _(flow_classify_set_interface, \
19169 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
19170 _(flow_classify_dump, "type [ip4|ip6]") \
19171 _(ip_fib_dump, "") \
19172 _(ip_mfib_dump, "") \
19173 _(ip6_fib_dump, "") \
19174 _(ip6_mfib_dump, "") \
19175 _(feature_enable_disable, "arc_name <arc_name> " \
19176 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
19177 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
19179 _(l2_xconnect_dump, "") \
19180 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
19181 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
19182 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
19184 /* List of command functions, CLI names map directly to functions */
19185 #define foreach_cli_function \
19186 _(comment, "usage: comment <ignore-rest-of-line>") \
19187 _(dump_interface_table, "usage: dump_interface_table") \
19188 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
19189 _(dump_ipv4_table, "usage: dump_ipv4_table") \
19190 _(dump_ipv6_table, "usage: dump_ipv6_table") \
19191 _(dump_stats_table, "usage: dump_stats_table") \
19192 _(dump_macro_table, "usage: dump_macro_table ") \
19193 _(dump_node_table, "usage: dump_node_table") \
19194 _(dump_msg_api_table, "usage: dump_msg_api_table") \
19195 _(get_msg_id, "usage: get_msg_id name_and_crc") \
19196 _(echo, "usage: echo <message>") \
19197 _(exec, "usage: exec <vpe-debug-CLI-command>") \
19198 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
19199 _(help, "usage: help") \
19200 _(q, "usage: quit") \
19201 _(quit, "usage: quit") \
19202 _(search_node_table, "usage: search_node_table <name>...") \
19203 _(set, "usage: set <variable-name> <value>") \
19204 _(script, "usage: script <file-name>") \
19205 _(unset, "usage: unset <variable-name>")
19208 static void vl_api_##n##_t_handler_uni \
19209 (vl_api_##n##_t * mp) \
19211 vat_main_t * vam = &vat_main; \
19212 if (vam->json_output) { \
19213 vl_api_##n##_t_handler_json(mp); \
19215 vl_api_##n##_t_handler(mp); \
19218 foreach_vpe_api_reply_msg;
19219 #if VPP_API_TEST_BUILTIN == 0
19220 foreach_standalone_reply_msg;
19225 vat_api_hookup (vat_main_t * vam)
19228 vl_msg_api_set_handlers(VL_API_##N, #n, \
19229 vl_api_##n##_t_handler_uni, \
19231 vl_api_##n##_t_endian, \
19232 vl_api_##n##_t_print, \
19233 sizeof(vl_api_##n##_t), 1);
19234 foreach_vpe_api_reply_msg;
19235 #if VPP_API_TEST_BUILTIN == 0
19236 foreach_standalone_reply_msg;
19240 #if (VPP_API_TEST_BUILTIN==0)
19241 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
19243 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
19245 vam->function_by_name = hash_create_string (0, sizeof (uword));
19247 vam->help_by_name = hash_create_string (0, sizeof (uword));
19250 /* API messages we can send */
19251 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
19252 foreach_vpe_api_msg;
19256 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
19257 foreach_vpe_api_msg;
19260 /* CLI functions */
19261 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
19262 foreach_cli_function;
19266 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
19267 foreach_cli_function;
19271 #if VPP_API_TEST_BUILTIN
19272 static clib_error_t *
19273 vat_api_hookup_shim (vlib_main_t * vm)
19275 vat_api_hookup (&vat_main);
19279 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
19283 * fd.io coding-style-patch-verification: ON
19286 * eval: (c-set-style "gnu")