2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vlibapi/api.h>
22 #include <vlibmemory/api.h>
23 #include <vlibsocket/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/l2/l2_input.h>
26 #include <vnet/l2tp/l2tp.h>
27 #include <vnet/vxlan/vxlan.h>
28 #include <vnet/gre/gre.h>
29 #include <vnet/vxlan-gpe/vxlan_gpe.h>
30 #include <vnet/lisp-gpe/lisp_gpe.h>
32 #include <vpp/api/vpe_msg_enum.h>
33 #include <vnet/l2/l2_classify.h>
34 #include <vnet/l2/l2_vtr.h>
35 #include <vnet/classify/input_acl.h>
36 #include <vnet/classify/policer_classify.h>
37 #include <vnet/classify/flow_classify.h>
38 #include <vnet/mpls/mpls.h>
39 #include <vnet/ipsec/ipsec.h>
40 #include <vnet/ipsec/ikev2.h>
42 #include <vnet/map/map.h>
43 #include <vnet/cop/cop.h>
44 #include <vnet/ip/ip6_hop_by_hop.h>
45 #include <vnet/ip/ip_source_and_port_range_check.h>
46 #include <vnet/policer/xlate.h>
47 #include <vnet/span/span.h>
48 #include <vnet/policer/policer.h>
49 #include <vnet/policer/police.h>
50 #include <vnet/mfib/mfib_types.h>
52 #include "vat/json_format.h"
57 #define vl_typedefs /* define message structures */
58 #include <vpp/api/vpe_all_api_h.h>
61 /* declare message handlers for each api */
63 #define vl_endianfun /* define message structures */
64 #include <vpp/api/vpe_all_api_h.h>
67 /* instantiate all the print functions we know about */
68 #define vl_print(handle, ...)
70 #include <vpp/api/vpe_all_api_h.h>
73 #define __plugin_msg_base 0
74 #include <vlibapi/vat_helper_macros.h>
77 vat_time_now (vat_main_t * vam)
79 #if VPP_API_TEST_BUILTIN
80 return vlib_time_now (vam->vlib_main);
82 return clib_time_now (&vam->clib_time);
87 errmsg (char *fmt, ...)
89 vat_main_t *vam = &vat_main;
94 s = va_format (0, fmt, &va);
99 #if VPP_API_TEST_BUILTIN
100 vlib_cli_output (vam->vlib_main, (char *) s);
103 if (vam->ifp != stdin)
104 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
105 vam->input_line_number);
106 fformat (vam->ofp, (char *) s);
114 #if VPP_API_TEST_BUILTIN == 0
116 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
118 vat_main_t *vam = va_arg (*args, vat_main_t *);
119 u32 *result = va_arg (*args, u32 *);
123 if (!unformat (input, "%s", &if_name))
126 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
133 /* Parse an IP4 address %d.%d.%d.%d. */
135 unformat_ip4_address (unformat_input_t * input, va_list * args)
137 u8 *result = va_arg (*args, u8 *);
140 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
143 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
155 unformat_ethernet_address (unformat_input_t * input, va_list * args)
157 u8 *result = va_arg (*args, u8 *);
160 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
161 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
165 for (i = 0; i < 6; i++)
166 if (a[i] >= (1 << 8))
169 for (i = 0; i < 6; i++)
175 /* Returns ethernet type as an int in host byte order. */
177 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
180 u16 *result = va_arg (*args, u16 *);
184 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
186 if (type >= (1 << 16))
194 /* Parse an IP6 address. */
196 unformat_ip6_address (unformat_input_t * input, va_list * args)
198 ip6_address_t *result = va_arg (*args, ip6_address_t *);
200 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
201 uword c, n_colon, double_colon_index;
203 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
204 double_colon_index = ARRAY_LEN (hex_quads);
205 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
208 if (c >= '0' && c <= '9')
210 else if (c >= 'a' && c <= 'f')
211 hex_digit = c + 10 - 'a';
212 else if (c >= 'A' && c <= 'F')
213 hex_digit = c + 10 - 'A';
214 else if (c == ':' && n_colon < 2)
218 unformat_put_input (input);
222 /* Too many hex quads. */
223 if (n_hex_quads >= ARRAY_LEN (hex_quads))
228 hex_quad = (hex_quad << 4) | hex_digit;
230 /* Hex quad must fit in 16 bits. */
231 if (n_hex_digits >= 4)
238 /* Save position of :: */
241 /* More than one :: ? */
242 if (double_colon_index < ARRAY_LEN (hex_quads))
244 double_colon_index = n_hex_quads;
247 if (n_colon > 0 && n_hex_digits > 0)
249 hex_quads[n_hex_quads++] = hex_quad;
255 if (n_hex_digits > 0)
256 hex_quads[n_hex_quads++] = hex_quad;
261 /* Expand :: to appropriate number of zero hex quads. */
262 if (double_colon_index < ARRAY_LEN (hex_quads))
264 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
266 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
267 hex_quads[n_zero + i] = hex_quads[i];
269 for (i = 0; i < n_zero; i++)
270 hex_quads[double_colon_index + i] = 0;
272 n_hex_quads = ARRAY_LEN (hex_quads);
275 /* Too few hex quads given. */
276 if (n_hex_quads < ARRAY_LEN (hex_quads))
279 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
280 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
287 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
289 u32 *r = va_arg (*args, u32 *);
292 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
293 foreach_ipsec_policy_action
301 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
303 u32 *r = va_arg (*args, u32 *);
306 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
307 foreach_ipsec_crypto_alg
315 format_ipsec_crypto_alg (u8 * s, va_list * args)
317 u32 i = va_arg (*args, u32);
322 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
323 foreach_ipsec_crypto_alg
326 return format (s, "unknown");
328 return format (s, "%s", t);
332 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
334 u32 *r = va_arg (*args, u32 *);
337 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
338 foreach_ipsec_integ_alg
346 format_ipsec_integ_alg (u8 * s, va_list * args)
348 u32 i = va_arg (*args, u32);
353 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
354 foreach_ipsec_integ_alg
357 return format (s, "unknown");
359 return format (s, "%s", t);
363 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
365 u32 *r = va_arg (*args, u32 *);
368 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
369 foreach_ikev2_auth_method
377 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
379 u32 *r = va_arg (*args, u32 *);
382 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
383 foreach_ikev2_id_type
389 #else /* VPP_API_TEST_BUILTIN == 1 */
391 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
393 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
394 vnet_main_t *vnm = vnet_get_main ();
395 u32 *result = va_arg (*args, u32 *);
398 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
401 *result = sw_if_index;
404 #endif /* VPP_API_TEST_BUILTIN */
407 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
409 u8 *r = va_arg (*args, u8 *);
411 if (unformat (input, "kbps"))
412 *r = SSE2_QOS_RATE_KBPS;
413 else if (unformat (input, "pps"))
414 *r = SSE2_QOS_RATE_PPS;
421 unformat_policer_round_type (unformat_input_t * input, va_list * args)
423 u8 *r = va_arg (*args, u8 *);
425 if (unformat (input, "closest"))
426 *r = SSE2_QOS_ROUND_TO_CLOSEST;
427 else if (unformat (input, "up"))
428 *r = SSE2_QOS_ROUND_TO_UP;
429 else if (unformat (input, "down"))
430 *r = SSE2_QOS_ROUND_TO_DOWN;
437 unformat_policer_type (unformat_input_t * input, va_list * args)
439 u8 *r = va_arg (*args, u8 *);
441 if (unformat (input, "1r2c"))
442 *r = SSE2_QOS_POLICER_TYPE_1R2C;
443 else if (unformat (input, "1r3c"))
444 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
445 else if (unformat (input, "2r3c-2698"))
446 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
447 else if (unformat (input, "2r3c-4115"))
448 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
449 else if (unformat (input, "2r3c-mef5cf1"))
450 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
457 unformat_dscp (unformat_input_t * input, va_list * va)
459 u8 *r = va_arg (*va, u8 *);
462 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
471 unformat_policer_action_type (unformat_input_t * input, va_list * va)
473 sse2_qos_pol_action_params_st *a
474 = va_arg (*va, sse2_qos_pol_action_params_st *);
476 if (unformat (input, "drop"))
477 a->action_type = SSE2_QOS_ACTION_DROP;
478 else if (unformat (input, "transmit"))
479 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
480 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
481 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
488 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
490 u32 *r = va_arg (*va, u32 *);
493 if (unformat (input, "ip4"))
494 tid = POLICER_CLASSIFY_TABLE_IP4;
495 else if (unformat (input, "ip6"))
496 tid = POLICER_CLASSIFY_TABLE_IP6;
497 else if (unformat (input, "l2"))
498 tid = POLICER_CLASSIFY_TABLE_L2;
507 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
509 u32 *r = va_arg (*va, u32 *);
512 if (unformat (input, "ip4"))
513 tid = FLOW_CLASSIFY_TABLE_IP4;
514 else if (unformat (input, "ip6"))
515 tid = FLOW_CLASSIFY_TABLE_IP6;
523 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
524 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
525 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
526 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
528 #if (VPP_API_TEST_BUILTIN==0)
530 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
532 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
533 mfib_itf_attribute_t attr;
536 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
538 if (unformat (input, mfib_itf_flag_long_names[attr]))
539 *iflags |= (1 << attr);
541 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
543 if (unformat (input, mfib_itf_flag_names[attr]))
544 *iflags |= (1 << attr);
547 return (old == *iflags ? 0 : 1);
551 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
553 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
554 mfib_entry_attribute_t attr;
557 FOR_EACH_MFIB_ATTRIBUTE (attr)
559 if (unformat (input, mfib_flag_long_names[attr]))
560 *eflags |= (1 << attr);
562 FOR_EACH_MFIB_ATTRIBUTE (attr)
564 if (unformat (input, mfib_flag_names[attr]))
565 *eflags |= (1 << attr);
568 return (old == *eflags ? 0 : 1);
572 format_ip4_address (u8 * s, va_list * args)
574 u8 *a = va_arg (*args, u8 *);
575 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
579 format_ip6_address (u8 * s, va_list * args)
581 ip6_address_t *a = va_arg (*args, ip6_address_t *);
582 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
584 i_max_n_zero = ARRAY_LEN (a->as_u16);
586 i_first_zero = i_max_n_zero;
588 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
590 u32 is_zero = a->as_u16[i] == 0;
591 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
597 if ((!is_zero && n_zeros > max_n_zeros)
598 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
600 i_max_n_zero = i_first_zero;
601 max_n_zeros = n_zeros;
602 i_first_zero = ARRAY_LEN (a->as_u16);
607 last_double_colon = 0;
608 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
610 if (i == i_max_n_zero && max_n_zeros > 1)
612 s = format (s, "::");
613 i += max_n_zeros - 1;
614 last_double_colon = 1;
618 s = format (s, "%s%x",
619 (last_double_colon || i == 0) ? "" : ":",
620 clib_net_to_host_u16 (a->as_u16[i]));
621 last_double_colon = 0;
628 /* Format an IP46 address. */
630 format_ip46_address (u8 * s, va_list * args)
632 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
633 ip46_type_t type = va_arg (*args, ip46_type_t);
639 is_ip4 = ip46_address_is_ip4 (ip46);
650 format (s, "%U", format_ip4_address, &ip46->ip4) :
651 format (s, "%U", format_ip6_address, &ip46->ip6);
655 format_ethernet_address (u8 * s, va_list * args)
657 u8 *a = va_arg (*args, u8 *);
659 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
660 a[0], a[1], a[2], a[3], a[4], a[5]);
665 increment_v4_address (ip4_address_t * a)
669 v = ntohl (a->as_u32) + 1;
670 a->as_u32 = ntohl (v);
674 increment_v6_address (ip6_address_t * a)
678 v0 = clib_net_to_host_u64 (a->as_u64[0]);
679 v1 = clib_net_to_host_u64 (a->as_u64[1]);
684 a->as_u64[0] = clib_net_to_host_u64 (v0);
685 a->as_u64[1] = clib_net_to_host_u64 (v1);
689 increment_mac_address (u64 * mac)
693 tmp = clib_net_to_host_u64 (tmp);
694 tmp += 1 << 16; /* skip unused (least significant) octets */
695 tmp = clib_host_to_net_u64 (tmp);
699 static void vl_api_create_loopback_reply_t_handler
700 (vl_api_create_loopback_reply_t * mp)
702 vat_main_t *vam = &vat_main;
703 i32 retval = ntohl (mp->retval);
705 vam->retval = retval;
706 vam->regenerate_interface_table = 1;
707 vam->sw_if_index = ntohl (mp->sw_if_index);
708 vam->result_ready = 1;
711 static void vl_api_create_loopback_reply_t_handler_json
712 (vl_api_create_loopback_reply_t * mp)
714 vat_main_t *vam = &vat_main;
715 vat_json_node_t node;
717 vat_json_init_object (&node);
718 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
719 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
721 vat_json_print (vam->ofp, &node);
722 vat_json_free (&node);
723 vam->retval = ntohl (mp->retval);
724 vam->result_ready = 1;
727 static void vl_api_create_loopback_instance_reply_t_handler
728 (vl_api_create_loopback_instance_reply_t * mp)
730 vat_main_t *vam = &vat_main;
731 i32 retval = ntohl (mp->retval);
733 vam->retval = retval;
734 vam->regenerate_interface_table = 1;
735 vam->sw_if_index = ntohl (mp->sw_if_index);
736 vam->result_ready = 1;
739 static void vl_api_create_loopback_instance_reply_t_handler_json
740 (vl_api_create_loopback_instance_reply_t * mp)
742 vat_main_t *vam = &vat_main;
743 vat_json_node_t node;
745 vat_json_init_object (&node);
746 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
747 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
749 vat_json_print (vam->ofp, &node);
750 vat_json_free (&node);
751 vam->retval = ntohl (mp->retval);
752 vam->result_ready = 1;
755 static void vl_api_af_packet_create_reply_t_handler
756 (vl_api_af_packet_create_reply_t * mp)
758 vat_main_t *vam = &vat_main;
759 i32 retval = ntohl (mp->retval);
761 vam->retval = retval;
762 vam->regenerate_interface_table = 1;
763 vam->sw_if_index = ntohl (mp->sw_if_index);
764 vam->result_ready = 1;
767 static void vl_api_af_packet_create_reply_t_handler_json
768 (vl_api_af_packet_create_reply_t * mp)
770 vat_main_t *vam = &vat_main;
771 vat_json_node_t node;
773 vat_json_init_object (&node);
774 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
775 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
777 vat_json_print (vam->ofp, &node);
778 vat_json_free (&node);
780 vam->retval = ntohl (mp->retval);
781 vam->result_ready = 1;
784 static void vl_api_create_vlan_subif_reply_t_handler
785 (vl_api_create_vlan_subif_reply_t * mp)
787 vat_main_t *vam = &vat_main;
788 i32 retval = ntohl (mp->retval);
790 vam->retval = retval;
791 vam->regenerate_interface_table = 1;
792 vam->sw_if_index = ntohl (mp->sw_if_index);
793 vam->result_ready = 1;
796 static void vl_api_create_vlan_subif_reply_t_handler_json
797 (vl_api_create_vlan_subif_reply_t * mp)
799 vat_main_t *vam = &vat_main;
800 vat_json_node_t node;
802 vat_json_init_object (&node);
803 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
804 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
806 vat_json_print (vam->ofp, &node);
807 vat_json_free (&node);
809 vam->retval = ntohl (mp->retval);
810 vam->result_ready = 1;
813 static void vl_api_create_subif_reply_t_handler
814 (vl_api_create_subif_reply_t * mp)
816 vat_main_t *vam = &vat_main;
817 i32 retval = ntohl (mp->retval);
819 vam->retval = retval;
820 vam->regenerate_interface_table = 1;
821 vam->sw_if_index = ntohl (mp->sw_if_index);
822 vam->result_ready = 1;
825 static void vl_api_create_subif_reply_t_handler_json
826 (vl_api_create_subif_reply_t * mp)
828 vat_main_t *vam = &vat_main;
829 vat_json_node_t node;
831 vat_json_init_object (&node);
832 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
833 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
835 vat_json_print (vam->ofp, &node);
836 vat_json_free (&node);
838 vam->retval = ntohl (mp->retval);
839 vam->result_ready = 1;
842 static void vl_api_interface_name_renumber_reply_t_handler
843 (vl_api_interface_name_renumber_reply_t * mp)
845 vat_main_t *vam = &vat_main;
846 i32 retval = ntohl (mp->retval);
848 vam->retval = retval;
849 vam->regenerate_interface_table = 1;
850 vam->result_ready = 1;
853 static void vl_api_interface_name_renumber_reply_t_handler_json
854 (vl_api_interface_name_renumber_reply_t * mp)
856 vat_main_t *vam = &vat_main;
857 vat_json_node_t node;
859 vat_json_init_object (&node);
860 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
862 vat_json_print (vam->ofp, &node);
863 vat_json_free (&node);
865 vam->retval = ntohl (mp->retval);
866 vam->result_ready = 1;
870 * Special-case: build the interface table, maintain
871 * the next loopback sw_if_index vbl.
873 static void vl_api_sw_interface_details_t_handler
874 (vl_api_sw_interface_details_t * mp)
876 vat_main_t *vam = &vat_main;
877 u8 *s = format (0, "%s%c", mp->interface_name, 0);
879 hash_set_mem (vam->sw_if_index_by_interface_name, s,
880 ntohl (mp->sw_if_index));
882 /* In sub interface case, fill the sub interface table entry */
883 if (mp->sw_if_index != mp->sup_sw_if_index)
885 sw_interface_subif_t *sub = NULL;
887 vec_add2 (vam->sw_if_subif_table, sub, 1);
889 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
890 strncpy ((char *) sub->interface_name, (char *) s,
891 vec_len (sub->interface_name));
892 sub->sw_if_index = ntohl (mp->sw_if_index);
893 sub->sub_id = ntohl (mp->sub_id);
895 sub->sub_dot1ad = mp->sub_dot1ad;
896 sub->sub_number_of_tags = mp->sub_number_of_tags;
897 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
898 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
899 sub->sub_exact_match = mp->sub_exact_match;
900 sub->sub_default = mp->sub_default;
901 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
902 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
904 /* vlan tag rewrite */
905 sub->vtr_op = ntohl (mp->vtr_op);
906 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
907 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
908 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
912 static void vl_api_sw_interface_details_t_handler_json
913 (vl_api_sw_interface_details_t * mp)
915 vat_main_t *vam = &vat_main;
916 vat_json_node_t *node = NULL;
918 if (VAT_JSON_ARRAY != vam->json_tree.type)
920 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
921 vat_json_init_array (&vam->json_tree);
923 node = vat_json_array_add (&vam->json_tree);
925 vat_json_init_object (node);
926 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
927 vat_json_object_add_uint (node, "sup_sw_if_index",
928 ntohl (mp->sup_sw_if_index));
929 vat_json_object_add_uint (node, "l2_address_length",
930 ntohl (mp->l2_address_length));
931 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
932 sizeof (mp->l2_address));
933 vat_json_object_add_string_copy (node, "interface_name",
935 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
936 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
937 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
938 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
939 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
940 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
941 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
942 vat_json_object_add_uint (node, "sub_number_of_tags",
943 mp->sub_number_of_tags);
944 vat_json_object_add_uint (node, "sub_outer_vlan_id",
945 ntohs (mp->sub_outer_vlan_id));
946 vat_json_object_add_uint (node, "sub_inner_vlan_id",
947 ntohs (mp->sub_inner_vlan_id));
948 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
949 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
950 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
951 mp->sub_outer_vlan_id_any);
952 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
953 mp->sub_inner_vlan_id_any);
954 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
955 vat_json_object_add_uint (node, "vtr_push_dot1q",
956 ntohl (mp->vtr_push_dot1q));
957 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
958 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
961 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
963 format_ethernet_address,
965 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
967 format_ethernet_address,
969 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
970 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
974 #if VPP_API_TEST_BUILTIN == 0
975 static void vl_api_sw_interface_set_flags_t_handler
976 (vl_api_sw_interface_set_flags_t * mp)
978 vat_main_t *vam = &vat_main;
979 if (vam->interface_event_display)
980 errmsg ("interface flags: sw_if_index %d %s %s",
981 ntohl (mp->sw_if_index),
982 mp->admin_up_down ? "admin-up" : "admin-down",
983 mp->link_up_down ? "link-up" : "link-down");
987 static void vl_api_sw_interface_set_flags_t_handler_json
988 (vl_api_sw_interface_set_flags_t * mp)
990 /* JSON output not supported */
994 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
996 vat_main_t *vam = &vat_main;
997 i32 retval = ntohl (mp->retval);
999 vam->retval = retval;
1000 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1001 vam->result_ready = 1;
1005 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1007 vat_main_t *vam = &vat_main;
1008 vat_json_node_t node;
1009 api_main_t *am = &api_main;
1013 vat_json_init_object (&node);
1014 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1015 vat_json_object_add_uint (&node, "reply_in_shmem",
1016 ntohl (mp->reply_in_shmem));
1017 /* Toss the shared-memory original... */
1018 pthread_mutex_lock (&am->vlib_rp->mutex);
1019 oldheap = svm_push_data_heap (am->vlib_rp);
1021 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1024 svm_pop_heap (oldheap);
1025 pthread_mutex_unlock (&am->vlib_rp->mutex);
1027 vat_json_print (vam->ofp, &node);
1028 vat_json_free (&node);
1030 vam->retval = ntohl (mp->retval);
1031 vam->result_ready = 1;
1035 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1037 vat_main_t *vam = &vat_main;
1038 i32 retval = ntohl (mp->retval);
1040 vam->retval = retval;
1041 vam->cmd_reply = mp->reply;
1042 vam->result_ready = 1;
1046 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1048 vat_main_t *vam = &vat_main;
1049 vat_json_node_t node;
1051 vat_json_init_object (&node);
1052 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1053 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1055 vat_json_print (vam->ofp, &node);
1056 vat_json_free (&node);
1058 vam->retval = ntohl (mp->retval);
1059 vam->result_ready = 1;
1062 static void vl_api_classify_add_del_table_reply_t_handler
1063 (vl_api_classify_add_del_table_reply_t * mp)
1065 vat_main_t *vam = &vat_main;
1066 i32 retval = ntohl (mp->retval);
1067 if (vam->async_mode)
1069 vam->async_errors += (retval < 0);
1073 vam->retval = retval;
1075 ((mp->new_table_index != 0xFFFFFFFF) ||
1076 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1077 (mp->match_n_vectors != 0xFFFFFFFF)))
1079 * Note: this is just barely thread-safe, depends on
1080 * the main thread spinning waiting for an answer...
1082 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1083 ntohl (mp->new_table_index),
1084 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1085 vam->result_ready = 1;
1089 static void vl_api_classify_add_del_table_reply_t_handler_json
1090 (vl_api_classify_add_del_table_reply_t * mp)
1092 vat_main_t *vam = &vat_main;
1093 vat_json_node_t node;
1095 vat_json_init_object (&node);
1096 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1097 vat_json_object_add_uint (&node, "new_table_index",
1098 ntohl (mp->new_table_index));
1099 vat_json_object_add_uint (&node, "skip_n_vectors",
1100 ntohl (mp->skip_n_vectors));
1101 vat_json_object_add_uint (&node, "match_n_vectors",
1102 ntohl (mp->match_n_vectors));
1104 vat_json_print (vam->ofp, &node);
1105 vat_json_free (&node);
1107 vam->retval = ntohl (mp->retval);
1108 vam->result_ready = 1;
1111 static void vl_api_get_node_index_reply_t_handler
1112 (vl_api_get_node_index_reply_t * mp)
1114 vat_main_t *vam = &vat_main;
1115 i32 retval = ntohl (mp->retval);
1116 if (vam->async_mode)
1118 vam->async_errors += (retval < 0);
1122 vam->retval = retval;
1124 errmsg ("node index %d", ntohl (mp->node_index));
1125 vam->result_ready = 1;
1129 static void vl_api_get_node_index_reply_t_handler_json
1130 (vl_api_get_node_index_reply_t * mp)
1132 vat_main_t *vam = &vat_main;
1133 vat_json_node_t node;
1135 vat_json_init_object (&node);
1136 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1137 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1139 vat_json_print (vam->ofp, &node);
1140 vat_json_free (&node);
1142 vam->retval = ntohl (mp->retval);
1143 vam->result_ready = 1;
1146 static void vl_api_get_next_index_reply_t_handler
1147 (vl_api_get_next_index_reply_t * mp)
1149 vat_main_t *vam = &vat_main;
1150 i32 retval = ntohl (mp->retval);
1151 if (vam->async_mode)
1153 vam->async_errors += (retval < 0);
1157 vam->retval = retval;
1159 errmsg ("next node index %d", ntohl (mp->next_index));
1160 vam->result_ready = 1;
1164 static void vl_api_get_next_index_reply_t_handler_json
1165 (vl_api_get_next_index_reply_t * mp)
1167 vat_main_t *vam = &vat_main;
1168 vat_json_node_t node;
1170 vat_json_init_object (&node);
1171 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1172 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1174 vat_json_print (vam->ofp, &node);
1175 vat_json_free (&node);
1177 vam->retval = ntohl (mp->retval);
1178 vam->result_ready = 1;
1181 static void vl_api_add_node_next_reply_t_handler
1182 (vl_api_add_node_next_reply_t * mp)
1184 vat_main_t *vam = &vat_main;
1185 i32 retval = ntohl (mp->retval);
1186 if (vam->async_mode)
1188 vam->async_errors += (retval < 0);
1192 vam->retval = retval;
1194 errmsg ("next index %d", ntohl (mp->next_index));
1195 vam->result_ready = 1;
1199 static void vl_api_add_node_next_reply_t_handler_json
1200 (vl_api_add_node_next_reply_t * mp)
1202 vat_main_t *vam = &vat_main;
1203 vat_json_node_t node;
1205 vat_json_init_object (&node);
1206 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1207 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1209 vat_json_print (vam->ofp, &node);
1210 vat_json_free (&node);
1212 vam->retval = ntohl (mp->retval);
1213 vam->result_ready = 1;
1216 static void vl_api_show_version_reply_t_handler
1217 (vl_api_show_version_reply_t * mp)
1219 vat_main_t *vam = &vat_main;
1220 i32 retval = ntohl (mp->retval);
1224 errmsg (" program: %s", mp->program);
1225 errmsg (" version: %s", mp->version);
1226 errmsg (" build date: %s", mp->build_date);
1227 errmsg ("build directory: %s", mp->build_directory);
1229 vam->retval = retval;
1230 vam->result_ready = 1;
1233 static void vl_api_show_version_reply_t_handler_json
1234 (vl_api_show_version_reply_t * mp)
1236 vat_main_t *vam = &vat_main;
1237 vat_json_node_t node;
1239 vat_json_init_object (&node);
1240 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1241 vat_json_object_add_string_copy (&node, "program", mp->program);
1242 vat_json_object_add_string_copy (&node, "version", mp->version);
1243 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1244 vat_json_object_add_string_copy (&node, "build_directory",
1245 mp->build_directory);
1247 vat_json_print (vam->ofp, &node);
1248 vat_json_free (&node);
1250 vam->retval = ntohl (mp->retval);
1251 vam->result_ready = 1;
1255 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1257 u32 sw_if_index = ntohl (mp->sw_if_index);
1258 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1259 mp->mac_ip ? "mac/ip binding" : "address resolution",
1260 ntohl (mp->pid), format_ip4_address, &mp->address,
1261 format_ethernet_address, mp->new_mac, sw_if_index);
1265 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1267 /* JSON output not supported */
1271 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1273 u32 sw_if_index = ntohl (mp->sw_if_index);
1274 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1275 mp->mac_ip ? "mac/ip binding" : "address resolution",
1276 ntohl (mp->pid), format_ip6_address, mp->address,
1277 format_ethernet_address, mp->new_mac, sw_if_index);
1281 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1283 /* JSON output not supported */
1286 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1287 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1290 * Special-case: build the bridge domain table, maintain
1291 * the next bd id vbl.
1293 static void vl_api_bridge_domain_details_t_handler
1294 (vl_api_bridge_domain_details_t * mp)
1296 vat_main_t *vam = &vat_main;
1297 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1300 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1301 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1303 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1304 ntohl (mp->bd_id), mp->learn, mp->forward,
1305 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1309 vl_api_bridge_domain_sw_if_t *sw_ifs;
1310 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1313 sw_ifs = mp->sw_if_details;
1314 for (i = 0; i < n_sw_ifs; i++)
1320 sw_if_index = ntohl (sw_ifs->sw_if_index);
1323 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1325 if ((u32) p->value[0] == sw_if_index)
1327 sw_if_name = (u8 *)(p->key);
1332 print (vam->ofp, "%7d %3d %s", sw_if_index,
1333 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1334 "sw_if_index not found!");
1341 static void vl_api_bridge_domain_details_t_handler_json
1342 (vl_api_bridge_domain_details_t * mp)
1344 vat_main_t *vam = &vat_main;
1345 vat_json_node_t *node, *array = NULL;
1346 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1348 if (VAT_JSON_ARRAY != vam->json_tree.type)
1350 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1351 vat_json_init_array (&vam->json_tree);
1353 node = vat_json_array_add (&vam->json_tree);
1355 vat_json_init_object (node);
1356 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1357 vat_json_object_add_uint (node, "flood", mp->flood);
1358 vat_json_object_add_uint (node, "forward", mp->forward);
1359 vat_json_object_add_uint (node, "learn", mp->learn);
1360 vat_json_object_add_uint (node, "bvi_sw_if_index",
1361 ntohl (mp->bvi_sw_if_index));
1362 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1363 array = vat_json_object_add (node, "sw_if");
1364 vat_json_init_array (array);
1370 vl_api_bridge_domain_sw_if_t *sw_ifs;
1373 sw_ifs = mp->sw_if_details;
1374 for (i = 0; i < n_sw_ifs; i++)
1376 node = vat_json_array_add (array);
1377 vat_json_init_object (node);
1378 vat_json_object_add_uint (node, "sw_if_index",
1379 ntohl (sw_ifs->sw_if_index));
1380 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1386 static void vl_api_control_ping_reply_t_handler
1387 (vl_api_control_ping_reply_t * mp)
1389 vat_main_t *vam = &vat_main;
1390 i32 retval = ntohl (mp->retval);
1391 if (vam->async_mode)
1393 vam->async_errors += (retval < 0);
1397 vam->retval = retval;
1398 vam->result_ready = 1;
1402 static void vl_api_control_ping_reply_t_handler_json
1403 (vl_api_control_ping_reply_t * mp)
1405 vat_main_t *vam = &vat_main;
1406 i32 retval = ntohl (mp->retval);
1408 if (VAT_JSON_NONE != vam->json_tree.type)
1410 vat_json_print (vam->ofp, &vam->json_tree);
1411 vat_json_free (&vam->json_tree);
1412 vam->json_tree.type = VAT_JSON_NONE;
1417 vat_json_init_array (&vam->json_tree);
1418 vat_json_print (vam->ofp, &vam->json_tree);
1419 vam->json_tree.type = VAT_JSON_NONE;
1422 vam->retval = retval;
1423 vam->result_ready = 1;
1427 vl_api_bridge_domain_set_mac_age_reply_t_handler
1428 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1430 vat_main_t *vam = &vat_main;
1431 i32 retval = ntohl (mp->retval);
1432 if (vam->async_mode)
1434 vam->async_errors += (retval < 0);
1438 vam->retval = retval;
1439 vam->result_ready = 1;
1443 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1444 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1446 vat_main_t *vam = &vat_main;
1447 vat_json_node_t node;
1449 vat_json_init_object (&node);
1450 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1452 vat_json_print (vam->ofp, &node);
1453 vat_json_free (&node);
1455 vam->retval = ntohl (mp->retval);
1456 vam->result_ready = 1;
1460 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1462 vat_main_t *vam = &vat_main;
1463 i32 retval = ntohl (mp->retval);
1464 if (vam->async_mode)
1466 vam->async_errors += (retval < 0);
1470 vam->retval = retval;
1471 vam->result_ready = 1;
1475 static void vl_api_l2_flags_reply_t_handler_json
1476 (vl_api_l2_flags_reply_t * mp)
1478 vat_main_t *vam = &vat_main;
1479 vat_json_node_t node;
1481 vat_json_init_object (&node);
1482 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1483 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1484 ntohl (mp->resulting_feature_bitmap));
1486 vat_json_print (vam->ofp, &node);
1487 vat_json_free (&node);
1489 vam->retval = ntohl (mp->retval);
1490 vam->result_ready = 1;
1493 static void vl_api_bridge_flags_reply_t_handler
1494 (vl_api_bridge_flags_reply_t * mp)
1496 vat_main_t *vam = &vat_main;
1497 i32 retval = ntohl (mp->retval);
1498 if (vam->async_mode)
1500 vam->async_errors += (retval < 0);
1504 vam->retval = retval;
1505 vam->result_ready = 1;
1509 static void vl_api_bridge_flags_reply_t_handler_json
1510 (vl_api_bridge_flags_reply_t * mp)
1512 vat_main_t *vam = &vat_main;
1513 vat_json_node_t node;
1515 vat_json_init_object (&node);
1516 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1517 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1518 ntohl (mp->resulting_feature_bitmap));
1520 vat_json_print (vam->ofp, &node);
1521 vat_json_free (&node);
1523 vam->retval = ntohl (mp->retval);
1524 vam->result_ready = 1;
1527 static void vl_api_tap_connect_reply_t_handler
1528 (vl_api_tap_connect_reply_t * mp)
1530 vat_main_t *vam = &vat_main;
1531 i32 retval = ntohl (mp->retval);
1532 if (vam->async_mode)
1534 vam->async_errors += (retval < 0);
1538 vam->retval = retval;
1539 vam->sw_if_index = ntohl (mp->sw_if_index);
1540 vam->result_ready = 1;
1545 static void vl_api_tap_connect_reply_t_handler_json
1546 (vl_api_tap_connect_reply_t * mp)
1548 vat_main_t *vam = &vat_main;
1549 vat_json_node_t node;
1551 vat_json_init_object (&node);
1552 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1553 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1555 vat_json_print (vam->ofp, &node);
1556 vat_json_free (&node);
1558 vam->retval = ntohl (mp->retval);
1559 vam->result_ready = 1;
1564 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1566 vat_main_t *vam = &vat_main;
1567 i32 retval = ntohl (mp->retval);
1568 if (vam->async_mode)
1570 vam->async_errors += (retval < 0);
1574 vam->retval = retval;
1575 vam->sw_if_index = ntohl (mp->sw_if_index);
1576 vam->result_ready = 1;
1580 static void vl_api_tap_modify_reply_t_handler_json
1581 (vl_api_tap_modify_reply_t * mp)
1583 vat_main_t *vam = &vat_main;
1584 vat_json_node_t node;
1586 vat_json_init_object (&node);
1587 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1588 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1590 vat_json_print (vam->ofp, &node);
1591 vat_json_free (&node);
1593 vam->retval = ntohl (mp->retval);
1594 vam->result_ready = 1;
1598 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1600 vat_main_t *vam = &vat_main;
1601 i32 retval = ntohl (mp->retval);
1602 if (vam->async_mode)
1604 vam->async_errors += (retval < 0);
1608 vam->retval = retval;
1609 vam->result_ready = 1;
1613 static void vl_api_tap_delete_reply_t_handler_json
1614 (vl_api_tap_delete_reply_t * mp)
1616 vat_main_t *vam = &vat_main;
1617 vat_json_node_t node;
1619 vat_json_init_object (&node);
1620 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1622 vat_json_print (vam->ofp, &node);
1623 vat_json_free (&node);
1625 vam->retval = ntohl (mp->retval);
1626 vam->result_ready = 1;
1629 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1630 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1632 vat_main_t *vam = &vat_main;
1633 i32 retval = ntohl (mp->retval);
1634 if (vam->async_mode)
1636 vam->async_errors += (retval < 0);
1640 vam->retval = retval;
1641 vam->result_ready = 1;
1645 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1646 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1648 vat_main_t *vam = &vat_main;
1649 vat_json_node_t node;
1651 vat_json_init_object (&node);
1652 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1653 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1654 ntohl (mp->sw_if_index));
1656 vat_json_print (vam->ofp, &node);
1657 vat_json_free (&node);
1659 vam->retval = ntohl (mp->retval);
1660 vam->result_ready = 1;
1663 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1664 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1666 vat_main_t *vam = &vat_main;
1667 i32 retval = ntohl (mp->retval);
1668 if (vam->async_mode)
1670 vam->async_errors += (retval < 0);
1674 vam->retval = retval;
1675 vam->sw_if_index = ntohl (mp->sw_if_index);
1676 vam->result_ready = 1;
1680 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1681 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1683 vat_main_t *vam = &vat_main;
1684 vat_json_node_t node;
1686 vat_json_init_object (&node);
1687 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1688 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1690 vat_json_print (vam->ofp, &node);
1691 vat_json_free (&node);
1693 vam->retval = ntohl (mp->retval);
1694 vam->result_ready = 1;
1697 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
1698 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1700 vat_main_t *vam = &vat_main;
1701 i32 retval = ntohl (mp->retval);
1702 if (vam->async_mode)
1704 vam->async_errors += (retval < 0);
1708 vam->retval = retval;
1709 vam->result_ready = 1;
1713 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
1714 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1716 vat_main_t *vam = &vat_main;
1717 vat_json_node_t node;
1719 vat_json_init_object (&node);
1720 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1721 vat_json_object_add_uint (&node, "fwd_entry_index",
1722 clib_net_to_host_u32 (mp->fwd_entry_index));
1724 vat_json_print (vam->ofp, &node);
1725 vat_json_free (&node);
1727 vam->retval = ntohl (mp->retval);
1728 vam->result_ready = 1;
1731 static void vl_api_one_add_del_locator_set_reply_t_handler
1732 (vl_api_one_add_del_locator_set_reply_t * mp)
1734 vat_main_t *vam = &vat_main;
1735 i32 retval = ntohl (mp->retval);
1736 if (vam->async_mode)
1738 vam->async_errors += (retval < 0);
1742 vam->retval = retval;
1743 vam->result_ready = 1;
1747 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1748 (vl_api_one_add_del_locator_set_reply_t * mp)
1750 vat_main_t *vam = &vat_main;
1751 vat_json_node_t node;
1753 vat_json_init_object (&node);
1754 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1755 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1757 vat_json_print (vam->ofp, &node);
1758 vat_json_free (&node);
1760 vam->retval = ntohl (mp->retval);
1761 vam->result_ready = 1;
1764 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1765 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1767 vat_main_t *vam = &vat_main;
1768 i32 retval = ntohl (mp->retval);
1769 if (vam->async_mode)
1771 vam->async_errors += (retval < 0);
1775 vam->retval = retval;
1776 vam->sw_if_index = ntohl (mp->sw_if_index);
1777 vam->result_ready = 1;
1781 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1782 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1784 vat_main_t *vam = &vat_main;
1785 vat_json_node_t node;
1787 vat_json_init_object (&node);
1788 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1789 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1791 vat_json_print (vam->ofp, &node);
1792 vat_json_free (&node);
1794 vam->retval = ntohl (mp->retval);
1795 vam->result_ready = 1;
1798 static void vl_api_gre_add_del_tunnel_reply_t_handler
1799 (vl_api_gre_add_del_tunnel_reply_t * mp)
1801 vat_main_t *vam = &vat_main;
1802 i32 retval = ntohl (mp->retval);
1803 if (vam->async_mode)
1805 vam->async_errors += (retval < 0);
1809 vam->retval = retval;
1810 vam->sw_if_index = ntohl (mp->sw_if_index);
1811 vam->result_ready = 1;
1815 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1816 (vl_api_gre_add_del_tunnel_reply_t * mp)
1818 vat_main_t *vam = &vat_main;
1819 vat_json_node_t node;
1821 vat_json_init_object (&node);
1822 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1823 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1825 vat_json_print (vam->ofp, &node);
1826 vat_json_free (&node);
1828 vam->retval = ntohl (mp->retval);
1829 vam->result_ready = 1;
1832 static void vl_api_create_vhost_user_if_reply_t_handler
1833 (vl_api_create_vhost_user_if_reply_t * mp)
1835 vat_main_t *vam = &vat_main;
1836 i32 retval = ntohl (mp->retval);
1837 if (vam->async_mode)
1839 vam->async_errors += (retval < 0);
1843 vam->retval = retval;
1844 vam->sw_if_index = ntohl (mp->sw_if_index);
1845 vam->result_ready = 1;
1849 static void vl_api_create_vhost_user_if_reply_t_handler_json
1850 (vl_api_create_vhost_user_if_reply_t * mp)
1852 vat_main_t *vam = &vat_main;
1853 vat_json_node_t node;
1855 vat_json_init_object (&node);
1856 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1857 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1859 vat_json_print (vam->ofp, &node);
1860 vat_json_free (&node);
1862 vam->retval = ntohl (mp->retval);
1863 vam->result_ready = 1;
1866 static void vl_api_ip_address_details_t_handler
1867 (vl_api_ip_address_details_t * mp)
1869 vat_main_t *vam = &vat_main;
1870 static ip_address_details_t empty_ip_address_details = { {0} };
1871 ip_address_details_t *address = NULL;
1872 ip_details_t *current_ip_details = NULL;
1873 ip_details_t *details = NULL;
1875 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1877 if (!details || vam->current_sw_if_index >= vec_len (details)
1878 || !details[vam->current_sw_if_index].present)
1880 errmsg ("ip address details arrived but not stored");
1881 errmsg ("ip_dump should be called first");
1885 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1887 #define addresses (current_ip_details->addr)
1889 vec_validate_init_empty (addresses, vec_len (addresses),
1890 empty_ip_address_details);
1892 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1894 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1895 address->prefix_length = mp->prefix_length;
1899 static void vl_api_ip_address_details_t_handler_json
1900 (vl_api_ip_address_details_t * mp)
1902 vat_main_t *vam = &vat_main;
1903 vat_json_node_t *node = NULL;
1904 struct in6_addr ip6;
1907 if (VAT_JSON_ARRAY != vam->json_tree.type)
1909 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1910 vat_json_init_array (&vam->json_tree);
1912 node = vat_json_array_add (&vam->json_tree);
1914 vat_json_init_object (node);
1917 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1918 vat_json_object_add_ip6 (node, "ip", ip6);
1922 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1923 vat_json_object_add_ip4 (node, "ip", ip4);
1925 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1929 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1931 vat_main_t *vam = &vat_main;
1932 static ip_details_t empty_ip_details = { 0 };
1933 ip_details_t *ip = NULL;
1934 u32 sw_if_index = ~0;
1936 sw_if_index = ntohl (mp->sw_if_index);
1938 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1939 sw_if_index, empty_ip_details);
1941 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1948 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1950 vat_main_t *vam = &vat_main;
1952 if (VAT_JSON_ARRAY != vam->json_tree.type)
1954 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1955 vat_json_init_array (&vam->json_tree);
1957 vat_json_array_add_uint (&vam->json_tree,
1958 clib_net_to_host_u32 (mp->sw_if_index));
1961 static void vl_api_map_domain_details_t_handler_json
1962 (vl_api_map_domain_details_t * mp)
1964 vat_json_node_t *node = NULL;
1965 vat_main_t *vam = &vat_main;
1966 struct in6_addr ip6;
1969 if (VAT_JSON_ARRAY != vam->json_tree.type)
1971 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1972 vat_json_init_array (&vam->json_tree);
1975 node = vat_json_array_add (&vam->json_tree);
1976 vat_json_init_object (node);
1978 vat_json_object_add_uint (node, "domain_index",
1979 clib_net_to_host_u32 (mp->domain_index));
1980 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1981 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1982 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1983 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1984 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1985 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1986 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1987 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1988 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1989 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1990 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1991 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1992 vat_json_object_add_uint (node, "flags", mp->flags);
1993 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1994 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1997 static void vl_api_map_domain_details_t_handler
1998 (vl_api_map_domain_details_t * mp)
2000 vat_main_t *vam = &vat_main;
2002 if (mp->is_translation)
2005 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2006 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2007 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2008 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2009 clib_net_to_host_u32 (mp->domain_index));
2014 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2015 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2016 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2017 format_ip6_address, mp->ip6_src,
2018 clib_net_to_host_u32 (mp->domain_index));
2020 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2021 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2022 mp->is_translation ? "map-t" : "");
2025 static void vl_api_map_rule_details_t_handler_json
2026 (vl_api_map_rule_details_t * mp)
2028 struct in6_addr ip6;
2029 vat_json_node_t *node = NULL;
2030 vat_main_t *vam = &vat_main;
2032 if (VAT_JSON_ARRAY != vam->json_tree.type)
2034 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2035 vat_json_init_array (&vam->json_tree);
2038 node = vat_json_array_add (&vam->json_tree);
2039 vat_json_init_object (node);
2041 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2042 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2043 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2047 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2049 vat_main_t *vam = &vat_main;
2050 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2051 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2055 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2057 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2058 "router_addr %U host_mac %U",
2059 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2060 format_ip4_address, &mp->host_address,
2061 format_ip4_address, &mp->router_address,
2062 format_ethernet_address, mp->host_mac);
2065 static void vl_api_dhcp_compl_event_t_handler_json
2066 (vl_api_dhcp_compl_event_t * mp)
2068 /* JSON output not supported */
2072 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2075 vat_main_t *vam = &vat_main;
2076 static u64 default_counter = 0;
2078 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2080 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2081 sw_if_index, default_counter);
2082 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2086 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2087 interface_counter_t counter)
2089 vat_main_t *vam = &vat_main;
2090 static interface_counter_t default_counter = { 0, };
2092 vec_validate_init_empty (vam->combined_interface_counters,
2093 vnet_counter_type, NULL);
2094 vec_validate_init_empty (vam->combined_interface_counters
2095 [vnet_counter_type], sw_if_index, default_counter);
2096 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2099 static void vl_api_vnet_interface_simple_counters_t_handler
2100 (vl_api_vnet_interface_simple_counters_t * mp)
2105 static void vl_api_vnet_interface_combined_counters_t_handler
2106 (vl_api_vnet_interface_combined_counters_t * mp)
2111 static void vl_api_vnet_interface_simple_counters_t_handler_json
2112 (vl_api_vnet_interface_simple_counters_t * mp)
2117 u32 first_sw_if_index;
2120 count = ntohl (mp->count);
2121 first_sw_if_index = ntohl (mp->first_sw_if_index);
2123 v_packets = (u64 *) & mp->data;
2124 for (i = 0; i < count; i++)
2126 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2127 set_simple_interface_counter (mp->vnet_counter_type,
2128 first_sw_if_index + i, packets);
2133 static void vl_api_vnet_interface_combined_counters_t_handler_json
2134 (vl_api_vnet_interface_combined_counters_t * mp)
2136 interface_counter_t counter;
2138 u32 first_sw_if_index;
2142 count = ntohl (mp->count);
2143 first_sw_if_index = ntohl (mp->first_sw_if_index);
2145 v = (vlib_counter_t *) & mp->data;
2146 for (i = 0; i < count; i++)
2149 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2151 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2152 set_combined_interface_counter (mp->vnet_counter_type,
2153 first_sw_if_index + i, counter);
2159 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2161 vat_main_t *vam = &vat_main;
2164 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2166 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2175 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2177 vat_main_t *vam = &vat_main;
2180 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2182 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2190 static void vl_api_vnet_ip4_fib_counters_t_handler
2191 (vl_api_vnet_ip4_fib_counters_t * mp)
2196 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2197 (vl_api_vnet_ip4_fib_counters_t * mp)
2199 vat_main_t *vam = &vat_main;
2200 vl_api_ip4_fib_counter_t *v;
2201 ip4_fib_counter_t *counter;
2208 vrf_id = ntohl (mp->vrf_id);
2209 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2210 if (~0 == vrf_index)
2212 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2213 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2214 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2215 vec_validate (vam->ip4_fib_counters, vrf_index);
2216 vam->ip4_fib_counters[vrf_index] = NULL;
2219 vec_free (vam->ip4_fib_counters[vrf_index]);
2220 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2221 count = ntohl (mp->count);
2222 for (i = 0; i < count; i++)
2224 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2225 counter = &vam->ip4_fib_counters[vrf_index][i];
2226 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2227 counter->address = ip4;
2228 counter->address_length = v->address_length;
2229 counter->packets = clib_net_to_host_u64 (v->packets);
2230 counter->bytes = clib_net_to_host_u64 (v->bytes);
2235 static void vl_api_vnet_ip4_nbr_counters_t_handler
2236 (vl_api_vnet_ip4_nbr_counters_t * mp)
2241 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2242 (vl_api_vnet_ip4_nbr_counters_t * mp)
2244 vat_main_t *vam = &vat_main;
2245 vl_api_ip4_nbr_counter_t *v;
2246 ip4_nbr_counter_t *counter;
2251 sw_if_index = ntohl (mp->sw_if_index);
2252 count = ntohl (mp->count);
2253 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2256 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2258 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2259 for (i = 0; i < count; i++)
2261 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2262 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2263 counter->address.s_addr = v->address;
2264 counter->packets = clib_net_to_host_u64 (v->packets);
2265 counter->bytes = clib_net_to_host_u64 (v->bytes);
2266 counter->linkt = v->link_type;
2271 static void vl_api_vnet_ip6_fib_counters_t_handler
2272 (vl_api_vnet_ip6_fib_counters_t * mp)
2277 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2278 (vl_api_vnet_ip6_fib_counters_t * mp)
2280 vat_main_t *vam = &vat_main;
2281 vl_api_ip6_fib_counter_t *v;
2282 ip6_fib_counter_t *counter;
2283 struct in6_addr ip6;
2289 vrf_id = ntohl (mp->vrf_id);
2290 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2291 if (~0 == vrf_index)
2293 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2294 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2295 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2296 vec_validate (vam->ip6_fib_counters, vrf_index);
2297 vam->ip6_fib_counters[vrf_index] = NULL;
2300 vec_free (vam->ip6_fib_counters[vrf_index]);
2301 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2302 count = ntohl (mp->count);
2303 for (i = 0; i < count; i++)
2305 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2306 counter = &vam->ip6_fib_counters[vrf_index][i];
2307 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2308 counter->address = ip6;
2309 counter->address_length = v->address_length;
2310 counter->packets = clib_net_to_host_u64 (v->packets);
2311 counter->bytes = clib_net_to_host_u64 (v->bytes);
2316 static void vl_api_vnet_ip6_nbr_counters_t_handler
2317 (vl_api_vnet_ip6_nbr_counters_t * mp)
2322 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2323 (vl_api_vnet_ip6_nbr_counters_t * mp)
2325 vat_main_t *vam = &vat_main;
2326 vl_api_ip6_nbr_counter_t *v;
2327 ip6_nbr_counter_t *counter;
2328 struct in6_addr ip6;
2333 sw_if_index = ntohl (mp->sw_if_index);
2334 count = ntohl (mp->count);
2335 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2338 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2340 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2341 for (i = 0; i < count; i++)
2343 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2344 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2345 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2346 counter->address = ip6;
2347 counter->packets = clib_net_to_host_u64 (v->packets);
2348 counter->bytes = clib_net_to_host_u64 (v->bytes);
2353 static void vl_api_get_first_msg_id_reply_t_handler
2354 (vl_api_get_first_msg_id_reply_t * mp)
2356 vat_main_t *vam = &vat_main;
2357 i32 retval = ntohl (mp->retval);
2359 if (vam->async_mode)
2361 vam->async_errors += (retval < 0);
2365 vam->retval = retval;
2366 vam->result_ready = 1;
2370 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2374 static void vl_api_get_first_msg_id_reply_t_handler_json
2375 (vl_api_get_first_msg_id_reply_t * mp)
2377 vat_main_t *vam = &vat_main;
2378 vat_json_node_t node;
2380 vat_json_init_object (&node);
2381 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2382 vat_json_object_add_uint (&node, "first_msg_id",
2383 (uint) ntohs (mp->first_msg_id));
2385 vat_json_print (vam->ofp, &node);
2386 vat_json_free (&node);
2388 vam->retval = ntohl (mp->retval);
2389 vam->result_ready = 1;
2392 static void vl_api_get_node_graph_reply_t_handler
2393 (vl_api_get_node_graph_reply_t * mp)
2395 vat_main_t *vam = &vat_main;
2396 api_main_t *am = &api_main;
2397 i32 retval = ntohl (mp->retval);
2398 u8 *pvt_copy, *reply;
2403 if (vam->async_mode)
2405 vam->async_errors += (retval < 0);
2409 vam->retval = retval;
2410 vam->result_ready = 1;
2413 /* "Should never happen..." */
2417 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2418 pvt_copy = vec_dup (reply);
2420 /* Toss the shared-memory original... */
2421 pthread_mutex_lock (&am->vlib_rp->mutex);
2422 oldheap = svm_push_data_heap (am->vlib_rp);
2426 svm_pop_heap (oldheap);
2427 pthread_mutex_unlock (&am->vlib_rp->mutex);
2429 if (vam->graph_nodes)
2431 hash_free (vam->graph_node_index_by_name);
2433 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2435 node = vam->graph_nodes[i];
2436 vec_free (node->name);
2437 vec_free (node->next_nodes);
2440 vec_free (vam->graph_nodes);
2443 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2444 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2445 vec_free (pvt_copy);
2447 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2449 node = vam->graph_nodes[i];
2450 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2454 static void vl_api_get_node_graph_reply_t_handler_json
2455 (vl_api_get_node_graph_reply_t * mp)
2457 vat_main_t *vam = &vat_main;
2458 api_main_t *am = &api_main;
2460 vat_json_node_t node;
2463 /* $$$$ make this real? */
2464 vat_json_init_object (&node);
2465 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2466 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2468 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2470 /* Toss the shared-memory original... */
2471 pthread_mutex_lock (&am->vlib_rp->mutex);
2472 oldheap = svm_push_data_heap (am->vlib_rp);
2476 svm_pop_heap (oldheap);
2477 pthread_mutex_unlock (&am->vlib_rp->mutex);
2479 vat_json_print (vam->ofp, &node);
2480 vat_json_free (&node);
2482 vam->retval = ntohl (mp->retval);
2483 vam->result_ready = 1;
2487 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2489 vat_main_t *vam = &vat_main;
2494 s = format (s, "%=16d%=16d%=16d",
2495 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2499 s = format (s, "%=16U%=16d%=16d",
2500 mp->is_ipv6 ? format_ip6_address :
2502 mp->ip_address, mp->priority, mp->weight);
2505 print (vam->ofp, "%v", s);
2510 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2512 vat_main_t *vam = &vat_main;
2513 vat_json_node_t *node = NULL;
2514 struct in6_addr ip6;
2517 if (VAT_JSON_ARRAY != vam->json_tree.type)
2519 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2520 vat_json_init_array (&vam->json_tree);
2522 node = vat_json_array_add (&vam->json_tree);
2523 vat_json_init_object (node);
2525 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2526 vat_json_object_add_uint (node, "priority", mp->priority);
2527 vat_json_object_add_uint (node, "weight", mp->weight);
2530 vat_json_object_add_uint (node, "sw_if_index",
2531 clib_net_to_host_u32 (mp->sw_if_index));
2536 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2537 vat_json_object_add_ip6 (node, "address", ip6);
2541 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2542 vat_json_object_add_ip4 (node, "address", ip4);
2548 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2551 vat_main_t *vam = &vat_main;
2554 ls_name = format (0, "%s", mp->ls_name);
2556 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2562 vl_api_one_locator_set_details_t_handler_json
2563 (vl_api_one_locator_set_details_t * mp)
2565 vat_main_t *vam = &vat_main;
2566 vat_json_node_t *node = 0;
2569 ls_name = format (0, "%s", mp->ls_name);
2570 vec_add1 (ls_name, 0);
2572 if (VAT_JSON_ARRAY != vam->json_tree.type)
2574 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2575 vat_json_init_array (&vam->json_tree);
2577 node = vat_json_array_add (&vam->json_tree);
2579 vat_json_init_object (node);
2580 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2581 vat_json_object_add_uint (node, "ls_index",
2582 clib_net_to_host_u32 (mp->ls_index));
2587 format_lisp_flat_eid (u8 * s, va_list * args)
2589 u32 type = va_arg (*args, u32);
2590 u8 *eid = va_arg (*args, u8 *);
2591 u32 eid_len = va_arg (*args, u32);
2596 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2598 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2600 return format (s, "%U", format_ethernet_address, eid);
2606 format_lisp_eid_vat (u8 * s, va_list * args)
2608 u32 type = va_arg (*args, u32);
2609 u8 *eid = va_arg (*args, u8 *);
2610 u32 eid_len = va_arg (*args, u32);
2611 u8 *seid = va_arg (*args, u8 *);
2612 u32 seid_len = va_arg (*args, u32);
2613 u32 is_src_dst = va_arg (*args, u32);
2616 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2618 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2624 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2626 vat_main_t *vam = &vat_main;
2627 u8 *s = 0, *eid = 0;
2629 if (~0 == mp->locator_set_index)
2630 s = format (0, "action: %d", mp->action);
2632 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2634 eid = format (0, "%U", format_lisp_eid_vat,
2638 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2641 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2642 clib_net_to_host_u32 (mp->vni),
2644 mp->is_local ? "local" : "remote",
2645 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2646 clib_net_to_host_u16 (mp->key_id), mp->key);
2653 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2656 vat_main_t *vam = &vat_main;
2657 vat_json_node_t *node = 0;
2660 if (VAT_JSON_ARRAY != vam->json_tree.type)
2662 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2663 vat_json_init_array (&vam->json_tree);
2665 node = vat_json_array_add (&vam->json_tree);
2667 vat_json_init_object (node);
2668 if (~0 == mp->locator_set_index)
2669 vat_json_object_add_uint (node, "action", mp->action);
2671 vat_json_object_add_uint (node, "locator_set_index",
2672 clib_net_to_host_u32 (mp->locator_set_index));
2674 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2675 eid = format (0, "%U", format_lisp_eid_vat,
2679 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2681 vat_json_object_add_string_copy (node, "eid", eid);
2682 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2683 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2684 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2688 vat_json_object_add_uint (node, "key_id",
2689 clib_net_to_host_u16 (mp->key_id));
2690 vat_json_object_add_string_copy (node, "key", mp->key);
2696 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
2698 vat_main_t *vam = &vat_main;
2699 u8 *seid = 0, *deid = 0;
2700 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2702 deid = format (0, "%U", format_lisp_eid_vat,
2703 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2705 seid = format (0, "%U", format_lisp_eid_vat,
2706 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2712 format_ip_address_fcn = format_ip4_address;
2714 format_ip_address_fcn = format_ip6_address;
2717 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
2718 clib_net_to_host_u32 (mp->vni),
2720 format_ip_address_fcn, mp->lloc,
2721 format_ip_address_fcn, mp->rloc,
2722 clib_net_to_host_u32 (mp->pkt_count),
2723 clib_net_to_host_u32 (mp->bytes));
2730 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
2732 struct in6_addr ip6;
2734 vat_main_t *vam = &vat_main;
2735 vat_json_node_t *node = 0;
2736 u8 *deid = 0, *seid = 0;
2738 if (VAT_JSON_ARRAY != vam->json_tree.type)
2740 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2741 vat_json_init_array (&vam->json_tree);
2743 node = vat_json_array_add (&vam->json_tree);
2745 vat_json_init_object (node);
2746 deid = format (0, "%U", format_lisp_eid_vat,
2747 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2749 seid = format (0, "%U", format_lisp_eid_vat,
2750 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2755 vat_json_object_add_string_copy (node, "seid", seid);
2756 vat_json_object_add_string_copy (node, "deid", deid);
2757 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2761 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
2762 vat_json_object_add_ip4 (node, "lloc", ip4);
2763 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
2764 vat_json_object_add_ip4 (node, "rloc", ip4);
2768 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
2769 vat_json_object_add_ip6 (node, "lloc", ip6);
2770 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
2771 vat_json_object_add_ip6 (node, "rloc", ip6);
2773 vat_json_object_add_uint (node, "pkt_count",
2774 clib_net_to_host_u32 (mp->pkt_count));
2775 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
2782 vl_api_one_eid_table_map_details_t_handler
2783 (vl_api_one_eid_table_map_details_t * mp)
2785 vat_main_t *vam = &vat_main;
2787 u8 *line = format (0, "%=10d%=10d",
2788 clib_net_to_host_u32 (mp->vni),
2789 clib_net_to_host_u32 (mp->dp_table));
2790 print (vam->ofp, "%v", line);
2795 vl_api_one_eid_table_map_details_t_handler_json
2796 (vl_api_one_eid_table_map_details_t * mp)
2798 vat_main_t *vam = &vat_main;
2799 vat_json_node_t *node = NULL;
2801 if (VAT_JSON_ARRAY != vam->json_tree.type)
2803 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2804 vat_json_init_array (&vam->json_tree);
2806 node = vat_json_array_add (&vam->json_tree);
2807 vat_json_init_object (node);
2808 vat_json_object_add_uint (node, "dp_table",
2809 clib_net_to_host_u32 (mp->dp_table));
2810 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2814 vl_api_one_eid_table_vni_details_t_handler
2815 (vl_api_one_eid_table_vni_details_t * mp)
2817 vat_main_t *vam = &vat_main;
2819 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2820 print (vam->ofp, "%v", line);
2825 vl_api_one_eid_table_vni_details_t_handler_json
2826 (vl_api_one_eid_table_vni_details_t * mp)
2828 vat_main_t *vam = &vat_main;
2829 vat_json_node_t *node = NULL;
2831 if (VAT_JSON_ARRAY != vam->json_tree.type)
2833 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2834 vat_json_init_array (&vam->json_tree);
2836 node = vat_json_array_add (&vam->json_tree);
2837 vat_json_init_object (node);
2838 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2842 vl_api_show_one_map_register_state_reply_t_handler
2843 (vl_api_show_one_map_register_state_reply_t * mp)
2845 vat_main_t *vam = &vat_main;
2846 int retval = clib_net_to_host_u32 (mp->retval);
2848 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2850 vam->retval = retval;
2851 vam->result_ready = 1;
2855 vl_api_show_one_map_register_state_reply_t_handler_json
2856 (vl_api_show_one_map_register_state_reply_t * mp)
2858 vat_main_t *vam = &vat_main;
2859 vat_json_node_t _node, *node = &_node;
2860 int retval = clib_net_to_host_u32 (mp->retval);
2862 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2864 vat_json_init_object (node);
2865 vat_json_object_add_string_copy (node, "state", s);
2867 vat_json_print (vam->ofp, node);
2868 vat_json_free (node);
2870 vam->retval = retval;
2871 vam->result_ready = 1;
2876 vl_api_show_one_rloc_probe_state_reply_t_handler
2877 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2879 vat_main_t *vam = &vat_main;
2880 int retval = clib_net_to_host_u32 (mp->retval);
2885 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2887 vam->retval = retval;
2888 vam->result_ready = 1;
2892 vl_api_show_one_rloc_probe_state_reply_t_handler_json
2893 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2895 vat_main_t *vam = &vat_main;
2896 vat_json_node_t _node, *node = &_node;
2897 int retval = clib_net_to_host_u32 (mp->retval);
2899 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2900 vat_json_init_object (node);
2901 vat_json_object_add_string_copy (node, "state", s);
2903 vat_json_print (vam->ofp, node);
2904 vat_json_free (node);
2906 vam->retval = retval;
2907 vam->result_ready = 1;
2912 vl_api_show_one_stats_enable_disable_reply_t_handler
2913 (vl_api_show_one_stats_enable_disable_reply_t * mp)
2915 vat_main_t *vam = &vat_main;
2916 int retval = clib_net_to_host_u32 (mp->retval);
2921 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
2923 vam->retval = retval;
2924 vam->result_ready = 1;
2928 vl_api_show_one_stats_enable_disable_reply_t_handler_json
2929 (vl_api_show_one_stats_enable_disable_reply_t * mp)
2931 vat_main_t *vam = &vat_main;
2932 vat_json_node_t _node, *node = &_node;
2933 int retval = clib_net_to_host_u32 (mp->retval);
2935 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
2936 vat_json_init_object (node);
2937 vat_json_object_add_string_copy (node, "state", s);
2939 vat_json_print (vam->ofp, node);
2940 vat_json_free (node);
2942 vam->retval = retval;
2943 vam->result_ready = 1;
2948 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
2950 e->dp_table = clib_net_to_host_u32 (e->dp_table);
2951 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
2952 e->vni = clib_net_to_host_u32 (e->vni);
2956 gpe_fwd_entries_get_reply_t_net_to_host
2957 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2961 mp->count = clib_net_to_host_u32 (mp->count);
2962 for (i = 0; i < mp->count; i++)
2964 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
2969 format_gpe_encap_mode (u8 * s, va_list * args)
2971 u32 mode = va_arg (*args, u32);
2976 return format (s, "lisp");
2978 return format (s, "vxlan");
2984 vl_api_gpe_get_encap_mode_reply_t_handler
2985 (vl_api_gpe_get_encap_mode_reply_t * mp)
2987 vat_main_t *vam = &vat_main;
2989 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
2990 vam->retval = ntohl (mp->retval);
2991 vam->result_ready = 1;
2995 vl_api_gpe_get_encap_mode_reply_t_handler_json
2996 (vl_api_gpe_get_encap_mode_reply_t * mp)
2998 vat_main_t *vam = &vat_main;
2999 vat_json_node_t node;
3001 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3002 vec_add1 (encap_mode, 0);
3004 vat_json_init_object (&node);
3005 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3007 vec_free (encap_mode);
3008 vat_json_print (vam->ofp, &node);
3009 vat_json_free (&node);
3011 vam->retval = ntohl (mp->retval);
3012 vam->result_ready = 1;
3016 vl_api_gpe_fwd_entry_path_details_t_handler
3017 (vl_api_gpe_fwd_entry_path_details_t * mp)
3019 vat_main_t *vam = &vat_main;
3020 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3022 if (mp->lcl_loc.is_ip4)
3023 format_ip_address_fcn = format_ip4_address;
3025 format_ip_address_fcn = format_ip6_address;
3027 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3028 format_ip_address_fcn, &mp->lcl_loc,
3029 format_ip_address_fcn, &mp->rmt_loc);
3033 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3035 struct in6_addr ip6;
3040 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3041 vat_json_object_add_ip4 (n, "address", ip4);
3045 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3046 vat_json_object_add_ip6 (n, "address", ip6);
3048 vat_json_object_add_uint (n, "weight", loc->weight);
3052 vl_api_gpe_fwd_entry_path_details_t_handler_json
3053 (vl_api_gpe_fwd_entry_path_details_t * mp)
3055 vat_main_t *vam = &vat_main;
3056 vat_json_node_t *node = NULL;
3057 vat_json_node_t *loc_node;
3059 if (VAT_JSON_ARRAY != vam->json_tree.type)
3061 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3062 vat_json_init_array (&vam->json_tree);
3064 node = vat_json_array_add (&vam->json_tree);
3065 vat_json_init_object (node);
3067 loc_node = vat_json_object_add (node, "local_locator");
3068 vat_json_init_object (loc_node);
3069 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3071 loc_node = vat_json_object_add (node, "remote_locator");
3072 vat_json_init_object (loc_node);
3073 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3077 vl_api_gpe_fwd_entries_get_reply_t_handler
3078 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3080 vat_main_t *vam = &vat_main;
3082 int retval = clib_net_to_host_u32 (mp->retval);
3083 vl_api_gpe_fwd_entry_t *e;
3088 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3090 for (i = 0; i < mp->count; i++)
3092 e = &mp->entries[i];
3093 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3094 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3095 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3099 vam->retval = retval;
3100 vam->result_ready = 1;
3104 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3105 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3108 vat_main_t *vam = &vat_main;
3109 vat_json_node_t *e = 0, root;
3111 int retval = clib_net_to_host_u32 (mp->retval);
3112 vl_api_gpe_fwd_entry_t *fwd;
3117 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3118 vat_json_init_array (&root);
3120 for (i = 0; i < mp->count; i++)
3122 e = vat_json_array_add (&root);
3123 fwd = &mp->entries[i];
3125 vat_json_init_object (e);
3126 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3127 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3128 vat_json_object_add_int (e, "vni", fwd->vni);
3129 vat_json_object_add_int (e, "action", fwd->action);
3131 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3132 fwd->leid_prefix_len);
3134 vat_json_object_add_string_copy (e, "leid", s);
3137 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3138 fwd->reid_prefix_len);
3140 vat_json_object_add_string_copy (e, "reid", s);
3144 vat_json_print (vam->ofp, &root);
3145 vat_json_free (&root);
3148 vam->retval = retval;
3149 vam->result_ready = 1;
3153 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3154 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3156 vat_main_t *vam = &vat_main;
3158 int retval = clib_net_to_host_u32 (mp->retval);
3163 n = clib_net_to_host_u32 (mp->count);
3165 for (i = 0; i < n; i++)
3166 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3169 vam->retval = retval;
3170 vam->result_ready = 1;
3174 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3175 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3177 vat_main_t *vam = &vat_main;
3178 vat_json_node_t root;
3180 int retval = clib_net_to_host_u32 (mp->retval);
3185 n = clib_net_to_host_u32 (mp->count);
3186 vat_json_init_array (&root);
3188 for (i = 0; i < n; i++)
3189 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3191 vat_json_print (vam->ofp, &root);
3192 vat_json_free (&root);
3195 vam->retval = retval;
3196 vam->result_ready = 1;
3200 vl_api_one_l2_arp_entries_get_reply_t_handler
3201 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3203 vat_main_t *vam = &vat_main;
3205 int retval = clib_net_to_host_u32 (mp->retval);
3210 n = clib_net_to_host_u32 (mp->count);
3212 for (i = 0; i < n; i++)
3213 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3214 format_ethernet_address, mp->entries[i].mac);
3217 vam->retval = retval;
3218 vam->result_ready = 1;
3222 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3223 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3226 vat_main_t *vam = &vat_main;
3227 vat_json_node_t *e = 0, root;
3229 int retval = clib_net_to_host_u32 (mp->retval);
3230 vl_api_one_l2_arp_entry_t *arp_entry;
3235 n = clib_net_to_host_u32 (mp->count);
3236 vat_json_init_array (&root);
3238 for (i = 0; i < n; i++)
3240 e = vat_json_array_add (&root);
3241 arp_entry = &mp->entries[i];
3243 vat_json_init_object (e);
3244 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3247 vat_json_object_add_string_copy (e, "mac", s);
3250 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3252 vat_json_object_add_string_copy (e, "ip4", s);
3256 vat_json_print (vam->ofp, &root);
3257 vat_json_free (&root);
3260 vam->retval = retval;
3261 vam->result_ready = 1;
3265 vl_api_one_l2_arp_bd_get_reply_t_handler
3266 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3268 vat_main_t *vam = &vat_main;
3270 int retval = clib_net_to_host_u32 (mp->retval);
3275 n = clib_net_to_host_u32 (mp->count);
3277 for (i = 0; i < n; i++)
3279 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3283 vam->retval = retval;
3284 vam->result_ready = 1;
3288 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3289 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3291 vat_main_t *vam = &vat_main;
3292 vat_json_node_t root;
3294 int retval = clib_net_to_host_u32 (mp->retval);
3299 n = clib_net_to_host_u32 (mp->count);
3300 vat_json_init_array (&root);
3302 for (i = 0; i < n; i++)
3304 vat_json_array_add_uint (&root,
3305 clib_net_to_host_u32 (mp->bridge_domains[i]));
3308 vat_json_print (vam->ofp, &root);
3309 vat_json_free (&root);
3312 vam->retval = retval;
3313 vam->result_ready = 1;
3317 vl_api_one_adjacencies_get_reply_t_handler
3318 (vl_api_one_adjacencies_get_reply_t * mp)
3320 vat_main_t *vam = &vat_main;
3322 int retval = clib_net_to_host_u32 (mp->retval);
3323 vl_api_one_adjacency_t *a;
3328 n = clib_net_to_host_u32 (mp->count);
3330 for (i = 0; i < n; i++)
3332 a = &mp->adjacencies[i];
3333 print (vam->ofp, "%U %40U",
3334 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3335 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3339 vam->retval = retval;
3340 vam->result_ready = 1;
3344 vl_api_one_adjacencies_get_reply_t_handler_json
3345 (vl_api_one_adjacencies_get_reply_t * mp)
3348 vat_main_t *vam = &vat_main;
3349 vat_json_node_t *e = 0, root;
3351 int retval = clib_net_to_host_u32 (mp->retval);
3352 vl_api_one_adjacency_t *a;
3357 n = clib_net_to_host_u32 (mp->count);
3358 vat_json_init_array (&root);
3360 for (i = 0; i < n; i++)
3362 e = vat_json_array_add (&root);
3363 a = &mp->adjacencies[i];
3365 vat_json_init_object (e);
3366 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3367 a->leid_prefix_len);
3369 vat_json_object_add_string_copy (e, "leid", s);
3372 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3373 a->reid_prefix_len);
3375 vat_json_object_add_string_copy (e, "reid", s);
3379 vat_json_print (vam->ofp, &root);
3380 vat_json_free (&root);
3383 vam->retval = retval;
3384 vam->result_ready = 1;
3388 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3390 vat_main_t *vam = &vat_main;
3392 print (vam->ofp, "%=20U",
3393 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3398 vl_api_one_map_server_details_t_handler_json
3399 (vl_api_one_map_server_details_t * mp)
3401 vat_main_t *vam = &vat_main;
3402 vat_json_node_t *node = NULL;
3403 struct in6_addr ip6;
3406 if (VAT_JSON_ARRAY != vam->json_tree.type)
3408 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3409 vat_json_init_array (&vam->json_tree);
3411 node = vat_json_array_add (&vam->json_tree);
3413 vat_json_init_object (node);
3416 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3417 vat_json_object_add_ip6 (node, "map-server", ip6);
3421 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3422 vat_json_object_add_ip4 (node, "map-server", ip4);
3427 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3430 vat_main_t *vam = &vat_main;
3432 print (vam->ofp, "%=20U",
3433 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3438 vl_api_one_map_resolver_details_t_handler_json
3439 (vl_api_one_map_resolver_details_t * mp)
3441 vat_main_t *vam = &vat_main;
3442 vat_json_node_t *node = NULL;
3443 struct in6_addr ip6;
3446 if (VAT_JSON_ARRAY != vam->json_tree.type)
3448 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3449 vat_json_init_array (&vam->json_tree);
3451 node = vat_json_array_add (&vam->json_tree);
3453 vat_json_init_object (node);
3456 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3457 vat_json_object_add_ip6 (node, "map resolver", ip6);
3461 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3462 vat_json_object_add_ip4 (node, "map resolver", ip4);
3467 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3469 vat_main_t *vam = &vat_main;
3470 i32 retval = ntohl (mp->retval);
3474 print (vam->ofp, "feature: %s\ngpe: %s",
3475 mp->feature_status ? "enabled" : "disabled",
3476 mp->gpe_status ? "enabled" : "disabled");
3479 vam->retval = retval;
3480 vam->result_ready = 1;
3484 vl_api_show_one_status_reply_t_handler_json
3485 (vl_api_show_one_status_reply_t * mp)
3487 vat_main_t *vam = &vat_main;
3488 vat_json_node_t node;
3489 u8 *gpe_status = NULL;
3490 u8 *feature_status = NULL;
3492 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3493 feature_status = format (0, "%s",
3494 mp->feature_status ? "enabled" : "disabled");
3495 vec_add1 (gpe_status, 0);
3496 vec_add1 (feature_status, 0);
3498 vat_json_init_object (&node);
3499 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3500 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3502 vec_free (gpe_status);
3503 vec_free (feature_status);
3505 vat_json_print (vam->ofp, &node);
3506 vat_json_free (&node);
3508 vam->retval = ntohl (mp->retval);
3509 vam->result_ready = 1;
3513 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3514 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3516 vat_main_t *vam = &vat_main;
3517 i32 retval = ntohl (mp->retval);
3521 print (vam->ofp, "%=20s", mp->locator_set_name);
3524 vam->retval = retval;
3525 vam->result_ready = 1;
3529 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3530 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3532 vat_main_t *vam = &vat_main;
3533 vat_json_node_t *node = NULL;
3535 if (VAT_JSON_ARRAY != vam->json_tree.type)
3537 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3538 vat_json_init_array (&vam->json_tree);
3540 node = vat_json_array_add (&vam->json_tree);
3542 vat_json_init_object (node);
3543 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3545 vat_json_print (vam->ofp, node);
3546 vat_json_free (node);
3548 vam->retval = ntohl (mp->retval);
3549 vam->result_ready = 1;
3553 format_lisp_map_request_mode (u8 * s, va_list * args)
3555 u32 mode = va_arg (*args, u32);
3560 return format (0, "dst-only");
3562 return format (0, "src-dst");
3568 vl_api_show_one_map_request_mode_reply_t_handler
3569 (vl_api_show_one_map_request_mode_reply_t * mp)
3571 vat_main_t *vam = &vat_main;
3572 i32 retval = ntohl (mp->retval);
3576 u32 mode = mp->mode;
3577 print (vam->ofp, "map_request_mode: %U",
3578 format_lisp_map_request_mode, mode);
3581 vam->retval = retval;
3582 vam->result_ready = 1;
3586 vl_api_show_one_map_request_mode_reply_t_handler_json
3587 (vl_api_show_one_map_request_mode_reply_t * mp)
3589 vat_main_t *vam = &vat_main;
3590 vat_json_node_t node;
3595 s = format (0, "%U", format_lisp_map_request_mode, mode);
3598 vat_json_init_object (&node);
3599 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3600 vat_json_print (vam->ofp, &node);
3601 vat_json_free (&node);
3604 vam->retval = ntohl (mp->retval);
3605 vam->result_ready = 1;
3609 vl_api_show_one_use_petr_reply_t_handler
3610 (vl_api_show_one_use_petr_reply_t * mp)
3612 vat_main_t *vam = &vat_main;
3613 i32 retval = ntohl (mp->retval);
3617 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
3620 print (vam->ofp, "Proxy-ETR address; %U",
3621 mp->is_ip4 ? format_ip4_address : format_ip6_address,
3626 vam->retval = retval;
3627 vam->result_ready = 1;
3631 vl_api_show_one_use_petr_reply_t_handler_json
3632 (vl_api_show_one_use_petr_reply_t * mp)
3634 vat_main_t *vam = &vat_main;
3635 vat_json_node_t node;
3638 struct in6_addr ip6;
3640 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3641 vec_add1 (status, 0);
3643 vat_json_init_object (&node);
3644 vat_json_object_add_string_copy (&node, "status", status);
3649 clib_memcpy (&ip6, mp->address, sizeof (ip6));
3650 vat_json_object_add_ip6 (&node, "address", ip6);
3654 clib_memcpy (&ip4, mp->address, sizeof (ip4));
3655 vat_json_object_add_ip4 (&node, "address", ip4);
3661 vat_json_print (vam->ofp, &node);
3662 vat_json_free (&node);
3664 vam->retval = ntohl (mp->retval);
3665 vam->result_ready = 1;
3669 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3671 vat_main_t *vam = &vat_main;
3672 i32 retval = ntohl (mp->retval);
3676 print (vam->ofp, "%-20s%-16s",
3677 mp->status ? "enabled" : "disabled",
3678 mp->status ? (char *) mp->locator_set_name : "");
3681 vam->retval = retval;
3682 vam->result_ready = 1;
3686 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3688 vat_main_t *vam = &vat_main;
3689 vat_json_node_t node;
3692 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3693 vec_add1 (status, 0);
3695 vat_json_init_object (&node);
3696 vat_json_object_add_string_copy (&node, "status", status);
3699 vat_json_object_add_string_copy (&node, "locator_set",
3700 mp->locator_set_name);
3705 vat_json_print (vam->ofp, &node);
3706 vat_json_free (&node);
3708 vam->retval = ntohl (mp->retval);
3709 vam->result_ready = 1;
3713 format_policer_type (u8 * s, va_list * va)
3715 u32 i = va_arg (*va, u32);
3717 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3718 s = format (s, "1r2c");
3719 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3720 s = format (s, "1r3c");
3721 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3722 s = format (s, "2r3c-2698");
3723 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3724 s = format (s, "2r3c-4115");
3725 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3726 s = format (s, "2r3c-mef5cf1");
3728 s = format (s, "ILLEGAL");
3733 format_policer_rate_type (u8 * s, va_list * va)
3735 u32 i = va_arg (*va, u32);
3737 if (i == SSE2_QOS_RATE_KBPS)
3738 s = format (s, "kbps");
3739 else if (i == SSE2_QOS_RATE_PPS)
3740 s = format (s, "pps");
3742 s = format (s, "ILLEGAL");
3747 format_policer_round_type (u8 * s, va_list * va)
3749 u32 i = va_arg (*va, u32);
3751 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3752 s = format (s, "closest");
3753 else if (i == SSE2_QOS_ROUND_TO_UP)
3754 s = format (s, "up");
3755 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3756 s = format (s, "down");
3758 s = format (s, "ILLEGAL");
3763 format_policer_action_type (u8 * s, va_list * va)
3765 u32 i = va_arg (*va, u32);
3767 if (i == SSE2_QOS_ACTION_DROP)
3768 s = format (s, "drop");
3769 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3770 s = format (s, "transmit");
3771 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3772 s = format (s, "mark-and-transmit");
3774 s = format (s, "ILLEGAL");
3779 format_dscp (u8 * s, va_list * va)
3781 u32 i = va_arg (*va, u32);
3786 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3790 return format (s, "ILLEGAL");
3792 s = format (s, "%s", t);
3797 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3799 vat_main_t *vam = &vat_main;
3800 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3802 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3803 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3805 conform_dscp_str = format (0, "");
3807 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3808 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3810 exceed_dscp_str = format (0, "");
3812 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3813 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3815 violate_dscp_str = format (0, "");
3817 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3818 "rate type %U, round type %U, %s rate, %s color-aware, "
3819 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3820 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3821 "conform action %U%s, exceed action %U%s, violate action %U%s",
3823 format_policer_type, mp->type,
3826 clib_net_to_host_u64 (mp->cb),
3827 clib_net_to_host_u64 (mp->eb),
3828 format_policer_rate_type, mp->rate_type,
3829 format_policer_round_type, mp->round_type,
3830 mp->single_rate ? "single" : "dual",
3831 mp->color_aware ? "is" : "not",
3832 ntohl (mp->cir_tokens_per_period),
3833 ntohl (mp->pir_tokens_per_period),
3835 ntohl (mp->current_limit),
3836 ntohl (mp->current_bucket),
3837 ntohl (mp->extended_limit),
3838 ntohl (mp->extended_bucket),
3839 clib_net_to_host_u64 (mp->last_update_time),
3840 format_policer_action_type, mp->conform_action_type,
3842 format_policer_action_type, mp->exceed_action_type,
3844 format_policer_action_type, mp->violate_action_type,
3847 vec_free (conform_dscp_str);
3848 vec_free (exceed_dscp_str);
3849 vec_free (violate_dscp_str);
3852 static void vl_api_policer_details_t_handler_json
3853 (vl_api_policer_details_t * mp)
3855 vat_main_t *vam = &vat_main;
3856 vat_json_node_t *node;
3857 u8 *rate_type_str, *round_type_str, *type_str;
3858 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3860 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3862 format (0, "%U", format_policer_round_type, mp->round_type);
3863 type_str = format (0, "%U", format_policer_type, mp->type);
3864 conform_action_str = format (0, "%U", format_policer_action_type,
3865 mp->conform_action_type);
3866 exceed_action_str = format (0, "%U", format_policer_action_type,
3867 mp->exceed_action_type);
3868 violate_action_str = format (0, "%U", format_policer_action_type,
3869 mp->violate_action_type);
3871 if (VAT_JSON_ARRAY != vam->json_tree.type)
3873 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3874 vat_json_init_array (&vam->json_tree);
3876 node = vat_json_array_add (&vam->json_tree);
3878 vat_json_init_object (node);
3879 vat_json_object_add_string_copy (node, "name", mp->name);
3880 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3881 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3882 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
3883 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
3884 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3885 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3886 vat_json_object_add_string_copy (node, "type", type_str);
3887 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3888 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3889 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3890 vat_json_object_add_uint (node, "cir_tokens_per_period",
3891 ntohl (mp->cir_tokens_per_period));
3892 vat_json_object_add_uint (node, "eir_tokens_per_period",
3893 ntohl (mp->pir_tokens_per_period));
3894 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3895 vat_json_object_add_uint (node, "current_bucket",
3896 ntohl (mp->current_bucket));
3897 vat_json_object_add_uint (node, "extended_limit",
3898 ntohl (mp->extended_limit));
3899 vat_json_object_add_uint (node, "extended_bucket",
3900 ntohl (mp->extended_bucket));
3901 vat_json_object_add_uint (node, "last_update_time",
3902 ntohl (mp->last_update_time));
3903 vat_json_object_add_string_copy (node, "conform_action",
3904 conform_action_str);
3905 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3907 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3908 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3909 vec_free (dscp_str);
3911 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3912 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3914 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3915 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3916 vec_free (dscp_str);
3918 vat_json_object_add_string_copy (node, "violate_action",
3919 violate_action_str);
3920 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3922 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3923 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3924 vec_free (dscp_str);
3927 vec_free (rate_type_str);
3928 vec_free (round_type_str);
3929 vec_free (type_str);
3930 vec_free (conform_action_str);
3931 vec_free (exceed_action_str);
3932 vec_free (violate_action_str);
3936 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3939 vat_main_t *vam = &vat_main;
3940 int i, count = ntohl (mp->count);
3943 print (vam->ofp, "classify table ids (%d) : ", count);
3944 for (i = 0; i < count; i++)
3946 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3947 print (vam->ofp, (i < count - 1) ? "," : "");
3949 vam->retval = ntohl (mp->retval);
3950 vam->result_ready = 1;
3954 vl_api_classify_table_ids_reply_t_handler_json
3955 (vl_api_classify_table_ids_reply_t * mp)
3957 vat_main_t *vam = &vat_main;
3958 int i, count = ntohl (mp->count);
3962 vat_json_node_t node;
3964 vat_json_init_object (&node);
3965 for (i = 0; i < count; i++)
3967 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3969 vat_json_print (vam->ofp, &node);
3970 vat_json_free (&node);
3972 vam->retval = ntohl (mp->retval);
3973 vam->result_ready = 1;
3977 vl_api_classify_table_by_interface_reply_t_handler
3978 (vl_api_classify_table_by_interface_reply_t * mp)
3980 vat_main_t *vam = &vat_main;
3983 table_id = ntohl (mp->l2_table_id);
3985 print (vam->ofp, "l2 table id : %d", table_id);
3987 print (vam->ofp, "l2 table id : No input ACL tables configured");
3988 table_id = ntohl (mp->ip4_table_id);
3990 print (vam->ofp, "ip4 table id : %d", table_id);
3992 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3993 table_id = ntohl (mp->ip6_table_id);
3995 print (vam->ofp, "ip6 table id : %d", table_id);
3997 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3998 vam->retval = ntohl (mp->retval);
3999 vam->result_ready = 1;
4003 vl_api_classify_table_by_interface_reply_t_handler_json
4004 (vl_api_classify_table_by_interface_reply_t * mp)
4006 vat_main_t *vam = &vat_main;
4007 vat_json_node_t node;
4009 vat_json_init_object (&node);
4011 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4012 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4013 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4015 vat_json_print (vam->ofp, &node);
4016 vat_json_free (&node);
4018 vam->retval = ntohl (mp->retval);
4019 vam->result_ready = 1;
4022 static void vl_api_policer_add_del_reply_t_handler
4023 (vl_api_policer_add_del_reply_t * mp)
4025 vat_main_t *vam = &vat_main;
4026 i32 retval = ntohl (mp->retval);
4027 if (vam->async_mode)
4029 vam->async_errors += (retval < 0);
4033 vam->retval = retval;
4034 vam->result_ready = 1;
4035 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4037 * Note: this is just barely thread-safe, depends on
4038 * the main thread spinning waiting for an answer...
4040 errmsg ("policer index %d", ntohl (mp->policer_index));
4044 static void vl_api_policer_add_del_reply_t_handler_json
4045 (vl_api_policer_add_del_reply_t * mp)
4047 vat_main_t *vam = &vat_main;
4048 vat_json_node_t node;
4050 vat_json_init_object (&node);
4051 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4052 vat_json_object_add_uint (&node, "policer_index",
4053 ntohl (mp->policer_index));
4055 vat_json_print (vam->ofp, &node);
4056 vat_json_free (&node);
4058 vam->retval = ntohl (mp->retval);
4059 vam->result_ready = 1;
4062 /* Format hex dump. */
4064 format_hex_bytes (u8 * s, va_list * va)
4066 u8 *bytes = va_arg (*va, u8 *);
4067 int n_bytes = va_arg (*va, int);
4070 /* Print short or long form depending on byte count. */
4071 uword short_form = n_bytes <= 32;
4072 uword indent = format_get_indent (s);
4077 for (i = 0; i < n_bytes; i++)
4079 if (!short_form && (i % 32) == 0)
4080 s = format (s, "%08x: ", i);
4081 s = format (s, "%02x", bytes[i]);
4082 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4083 s = format (s, "\n%U", format_white_space, indent);
4090 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4093 vat_main_t *vam = &vat_main;
4094 i32 retval = ntohl (mp->retval);
4097 print (vam->ofp, "classify table info :");
4098 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4099 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4100 ntohl (mp->miss_next_index));
4101 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4102 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4103 ntohl (mp->match_n_vectors));
4104 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4105 ntohl (mp->mask_length));
4107 vam->retval = retval;
4108 vam->result_ready = 1;
4112 vl_api_classify_table_info_reply_t_handler_json
4113 (vl_api_classify_table_info_reply_t * mp)
4115 vat_main_t *vam = &vat_main;
4116 vat_json_node_t node;
4118 i32 retval = ntohl (mp->retval);
4121 vat_json_init_object (&node);
4123 vat_json_object_add_int (&node, "sessions",
4124 ntohl (mp->active_sessions));
4125 vat_json_object_add_int (&node, "nexttbl",
4126 ntohl (mp->next_table_index));
4127 vat_json_object_add_int (&node, "nextnode",
4128 ntohl (mp->miss_next_index));
4129 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4130 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4131 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4132 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4133 ntohl (mp->mask_length), 0);
4134 vat_json_object_add_string_copy (&node, "mask", s);
4136 vat_json_print (vam->ofp, &node);
4137 vat_json_free (&node);
4139 vam->retval = ntohl (mp->retval);
4140 vam->result_ready = 1;
4144 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4147 vat_main_t *vam = &vat_main;
4149 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4150 ntohl (mp->hit_next_index), ntohl (mp->advance),
4151 ntohl (mp->opaque_index));
4152 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4153 ntohl (mp->match_length));
4157 vl_api_classify_session_details_t_handler_json
4158 (vl_api_classify_session_details_t * mp)
4160 vat_main_t *vam = &vat_main;
4161 vat_json_node_t *node = NULL;
4163 if (VAT_JSON_ARRAY != vam->json_tree.type)
4165 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4166 vat_json_init_array (&vam->json_tree);
4168 node = vat_json_array_add (&vam->json_tree);
4170 vat_json_init_object (node);
4171 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4172 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4173 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4175 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4177 vat_json_object_add_string_copy (node, "match", s);
4180 static void vl_api_pg_create_interface_reply_t_handler
4181 (vl_api_pg_create_interface_reply_t * mp)
4183 vat_main_t *vam = &vat_main;
4185 vam->retval = ntohl (mp->retval);
4186 vam->result_ready = 1;
4189 static void vl_api_pg_create_interface_reply_t_handler_json
4190 (vl_api_pg_create_interface_reply_t * mp)
4192 vat_main_t *vam = &vat_main;
4193 vat_json_node_t node;
4195 i32 retval = ntohl (mp->retval);
4198 vat_json_init_object (&node);
4200 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4202 vat_json_print (vam->ofp, &node);
4203 vat_json_free (&node);
4205 vam->retval = ntohl (mp->retval);
4206 vam->result_ready = 1;
4209 static void vl_api_policer_classify_details_t_handler
4210 (vl_api_policer_classify_details_t * mp)
4212 vat_main_t *vam = &vat_main;
4214 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4215 ntohl (mp->table_index));
4218 static void vl_api_policer_classify_details_t_handler_json
4219 (vl_api_policer_classify_details_t * mp)
4221 vat_main_t *vam = &vat_main;
4222 vat_json_node_t *node;
4224 if (VAT_JSON_ARRAY != vam->json_tree.type)
4226 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4227 vat_json_init_array (&vam->json_tree);
4229 node = vat_json_array_add (&vam->json_tree);
4231 vat_json_init_object (node);
4232 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4233 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4236 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4237 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4239 vat_main_t *vam = &vat_main;
4240 i32 retval = ntohl (mp->retval);
4241 if (vam->async_mode)
4243 vam->async_errors += (retval < 0);
4247 vam->retval = retval;
4248 vam->sw_if_index = ntohl (mp->sw_if_index);
4249 vam->result_ready = 1;
4253 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4254 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4256 vat_main_t *vam = &vat_main;
4257 vat_json_node_t node;
4259 vat_json_init_object (&node);
4260 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4261 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4263 vat_json_print (vam->ofp, &node);
4264 vat_json_free (&node);
4266 vam->retval = ntohl (mp->retval);
4267 vam->result_ready = 1;
4270 static void vl_api_flow_classify_details_t_handler
4271 (vl_api_flow_classify_details_t * mp)
4273 vat_main_t *vam = &vat_main;
4275 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4276 ntohl (mp->table_index));
4279 static void vl_api_flow_classify_details_t_handler_json
4280 (vl_api_flow_classify_details_t * mp)
4282 vat_main_t *vam = &vat_main;
4283 vat_json_node_t *node;
4285 if (VAT_JSON_ARRAY != vam->json_tree.type)
4287 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4288 vat_json_init_array (&vam->json_tree);
4290 node = vat_json_array_add (&vam->json_tree);
4292 vat_json_init_object (node);
4293 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4294 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4297 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
4298 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
4299 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
4300 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
4301 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4302 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4303 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4304 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4305 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4306 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4307 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4308 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4309 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4310 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4311 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
4312 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
4313 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
4314 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
4317 * Generate boilerplate reply handlers, which
4318 * dig the return value out of the xxx_reply_t API message,
4319 * stick it into vam->retval, and set vam->result_ready
4321 * Could also do this by pointing N message decode slots at
4322 * a single function, but that could break in subtle ways.
4325 #define foreach_standard_reply_retval_handler \
4326 _(sw_interface_set_flags_reply) \
4327 _(sw_interface_add_del_address_reply) \
4328 _(sw_interface_set_table_reply) \
4329 _(sw_interface_set_mpls_enable_reply) \
4330 _(sw_interface_set_vpath_reply) \
4331 _(sw_interface_set_vxlan_bypass_reply) \
4332 _(sw_interface_set_l2_bridge_reply) \
4333 _(bridge_domain_add_del_reply) \
4334 _(sw_interface_set_l2_xconnect_reply) \
4335 _(l2fib_add_del_reply) \
4336 _(l2fib_flush_int_reply) \
4337 _(l2fib_flush_bd_reply) \
4338 _(ip_add_del_route_reply) \
4339 _(ip_mroute_add_del_reply) \
4340 _(mpls_route_add_del_reply) \
4341 _(mpls_ip_bind_unbind_reply) \
4342 _(proxy_arp_add_del_reply) \
4343 _(proxy_arp_intfc_enable_disable_reply) \
4344 _(sw_interface_set_unnumbered_reply) \
4345 _(ip_neighbor_add_del_reply) \
4346 _(reset_vrf_reply) \
4347 _(oam_add_del_reply) \
4348 _(reset_fib_reply) \
4349 _(dhcp_proxy_config_reply) \
4350 _(dhcp_proxy_set_vss_reply) \
4351 _(dhcp_client_config_reply) \
4352 _(set_ip_flow_hash_reply) \
4353 _(sw_interface_ip6_enable_disable_reply) \
4354 _(sw_interface_ip6_set_link_local_address_reply) \
4355 _(ip6nd_proxy_add_del_reply) \
4356 _(sw_interface_ip6nd_ra_prefix_reply) \
4357 _(sw_interface_ip6nd_ra_config_reply) \
4358 _(set_arp_neighbor_limit_reply) \
4359 _(l2_patch_add_del_reply) \
4360 _(sr_policy_add_reply) \
4361 _(sr_policy_mod_reply) \
4362 _(sr_policy_del_reply) \
4363 _(sr_localsid_add_del_reply) \
4364 _(sr_steering_add_del_reply) \
4365 _(classify_add_del_session_reply) \
4366 _(classify_set_interface_ip_table_reply) \
4367 _(classify_set_interface_l2_tables_reply) \
4368 _(l2tpv3_set_tunnel_cookies_reply) \
4369 _(l2tpv3_interface_enable_disable_reply) \
4370 _(l2tpv3_set_lookup_key_reply) \
4371 _(l2_fib_clear_table_reply) \
4372 _(l2_interface_efp_filter_reply) \
4373 _(l2_interface_vlan_tag_rewrite_reply) \
4374 _(modify_vhost_user_if_reply) \
4375 _(delete_vhost_user_if_reply) \
4376 _(want_ip4_arp_events_reply) \
4377 _(want_ip6_nd_events_reply) \
4378 _(input_acl_set_interface_reply) \
4379 _(ipsec_spd_add_del_reply) \
4380 _(ipsec_interface_add_del_spd_reply) \
4381 _(ipsec_spd_add_del_entry_reply) \
4382 _(ipsec_sad_add_del_entry_reply) \
4383 _(ipsec_sa_set_key_reply) \
4384 _(ipsec_tunnel_if_add_del_reply) \
4385 _(ikev2_profile_add_del_reply) \
4386 _(ikev2_profile_set_auth_reply) \
4387 _(ikev2_profile_set_id_reply) \
4388 _(ikev2_profile_set_ts_reply) \
4389 _(ikev2_set_local_key_reply) \
4390 _(ikev2_set_responder_reply) \
4391 _(ikev2_set_ike_transforms_reply) \
4392 _(ikev2_set_esp_transforms_reply) \
4393 _(ikev2_set_sa_lifetime_reply) \
4394 _(ikev2_initiate_sa_init_reply) \
4395 _(ikev2_initiate_del_ike_sa_reply) \
4396 _(ikev2_initiate_del_child_sa_reply) \
4397 _(ikev2_initiate_rekey_child_sa_reply) \
4398 _(delete_loopback_reply) \
4399 _(bd_ip_mac_add_del_reply) \
4400 _(map_del_domain_reply) \
4401 _(map_add_del_rule_reply) \
4402 _(want_interface_events_reply) \
4403 _(want_stats_reply) \
4404 _(cop_interface_enable_disable_reply) \
4405 _(cop_whitelist_enable_disable_reply) \
4406 _(sw_interface_clear_stats_reply) \
4407 _(ioam_enable_reply) \
4408 _(ioam_disable_reply) \
4409 _(one_add_del_locator_reply) \
4410 _(one_add_del_local_eid_reply) \
4411 _(one_add_del_remote_mapping_reply) \
4412 _(one_add_del_adjacency_reply) \
4413 _(one_add_del_map_resolver_reply) \
4414 _(one_add_del_map_server_reply) \
4415 _(one_enable_disable_reply) \
4416 _(one_rloc_probe_enable_disable_reply) \
4417 _(one_map_register_enable_disable_reply) \
4418 _(one_pitr_set_locator_set_reply) \
4419 _(one_map_request_mode_reply) \
4420 _(one_add_del_map_request_itr_rlocs_reply) \
4421 _(one_eid_table_add_del_map_reply) \
4422 _(one_use_petr_reply) \
4423 _(one_stats_enable_disable_reply) \
4424 _(one_add_del_l2_arp_entry_reply) \
4425 _(one_stats_flush_reply) \
4426 _(gpe_enable_disable_reply) \
4427 _(gpe_set_encap_mode_reply) \
4428 _(gpe_add_del_iface_reply) \
4429 _(vxlan_gpe_add_del_tunnel_reply) \
4430 _(af_packet_delete_reply) \
4431 _(policer_classify_set_interface_reply) \
4432 _(netmap_create_reply) \
4433 _(netmap_delete_reply) \
4434 _(set_ipfix_exporter_reply) \
4435 _(set_ipfix_classify_stream_reply) \
4436 _(ipfix_classify_table_add_del_reply) \
4437 _(flow_classify_set_interface_reply) \
4438 _(sw_interface_span_enable_disable_reply) \
4439 _(pg_capture_reply) \
4440 _(pg_enable_disable_reply) \
4441 _(ip_source_and_port_range_check_add_del_reply) \
4442 _(ip_source_and_port_range_check_interface_add_del_reply)\
4443 _(delete_subif_reply) \
4444 _(l2_interface_pbb_tag_rewrite_reply) \
4446 _(feature_enable_disable_reply) \
4447 _(sw_interface_tag_add_del_reply) \
4448 _(sw_interface_set_mtu_reply)
4451 static void vl_api_##n##_t_handler \
4452 (vl_api_##n##_t * mp) \
4454 vat_main_t * vam = &vat_main; \
4455 i32 retval = ntohl(mp->retval); \
4456 if (vam->async_mode) { \
4457 vam->async_errors += (retval < 0); \
4459 vam->retval = retval; \
4460 vam->result_ready = 1; \
4463 foreach_standard_reply_retval_handler;
4467 static void vl_api_##n##_t_handler_json \
4468 (vl_api_##n##_t * mp) \
4470 vat_main_t * vam = &vat_main; \
4471 vat_json_node_t node; \
4472 vat_json_init_object(&node); \
4473 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4474 vat_json_print(vam->ofp, &node); \
4475 vam->retval = ntohl(mp->retval); \
4476 vam->result_ready = 1; \
4478 foreach_standard_reply_retval_handler;
4482 * Table of message reply handlers, must include boilerplate handlers
4486 #define foreach_vpe_api_reply_msg \
4487 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4488 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4489 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4490 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4491 _(CONTROL_PING_REPLY, control_ping_reply) \
4492 _(CLI_REPLY, cli_reply) \
4493 _(CLI_INBAND_REPLY, cli_inband_reply) \
4494 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4495 sw_interface_add_del_address_reply) \
4496 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4497 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4498 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4499 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4500 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4501 sw_interface_set_l2_xconnect_reply) \
4502 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4503 sw_interface_set_l2_bridge_reply) \
4504 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4505 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4506 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
4507 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4508 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
4509 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
4510 _(L2_FLAGS_REPLY, l2_flags_reply) \
4511 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4512 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4513 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4514 _(TAP_DELETE_REPLY, tap_delete_reply) \
4515 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4516 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4517 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4518 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4519 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4520 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4521 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4522 proxy_arp_intfc_enable_disable_reply) \
4523 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4524 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4525 sw_interface_set_unnumbered_reply) \
4526 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4527 _(RESET_VRF_REPLY, reset_vrf_reply) \
4528 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4529 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4530 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4531 _(RESET_FIB_REPLY, reset_fib_reply) \
4532 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4533 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4534 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4535 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4536 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4537 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4538 sw_interface_ip6_enable_disable_reply) \
4539 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4540 sw_interface_ip6_set_link_local_address_reply) \
4541 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
4542 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
4543 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4544 sw_interface_ip6nd_ra_prefix_reply) \
4545 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4546 sw_interface_ip6nd_ra_config_reply) \
4547 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4548 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4549 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4550 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4551 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4552 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4553 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4554 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4555 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4556 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4557 classify_set_interface_ip_table_reply) \
4558 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4559 classify_set_interface_l2_tables_reply) \
4560 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4561 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4562 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4563 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4564 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4565 l2tpv3_interface_enable_disable_reply) \
4566 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4567 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4568 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4569 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4570 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4571 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4572 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4573 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4574 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4575 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4576 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4577 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4578 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4579 _(SHOW_VERSION_REPLY, show_version_reply) \
4580 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
4581 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4582 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4583 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4584 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4585 _(IP4_ARP_EVENT, ip4_arp_event) \
4586 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4587 _(IP6_ND_EVENT, ip6_nd_event) \
4588 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4589 _(IP_ADDRESS_DETAILS, ip_address_details) \
4590 _(IP_DETAILS, ip_details) \
4591 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4592 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4593 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4594 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4595 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4596 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
4597 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4598 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4599 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4600 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4601 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4602 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4603 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4604 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4605 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4606 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4607 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4608 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4609 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4610 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4611 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4612 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4613 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4614 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4615 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4616 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4617 _(MAP_RULE_DETAILS, map_rule_details) \
4618 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4619 _(WANT_STATS_REPLY, want_stats_reply) \
4620 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4621 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4622 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4623 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4624 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4625 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4626 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4627 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4628 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4629 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4630 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4631 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4632 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4633 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4634 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4635 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4636 one_map_register_enable_disable_reply) \
4637 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4638 one_rloc_probe_enable_disable_reply) \
4639 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4640 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
4641 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4642 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4643 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4644 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4645 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4646 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4647 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4648 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4649 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4650 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4651 _(ONE_STATS_DETAILS, one_stats_details) \
4652 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
4653 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
4654 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
4655 show_one_stats_enable_disable_reply) \
4656 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
4657 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
4658 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
4659 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4660 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4661 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4662 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4663 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4664 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
4665 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4666 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4667 gpe_fwd_entry_path_details) \
4668 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4669 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4670 one_add_del_map_request_itr_rlocs_reply) \
4671 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4672 one_get_map_request_itr_rlocs_reply) \
4673 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4674 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
4675 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4676 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4677 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4678 show_one_map_register_state_reply) \
4679 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4680 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4681 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4682 _(POLICER_DETAILS, policer_details) \
4683 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4684 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4685 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4686 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4687 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4688 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4689 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4690 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4691 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4692 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4693 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4694 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4695 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4696 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4697 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4698 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4699 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4700 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4701 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4702 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4703 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4704 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4705 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4706 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4707 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4708 ip_source_and_port_range_check_add_del_reply) \
4709 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4710 ip_source_and_port_range_check_interface_add_del_reply) \
4711 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4712 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4713 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4714 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4715 _(PUNT_REPLY, punt_reply) \
4716 _(IP_FIB_DETAILS, ip_fib_details) \
4717 _(IP6_FIB_DETAILS, ip6_fib_details) \
4718 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4719 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4720 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4721 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4722 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4723 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4725 #define foreach_standalone_reply_msg \
4726 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4727 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
4728 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
4729 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4730 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4731 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4732 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
4741 #define STR_VTR_OP_CASE(op) \
4742 case L2_VTR_ ## op: \
4746 str_vtr_op (u32 vtr_op)
4750 STR_VTR_OP_CASE (DISABLED);
4751 STR_VTR_OP_CASE (PUSH_1);
4752 STR_VTR_OP_CASE (PUSH_2);
4753 STR_VTR_OP_CASE (POP_1);
4754 STR_VTR_OP_CASE (POP_2);
4755 STR_VTR_OP_CASE (TRANSLATE_1_1);
4756 STR_VTR_OP_CASE (TRANSLATE_1_2);
4757 STR_VTR_OP_CASE (TRANSLATE_2_1);
4758 STR_VTR_OP_CASE (TRANSLATE_2_2);
4765 dump_sub_interface_table (vat_main_t * vam)
4767 const sw_interface_subif_t *sub = NULL;
4769 if (vam->json_output)
4772 ("JSON output supported only for VPE API calls and dump_stats_table");
4777 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4778 "Interface", "sw_if_index",
4779 "sub id", "dot1ad", "tags", "outer id",
4780 "inner id", "exact", "default", "outer any", "inner any");
4782 vec_foreach (sub, vam->sw_if_subif_table)
4785 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4786 sub->interface_name,
4788 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4789 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4790 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4791 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4792 if (sub->vtr_op != L2_VTR_DISABLED)
4795 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4796 "tag1: %d tag2: %d ]",
4797 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4798 sub->vtr_tag1, sub->vtr_tag2);
4806 name_sort_cmp (void *a1, void *a2)
4808 name_sort_t *n1 = a1;
4809 name_sort_t *n2 = a2;
4811 return strcmp ((char *) n1->name, (char *) n2->name);
4815 dump_interface_table (vat_main_t * vam)
4818 name_sort_t *nses = 0, *ns;
4820 if (vam->json_output)
4823 ("JSON output supported only for VPE API calls and dump_stats_table");
4828 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4830 vec_add2 (nses, ns, 1);
4831 ns->name = (u8 *)(p->key);
4832 ns->value = (u32) p->value[0];
4836 vec_sort_with_function (nses, name_sort_cmp);
4838 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4839 vec_foreach (ns, nses)
4841 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4848 dump_ip_table (vat_main_t * vam, int is_ipv6)
4850 const ip_details_t *det = NULL;
4851 const ip_address_details_t *address = NULL;
4854 print (vam->ofp, "%-12s", "sw_if_index");
4856 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4863 print (vam->ofp, "%-12d", i);
4864 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4869 vec_foreach (address, det->addr)
4873 is_ipv6 ? format_ip6_address : format_ip4_address,
4874 address->ip, address->prefix_length);
4882 dump_ipv4_table (vat_main_t * vam)
4884 if (vam->json_output)
4887 ("JSON output supported only for VPE API calls and dump_stats_table");
4891 return dump_ip_table (vam, 0);
4895 dump_ipv6_table (vat_main_t * vam)
4897 if (vam->json_output)
4900 ("JSON output supported only for VPE API calls and dump_stats_table");
4904 return dump_ip_table (vam, 1);
4908 counter_type_to_str (u8 counter_type, u8 is_combined)
4912 switch (counter_type)
4914 case VNET_INTERFACE_COUNTER_DROP:
4916 case VNET_INTERFACE_COUNTER_PUNT:
4918 case VNET_INTERFACE_COUNTER_IP4:
4920 case VNET_INTERFACE_COUNTER_IP6:
4922 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4924 case VNET_INTERFACE_COUNTER_RX_MISS:
4926 case VNET_INTERFACE_COUNTER_RX_ERROR:
4928 case VNET_INTERFACE_COUNTER_TX_ERROR:
4931 return "INVALID-COUNTER-TYPE";
4936 switch (counter_type)
4938 case VNET_INTERFACE_COUNTER_RX:
4940 case VNET_INTERFACE_COUNTER_TX:
4943 return "INVALID-COUNTER-TYPE";
4949 dump_stats_table (vat_main_t * vam)
4951 vat_json_node_t node;
4952 vat_json_node_t *msg_array;
4953 vat_json_node_t *msg;
4954 vat_json_node_t *counter_array;
4955 vat_json_node_t *counter;
4956 interface_counter_t c;
4958 ip4_fib_counter_t *c4;
4959 ip6_fib_counter_t *c6;
4960 ip4_nbr_counter_t *n4;
4961 ip6_nbr_counter_t *n6;
4964 if (!vam->json_output)
4966 clib_warning ("dump_stats_table supported only in JSON format");
4970 vat_json_init_object (&node);
4972 /* interface counters */
4973 msg_array = vat_json_object_add (&node, "interface_counters");
4974 vat_json_init_array (msg_array);
4975 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4977 msg = vat_json_array_add (msg_array);
4978 vat_json_init_object (msg);
4979 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4980 (u8 *) counter_type_to_str (i, 0));
4981 vat_json_object_add_int (msg, "is_combined", 0);
4982 counter_array = vat_json_object_add (msg, "data");
4983 vat_json_init_array (counter_array);
4984 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4986 packets = vam->simple_interface_counters[i][j];
4987 vat_json_array_add_uint (counter_array, packets);
4990 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4992 msg = vat_json_array_add (msg_array);
4993 vat_json_init_object (msg);
4994 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4995 (u8 *) counter_type_to_str (i, 1));
4996 vat_json_object_add_int (msg, "is_combined", 1);
4997 counter_array = vat_json_object_add (msg, "data");
4998 vat_json_init_array (counter_array);
4999 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5001 c = vam->combined_interface_counters[i][j];
5002 counter = vat_json_array_add (counter_array);
5003 vat_json_init_object (counter);
5004 vat_json_object_add_uint (counter, "packets", c.packets);
5005 vat_json_object_add_uint (counter, "bytes", c.bytes);
5009 /* ip4 fib counters */
5010 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5011 vat_json_init_array (msg_array);
5012 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5014 msg = vat_json_array_add (msg_array);
5015 vat_json_init_object (msg);
5016 vat_json_object_add_uint (msg, "vrf_id",
5017 vam->ip4_fib_counters_vrf_id_by_index[i]);
5018 counter_array = vat_json_object_add (msg, "c");
5019 vat_json_init_array (counter_array);
5020 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5022 counter = vat_json_array_add (counter_array);
5023 vat_json_init_object (counter);
5024 c4 = &vam->ip4_fib_counters[i][j];
5025 vat_json_object_add_ip4 (counter, "address", c4->address);
5026 vat_json_object_add_uint (counter, "address_length",
5027 c4->address_length);
5028 vat_json_object_add_uint (counter, "packets", c4->packets);
5029 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5033 /* ip6 fib counters */
5034 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5035 vat_json_init_array (msg_array);
5036 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5038 msg = vat_json_array_add (msg_array);
5039 vat_json_init_object (msg);
5040 vat_json_object_add_uint (msg, "vrf_id",
5041 vam->ip6_fib_counters_vrf_id_by_index[i]);
5042 counter_array = vat_json_object_add (msg, "c");
5043 vat_json_init_array (counter_array);
5044 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5046 counter = vat_json_array_add (counter_array);
5047 vat_json_init_object (counter);
5048 c6 = &vam->ip6_fib_counters[i][j];
5049 vat_json_object_add_ip6 (counter, "address", c6->address);
5050 vat_json_object_add_uint (counter, "address_length",
5051 c6->address_length);
5052 vat_json_object_add_uint (counter, "packets", c6->packets);
5053 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5057 /* ip4 nbr counters */
5058 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5059 vat_json_init_array (msg_array);
5060 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5062 msg = vat_json_array_add (msg_array);
5063 vat_json_init_object (msg);
5064 vat_json_object_add_uint (msg, "sw_if_index", i);
5065 counter_array = vat_json_object_add (msg, "c");
5066 vat_json_init_array (counter_array);
5067 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5069 counter = vat_json_array_add (counter_array);
5070 vat_json_init_object (counter);
5071 n4 = &vam->ip4_nbr_counters[i][j];
5072 vat_json_object_add_ip4 (counter, "address", n4->address);
5073 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5074 vat_json_object_add_uint (counter, "packets", n4->packets);
5075 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5079 /* ip6 nbr counters */
5080 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5081 vat_json_init_array (msg_array);
5082 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5084 msg = vat_json_array_add (msg_array);
5085 vat_json_init_object (msg);
5086 vat_json_object_add_uint (msg, "sw_if_index", i);
5087 counter_array = vat_json_object_add (msg, "c");
5088 vat_json_init_array (counter_array);
5089 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5091 counter = vat_json_array_add (counter_array);
5092 vat_json_init_object (counter);
5093 n6 = &vam->ip6_nbr_counters[i][j];
5094 vat_json_object_add_ip6 (counter, "address", n6->address);
5095 vat_json_object_add_uint (counter, "packets", n6->packets);
5096 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5100 vat_json_print (vam->ofp, &node);
5101 vat_json_free (&node);
5107 exec (vat_main_t * vam)
5109 api_main_t *am = &api_main;
5114 unformat_input_t *i = vam->input;
5116 if (vec_len (i->buffer) == 0)
5119 if (vam->exec_mode == 0 && unformat (i, "mode"))
5124 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5134 * Copy cmd into shared memory.
5135 * In order for the CLI command to work, it
5136 * must be a vector ending in \n, not a C-string ending
5139 pthread_mutex_lock (&am->vlib_rp->mutex);
5140 oldheap = svm_push_data_heap (am->vlib_rp);
5142 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
5143 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
5145 svm_pop_heap (oldheap);
5146 pthread_mutex_unlock (&am->vlib_rp->mutex);
5148 mp->cmd_in_shmem = pointer_to_uword (cmd);
5150 timeout = vat_time_now (vam) + 10.0;
5152 while (vat_time_now (vam) < timeout)
5154 if (vam->result_ready == 1)
5157 if (vam->shmem_result != NULL)
5158 print (vam->ofp, "%s", vam->shmem_result);
5159 pthread_mutex_lock (&am->vlib_rp->mutex);
5160 oldheap = svm_push_data_heap (am->vlib_rp);
5162 free_me = (u8 *) vam->shmem_result;
5165 svm_pop_heap (oldheap);
5166 pthread_mutex_unlock (&am->vlib_rp->mutex);
5174 * Future replacement of exec() that passes CLI buffers directly in
5175 * the API messages instead of an additional shared memory area.
5178 exec_inband (vat_main_t * vam)
5180 vl_api_cli_inband_t *mp;
5181 unformat_input_t *i = vam->input;
5184 if (vec_len (i->buffer) == 0)
5187 if (vam->exec_mode == 0 && unformat (i, "mode"))
5192 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5199 * In order for the CLI command to work, it
5200 * must be a vector ending in \n, not a C-string ending
5203 u32 len = vec_len (vam->input->buffer);
5204 M2 (CLI_INBAND, mp, len);
5205 clib_memcpy (mp->cmd, vam->input->buffer, len);
5206 mp->length = htonl (len);
5209 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
5214 api_create_loopback (vat_main_t * vam)
5216 unformat_input_t *i = vam->input;
5217 vl_api_create_loopback_t *mp;
5218 vl_api_create_loopback_instance_t *mp_lbi;
5221 u8 is_specified = 0;
5222 u32 user_instance = 0;
5225 memset (mac_address, 0, sizeof (mac_address));
5227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5229 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5231 if (unformat (i, "instance %d", &user_instance))
5239 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5240 mp_lbi->is_specified = is_specified;
5242 mp_lbi->user_instance = htonl (user_instance);
5244 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5249 /* Construct the API message */
5250 M (CREATE_LOOPBACK, mp);
5252 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5261 api_delete_loopback (vat_main_t * vam)
5263 unformat_input_t *i = vam->input;
5264 vl_api_delete_loopback_t *mp;
5265 u32 sw_if_index = ~0;
5268 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5270 if (unformat (i, "sw_if_index %d", &sw_if_index))
5276 if (sw_if_index == ~0)
5278 errmsg ("missing sw_if_index");
5282 /* Construct the API message */
5283 M (DELETE_LOOPBACK, mp);
5284 mp->sw_if_index = ntohl (sw_if_index);
5292 api_want_stats (vat_main_t * vam)
5294 unformat_input_t *i = vam->input;
5295 vl_api_want_stats_t *mp;
5299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5301 if (unformat (i, "enable"))
5303 else if (unformat (i, "disable"))
5311 errmsg ("missing enable|disable");
5316 mp->enable_disable = enable;
5324 api_want_interface_events (vat_main_t * vam)
5326 unformat_input_t *i = vam->input;
5327 vl_api_want_interface_events_t *mp;
5331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5333 if (unformat (i, "enable"))
5335 else if (unformat (i, "disable"))
5343 errmsg ("missing enable|disable");
5347 M (WANT_INTERFACE_EVENTS, mp);
5348 mp->enable_disable = enable;
5350 vam->interface_event_display = enable;
5358 /* Note: non-static, called once to set up the initial intfc table */
5360 api_sw_interface_dump (vat_main_t * vam)
5362 vl_api_sw_interface_dump_t *mp;
5363 vl_api_control_ping_t *mp_ping;
5365 name_sort_t *nses = 0, *ns;
5366 sw_interface_subif_t *sub = NULL;
5369 /* Toss the old name table */
5371 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5373 vec_add2 (nses, ns, 1);
5374 ns->name = (u8 *)(p->key);
5375 ns->value = (u32) p->value[0];
5379 hash_free (vam->sw_if_index_by_interface_name);
5381 vec_foreach (ns, nses) vec_free (ns->name);
5385 vec_foreach (sub, vam->sw_if_subif_table)
5387 vec_free (sub->interface_name);
5389 vec_free (vam->sw_if_subif_table);
5391 /* recreate the interface name hash table */
5392 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5394 /* Get list of ethernets */
5395 M (SW_INTERFACE_DUMP, mp);
5396 mp->name_filter_valid = 1;
5397 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
5400 /* and local / loopback interfaces */
5401 M (SW_INTERFACE_DUMP, mp);
5402 mp->name_filter_valid = 1;
5403 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
5406 /* and packet-generator interfaces */
5407 M (SW_INTERFACE_DUMP, mp);
5408 mp->name_filter_valid = 1;
5409 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
5412 /* and vxlan-gpe tunnel interfaces */
5413 M (SW_INTERFACE_DUMP, mp);
5414 mp->name_filter_valid = 1;
5415 strncpy ((char *) mp->name_filter, "vxlan_gpe",
5416 sizeof (mp->name_filter) - 1);
5419 /* and vxlan tunnel interfaces */
5420 M (SW_INTERFACE_DUMP, mp);
5421 mp->name_filter_valid = 1;
5422 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
5425 /* and host (af_packet) interfaces */
5426 M (SW_INTERFACE_DUMP, mp);
5427 mp->name_filter_valid = 1;
5428 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
5431 /* and l2tpv3 tunnel interfaces */
5432 M (SW_INTERFACE_DUMP, mp);
5433 mp->name_filter_valid = 1;
5434 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
5435 sizeof (mp->name_filter) - 1);
5438 /* and GRE tunnel interfaces */
5439 M (SW_INTERFACE_DUMP, mp);
5440 mp->name_filter_valid = 1;
5441 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
5444 /* and LISP-GPE interfaces */
5445 M (SW_INTERFACE_DUMP, mp);
5446 mp->name_filter_valid = 1;
5447 strncpy ((char *) mp->name_filter, "lisp_gpe",
5448 sizeof (mp->name_filter) - 1);
5451 /* and IPSEC tunnel interfaces */
5452 M (SW_INTERFACE_DUMP, mp);
5453 mp->name_filter_valid = 1;
5454 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
5457 /* Use a control ping for synchronization */
5458 M (CONTROL_PING, mp_ping);
5466 api_sw_interface_set_flags (vat_main_t * vam)
5468 unformat_input_t *i = vam->input;
5469 vl_api_sw_interface_set_flags_t *mp;
5471 u8 sw_if_index_set = 0;
5472 u8 admin_up = 0, link_up = 0;
5475 /* Parse args required to build the message */
5476 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5478 if (unformat (i, "admin-up"))
5480 else if (unformat (i, "admin-down"))
5482 else if (unformat (i, "link-up"))
5484 else if (unformat (i, "link-down"))
5487 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5488 sw_if_index_set = 1;
5489 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5490 sw_if_index_set = 1;
5495 if (sw_if_index_set == 0)
5497 errmsg ("missing interface name or sw_if_index");
5501 /* Construct the API message */
5502 M (SW_INTERFACE_SET_FLAGS, mp);
5503 mp->sw_if_index = ntohl (sw_if_index);
5504 mp->admin_up_down = admin_up;
5505 mp->link_up_down = link_up;
5510 /* Wait for a reply, return the good/bad news... */
5516 api_sw_interface_clear_stats (vat_main_t * vam)
5518 unformat_input_t *i = vam->input;
5519 vl_api_sw_interface_clear_stats_t *mp;
5521 u8 sw_if_index_set = 0;
5524 /* Parse args required to build the message */
5525 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5527 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5528 sw_if_index_set = 1;
5529 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5530 sw_if_index_set = 1;
5535 /* Construct the API message */
5536 M (SW_INTERFACE_CLEAR_STATS, mp);
5538 if (sw_if_index_set == 1)
5539 mp->sw_if_index = ntohl (sw_if_index);
5541 mp->sw_if_index = ~0;
5546 /* Wait for a reply, return the good/bad news... */
5552 api_sw_interface_add_del_address (vat_main_t * vam)
5554 unformat_input_t *i = vam->input;
5555 vl_api_sw_interface_add_del_address_t *mp;
5557 u8 sw_if_index_set = 0;
5558 u8 is_add = 1, del_all = 0;
5559 u32 address_length = 0;
5560 u8 v4_address_set = 0;
5561 u8 v6_address_set = 0;
5562 ip4_address_t v4address;
5563 ip6_address_t v6address;
5566 /* Parse args required to build the message */
5567 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5569 if (unformat (i, "del-all"))
5571 else if (unformat (i, "del"))
5574 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5575 sw_if_index_set = 1;
5576 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5577 sw_if_index_set = 1;
5578 else if (unformat (i, "%U/%d",
5579 unformat_ip4_address, &v4address, &address_length))
5581 else if (unformat (i, "%U/%d",
5582 unformat_ip6_address, &v6address, &address_length))
5588 if (sw_if_index_set == 0)
5590 errmsg ("missing interface name or sw_if_index");
5593 if (v4_address_set && v6_address_set)
5595 errmsg ("both v4 and v6 addresses set");
5598 if (!v4_address_set && !v6_address_set && !del_all)
5600 errmsg ("no addresses set");
5604 /* Construct the API message */
5605 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5607 mp->sw_if_index = ntohl (sw_if_index);
5608 mp->is_add = is_add;
5609 mp->del_all = del_all;
5613 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5617 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5619 mp->address_length = address_length;
5624 /* Wait for a reply, return good/bad news */
5630 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5632 unformat_input_t *i = vam->input;
5633 vl_api_sw_interface_set_mpls_enable_t *mp;
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, "disable"))
5648 else if (unformat (i, "dis"))
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_MPLS_ENABLE, mp);
5663 mp->sw_if_index = ntohl (sw_if_index);
5664 mp->enable = enable;
5669 /* Wait for a reply... */
5675 api_sw_interface_set_table (vat_main_t * vam)
5677 unformat_input_t *i = vam->input;
5678 vl_api_sw_interface_set_table_t *mp;
5679 u32 sw_if_index, vrf_id = 0;
5680 u8 sw_if_index_set = 0;
5684 /* Parse args required to build the message */
5685 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5687 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5688 sw_if_index_set = 1;
5689 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5690 sw_if_index_set = 1;
5691 else if (unformat (i, "vrf %d", &vrf_id))
5693 else if (unformat (i, "ipv6"))
5699 if (sw_if_index_set == 0)
5701 errmsg ("missing interface name or sw_if_index");
5705 /* Construct the API message */
5706 M (SW_INTERFACE_SET_TABLE, mp);
5708 mp->sw_if_index = ntohl (sw_if_index);
5709 mp->is_ipv6 = is_ipv6;
5710 mp->vrf_id = ntohl (vrf_id);
5715 /* Wait for a reply... */
5720 static void vl_api_sw_interface_get_table_reply_t_handler
5721 (vl_api_sw_interface_get_table_reply_t * mp)
5723 vat_main_t *vam = &vat_main;
5725 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5727 vam->retval = ntohl (mp->retval);
5728 vam->result_ready = 1;
5732 static void vl_api_sw_interface_get_table_reply_t_handler_json
5733 (vl_api_sw_interface_get_table_reply_t * mp)
5735 vat_main_t *vam = &vat_main;
5736 vat_json_node_t node;
5738 vat_json_init_object (&node);
5739 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5740 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5742 vat_json_print (vam->ofp, &node);
5743 vat_json_free (&node);
5745 vam->retval = ntohl (mp->retval);
5746 vam->result_ready = 1;
5750 api_sw_interface_get_table (vat_main_t * vam)
5752 unformat_input_t *i = vam->input;
5753 vl_api_sw_interface_get_table_t *mp;
5755 u8 sw_if_index_set = 0;
5759 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5761 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5762 sw_if_index_set = 1;
5763 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5764 sw_if_index_set = 1;
5765 else if (unformat (i, "ipv6"))
5771 if (sw_if_index_set == 0)
5773 errmsg ("missing interface name or sw_if_index");
5777 M (SW_INTERFACE_GET_TABLE, mp);
5778 mp->sw_if_index = htonl (sw_if_index);
5779 mp->is_ipv6 = is_ipv6;
5787 api_sw_interface_set_vpath (vat_main_t * vam)
5789 unformat_input_t *i = vam->input;
5790 vl_api_sw_interface_set_vpath_t *mp;
5791 u32 sw_if_index = 0;
5792 u8 sw_if_index_set = 0;
5796 /* Parse args required to build the message */
5797 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5799 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5800 sw_if_index_set = 1;
5801 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5802 sw_if_index_set = 1;
5803 else if (unformat (i, "enable"))
5805 else if (unformat (i, "disable"))
5811 if (sw_if_index_set == 0)
5813 errmsg ("missing interface name or sw_if_index");
5817 /* Construct the API message */
5818 M (SW_INTERFACE_SET_VPATH, mp);
5820 mp->sw_if_index = ntohl (sw_if_index);
5821 mp->enable = is_enable;
5826 /* Wait for a reply... */
5832 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5834 unformat_input_t *i = vam->input;
5835 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5836 u32 sw_if_index = 0;
5837 u8 sw_if_index_set = 0;
5842 /* Parse args required to build the message */
5843 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5845 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5846 sw_if_index_set = 1;
5847 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5848 sw_if_index_set = 1;
5849 else if (unformat (i, "enable"))
5851 else if (unformat (i, "disable"))
5853 else if (unformat (i, "ip4"))
5855 else if (unformat (i, "ip6"))
5861 if (sw_if_index_set == 0)
5863 errmsg ("missing interface name or sw_if_index");
5867 /* Construct the API message */
5868 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5870 mp->sw_if_index = ntohl (sw_if_index);
5871 mp->enable = is_enable;
5872 mp->is_ipv6 = is_ipv6;
5877 /* Wait for a reply... */
5883 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5885 unformat_input_t *i = vam->input;
5886 vl_api_sw_interface_set_l2_xconnect_t *mp;
5888 u8 rx_sw_if_index_set = 0;
5890 u8 tx_sw_if_index_set = 0;
5894 /* Parse args required to build the message */
5895 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5897 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5898 rx_sw_if_index_set = 1;
5899 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5900 tx_sw_if_index_set = 1;
5901 else if (unformat (i, "rx"))
5903 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5905 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5907 rx_sw_if_index_set = 1;
5912 else if (unformat (i, "tx"))
5914 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5916 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5918 tx_sw_if_index_set = 1;
5923 else if (unformat (i, "enable"))
5925 else if (unformat (i, "disable"))
5931 if (rx_sw_if_index_set == 0)
5933 errmsg ("missing rx interface name or rx_sw_if_index");
5937 if (enable && (tx_sw_if_index_set == 0))
5939 errmsg ("missing tx interface name or tx_sw_if_index");
5943 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5945 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5946 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5947 mp->enable = enable;
5955 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5957 unformat_input_t *i = vam->input;
5958 vl_api_sw_interface_set_l2_bridge_t *mp;
5960 u8 rx_sw_if_index_set = 0;
5968 /* Parse args required to build the message */
5969 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5971 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5972 rx_sw_if_index_set = 1;
5973 else if (unformat (i, "bd_id %d", &bd_id))
5977 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5978 rx_sw_if_index_set = 1;
5979 else if (unformat (i, "shg %d", &shg))
5981 else if (unformat (i, "bvi"))
5983 else if (unformat (i, "enable"))
5985 else if (unformat (i, "disable"))
5991 if (rx_sw_if_index_set == 0)
5993 errmsg ("missing rx interface name or sw_if_index");
5997 if (enable && (bd_id_set == 0))
5999 errmsg ("missing bridge domain");
6003 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6005 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6006 mp->bd_id = ntohl (bd_id);
6009 mp->enable = enable;
6017 api_bridge_domain_dump (vat_main_t * vam)
6019 unformat_input_t *i = vam->input;
6020 vl_api_bridge_domain_dump_t *mp;
6021 vl_api_control_ping_t *mp_ping;
6025 /* Parse args required to build the message */
6026 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6028 if (unformat (i, "bd_id %d", &bd_id))
6034 M (BRIDGE_DOMAIN_DUMP, mp);
6035 mp->bd_id = ntohl (bd_id);
6038 /* Use a control ping for synchronization */
6039 M (CONTROL_PING, mp_ping);
6047 api_bridge_domain_add_del (vat_main_t * vam)
6049 unformat_input_t *i = vam->input;
6050 vl_api_bridge_domain_add_del_t *mp;
6053 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6057 /* Parse args required to build the message */
6058 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6060 if (unformat (i, "bd_id %d", &bd_id))
6062 else if (unformat (i, "flood %d", &flood))
6064 else if (unformat (i, "uu-flood %d", &uu_flood))
6066 else if (unformat (i, "forward %d", &forward))
6068 else if (unformat (i, "learn %d", &learn))
6070 else if (unformat (i, "arp-term %d", &arp_term))
6072 else if (unformat (i, "mac-age %d", &mac_age))
6074 else if (unformat (i, "del"))
6077 flood = uu_flood = forward = learn = 0;
6085 errmsg ("missing bridge domain");
6091 errmsg ("mac age must be less than 256 ");
6095 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6097 mp->bd_id = ntohl (bd_id);
6099 mp->uu_flood = uu_flood;
6100 mp->forward = forward;
6102 mp->arp_term = arp_term;
6103 mp->is_add = is_add;
6104 mp->mac_age = (u8) mac_age;
6112 api_l2fib_flush_bd (vat_main_t * vam)
6114 unformat_input_t *i = vam->input;
6115 vl_api_l2fib_flush_bd_t *mp;
6119 /* Parse args required to build the message */
6120 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6122 if (unformat (i, "bd_id %d", &bd_id));
6129 errmsg ("missing bridge domain");
6133 M (L2FIB_FLUSH_BD, mp);
6135 mp->bd_id = htonl (bd_id);
6143 api_l2fib_flush_int (vat_main_t * vam)
6145 unformat_input_t *i = vam->input;
6146 vl_api_l2fib_flush_int_t *mp;
6147 u32 sw_if_index = ~0;
6150 /* Parse args required to build the message */
6151 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6153 if (unformat (i, "sw_if_index %d", &sw_if_index));
6155 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6160 if (sw_if_index == ~0)
6162 errmsg ("missing interface name or sw_if_index");
6166 M (L2FIB_FLUSH_INT, mp);
6168 mp->sw_if_index = ntohl (sw_if_index);
6176 api_l2fib_add_del (vat_main_t * vam)
6178 unformat_input_t *i = vam->input;
6179 vl_api_l2fib_add_del_t *mp;
6185 u32 sw_if_index = ~0;
6186 u8 sw_if_index_set = 0;
6195 /* Parse args required to build the message */
6196 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6198 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6200 else if (unformat (i, "bd_id %d", &bd_id))
6202 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6203 sw_if_index_set = 1;
6204 else if (unformat (i, "sw_if"))
6206 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6209 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6210 sw_if_index_set = 1;
6215 else if (unformat (i, "static"))
6217 else if (unformat (i, "filter"))
6222 else if (unformat (i, "bvi"))
6227 else if (unformat (i, "del"))
6229 else if (unformat (i, "count %d", &count))
6237 errmsg ("missing mac address");
6243 errmsg ("missing bridge domain");
6247 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6249 errmsg ("missing interface name or sw_if_index");
6255 /* Turn on async mode */
6256 vam->async_mode = 1;
6257 vam->async_errors = 0;
6258 before = vat_time_now (vam);
6261 for (j = 0; j < count; j++)
6263 M (L2FIB_ADD_DEL, mp);
6266 mp->bd_id = ntohl (bd_id);
6267 mp->is_add = is_add;
6271 mp->sw_if_index = ntohl (sw_if_index);
6272 mp->static_mac = static_mac;
6273 mp->filter_mac = filter_mac;
6274 mp->bvi_mac = bvi_mac;
6276 increment_mac_address (&mac);
6283 vl_api_control_ping_t *mp_ping;
6286 /* Shut off async mode */
6287 vam->async_mode = 0;
6289 M (CONTROL_PING, mp_ping);
6292 timeout = vat_time_now (vam) + 1.0;
6293 while (vat_time_now (vam) < timeout)
6294 if (vam->result_ready == 1)
6299 if (vam->retval == -99)
6302 if (vam->async_errors > 0)
6304 errmsg ("%d asynchronous errors", vam->async_errors);
6307 vam->async_errors = 0;
6308 after = vat_time_now (vam);
6310 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6311 count, after - before, count / (after - before));
6317 /* Wait for a reply... */
6321 /* Return the good/bad news */
6322 return (vam->retval);
6326 api_bridge_domain_set_mac_age (vat_main_t * vam)
6328 unformat_input_t *i = vam->input;
6329 vl_api_bridge_domain_set_mac_age_t *mp;
6334 /* Parse args required to build the message */
6335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6337 if (unformat (i, "bd_id %d", &bd_id));
6338 else if (unformat (i, "mac-age %d", &mac_age));
6345 errmsg ("missing bridge domain");
6351 errmsg ("mac age must be less than 256 ");
6355 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6357 mp->bd_id = htonl (bd_id);
6358 mp->mac_age = (u8) mac_age;
6366 api_l2_flags (vat_main_t * vam)
6368 unformat_input_t *i = vam->input;
6369 vl_api_l2_flags_t *mp;
6371 u32 feature_bitmap = 0;
6372 u8 sw_if_index_set = 0;
6375 /* Parse args required to build the message */
6376 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6378 if (unformat (i, "sw_if_index %d", &sw_if_index))
6379 sw_if_index_set = 1;
6380 else if (unformat (i, "sw_if"))
6382 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6385 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6386 sw_if_index_set = 1;
6391 else if (unformat (i, "learn"))
6392 feature_bitmap |= L2INPUT_FEAT_LEARN;
6393 else if (unformat (i, "forward"))
6394 feature_bitmap |= L2INPUT_FEAT_FWD;
6395 else if (unformat (i, "flood"))
6396 feature_bitmap |= L2INPUT_FEAT_FLOOD;
6397 else if (unformat (i, "uu-flood"))
6398 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
6403 if (sw_if_index_set == 0)
6405 errmsg ("missing interface name or sw_if_index");
6411 mp->sw_if_index = ntohl (sw_if_index);
6412 mp->feature_bitmap = ntohl (feature_bitmap);
6420 api_bridge_flags (vat_main_t * vam)
6422 unformat_input_t *i = vam->input;
6423 vl_api_bridge_flags_t *mp;
6430 /* Parse args required to build the message */
6431 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6433 if (unformat (i, "bd_id %d", &bd_id))
6435 else if (unformat (i, "learn"))
6437 else if (unformat (i, "forward"))
6439 else if (unformat (i, "flood"))
6441 else if (unformat (i, "uu-flood"))
6442 flags |= L2_UU_FLOOD;
6443 else if (unformat (i, "arp-term"))
6444 flags |= L2_ARP_TERM;
6445 else if (unformat (i, "off"))
6447 else if (unformat (i, "disable"))
6455 errmsg ("missing bridge domain");
6459 M (BRIDGE_FLAGS, mp);
6461 mp->bd_id = ntohl (bd_id);
6462 mp->feature_bitmap = ntohl (flags);
6463 mp->is_set = is_set;
6471 api_bd_ip_mac_add_del (vat_main_t * vam)
6473 unformat_input_t *i = vam->input;
6474 vl_api_bd_ip_mac_add_del_t *mp;
6481 ip4_address_t v4addr;
6482 ip6_address_t v6addr;
6487 /* Parse args required to build the message */
6488 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6490 if (unformat (i, "bd_id %d", &bd_id))
6494 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6498 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6503 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6507 else if (unformat (i, "del"))
6515 errmsg ("missing bridge domain");
6518 else if (ip_set == 0)
6520 errmsg ("missing IP address");
6523 else if (mac_set == 0)
6525 errmsg ("missing MAC address");
6529 M (BD_IP_MAC_ADD_DEL, mp);
6531 mp->bd_id = ntohl (bd_id);
6532 mp->is_ipv6 = is_ipv6;
6533 mp->is_add = is_add;
6535 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6537 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6538 clib_memcpy (mp->mac_address, macaddr, 6);
6545 api_tap_connect (vat_main_t * vam)
6547 unformat_input_t *i = vam->input;
6548 vl_api_tap_connect_t *mp;
6554 ip4_address_t ip4_address;
6556 int ip4_address_set = 0;
6557 ip6_address_t ip6_address;
6559 int ip6_address_set = 0;
6562 memset (mac_address, 0, sizeof (mac_address));
6564 /* Parse args required to build the message */
6565 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6567 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6571 else if (unformat (i, "random-mac"))
6573 else if (unformat (i, "tapname %s", &tap_name))
6575 else if (unformat (i, "tag %s", &tag))
6577 else if (unformat (i, "address %U/%d",
6578 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6579 ip4_address_set = 1;
6580 else if (unformat (i, "address %U/%d",
6581 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6582 ip6_address_set = 1;
6589 errmsg ("missing tap name");
6592 if (vec_len (tap_name) > 63)
6594 errmsg ("tap name too long");
6597 vec_add1 (tap_name, 0);
6599 if (vec_len (tag) > 63)
6601 errmsg ("tag too long");
6605 /* Construct the API message */
6606 M (TAP_CONNECT, mp);
6608 mp->use_random_mac = random_mac;
6609 clib_memcpy (mp->mac_address, mac_address, 6);
6610 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6612 clib_memcpy (mp->tag, tag, vec_len (tag));
6614 if (ip4_address_set)
6616 mp->ip4_address_set = 1;
6617 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6618 mp->ip4_mask_width = ip4_mask_width;
6620 if (ip6_address_set)
6622 mp->ip6_address_set = 1;
6623 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6624 mp->ip6_mask_width = ip6_mask_width;
6627 vec_free (tap_name);
6633 /* Wait for a reply... */
6639 api_tap_modify (vat_main_t * vam)
6641 unformat_input_t *i = vam->input;
6642 vl_api_tap_modify_t *mp;
6647 u32 sw_if_index = ~0;
6648 u8 sw_if_index_set = 0;
6651 memset (mac_address, 0, sizeof (mac_address));
6653 /* Parse args required to build the message */
6654 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6656 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6657 sw_if_index_set = 1;
6658 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6659 sw_if_index_set = 1;
6660 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6664 else if (unformat (i, "random-mac"))
6666 else if (unformat (i, "tapname %s", &tap_name))
6672 if (sw_if_index_set == 0)
6674 errmsg ("missing vpp interface name");
6679 errmsg ("missing tap name");
6682 if (vec_len (tap_name) > 63)
6684 errmsg ("tap name too long");
6686 vec_add1 (tap_name, 0);
6688 /* Construct the API message */
6691 mp->use_random_mac = random_mac;
6692 mp->sw_if_index = ntohl (sw_if_index);
6693 clib_memcpy (mp->mac_address, mac_address, 6);
6694 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6695 vec_free (tap_name);
6700 /* Wait for a reply... */
6706 api_tap_delete (vat_main_t * vam)
6708 unformat_input_t *i = vam->input;
6709 vl_api_tap_delete_t *mp;
6710 u32 sw_if_index = ~0;
6711 u8 sw_if_index_set = 0;
6714 /* Parse args required to build the message */
6715 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6717 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6718 sw_if_index_set = 1;
6719 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6720 sw_if_index_set = 1;
6725 if (sw_if_index_set == 0)
6727 errmsg ("missing vpp interface name");
6731 /* Construct the API message */
6734 mp->sw_if_index = ntohl (sw_if_index);
6739 /* Wait for a reply... */
6745 api_ip_add_del_route (vat_main_t * vam)
6747 unformat_input_t *i = vam->input;
6748 vl_api_ip_add_del_route_t *mp;
6749 u32 sw_if_index = ~0, vrf_id = 0;
6751 u8 is_local = 0, is_drop = 0;
6752 u8 is_unreach = 0, is_prohibit = 0;
6753 u8 create_vrf_if_needed = 0;
6755 u32 next_hop_weight = 1;
6757 u8 is_multipath = 0;
6759 u8 address_length_set = 0;
6760 u32 next_hop_table_id = 0;
6761 u32 resolve_attempts = 0;
6762 u32 dst_address_length = 0;
6763 u8 next_hop_set = 0;
6764 ip4_address_t v4_dst_address, v4_next_hop_address;
6765 ip6_address_t v6_dst_address, v6_next_hop_address;
6769 u32 random_add_del = 0;
6770 u32 *random_vector = 0;
6772 u32 random_seed = 0xdeaddabe;
6773 u32 classify_table_index = ~0;
6775 u8 resolve_host = 0, resolve_attached = 0;
6776 mpls_label_t *next_hop_out_label_stack = NULL;
6777 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6778 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6780 /* Parse args required to build the message */
6781 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6783 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6785 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6787 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6792 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6797 else if (unformat (i, "/%d", &dst_address_length))
6799 address_length_set = 1;
6802 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6803 &v4_next_hop_address))
6807 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6808 &v6_next_hop_address))
6812 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6814 else if (unformat (i, "weight %d", &next_hop_weight))
6816 else if (unformat (i, "drop"))
6820 else if (unformat (i, "null-send-unreach"))
6824 else if (unformat (i, "null-send-prohibit"))
6828 else if (unformat (i, "local"))
6832 else if (unformat (i, "classify %d", &classify_table_index))
6836 else if (unformat (i, "del"))
6838 else if (unformat (i, "add"))
6840 else if (unformat (i, "not-last"))
6842 else if (unformat (i, "resolve-via-host"))
6844 else if (unformat (i, "resolve-via-attached"))
6845 resolve_attached = 1;
6846 else if (unformat (i, "multipath"))
6848 else if (unformat (i, "vrf %d", &vrf_id))
6850 else if (unformat (i, "create-vrf"))
6851 create_vrf_if_needed = 1;
6852 else if (unformat (i, "count %d", &count))
6854 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6856 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6858 else if (unformat (i, "out-label %d", &next_hop_out_label))
6859 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6860 else if (unformat (i, "via-label %d", &next_hop_via_label))
6862 else if (unformat (i, "random"))
6864 else if (unformat (i, "seed %d", &random_seed))
6868 clib_warning ("parse error '%U'", format_unformat_error, i);
6873 if (!next_hop_set && !is_drop && !is_local &&
6874 !is_classify && !is_unreach && !is_prohibit &&
6875 MPLS_LABEL_INVALID == next_hop_via_label)
6878 ("next hop / local / drop / unreach / prohibit / classify not set");
6882 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6884 errmsg ("next hop and next-hop via label set");
6887 if (address_set == 0)
6889 errmsg ("missing addresses");
6893 if (address_length_set == 0)
6895 errmsg ("missing address length");
6899 /* Generate a pile of unique, random routes */
6902 u32 this_random_address;
6903 random_hash = hash_create (count, sizeof (uword));
6905 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6906 for (j = 0; j <= count; j++)
6910 this_random_address = random_u32 (&random_seed);
6911 this_random_address =
6912 clib_host_to_net_u32 (this_random_address);
6914 while (hash_get (random_hash, this_random_address));
6915 vec_add1 (random_vector, this_random_address);
6916 hash_set (random_hash, this_random_address, 1);
6918 hash_free (random_hash);
6919 v4_dst_address.as_u32 = random_vector[0];
6924 /* Turn on async mode */
6925 vam->async_mode = 1;
6926 vam->async_errors = 0;
6927 before = vat_time_now (vam);
6930 for (j = 0; j < count; j++)
6932 /* Construct the API message */
6933 M2 (IP_ADD_DEL_ROUTE, mp,
6934 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6936 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6937 mp->table_id = ntohl (vrf_id);
6938 mp->create_vrf_if_needed = create_vrf_if_needed;
6940 mp->is_add = is_add;
6941 mp->is_drop = is_drop;
6942 mp->is_unreach = is_unreach;
6943 mp->is_prohibit = is_prohibit;
6944 mp->is_ipv6 = is_ipv6;
6945 mp->is_local = is_local;
6946 mp->is_classify = is_classify;
6947 mp->is_multipath = is_multipath;
6948 mp->is_resolve_host = resolve_host;
6949 mp->is_resolve_attached = resolve_attached;
6950 mp->not_last = not_last;
6951 mp->next_hop_weight = next_hop_weight;
6952 mp->dst_address_length = dst_address_length;
6953 mp->next_hop_table_id = ntohl (next_hop_table_id);
6954 mp->classify_table_index = ntohl (classify_table_index);
6955 mp->next_hop_via_label = ntohl (next_hop_via_label);
6956 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6957 if (0 != mp->next_hop_n_out_labels)
6959 memcpy (mp->next_hop_out_label_stack,
6960 next_hop_out_label_stack,
6961 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6962 vec_free (next_hop_out_label_stack);
6967 clib_memcpy (mp->dst_address, &v6_dst_address,
6968 sizeof (v6_dst_address));
6970 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6971 sizeof (v6_next_hop_address));
6972 increment_v6_address (&v6_dst_address);
6976 clib_memcpy (mp->dst_address, &v4_dst_address,
6977 sizeof (v4_dst_address));
6979 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6980 sizeof (v4_next_hop_address));
6982 v4_dst_address.as_u32 = random_vector[j + 1];
6984 increment_v4_address (&v4_dst_address);
6988 /* If we receive SIGTERM, stop now... */
6993 /* When testing multiple add/del ops, use a control-ping to sync */
6996 vl_api_control_ping_t *mp_ping;
7000 /* Shut off async mode */
7001 vam->async_mode = 0;
7003 M (CONTROL_PING, mp_ping);
7006 timeout = vat_time_now (vam) + 1.0;
7007 while (vat_time_now (vam) < timeout)
7008 if (vam->result_ready == 1)
7013 if (vam->retval == -99)
7016 if (vam->async_errors > 0)
7018 errmsg ("%d asynchronous errors", vam->async_errors);
7021 vam->async_errors = 0;
7022 after = vat_time_now (vam);
7024 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7028 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7029 count, after - before, count / (after - before));
7035 /* Wait for a reply... */
7040 /* Return the good/bad news */
7041 return (vam->retval);
7045 api_ip_mroute_add_del (vat_main_t * vam)
7047 unformat_input_t *i = vam->input;
7048 vl_api_ip_mroute_add_del_t *mp;
7049 u32 sw_if_index = ~0, vrf_id = 0;
7052 u8 create_vrf_if_needed = 0;
7055 u32 grp_address_length = 0;
7056 ip4_address_t v4_grp_address, v4_src_address;
7057 ip6_address_t v6_grp_address, v6_src_address;
7058 mfib_itf_flags_t iflags = 0;
7059 mfib_entry_flags_t eflags = 0;
7062 /* Parse args required to build the message */
7063 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7065 if (unformat (i, "sw_if_index %d", &sw_if_index))
7067 else if (unformat (i, "%U %U",
7068 unformat_ip4_address, &v4_src_address,
7069 unformat_ip4_address, &v4_grp_address))
7071 grp_address_length = 64;
7075 else if (unformat (i, "%U %U",
7076 unformat_ip6_address, &v6_src_address,
7077 unformat_ip6_address, &v6_grp_address))
7079 grp_address_length = 256;
7083 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7085 memset (&v4_src_address, 0, sizeof (v4_src_address));
7086 grp_address_length = 32;
7090 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7092 memset (&v6_src_address, 0, sizeof (v6_src_address));
7093 grp_address_length = 128;
7097 else if (unformat (i, "/%d", &grp_address_length))
7099 else if (unformat (i, "local"))
7103 else if (unformat (i, "del"))
7105 else if (unformat (i, "add"))
7107 else if (unformat (i, "vrf %d", &vrf_id))
7109 else if (unformat (i, "create-vrf"))
7110 create_vrf_if_needed = 1;
7111 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7113 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7117 clib_warning ("parse error '%U'", format_unformat_error, i);
7122 if (address_set == 0)
7124 errmsg ("missing addresses\n");
7128 /* Construct the API message */
7129 M (IP_MROUTE_ADD_DEL, mp);
7131 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7132 mp->table_id = ntohl (vrf_id);
7133 mp->create_vrf_if_needed = create_vrf_if_needed;
7135 mp->is_add = is_add;
7136 mp->is_ipv6 = is_ipv6;
7137 mp->is_local = is_local;
7138 mp->itf_flags = ntohl (iflags);
7139 mp->entry_flags = ntohl (eflags);
7140 mp->grp_address_length = grp_address_length;
7141 mp->grp_address_length = ntohs (mp->grp_address_length);
7145 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7146 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7150 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7151 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7157 /* Wait for a reply... */
7163 api_mpls_route_add_del (vat_main_t * vam)
7165 unformat_input_t *i = vam->input;
7166 vl_api_mpls_route_add_del_t *mp;
7167 u32 sw_if_index = ~0, table_id = 0;
7168 u8 create_table_if_needed = 0;
7170 u32 next_hop_weight = 1;
7171 u8 is_multipath = 0;
7172 u32 next_hop_table_id = 0;
7173 u8 next_hop_set = 0;
7174 ip4_address_t v4_next_hop_address = {
7177 ip6_address_t v6_next_hop_address = { {0} };
7181 u32 classify_table_index = ~0;
7183 u8 resolve_host = 0, resolve_attached = 0;
7184 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7185 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7186 mpls_label_t *next_hop_out_label_stack = NULL;
7187 mpls_label_t local_label = MPLS_LABEL_INVALID;
7189 u8 next_hop_proto_is_ip4 = 1;
7191 /* Parse args required to build the message */
7192 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7194 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7196 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7198 else if (unformat (i, "%d", &local_label))
7200 else if (unformat (i, "eos"))
7202 else if (unformat (i, "non-eos"))
7204 else if (unformat (i, "via %U", unformat_ip4_address,
7205 &v4_next_hop_address))
7208 next_hop_proto_is_ip4 = 1;
7210 else if (unformat (i, "via %U", unformat_ip6_address,
7211 &v6_next_hop_address))
7214 next_hop_proto_is_ip4 = 0;
7216 else if (unformat (i, "weight %d", &next_hop_weight))
7218 else if (unformat (i, "create-table"))
7219 create_table_if_needed = 1;
7220 else if (unformat (i, "classify %d", &classify_table_index))
7224 else if (unformat (i, "del"))
7226 else if (unformat (i, "add"))
7228 else if (unformat (i, "resolve-via-host"))
7230 else if (unformat (i, "resolve-via-attached"))
7231 resolve_attached = 1;
7232 else if (unformat (i, "multipath"))
7234 else if (unformat (i, "count %d", &count))
7236 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
7239 next_hop_proto_is_ip4 = 1;
7241 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
7244 next_hop_proto_is_ip4 = 0;
7246 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7248 else if (unformat (i, "via-label %d", &next_hop_via_label))
7250 else if (unformat (i, "out-label %d", &next_hop_out_label))
7251 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7254 clib_warning ("parse error '%U'", format_unformat_error, i);
7259 if (!next_hop_set && !is_classify)
7261 errmsg ("next hop / classify not set");
7265 if (MPLS_LABEL_INVALID == local_label)
7267 errmsg ("missing label");
7273 /* Turn on async mode */
7274 vam->async_mode = 1;
7275 vam->async_errors = 0;
7276 before = vat_time_now (vam);
7279 for (j = 0; j < count; j++)
7281 /* Construct the API message */
7282 M2 (MPLS_ROUTE_ADD_DEL, mp,
7283 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7285 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
7286 mp->mr_table_id = ntohl (table_id);
7287 mp->mr_create_table_if_needed = create_table_if_needed;
7289 mp->mr_is_add = is_add;
7290 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7291 mp->mr_is_classify = is_classify;
7292 mp->mr_is_multipath = is_multipath;
7293 mp->mr_is_resolve_host = resolve_host;
7294 mp->mr_is_resolve_attached = resolve_attached;
7295 mp->mr_next_hop_weight = next_hop_weight;
7296 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
7297 mp->mr_classify_table_index = ntohl (classify_table_index);
7298 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
7299 mp->mr_label = ntohl (local_label);
7300 mp->mr_eos = is_eos;
7302 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7303 if (0 != mp->mr_next_hop_n_out_labels)
7305 memcpy (mp->mr_next_hop_out_label_stack,
7306 next_hop_out_label_stack,
7307 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7308 vec_free (next_hop_out_label_stack);
7313 if (next_hop_proto_is_ip4)
7315 clib_memcpy (mp->mr_next_hop,
7316 &v4_next_hop_address,
7317 sizeof (v4_next_hop_address));
7321 clib_memcpy (mp->mr_next_hop,
7322 &v6_next_hop_address,
7323 sizeof (v6_next_hop_address));
7330 /* If we receive SIGTERM, stop now... */
7335 /* When testing multiple add/del ops, use a control-ping to sync */
7338 vl_api_control_ping_t *mp_ping;
7342 /* Shut off async mode */
7343 vam->async_mode = 0;
7345 M (CONTROL_PING, mp_ping);
7348 timeout = vat_time_now (vam) + 1.0;
7349 while (vat_time_now (vam) < timeout)
7350 if (vam->result_ready == 1)
7355 if (vam->retval == -99)
7358 if (vam->async_errors > 0)
7360 errmsg ("%d asynchronous errors", vam->async_errors);
7363 vam->async_errors = 0;
7364 after = vat_time_now (vam);
7366 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7370 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7371 count, after - before, count / (after - before));
7377 /* Wait for a reply... */
7382 /* Return the good/bad news */
7383 return (vam->retval);
7387 api_mpls_ip_bind_unbind (vat_main_t * vam)
7389 unformat_input_t *i = vam->input;
7390 vl_api_mpls_ip_bind_unbind_t *mp;
7391 u32 ip_table_id = 0;
7392 u8 create_table_if_needed = 0;
7395 ip4_address_t v4_address;
7396 ip6_address_t v6_address;
7399 mpls_label_t local_label = MPLS_LABEL_INVALID;
7402 /* Parse args required to build the message */
7403 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7405 if (unformat (i, "%U/%d", unformat_ip4_address,
7406 &v4_address, &address_length))
7411 else if (unformat (i, "%U/%d", unformat_ip6_address,
7412 &v6_address, &address_length))
7417 else if (unformat (i, "%d", &local_label))
7419 else if (unformat (i, "create-table"))
7420 create_table_if_needed = 1;
7421 else if (unformat (i, "table-id %d", &ip_table_id))
7423 else if (unformat (i, "unbind"))
7425 else if (unformat (i, "bind"))
7429 clib_warning ("parse error '%U'", format_unformat_error, i);
7436 errmsg ("IP addres not set");
7440 if (MPLS_LABEL_INVALID == local_label)
7442 errmsg ("missing label");
7446 /* Construct the API message */
7447 M (MPLS_IP_BIND_UNBIND, mp);
7449 mp->mb_create_table_if_needed = create_table_if_needed;
7450 mp->mb_is_bind = is_bind;
7451 mp->mb_is_ip4 = is_ip4;
7452 mp->mb_ip_table_id = ntohl (ip_table_id);
7453 mp->mb_mpls_table_id = 0;
7454 mp->mb_label = ntohl (local_label);
7455 mp->mb_address_length = address_length;
7458 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7460 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7465 /* Wait for a reply... */
7471 api_proxy_arp_add_del (vat_main_t * vam)
7473 unformat_input_t *i = vam->input;
7474 vl_api_proxy_arp_add_del_t *mp;
7477 ip4_address_t lo, hi;
7481 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7483 if (unformat (i, "vrf %d", &vrf_id))
7485 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7486 unformat_ip4_address, &hi))
7488 else if (unformat (i, "del"))
7492 clib_warning ("parse error '%U'", format_unformat_error, i);
7499 errmsg ("address range not set");
7503 M (PROXY_ARP_ADD_DEL, mp);
7505 mp->vrf_id = ntohl (vrf_id);
7506 mp->is_add = is_add;
7507 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7508 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7516 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7518 unformat_input_t *i = vam->input;
7519 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7522 u8 sw_if_index_set = 0;
7525 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7527 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7528 sw_if_index_set = 1;
7529 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7530 sw_if_index_set = 1;
7531 else if (unformat (i, "enable"))
7533 else if (unformat (i, "disable"))
7537 clib_warning ("parse error '%U'", format_unformat_error, i);
7542 if (sw_if_index_set == 0)
7544 errmsg ("missing interface name or sw_if_index");
7548 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7550 mp->sw_if_index = ntohl (sw_if_index);
7551 mp->enable_disable = enable;
7559 api_mpls_tunnel_add_del (vat_main_t * vam)
7561 unformat_input_t *i = vam->input;
7562 vl_api_mpls_tunnel_add_del_t *mp;
7566 u32 sw_if_index = ~0;
7567 u32 next_hop_sw_if_index = ~0;
7568 u32 next_hop_proto_is_ip4 = 1;
7570 u32 next_hop_table_id = 0;
7571 ip4_address_t v4_next_hop_address = {
7574 ip6_address_t v6_next_hop_address = { {0} };
7575 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7578 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7580 if (unformat (i, "add"))
7582 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7584 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7586 else if (unformat (i, "via %U",
7587 unformat_ip4_address, &v4_next_hop_address))
7589 next_hop_proto_is_ip4 = 1;
7591 else if (unformat (i, "via %U",
7592 unformat_ip6_address, &v6_next_hop_address))
7594 next_hop_proto_is_ip4 = 0;
7596 else if (unformat (i, "l2-only"))
7598 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7600 else if (unformat (i, "out-label %d", &next_hop_out_label))
7601 vec_add1 (labels, ntohl (next_hop_out_label));
7604 clib_warning ("parse error '%U'", format_unformat_error, i);
7609 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7611 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7612 mp->mt_sw_if_index = ntohl (sw_if_index);
7613 mp->mt_is_add = is_add;
7614 mp->mt_l2_only = l2_only;
7615 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7616 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7618 mp->mt_next_hop_n_out_labels = vec_len (labels);
7620 if (0 != mp->mt_next_hop_n_out_labels)
7622 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7623 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7627 if (next_hop_proto_is_ip4)
7629 clib_memcpy (mp->mt_next_hop,
7630 &v4_next_hop_address, sizeof (v4_next_hop_address));
7634 clib_memcpy (mp->mt_next_hop,
7635 &v6_next_hop_address, sizeof (v6_next_hop_address));
7644 api_sw_interface_set_unnumbered (vat_main_t * vam)
7646 unformat_input_t *i = vam->input;
7647 vl_api_sw_interface_set_unnumbered_t *mp;
7649 u32 unnum_sw_index = ~0;
7651 u8 sw_if_index_set = 0;
7654 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7656 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7657 sw_if_index_set = 1;
7658 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7659 sw_if_index_set = 1;
7660 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7662 else if (unformat (i, "del"))
7666 clib_warning ("parse error '%U'", format_unformat_error, i);
7671 if (sw_if_index_set == 0)
7673 errmsg ("missing interface name or sw_if_index");
7677 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7679 mp->sw_if_index = ntohl (sw_if_index);
7680 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7681 mp->is_add = is_add;
7689 api_ip_neighbor_add_del (vat_main_t * vam)
7691 unformat_input_t *i = vam->input;
7692 vl_api_ip_neighbor_add_del_t *mp;
7694 u8 sw_if_index_set = 0;
7697 u8 is_no_fib_entry = 0;
7700 u8 v4_address_set = 0;
7701 u8 v6_address_set = 0;
7702 ip4_address_t v4address;
7703 ip6_address_t v6address;
7706 memset (mac_address, 0, sizeof (mac_address));
7708 /* Parse args required to build the message */
7709 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7711 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7715 else if (unformat (i, "del"))
7718 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7719 sw_if_index_set = 1;
7720 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7721 sw_if_index_set = 1;
7722 else if (unformat (i, "is_static"))
7724 else if (unformat (i, "no-fib-entry"))
7725 is_no_fib_entry = 1;
7726 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7728 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7732 clib_warning ("parse error '%U'", format_unformat_error, i);
7737 if (sw_if_index_set == 0)
7739 errmsg ("missing interface name or sw_if_index");
7742 if (v4_address_set && v6_address_set)
7744 errmsg ("both v4 and v6 addresses set");
7747 if (!v4_address_set && !v6_address_set)
7749 errmsg ("no address set");
7753 /* Construct the API message */
7754 M (IP_NEIGHBOR_ADD_DEL, mp);
7756 mp->sw_if_index = ntohl (sw_if_index);
7757 mp->is_add = is_add;
7758 mp->is_static = is_static;
7759 mp->is_no_adj_fib = is_no_fib_entry;
7761 clib_memcpy (mp->mac_address, mac_address, 6);
7765 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7769 /* mp->is_ipv6 = 0; via memset in M macro above */
7770 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7776 /* Wait for a reply, return good/bad news */
7782 api_reset_vrf (vat_main_t * vam)
7784 unformat_input_t *i = vam->input;
7785 vl_api_reset_vrf_t *mp;
7791 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7793 if (unformat (i, "vrf %d", &vrf_id))
7795 else if (unformat (i, "ipv6"))
7799 clib_warning ("parse error '%U'", format_unformat_error, i);
7804 if (vrf_id_set == 0)
7806 errmsg ("missing vrf id");
7812 mp->vrf_id = ntohl (vrf_id);
7813 mp->is_ipv6 = is_ipv6;
7821 api_create_vlan_subif (vat_main_t * vam)
7823 unformat_input_t *i = vam->input;
7824 vl_api_create_vlan_subif_t *mp;
7826 u8 sw_if_index_set = 0;
7831 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7833 if (unformat (i, "sw_if_index %d", &sw_if_index))
7834 sw_if_index_set = 1;
7836 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7837 sw_if_index_set = 1;
7838 else if (unformat (i, "vlan %d", &vlan_id))
7842 clib_warning ("parse error '%U'", format_unformat_error, i);
7847 if (sw_if_index_set == 0)
7849 errmsg ("missing interface name or sw_if_index");
7853 if (vlan_id_set == 0)
7855 errmsg ("missing vlan_id");
7858 M (CREATE_VLAN_SUBIF, mp);
7860 mp->sw_if_index = ntohl (sw_if_index);
7861 mp->vlan_id = ntohl (vlan_id);
7868 #define foreach_create_subif_bit \
7875 _(outer_vlan_id_any) \
7876 _(inner_vlan_id_any)
7879 api_create_subif (vat_main_t * vam)
7881 unformat_input_t *i = vam->input;
7882 vl_api_create_subif_t *mp;
7884 u8 sw_if_index_set = 0;
7891 u32 exact_match = 0;
7892 u32 default_sub = 0;
7893 u32 outer_vlan_id_any = 0;
7894 u32 inner_vlan_id_any = 0;
7896 u16 outer_vlan_id = 0;
7897 u16 inner_vlan_id = 0;
7900 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7902 if (unformat (i, "sw_if_index %d", &sw_if_index))
7903 sw_if_index_set = 1;
7905 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7906 sw_if_index_set = 1;
7907 else if (unformat (i, "sub_id %d", &sub_id))
7909 else if (unformat (i, "outer_vlan_id %d", &tmp))
7910 outer_vlan_id = tmp;
7911 else if (unformat (i, "inner_vlan_id %d", &tmp))
7912 inner_vlan_id = tmp;
7914 #define _(a) else if (unformat (i, #a)) a = 1 ;
7915 foreach_create_subif_bit
7919 clib_warning ("parse error '%U'", format_unformat_error, i);
7924 if (sw_if_index_set == 0)
7926 errmsg ("missing interface name or sw_if_index");
7930 if (sub_id_set == 0)
7932 errmsg ("missing sub_id");
7935 M (CREATE_SUBIF, mp);
7937 mp->sw_if_index = ntohl (sw_if_index);
7938 mp->sub_id = ntohl (sub_id);
7940 #define _(a) mp->a = a;
7941 foreach_create_subif_bit;
7944 mp->outer_vlan_id = ntohs (outer_vlan_id);
7945 mp->inner_vlan_id = ntohs (inner_vlan_id);
7953 api_oam_add_del (vat_main_t * vam)
7955 unformat_input_t *i = vam->input;
7956 vl_api_oam_add_del_t *mp;
7959 ip4_address_t src, dst;
7964 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7966 if (unformat (i, "vrf %d", &vrf_id))
7968 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7970 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7972 else if (unformat (i, "del"))
7976 clib_warning ("parse error '%U'", format_unformat_error, i);
7983 errmsg ("missing src addr");
7989 errmsg ("missing dst addr");
7993 M (OAM_ADD_DEL, mp);
7995 mp->vrf_id = ntohl (vrf_id);
7996 mp->is_add = is_add;
7997 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7998 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8006 api_reset_fib (vat_main_t * vam)
8008 unformat_input_t *i = vam->input;
8009 vl_api_reset_fib_t *mp;
8015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8017 if (unformat (i, "vrf %d", &vrf_id))
8019 else if (unformat (i, "ipv6"))
8023 clib_warning ("parse error '%U'", format_unformat_error, i);
8028 if (vrf_id_set == 0)
8030 errmsg ("missing vrf id");
8036 mp->vrf_id = ntohl (vrf_id);
8037 mp->is_ipv6 = is_ipv6;
8045 api_dhcp_proxy_config (vat_main_t * vam)
8047 unformat_input_t *i = vam->input;
8048 vl_api_dhcp_proxy_config_t *mp;
8050 u32 server_vrf_id = 0;
8052 u8 v4_address_set = 0;
8053 u8 v6_address_set = 0;
8054 ip4_address_t v4address;
8055 ip6_address_t v6address;
8056 u8 v4_src_address_set = 0;
8057 u8 v6_src_address_set = 0;
8058 ip4_address_t v4srcaddress;
8059 ip6_address_t v6srcaddress;
8062 /* Parse args required to build the message */
8063 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8065 if (unformat (i, "del"))
8067 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8069 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8071 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8073 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8075 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8076 v4_src_address_set = 1;
8077 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8078 v6_src_address_set = 1;
8083 if (v4_address_set && v6_address_set)
8085 errmsg ("both v4 and v6 server addresses set");
8088 if (!v4_address_set && !v6_address_set)
8090 errmsg ("no server addresses set");
8094 if (v4_src_address_set && v6_src_address_set)
8096 errmsg ("both v4 and v6 src addresses set");
8099 if (!v4_src_address_set && !v6_src_address_set)
8101 errmsg ("no src addresses set");
8105 if (!(v4_src_address_set && v4_address_set) &&
8106 !(v6_src_address_set && v6_address_set))
8108 errmsg ("no matching server and src addresses set");
8112 /* Construct the API message */
8113 M (DHCP_PROXY_CONFIG, mp);
8115 mp->is_add = is_add;
8116 mp->rx_vrf_id = ntohl (rx_vrf_id);
8117 mp->server_vrf_id = ntohl (server_vrf_id);
8121 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
8122 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
8126 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
8127 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
8133 /* Wait for a reply, return good/bad news */
8138 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
8139 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
8142 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
8144 vat_main_t *vam = &vat_main;
8145 u32 i, count = mp->count;
8146 vl_api_dhcp_server_t *s;
8150 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8151 ntohl (mp->rx_vrf_id),
8152 format_ip6_address, mp->dhcp_src_address,
8153 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8156 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8157 ntohl (mp->rx_vrf_id),
8158 format_ip4_address, mp->dhcp_src_address,
8159 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8161 for (i = 0; i < count; i++)
8163 s = &mp->servers[i];
8167 " Server Table-ID %d, Server Address %U",
8168 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
8171 " Server Table-ID %d, Server Address %U",
8172 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
8176 static void vl_api_dhcp_proxy_details_t_handler_json
8177 (vl_api_dhcp_proxy_details_t * mp)
8179 vat_main_t *vam = &vat_main;
8180 vat_json_node_t *node = NULL;
8181 u32 i, count = mp->count;
8183 struct in6_addr ip6;
8184 vl_api_dhcp_server_t *s;
8186 if (VAT_JSON_ARRAY != vam->json_tree.type)
8188 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8189 vat_json_init_array (&vam->json_tree);
8191 node = vat_json_array_add (&vam->json_tree);
8193 vat_json_init_object (node);
8194 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
8195 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
8196 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
8200 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
8201 vat_json_object_add_ip6 (node, "src_address", ip6);
8205 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
8206 vat_json_object_add_ip4 (node, "src_address", ip4);
8209 for (i = 0; i < count; i++)
8211 s = &mp->servers[i];
8213 vat_json_object_add_uint (node, "server-table-id",
8214 ntohl (s->server_vrf_id));
8218 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
8219 vat_json_object_add_ip4 (node, "src_address", ip4);
8223 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
8224 vat_json_object_add_ip6 (node, "server_address", ip6);
8230 api_dhcp_proxy_dump (vat_main_t * vam)
8232 unformat_input_t *i = vam->input;
8233 vl_api_control_ping_t *mp_ping;
8234 vl_api_dhcp_proxy_dump_t *mp;
8238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8240 if (unformat (i, "ipv6"))
8244 clib_warning ("parse error '%U'", format_unformat_error, i);
8249 M (DHCP_PROXY_DUMP, mp);
8251 mp->is_ip6 = is_ipv6;
8254 /* Use a control ping for synchronization */
8255 M (CONTROL_PING, mp_ping);
8263 api_dhcp_proxy_set_vss (vat_main_t * vam)
8265 unformat_input_t *i = vam->input;
8266 vl_api_dhcp_proxy_set_vss_t *mp;
8277 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8279 if (unformat (i, "tbl_id %d", &tbl_id))
8281 if (unformat (i, "fib_id %d", &fib_id))
8283 if (unformat (i, "oui %d", &oui))
8285 else if (unformat (i, "ipv6"))
8287 else if (unformat (i, "del"))
8291 clib_warning ("parse error '%U'", format_unformat_error, i);
8296 if (tbl_id_set == 0)
8298 errmsg ("missing tbl id");
8302 if (fib_id_set == 0)
8304 errmsg ("missing fib id");
8309 errmsg ("missing oui");
8313 M (DHCP_PROXY_SET_VSS, mp);
8314 mp->tbl_id = ntohl (tbl_id);
8315 mp->fib_id = ntohl (fib_id);
8316 mp->oui = ntohl (oui);
8317 mp->is_ipv6 = is_ipv6;
8318 mp->is_add = is_add;
8326 api_dhcp_client_config (vat_main_t * vam)
8328 unformat_input_t *i = vam->input;
8329 vl_api_dhcp_client_config_t *mp;
8331 u8 sw_if_index_set = 0;
8334 u8 disable_event = 0;
8337 /* Parse args required to build the message */
8338 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8340 if (unformat (i, "del"))
8343 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8344 sw_if_index_set = 1;
8345 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8346 sw_if_index_set = 1;
8347 else if (unformat (i, "hostname %s", &hostname))
8349 else if (unformat (i, "disable_event"))
8355 if (sw_if_index_set == 0)
8357 errmsg ("missing interface name or sw_if_index");
8361 if (vec_len (hostname) > 63)
8363 errmsg ("hostname too long");
8365 vec_add1 (hostname, 0);
8367 /* Construct the API message */
8368 M (DHCP_CLIENT_CONFIG, mp);
8370 mp->sw_if_index = htonl (sw_if_index);
8371 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
8372 vec_free (hostname);
8373 mp->is_add = is_add;
8374 mp->want_dhcp_event = disable_event ? 0 : 1;
8375 mp->pid = htonl (getpid ());
8380 /* Wait for a reply, return good/bad news */
8386 api_set_ip_flow_hash (vat_main_t * vam)
8388 unformat_input_t *i = vam->input;
8389 vl_api_set_ip_flow_hash_t *mp;
8401 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8403 if (unformat (i, "vrf %d", &vrf_id))
8405 else if (unformat (i, "ipv6"))
8407 else if (unformat (i, "src"))
8409 else if (unformat (i, "dst"))
8411 else if (unformat (i, "sport"))
8413 else if (unformat (i, "dport"))
8415 else if (unformat (i, "proto"))
8417 else if (unformat (i, "reverse"))
8422 clib_warning ("parse error '%U'", format_unformat_error, i);
8427 if (vrf_id_set == 0)
8429 errmsg ("missing vrf id");
8433 M (SET_IP_FLOW_HASH, mp);
8439 mp->reverse = reverse;
8440 mp->vrf_id = ntohl (vrf_id);
8441 mp->is_ipv6 = is_ipv6;
8449 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8451 unformat_input_t *i = vam->input;
8452 vl_api_sw_interface_ip6_enable_disable_t *mp;
8454 u8 sw_if_index_set = 0;
8458 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8460 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8461 sw_if_index_set = 1;
8462 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8463 sw_if_index_set = 1;
8464 else if (unformat (i, "enable"))
8466 else if (unformat (i, "disable"))
8470 clib_warning ("parse error '%U'", format_unformat_error, i);
8475 if (sw_if_index_set == 0)
8477 errmsg ("missing interface name or sw_if_index");
8481 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8483 mp->sw_if_index = ntohl (sw_if_index);
8484 mp->enable = enable;
8492 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8494 unformat_input_t *i = vam->input;
8495 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8497 u8 sw_if_index_set = 0;
8498 u8 v6_address_set = 0;
8499 ip6_address_t v6address;
8502 /* Parse args required to build the message */
8503 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8505 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8506 sw_if_index_set = 1;
8507 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8508 sw_if_index_set = 1;
8509 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8515 if (sw_if_index_set == 0)
8517 errmsg ("missing interface name or sw_if_index");
8520 if (!v6_address_set)
8522 errmsg ("no address set");
8526 /* Construct the API message */
8527 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8529 mp->sw_if_index = ntohl (sw_if_index);
8530 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8535 /* Wait for a reply, return good/bad news */
8541 api_ip6nd_proxy_add_del (vat_main_t * vam)
8543 unformat_input_t *i = vam->input;
8544 vl_api_ip6nd_proxy_add_del_t *mp;
8545 u32 sw_if_index = ~0;
8546 u8 v6_address_set = 0;
8547 ip6_address_t v6address;
8551 /* Parse args required to build the message */
8552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8554 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8556 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8558 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8560 if (unformat (i, "del"))
8564 clib_warning ("parse error '%U'", format_unformat_error, i);
8569 if (sw_if_index == ~0)
8571 errmsg ("missing interface name or sw_if_index");
8574 if (!v6_address_set)
8576 errmsg ("no address set");
8580 /* Construct the API message */
8581 M (IP6ND_PROXY_ADD_DEL, mp);
8583 mp->is_del = is_del;
8584 mp->sw_if_index = ntohl (sw_if_index);
8585 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8590 /* Wait for a reply, return good/bad news */
8596 api_ip6nd_proxy_dump (vat_main_t * vam)
8598 vl_api_ip6nd_proxy_dump_t *mp;
8599 vl_api_control_ping_t *mp_ping;
8602 M (IP6ND_PROXY_DUMP, mp);
8606 /* Use a control ping for synchronization */
8607 M (CONTROL_PING, mp_ping);
8614 static void vl_api_ip6nd_proxy_details_t_handler
8615 (vl_api_ip6nd_proxy_details_t * mp)
8617 vat_main_t *vam = &vat_main;
8619 print (vam->ofp, "host %U sw_if_index %d",
8620 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
8623 static void vl_api_ip6nd_proxy_details_t_handler_json
8624 (vl_api_ip6nd_proxy_details_t * mp)
8626 vat_main_t *vam = &vat_main;
8627 struct in6_addr ip6;
8628 vat_json_node_t *node = NULL;
8630 if (VAT_JSON_ARRAY != vam->json_tree.type)
8632 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8633 vat_json_init_array (&vam->json_tree);
8635 node = vat_json_array_add (&vam->json_tree);
8637 vat_json_init_object (node);
8638 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
8640 clib_memcpy (&ip6, mp->address, sizeof (ip6));
8641 vat_json_object_add_ip6 (node, "host", ip6);
8645 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8647 unformat_input_t *i = vam->input;
8648 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8650 u8 sw_if_index_set = 0;
8651 u32 address_length = 0;
8652 u8 v6_address_set = 0;
8653 ip6_address_t v6address;
8655 u8 no_advertise = 0;
8657 u8 no_autoconfig = 0;
8660 u32 val_lifetime = 0;
8661 u32 pref_lifetime = 0;
8664 /* Parse args required to build the message */
8665 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8667 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8668 sw_if_index_set = 1;
8669 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8670 sw_if_index_set = 1;
8671 else if (unformat (i, "%U/%d",
8672 unformat_ip6_address, &v6address, &address_length))
8674 else if (unformat (i, "val_life %d", &val_lifetime))
8676 else if (unformat (i, "pref_life %d", &pref_lifetime))
8678 else if (unformat (i, "def"))
8680 else if (unformat (i, "noadv"))
8682 else if (unformat (i, "offl"))
8684 else if (unformat (i, "noauto"))
8686 else if (unformat (i, "nolink"))
8688 else if (unformat (i, "isno"))
8692 clib_warning ("parse error '%U'", format_unformat_error, i);
8697 if (sw_if_index_set == 0)
8699 errmsg ("missing interface name or sw_if_index");
8702 if (!v6_address_set)
8704 errmsg ("no address set");
8708 /* Construct the API message */
8709 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8711 mp->sw_if_index = ntohl (sw_if_index);
8712 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8713 mp->address_length = address_length;
8714 mp->use_default = use_default;
8715 mp->no_advertise = no_advertise;
8716 mp->off_link = off_link;
8717 mp->no_autoconfig = no_autoconfig;
8718 mp->no_onlink = no_onlink;
8720 mp->val_lifetime = ntohl (val_lifetime);
8721 mp->pref_lifetime = ntohl (pref_lifetime);
8726 /* Wait for a reply, return good/bad news */
8732 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8734 unformat_input_t *i = vam->input;
8735 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8737 u8 sw_if_index_set = 0;
8742 u8 send_unicast = 0;
8745 u8 default_router = 0;
8746 u32 max_interval = 0;
8747 u32 min_interval = 0;
8749 u32 initial_count = 0;
8750 u32 initial_interval = 0;
8754 /* Parse args required to build the message */
8755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8757 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8758 sw_if_index_set = 1;
8759 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8760 sw_if_index_set = 1;
8761 else if (unformat (i, "maxint %d", &max_interval))
8763 else if (unformat (i, "minint %d", &min_interval))
8765 else if (unformat (i, "life %d", &lifetime))
8767 else if (unformat (i, "count %d", &initial_count))
8769 else if (unformat (i, "interval %d", &initial_interval))
8771 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8773 else if (unformat (i, "managed"))
8775 else if (unformat (i, "other"))
8777 else if (unformat (i, "ll"))
8779 else if (unformat (i, "send"))
8781 else if (unformat (i, "cease"))
8783 else if (unformat (i, "isno"))
8785 else if (unformat (i, "def"))
8789 clib_warning ("parse error '%U'", format_unformat_error, i);
8794 if (sw_if_index_set == 0)
8796 errmsg ("missing interface name or sw_if_index");
8800 /* Construct the API message */
8801 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8803 mp->sw_if_index = ntohl (sw_if_index);
8804 mp->max_interval = ntohl (max_interval);
8805 mp->min_interval = ntohl (min_interval);
8806 mp->lifetime = ntohl (lifetime);
8807 mp->initial_count = ntohl (initial_count);
8808 mp->initial_interval = ntohl (initial_interval);
8809 mp->suppress = suppress;
8810 mp->managed = managed;
8812 mp->ll_option = ll_option;
8813 mp->send_unicast = send_unicast;
8816 mp->default_router = default_router;
8821 /* Wait for a reply, return good/bad news */
8827 api_set_arp_neighbor_limit (vat_main_t * vam)
8829 unformat_input_t *i = vam->input;
8830 vl_api_set_arp_neighbor_limit_t *mp;
8836 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8838 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8840 else if (unformat (i, "ipv6"))
8844 clib_warning ("parse error '%U'", format_unformat_error, i);
8851 errmsg ("missing limit value");
8855 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8857 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8858 mp->is_ipv6 = is_ipv6;
8866 api_l2_patch_add_del (vat_main_t * vam)
8868 unformat_input_t *i = vam->input;
8869 vl_api_l2_patch_add_del_t *mp;
8871 u8 rx_sw_if_index_set = 0;
8873 u8 tx_sw_if_index_set = 0;
8877 /* Parse args required to build the message */
8878 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8880 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8881 rx_sw_if_index_set = 1;
8882 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8883 tx_sw_if_index_set = 1;
8884 else if (unformat (i, "rx"))
8886 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8888 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8890 rx_sw_if_index_set = 1;
8895 else if (unformat (i, "tx"))
8897 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8899 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8901 tx_sw_if_index_set = 1;
8906 else if (unformat (i, "del"))
8912 if (rx_sw_if_index_set == 0)
8914 errmsg ("missing rx interface name or rx_sw_if_index");
8918 if (tx_sw_if_index_set == 0)
8920 errmsg ("missing tx interface name or tx_sw_if_index");
8924 M (L2_PATCH_ADD_DEL, mp);
8926 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8927 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8928 mp->is_add = is_add;
8936 u8 localsid_addr[16];
8945 api_sr_localsid_add_del (vat_main_t * vam)
8947 unformat_input_t *i = vam->input;
8948 vl_api_sr_localsid_add_del_t *mp;
8951 ip6_address_t localsid;
8955 u32 fib_table = ~(u32) 0;
8956 ip6_address_t next_hop;
8958 bool nexthop_set = 0;
8962 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8964 if (unformat (i, "del"))
8966 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
8967 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
8969 else if (unformat (i, "behavior %u", &behavior));
8970 else if (unformat (i, "sw_if_index %u", &sw_if_index));
8971 else if (unformat (i, "fib-table %u", &fib_table));
8972 else if (unformat (i, "end.psp %u", &behavior));
8977 M (SR_LOCALSID_ADD_DEL, mp);
8979 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
8981 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
8982 mp->behavior = behavior;
8983 mp->sw_if_index = ntohl (sw_if_index);
8984 mp->fib_table = ntohl (fib_table);
8985 mp->end_psp = end_psp;
8986 mp->is_del = is_del;
8994 api_ioam_enable (vat_main_t * vam)
8996 unformat_input_t *input = vam->input;
8997 vl_api_ioam_enable_t *mp;
8999 int has_trace_option = 0;
9000 int has_pot_option = 0;
9001 int has_seqno_option = 0;
9002 int has_analyse_option = 0;
9005 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9007 if (unformat (input, "trace"))
9008 has_trace_option = 1;
9009 else if (unformat (input, "pot"))
9011 else if (unformat (input, "seqno"))
9012 has_seqno_option = 1;
9013 else if (unformat (input, "analyse"))
9014 has_analyse_option = 1;
9018 M (IOAM_ENABLE, mp);
9019 mp->id = htons (id);
9020 mp->seqno = has_seqno_option;
9021 mp->analyse = has_analyse_option;
9022 mp->pot_enable = has_pot_option;
9023 mp->trace_enable = has_trace_option;
9032 api_ioam_disable (vat_main_t * vam)
9034 vl_api_ioam_disable_t *mp;
9037 M (IOAM_DISABLE, mp);
9043 #define foreach_tcp_proto_field \
9047 #define foreach_udp_proto_field \
9051 #define foreach_ip4_proto_field \
9063 u16 src_port, dst_port;
9066 #if VPP_API_TEST_BUILTIN == 0
9068 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9070 u8 **maskp = va_arg (*args, u8 **);
9072 u8 found_something = 0;
9075 #define _(a) u8 a=0;
9076 foreach_tcp_proto_field;
9079 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9082 #define _(a) else if (unformat (input, #a)) a=1;
9083 foreach_tcp_proto_field
9089 #define _(a) found_something += a;
9090 foreach_tcp_proto_field;
9093 if (found_something == 0)
9096 vec_validate (mask, sizeof (*tcp) - 1);
9098 tcp = (tcp_header_t *) mask;
9100 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9101 foreach_tcp_proto_field;
9109 unformat_udp_mask (unformat_input_t * input, va_list * args)
9111 u8 **maskp = va_arg (*args, u8 **);
9113 u8 found_something = 0;
9116 #define _(a) u8 a=0;
9117 foreach_udp_proto_field;
9120 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9123 #define _(a) else if (unformat (input, #a)) a=1;
9124 foreach_udp_proto_field
9130 #define _(a) found_something += a;
9131 foreach_udp_proto_field;
9134 if (found_something == 0)
9137 vec_validate (mask, sizeof (*udp) - 1);
9139 udp = (udp_header_t *) mask;
9141 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
9142 foreach_udp_proto_field;
9150 unformat_l4_mask (unformat_input_t * input, va_list * args)
9152 u8 **maskp = va_arg (*args, u8 **);
9153 u16 src_port = 0, dst_port = 0;
9154 tcpudp_header_t *tcpudp;
9156 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9158 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9160 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9162 else if (unformat (input, "src_port"))
9164 else if (unformat (input, "dst_port"))
9170 if (!src_port && !dst_port)
9174 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9176 tcpudp = (tcpudp_header_t *) mask;
9177 tcpudp->src_port = src_port;
9178 tcpudp->dst_port = dst_port;
9186 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9188 u8 **maskp = va_arg (*args, u8 **);
9190 u8 found_something = 0;
9193 #define _(a) u8 a=0;
9194 foreach_ip4_proto_field;
9200 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9202 if (unformat (input, "version"))
9204 else if (unformat (input, "hdr_length"))
9206 else if (unformat (input, "src"))
9208 else if (unformat (input, "dst"))
9210 else if (unformat (input, "proto"))
9213 #define _(a) else if (unformat (input, #a)) a=1;
9214 foreach_ip4_proto_field
9220 #define _(a) found_something += a;
9221 foreach_ip4_proto_field;
9224 if (found_something == 0)
9227 vec_validate (mask, sizeof (*ip) - 1);
9229 ip = (ip4_header_t *) mask;
9231 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9232 foreach_ip4_proto_field;
9235 ip->ip_version_and_header_length = 0;
9238 ip->ip_version_and_header_length |= 0xF0;
9241 ip->ip_version_and_header_length |= 0x0F;
9247 #define foreach_ip6_proto_field \
9255 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9257 u8 **maskp = va_arg (*args, u8 **);
9259 u8 found_something = 0;
9261 u32 ip_version_traffic_class_and_flow_label;
9263 #define _(a) u8 a=0;
9264 foreach_ip6_proto_field;
9267 u8 traffic_class = 0;
9270 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9272 if (unformat (input, "version"))
9274 else if (unformat (input, "traffic-class"))
9276 else if (unformat (input, "flow-label"))
9278 else if (unformat (input, "src"))
9280 else if (unformat (input, "dst"))
9282 else if (unformat (input, "proto"))
9285 #define _(a) else if (unformat (input, #a)) a=1;
9286 foreach_ip6_proto_field
9292 #define _(a) found_something += a;
9293 foreach_ip6_proto_field;
9296 if (found_something == 0)
9299 vec_validate (mask, sizeof (*ip) - 1);
9301 ip = (ip6_header_t *) mask;
9303 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9304 foreach_ip6_proto_field;
9307 ip_version_traffic_class_and_flow_label = 0;
9310 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9313 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9316 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9318 ip->ip_version_traffic_class_and_flow_label =
9319 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9326 unformat_l3_mask (unformat_input_t * input, va_list * args)
9328 u8 **maskp = va_arg (*args, u8 **);
9330 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9332 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9334 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9343 unformat_l2_mask (unformat_input_t * input, va_list * args)
9345 u8 **maskp = va_arg (*args, u8 **);
9360 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9362 if (unformat (input, "src"))
9364 else if (unformat (input, "dst"))
9366 else if (unformat (input, "proto"))
9368 else if (unformat (input, "tag1"))
9370 else if (unformat (input, "tag2"))
9372 else if (unformat (input, "ignore-tag1"))
9374 else if (unformat (input, "ignore-tag2"))
9376 else if (unformat (input, "cos1"))
9378 else if (unformat (input, "cos2"))
9380 else if (unformat (input, "dot1q"))
9382 else if (unformat (input, "dot1ad"))
9387 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9388 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9391 if (tag1 || ignore_tag1 || cos1 || dot1q)
9393 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9396 vec_validate (mask, len - 1);
9399 memset (mask, 0xff, 6);
9402 memset (mask + 6, 0xff, 6);
9406 /* inner vlan tag */
9415 mask[21] = mask[20] = 0xff;
9436 mask[16] = mask[17] = 0xff;
9446 mask[12] = mask[13] = 0xff;
9453 unformat_classify_mask (unformat_input_t * input, va_list * args)
9455 u8 **maskp = va_arg (*args, u8 **);
9456 u32 *skipp = va_arg (*args, u32 *);
9457 u32 *matchp = va_arg (*args, u32 *);
9465 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9467 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9469 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9471 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9473 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9487 if (mask || l2 || l3 || l4)
9491 /* "With a free Ethernet header in every package" */
9493 vec_validate (l2, 13);
9497 vec_append (mask, l3);
9502 vec_append (mask, l4);
9507 /* Scan forward looking for the first significant mask octet */
9508 for (i = 0; i < vec_len (mask); i++)
9512 /* compute (skip, match) params */
9513 *skipp = i / sizeof (u32x4);
9514 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9516 /* Pad mask to an even multiple of the vector size */
9517 while (vec_len (mask) % sizeof (u32x4))
9520 match = vec_len (mask) / sizeof (u32x4);
9522 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9524 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9525 if (*tmp || *(tmp + 1))
9530 clib_warning ("BUG: match 0");
9532 _vec_len (mask) = match * sizeof (u32x4);
9542 #endif /* VPP_API_TEST_BUILTIN */
9544 #define foreach_l2_next \
9546 _(ethernet, ETHERNET_INPUT) \
9551 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9553 u32 *miss_next_indexp = va_arg (*args, u32 *);
9558 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9562 if (unformat (input, "%d", &tmp))
9571 *miss_next_indexp = next_index;
9575 #define foreach_ip_next \
9581 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9583 u32 *miss_next_indexp = va_arg (*args, u32 *);
9588 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9592 if (unformat (input, "%d", &tmp))
9601 *miss_next_indexp = next_index;
9605 #define foreach_acl_next \
9609 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9611 u32 *miss_next_indexp = va_arg (*args, u32 *);
9616 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9620 if (unformat (input, "permit"))
9625 else if (unformat (input, "%d", &tmp))
9634 *miss_next_indexp = next_index;
9639 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9641 u32 *r = va_arg (*args, u32 *);
9643 if (unformat (input, "conform-color"))
9644 *r = POLICE_CONFORM;
9645 else if (unformat (input, "exceed-color"))
9654 api_classify_add_del_table (vat_main_t * vam)
9656 unformat_input_t *i = vam->input;
9657 vl_api_classify_add_del_table_t *mp;
9664 u32 table_index = ~0;
9665 u32 next_table_index = ~0;
9666 u32 miss_next_index = ~0;
9667 u32 memory_size = 32 << 20;
9669 u32 current_data_flag = 0;
9670 int current_data_offset = 0;
9673 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9675 if (unformat (i, "del"))
9677 else if (unformat (i, "del-chain"))
9682 else if (unformat (i, "buckets %d", &nbuckets))
9684 else if (unformat (i, "memory_size %d", &memory_size))
9686 else if (unformat (i, "skip %d", &skip))
9688 else if (unformat (i, "match %d", &match))
9690 else if (unformat (i, "table %d", &table_index))
9692 else if (unformat (i, "mask %U", unformat_classify_mask,
9693 &mask, &skip, &match))
9695 else if (unformat (i, "next-table %d", &next_table_index))
9697 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9700 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9703 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9706 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9708 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9714 if (is_add && mask == 0)
9716 errmsg ("Mask required");
9720 if (is_add && skip == ~0)
9722 errmsg ("skip count required");
9726 if (is_add && match == ~0)
9728 errmsg ("match count required");
9732 if (!is_add && table_index == ~0)
9734 errmsg ("table index required for delete");
9738 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9740 mp->is_add = is_add;
9741 mp->del_chain = del_chain;
9742 mp->table_index = ntohl (table_index);
9743 mp->nbuckets = ntohl (nbuckets);
9744 mp->memory_size = ntohl (memory_size);
9745 mp->skip_n_vectors = ntohl (skip);
9746 mp->match_n_vectors = ntohl (match);
9747 mp->next_table_index = ntohl (next_table_index);
9748 mp->miss_next_index = ntohl (miss_next_index);
9749 mp->current_data_flag = ntohl (current_data_flag);
9750 mp->current_data_offset = ntohl (current_data_offset);
9751 clib_memcpy (mp->mask, mask, vec_len (mask));
9760 #if VPP_API_TEST_BUILTIN == 0
9762 unformat_l4_match (unformat_input_t * input, va_list * args)
9764 u8 **matchp = va_arg (*args, u8 **);
9766 u8 *proto_header = 0;
9772 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9774 if (unformat (input, "src_port %d", &src_port))
9776 else if (unformat (input, "dst_port %d", &dst_port))
9782 h.src_port = clib_host_to_net_u16 (src_port);
9783 h.dst_port = clib_host_to_net_u16 (dst_port);
9784 vec_validate (proto_header, sizeof (h) - 1);
9785 memcpy (proto_header, &h, sizeof (h));
9787 *matchp = proto_header;
9793 unformat_ip4_match (unformat_input_t * input, va_list * args)
9795 u8 **matchp = va_arg (*args, u8 **);
9802 int src = 0, dst = 0;
9803 ip4_address_t src_val, dst_val;
9810 int fragment_id = 0;
9811 u32 fragment_id_val;
9817 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9819 if (unformat (input, "version %d", &version_val))
9821 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9823 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9825 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9827 else if (unformat (input, "proto %d", &proto_val))
9829 else if (unformat (input, "tos %d", &tos_val))
9831 else if (unformat (input, "length %d", &length_val))
9833 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9835 else if (unformat (input, "ttl %d", &ttl_val))
9837 else if (unformat (input, "checksum %d", &checksum_val))
9843 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9844 + ttl + checksum == 0)
9848 * Aligned because we use the real comparison functions
9850 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9852 ip = (ip4_header_t *) match;
9854 /* These are realistically matched in practice */
9856 ip->src_address.as_u32 = src_val.as_u32;
9859 ip->dst_address.as_u32 = dst_val.as_u32;
9862 ip->protocol = proto_val;
9865 /* These are not, but they're included for completeness */
9867 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9870 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9876 ip->length = clib_host_to_net_u16 (length_val);
9882 ip->checksum = clib_host_to_net_u16 (checksum_val);
9889 unformat_ip6_match (unformat_input_t * input, va_list * args)
9891 u8 **matchp = va_arg (*args, u8 **);
9896 u8 traffic_class = 0;
9897 u32 traffic_class_val = 0;
9900 int src = 0, dst = 0;
9901 ip6_address_t src_val, dst_val;
9904 int payload_length = 0;
9905 u32 payload_length_val;
9908 u32 ip_version_traffic_class_and_flow_label;
9910 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9912 if (unformat (input, "version %d", &version_val))
9914 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9916 else if (unformat (input, "flow_label %d", &flow_label_val))
9918 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9920 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9922 else if (unformat (input, "proto %d", &proto_val))
9924 else if (unformat (input, "payload_length %d", &payload_length_val))
9926 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9932 if (version + traffic_class + flow_label + src + dst + proto +
9933 payload_length + hop_limit == 0)
9937 * Aligned because we use the real comparison functions
9939 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9941 ip = (ip6_header_t *) match;
9944 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9947 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9950 ip->protocol = proto_val;
9952 ip_version_traffic_class_and_flow_label = 0;
9955 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9958 ip_version_traffic_class_and_flow_label |=
9959 (traffic_class_val & 0xFF) << 20;
9962 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9964 ip->ip_version_traffic_class_and_flow_label =
9965 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9968 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9971 ip->hop_limit = hop_limit_val;
9978 unformat_l3_match (unformat_input_t * input, va_list * args)
9980 u8 **matchp = va_arg (*args, u8 **);
9982 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9984 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9986 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9995 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9997 u8 *tagp = va_arg (*args, u8 *);
10000 if (unformat (input, "%d", &tag))
10002 tagp[0] = (tag >> 8) & 0x0F;
10003 tagp[1] = tag & 0xFF;
10011 unformat_l2_match (unformat_input_t * input, va_list * args)
10013 u8 **matchp = va_arg (*args, u8 **);
10026 u8 ignore_tag1 = 0;
10027 u8 ignore_tag2 = 0;
10033 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10035 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10038 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10040 else if (unformat (input, "proto %U",
10041 unformat_ethernet_type_host_byte_order, &proto_val))
10043 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10045 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10047 else if (unformat (input, "ignore-tag1"))
10049 else if (unformat (input, "ignore-tag2"))
10051 else if (unformat (input, "cos1 %d", &cos1_val))
10053 else if (unformat (input, "cos2 %d", &cos2_val))
10058 if ((src + dst + proto + tag1 + tag2 +
10059 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10062 if (tag1 || ignore_tag1 || cos1)
10064 if (tag2 || ignore_tag2 || cos2)
10067 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10070 clib_memcpy (match, dst_val, 6);
10073 clib_memcpy (match + 6, src_val, 6);
10077 /* inner vlan tag */
10078 match[19] = tag2_val[1];
10079 match[18] = tag2_val[0];
10081 match[18] |= (cos2_val & 0x7) << 5;
10084 match[21] = proto_val & 0xff;
10085 match[20] = proto_val >> 8;
10089 match[15] = tag1_val[1];
10090 match[14] = tag1_val[0];
10093 match[14] |= (cos1_val & 0x7) << 5;
10099 match[15] = tag1_val[1];
10100 match[14] = tag1_val[0];
10103 match[17] = proto_val & 0xff;
10104 match[16] = proto_val >> 8;
10107 match[14] |= (cos1_val & 0x7) << 5;
10113 match[18] |= (cos2_val & 0x7) << 5;
10115 match[14] |= (cos1_val & 0x7) << 5;
10118 match[13] = proto_val & 0xff;
10119 match[12] = proto_val >> 8;
10128 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10130 u8 **matchp = va_arg (*args, u8 **);
10131 u32 skip_n_vectors = va_arg (*args, u32);
10132 u32 match_n_vectors = va_arg (*args, u32);
10139 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10141 if (unformat (input, "hex %U", unformat_hex_string, &match))
10143 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10145 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10147 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10161 if (match || l2 || l3 || l4)
10163 if (l2 || l3 || l4)
10165 /* "Win a free Ethernet header in every packet" */
10167 vec_validate_aligned (l2, 13, sizeof (u32x4));
10171 vec_append_aligned (match, l3, sizeof (u32x4));
10176 vec_append_aligned (match, l4, sizeof (u32x4));
10181 /* Make sure the vector is big enough even if key is all 0's */
10182 vec_validate_aligned
10183 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10186 /* Set size, include skipped vectors */
10187 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10198 api_classify_add_del_session (vat_main_t * vam)
10200 unformat_input_t *i = vam->input;
10201 vl_api_classify_add_del_session_t *mp;
10203 u32 table_index = ~0;
10204 u32 hit_next_index = ~0;
10205 u32 opaque_index = ~0;
10208 u32 skip_n_vectors = 0;
10209 u32 match_n_vectors = 0;
10215 * Warning: you have to supply skip_n and match_n
10216 * because the API client cant simply look at the classify
10220 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10222 if (unformat (i, "del"))
10224 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10227 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10230 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10233 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10235 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10237 else if (unformat (i, "opaque-index %d", &opaque_index))
10239 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10241 else if (unformat (i, "match_n %d", &match_n_vectors))
10243 else if (unformat (i, "match %U", api_unformat_classify_match,
10244 &match, skip_n_vectors, match_n_vectors))
10246 else if (unformat (i, "advance %d", &advance))
10248 else if (unformat (i, "table-index %d", &table_index))
10250 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10252 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10254 else if (unformat (i, "action %d", &action))
10256 else if (unformat (i, "metadata %d", &metadata))
10262 if (table_index == ~0)
10264 errmsg ("Table index required");
10268 if (is_add && match == 0)
10270 errmsg ("Match value required");
10274 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10276 mp->is_add = is_add;
10277 mp->table_index = ntohl (table_index);
10278 mp->hit_next_index = ntohl (hit_next_index);
10279 mp->opaque_index = ntohl (opaque_index);
10280 mp->advance = ntohl (advance);
10281 mp->action = action;
10282 mp->metadata = ntohl (metadata);
10283 clib_memcpy (mp->match, match, vec_len (match));
10292 api_classify_set_interface_ip_table (vat_main_t * vam)
10294 unformat_input_t *i = vam->input;
10295 vl_api_classify_set_interface_ip_table_t *mp;
10297 int sw_if_index_set;
10298 u32 table_index = ~0;
10302 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10304 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10305 sw_if_index_set = 1;
10306 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10307 sw_if_index_set = 1;
10308 else if (unformat (i, "table %d", &table_index))
10312 clib_warning ("parse error '%U'", format_unformat_error, i);
10317 if (sw_if_index_set == 0)
10319 errmsg ("missing interface name or sw_if_index");
10324 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10326 mp->sw_if_index = ntohl (sw_if_index);
10327 mp->table_index = ntohl (table_index);
10328 mp->is_ipv6 = is_ipv6;
10336 api_classify_set_interface_l2_tables (vat_main_t * vam)
10338 unformat_input_t *i = vam->input;
10339 vl_api_classify_set_interface_l2_tables_t *mp;
10341 int sw_if_index_set;
10342 u32 ip4_table_index = ~0;
10343 u32 ip6_table_index = ~0;
10344 u32 other_table_index = ~0;
10348 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10350 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10351 sw_if_index_set = 1;
10352 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10353 sw_if_index_set = 1;
10354 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10356 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10358 else if (unformat (i, "other-table %d", &other_table_index))
10360 else if (unformat (i, "is-input %d", &is_input))
10364 clib_warning ("parse error '%U'", format_unformat_error, i);
10369 if (sw_if_index_set == 0)
10371 errmsg ("missing interface name or sw_if_index");
10376 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10378 mp->sw_if_index = ntohl (sw_if_index);
10379 mp->ip4_table_index = ntohl (ip4_table_index);
10380 mp->ip6_table_index = ntohl (ip6_table_index);
10381 mp->other_table_index = ntohl (other_table_index);
10382 mp->is_input = (u8) is_input;
10390 api_set_ipfix_exporter (vat_main_t * vam)
10392 unformat_input_t *i = vam->input;
10393 vl_api_set_ipfix_exporter_t *mp;
10394 ip4_address_t collector_address;
10395 u8 collector_address_set = 0;
10396 u32 collector_port = ~0;
10397 ip4_address_t src_address;
10398 u8 src_address_set = 0;
10401 u32 template_interval = ~0;
10402 u8 udp_checksum = 0;
10405 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10407 if (unformat (i, "collector_address %U", unformat_ip4_address,
10408 &collector_address))
10409 collector_address_set = 1;
10410 else if (unformat (i, "collector_port %d", &collector_port))
10412 else if (unformat (i, "src_address %U", unformat_ip4_address,
10414 src_address_set = 1;
10415 else if (unformat (i, "vrf_id %d", &vrf_id))
10417 else if (unformat (i, "path_mtu %d", &path_mtu))
10419 else if (unformat (i, "template_interval %d", &template_interval))
10421 else if (unformat (i, "udp_checksum"))
10427 if (collector_address_set == 0)
10429 errmsg ("collector_address required");
10433 if (src_address_set == 0)
10435 errmsg ("src_address required");
10439 M (SET_IPFIX_EXPORTER, mp);
10441 memcpy (mp->collector_address, collector_address.data,
10442 sizeof (collector_address.data));
10443 mp->collector_port = htons ((u16) collector_port);
10444 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10445 mp->vrf_id = htonl (vrf_id);
10446 mp->path_mtu = htonl (path_mtu);
10447 mp->template_interval = htonl (template_interval);
10448 mp->udp_checksum = udp_checksum;
10456 api_set_ipfix_classify_stream (vat_main_t * vam)
10458 unformat_input_t *i = vam->input;
10459 vl_api_set_ipfix_classify_stream_t *mp;
10461 u32 src_port = UDP_DST_PORT_ipfix;
10464 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10466 if (unformat (i, "domain %d", &domain_id))
10468 else if (unformat (i, "src_port %d", &src_port))
10472 errmsg ("unknown input `%U'", format_unformat_error, i);
10477 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10479 mp->domain_id = htonl (domain_id);
10480 mp->src_port = htons ((u16) src_port);
10488 api_ipfix_classify_table_add_del (vat_main_t * vam)
10490 unformat_input_t *i = vam->input;
10491 vl_api_ipfix_classify_table_add_del_t *mp;
10493 u32 classify_table_index = ~0;
10495 u8 transport_protocol = 255;
10498 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10500 if (unformat (i, "add"))
10502 else if (unformat (i, "del"))
10504 else if (unformat (i, "table %d", &classify_table_index))
10506 else if (unformat (i, "ip4"))
10508 else if (unformat (i, "ip6"))
10510 else if (unformat (i, "tcp"))
10511 transport_protocol = 6;
10512 else if (unformat (i, "udp"))
10513 transport_protocol = 17;
10516 errmsg ("unknown input `%U'", format_unformat_error, i);
10523 errmsg ("expecting: add|del");
10526 if (classify_table_index == ~0)
10528 errmsg ("classifier table not specified");
10531 if (ip_version == 0)
10533 errmsg ("IP version not specified");
10537 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10539 mp->is_add = is_add;
10540 mp->table_id = htonl (classify_table_index);
10541 mp->ip_version = ip_version;
10542 mp->transport_protocol = transport_protocol;
10550 api_get_node_index (vat_main_t * vam)
10552 unformat_input_t *i = vam->input;
10553 vl_api_get_node_index_t *mp;
10557 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10559 if (unformat (i, "node %s", &name))
10566 errmsg ("node name required");
10569 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10571 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10575 M (GET_NODE_INDEX, mp);
10576 clib_memcpy (mp->node_name, name, vec_len (name));
10585 api_get_next_index (vat_main_t * vam)
10587 unformat_input_t *i = vam->input;
10588 vl_api_get_next_index_t *mp;
10589 u8 *node_name = 0, *next_node_name = 0;
10592 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10594 if (unformat (i, "node-name %s", &node_name))
10596 else if (unformat (i, "next-node-name %s", &next_node_name))
10600 if (node_name == 0)
10602 errmsg ("node name required");
10605 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10607 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10611 if (next_node_name == 0)
10613 errmsg ("next node name required");
10616 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10618 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10622 M (GET_NEXT_INDEX, mp);
10623 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10624 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10625 vec_free (node_name);
10626 vec_free (next_node_name);
10634 api_add_node_next (vat_main_t * vam)
10636 unformat_input_t *i = vam->input;
10637 vl_api_add_node_next_t *mp;
10642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10644 if (unformat (i, "node %s", &name))
10646 else if (unformat (i, "next %s", &next))
10653 errmsg ("node name required");
10656 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10658 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10663 errmsg ("next node required");
10666 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10668 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10672 M (ADD_NODE_NEXT, mp);
10673 clib_memcpy (mp->node_name, name, vec_len (name));
10674 clib_memcpy (mp->next_name, next, vec_len (next));
10684 api_l2tpv3_create_tunnel (vat_main_t * vam)
10686 unformat_input_t *i = vam->input;
10687 ip6_address_t client_address, our_address;
10688 int client_address_set = 0;
10689 int our_address_set = 0;
10690 u32 local_session_id = 0;
10691 u32 remote_session_id = 0;
10692 u64 local_cookie = 0;
10693 u64 remote_cookie = 0;
10694 u8 l2_sublayer_present = 0;
10695 vl_api_l2tpv3_create_tunnel_t *mp;
10698 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10700 if (unformat (i, "client_address %U", unformat_ip6_address,
10702 client_address_set = 1;
10703 else if (unformat (i, "our_address %U", unformat_ip6_address,
10705 our_address_set = 1;
10706 else if (unformat (i, "local_session_id %d", &local_session_id))
10708 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10710 else if (unformat (i, "local_cookie %lld", &local_cookie))
10712 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10714 else if (unformat (i, "l2-sublayer-present"))
10715 l2_sublayer_present = 1;
10720 if (client_address_set == 0)
10722 errmsg ("client_address required");
10726 if (our_address_set == 0)
10728 errmsg ("our_address required");
10732 M (L2TPV3_CREATE_TUNNEL, mp);
10734 clib_memcpy (mp->client_address, client_address.as_u8,
10735 sizeof (mp->client_address));
10737 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10739 mp->local_session_id = ntohl (local_session_id);
10740 mp->remote_session_id = ntohl (remote_session_id);
10741 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10742 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10743 mp->l2_sublayer_present = l2_sublayer_present;
10752 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10754 unformat_input_t *i = vam->input;
10756 u8 sw_if_index_set = 0;
10757 u64 new_local_cookie = 0;
10758 u64 new_remote_cookie = 0;
10759 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10762 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10764 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10765 sw_if_index_set = 1;
10766 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10767 sw_if_index_set = 1;
10768 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10770 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10776 if (sw_if_index_set == 0)
10778 errmsg ("missing interface name or sw_if_index");
10782 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10784 mp->sw_if_index = ntohl (sw_if_index);
10785 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10786 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10794 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10796 unformat_input_t *i = vam->input;
10797 vl_api_l2tpv3_interface_enable_disable_t *mp;
10799 u8 sw_if_index_set = 0;
10800 u8 enable_disable = 1;
10803 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10805 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10806 sw_if_index_set = 1;
10807 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10808 sw_if_index_set = 1;
10809 else if (unformat (i, "enable"))
10810 enable_disable = 1;
10811 else if (unformat (i, "disable"))
10812 enable_disable = 0;
10817 if (sw_if_index_set == 0)
10819 errmsg ("missing interface name or sw_if_index");
10823 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10825 mp->sw_if_index = ntohl (sw_if_index);
10826 mp->enable_disable = enable_disable;
10834 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10836 unformat_input_t *i = vam->input;
10837 vl_api_l2tpv3_set_lookup_key_t *mp;
10841 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10843 if (unformat (i, "lookup_v6_src"))
10844 key = L2T_LOOKUP_SRC_ADDRESS;
10845 else if (unformat (i, "lookup_v6_dst"))
10846 key = L2T_LOOKUP_DST_ADDRESS;
10847 else if (unformat (i, "lookup_session_id"))
10848 key = L2T_LOOKUP_SESSION_ID;
10853 if (key == (u8) ~ 0)
10855 errmsg ("l2tp session lookup key unset");
10859 M (L2TPV3_SET_LOOKUP_KEY, mp);
10868 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10869 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10871 vat_main_t *vam = &vat_main;
10873 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10874 format_ip6_address, mp->our_address,
10875 format_ip6_address, mp->client_address,
10876 clib_net_to_host_u32 (mp->sw_if_index));
10879 " local cookies %016llx %016llx remote cookie %016llx",
10880 clib_net_to_host_u64 (mp->local_cookie[0]),
10881 clib_net_to_host_u64 (mp->local_cookie[1]),
10882 clib_net_to_host_u64 (mp->remote_cookie));
10884 print (vam->ofp, " local session-id %d remote session-id %d",
10885 clib_net_to_host_u32 (mp->local_session_id),
10886 clib_net_to_host_u32 (mp->remote_session_id));
10888 print (vam->ofp, " l2 specific sublayer %s\n",
10889 mp->l2_sublayer_present ? "preset" : "absent");
10893 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10894 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10896 vat_main_t *vam = &vat_main;
10897 vat_json_node_t *node = NULL;
10898 struct in6_addr addr;
10900 if (VAT_JSON_ARRAY != vam->json_tree.type)
10902 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10903 vat_json_init_array (&vam->json_tree);
10905 node = vat_json_array_add (&vam->json_tree);
10907 vat_json_init_object (node);
10909 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10910 vat_json_object_add_ip6 (node, "our_address", addr);
10911 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10912 vat_json_object_add_ip6 (node, "client_address", addr);
10914 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10915 vat_json_init_array (lc);
10916 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10917 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10918 vat_json_object_add_uint (node, "remote_cookie",
10919 clib_net_to_host_u64 (mp->remote_cookie));
10921 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10922 vat_json_object_add_uint (node, "local_session_id",
10923 clib_net_to_host_u32 (mp->local_session_id));
10924 vat_json_object_add_uint (node, "remote_session_id",
10925 clib_net_to_host_u32 (mp->remote_session_id));
10926 vat_json_object_add_string_copy (node, "l2_sublayer",
10927 mp->l2_sublayer_present ? (u8 *) "present"
10928 : (u8 *) "absent");
10932 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10934 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10935 vl_api_control_ping_t *mp_ping;
10938 /* Get list of l2tpv3-tunnel interfaces */
10939 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10942 /* Use a control ping for synchronization */
10943 M (CONTROL_PING, mp_ping);
10951 static void vl_api_sw_interface_tap_details_t_handler
10952 (vl_api_sw_interface_tap_details_t * mp)
10954 vat_main_t *vam = &vat_main;
10956 print (vam->ofp, "%-16s %d",
10957 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10960 static void vl_api_sw_interface_tap_details_t_handler_json
10961 (vl_api_sw_interface_tap_details_t * mp)
10963 vat_main_t *vam = &vat_main;
10964 vat_json_node_t *node = NULL;
10966 if (VAT_JSON_ARRAY != vam->json_tree.type)
10968 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10969 vat_json_init_array (&vam->json_tree);
10971 node = vat_json_array_add (&vam->json_tree);
10973 vat_json_init_object (node);
10974 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10975 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10979 api_sw_interface_tap_dump (vat_main_t * vam)
10981 vl_api_sw_interface_tap_dump_t *mp;
10982 vl_api_control_ping_t *mp_ping;
10985 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10986 /* Get list of tap interfaces */
10987 M (SW_INTERFACE_TAP_DUMP, mp);
10990 /* Use a control ping for synchronization */
10991 M (CONTROL_PING, mp_ping);
10998 static uword unformat_vxlan_decap_next
10999 (unformat_input_t * input, va_list * args)
11001 u32 *result = va_arg (*args, u32 *);
11004 if (unformat (input, "l2"))
11005 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11006 else if (unformat (input, "%d", &tmp))
11014 api_vxlan_add_del_tunnel (vat_main_t * vam)
11016 unformat_input_t *line_input = vam->input;
11017 vl_api_vxlan_add_del_tunnel_t *mp;
11018 ip46_address_t src, dst;
11020 u8 ipv4_set = 0, ipv6_set = 0;
11024 u32 mcast_sw_if_index = ~0;
11025 u32 encap_vrf_id = 0;
11026 u32 decap_next_index = ~0;
11030 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11031 memset (&src, 0, sizeof src);
11032 memset (&dst, 0, sizeof dst);
11034 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11036 if (unformat (line_input, "del"))
11039 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11045 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11051 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11057 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11062 else if (unformat (line_input, "group %U %U",
11063 unformat_ip4_address, &dst.ip4,
11064 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11066 grp_set = dst_set = 1;
11069 else if (unformat (line_input, "group %U",
11070 unformat_ip4_address, &dst.ip4))
11072 grp_set = dst_set = 1;
11075 else if (unformat (line_input, "group %U %U",
11076 unformat_ip6_address, &dst.ip6,
11077 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11079 grp_set = dst_set = 1;
11082 else if (unformat (line_input, "group %U",
11083 unformat_ip6_address, &dst.ip6))
11085 grp_set = dst_set = 1;
11089 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11091 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11093 else if (unformat (line_input, "decap-next %U",
11094 unformat_vxlan_decap_next, &decap_next_index))
11096 else if (unformat (line_input, "vni %d", &vni))
11100 errmsg ("parse error '%U'", format_unformat_error, line_input);
11107 errmsg ("tunnel src address not specified");
11112 errmsg ("tunnel dst address not specified");
11116 if (grp_set && !ip46_address_is_multicast (&dst))
11118 errmsg ("tunnel group address not multicast");
11121 if (grp_set && mcast_sw_if_index == ~0)
11123 errmsg ("tunnel nonexistent multicast device");
11126 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11128 errmsg ("tunnel dst address must be unicast");
11133 if (ipv4_set && ipv6_set)
11135 errmsg ("both IPv4 and IPv6 addresses specified");
11139 if ((vni == 0) || (vni >> 24))
11141 errmsg ("vni not specified or out of range");
11145 M (VXLAN_ADD_DEL_TUNNEL, mp);
11149 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
11150 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
11154 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
11155 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
11157 mp->encap_vrf_id = ntohl (encap_vrf_id);
11158 mp->decap_next_index = ntohl (decap_next_index);
11159 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11160 mp->vni = ntohl (vni);
11161 mp->is_add = is_add;
11162 mp->is_ipv6 = ipv6_set;
11169 static void vl_api_vxlan_tunnel_details_t_handler
11170 (vl_api_vxlan_tunnel_details_t * mp)
11172 vat_main_t *vam = &vat_main;
11173 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
11174 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
11176 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
11177 ntohl (mp->sw_if_index),
11178 format_ip46_address, &src, IP46_TYPE_ANY,
11179 format_ip46_address, &dst, IP46_TYPE_ANY,
11180 ntohl (mp->encap_vrf_id),
11181 ntohl (mp->decap_next_index), ntohl (mp->vni),
11182 ntohl (mp->mcast_sw_if_index));
11185 static void vl_api_vxlan_tunnel_details_t_handler_json
11186 (vl_api_vxlan_tunnel_details_t * mp)
11188 vat_main_t *vam = &vat_main;
11189 vat_json_node_t *node = NULL;
11191 if (VAT_JSON_ARRAY != vam->json_tree.type)
11193 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11194 vat_json_init_array (&vam->json_tree);
11196 node = vat_json_array_add (&vam->json_tree);
11198 vat_json_init_object (node);
11199 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11202 struct in6_addr ip6;
11204 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
11205 vat_json_object_add_ip6 (node, "src_address", ip6);
11206 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
11207 vat_json_object_add_ip6 (node, "dst_address", ip6);
11211 struct in_addr ip4;
11213 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
11214 vat_json_object_add_ip4 (node, "src_address", ip4);
11215 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
11216 vat_json_object_add_ip4 (node, "dst_address", ip4);
11218 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11219 vat_json_object_add_uint (node, "decap_next_index",
11220 ntohl (mp->decap_next_index));
11221 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11222 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11223 vat_json_object_add_uint (node, "mcast_sw_if_index",
11224 ntohl (mp->mcast_sw_if_index));
11228 api_vxlan_tunnel_dump (vat_main_t * vam)
11230 unformat_input_t *i = vam->input;
11231 vl_api_vxlan_tunnel_dump_t *mp;
11232 vl_api_control_ping_t *mp_ping;
11234 u8 sw_if_index_set = 0;
11237 /* Parse args required to build the message */
11238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11240 if (unformat (i, "sw_if_index %d", &sw_if_index))
11241 sw_if_index_set = 1;
11246 if (sw_if_index_set == 0)
11251 if (!vam->json_output)
11253 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
11254 "sw_if_index", "src_address", "dst_address",
11255 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11258 /* Get list of vxlan-tunnel interfaces */
11259 M (VXLAN_TUNNEL_DUMP, mp);
11261 mp->sw_if_index = htonl (sw_if_index);
11265 /* Use a control ping for synchronization */
11266 M (CONTROL_PING, mp_ping);
11274 api_gre_add_del_tunnel (vat_main_t * vam)
11276 unformat_input_t *line_input = vam->input;
11277 vl_api_gre_add_del_tunnel_t *mp;
11278 ip4_address_t src4, dst4;
11279 ip6_address_t src6, dst6;
11286 u32 outer_fib_id = 0;
11289 memset (&src4, 0, sizeof src4);
11290 memset (&dst4, 0, sizeof dst4);
11291 memset (&src6, 0, sizeof src6);
11292 memset (&dst6, 0, sizeof dst6);
11294 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11296 if (unformat (line_input, "del"))
11298 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
11303 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
11308 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
11313 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
11318 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
11320 else if (unformat (line_input, "teb"))
11324 errmsg ("parse error '%U'", format_unformat_error, line_input);
11331 errmsg ("tunnel src address not specified");
11336 errmsg ("tunnel dst address not specified");
11339 if (ipv4_set && ipv6_set)
11341 errmsg ("both IPv4 and IPv6 addresses specified");
11346 M (GRE_ADD_DEL_TUNNEL, mp);
11350 clib_memcpy (&mp->src_address, &src4, 4);
11351 clib_memcpy (&mp->dst_address, &dst4, 4);
11355 clib_memcpy (&mp->src_address, &src6, 16);
11356 clib_memcpy (&mp->dst_address, &dst6, 16);
11358 mp->outer_fib_id = ntohl (outer_fib_id);
11359 mp->is_add = is_add;
11361 mp->is_ipv6 = ipv6_set;
11368 static void vl_api_gre_tunnel_details_t_handler
11369 (vl_api_gre_tunnel_details_t * mp)
11371 vat_main_t *vam = &vat_main;
11372 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
11373 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
11375 print (vam->ofp, "%11d%24U%24U%6d%14d",
11376 ntohl (mp->sw_if_index),
11377 format_ip46_address, &src, IP46_TYPE_ANY,
11378 format_ip46_address, &dst, IP46_TYPE_ANY,
11379 mp->teb, ntohl (mp->outer_fib_id));
11382 static void vl_api_gre_tunnel_details_t_handler_json
11383 (vl_api_gre_tunnel_details_t * mp)
11385 vat_main_t *vam = &vat_main;
11386 vat_json_node_t *node = NULL;
11387 struct in_addr ip4;
11388 struct in6_addr ip6;
11390 if (VAT_JSON_ARRAY != vam->json_tree.type)
11392 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11393 vat_json_init_array (&vam->json_tree);
11395 node = vat_json_array_add (&vam->json_tree);
11397 vat_json_init_object (node);
11398 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11401 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11402 vat_json_object_add_ip4 (node, "src_address", ip4);
11403 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11404 vat_json_object_add_ip4 (node, "dst_address", ip4);
11408 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
11409 vat_json_object_add_ip6 (node, "src_address", ip6);
11410 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
11411 vat_json_object_add_ip6 (node, "dst_address", ip6);
11413 vat_json_object_add_uint (node, "teb", mp->teb);
11414 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11415 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
11419 api_gre_tunnel_dump (vat_main_t * vam)
11421 unformat_input_t *i = vam->input;
11422 vl_api_gre_tunnel_dump_t *mp;
11423 vl_api_control_ping_t *mp_ping;
11425 u8 sw_if_index_set = 0;
11428 /* Parse args required to build the message */
11429 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11431 if (unformat (i, "sw_if_index %d", &sw_if_index))
11432 sw_if_index_set = 1;
11437 if (sw_if_index_set == 0)
11442 if (!vam->json_output)
11444 print (vam->ofp, "%11s%24s%24s%6s%14s",
11445 "sw_if_index", "src_address", "dst_address", "teb",
11449 /* Get list of gre-tunnel interfaces */
11450 M (GRE_TUNNEL_DUMP, mp);
11452 mp->sw_if_index = htonl (sw_if_index);
11456 /* Use a control ping for synchronization */
11457 M (CONTROL_PING, mp_ping);
11465 api_l2_fib_clear_table (vat_main_t * vam)
11467 // unformat_input_t * i = vam->input;
11468 vl_api_l2_fib_clear_table_t *mp;
11471 M (L2_FIB_CLEAR_TABLE, mp);
11479 api_l2_interface_efp_filter (vat_main_t * vam)
11481 unformat_input_t *i = vam->input;
11482 vl_api_l2_interface_efp_filter_t *mp;
11485 u8 sw_if_index_set = 0;
11488 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11490 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11491 sw_if_index_set = 1;
11492 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11493 sw_if_index_set = 1;
11494 else if (unformat (i, "enable"))
11496 else if (unformat (i, "disable"))
11500 clib_warning ("parse error '%U'", format_unformat_error, i);
11505 if (sw_if_index_set == 0)
11507 errmsg ("missing sw_if_index");
11511 M (L2_INTERFACE_EFP_FILTER, mp);
11513 mp->sw_if_index = ntohl (sw_if_index);
11514 mp->enable_disable = enable;
11521 #define foreach_vtr_op \
11522 _("disable", L2_VTR_DISABLED) \
11523 _("push-1", L2_VTR_PUSH_1) \
11524 _("push-2", L2_VTR_PUSH_2) \
11525 _("pop-1", L2_VTR_POP_1) \
11526 _("pop-2", L2_VTR_POP_2) \
11527 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11528 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11529 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11530 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11533 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11535 unformat_input_t *i = vam->input;
11536 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11538 u8 sw_if_index_set = 0;
11541 u32 push_dot1q = 1;
11546 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11548 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11549 sw_if_index_set = 1;
11550 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11551 sw_if_index_set = 1;
11552 else if (unformat (i, "vtr_op %d", &vtr_op))
11554 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11557 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11559 else if (unformat (i, "tag1 %d", &tag1))
11561 else if (unformat (i, "tag2 %d", &tag2))
11565 clib_warning ("parse error '%U'", format_unformat_error, i);
11570 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11572 errmsg ("missing vtr operation or sw_if_index");
11576 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11577 mp->sw_if_index = ntohl (sw_if_index);
11578 mp->vtr_op = ntohl (vtr_op);
11579 mp->push_dot1q = ntohl (push_dot1q);
11580 mp->tag1 = ntohl (tag1);
11581 mp->tag2 = ntohl (tag2);
11589 api_create_vhost_user_if (vat_main_t * vam)
11591 unformat_input_t *i = vam->input;
11592 vl_api_create_vhost_user_if_t *mp;
11595 u8 file_name_set = 0;
11596 u32 custom_dev_instance = ~0;
11598 u8 use_custom_mac = 0;
11602 /* Shut up coverity */
11603 memset (hwaddr, 0, sizeof (hwaddr));
11605 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11607 if (unformat (i, "socket %s", &file_name))
11611 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11613 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11614 use_custom_mac = 1;
11615 else if (unformat (i, "server"))
11617 else if (unformat (i, "tag %s", &tag))
11623 if (file_name_set == 0)
11625 errmsg ("missing socket file name");
11629 if (vec_len (file_name) > 255)
11631 errmsg ("socket file name too long");
11634 vec_add1 (file_name, 0);
11636 M (CREATE_VHOST_USER_IF, mp);
11638 mp->is_server = is_server;
11639 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11640 vec_free (file_name);
11641 if (custom_dev_instance != ~0)
11644 mp->custom_dev_instance = ntohl (custom_dev_instance);
11646 mp->use_custom_mac = use_custom_mac;
11647 clib_memcpy (mp->mac_address, hwaddr, 6);
11649 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11658 api_modify_vhost_user_if (vat_main_t * vam)
11660 unformat_input_t *i = vam->input;
11661 vl_api_modify_vhost_user_if_t *mp;
11664 u8 file_name_set = 0;
11665 u32 custom_dev_instance = ~0;
11666 u8 sw_if_index_set = 0;
11667 u32 sw_if_index = (u32) ~ 0;
11670 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11672 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11673 sw_if_index_set = 1;
11674 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11675 sw_if_index_set = 1;
11676 else if (unformat (i, "socket %s", &file_name))
11680 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11682 else if (unformat (i, "server"))
11688 if (sw_if_index_set == 0)
11690 errmsg ("missing sw_if_index or interface name");
11694 if (file_name_set == 0)
11696 errmsg ("missing socket file name");
11700 if (vec_len (file_name) > 255)
11702 errmsg ("socket file name too long");
11705 vec_add1 (file_name, 0);
11707 M (MODIFY_VHOST_USER_IF, mp);
11709 mp->sw_if_index = ntohl (sw_if_index);
11710 mp->is_server = is_server;
11711 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11712 vec_free (file_name);
11713 if (custom_dev_instance != ~0)
11716 mp->custom_dev_instance = ntohl (custom_dev_instance);
11725 api_delete_vhost_user_if (vat_main_t * vam)
11727 unformat_input_t *i = vam->input;
11728 vl_api_delete_vhost_user_if_t *mp;
11729 u32 sw_if_index = ~0;
11730 u8 sw_if_index_set = 0;
11733 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11735 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11736 sw_if_index_set = 1;
11737 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11738 sw_if_index_set = 1;
11743 if (sw_if_index_set == 0)
11745 errmsg ("missing sw_if_index or interface name");
11750 M (DELETE_VHOST_USER_IF, mp);
11752 mp->sw_if_index = ntohl (sw_if_index);
11759 static void vl_api_sw_interface_vhost_user_details_t_handler
11760 (vl_api_sw_interface_vhost_user_details_t * mp)
11762 vat_main_t *vam = &vat_main;
11764 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11765 (char *) mp->interface_name,
11766 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11767 clib_net_to_host_u64 (mp->features), mp->is_server,
11768 ntohl (mp->num_regions), (char *) mp->sock_filename);
11769 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11772 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11773 (vl_api_sw_interface_vhost_user_details_t * mp)
11775 vat_main_t *vam = &vat_main;
11776 vat_json_node_t *node = NULL;
11778 if (VAT_JSON_ARRAY != vam->json_tree.type)
11780 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11781 vat_json_init_array (&vam->json_tree);
11783 node = vat_json_array_add (&vam->json_tree);
11785 vat_json_init_object (node);
11786 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11787 vat_json_object_add_string_copy (node, "interface_name",
11788 mp->interface_name);
11789 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11790 ntohl (mp->virtio_net_hdr_sz));
11791 vat_json_object_add_uint (node, "features",
11792 clib_net_to_host_u64 (mp->features));
11793 vat_json_object_add_uint (node, "is_server", mp->is_server);
11794 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11795 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11796 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11800 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11802 vl_api_sw_interface_vhost_user_dump_t *mp;
11803 vl_api_control_ping_t *mp_ping;
11806 "Interface name idx hdr_sz features server regions filename");
11808 /* Get list of vhost-user interfaces */
11809 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11812 /* Use a control ping for synchronization */
11813 M (CONTROL_PING, mp_ping);
11821 api_show_version (vat_main_t * vam)
11823 vl_api_show_version_t *mp;
11826 M (SHOW_VERSION, mp);
11835 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11837 unformat_input_t *line_input = vam->input;
11838 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11839 ip4_address_t local4, remote4;
11840 ip6_address_t local6, remote6;
11842 u8 ipv4_set = 0, ipv6_set = 0;
11845 u32 encap_vrf_id = 0;
11846 u32 decap_vrf_id = 0;
11852 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11854 if (unformat (line_input, "del"))
11856 else if (unformat (line_input, "local %U",
11857 unformat_ip4_address, &local4))
11862 else if (unformat (line_input, "remote %U",
11863 unformat_ip4_address, &remote4))
11868 else if (unformat (line_input, "local %U",
11869 unformat_ip6_address, &local6))
11874 else if (unformat (line_input, "remote %U",
11875 unformat_ip6_address, &remote6))
11880 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11882 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11884 else if (unformat (line_input, "vni %d", &vni))
11886 else if (unformat (line_input, "next-ip4"))
11888 else if (unformat (line_input, "next-ip6"))
11890 else if (unformat (line_input, "next-ethernet"))
11892 else if (unformat (line_input, "next-nsh"))
11896 errmsg ("parse error '%U'", format_unformat_error, line_input);
11901 if (local_set == 0)
11903 errmsg ("tunnel local address not specified");
11906 if (remote_set == 0)
11908 errmsg ("tunnel remote address not specified");
11911 if (ipv4_set && ipv6_set)
11913 errmsg ("both IPv4 and IPv6 addresses specified");
11919 errmsg ("vni not specified");
11923 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11928 clib_memcpy (&mp->local, &local6, sizeof (local6));
11929 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11933 clib_memcpy (&mp->local, &local4, sizeof (local4));
11934 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11937 mp->encap_vrf_id = ntohl (encap_vrf_id);
11938 mp->decap_vrf_id = ntohl (decap_vrf_id);
11939 mp->protocol = protocol;
11940 mp->vni = ntohl (vni);
11941 mp->is_add = is_add;
11942 mp->is_ipv6 = ipv6_set;
11949 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11950 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11952 vat_main_t *vam = &vat_main;
11954 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11955 ntohl (mp->sw_if_index),
11956 format_ip46_address, &(mp->local[0]),
11957 format_ip46_address, &(mp->remote[0]),
11959 ntohl (mp->protocol),
11960 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11963 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11964 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11966 vat_main_t *vam = &vat_main;
11967 vat_json_node_t *node = NULL;
11968 struct in_addr ip4;
11969 struct in6_addr ip6;
11971 if (VAT_JSON_ARRAY != vam->json_tree.type)
11973 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11974 vat_json_init_array (&vam->json_tree);
11976 node = vat_json_array_add (&vam->json_tree);
11978 vat_json_init_object (node);
11979 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11982 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11983 vat_json_object_add_ip6 (node, "local", ip6);
11984 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11985 vat_json_object_add_ip6 (node, "remote", ip6);
11989 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11990 vat_json_object_add_ip4 (node, "local", ip4);
11991 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11992 vat_json_object_add_ip4 (node, "remote", ip4);
11994 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11995 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11996 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11997 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11998 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12002 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
12004 unformat_input_t *i = vam->input;
12005 vl_api_vxlan_gpe_tunnel_dump_t *mp;
12006 vl_api_control_ping_t *mp_ping;
12008 u8 sw_if_index_set = 0;
12011 /* Parse args required to build the message */
12012 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12014 if (unformat (i, "sw_if_index %d", &sw_if_index))
12015 sw_if_index_set = 1;
12020 if (sw_if_index_set == 0)
12025 if (!vam->json_output)
12027 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
12028 "sw_if_index", "local", "remote", "vni",
12029 "protocol", "encap_vrf_id", "decap_vrf_id");
12032 /* Get list of vxlan-tunnel interfaces */
12033 M (VXLAN_GPE_TUNNEL_DUMP, mp);
12035 mp->sw_if_index = htonl (sw_if_index);
12039 /* Use a control ping for synchronization */
12040 M (CONTROL_PING, mp_ping);
12048 format_l2_fib_mac_address (u8 * s, va_list * args)
12050 u8 *a = va_arg (*args, u8 *);
12052 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
12053 a[2], a[3], a[4], a[5], a[6], a[7]);
12056 static void vl_api_l2_fib_table_details_t_handler
12057 (vl_api_l2_fib_table_details_t * mp)
12059 vat_main_t *vam = &vat_main;
12061 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
12063 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
12064 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
12068 static void vl_api_l2_fib_table_details_t_handler_json
12069 (vl_api_l2_fib_table_details_t * mp)
12071 vat_main_t *vam = &vat_main;
12072 vat_json_node_t *node = NULL;
12074 if (VAT_JSON_ARRAY != vam->json_tree.type)
12076 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12077 vat_json_init_array (&vam->json_tree);
12079 node = vat_json_array_add (&vam->json_tree);
12081 vat_json_init_object (node);
12082 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
12083 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
12084 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12085 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
12086 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
12087 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
12091 api_l2_fib_table_dump (vat_main_t * vam)
12093 unformat_input_t *i = vam->input;
12094 vl_api_l2_fib_table_dump_t *mp;
12095 vl_api_control_ping_t *mp_ping;
12100 /* Parse args required to build the message */
12101 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12103 if (unformat (i, "bd_id %d", &bd_id))
12109 if (bd_id_set == 0)
12111 errmsg ("missing bridge domain");
12115 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
12117 /* Get list of l2 fib entries */
12118 M (L2_FIB_TABLE_DUMP, mp);
12120 mp->bd_id = ntohl (bd_id);
12123 /* Use a control ping for synchronization */
12124 M (CONTROL_PING, mp_ping);
12133 api_interface_name_renumber (vat_main_t * vam)
12135 unformat_input_t *line_input = vam->input;
12136 vl_api_interface_name_renumber_t *mp;
12137 u32 sw_if_index = ~0;
12138 u32 new_show_dev_instance = ~0;
12141 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12143 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
12146 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12148 else if (unformat (line_input, "new_show_dev_instance %d",
12149 &new_show_dev_instance))
12155 if (sw_if_index == ~0)
12157 errmsg ("missing interface name or sw_if_index");
12161 if (new_show_dev_instance == ~0)
12163 errmsg ("missing new_show_dev_instance");
12167 M (INTERFACE_NAME_RENUMBER, mp);
12169 mp->sw_if_index = ntohl (sw_if_index);
12170 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
12178 api_want_ip4_arp_events (vat_main_t * vam)
12180 unformat_input_t *line_input = vam->input;
12181 vl_api_want_ip4_arp_events_t *mp;
12182 ip4_address_t address;
12183 int address_set = 0;
12184 u32 enable_disable = 1;
12187 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12189 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
12191 else if (unformat (line_input, "del"))
12192 enable_disable = 0;
12197 if (address_set == 0)
12199 errmsg ("missing addresses");
12203 M (WANT_IP4_ARP_EVENTS, mp);
12204 mp->enable_disable = enable_disable;
12205 mp->pid = htonl (getpid ());
12206 mp->address = address.as_u32;
12214 api_want_ip6_nd_events (vat_main_t * vam)
12216 unformat_input_t *line_input = vam->input;
12217 vl_api_want_ip6_nd_events_t *mp;
12218 ip6_address_t address;
12219 int address_set = 0;
12220 u32 enable_disable = 1;
12223 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12225 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
12227 else if (unformat (line_input, "del"))
12228 enable_disable = 0;
12233 if (address_set == 0)
12235 errmsg ("missing addresses");
12239 M (WANT_IP6_ND_EVENTS, mp);
12240 mp->enable_disable = enable_disable;
12241 mp->pid = htonl (getpid ());
12242 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
12250 api_input_acl_set_interface (vat_main_t * vam)
12252 unformat_input_t *i = vam->input;
12253 vl_api_input_acl_set_interface_t *mp;
12255 int sw_if_index_set;
12256 u32 ip4_table_index = ~0;
12257 u32 ip6_table_index = ~0;
12258 u32 l2_table_index = ~0;
12262 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12264 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12265 sw_if_index_set = 1;
12266 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12267 sw_if_index_set = 1;
12268 else if (unformat (i, "del"))
12270 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12272 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12274 else if (unformat (i, "l2-table %d", &l2_table_index))
12278 clib_warning ("parse error '%U'", format_unformat_error, i);
12283 if (sw_if_index_set == 0)
12285 errmsg ("missing interface name or sw_if_index");
12289 M (INPUT_ACL_SET_INTERFACE, mp);
12291 mp->sw_if_index = ntohl (sw_if_index);
12292 mp->ip4_table_index = ntohl (ip4_table_index);
12293 mp->ip6_table_index = ntohl (ip6_table_index);
12294 mp->l2_table_index = ntohl (l2_table_index);
12295 mp->is_add = is_add;
12303 api_ip_address_dump (vat_main_t * vam)
12305 unformat_input_t *i = vam->input;
12306 vl_api_ip_address_dump_t *mp;
12307 vl_api_control_ping_t *mp_ping;
12308 u32 sw_if_index = ~0;
12309 u8 sw_if_index_set = 0;
12314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12316 if (unformat (i, "sw_if_index %d", &sw_if_index))
12317 sw_if_index_set = 1;
12319 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12320 sw_if_index_set = 1;
12321 else if (unformat (i, "ipv4"))
12323 else if (unformat (i, "ipv6"))
12329 if (ipv4_set && ipv6_set)
12331 errmsg ("ipv4 and ipv6 flags cannot be both set");
12335 if ((!ipv4_set) && (!ipv6_set))
12337 errmsg ("no ipv4 nor ipv6 flag set");
12341 if (sw_if_index_set == 0)
12343 errmsg ("missing interface name or sw_if_index");
12347 vam->current_sw_if_index = sw_if_index;
12348 vam->is_ipv6 = ipv6_set;
12350 M (IP_ADDRESS_DUMP, mp);
12351 mp->sw_if_index = ntohl (sw_if_index);
12352 mp->is_ipv6 = ipv6_set;
12355 /* Use a control ping for synchronization */
12356 M (CONTROL_PING, mp_ping);
12364 api_ip_dump (vat_main_t * vam)
12366 vl_api_ip_dump_t *mp;
12367 vl_api_control_ping_t *mp_ping;
12368 unformat_input_t *in = vam->input;
12375 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
12377 if (unformat (in, "ipv4"))
12379 else if (unformat (in, "ipv6"))
12385 if (ipv4_set && ipv6_set)
12387 errmsg ("ipv4 and ipv6 flags cannot be both set");
12391 if ((!ipv4_set) && (!ipv6_set))
12393 errmsg ("no ipv4 nor ipv6 flag set");
12397 is_ipv6 = ipv6_set;
12398 vam->is_ipv6 = is_ipv6;
12400 /* free old data */
12401 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12403 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12405 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12408 mp->is_ipv6 = ipv6_set;
12411 /* Use a control ping for synchronization */
12412 M (CONTROL_PING, mp_ping);
12420 api_ipsec_spd_add_del (vat_main_t * vam)
12422 unformat_input_t *i = vam->input;
12423 vl_api_ipsec_spd_add_del_t *mp;
12428 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12430 if (unformat (i, "spd_id %d", &spd_id))
12432 else if (unformat (i, "del"))
12436 clib_warning ("parse error '%U'", format_unformat_error, i);
12442 errmsg ("spd_id must be set");
12446 M (IPSEC_SPD_ADD_DEL, mp);
12448 mp->spd_id = ntohl (spd_id);
12449 mp->is_add = is_add;
12457 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12459 unformat_input_t *i = vam->input;
12460 vl_api_ipsec_interface_add_del_spd_t *mp;
12462 u8 sw_if_index_set = 0;
12463 u32 spd_id = (u32) ~ 0;
12467 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12469 if (unformat (i, "del"))
12471 else if (unformat (i, "spd_id %d", &spd_id))
12474 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12475 sw_if_index_set = 1;
12476 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12477 sw_if_index_set = 1;
12480 clib_warning ("parse error '%U'", format_unformat_error, i);
12486 if (spd_id == (u32) ~ 0)
12488 errmsg ("spd_id must be set");
12492 if (sw_if_index_set == 0)
12494 errmsg ("missing interface name or sw_if_index");
12498 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12500 mp->spd_id = ntohl (spd_id);
12501 mp->sw_if_index = ntohl (sw_if_index);
12502 mp->is_add = is_add;
12510 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12512 unformat_input_t *i = vam->input;
12513 vl_api_ipsec_spd_add_del_entry_t *mp;
12514 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12515 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12517 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12518 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12519 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12520 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12523 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12524 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12525 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12526 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12527 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12528 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12530 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12532 if (unformat (i, "del"))
12534 if (unformat (i, "outbound"))
12536 if (unformat (i, "inbound"))
12538 else if (unformat (i, "spd_id %d", &spd_id))
12540 else if (unformat (i, "sa_id %d", &sa_id))
12542 else if (unformat (i, "priority %d", &priority))
12544 else if (unformat (i, "protocol %d", &protocol))
12546 else if (unformat (i, "lport_start %d", &lport_start))
12548 else if (unformat (i, "lport_stop %d", &lport_stop))
12550 else if (unformat (i, "rport_start %d", &rport_start))
12552 else if (unformat (i, "rport_stop %d", &rport_stop))
12556 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12562 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12569 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12575 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12582 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12588 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12595 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12601 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12607 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12609 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12611 clib_warning ("unsupported action: 'resolve'");
12617 clib_warning ("parse error '%U'", format_unformat_error, i);
12623 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12625 mp->spd_id = ntohl (spd_id);
12626 mp->priority = ntohl (priority);
12627 mp->is_outbound = is_outbound;
12629 mp->is_ipv6 = is_ipv6;
12630 if (is_ipv6 || is_ip_any)
12632 clib_memcpy (mp->remote_address_start, &raddr6_start,
12633 sizeof (ip6_address_t));
12634 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12635 sizeof (ip6_address_t));
12636 clib_memcpy (mp->local_address_start, &laddr6_start,
12637 sizeof (ip6_address_t));
12638 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12639 sizeof (ip6_address_t));
12643 clib_memcpy (mp->remote_address_start, &raddr4_start,
12644 sizeof (ip4_address_t));
12645 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12646 sizeof (ip4_address_t));
12647 clib_memcpy (mp->local_address_start, &laddr4_start,
12648 sizeof (ip4_address_t));
12649 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12650 sizeof (ip4_address_t));
12652 mp->protocol = (u8) protocol;
12653 mp->local_port_start = ntohs ((u16) lport_start);
12654 mp->local_port_stop = ntohs ((u16) lport_stop);
12655 mp->remote_port_start = ntohs ((u16) rport_start);
12656 mp->remote_port_stop = ntohs ((u16) rport_stop);
12657 mp->policy = (u8) policy;
12658 mp->sa_id = ntohl (sa_id);
12659 mp->is_add = is_add;
12660 mp->is_ip_any = is_ip_any;
12667 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12669 unformat_input_t *i = vam->input;
12670 vl_api_ipsec_sad_add_del_entry_t *mp;
12671 u32 sad_id = 0, spi = 0;
12672 u8 *ck = 0, *ik = 0;
12675 u8 protocol = IPSEC_PROTOCOL_AH;
12676 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12677 u32 crypto_alg = 0, integ_alg = 0;
12678 ip4_address_t tun_src4;
12679 ip4_address_t tun_dst4;
12680 ip6_address_t tun_src6;
12681 ip6_address_t tun_dst6;
12684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12686 if (unformat (i, "del"))
12688 else if (unformat (i, "sad_id %d", &sad_id))
12690 else if (unformat (i, "spi %d", &spi))
12692 else if (unformat (i, "esp"))
12693 protocol = IPSEC_PROTOCOL_ESP;
12694 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12697 is_tunnel_ipv6 = 0;
12699 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12702 is_tunnel_ipv6 = 0;
12704 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12707 is_tunnel_ipv6 = 1;
12709 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12712 is_tunnel_ipv6 = 1;
12716 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12718 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12719 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12721 clib_warning ("unsupported crypto-alg: '%U'",
12722 format_ipsec_crypto_alg, crypto_alg);
12726 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12730 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12732 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12733 integ_alg >= IPSEC_INTEG_N_ALG)
12735 clib_warning ("unsupported integ-alg: '%U'",
12736 format_ipsec_integ_alg, integ_alg);
12740 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12744 clib_warning ("parse error '%U'", format_unformat_error, i);
12750 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12752 mp->sad_id = ntohl (sad_id);
12753 mp->is_add = is_add;
12754 mp->protocol = protocol;
12755 mp->spi = ntohl (spi);
12756 mp->is_tunnel = is_tunnel;
12757 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12758 mp->crypto_algorithm = crypto_alg;
12759 mp->integrity_algorithm = integ_alg;
12760 mp->crypto_key_length = vec_len (ck);
12761 mp->integrity_key_length = vec_len (ik);
12763 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12764 mp->crypto_key_length = sizeof (mp->crypto_key);
12766 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12767 mp->integrity_key_length = sizeof (mp->integrity_key);
12770 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12772 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12776 if (is_tunnel_ipv6)
12778 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12779 sizeof (ip6_address_t));
12780 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12781 sizeof (ip6_address_t));
12785 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12786 sizeof (ip4_address_t));
12787 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12788 sizeof (ip4_address_t));
12798 api_ipsec_sa_set_key (vat_main_t * vam)
12800 unformat_input_t *i = vam->input;
12801 vl_api_ipsec_sa_set_key_t *mp;
12803 u8 *ck = 0, *ik = 0;
12806 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12808 if (unformat (i, "sa_id %d", &sa_id))
12810 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12812 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12816 clib_warning ("parse error '%U'", format_unformat_error, i);
12821 M (IPSEC_SA_SET_KEY, mp);
12823 mp->sa_id = ntohl (sa_id);
12824 mp->crypto_key_length = vec_len (ck);
12825 mp->integrity_key_length = vec_len (ik);
12827 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12828 mp->crypto_key_length = sizeof (mp->crypto_key);
12830 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12831 mp->integrity_key_length = sizeof (mp->integrity_key);
12834 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12836 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12844 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
12846 unformat_input_t *i = vam->input;
12847 vl_api_ipsec_tunnel_if_add_del_t *mp;
12848 u32 local_spi = 0, remote_spi = 0;
12849 u32 crypto_alg = 0, integ_alg = 0;
12850 u8 *lck = NULL, *rck = NULL;
12851 u8 *lik = NULL, *rik = NULL;
12852 ip4_address_t local_ip = { {0} };
12853 ip4_address_t remote_ip = { {0} };
12856 u8 anti_replay = 0;
12859 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12861 if (unformat (i, "del"))
12863 else if (unformat (i, "esn"))
12865 else if (unformat (i, "anti_replay"))
12867 else if (unformat (i, "local_spi %d", &local_spi))
12869 else if (unformat (i, "remote_spi %d", &remote_spi))
12871 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
12873 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
12875 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
12878 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
12880 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
12882 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
12886 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12888 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12889 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12891 errmsg ("unsupported crypto-alg: '%U'\n",
12892 format_ipsec_crypto_alg, crypto_alg);
12898 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12900 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12901 integ_alg >= IPSEC_INTEG_N_ALG)
12903 errmsg ("unsupported integ-alg: '%U'\n",
12904 format_ipsec_integ_alg, integ_alg);
12910 errmsg ("parse error '%U'\n", format_unformat_error, i);
12915 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
12917 mp->is_add = is_add;
12919 mp->anti_replay = anti_replay;
12921 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
12922 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
12924 mp->local_spi = htonl (local_spi);
12925 mp->remote_spi = htonl (remote_spi);
12926 mp->crypto_alg = (u8) crypto_alg;
12928 mp->local_crypto_key_len = 0;
12931 mp->local_crypto_key_len = vec_len (lck);
12932 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
12933 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
12934 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
12937 mp->remote_crypto_key_len = 0;
12940 mp->remote_crypto_key_len = vec_len (rck);
12941 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
12942 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
12943 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
12946 mp->integ_alg = (u8) integ_alg;
12948 mp->local_integ_key_len = 0;
12951 mp->local_integ_key_len = vec_len (lik);
12952 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
12953 mp->local_integ_key_len = sizeof (mp->local_integ_key);
12954 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
12957 mp->remote_integ_key_len = 0;
12960 mp->remote_integ_key_len = vec_len (rik);
12961 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
12962 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
12963 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
12972 api_ikev2_profile_add_del (vat_main_t * vam)
12974 unformat_input_t *i = vam->input;
12975 vl_api_ikev2_profile_add_del_t *mp;
12980 const char *valid_chars = "a-zA-Z0-9_";
12982 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12984 if (unformat (i, "del"))
12986 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12987 vec_add1 (name, 0);
12990 errmsg ("parse error '%U'", format_unformat_error, i);
12995 if (!vec_len (name))
12997 errmsg ("profile name must be specified");
13001 if (vec_len (name) > 64)
13003 errmsg ("profile name too long");
13007 M (IKEV2_PROFILE_ADD_DEL, mp);
13009 clib_memcpy (mp->name, name, vec_len (name));
13010 mp->is_add = is_add;
13019 api_ikev2_profile_set_auth (vat_main_t * vam)
13021 unformat_input_t *i = vam->input;
13022 vl_api_ikev2_profile_set_auth_t *mp;
13025 u32 auth_method = 0;
13029 const char *valid_chars = "a-zA-Z0-9_";
13031 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13033 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13034 vec_add1 (name, 0);
13035 else if (unformat (i, "auth_method %U",
13036 unformat_ikev2_auth_method, &auth_method))
13038 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
13040 else if (unformat (i, "auth_data %v", &data))
13044 errmsg ("parse error '%U'", format_unformat_error, i);
13049 if (!vec_len (name))
13051 errmsg ("profile name must be specified");
13055 if (vec_len (name) > 64)
13057 errmsg ("profile name too long");
13061 if (!vec_len (data))
13063 errmsg ("auth_data must be specified");
13069 errmsg ("auth_method must be specified");
13073 M (IKEV2_PROFILE_SET_AUTH, mp);
13075 mp->is_hex = is_hex;
13076 mp->auth_method = (u8) auth_method;
13077 mp->data_len = vec_len (data);
13078 clib_memcpy (mp->name, name, vec_len (name));
13079 clib_memcpy (mp->data, data, vec_len (data));
13089 api_ikev2_profile_set_id (vat_main_t * vam)
13091 unformat_input_t *i = vam->input;
13092 vl_api_ikev2_profile_set_id_t *mp;
13100 const char *valid_chars = "a-zA-Z0-9_";
13102 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13104 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13105 vec_add1 (name, 0);
13106 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
13108 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
13110 data = vec_new (u8, 4);
13111 clib_memcpy (data, ip4.as_u8, 4);
13113 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
13115 else if (unformat (i, "id_data %v", &data))
13117 else if (unformat (i, "local"))
13119 else if (unformat (i, "remote"))
13123 errmsg ("parse error '%U'", format_unformat_error, i);
13128 if (!vec_len (name))
13130 errmsg ("profile name must be specified");
13134 if (vec_len (name) > 64)
13136 errmsg ("profile name too long");
13140 if (!vec_len (data))
13142 errmsg ("id_data must be specified");
13148 errmsg ("id_type must be specified");
13152 M (IKEV2_PROFILE_SET_ID, mp);
13154 mp->is_local = is_local;
13155 mp->id_type = (u8) id_type;
13156 mp->data_len = vec_len (data);
13157 clib_memcpy (mp->name, name, vec_len (name));
13158 clib_memcpy (mp->data, data, vec_len (data));
13168 api_ikev2_profile_set_ts (vat_main_t * vam)
13170 unformat_input_t *i = vam->input;
13171 vl_api_ikev2_profile_set_ts_t *mp;
13174 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
13175 ip4_address_t start_addr, end_addr;
13177 const char *valid_chars = "a-zA-Z0-9_";
13180 start_addr.as_u32 = 0;
13181 end_addr.as_u32 = (u32) ~ 0;
13183 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13185 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13186 vec_add1 (name, 0);
13187 else if (unformat (i, "protocol %d", &proto))
13189 else if (unformat (i, "start_port %d", &start_port))
13191 else if (unformat (i, "end_port %d", &end_port))
13194 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
13196 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
13198 else if (unformat (i, "local"))
13200 else if (unformat (i, "remote"))
13204 errmsg ("parse error '%U'", format_unformat_error, i);
13209 if (!vec_len (name))
13211 errmsg ("profile name must be specified");
13215 if (vec_len (name) > 64)
13217 errmsg ("profile name too long");
13221 M (IKEV2_PROFILE_SET_TS, mp);
13223 mp->is_local = is_local;
13224 mp->proto = (u8) proto;
13225 mp->start_port = (u16) start_port;
13226 mp->end_port = (u16) end_port;
13227 mp->start_addr = start_addr.as_u32;
13228 mp->end_addr = end_addr.as_u32;
13229 clib_memcpy (mp->name, name, vec_len (name));
13238 api_ikev2_set_local_key (vat_main_t * vam)
13240 unformat_input_t *i = vam->input;
13241 vl_api_ikev2_set_local_key_t *mp;
13245 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13247 if (unformat (i, "file %v", &file))
13248 vec_add1 (file, 0);
13251 errmsg ("parse error '%U'", format_unformat_error, i);
13256 if (!vec_len (file))
13258 errmsg ("RSA key file must be specified");
13262 if (vec_len (file) > 256)
13264 errmsg ("file name too long");
13268 M (IKEV2_SET_LOCAL_KEY, mp);
13270 clib_memcpy (mp->key_file, file, vec_len (file));
13279 api_ikev2_set_responder (vat_main_t * vam)
13281 unformat_input_t *i = vam->input;
13282 vl_api_ikev2_set_responder_t *mp;
13285 u32 sw_if_index = ~0;
13286 ip4_address_t address;
13288 const char *valid_chars = "a-zA-Z0-9_";
13290 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13293 (i, "%U interface %d address %U", unformat_token, valid_chars,
13294 &name, &sw_if_index, unformat_ip4_address, &address))
13295 vec_add1 (name, 0);
13298 errmsg ("parse error '%U'", format_unformat_error, i);
13303 if (!vec_len (name))
13305 errmsg ("profile name must be specified");
13309 if (vec_len (name) > 64)
13311 errmsg ("profile name too long");
13315 M (IKEV2_SET_RESPONDER, mp);
13317 clib_memcpy (mp->name, name, vec_len (name));
13320 mp->sw_if_index = sw_if_index;
13321 clib_memcpy (mp->address, &address, sizeof (address));
13329 api_ikev2_set_ike_transforms (vat_main_t * vam)
13331 unformat_input_t *i = vam->input;
13332 vl_api_ikev2_set_ike_transforms_t *mp;
13335 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13337 const char *valid_chars = "a-zA-Z0-9_";
13339 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13341 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13342 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13343 vec_add1 (name, 0);
13346 errmsg ("parse error '%U'", format_unformat_error, i);
13351 if (!vec_len (name))
13353 errmsg ("profile name must be specified");
13357 if (vec_len (name) > 64)
13359 errmsg ("profile name too long");
13363 M (IKEV2_SET_IKE_TRANSFORMS, mp);
13365 clib_memcpy (mp->name, name, vec_len (name));
13367 mp->crypto_alg = crypto_alg;
13368 mp->crypto_key_size = crypto_key_size;
13369 mp->integ_alg = integ_alg;
13370 mp->dh_group = dh_group;
13379 api_ikev2_set_esp_transforms (vat_main_t * vam)
13381 unformat_input_t *i = vam->input;
13382 vl_api_ikev2_set_esp_transforms_t *mp;
13385 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13387 const char *valid_chars = "a-zA-Z0-9_";
13389 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13391 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13392 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13393 vec_add1 (name, 0);
13396 errmsg ("parse error '%U'", format_unformat_error, i);
13401 if (!vec_len (name))
13403 errmsg ("profile name must be specified");
13407 if (vec_len (name) > 64)
13409 errmsg ("profile name too long");
13413 M (IKEV2_SET_ESP_TRANSFORMS, mp);
13415 clib_memcpy (mp->name, name, vec_len (name));
13417 mp->crypto_alg = crypto_alg;
13418 mp->crypto_key_size = crypto_key_size;
13419 mp->integ_alg = integ_alg;
13420 mp->dh_group = dh_group;
13428 api_ikev2_set_sa_lifetime (vat_main_t * vam)
13430 unformat_input_t *i = vam->input;
13431 vl_api_ikev2_set_sa_lifetime_t *mp;
13434 u64 lifetime, lifetime_maxdata;
13435 u32 lifetime_jitter, handover;
13437 const char *valid_chars = "a-zA-Z0-9_";
13439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13441 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
13442 &lifetime, &lifetime_jitter, &handover,
13443 &lifetime_maxdata))
13444 vec_add1 (name, 0);
13447 errmsg ("parse error '%U'", format_unformat_error, i);
13452 if (!vec_len (name))
13454 errmsg ("profile name must be specified");
13458 if (vec_len (name) > 64)
13460 errmsg ("profile name too long");
13464 M (IKEV2_SET_SA_LIFETIME, mp);
13466 clib_memcpy (mp->name, name, vec_len (name));
13468 mp->lifetime = lifetime;
13469 mp->lifetime_jitter = lifetime_jitter;
13470 mp->handover = handover;
13471 mp->lifetime_maxdata = lifetime_maxdata;
13479 api_ikev2_initiate_sa_init (vat_main_t * vam)
13481 unformat_input_t *i = vam->input;
13482 vl_api_ikev2_initiate_sa_init_t *mp;
13486 const char *valid_chars = "a-zA-Z0-9_";
13488 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13490 if (unformat (i, "%U", unformat_token, valid_chars, &name))
13491 vec_add1 (name, 0);
13494 errmsg ("parse error '%U'", format_unformat_error, i);
13499 if (!vec_len (name))
13501 errmsg ("profile name must be specified");
13505 if (vec_len (name) > 64)
13507 errmsg ("profile name too long");
13511 M (IKEV2_INITIATE_SA_INIT, mp);
13513 clib_memcpy (mp->name, name, vec_len (name));
13522 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
13524 unformat_input_t *i = vam->input;
13525 vl_api_ikev2_initiate_del_ike_sa_t *mp;
13530 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13532 if (unformat (i, "%lx", &ispi))
13536 errmsg ("parse error '%U'", format_unformat_error, i);
13541 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
13551 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13553 unformat_input_t *i = vam->input;
13554 vl_api_ikev2_initiate_del_child_sa_t *mp;
13559 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13561 if (unformat (i, "%x", &ispi))
13565 errmsg ("parse error '%U'", format_unformat_error, i);
13570 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13580 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13582 unformat_input_t *i = vam->input;
13583 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13588 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13590 if (unformat (i, "%x", &ispi))
13594 errmsg ("parse error '%U'", format_unformat_error, i);
13599 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
13612 api_map_add_domain (vat_main_t * vam)
13614 unformat_input_t *i = vam->input;
13615 vl_api_map_add_domain_t *mp;
13617 ip4_address_t ip4_prefix;
13618 ip6_address_t ip6_prefix;
13619 ip6_address_t ip6_src;
13620 u32 num_m_args = 0;
13621 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
13622 0, psid_length = 0;
13623 u8 is_translation = 0;
13625 u32 ip6_src_len = 128;
13628 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13630 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
13631 &ip4_prefix, &ip4_prefix_len))
13633 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
13634 &ip6_prefix, &ip6_prefix_len))
13638 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
13641 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
13643 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
13645 else if (unformat (i, "psid-offset %d", &psid_offset))
13647 else if (unformat (i, "psid-len %d", &psid_length))
13649 else if (unformat (i, "mtu %d", &mtu))
13651 else if (unformat (i, "map-t"))
13652 is_translation = 1;
13655 clib_warning ("parse error '%U'", format_unformat_error, i);
13660 if (num_m_args < 3)
13662 errmsg ("mandatory argument(s) missing");
13666 /* Construct the API message */
13667 M (MAP_ADD_DOMAIN, mp);
13669 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
13670 mp->ip4_prefix_len = ip4_prefix_len;
13672 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
13673 mp->ip6_prefix_len = ip6_prefix_len;
13675 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
13676 mp->ip6_src_prefix_len = ip6_src_len;
13678 mp->ea_bits_len = ea_bits_len;
13679 mp->psid_offset = psid_offset;
13680 mp->psid_length = psid_length;
13681 mp->is_translation = is_translation;
13682 mp->mtu = htons (mtu);
13687 /* Wait for a reply, return good/bad news */
13693 api_map_del_domain (vat_main_t * vam)
13695 unformat_input_t *i = vam->input;
13696 vl_api_map_del_domain_t *mp;
13698 u32 num_m_args = 0;
13702 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13704 if (unformat (i, "index %d", &index))
13708 clib_warning ("parse error '%U'", format_unformat_error, i);
13713 if (num_m_args != 1)
13715 errmsg ("mandatory argument(s) missing");
13719 /* Construct the API message */
13720 M (MAP_DEL_DOMAIN, mp);
13722 mp->index = ntohl (index);
13727 /* Wait for a reply, return good/bad news */
13733 api_map_add_del_rule (vat_main_t * vam)
13735 unformat_input_t *i = vam->input;
13736 vl_api_map_add_del_rule_t *mp;
13738 ip6_address_t ip6_dst;
13739 u32 num_m_args = 0, index, psid = 0;
13742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13744 if (unformat (i, "index %d", &index))
13746 else if (unformat (i, "psid %d", &psid))
13748 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13750 else if (unformat (i, "del"))
13756 clib_warning ("parse error '%U'", format_unformat_error, i);
13761 /* Construct the API message */
13762 M (MAP_ADD_DEL_RULE, mp);
13764 mp->index = ntohl (index);
13765 mp->is_add = is_add;
13766 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13767 mp->psid = ntohs (psid);
13772 /* Wait for a reply, return good/bad news */
13778 api_map_domain_dump (vat_main_t * vam)
13780 vl_api_map_domain_dump_t *mp;
13781 vl_api_control_ping_t *mp_ping;
13784 /* Construct the API message */
13785 M (MAP_DOMAIN_DUMP, mp);
13790 /* Use a control ping for synchronization */
13791 M (CONTROL_PING, mp_ping);
13799 api_map_rule_dump (vat_main_t * vam)
13801 unformat_input_t *i = vam->input;
13802 vl_api_map_rule_dump_t *mp;
13803 vl_api_control_ping_t *mp_ping;
13804 u32 domain_index = ~0;
13807 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13809 if (unformat (i, "index %u", &domain_index))
13815 if (domain_index == ~0)
13817 clib_warning ("parse error: domain index expected");
13821 /* Construct the API message */
13822 M (MAP_RULE_DUMP, mp);
13824 mp->domain_index = htonl (domain_index);
13829 /* Use a control ping for synchronization */
13830 M (CONTROL_PING, mp_ping);
13837 static void vl_api_map_add_domain_reply_t_handler
13838 (vl_api_map_add_domain_reply_t * mp)
13840 vat_main_t *vam = &vat_main;
13841 i32 retval = ntohl (mp->retval);
13843 if (vam->async_mode)
13845 vam->async_errors += (retval < 0);
13849 vam->retval = retval;
13850 vam->result_ready = 1;
13854 static void vl_api_map_add_domain_reply_t_handler_json
13855 (vl_api_map_add_domain_reply_t * mp)
13857 vat_main_t *vam = &vat_main;
13858 vat_json_node_t node;
13860 vat_json_init_object (&node);
13861 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13862 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13864 vat_json_print (vam->ofp, &node);
13865 vat_json_free (&node);
13867 vam->retval = ntohl (mp->retval);
13868 vam->result_ready = 1;
13872 api_get_first_msg_id (vat_main_t * vam)
13874 vl_api_get_first_msg_id_t *mp;
13875 unformat_input_t *i = vam->input;
13880 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13882 if (unformat (i, "client %s", &name))
13890 errmsg ("missing client name");
13893 vec_add1 (name, 0);
13895 if (vec_len (name) > 63)
13897 errmsg ("client name too long");
13901 M (GET_FIRST_MSG_ID, mp);
13902 clib_memcpy (mp->name, name, vec_len (name));
13909 api_cop_interface_enable_disable (vat_main_t * vam)
13911 unformat_input_t *line_input = vam->input;
13912 vl_api_cop_interface_enable_disable_t *mp;
13913 u32 sw_if_index = ~0;
13914 u8 enable_disable = 1;
13917 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13919 if (unformat (line_input, "disable"))
13920 enable_disable = 0;
13921 if (unformat (line_input, "enable"))
13922 enable_disable = 1;
13923 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13924 vam, &sw_if_index))
13926 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13932 if (sw_if_index == ~0)
13934 errmsg ("missing interface name or sw_if_index");
13938 /* Construct the API message */
13939 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13940 mp->sw_if_index = ntohl (sw_if_index);
13941 mp->enable_disable = enable_disable;
13945 /* Wait for the reply */
13951 api_cop_whitelist_enable_disable (vat_main_t * vam)
13953 unformat_input_t *line_input = vam->input;
13954 vl_api_cop_whitelist_enable_disable_t *mp;
13955 u32 sw_if_index = ~0;
13956 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13960 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13962 if (unformat (line_input, "ip4"))
13964 else if (unformat (line_input, "ip6"))
13966 else if (unformat (line_input, "default"))
13968 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13969 vam, &sw_if_index))
13971 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13973 else if (unformat (line_input, "fib-id %d", &fib_id))
13979 if (sw_if_index == ~0)
13981 errmsg ("missing interface name or sw_if_index");
13985 /* Construct the API message */
13986 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13987 mp->sw_if_index = ntohl (sw_if_index);
13988 mp->fib_id = ntohl (fib_id);
13991 mp->default_cop = default_cop;
13995 /* Wait for the reply */
14001 api_get_node_graph (vat_main_t * vam)
14003 vl_api_get_node_graph_t *mp;
14006 M (GET_NODE_GRAPH, mp);
14010 /* Wait for the reply */
14016 /** Used for parsing LISP eids */
14017 typedef CLIB_PACKED(struct{
14018 u8 addr[16]; /**< eid address */
14019 u32 len; /**< prefix length if IP */
14020 u8 type; /**< type of eid */
14025 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14027 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14029 memset (a, 0, sizeof (a[0]));
14031 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
14033 a->type = 0; /* ipv4 type */
14035 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
14037 a->type = 1; /* ipv6 type */
14039 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
14041 a->type = 2; /* mac type */
14048 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
14057 lisp_eid_size_vat (u8 type)
14072 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
14074 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
14078 api_one_add_del_locator_set (vat_main_t * vam)
14080 unformat_input_t *input = vam->input;
14081 vl_api_one_add_del_locator_set_t *mp;
14083 u8 *locator_set_name = NULL;
14084 u8 locator_set_name_set = 0;
14085 vl_api_local_locator_t locator, *locators = 0;
14086 u32 sw_if_index, priority, weight;
14090 /* Parse args required to build the message */
14091 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14093 if (unformat (input, "del"))
14097 else if (unformat (input, "locator-set %s", &locator_set_name))
14099 locator_set_name_set = 1;
14101 else if (unformat (input, "sw_if_index %u p %u w %u",
14102 &sw_if_index, &priority, &weight))
14104 locator.sw_if_index = htonl (sw_if_index);
14105 locator.priority = priority;
14106 locator.weight = weight;
14107 vec_add1 (locators, locator);
14111 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14112 &sw_if_index, &priority, &weight))
14114 locator.sw_if_index = htonl (sw_if_index);
14115 locator.priority = priority;
14116 locator.weight = weight;
14117 vec_add1 (locators, locator);
14123 if (locator_set_name_set == 0)
14125 errmsg ("missing locator-set name");
14126 vec_free (locators);
14130 if (vec_len (locator_set_name) > 64)
14132 errmsg ("locator-set name too long");
14133 vec_free (locator_set_name);
14134 vec_free (locators);
14137 vec_add1 (locator_set_name, 0);
14139 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14141 /* Construct the API message */
14142 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14144 mp->is_add = is_add;
14145 clib_memcpy (mp->locator_set_name, locator_set_name,
14146 vec_len (locator_set_name));
14147 vec_free (locator_set_name);
14149 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14151 clib_memcpy (mp->locators, locators, data_len);
14152 vec_free (locators);
14157 /* Wait for a reply... */
14162 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14165 api_one_add_del_locator (vat_main_t * vam)
14167 unformat_input_t *input = vam->input;
14168 vl_api_one_add_del_locator_t *mp;
14169 u32 tmp_if_index = ~0;
14170 u32 sw_if_index = ~0;
14171 u8 sw_if_index_set = 0;
14172 u8 sw_if_index_if_name_set = 0;
14174 u8 priority_set = 0;
14178 u8 *locator_set_name = NULL;
14179 u8 locator_set_name_set = 0;
14182 /* Parse args required to build the message */
14183 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14185 if (unformat (input, "del"))
14189 else if (unformat (input, "locator-set %s", &locator_set_name))
14191 locator_set_name_set = 1;
14193 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14196 sw_if_index_if_name_set = 1;
14197 sw_if_index = tmp_if_index;
14199 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14201 sw_if_index_set = 1;
14202 sw_if_index = tmp_if_index;
14204 else if (unformat (input, "p %d", &priority))
14208 else if (unformat (input, "w %d", &weight))
14216 if (locator_set_name_set == 0)
14218 errmsg ("missing locator-set name");
14222 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14224 errmsg ("missing sw_if_index");
14225 vec_free (locator_set_name);
14229 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14231 errmsg ("cannot use both params interface name and sw_if_index");
14232 vec_free (locator_set_name);
14236 if (priority_set == 0)
14238 errmsg ("missing locator-set priority");
14239 vec_free (locator_set_name);
14243 if (weight_set == 0)
14245 errmsg ("missing locator-set weight");
14246 vec_free (locator_set_name);
14250 if (vec_len (locator_set_name) > 64)
14252 errmsg ("locator-set name too long");
14253 vec_free (locator_set_name);
14256 vec_add1 (locator_set_name, 0);
14258 /* Construct the API message */
14259 M (ONE_ADD_DEL_LOCATOR, mp);
14261 mp->is_add = is_add;
14262 mp->sw_if_index = ntohl (sw_if_index);
14263 mp->priority = priority;
14264 mp->weight = weight;
14265 clib_memcpy (mp->locator_set_name, locator_set_name,
14266 vec_len (locator_set_name));
14267 vec_free (locator_set_name);
14272 /* Wait for a reply... */
14277 #define api_lisp_add_del_locator api_one_add_del_locator
14280 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14282 u32 *key_id = va_arg (*args, u32 *);
14285 if (unformat (input, "%s", &s))
14287 if (!strcmp ((char *) s, "sha1"))
14288 key_id[0] = HMAC_SHA_1_96;
14289 else if (!strcmp ((char *) s, "sha256"))
14290 key_id[0] = HMAC_SHA_256_128;
14293 clib_warning ("invalid key_id: '%s'", s);
14294 key_id[0] = HMAC_NO_KEY;
14305 api_one_add_del_local_eid (vat_main_t * vam)
14307 unformat_input_t *input = vam->input;
14308 vl_api_one_add_del_local_eid_t *mp;
14311 lisp_eid_vat_t _eid, *eid = &_eid;
14312 u8 *locator_set_name = 0;
14313 u8 locator_set_name_set = 0;
14319 /* Parse args required to build the message */
14320 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14322 if (unformat (input, "del"))
14326 else if (unformat (input, "vni %d", &vni))
14330 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14334 else if (unformat (input, "locator-set %s", &locator_set_name))
14336 locator_set_name_set = 1;
14338 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14340 else if (unformat (input, "secret-key %_%v%_", &key))
14346 if (locator_set_name_set == 0)
14348 errmsg ("missing locator-set name");
14354 errmsg ("EID address not set!");
14355 vec_free (locator_set_name);
14359 if (key && (0 == key_id))
14361 errmsg ("invalid key_id!");
14365 if (vec_len (key) > 64)
14367 errmsg ("key too long");
14372 if (vec_len (locator_set_name) > 64)
14374 errmsg ("locator-set name too long");
14375 vec_free (locator_set_name);
14378 vec_add1 (locator_set_name, 0);
14380 /* Construct the API message */
14381 M (ONE_ADD_DEL_LOCAL_EID, mp);
14383 mp->is_add = is_add;
14384 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14385 mp->eid_type = eid->type;
14386 mp->prefix_len = eid->len;
14387 mp->vni = clib_host_to_net_u32 (vni);
14388 mp->key_id = clib_host_to_net_u16 (key_id);
14389 clib_memcpy (mp->locator_set_name, locator_set_name,
14390 vec_len (locator_set_name));
14391 clib_memcpy (mp->key, key, vec_len (key));
14393 vec_free (locator_set_name);
14399 /* Wait for a reply... */
14404 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14407 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14409 u32 dp_table = 0, vni = 0;;
14410 unformat_input_t *input = vam->input;
14411 vl_api_gpe_add_del_fwd_entry_t *mp;
14413 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14414 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14415 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14416 u32 action = ~0, w;
14417 ip4_address_t rmt_rloc4, lcl_rloc4;
14418 ip6_address_t rmt_rloc6, lcl_rloc6;
14419 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14422 memset (&rloc, 0, sizeof (rloc));
14424 /* Parse args required to build the message */
14425 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14427 if (unformat (input, "del"))
14429 else if (unformat (input, "add"))
14431 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14435 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14439 else if (unformat (input, "vrf %d", &dp_table))
14441 else if (unformat (input, "bd %d", &dp_table))
14443 else if (unformat (input, "vni %d", &vni))
14445 else if (unformat (input, "w %d", &w))
14449 errmsg ("No RLOC configured for setting priority/weight!");
14452 curr_rloc->weight = w;
14454 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14455 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14459 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
14461 vec_add1 (lcl_locs, rloc);
14463 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
14464 vec_add1 (rmt_locs, rloc);
14465 /* weight saved in rmt loc */
14466 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14468 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14469 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14472 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
14474 vec_add1 (lcl_locs, rloc);
14476 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
14477 vec_add1 (rmt_locs, rloc);
14478 /* weight saved in rmt loc */
14479 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14481 else if (unformat (input, "action %d", &action))
14487 clib_warning ("parse error '%U'", format_unformat_error, input);
14494 errmsg ("remote eid addresses not set");
14498 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14500 errmsg ("eid types don't match");
14504 if (0 == rmt_locs && (u32) ~ 0 == action)
14506 errmsg ("action not set for negative mapping");
14510 /* Construct the API message */
14511 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14512 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14514 mp->is_add = is_add;
14515 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14516 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14517 mp->eid_type = rmt_eid->type;
14518 mp->dp_table = clib_host_to_net_u32 (dp_table);
14519 mp->vni = clib_host_to_net_u32 (vni);
14520 mp->rmt_len = rmt_eid->len;
14521 mp->lcl_len = lcl_eid->len;
14522 mp->action = action;
14524 if (0 != rmt_locs && 0 != lcl_locs)
14526 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14527 clib_memcpy (mp->locs, lcl_locs,
14528 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14530 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14531 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14532 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14534 vec_free (lcl_locs);
14535 vec_free (rmt_locs);
14540 /* Wait for a reply... */
14546 api_one_add_del_map_server (vat_main_t * vam)
14548 unformat_input_t *input = vam->input;
14549 vl_api_one_add_del_map_server_t *mp;
14553 ip4_address_t ipv4;
14554 ip6_address_t ipv6;
14557 /* Parse args required to build the message */
14558 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14560 if (unformat (input, "del"))
14564 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14568 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14576 if (ipv4_set && ipv6_set)
14578 errmsg ("both eid v4 and v6 addresses set");
14582 if (!ipv4_set && !ipv6_set)
14584 errmsg ("eid addresses not set");
14588 /* Construct the API message */
14589 M (ONE_ADD_DEL_MAP_SERVER, mp);
14591 mp->is_add = is_add;
14595 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14600 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14606 /* Wait for a reply... */
14611 #define api_lisp_add_del_map_server api_one_add_del_map_server
14614 api_one_add_del_map_resolver (vat_main_t * vam)
14616 unformat_input_t *input = vam->input;
14617 vl_api_one_add_del_map_resolver_t *mp;
14621 ip4_address_t ipv4;
14622 ip6_address_t ipv6;
14625 /* Parse args required to build the message */
14626 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14628 if (unformat (input, "del"))
14632 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14636 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14644 if (ipv4_set && ipv6_set)
14646 errmsg ("both eid v4 and v6 addresses set");
14650 if (!ipv4_set && !ipv6_set)
14652 errmsg ("eid addresses not set");
14656 /* Construct the API message */
14657 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14659 mp->is_add = is_add;
14663 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14668 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14674 /* Wait for a reply... */
14679 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14682 api_lisp_gpe_enable_disable (vat_main_t * vam)
14684 unformat_input_t *input = vam->input;
14685 vl_api_gpe_enable_disable_t *mp;
14690 /* Parse args required to build the message */
14691 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14693 if (unformat (input, "enable"))
14698 else if (unformat (input, "disable"))
14709 errmsg ("Value not set");
14713 /* Construct the API message */
14714 M (GPE_ENABLE_DISABLE, mp);
14721 /* Wait for a reply... */
14727 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14729 unformat_input_t *input = vam->input;
14730 vl_api_one_rloc_probe_enable_disable_t *mp;
14735 /* Parse args required to build the message */
14736 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14738 if (unformat (input, "enable"))
14743 else if (unformat (input, "disable"))
14751 errmsg ("Value not set");
14755 /* Construct the API message */
14756 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14758 mp->is_enabled = is_en;
14763 /* Wait for a reply... */
14768 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14771 api_one_map_register_enable_disable (vat_main_t * vam)
14773 unformat_input_t *input = vam->input;
14774 vl_api_one_map_register_enable_disable_t *mp;
14779 /* Parse args required to build the message */
14780 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14782 if (unformat (input, "enable"))
14787 else if (unformat (input, "disable"))
14795 errmsg ("Value not set");
14799 /* Construct the API message */
14800 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14802 mp->is_enabled = is_en;
14807 /* Wait for a reply... */
14812 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14815 api_one_enable_disable (vat_main_t * vam)
14817 unformat_input_t *input = vam->input;
14818 vl_api_one_enable_disable_t *mp;
14823 /* Parse args required to build the message */
14824 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14826 if (unformat (input, "enable"))
14831 else if (unformat (input, "disable"))
14841 errmsg ("Value not set");
14845 /* Construct the API message */
14846 M (ONE_ENABLE_DISABLE, mp);
14853 /* Wait for a reply... */
14858 #define api_lisp_enable_disable api_one_enable_disable
14861 api_show_one_map_register_state (vat_main_t * vam)
14863 vl_api_show_one_map_register_state_t *mp;
14866 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14871 /* wait for reply */
14876 #define api_show_lisp_map_register_state api_show_one_map_register_state
14879 api_show_one_rloc_probe_state (vat_main_t * vam)
14881 vl_api_show_one_rloc_probe_state_t *mp;
14884 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14889 /* wait for reply */
14894 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14897 api_one_add_del_l2_arp_entry (vat_main_t * vam)
14899 vl_api_one_add_del_l2_arp_entry_t *mp;
14900 unformat_input_t *input = vam->input;
14905 u8 mac[6] = { 0, };
14906 u32 ip4 = 0, bd = ~0;
14909 /* Parse args required to build the message */
14910 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14912 if (unformat (input, "del"))
14914 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
14916 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
14918 else if (unformat (input, "bd %d", &bd))
14922 errmsg ("parse error '%U'", format_unformat_error, input);
14927 if (!bd_set || !ip_set || (!mac_set && is_add))
14929 errmsg ("Missing BD, IP or MAC!");
14933 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
14934 mp->is_add = is_add;
14935 clib_memcpy (mp->mac, mac, 6);
14936 mp->bd = clib_host_to_net_u32 (bd);
14942 /* wait for reply */
14948 api_one_l2_arp_bd_get (vat_main_t * vam)
14950 vl_api_one_l2_arp_bd_get_t *mp;
14953 M (ONE_L2_ARP_BD_GET, mp);
14958 /* wait for reply */
14964 api_one_l2_arp_entries_get (vat_main_t * vam)
14966 vl_api_one_l2_arp_entries_get_t *mp;
14967 unformat_input_t *input = vam->input;
14972 /* Parse args required to build the message */
14973 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14975 if (unformat (input, "bd %d", &bd))
14979 errmsg ("parse error '%U'", format_unformat_error, input);
14986 errmsg ("Expected bridge domain!");
14990 M (ONE_L2_ARP_ENTRIES_GET, mp);
14991 mp->bd = clib_host_to_net_u32 (bd);
14996 /* wait for reply */
15002 api_one_stats_enable_disable (vat_main_t * vam)
15004 vl_api_one_stats_enable_disable_t *mp;
15005 unformat_input_t *input = vam->input;
15010 /* Parse args required to build the message */
15011 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15013 if (unformat (input, "enable"))
15018 else if (unformat (input, "disable"))
15028 errmsg ("Value not set");
15032 M (ONE_STATS_ENABLE_DISABLE, mp);
15038 /* wait for reply */
15044 api_show_one_stats_enable_disable (vat_main_t * vam)
15046 vl_api_show_one_stats_enable_disable_t *mp;
15049 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
15054 /* wait for reply */
15060 api_show_one_map_request_mode (vat_main_t * vam)
15062 vl_api_show_one_map_request_mode_t *mp;
15065 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
15070 /* wait for reply */
15075 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
15078 api_one_map_request_mode (vat_main_t * vam)
15080 unformat_input_t *input = vam->input;
15081 vl_api_one_map_request_mode_t *mp;
15085 /* Parse args required to build the message */
15086 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15088 if (unformat (input, "dst-only"))
15090 else if (unformat (input, "src-dst"))
15094 errmsg ("parse error '%U'", format_unformat_error, input);
15099 M (ONE_MAP_REQUEST_MODE, mp);
15106 /* wait for reply */
15111 #define api_lisp_map_request_mode api_one_map_request_mode
15114 * Enable/disable ONE proxy ITR.
15116 * @param vam vpp API test context
15117 * @return return code
15120 api_one_pitr_set_locator_set (vat_main_t * vam)
15122 u8 ls_name_set = 0;
15123 unformat_input_t *input = vam->input;
15124 vl_api_one_pitr_set_locator_set_t *mp;
15129 /* Parse args required to build the message */
15130 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15132 if (unformat (input, "del"))
15134 else if (unformat (input, "locator-set %s", &ls_name))
15138 errmsg ("parse error '%U'", format_unformat_error, input);
15145 errmsg ("locator-set name not set!");
15149 M (ONE_PITR_SET_LOCATOR_SET, mp);
15151 mp->is_add = is_add;
15152 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15153 vec_free (ls_name);
15158 /* wait for reply */
15163 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
15166 api_show_one_pitr (vat_main_t * vam)
15168 vl_api_show_one_pitr_t *mp;
15171 if (!vam->json_output)
15173 print (vam->ofp, "%=20s", "lisp status:");
15176 M (SHOW_ONE_PITR, mp);
15180 /* Wait for a reply... */
15185 #define api_show_lisp_pitr api_show_one_pitr
15188 api_one_use_petr (vat_main_t * vam)
15190 unformat_input_t *input = vam->input;
15191 vl_api_one_use_petr_t *mp;
15196 memset (&ip, 0, sizeof (ip));
15198 /* Parse args required to build the message */
15199 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15201 if (unformat (input, "disable"))
15204 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
15207 ip_addr_version (&ip) = IP4;
15210 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
15213 ip_addr_version (&ip) = IP6;
15217 errmsg ("parse error '%U'", format_unformat_error, input);
15222 M (ONE_USE_PETR, mp);
15224 mp->is_add = is_add;
15227 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
15229 clib_memcpy (mp->address, &ip, 4);
15231 clib_memcpy (mp->address, &ip, 16);
15237 /* wait for reply */
15242 #define api_lisp_use_petr api_one_use_petr
15245 api_show_one_use_petr (vat_main_t * vam)
15247 vl_api_show_one_use_petr_t *mp;
15250 if (!vam->json_output)
15252 print (vam->ofp, "%=20s", "Proxy-ETR status:");
15255 M (SHOW_ONE_USE_PETR, mp);
15259 /* Wait for a reply... */
15264 #define api_show_lisp_use_petr api_show_one_use_petr
15267 * Add/delete mapping between vni and vrf
15270 api_one_eid_table_add_del_map (vat_main_t * vam)
15272 unformat_input_t *input = vam->input;
15273 vl_api_one_eid_table_add_del_map_t *mp;
15274 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15275 u32 vni, vrf, bd_index;
15278 /* Parse args required to build the message */
15279 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15281 if (unformat (input, "del"))
15283 else if (unformat (input, "vrf %d", &vrf))
15285 else if (unformat (input, "bd_index %d", &bd_index))
15287 else if (unformat (input, "vni %d", &vni))
15293 if (!vni_set || (!vrf_set && !bd_index_set))
15295 errmsg ("missing arguments!");
15299 if (vrf_set && bd_index_set)
15301 errmsg ("error: both vrf and bd entered!");
15305 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15307 mp->is_add = is_add;
15308 mp->vni = htonl (vni);
15309 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15310 mp->is_l2 = bd_index_set;
15315 /* wait for reply */
15320 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15323 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15325 u32 *action = va_arg (*args, u32 *);
15328 if (unformat (input, "%s", &s))
15330 if (!strcmp ((char *) s, "no-action"))
15332 else if (!strcmp ((char *) s, "natively-forward"))
15334 else if (!strcmp ((char *) s, "send-map-request"))
15336 else if (!strcmp ((char *) s, "drop"))
15340 clib_warning ("invalid action: '%s'", s);
15352 * Add/del remote mapping to/from ONE control plane
15354 * @param vam vpp API test context
15355 * @return return code
15358 api_one_add_del_remote_mapping (vat_main_t * vam)
15360 unformat_input_t *input = vam->input;
15361 vl_api_one_add_del_remote_mapping_t *mp;
15363 lisp_eid_vat_t _eid, *eid = &_eid;
15364 lisp_eid_vat_t _seid, *seid = &_seid;
15365 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15366 u32 action = ~0, p, w, data_len;
15367 ip4_address_t rloc4;
15368 ip6_address_t rloc6;
15369 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15372 memset (&rloc, 0, sizeof (rloc));
15374 /* Parse args required to build the message */
15375 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15377 if (unformat (input, "del-all"))
15381 else if (unformat (input, "del"))
15385 else if (unformat (input, "add"))
15389 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15393 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15397 else if (unformat (input, "vni %d", &vni))
15401 else if (unformat (input, "p %d w %d", &p, &w))
15405 errmsg ("No RLOC configured for setting priority/weight!");
15408 curr_rloc->priority = p;
15409 curr_rloc->weight = w;
15411 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15414 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
15415 vec_add1 (rlocs, rloc);
15416 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15418 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15421 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
15422 vec_add1 (rlocs, rloc);
15423 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15425 else if (unformat (input, "action %U",
15426 unformat_negative_mapping_action, &action))
15432 clib_warning ("parse error '%U'", format_unformat_error, input);
15439 errmsg ("missing params!");
15443 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15445 errmsg ("no action set for negative map-reply!");
15449 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15451 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15452 mp->is_add = is_add;
15453 mp->vni = htonl (vni);
15454 mp->action = (u8) action;
15455 mp->is_src_dst = seid_set;
15456 mp->eid_len = eid->len;
15457 mp->seid_len = seid->len;
15458 mp->del_all = del_all;
15459 mp->eid_type = eid->type;
15460 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15461 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
15463 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15464 clib_memcpy (mp->rlocs, rlocs, data_len);
15470 /* Wait for a reply... */
15475 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15478 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15479 * forwarding entries in data-plane accordingly.
15481 * @param vam vpp API test context
15482 * @return return code
15485 api_one_add_del_adjacency (vat_main_t * vam)
15487 unformat_input_t *input = vam->input;
15488 vl_api_one_add_del_adjacency_t *mp;
15490 ip4_address_t leid4, reid4;
15491 ip6_address_t leid6, reid6;
15492 u8 reid_mac[6] = { 0 };
15493 u8 leid_mac[6] = { 0 };
15494 u8 reid_type, leid_type;
15495 u32 leid_len = 0, reid_len = 0, len;
15499 leid_type = reid_type = (u8) ~ 0;
15501 /* Parse args required to build the message */
15502 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15504 if (unformat (input, "del"))
15508 else if (unformat (input, "add"))
15512 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
15515 reid_type = 0; /* ipv4 */
15518 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
15521 reid_type = 1; /* ipv6 */
15524 else if (unformat (input, "reid %U", unformat_ethernet_address,
15527 reid_type = 2; /* mac */
15529 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
15532 leid_type = 0; /* ipv4 */
15535 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
15538 leid_type = 1; /* ipv6 */
15541 else if (unformat (input, "leid %U", unformat_ethernet_address,
15544 leid_type = 2; /* mac */
15546 else if (unformat (input, "vni %d", &vni))
15552 errmsg ("parse error '%U'", format_unformat_error, input);
15557 if ((u8) ~ 0 == reid_type)
15559 errmsg ("missing params!");
15563 if (leid_type != reid_type)
15565 errmsg ("remote and local EIDs are of different types!");
15569 M (ONE_ADD_DEL_ADJACENCY, mp);
15570 mp->is_add = is_add;
15571 mp->vni = htonl (vni);
15572 mp->leid_len = leid_len;
15573 mp->reid_len = reid_len;
15574 mp->eid_type = reid_type;
15576 switch (mp->eid_type)
15579 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
15580 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
15583 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
15584 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
15587 clib_memcpy (mp->leid, leid_mac, 6);
15588 clib_memcpy (mp->reid, reid_mac, 6);
15591 errmsg ("unknown EID type %d!", mp->eid_type);
15598 /* Wait for a reply... */
15603 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
15606 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
15608 u32 *mode = va_arg (*args, u32 *);
15610 if (unformat (input, "lisp"))
15612 else if (unformat (input, "vxlan"))
15621 api_gpe_get_encap_mode (vat_main_t * vam)
15623 vl_api_gpe_get_encap_mode_t *mp;
15626 /* Construct the API message */
15627 M (GPE_GET_ENCAP_MODE, mp);
15632 /* Wait for a reply... */
15638 api_gpe_set_encap_mode (vat_main_t * vam)
15640 unformat_input_t *input = vam->input;
15641 vl_api_gpe_set_encap_mode_t *mp;
15645 /* Parse args required to build the message */
15646 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15648 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
15654 /* Construct the API message */
15655 M (GPE_SET_ENCAP_MODE, mp);
15662 /* Wait for a reply... */
15668 api_lisp_gpe_add_del_iface (vat_main_t * vam)
15670 unformat_input_t *input = vam->input;
15671 vl_api_gpe_add_del_iface_t *mp;
15672 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
15673 u32 dp_table = 0, vni = 0;
15676 /* Parse args required to build the message */
15677 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15679 if (unformat (input, "up"))
15684 else if (unformat (input, "down"))
15689 else if (unformat (input, "table_id %d", &dp_table))
15693 else if (unformat (input, "bd_id %d", &dp_table))
15698 else if (unformat (input, "vni %d", &vni))
15706 if (action_set == 0)
15708 errmsg ("Action not set");
15711 if (dp_table_set == 0 || vni_set == 0)
15713 errmsg ("vni and dp_table must be set");
15717 /* Construct the API message */
15718 M (GPE_ADD_DEL_IFACE, mp);
15720 mp->is_add = is_add;
15721 mp->dp_table = dp_table;
15728 /* Wait for a reply... */
15734 * Add/del map request itr rlocs from ONE control plane and updates
15736 * @param vam vpp API test context
15737 * @return return code
15740 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
15742 unformat_input_t *input = vam->input;
15743 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
15744 u8 *locator_set_name = 0;
15745 u8 locator_set_name_set = 0;
15749 /* Parse args required to build the message */
15750 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15752 if (unformat (input, "del"))
15756 else if (unformat (input, "%_%v%_", &locator_set_name))
15758 locator_set_name_set = 1;
15762 clib_warning ("parse error '%U'", format_unformat_error, input);
15767 if (is_add && !locator_set_name_set)
15769 errmsg ("itr-rloc is not set!");
15773 if (is_add && vec_len (locator_set_name) > 64)
15775 errmsg ("itr-rloc locator-set name too long");
15776 vec_free (locator_set_name);
15780 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
15781 mp->is_add = is_add;
15784 clib_memcpy (mp->locator_set_name, locator_set_name,
15785 vec_len (locator_set_name));
15789 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
15791 vec_free (locator_set_name);
15796 /* Wait for a reply... */
15801 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
15804 api_one_locator_dump (vat_main_t * vam)
15806 unformat_input_t *input = vam->input;
15807 vl_api_one_locator_dump_t *mp;
15808 vl_api_control_ping_t *mp_ping;
15809 u8 is_index_set = 0, is_name_set = 0;
15814 /* Parse args required to build the message */
15815 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15817 if (unformat (input, "ls_name %_%v%_", &ls_name))
15821 else if (unformat (input, "ls_index %d", &ls_index))
15827 errmsg ("parse error '%U'", format_unformat_error, input);
15832 if (!is_index_set && !is_name_set)
15834 errmsg ("error: expected one of index or name!");
15838 if (is_index_set && is_name_set)
15840 errmsg ("error: only one param expected!");
15844 if (vec_len (ls_name) > 62)
15846 errmsg ("error: locator set name too long!");
15850 if (!vam->json_output)
15852 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
15855 M (ONE_LOCATOR_DUMP, mp);
15856 mp->is_index_set = is_index_set;
15859 mp->ls_index = clib_host_to_net_u32 (ls_index);
15862 vec_add1 (ls_name, 0);
15863 strncpy ((char *) mp->ls_name, (char *) ls_name,
15864 sizeof (mp->ls_name) - 1);
15870 /* Use a control ping for synchronization */
15871 M (CONTROL_PING, mp_ping);
15874 /* Wait for a reply... */
15879 #define api_lisp_locator_dump api_one_locator_dump
15882 api_one_locator_set_dump (vat_main_t * vam)
15884 vl_api_one_locator_set_dump_t *mp;
15885 vl_api_control_ping_t *mp_ping;
15886 unformat_input_t *input = vam->input;
15890 /* Parse args required to build the message */
15891 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15893 if (unformat (input, "local"))
15897 else if (unformat (input, "remote"))
15903 errmsg ("parse error '%U'", format_unformat_error, input);
15908 if (!vam->json_output)
15910 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
15913 M (ONE_LOCATOR_SET_DUMP, mp);
15915 mp->filter = filter;
15920 /* Use a control ping for synchronization */
15921 M (CONTROL_PING, mp_ping);
15924 /* Wait for a reply... */
15929 #define api_lisp_locator_set_dump api_one_locator_set_dump
15932 api_one_eid_table_map_dump (vat_main_t * vam)
15936 unformat_input_t *input = vam->input;
15937 vl_api_one_eid_table_map_dump_t *mp;
15938 vl_api_control_ping_t *mp_ping;
15941 /* Parse args required to build the message */
15942 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15944 if (unformat (input, "l2"))
15949 else if (unformat (input, "l3"))
15956 errmsg ("parse error '%U'", format_unformat_error, input);
15963 errmsg ("expected one of 'l2' or 'l3' parameter!");
15967 if (!vam->json_output)
15969 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
15972 M (ONE_EID_TABLE_MAP_DUMP, mp);
15978 /* Use a control ping for synchronization */
15979 M (CONTROL_PING, mp_ping);
15982 /* Wait for a reply... */
15987 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
15990 api_one_eid_table_vni_dump (vat_main_t * vam)
15992 vl_api_one_eid_table_vni_dump_t *mp;
15993 vl_api_control_ping_t *mp_ping;
15996 if (!vam->json_output)
15998 print (vam->ofp, "VNI");
16001 M (ONE_EID_TABLE_VNI_DUMP, mp);
16006 /* Use a control ping for synchronization */
16007 M (CONTROL_PING, mp_ping);
16010 /* Wait for a reply... */
16015 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
16018 api_one_eid_table_dump (vat_main_t * vam)
16020 unformat_input_t *i = vam->input;
16021 vl_api_one_eid_table_dump_t *mp;
16022 vl_api_control_ping_t *mp_ping;
16023 struct in_addr ip4;
16024 struct in6_addr ip6;
16026 u8 eid_type = ~0, eid_set = 0;
16027 u32 prefix_length = ~0, t, vni = 0;
16031 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16033 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
16039 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
16045 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
16050 else if (unformat (i, "vni %d", &t))
16054 else if (unformat (i, "local"))
16058 else if (unformat (i, "remote"))
16064 errmsg ("parse error '%U'", format_unformat_error, i);
16069 if (!vam->json_output)
16071 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
16072 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
16075 M (ONE_EID_TABLE_DUMP, mp);
16077 mp->filter = filter;
16081 mp->vni = htonl (vni);
16082 mp->eid_type = eid_type;
16086 mp->prefix_length = prefix_length;
16087 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
16090 mp->prefix_length = prefix_length;
16091 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
16094 clib_memcpy (mp->eid, mac, sizeof (mac));
16097 errmsg ("unknown EID type %d!", eid_type);
16105 /* Use a control ping for synchronization */
16106 M (CONTROL_PING, mp_ping);
16109 /* Wait for a reply... */
16114 #define api_lisp_eid_table_dump api_one_eid_table_dump
16117 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
16119 unformat_input_t *i = vam->input;
16120 vl_api_gpe_fwd_entries_get_t *mp;
16125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16127 if (unformat (i, "vni %d", &vni))
16133 errmsg ("parse error '%U'", format_unformat_error, i);
16140 errmsg ("vni not set!");
16144 if (!vam->json_output)
16146 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
16150 M (GPE_FWD_ENTRIES_GET, mp);
16151 mp->vni = clib_host_to_net_u32 (vni);
16156 /* Wait for a reply... */
16161 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
16162 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
16163 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
16164 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
16165 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
16166 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
16169 api_one_adjacencies_get (vat_main_t * vam)
16171 unformat_input_t *i = vam->input;
16172 vl_api_one_adjacencies_get_t *mp;
16177 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16179 if (unformat (i, "vni %d", &vni))
16185 errmsg ("parse error '%U'", format_unformat_error, i);
16192 errmsg ("vni not set!");
16196 if (!vam->json_output)
16198 print (vam->ofp, "%s %40s", "leid", "reid");
16201 M (ONE_ADJACENCIES_GET, mp);
16202 mp->vni = clib_host_to_net_u32 (vni);
16207 /* Wait for a reply... */
16212 #define api_lisp_adjacencies_get api_one_adjacencies_get
16215 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
16217 vl_api_gpe_fwd_entry_vnis_get_t *mp;
16220 if (!vam->json_output)
16222 print (vam->ofp, "VNIs");
16225 M (GPE_FWD_ENTRY_VNIS_GET, mp);
16230 /* Wait for a reply... */
16236 api_one_map_server_dump (vat_main_t * vam)
16238 vl_api_one_map_server_dump_t *mp;
16239 vl_api_control_ping_t *mp_ping;
16242 if (!vam->json_output)
16244 print (vam->ofp, "%=20s", "Map server");
16247 M (ONE_MAP_SERVER_DUMP, mp);
16251 /* Use a control ping for synchronization */
16252 M (CONTROL_PING, mp_ping);
16255 /* Wait for a reply... */
16260 #define api_lisp_map_server_dump api_one_map_server_dump
16263 api_one_map_resolver_dump (vat_main_t * vam)
16265 vl_api_one_map_resolver_dump_t *mp;
16266 vl_api_control_ping_t *mp_ping;
16269 if (!vam->json_output)
16271 print (vam->ofp, "%=20s", "Map resolver");
16274 M (ONE_MAP_RESOLVER_DUMP, mp);
16278 /* Use a control ping for synchronization */
16279 M (CONTROL_PING, mp_ping);
16282 /* Wait for a reply... */
16287 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
16290 api_one_stats_flush (vat_main_t * vam)
16292 vl_api_one_stats_flush_t *mp;
16295 M (ONE_STATS_FLUSH, mp);
16302 api_one_stats_dump (vat_main_t * vam)
16304 vl_api_one_stats_dump_t *mp;
16305 vl_api_control_ping_t *mp_ping;
16308 M (ONE_STATS_DUMP, mp);
16312 /* Use a control ping for synchronization */
16313 M (CONTROL_PING, mp_ping);
16316 /* Wait for a reply... */
16322 api_show_one_status (vat_main_t * vam)
16324 vl_api_show_one_status_t *mp;
16327 if (!vam->json_output)
16329 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
16332 M (SHOW_ONE_STATUS, mp);
16335 /* Wait for a reply... */
16340 #define api_show_lisp_status api_show_one_status
16343 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
16345 vl_api_gpe_fwd_entry_path_dump_t *mp;
16346 vl_api_control_ping_t *mp_ping;
16347 unformat_input_t *i = vam->input;
16348 u32 fwd_entry_index = ~0;
16351 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16353 if (unformat (i, "index %d", &fwd_entry_index))
16359 if (~0 == fwd_entry_index)
16361 errmsg ("no index specified!");
16365 if (!vam->json_output)
16367 print (vam->ofp, "first line");
16370 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
16374 /* Use a control ping for synchronization */
16375 M (CONTROL_PING, mp_ping);
16378 /* Wait for a reply... */
16384 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
16386 vl_api_one_get_map_request_itr_rlocs_t *mp;
16389 if (!vam->json_output)
16391 print (vam->ofp, "%=20s", "itr-rlocs:");
16394 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
16397 /* Wait for a reply... */
16402 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
16405 api_af_packet_create (vat_main_t * vam)
16407 unformat_input_t *i = vam->input;
16408 vl_api_af_packet_create_t *mp;
16409 u8 *host_if_name = 0;
16411 u8 random_hw_addr = 1;
16414 memset (hw_addr, 0, sizeof (hw_addr));
16416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16418 if (unformat (i, "name %s", &host_if_name))
16419 vec_add1 (host_if_name, 0);
16420 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16421 random_hw_addr = 0;
16426 if (!vec_len (host_if_name))
16428 errmsg ("host-interface name must be specified");
16432 if (vec_len (host_if_name) > 64)
16434 errmsg ("host-interface name too long");
16438 M (AF_PACKET_CREATE, mp);
16440 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16441 clib_memcpy (mp->hw_addr, hw_addr, 6);
16442 mp->use_random_hw_addr = random_hw_addr;
16443 vec_free (host_if_name);
16451 fprintf (vam->ofp ? vam->ofp : stderr,
16452 " new sw_if_index = %d\n", vam->sw_if_index);
16459 api_af_packet_delete (vat_main_t * vam)
16461 unformat_input_t *i = vam->input;
16462 vl_api_af_packet_delete_t *mp;
16463 u8 *host_if_name = 0;
16466 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16468 if (unformat (i, "name %s", &host_if_name))
16469 vec_add1 (host_if_name, 0);
16474 if (!vec_len (host_if_name))
16476 errmsg ("host-interface name must be specified");
16480 if (vec_len (host_if_name) > 64)
16482 errmsg ("host-interface name too long");
16486 M (AF_PACKET_DELETE, mp);
16488 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16489 vec_free (host_if_name);
16497 api_policer_add_del (vat_main_t * vam)
16499 unformat_input_t *i = vam->input;
16500 vl_api_policer_add_del_t *mp;
16510 u8 color_aware = 0;
16511 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
16514 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
16515 conform_action.dscp = 0;
16516 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
16517 exceed_action.dscp = 0;
16518 violate_action.action_type = SSE2_QOS_ACTION_DROP;
16519 violate_action.dscp = 0;
16521 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16523 if (unformat (i, "del"))
16525 else if (unformat (i, "name %s", &name))
16526 vec_add1 (name, 0);
16527 else if (unformat (i, "cir %u", &cir))
16529 else if (unformat (i, "eir %u", &eir))
16531 else if (unformat (i, "cb %u", &cb))
16533 else if (unformat (i, "eb %u", &eb))
16535 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
16538 else if (unformat (i, "round_type %U", unformat_policer_round_type,
16541 else if (unformat (i, "type %U", unformat_policer_type, &type))
16543 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
16546 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
16549 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
16552 else if (unformat (i, "color-aware"))
16558 if (!vec_len (name))
16560 errmsg ("policer name must be specified");
16564 if (vec_len (name) > 64)
16566 errmsg ("policer name too long");
16570 M (POLICER_ADD_DEL, mp);
16572 clib_memcpy (mp->name, name, vec_len (name));
16574 mp->is_add = is_add;
16579 mp->rate_type = rate_type;
16580 mp->round_type = round_type;
16582 mp->conform_action_type = conform_action.action_type;
16583 mp->conform_dscp = conform_action.dscp;
16584 mp->exceed_action_type = exceed_action.action_type;
16585 mp->exceed_dscp = exceed_action.dscp;
16586 mp->violate_action_type = violate_action.action_type;
16587 mp->violate_dscp = violate_action.dscp;
16588 mp->color_aware = color_aware;
16596 api_policer_dump (vat_main_t * vam)
16598 unformat_input_t *i = vam->input;
16599 vl_api_policer_dump_t *mp;
16600 vl_api_control_ping_t *mp_ping;
16601 u8 *match_name = 0;
16602 u8 match_name_valid = 0;
16605 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16607 if (unformat (i, "name %s", &match_name))
16609 vec_add1 (match_name, 0);
16610 match_name_valid = 1;
16616 M (POLICER_DUMP, mp);
16617 mp->match_name_valid = match_name_valid;
16618 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
16619 vec_free (match_name);
16623 /* Use a control ping for synchronization */
16624 M (CONTROL_PING, mp_ping);
16627 /* Wait for a reply... */
16633 api_policer_classify_set_interface (vat_main_t * vam)
16635 unformat_input_t *i = vam->input;
16636 vl_api_policer_classify_set_interface_t *mp;
16638 int sw_if_index_set;
16639 u32 ip4_table_index = ~0;
16640 u32 ip6_table_index = ~0;
16641 u32 l2_table_index = ~0;
16645 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16647 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16648 sw_if_index_set = 1;
16649 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16650 sw_if_index_set = 1;
16651 else if (unformat (i, "del"))
16653 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16655 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16657 else if (unformat (i, "l2-table %d", &l2_table_index))
16661 clib_warning ("parse error '%U'", format_unformat_error, i);
16666 if (sw_if_index_set == 0)
16668 errmsg ("missing interface name or sw_if_index");
16672 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
16674 mp->sw_if_index = ntohl (sw_if_index);
16675 mp->ip4_table_index = ntohl (ip4_table_index);
16676 mp->ip6_table_index = ntohl (ip6_table_index);
16677 mp->l2_table_index = ntohl (l2_table_index);
16678 mp->is_add = is_add;
16686 api_policer_classify_dump (vat_main_t * vam)
16688 unformat_input_t *i = vam->input;
16689 vl_api_policer_classify_dump_t *mp;
16690 vl_api_control_ping_t *mp_ping;
16691 u8 type = POLICER_CLASSIFY_N_TABLES;
16694 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
16698 errmsg ("classify table type must be specified");
16702 if (!vam->json_output)
16704 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
16707 M (POLICER_CLASSIFY_DUMP, mp);
16712 /* Use a control ping for synchronization */
16713 M (CONTROL_PING, mp_ping);
16716 /* Wait for a reply... */
16722 api_netmap_create (vat_main_t * vam)
16724 unformat_input_t *i = vam->input;
16725 vl_api_netmap_create_t *mp;
16728 u8 random_hw_addr = 1;
16733 memset (hw_addr, 0, sizeof (hw_addr));
16735 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16737 if (unformat (i, "name %s", &if_name))
16738 vec_add1 (if_name, 0);
16739 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16740 random_hw_addr = 0;
16741 else if (unformat (i, "pipe"))
16743 else if (unformat (i, "master"))
16745 else if (unformat (i, "slave"))
16751 if (!vec_len (if_name))
16753 errmsg ("interface name must be specified");
16757 if (vec_len (if_name) > 64)
16759 errmsg ("interface name too long");
16763 M (NETMAP_CREATE, mp);
16765 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16766 clib_memcpy (mp->hw_addr, hw_addr, 6);
16767 mp->use_random_hw_addr = random_hw_addr;
16768 mp->is_pipe = is_pipe;
16769 mp->is_master = is_master;
16770 vec_free (if_name);
16778 api_netmap_delete (vat_main_t * vam)
16780 unformat_input_t *i = vam->input;
16781 vl_api_netmap_delete_t *mp;
16785 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16787 if (unformat (i, "name %s", &if_name))
16788 vec_add1 (if_name, 0);
16793 if (!vec_len (if_name))
16795 errmsg ("interface name must be specified");
16799 if (vec_len (if_name) > 64)
16801 errmsg ("interface name too long");
16805 M (NETMAP_DELETE, mp);
16807 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16808 vec_free (if_name);
16816 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
16818 if (fp->afi == IP46_TYPE_IP6)
16820 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16821 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16822 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16823 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16824 format_ip6_address, fp->next_hop);
16825 else if (fp->afi == IP46_TYPE_IP4)
16827 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16828 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16829 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16830 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16831 format_ip4_address, fp->next_hop);
16835 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
16836 vl_api_fib_path2_t * fp)
16838 struct in_addr ip4;
16839 struct in6_addr ip6;
16841 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16842 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16843 vat_json_object_add_uint (node, "is_local", fp->is_local);
16844 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16845 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16846 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16847 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16848 if (fp->afi == IP46_TYPE_IP4)
16850 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16851 vat_json_object_add_ip4 (node, "next_hop", ip4);
16853 else if (fp->afi == IP46_TYPE_IP6)
16855 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16856 vat_json_object_add_ip6 (node, "next_hop", ip6);
16861 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
16863 vat_main_t *vam = &vat_main;
16864 int count = ntohl (mp->mt_count);
16865 vl_api_fib_path2_t *fp;
16868 print (vam->ofp, "[%d]: sw_if_index %d via:",
16869 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
16871 for (i = 0; i < count; i++)
16873 vl_api_mpls_fib_path_print (vam, fp);
16877 print (vam->ofp, "");
16880 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
16881 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
16884 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
16886 vat_main_t *vam = &vat_main;
16887 vat_json_node_t *node = NULL;
16888 int count = ntohl (mp->mt_count);
16889 vl_api_fib_path2_t *fp;
16892 if (VAT_JSON_ARRAY != vam->json_tree.type)
16894 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16895 vat_json_init_array (&vam->json_tree);
16897 node = vat_json_array_add (&vam->json_tree);
16899 vat_json_init_object (node);
16900 vat_json_object_add_uint (node, "tunnel_index",
16901 ntohl (mp->mt_tunnel_index));
16902 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
16904 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
16907 for (i = 0; i < count; i++)
16909 vl_api_mpls_fib_path_json_print (node, fp);
16915 api_mpls_tunnel_dump (vat_main_t * vam)
16917 vl_api_mpls_tunnel_dump_t *mp;
16918 vl_api_control_ping_t *mp_ping;
16922 /* Parse args required to build the message */
16923 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
16925 if (!unformat (vam->input, "tunnel_index %d", &index))
16932 print (vam->ofp, " tunnel_index %d", index);
16934 M (MPLS_TUNNEL_DUMP, mp);
16935 mp->tunnel_index = htonl (index);
16938 /* Use a control ping for synchronization */
16939 M (CONTROL_PING, mp_ping);
16946 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
16947 #define vl_api_mpls_fib_details_t_print vl_noop_handler
16951 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
16953 vat_main_t *vam = &vat_main;
16954 int count = ntohl (mp->count);
16955 vl_api_fib_path2_t *fp;
16959 "table-id %d, label %u, ess_bit %u",
16960 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
16962 for (i = 0; i < count; i++)
16964 vl_api_mpls_fib_path_print (vam, fp);
16969 static void vl_api_mpls_fib_details_t_handler_json
16970 (vl_api_mpls_fib_details_t * mp)
16972 vat_main_t *vam = &vat_main;
16973 int count = ntohl (mp->count);
16974 vat_json_node_t *node = NULL;
16975 vl_api_fib_path2_t *fp;
16978 if (VAT_JSON_ARRAY != vam->json_tree.type)
16980 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16981 vat_json_init_array (&vam->json_tree);
16983 node = vat_json_array_add (&vam->json_tree);
16985 vat_json_init_object (node);
16986 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16987 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
16988 vat_json_object_add_uint (node, "label", ntohl (mp->label));
16989 vat_json_object_add_uint (node, "path_count", count);
16991 for (i = 0; i < count; i++)
16993 vl_api_mpls_fib_path_json_print (node, fp);
16999 api_mpls_fib_dump (vat_main_t * vam)
17001 vl_api_mpls_fib_dump_t *mp;
17002 vl_api_control_ping_t *mp_ping;
17005 M (MPLS_FIB_DUMP, mp);
17008 /* Use a control ping for synchronization */
17009 M (CONTROL_PING, mp_ping);
17016 #define vl_api_ip_fib_details_t_endian vl_noop_handler
17017 #define vl_api_ip_fib_details_t_print vl_noop_handler
17020 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
17022 vat_main_t *vam = &vat_main;
17023 int count = ntohl (mp->count);
17024 vl_api_fib_path_t *fp;
17028 "table-id %d, prefix %U/%d",
17029 ntohl (mp->table_id), format_ip4_address, mp->address,
17030 mp->address_length);
17032 for (i = 0; i < count; i++)
17034 if (fp->afi == IP46_TYPE_IP6)
17036 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17037 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17038 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17039 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17040 format_ip6_address, fp->next_hop);
17041 else if (fp->afi == IP46_TYPE_IP4)
17043 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17044 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17045 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17046 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17047 format_ip4_address, fp->next_hop);
17052 static void vl_api_ip_fib_details_t_handler_json
17053 (vl_api_ip_fib_details_t * mp)
17055 vat_main_t *vam = &vat_main;
17056 int count = ntohl (mp->count);
17057 vat_json_node_t *node = NULL;
17058 struct in_addr ip4;
17059 struct in6_addr ip6;
17060 vl_api_fib_path_t *fp;
17063 if (VAT_JSON_ARRAY != vam->json_tree.type)
17065 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17066 vat_json_init_array (&vam->json_tree);
17068 node = vat_json_array_add (&vam->json_tree);
17070 vat_json_init_object (node);
17071 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17072 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
17073 vat_json_object_add_ip4 (node, "prefix", ip4);
17074 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17075 vat_json_object_add_uint (node, "path_count", count);
17077 for (i = 0; i < count; i++)
17079 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17080 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17081 vat_json_object_add_uint (node, "is_local", fp->is_local);
17082 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17083 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17084 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17085 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17086 if (fp->afi == IP46_TYPE_IP4)
17088 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17089 vat_json_object_add_ip4 (node, "next_hop", ip4);
17091 else if (fp->afi == IP46_TYPE_IP6)
17093 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17094 vat_json_object_add_ip6 (node, "next_hop", ip6);
17100 api_ip_fib_dump (vat_main_t * vam)
17102 vl_api_ip_fib_dump_t *mp;
17103 vl_api_control_ping_t *mp_ping;
17106 M (IP_FIB_DUMP, mp);
17109 /* Use a control ping for synchronization */
17110 M (CONTROL_PING, mp_ping);
17118 api_ip_mfib_dump (vat_main_t * vam)
17120 vl_api_ip_mfib_dump_t *mp;
17121 vl_api_control_ping_t *mp_ping;
17124 M (IP_MFIB_DUMP, mp);
17127 /* Use a control ping for synchronization */
17128 M (CONTROL_PING, mp_ping);
17135 static void vl_api_ip_neighbor_details_t_handler
17136 (vl_api_ip_neighbor_details_t * mp)
17138 vat_main_t *vam = &vat_main;
17140 print (vam->ofp, "%c %U %U",
17141 (mp->is_static) ? 'S' : 'D',
17142 format_ethernet_address, &mp->mac_address,
17143 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
17147 static void vl_api_ip_neighbor_details_t_handler_json
17148 (vl_api_ip_neighbor_details_t * mp)
17151 vat_main_t *vam = &vat_main;
17152 vat_json_node_t *node;
17153 struct in_addr ip4;
17154 struct in6_addr ip6;
17156 if (VAT_JSON_ARRAY != vam->json_tree.type)
17158 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17159 vat_json_init_array (&vam->json_tree);
17161 node = vat_json_array_add (&vam->json_tree);
17163 vat_json_init_object (node);
17164 vat_json_object_add_string_copy (node, "flag",
17165 (mp->is_static) ? (u8 *) "static" : (u8 *)
17168 vat_json_object_add_string_copy (node, "link_layer",
17169 format (0, "%U", format_ethernet_address,
17170 &mp->mac_address));
17174 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
17175 vat_json_object_add_ip6 (node, "ip_address", ip6);
17179 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
17180 vat_json_object_add_ip4 (node, "ip_address", ip4);
17185 api_ip_neighbor_dump (vat_main_t * vam)
17187 unformat_input_t *i = vam->input;
17188 vl_api_ip_neighbor_dump_t *mp;
17189 vl_api_control_ping_t *mp_ping;
17191 u32 sw_if_index = ~0;
17194 /* Parse args required to build the message */
17195 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17197 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17199 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17201 else if (unformat (i, "ip6"))
17207 if (sw_if_index == ~0)
17209 errmsg ("missing interface name or sw_if_index");
17213 M (IP_NEIGHBOR_DUMP, mp);
17214 mp->is_ipv6 = (u8) is_ipv6;
17215 mp->sw_if_index = ntohl (sw_if_index);
17218 /* Use a control ping for synchronization */
17219 M (CONTROL_PING, mp_ping);
17226 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
17227 #define vl_api_ip6_fib_details_t_print vl_noop_handler
17230 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
17232 vat_main_t *vam = &vat_main;
17233 int count = ntohl (mp->count);
17234 vl_api_fib_path_t *fp;
17238 "table-id %d, prefix %U/%d",
17239 ntohl (mp->table_id), format_ip6_address, mp->address,
17240 mp->address_length);
17242 for (i = 0; i < count; i++)
17244 if (fp->afi == IP46_TYPE_IP6)
17246 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17247 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17248 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17249 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17250 format_ip6_address, fp->next_hop);
17251 else if (fp->afi == IP46_TYPE_IP4)
17253 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17254 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17255 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17256 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17257 format_ip4_address, fp->next_hop);
17262 static void vl_api_ip6_fib_details_t_handler_json
17263 (vl_api_ip6_fib_details_t * mp)
17265 vat_main_t *vam = &vat_main;
17266 int count = ntohl (mp->count);
17267 vat_json_node_t *node = NULL;
17268 struct in_addr ip4;
17269 struct in6_addr ip6;
17270 vl_api_fib_path_t *fp;
17273 if (VAT_JSON_ARRAY != vam->json_tree.type)
17275 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17276 vat_json_init_array (&vam->json_tree);
17278 node = vat_json_array_add (&vam->json_tree);
17280 vat_json_init_object (node);
17281 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17282 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
17283 vat_json_object_add_ip6 (node, "prefix", ip6);
17284 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17285 vat_json_object_add_uint (node, "path_count", count);
17287 for (i = 0; i < count; i++)
17289 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17290 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17291 vat_json_object_add_uint (node, "is_local", fp->is_local);
17292 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17293 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17294 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17295 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17296 if (fp->afi == IP46_TYPE_IP4)
17298 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17299 vat_json_object_add_ip4 (node, "next_hop", ip4);
17301 else if (fp->afi == IP46_TYPE_IP6)
17303 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17304 vat_json_object_add_ip6 (node, "next_hop", ip6);
17310 api_ip6_fib_dump (vat_main_t * vam)
17312 vl_api_ip6_fib_dump_t *mp;
17313 vl_api_control_ping_t *mp_ping;
17316 M (IP6_FIB_DUMP, mp);
17319 /* Use a control ping for synchronization */
17320 M (CONTROL_PING, mp_ping);
17328 api_ip6_mfib_dump (vat_main_t * vam)
17330 vl_api_ip6_mfib_dump_t *mp;
17331 vl_api_control_ping_t *mp_ping;
17334 M (IP6_MFIB_DUMP, mp);
17337 /* Use a control ping for synchronization */
17338 M (CONTROL_PING, mp_ping);
17346 api_classify_table_ids (vat_main_t * vam)
17348 vl_api_classify_table_ids_t *mp;
17351 /* Construct the API message */
17352 M (CLASSIFY_TABLE_IDS, mp);
17361 api_classify_table_by_interface (vat_main_t * vam)
17363 unformat_input_t *input = vam->input;
17364 vl_api_classify_table_by_interface_t *mp;
17366 u32 sw_if_index = ~0;
17368 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17370 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17372 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17377 if (sw_if_index == ~0)
17379 errmsg ("missing interface name or sw_if_index");
17383 /* Construct the API message */
17384 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
17386 mp->sw_if_index = ntohl (sw_if_index);
17394 api_classify_table_info (vat_main_t * vam)
17396 unformat_input_t *input = vam->input;
17397 vl_api_classify_table_info_t *mp;
17401 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17403 if (unformat (input, "table_id %d", &table_id))
17408 if (table_id == ~0)
17410 errmsg ("missing table id");
17414 /* Construct the API message */
17415 M (CLASSIFY_TABLE_INFO, mp);
17417 mp->table_id = ntohl (table_id);
17425 api_classify_session_dump (vat_main_t * vam)
17427 unformat_input_t *input = vam->input;
17428 vl_api_classify_session_dump_t *mp;
17429 vl_api_control_ping_t *mp_ping;
17433 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17435 if (unformat (input, "table_id %d", &table_id))
17440 if (table_id == ~0)
17442 errmsg ("missing table id");
17446 /* Construct the API message */
17447 M (CLASSIFY_SESSION_DUMP, mp);
17449 mp->table_id = ntohl (table_id);
17452 /* Use a control ping for synchronization */
17453 M (CONTROL_PING, mp_ping);
17461 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
17463 vat_main_t *vam = &vat_main;
17465 print (vam->ofp, "collector_address %U, collector_port %d, "
17466 "src_address %U, vrf_id %d, path_mtu %u, "
17467 "template_interval %u, udp_checksum %d",
17468 format_ip4_address, mp->collector_address,
17469 ntohs (mp->collector_port),
17470 format_ip4_address, mp->src_address,
17471 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
17472 ntohl (mp->template_interval), mp->udp_checksum);
17475 vam->result_ready = 1;
17479 vl_api_ipfix_exporter_details_t_handler_json
17480 (vl_api_ipfix_exporter_details_t * mp)
17482 vat_main_t *vam = &vat_main;
17483 vat_json_node_t node;
17484 struct in_addr collector_address;
17485 struct in_addr src_address;
17487 vat_json_init_object (&node);
17488 clib_memcpy (&collector_address, &mp->collector_address,
17489 sizeof (collector_address));
17490 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
17491 vat_json_object_add_uint (&node, "collector_port",
17492 ntohs (mp->collector_port));
17493 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
17494 vat_json_object_add_ip4 (&node, "src_address", src_address);
17495 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
17496 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
17497 vat_json_object_add_uint (&node, "template_interval",
17498 ntohl (mp->template_interval));
17499 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
17501 vat_json_print (vam->ofp, &node);
17502 vat_json_free (&node);
17504 vam->result_ready = 1;
17508 api_ipfix_exporter_dump (vat_main_t * vam)
17510 vl_api_ipfix_exporter_dump_t *mp;
17513 /* Construct the API message */
17514 M (IPFIX_EXPORTER_DUMP, mp);
17523 api_ipfix_classify_stream_dump (vat_main_t * vam)
17525 vl_api_ipfix_classify_stream_dump_t *mp;
17528 /* Construct the API message */
17529 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
17540 vl_api_ipfix_classify_stream_details_t_handler
17541 (vl_api_ipfix_classify_stream_details_t * mp)
17543 vat_main_t *vam = &vat_main;
17544 print (vam->ofp, "domain_id %d, src_port %d",
17545 ntohl (mp->domain_id), ntohs (mp->src_port));
17547 vam->result_ready = 1;
17551 vl_api_ipfix_classify_stream_details_t_handler_json
17552 (vl_api_ipfix_classify_stream_details_t * mp)
17554 vat_main_t *vam = &vat_main;
17555 vat_json_node_t node;
17557 vat_json_init_object (&node);
17558 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
17559 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
17561 vat_json_print (vam->ofp, &node);
17562 vat_json_free (&node);
17564 vam->result_ready = 1;
17568 api_ipfix_classify_table_dump (vat_main_t * vam)
17570 vl_api_ipfix_classify_table_dump_t *mp;
17571 vl_api_control_ping_t *mp_ping;
17574 if (!vam->json_output)
17576 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
17577 "transport_protocol");
17580 /* Construct the API message */
17581 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
17586 /* Use a control ping for synchronization */
17587 M (CONTROL_PING, mp_ping);
17595 vl_api_ipfix_classify_table_details_t_handler
17596 (vl_api_ipfix_classify_table_details_t * mp)
17598 vat_main_t *vam = &vat_main;
17599 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
17600 mp->transport_protocol);
17604 vl_api_ipfix_classify_table_details_t_handler_json
17605 (vl_api_ipfix_classify_table_details_t * mp)
17607 vat_json_node_t *node = NULL;
17608 vat_main_t *vam = &vat_main;
17610 if (VAT_JSON_ARRAY != vam->json_tree.type)
17612 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17613 vat_json_init_array (&vam->json_tree);
17616 node = vat_json_array_add (&vam->json_tree);
17617 vat_json_init_object (node);
17619 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
17620 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
17621 vat_json_object_add_uint (node, "transport_protocol",
17622 mp->transport_protocol);
17626 api_sw_interface_span_enable_disable (vat_main_t * vam)
17628 unformat_input_t *i = vam->input;
17629 vl_api_sw_interface_span_enable_disable_t *mp;
17630 u32 src_sw_if_index = ~0;
17631 u32 dst_sw_if_index = ~0;
17635 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17638 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
17640 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
17644 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
17646 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
17648 else if (unformat (i, "disable"))
17650 else if (unformat (i, "rx"))
17652 else if (unformat (i, "tx"))
17654 else if (unformat (i, "both"))
17660 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
17662 mp->sw_if_index_from = htonl (src_sw_if_index);
17663 mp->sw_if_index_to = htonl (dst_sw_if_index);
17672 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
17675 vat_main_t *vam = &vat_main;
17676 u8 *sw_if_from_name = 0;
17677 u8 *sw_if_to_name = 0;
17678 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17679 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17680 char *states[] = { "none", "rx", "tx", "both" };
17684 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17686 if ((u32) p->value[0] == sw_if_index_from)
17688 sw_if_from_name = (u8 *)(p->key);
17692 if ((u32) p->value[0] == sw_if_index_to)
17694 sw_if_to_name = (u8 *)(p->key);
17695 if (sw_if_from_name)
17700 print (vam->ofp, "%20s => %20s (%s)",
17701 sw_if_from_name, sw_if_to_name, states[mp->state]);
17705 vl_api_sw_interface_span_details_t_handler_json
17706 (vl_api_sw_interface_span_details_t * mp)
17708 vat_main_t *vam = &vat_main;
17709 vat_json_node_t *node = NULL;
17710 u8 *sw_if_from_name = 0;
17711 u8 *sw_if_to_name = 0;
17712 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17713 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17717 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17719 if ((u32) p->value[0] == sw_if_index_from)
17721 sw_if_from_name = (u8 *)(p->key);
17725 if ((u32) p->value[0] == sw_if_index_to)
17727 sw_if_to_name = (u8 *)(p->key);
17728 if (sw_if_from_name)
17734 if (VAT_JSON_ARRAY != vam->json_tree.type)
17736 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17737 vat_json_init_array (&vam->json_tree);
17739 node = vat_json_array_add (&vam->json_tree);
17741 vat_json_init_object (node);
17742 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
17743 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
17744 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
17745 if (0 != sw_if_to_name)
17747 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
17749 vat_json_object_add_uint (node, "state", mp->state);
17753 api_sw_interface_span_dump (vat_main_t * vam)
17755 vl_api_sw_interface_span_dump_t *mp;
17756 vl_api_control_ping_t *mp_ping;
17759 M (SW_INTERFACE_SPAN_DUMP, mp);
17762 /* Use a control ping for synchronization */
17763 M (CONTROL_PING, mp_ping);
17771 api_pg_create_interface (vat_main_t * vam)
17773 unformat_input_t *input = vam->input;
17774 vl_api_pg_create_interface_t *mp;
17778 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17780 if (unformat (input, "if_id %d", &if_id))
17787 errmsg ("missing pg interface index");
17791 /* Construct the API message */
17792 M (PG_CREATE_INTERFACE, mp);
17794 mp->interface_id = ntohl (if_id);
17802 api_pg_capture (vat_main_t * vam)
17804 unformat_input_t *input = vam->input;
17805 vl_api_pg_capture_t *mp;
17810 u8 pcap_file_set = 0;
17813 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17815 if (unformat (input, "if_id %d", &if_id))
17817 else if (unformat (input, "pcap %s", &pcap_file))
17819 else if (unformat (input, "count %d", &count))
17821 else if (unformat (input, "disable"))
17828 errmsg ("missing pg interface index");
17831 if (pcap_file_set > 0)
17833 if (vec_len (pcap_file) > 255)
17835 errmsg ("pcap file name is too long");
17840 u32 name_len = vec_len (pcap_file);
17841 /* Construct the API message */
17842 M (PG_CAPTURE, mp);
17844 mp->interface_id = ntohl (if_id);
17845 mp->is_enabled = enable;
17846 mp->count = ntohl (count);
17847 mp->pcap_name_length = ntohl (name_len);
17848 if (pcap_file_set != 0)
17850 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
17852 vec_free (pcap_file);
17860 api_pg_enable_disable (vat_main_t * vam)
17862 unformat_input_t *input = vam->input;
17863 vl_api_pg_enable_disable_t *mp;
17866 u8 stream_name_set = 0;
17867 u8 *stream_name = 0;
17869 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17871 if (unformat (input, "stream %s", &stream_name))
17872 stream_name_set = 1;
17873 else if (unformat (input, "disable"))
17879 if (stream_name_set > 0)
17881 if (vec_len (stream_name) > 255)
17883 errmsg ("stream name too long");
17888 u32 name_len = vec_len (stream_name);
17889 /* Construct the API message */
17890 M (PG_ENABLE_DISABLE, mp);
17892 mp->is_enabled = enable;
17893 if (stream_name_set != 0)
17895 mp->stream_name_length = ntohl (name_len);
17896 clib_memcpy (mp->stream_name, stream_name, name_len);
17898 vec_free (stream_name);
17906 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
17908 unformat_input_t *input = vam->input;
17909 vl_api_ip_source_and_port_range_check_add_del_t *mp;
17911 u16 *low_ports = 0;
17912 u16 *high_ports = 0;
17915 ip4_address_t ip4_addr;
17916 ip6_address_t ip6_addr;
17925 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17927 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
17933 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
17938 else if (unformat (input, "vrf %d", &vrf_id))
17940 else if (unformat (input, "del"))
17942 else if (unformat (input, "port %d", &tmp))
17944 if (tmp == 0 || tmp > 65535)
17946 errmsg ("port %d out of range", tmp);
17950 this_hi = this_low + 1;
17951 vec_add1 (low_ports, this_low);
17952 vec_add1 (high_ports, this_hi);
17954 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
17956 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
17958 errmsg ("incorrect range parameters");
17962 /* Note: in debug CLI +1 is added to high before
17963 passing to real fn that does "the work"
17964 (ip_source_and_port_range_check_add_del).
17965 This fn is a wrapper around the binary API fn a
17966 control plane will call, which expects this increment
17967 to have occurred. Hence letting the binary API control
17968 plane fn do the increment for consistency between VAT
17969 and other control planes.
17972 vec_add1 (low_ports, this_low);
17973 vec_add1 (high_ports, this_hi);
17979 if (prefix_set == 0)
17981 errmsg ("<address>/<mask> not specified");
17987 errmsg ("VRF ID required, not specified");
17994 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17998 if (vec_len (low_ports) == 0)
18000 errmsg ("At least one port or port range required");
18004 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
18006 mp->is_add = is_add;
18011 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
18016 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
18019 mp->mask_length = length;
18020 mp->number_of_ranges = vec_len (low_ports);
18022 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
18023 vec_free (low_ports);
18025 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
18026 vec_free (high_ports);
18028 mp->vrf_id = ntohl (vrf_id);
18036 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
18038 unformat_input_t *input = vam->input;
18039 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
18040 u32 sw_if_index = ~0;
18042 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
18043 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
18047 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18049 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18051 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18053 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
18055 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
18057 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
18059 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
18061 else if (unformat (input, "del"))
18067 if (sw_if_index == ~0)
18069 errmsg ("Interface required but not specified");
18075 errmsg ("VRF ID required but not specified");
18079 if (tcp_out_vrf_id == 0
18080 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
18083 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18087 /* Construct the API message */
18088 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
18090 mp->sw_if_index = ntohl (sw_if_index);
18091 mp->is_add = is_add;
18092 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
18093 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
18094 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
18095 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
18100 /* Wait for a reply... */
18106 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
18108 unformat_input_t *i = vam->input;
18109 vl_api_ipsec_gre_add_del_tunnel_t *mp;
18110 u32 local_sa_id = 0;
18111 u32 remote_sa_id = 0;
18112 ip4_address_t src_address;
18113 ip4_address_t dst_address;
18117 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18119 if (unformat (i, "local_sa %d", &local_sa_id))
18121 else if (unformat (i, "remote_sa %d", &remote_sa_id))
18123 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
18125 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
18127 else if (unformat (i, "del"))
18131 clib_warning ("parse error '%U'", format_unformat_error, i);
18136 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
18138 mp->local_sa_id = ntohl (local_sa_id);
18139 mp->remote_sa_id = ntohl (remote_sa_id);
18140 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
18141 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
18142 mp->is_add = is_add;
18150 api_punt (vat_main_t * vam)
18152 unformat_input_t *i = vam->input;
18160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18162 if (unformat (i, "ip %d", &ipv))
18164 else if (unformat (i, "protocol %d", &protocol))
18166 else if (unformat (i, "port %d", &port))
18168 else if (unformat (i, "del"))
18172 clib_warning ("parse error '%U'", format_unformat_error, i);
18179 mp->is_add = (u8) is_add;
18180 mp->ipv = (u8) ipv;
18181 mp->l4_protocol = (u8) protocol;
18182 mp->l4_port = htons ((u16) port);
18189 static void vl_api_ipsec_gre_tunnel_details_t_handler
18190 (vl_api_ipsec_gre_tunnel_details_t * mp)
18192 vat_main_t *vam = &vat_main;
18194 print (vam->ofp, "%11d%15U%15U%14d%14d",
18195 ntohl (mp->sw_if_index),
18196 format_ip4_address, &mp->src_address,
18197 format_ip4_address, &mp->dst_address,
18198 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
18201 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
18202 (vl_api_ipsec_gre_tunnel_details_t * mp)
18204 vat_main_t *vam = &vat_main;
18205 vat_json_node_t *node = NULL;
18206 struct in_addr ip4;
18208 if (VAT_JSON_ARRAY != vam->json_tree.type)
18210 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18211 vat_json_init_array (&vam->json_tree);
18213 node = vat_json_array_add (&vam->json_tree);
18215 vat_json_init_object (node);
18216 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18217 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
18218 vat_json_object_add_ip4 (node, "src_address", ip4);
18219 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
18220 vat_json_object_add_ip4 (node, "dst_address", ip4);
18221 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
18222 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
18226 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
18228 unformat_input_t *i = vam->input;
18229 vl_api_ipsec_gre_tunnel_dump_t *mp;
18230 vl_api_control_ping_t *mp_ping;
18232 u8 sw_if_index_set = 0;
18235 /* Parse args required to build the message */
18236 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18238 if (unformat (i, "sw_if_index %d", &sw_if_index))
18239 sw_if_index_set = 1;
18244 if (sw_if_index_set == 0)
18249 if (!vam->json_output)
18251 print (vam->ofp, "%11s%15s%15s%14s%14s",
18252 "sw_if_index", "src_address", "dst_address",
18253 "local_sa_id", "remote_sa_id");
18256 /* Get list of gre-tunnel interfaces */
18257 M (IPSEC_GRE_TUNNEL_DUMP, mp);
18259 mp->sw_if_index = htonl (sw_if_index);
18263 /* Use a control ping for synchronization */
18264 M (CONTROL_PING, mp_ping);
18272 api_delete_subif (vat_main_t * vam)
18274 unformat_input_t *i = vam->input;
18275 vl_api_delete_subif_t *mp;
18276 u32 sw_if_index = ~0;
18279 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18281 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18283 if (unformat (i, "sw_if_index %d", &sw_if_index))
18289 if (sw_if_index == ~0)
18291 errmsg ("missing sw_if_index");
18295 /* Construct the API message */
18296 M (DELETE_SUBIF, mp);
18297 mp->sw_if_index = ntohl (sw_if_index);
18304 #define foreach_pbb_vtr_op \
18305 _("disable", L2_VTR_DISABLED) \
18306 _("pop", L2_VTR_POP_2) \
18307 _("push", L2_VTR_PUSH_2)
18310 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
18312 unformat_input_t *i = vam->input;
18313 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
18314 u32 sw_if_index = ~0, vtr_op = ~0;
18315 u16 outer_tag = ~0;
18316 u8 dmac[6], smac[6];
18317 u8 dmac_set = 0, smac_set = 0;
18323 /* Shut up coverity */
18324 memset (dmac, 0, sizeof (dmac));
18325 memset (smac, 0, sizeof (smac));
18327 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18329 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18331 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18333 else if (unformat (i, "vtr_op %d", &vtr_op))
18335 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
18338 else if (unformat (i, "translate_pbb_stag"))
18340 if (unformat (i, "%d", &tmp))
18342 vtr_op = L2_VTR_TRANSLATE_2_1;
18348 ("translate_pbb_stag operation requires outer tag definition");
18352 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
18354 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
18356 else if (unformat (i, "sid %d", &sid))
18358 else if (unformat (i, "vlanid %d", &tmp))
18362 clib_warning ("parse error '%U'", format_unformat_error, i);
18367 if ((sw_if_index == ~0) || (vtr_op == ~0))
18369 errmsg ("missing sw_if_index or vtr operation");
18372 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
18373 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
18376 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
18380 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
18381 mp->sw_if_index = ntohl (sw_if_index);
18382 mp->vtr_op = ntohl (vtr_op);
18383 mp->outer_tag = ntohs (outer_tag);
18384 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
18385 clib_memcpy (mp->b_smac, smac, sizeof (smac));
18386 mp->b_vlanid = ntohs (vlanid);
18387 mp->i_sid = ntohl (sid);
18395 api_flow_classify_set_interface (vat_main_t * vam)
18397 unformat_input_t *i = vam->input;
18398 vl_api_flow_classify_set_interface_t *mp;
18400 int sw_if_index_set;
18401 u32 ip4_table_index = ~0;
18402 u32 ip6_table_index = ~0;
18406 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18408 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18409 sw_if_index_set = 1;
18410 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18411 sw_if_index_set = 1;
18412 else if (unformat (i, "del"))
18414 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18416 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18420 clib_warning ("parse error '%U'", format_unformat_error, i);
18425 if (sw_if_index_set == 0)
18427 errmsg ("missing interface name or sw_if_index");
18431 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
18433 mp->sw_if_index = ntohl (sw_if_index);
18434 mp->ip4_table_index = ntohl (ip4_table_index);
18435 mp->ip6_table_index = ntohl (ip6_table_index);
18436 mp->is_add = is_add;
18444 api_flow_classify_dump (vat_main_t * vam)
18446 unformat_input_t *i = vam->input;
18447 vl_api_flow_classify_dump_t *mp;
18448 vl_api_control_ping_t *mp_ping;
18449 u8 type = FLOW_CLASSIFY_N_TABLES;
18452 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
18456 errmsg ("classify table type must be specified");
18460 if (!vam->json_output)
18462 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18465 M (FLOW_CLASSIFY_DUMP, mp);
18470 /* Use a control ping for synchronization */
18471 M (CONTROL_PING, mp_ping);
18474 /* Wait for a reply... */
18480 api_feature_enable_disable (vat_main_t * vam)
18482 unformat_input_t *i = vam->input;
18483 vl_api_feature_enable_disable_t *mp;
18485 u8 *feature_name = 0;
18486 u32 sw_if_index = ~0;
18490 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18492 if (unformat (i, "arc_name %s", &arc_name))
18494 else if (unformat (i, "feature_name %s", &feature_name))
18497 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18499 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18501 else if (unformat (i, "disable"))
18509 errmsg ("missing arc name");
18512 if (vec_len (arc_name) > 63)
18514 errmsg ("arc name too long");
18517 if (feature_name == 0)
18519 errmsg ("missing feature name");
18522 if (vec_len (feature_name) > 63)
18524 errmsg ("feature name too long");
18527 if (sw_if_index == ~0)
18529 errmsg ("missing interface name or sw_if_index");
18533 /* Construct the API message */
18534 M (FEATURE_ENABLE_DISABLE, mp);
18535 mp->sw_if_index = ntohl (sw_if_index);
18536 mp->enable = enable;
18537 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
18538 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
18539 vec_free (arc_name);
18540 vec_free (feature_name);
18548 api_sw_interface_tag_add_del (vat_main_t * vam)
18550 unformat_input_t *i = vam->input;
18551 vl_api_sw_interface_tag_add_del_t *mp;
18552 u32 sw_if_index = ~0;
18557 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18559 if (unformat (i, "tag %s", &tag))
18561 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18563 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18565 else if (unformat (i, "del"))
18571 if (sw_if_index == ~0)
18573 errmsg ("missing interface name or sw_if_index");
18577 if (enable && (tag == 0))
18579 errmsg ("no tag specified");
18583 /* Construct the API message */
18584 M (SW_INTERFACE_TAG_ADD_DEL, mp);
18585 mp->sw_if_index = ntohl (sw_if_index);
18586 mp->is_add = enable;
18588 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
18596 static void vl_api_l2_xconnect_details_t_handler
18597 (vl_api_l2_xconnect_details_t * mp)
18599 vat_main_t *vam = &vat_main;
18601 print (vam->ofp, "%15d%15d",
18602 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
18605 static void vl_api_l2_xconnect_details_t_handler_json
18606 (vl_api_l2_xconnect_details_t * mp)
18608 vat_main_t *vam = &vat_main;
18609 vat_json_node_t *node = NULL;
18611 if (VAT_JSON_ARRAY != vam->json_tree.type)
18613 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18614 vat_json_init_array (&vam->json_tree);
18616 node = vat_json_array_add (&vam->json_tree);
18618 vat_json_init_object (node);
18619 vat_json_object_add_uint (node, "rx_sw_if_index",
18620 ntohl (mp->rx_sw_if_index));
18621 vat_json_object_add_uint (node, "tx_sw_if_index",
18622 ntohl (mp->tx_sw_if_index));
18626 api_l2_xconnect_dump (vat_main_t * vam)
18628 vl_api_l2_xconnect_dump_t *mp;
18629 vl_api_control_ping_t *mp_ping;
18632 if (!vam->json_output)
18634 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
18637 M (L2_XCONNECT_DUMP, mp);
18641 /* Use a control ping for synchronization */
18642 M (CONTROL_PING, mp_ping);
18650 api_sw_interface_set_mtu (vat_main_t * vam)
18652 unformat_input_t *i = vam->input;
18653 vl_api_sw_interface_set_mtu_t *mp;
18654 u32 sw_if_index = ~0;
18658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18660 if (unformat (i, "mtu %d", &mtu))
18662 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18664 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18670 if (sw_if_index == ~0)
18672 errmsg ("missing interface name or sw_if_index");
18678 errmsg ("no mtu specified");
18682 /* Construct the API message */
18683 M (SW_INTERFACE_SET_MTU, mp);
18684 mp->sw_if_index = ntohl (sw_if_index);
18685 mp->mtu = ntohs ((u16) mtu);
18694 q_or_quit (vat_main_t * vam)
18696 #if VPP_API_TEST_BUILTIN == 0
18697 longjmp (vam->jump_buf, 1);
18699 return 0; /* not so much */
18703 q (vat_main_t * vam)
18705 return q_or_quit (vam);
18709 quit (vat_main_t * vam)
18711 return q_or_quit (vam);
18715 comment (vat_main_t * vam)
18721 cmd_cmp (void *a1, void *a2)
18726 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
18730 help (vat_main_t * vam)
18735 unformat_input_t *i = vam->input;
18738 if (unformat (i, "%s", &name))
18742 vec_add1 (name, 0);
18744 hs = hash_get_mem (vam->help_by_name, name);
18746 print (vam->ofp, "usage: %s %s", name, hs[0]);
18748 print (vam->ofp, "No such msg / command '%s'", name);
18753 print (vam->ofp, "Help is available for the following:");
18756 hash_foreach_pair (p, vam->function_by_name,
18758 vec_add1 (cmds, (u8 *)(p->key));
18762 vec_sort_with_function (cmds, cmd_cmp);
18764 for (j = 0; j < vec_len (cmds); j++)
18765 print (vam->ofp, "%s", cmds[j]);
18772 set (vat_main_t * vam)
18774 u8 *name = 0, *value = 0;
18775 unformat_input_t *i = vam->input;
18777 if (unformat (i, "%s", &name))
18779 /* The input buffer is a vector, not a string. */
18780 value = vec_dup (i->buffer);
18781 vec_delete (value, i->index, 0);
18782 /* Almost certainly has a trailing newline */
18783 if (value[vec_len (value) - 1] == '\n')
18784 value[vec_len (value) - 1] = 0;
18785 /* Make sure it's a proper string, one way or the other */
18786 vec_add1 (value, 0);
18787 (void) clib_macro_set_value (&vam->macro_main,
18788 (char *) name, (char *) value);
18791 errmsg ("usage: set <name> <value>");
18799 unset (vat_main_t * vam)
18803 if (unformat (vam->input, "%s", &name))
18804 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
18805 errmsg ("unset: %s wasn't set", name);
18818 macro_sort_cmp (void *a1, void *a2)
18820 macro_sort_t *s1 = a1;
18821 macro_sort_t *s2 = a2;
18823 return strcmp ((char *) (s1->name), (char *) (s2->name));
18827 dump_macro_table (vat_main_t * vam)
18829 macro_sort_t *sort_me = 0, *sm;
18834 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
18836 vec_add2 (sort_me, sm, 1);
18837 sm->name = (u8 *)(p->key);
18838 sm->value = (u8 *) (p->value[0]);
18842 vec_sort_with_function (sort_me, macro_sort_cmp);
18844 if (vec_len (sort_me))
18845 print (vam->ofp, "%-15s%s", "Name", "Value");
18847 print (vam->ofp, "The macro table is empty...");
18849 for (i = 0; i < vec_len (sort_me); i++)
18850 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
18855 dump_node_table (vat_main_t * vam)
18858 vlib_node_t *node, *next_node;
18860 if (vec_len (vam->graph_nodes) == 0)
18862 print (vam->ofp, "Node table empty, issue get_node_graph...");
18866 for (i = 0; i < vec_len (vam->graph_nodes); i++)
18868 node = vam->graph_nodes[i];
18869 print (vam->ofp, "[%d] %s", i, node->name);
18870 for (j = 0; j < vec_len (node->next_nodes); j++)
18872 if (node->next_nodes[j] != ~0)
18874 next_node = vam->graph_nodes[node->next_nodes[j]];
18875 print (vam->ofp, " [%d] %s", j, next_node->name);
18883 value_sort_cmp (void *a1, void *a2)
18885 name_sort_t *n1 = a1;
18886 name_sort_t *n2 = a2;
18888 if (n1->value < n2->value)
18890 if (n1->value > n2->value)
18897 dump_msg_api_table (vat_main_t * vam)
18899 api_main_t *am = &api_main;
18900 name_sort_t *nses = 0, *ns;
18905 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
18907 vec_add2 (nses, ns, 1);
18908 ns->name = (u8 *)(hp->key);
18909 ns->value = (u32) hp->value[0];
18913 vec_sort_with_function (nses, value_sort_cmp);
18915 for (i = 0; i < vec_len (nses); i++)
18916 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
18922 get_msg_id (vat_main_t * vam)
18927 if (unformat (vam->input, "%s", &name_and_crc))
18929 message_index = vl_api_get_msg_index (name_and_crc);
18930 if (message_index == ~0)
18932 print (vam->ofp, " '%s' not found", name_and_crc);
18935 print (vam->ofp, " '%s' has message index %d",
18936 name_and_crc, message_index);
18939 errmsg ("name_and_crc required...");
18944 search_node_table (vat_main_t * vam)
18946 unformat_input_t *line_input = vam->input;
18949 vlib_node_t *node, *next_node;
18952 if (vam->graph_node_index_by_name == 0)
18954 print (vam->ofp, "Node table empty, issue get_node_graph...");
18958 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
18960 if (unformat (line_input, "%s", &node_to_find))
18962 vec_add1 (node_to_find, 0);
18963 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
18966 print (vam->ofp, "%s not found...", node_to_find);
18969 node = vam->graph_nodes[p[0]];
18970 print (vam->ofp, "[%d] %s", p[0], node->name);
18971 for (j = 0; j < vec_len (node->next_nodes); j++)
18973 if (node->next_nodes[j] != ~0)
18975 next_node = vam->graph_nodes[node->next_nodes[j]];
18976 print (vam->ofp, " [%d] %s", j, next_node->name);
18983 clib_warning ("parse error '%U'", format_unformat_error,
18989 vec_free (node_to_find);
18998 script (vat_main_t * vam)
19000 #if (VPP_API_TEST_BUILTIN==0)
19002 char *save_current_file;
19003 unformat_input_t save_input;
19004 jmp_buf save_jump_buf;
19005 u32 save_line_number;
19007 FILE *new_fp, *save_ifp;
19009 if (unformat (vam->input, "%s", &s))
19011 new_fp = fopen ((char *) s, "r");
19014 errmsg ("Couldn't open script file %s", s);
19021 errmsg ("Missing script name");
19025 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
19026 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
19027 save_ifp = vam->ifp;
19028 save_line_number = vam->input_line_number;
19029 save_current_file = (char *) vam->current_file;
19031 vam->input_line_number = 0;
19033 vam->current_file = s;
19036 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
19037 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
19038 vam->ifp = save_ifp;
19039 vam->input_line_number = save_line_number;
19040 vam->current_file = (u8 *) save_current_file;
19045 clib_warning ("use the exec command...");
19051 echo (vat_main_t * vam)
19053 print (vam->ofp, "%v", vam->input->buffer);
19057 /* List of API message constructors, CLI names map to api_xxx */
19058 #define foreach_vpe_api_msg \
19059 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
19060 _(sw_interface_dump,"") \
19061 _(sw_interface_set_flags, \
19062 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
19063 _(sw_interface_add_del_address, \
19064 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
19065 _(sw_interface_set_table, \
19066 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
19067 _(sw_interface_set_mpls_enable, \
19068 "<intfc> | sw_if_index [disable | dis]") \
19069 _(sw_interface_set_vpath, \
19070 "<intfc> | sw_if_index <id> enable | disable") \
19071 _(sw_interface_set_vxlan_bypass, \
19072 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
19073 _(sw_interface_set_l2_xconnect, \
19074 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
19075 "enable | disable") \
19076 _(sw_interface_set_l2_bridge, \
19077 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
19078 "[shg <split-horizon-group>] [bvi]\n" \
19079 "enable | disable") \
19080 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
19081 _(bridge_domain_add_del, \
19082 "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") \
19083 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
19085 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
19086 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
19087 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
19089 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
19091 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
19093 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
19095 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
19097 "<vpp-if-name> | sw_if_index <id>") \
19098 _(sw_interface_tap_dump, "") \
19099 _(ip_add_del_route, \
19100 "<addr>/<mask> via <addr> [table-id <n>]\n" \
19101 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
19102 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
19103 "[multipath] [count <n>]") \
19104 _(ip_mroute_add_del, \
19105 "<src> <grp>/<mask> [table-id <n>]\n" \
19106 "[<intfc> | sw_if_index <id>] [local] [del]") \
19107 _(mpls_route_add_del, \
19108 "<label> <eos> via <addr> [table-id <n>]\n" \
19109 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
19110 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
19111 "[multipath] [count <n>]") \
19112 _(mpls_ip_bind_unbind, \
19113 "<label> <addr/len>") \
19114 _(mpls_tunnel_add_del, \
19115 " via <addr> [table-id <n>]\n" \
19116 "sw_if_index <id>] [l2] [del]") \
19117 _(proxy_arp_add_del, \
19118 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
19119 _(proxy_arp_intfc_enable_disable, \
19120 "<intfc> | sw_if_index <id> enable | disable") \
19121 _(sw_interface_set_unnumbered, \
19122 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
19123 _(ip_neighbor_add_del, \
19124 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
19125 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
19126 _(reset_vrf, "vrf <id> [ipv6]") \
19127 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
19128 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
19129 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
19130 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
19131 "[outer_vlan_id_any][inner_vlan_id_any]") \
19132 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
19133 _(reset_fib, "vrf <n> [ipv6]") \
19134 _(dhcp_proxy_config, \
19135 "svr <v46-address> src <v46-address>\n" \
19136 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
19137 _(dhcp_proxy_set_vss, \
19138 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
19139 _(dhcp_proxy_dump, "ip6") \
19140 _(dhcp_client_config, \
19141 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
19142 _(set_ip_flow_hash, \
19143 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
19144 _(sw_interface_ip6_enable_disable, \
19145 "<intfc> | sw_if_index <id> enable | disable") \
19146 _(sw_interface_ip6_set_link_local_address, \
19147 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
19148 _(ip6nd_proxy_add_del, \
19149 "<intfc> | sw_if_index <id> <ip6-address>") \
19150 _(ip6nd_proxy_dump, "") \
19151 _(sw_interface_ip6nd_ra_prefix, \
19152 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
19153 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
19154 "[nolink] [isno]") \
19155 _(sw_interface_ip6nd_ra_config, \
19156 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
19157 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
19158 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
19159 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
19160 _(l2_patch_add_del, \
19161 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
19162 "enable | disable") \
19163 _(sr_localsid_add_del, \
19164 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
19165 "fib-table <num> (end.psp) sw_if_index <num>") \
19166 _(classify_add_del_table, \
19167 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
19168 " [del] [del-chain] mask <mask-value>\n" \
19169 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
19170 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
19171 _(classify_add_del_session, \
19172 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
19173 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
19174 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
19175 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
19176 _(classify_set_interface_ip_table, \
19177 "<intfc> | sw_if_index <nn> table <nn>") \
19178 _(classify_set_interface_l2_tables, \
19179 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19180 " [other-table <nn>]") \
19181 _(get_node_index, "node <node-name") \
19182 _(add_node_next, "node <node-name> next <next-node-name>") \
19183 _(l2tpv3_create_tunnel, \
19184 "client_address <ip6-addr> our_address <ip6-addr>\n" \
19185 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
19186 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
19187 _(l2tpv3_set_tunnel_cookies, \
19188 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
19189 "[new_remote_cookie <nn>]\n") \
19190 _(l2tpv3_interface_enable_disable, \
19191 "<intfc> | sw_if_index <nn> enable | disable") \
19192 _(l2tpv3_set_lookup_key, \
19193 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
19194 _(sw_if_l2tpv3_tunnel_dump, "") \
19195 _(vxlan_add_del_tunnel, \
19196 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
19197 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
19198 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
19199 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19200 _(gre_add_del_tunnel, \
19201 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
19202 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19203 _(l2_fib_clear_table, "") \
19204 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
19205 _(l2_interface_vlan_tag_rewrite, \
19206 "<intfc> | sw_if_index <nn> \n" \
19207 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
19208 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
19209 _(create_vhost_user_if, \
19210 "socket <filename> [server] [renumber <dev_instance>] " \
19211 "[mac <mac_address>]") \
19212 _(modify_vhost_user_if, \
19213 "<intfc> | sw_if_index <nn> socket <filename>\n" \
19214 "[server] [renumber <dev_instance>]") \
19215 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
19216 _(sw_interface_vhost_user_dump, "") \
19217 _(show_version, "") \
19218 _(vxlan_gpe_add_del_tunnel, \
19219 "local <addr> remote <addr> vni <nn>\n" \
19220 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
19221 "[next-ethernet] [next-nsh]\n") \
19222 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19223 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
19224 _(interface_name_renumber, \
19225 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
19226 _(input_acl_set_interface, \
19227 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19228 " [l2-table <nn>] [del]") \
19229 _(want_ip4_arp_events, "address <ip4-address> [del]") \
19230 _(want_ip6_nd_events, "address <ip6-address> [del]") \
19231 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
19232 _(ip_dump, "ipv4 | ipv6") \
19233 _(ipsec_spd_add_del, "spd_id <n> [del]") \
19234 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
19236 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
19237 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
19238 " integ_alg <alg> integ_key <hex>") \
19239 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
19240 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
19241 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
19242 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
19243 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
19244 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
19245 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
19246 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
19247 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
19248 _(ikev2_profile_add_del, "name <profile_name> [del]") \
19249 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
19250 "(auth_data 0x<data> | auth_data <data>)") \
19251 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
19252 "(id_data 0x<data> | id_data <data>) (local|remote)") \
19253 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
19254 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
19255 "(local|remote)") \
19256 _(ikev2_set_local_key, "file <absolute_file_path>") \
19257 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
19258 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
19259 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
19260 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
19261 _(ikev2_initiate_sa_init, "<profile_name>") \
19262 _(ikev2_initiate_del_ike_sa, "<ispi>") \
19263 _(ikev2_initiate_del_child_sa, "<ispi>") \
19264 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
19265 _(delete_loopback,"sw_if_index <nn>") \
19266 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
19267 _(map_add_domain, \
19268 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
19269 "ip6-src <ip6addr> " \
19270 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
19271 _(map_del_domain, "index <n>") \
19272 _(map_add_del_rule, \
19273 "index <n> psid <n> dst <ip6addr> [del]") \
19274 _(map_domain_dump, "") \
19275 _(map_rule_dump, "index <map-domain>") \
19276 _(want_interface_events, "enable|disable") \
19277 _(want_stats,"enable|disable") \
19278 _(get_first_msg_id, "client <name>") \
19279 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
19280 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
19281 "fib-id <nn> [ip4][ip6][default]") \
19282 _(get_node_graph, " ") \
19283 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
19284 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
19285 _(ioam_disable, "") \
19286 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
19287 " sw_if_index <sw_if_index> p <priority> " \
19288 "w <weight>] [del]") \
19289 _(one_add_del_locator, "locator-set <locator_name> " \
19290 "iface <intf> | sw_if_index <sw_if_index> " \
19291 "p <priority> w <weight> [del]") \
19292 _(one_add_del_local_eid,"vni <vni> eid " \
19293 "<ipv4|ipv6>/<prefix> | <L2 address> " \
19294 "locator-set <locator_name> [del]" \
19295 "[key-id sha1|sha256 secret-key <secret-key>]")\
19296 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
19297 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
19298 _(one_enable_disable, "enable|disable") \
19299 _(one_map_register_enable_disable, "enable|disable") \
19300 _(one_rloc_probe_enable_disable, "enable|disable") \
19301 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
19303 "rloc <locator> p <prio> " \
19304 "w <weight> [rloc <loc> ... ] " \
19305 "action <action> [del-all]") \
19306 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
19308 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
19309 _(one_use_petr, "ip-address> | disable") \
19310 _(one_map_request_mode, "src-dst|dst-only") \
19311 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
19312 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
19313 _(one_locator_set_dump, "[local | remote]") \
19314 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
19315 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
19316 "[local] | [remote]") \
19317 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
19318 _(one_l2_arp_bd_get, "") \
19319 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
19320 _(one_stats_enable_disable, "enable|disalbe") \
19321 _(show_one_stats_enable_disable, "") \
19322 _(one_eid_table_vni_dump, "") \
19323 _(one_eid_table_map_dump, "l2|l3") \
19324 _(one_map_resolver_dump, "") \
19325 _(one_map_server_dump, "") \
19326 _(one_adjacencies_get, "vni <vni>") \
19327 _(show_one_rloc_probe_state, "") \
19328 _(show_one_map_register_state, "") \
19329 _(show_one_status, "") \
19330 _(one_stats_dump, "") \
19331 _(one_stats_flush, "") \
19332 _(one_get_map_request_itr_rlocs, "") \
19333 _(show_one_pitr, "") \
19334 _(show_one_use_petr, "") \
19335 _(show_one_map_request_mode, "") \
19336 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
19337 " sw_if_index <sw_if_index> p <priority> " \
19338 "w <weight>] [del]") \
19339 _(lisp_add_del_locator, "locator-set <locator_name> " \
19340 "iface <intf> | sw_if_index <sw_if_index> " \
19341 "p <priority> w <weight> [del]") \
19342 _(lisp_add_del_local_eid,"vni <vni> eid " \
19343 "<ipv4|ipv6>/<prefix> | <L2 address> " \
19344 "locator-set <locator_name> [del]" \
19345 "[key-id sha1|sha256 secret-key <secret-key>]") \
19346 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
19347 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
19348 _(lisp_enable_disable, "enable|disable") \
19349 _(lisp_map_register_enable_disable, "enable|disable") \
19350 _(lisp_rloc_probe_enable_disable, "enable|disable") \
19351 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
19353 "rloc <locator> p <prio> " \
19354 "w <weight> [rloc <loc> ... ] " \
19355 "action <action> [del-all]") \
19356 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
19358 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
19359 _(lisp_use_petr, "<ip-address> | disable") \
19360 _(lisp_map_request_mode, "src-dst|dst-only") \
19361 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
19362 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
19363 _(lisp_locator_set_dump, "[local | remote]") \
19364 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
19365 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
19366 "[local] | [remote]") \
19367 _(lisp_eid_table_vni_dump, "") \
19368 _(lisp_eid_table_map_dump, "l2|l3") \
19369 _(lisp_map_resolver_dump, "") \
19370 _(lisp_map_server_dump, "") \
19371 _(lisp_adjacencies_get, "vni <vni>") \
19372 _(gpe_fwd_entry_vnis_get, "") \
19373 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
19374 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
19375 _(gpe_set_encap_mode, "lisp|vxlan") \
19376 _(gpe_get_encap_mode, "") \
19377 _(lisp_gpe_add_del_iface, "up|down") \
19378 _(lisp_gpe_enable_disable, "enable|disable") \
19379 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
19380 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
19381 _(show_lisp_rloc_probe_state, "") \
19382 _(show_lisp_map_register_state, "") \
19383 _(show_lisp_status, "") \
19384 _(lisp_get_map_request_itr_rlocs, "") \
19385 _(show_lisp_pitr, "") \
19386 _(show_lisp_use_petr, "") \
19387 _(show_lisp_map_request_mode, "") \
19388 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
19389 _(af_packet_delete, "name <host interface name>") \
19390 _(policer_add_del, "name <policer name> <params> [del]") \
19391 _(policer_dump, "[name <policer name>]") \
19392 _(policer_classify_set_interface, \
19393 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19394 " [l2-table <nn>] [del]") \
19395 _(policer_classify_dump, "type [ip4|ip6|l2]") \
19396 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
19397 "[master|slave]") \
19398 _(netmap_delete, "name <interface name>") \
19399 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
19400 _(mpls_fib_dump, "") \
19401 _(classify_table_ids, "") \
19402 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
19403 _(classify_table_info, "table_id <nn>") \
19404 _(classify_session_dump, "table_id <nn>") \
19405 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
19406 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
19407 "[template_interval <nn>] [udp_checksum]") \
19408 _(ipfix_exporter_dump, "") \
19409 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
19410 _(ipfix_classify_stream_dump, "") \
19411 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
19412 _(ipfix_classify_table_dump, "") \
19413 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
19414 _(sw_interface_span_dump, "") \
19415 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
19416 _(pg_create_interface, "if_id <nn>") \
19417 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
19418 _(pg_enable_disable, "[stream <id>] disable") \
19419 _(ip_source_and_port_range_check_add_del, \
19420 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
19421 _(ip_source_and_port_range_check_interface_add_del, \
19422 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
19423 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
19424 _(ipsec_gre_add_del_tunnel, \
19425 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
19426 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
19427 _(delete_subif,"<intfc> | sw_if_index <nn>") \
19428 _(l2_interface_pbb_tag_rewrite, \
19429 "<intfc> | sw_if_index <nn> \n" \
19430 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
19431 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
19432 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
19433 _(flow_classify_set_interface, \
19434 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
19435 _(flow_classify_dump, "type [ip4|ip6]") \
19436 _(ip_fib_dump, "") \
19437 _(ip_mfib_dump, "") \
19438 _(ip6_fib_dump, "") \
19439 _(ip6_mfib_dump, "") \
19440 _(feature_enable_disable, "arc_name <arc_name> " \
19441 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
19442 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
19444 _(l2_xconnect_dump, "") \
19445 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
19446 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
19447 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
19449 /* List of command functions, CLI names map directly to functions */
19450 #define foreach_cli_function \
19451 _(comment, "usage: comment <ignore-rest-of-line>") \
19452 _(dump_interface_table, "usage: dump_interface_table") \
19453 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
19454 _(dump_ipv4_table, "usage: dump_ipv4_table") \
19455 _(dump_ipv6_table, "usage: dump_ipv6_table") \
19456 _(dump_stats_table, "usage: dump_stats_table") \
19457 _(dump_macro_table, "usage: dump_macro_table ") \
19458 _(dump_node_table, "usage: dump_node_table") \
19459 _(dump_msg_api_table, "usage: dump_msg_api_table") \
19460 _(get_msg_id, "usage: get_msg_id name_and_crc") \
19461 _(echo, "usage: echo <message>") \
19462 _(exec, "usage: exec <vpe-debug-CLI-command>") \
19463 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
19464 _(help, "usage: help") \
19465 _(q, "usage: quit") \
19466 _(quit, "usage: quit") \
19467 _(search_node_table, "usage: search_node_table <name>...") \
19468 _(set, "usage: set <variable-name> <value>") \
19469 _(script, "usage: script <file-name>") \
19470 _(unset, "usage: unset <variable-name>")
19473 static void vl_api_##n##_t_handler_uni \
19474 (vl_api_##n##_t * mp) \
19476 vat_main_t * vam = &vat_main; \
19477 if (vam->json_output) { \
19478 vl_api_##n##_t_handler_json(mp); \
19480 vl_api_##n##_t_handler(mp); \
19483 foreach_vpe_api_reply_msg;
19484 #if VPP_API_TEST_BUILTIN == 0
19485 foreach_standalone_reply_msg;
19490 vat_api_hookup (vat_main_t * vam)
19493 vl_msg_api_set_handlers(VL_API_##N, #n, \
19494 vl_api_##n##_t_handler_uni, \
19496 vl_api_##n##_t_endian, \
19497 vl_api_##n##_t_print, \
19498 sizeof(vl_api_##n##_t), 1);
19499 foreach_vpe_api_reply_msg;
19500 #if VPP_API_TEST_BUILTIN == 0
19501 foreach_standalone_reply_msg;
19505 #if (VPP_API_TEST_BUILTIN==0)
19506 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
19508 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
19510 vam->function_by_name = hash_create_string (0, sizeof (uword));
19512 vam->help_by_name = hash_create_string (0, sizeof (uword));
19515 /* API messages we can send */
19516 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
19517 foreach_vpe_api_msg;
19521 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
19522 foreach_vpe_api_msg;
19525 /* CLI functions */
19526 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
19527 foreach_cli_function;
19531 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
19532 foreach_cli_function;
19536 #if VPP_API_TEST_BUILTIN
19537 static clib_error_t *
19538 vat_api_hookup_shim (vlib_main_t * vm)
19540 vat_api_hookup (&vat_main);
19544 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
19548 * fd.io coding-style-patch-verification: ON
19551 * eval: (c-set-style "gnu")