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) \
4449 _(p2p_ethernet_add_reply) \
4450 _(p2p_ethernet_del_reply)
4453 static void vl_api_##n##_t_handler \
4454 (vl_api_##n##_t * mp) \
4456 vat_main_t * vam = &vat_main; \
4457 i32 retval = ntohl(mp->retval); \
4458 if (vam->async_mode) { \
4459 vam->async_errors += (retval < 0); \
4461 vam->retval = retval; \
4462 vam->result_ready = 1; \
4465 foreach_standard_reply_retval_handler;
4469 static void vl_api_##n##_t_handler_json \
4470 (vl_api_##n##_t * mp) \
4472 vat_main_t * vam = &vat_main; \
4473 vat_json_node_t node; \
4474 vat_json_init_object(&node); \
4475 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4476 vat_json_print(vam->ofp, &node); \
4477 vam->retval = ntohl(mp->retval); \
4478 vam->result_ready = 1; \
4480 foreach_standard_reply_retval_handler;
4484 * Table of message reply handlers, must include boilerplate handlers
4488 #define foreach_vpe_api_reply_msg \
4489 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4490 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4491 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4492 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4493 _(CONTROL_PING_REPLY, control_ping_reply) \
4494 _(CLI_REPLY, cli_reply) \
4495 _(CLI_INBAND_REPLY, cli_inband_reply) \
4496 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4497 sw_interface_add_del_address_reply) \
4498 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4499 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4500 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4501 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4502 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4503 sw_interface_set_l2_xconnect_reply) \
4504 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4505 sw_interface_set_l2_bridge_reply) \
4506 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4507 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4508 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
4509 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4510 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
4511 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
4512 _(L2_FLAGS_REPLY, l2_flags_reply) \
4513 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4514 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4515 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4516 _(TAP_DELETE_REPLY, tap_delete_reply) \
4517 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4518 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4519 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4520 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4521 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4522 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4523 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4524 proxy_arp_intfc_enable_disable_reply) \
4525 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4526 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4527 sw_interface_set_unnumbered_reply) \
4528 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4529 _(RESET_VRF_REPLY, reset_vrf_reply) \
4530 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4531 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4532 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4533 _(RESET_FIB_REPLY, reset_fib_reply) \
4534 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4535 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4536 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4537 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4538 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4539 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4540 sw_interface_ip6_enable_disable_reply) \
4541 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4542 sw_interface_ip6_set_link_local_address_reply) \
4543 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
4544 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
4545 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4546 sw_interface_ip6nd_ra_prefix_reply) \
4547 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4548 sw_interface_ip6nd_ra_config_reply) \
4549 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4550 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4551 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4552 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4553 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4554 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4555 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4556 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4557 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4558 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4559 classify_set_interface_ip_table_reply) \
4560 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4561 classify_set_interface_l2_tables_reply) \
4562 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4563 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4564 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4565 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4566 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4567 l2tpv3_interface_enable_disable_reply) \
4568 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4569 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4570 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4571 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4572 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4573 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4574 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4575 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4576 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4577 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4578 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4579 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4580 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4581 _(SHOW_VERSION_REPLY, show_version_reply) \
4582 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
4583 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4584 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4585 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4586 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4587 _(IP4_ARP_EVENT, ip4_arp_event) \
4588 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4589 _(IP6_ND_EVENT, ip6_nd_event) \
4590 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4591 _(IP_ADDRESS_DETAILS, ip_address_details) \
4592 _(IP_DETAILS, ip_details) \
4593 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4594 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4595 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4596 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4597 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4598 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
4599 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4600 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4601 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4602 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4603 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4604 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4605 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4606 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4607 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4608 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4609 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4610 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4611 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4612 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4613 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4614 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4615 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4616 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4617 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4618 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4619 _(MAP_RULE_DETAILS, map_rule_details) \
4620 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4621 _(WANT_STATS_REPLY, want_stats_reply) \
4622 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4623 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4624 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4625 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4626 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4627 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4628 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4629 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4630 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4631 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4632 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4633 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4634 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4635 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4636 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4637 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4638 one_map_register_enable_disable_reply) \
4639 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4640 one_rloc_probe_enable_disable_reply) \
4641 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4642 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
4643 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4644 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4645 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4646 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4647 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4648 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4649 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4650 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4651 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4652 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4653 _(ONE_STATS_DETAILS, one_stats_details) \
4654 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
4655 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
4656 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
4657 show_one_stats_enable_disable_reply) \
4658 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
4659 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
4660 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
4661 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4662 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4663 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4664 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4665 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4666 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
4667 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4668 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4669 gpe_fwd_entry_path_details) \
4670 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4671 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4672 one_add_del_map_request_itr_rlocs_reply) \
4673 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4674 one_get_map_request_itr_rlocs_reply) \
4675 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4676 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
4677 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4678 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4679 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4680 show_one_map_register_state_reply) \
4681 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4682 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4683 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4684 _(POLICER_DETAILS, policer_details) \
4685 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4686 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4687 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4688 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4689 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4690 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4691 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4692 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4693 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4694 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4695 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4696 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4697 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4698 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4699 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4700 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4701 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4702 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4703 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4704 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4705 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4706 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4707 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4708 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4709 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4710 ip_source_and_port_range_check_add_del_reply) \
4711 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4712 ip_source_and_port_range_check_interface_add_del_reply) \
4713 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4714 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4715 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4716 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4717 _(PUNT_REPLY, punt_reply) \
4718 _(IP_FIB_DETAILS, ip_fib_details) \
4719 _(IP6_FIB_DETAILS, ip6_fib_details) \
4720 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4721 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4722 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4723 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4724 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4725 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
4726 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
4727 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply)
4729 #define foreach_standalone_reply_msg \
4730 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4731 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
4732 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
4733 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4734 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4735 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4736 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
4745 #define STR_VTR_OP_CASE(op) \
4746 case L2_VTR_ ## op: \
4750 str_vtr_op (u32 vtr_op)
4754 STR_VTR_OP_CASE (DISABLED);
4755 STR_VTR_OP_CASE (PUSH_1);
4756 STR_VTR_OP_CASE (PUSH_2);
4757 STR_VTR_OP_CASE (POP_1);
4758 STR_VTR_OP_CASE (POP_2);
4759 STR_VTR_OP_CASE (TRANSLATE_1_1);
4760 STR_VTR_OP_CASE (TRANSLATE_1_2);
4761 STR_VTR_OP_CASE (TRANSLATE_2_1);
4762 STR_VTR_OP_CASE (TRANSLATE_2_2);
4769 dump_sub_interface_table (vat_main_t * vam)
4771 const sw_interface_subif_t *sub = NULL;
4773 if (vam->json_output)
4776 ("JSON output supported only for VPE API calls and dump_stats_table");
4781 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4782 "Interface", "sw_if_index",
4783 "sub id", "dot1ad", "tags", "outer id",
4784 "inner id", "exact", "default", "outer any", "inner any");
4786 vec_foreach (sub, vam->sw_if_subif_table)
4789 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4790 sub->interface_name,
4792 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4793 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4794 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4795 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4796 if (sub->vtr_op != L2_VTR_DISABLED)
4799 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4800 "tag1: %d tag2: %d ]",
4801 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4802 sub->vtr_tag1, sub->vtr_tag2);
4810 name_sort_cmp (void *a1, void *a2)
4812 name_sort_t *n1 = a1;
4813 name_sort_t *n2 = a2;
4815 return strcmp ((char *) n1->name, (char *) n2->name);
4819 dump_interface_table (vat_main_t * vam)
4822 name_sort_t *nses = 0, *ns;
4824 if (vam->json_output)
4827 ("JSON output supported only for VPE API calls and dump_stats_table");
4832 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4834 vec_add2 (nses, ns, 1);
4835 ns->name = (u8 *)(p->key);
4836 ns->value = (u32) p->value[0];
4840 vec_sort_with_function (nses, name_sort_cmp);
4842 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4843 vec_foreach (ns, nses)
4845 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4852 dump_ip_table (vat_main_t * vam, int is_ipv6)
4854 const ip_details_t *det = NULL;
4855 const ip_address_details_t *address = NULL;
4858 print (vam->ofp, "%-12s", "sw_if_index");
4860 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4867 print (vam->ofp, "%-12d", i);
4868 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4873 vec_foreach (address, det->addr)
4877 is_ipv6 ? format_ip6_address : format_ip4_address,
4878 address->ip, address->prefix_length);
4886 dump_ipv4_table (vat_main_t * vam)
4888 if (vam->json_output)
4891 ("JSON output supported only for VPE API calls and dump_stats_table");
4895 return dump_ip_table (vam, 0);
4899 dump_ipv6_table (vat_main_t * vam)
4901 if (vam->json_output)
4904 ("JSON output supported only for VPE API calls and dump_stats_table");
4908 return dump_ip_table (vam, 1);
4912 counter_type_to_str (u8 counter_type, u8 is_combined)
4916 switch (counter_type)
4918 case VNET_INTERFACE_COUNTER_DROP:
4920 case VNET_INTERFACE_COUNTER_PUNT:
4922 case VNET_INTERFACE_COUNTER_IP4:
4924 case VNET_INTERFACE_COUNTER_IP6:
4926 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4928 case VNET_INTERFACE_COUNTER_RX_MISS:
4930 case VNET_INTERFACE_COUNTER_RX_ERROR:
4932 case VNET_INTERFACE_COUNTER_TX_ERROR:
4935 return "INVALID-COUNTER-TYPE";
4940 switch (counter_type)
4942 case VNET_INTERFACE_COUNTER_RX:
4944 case VNET_INTERFACE_COUNTER_TX:
4947 return "INVALID-COUNTER-TYPE";
4953 dump_stats_table (vat_main_t * vam)
4955 vat_json_node_t node;
4956 vat_json_node_t *msg_array;
4957 vat_json_node_t *msg;
4958 vat_json_node_t *counter_array;
4959 vat_json_node_t *counter;
4960 interface_counter_t c;
4962 ip4_fib_counter_t *c4;
4963 ip6_fib_counter_t *c6;
4964 ip4_nbr_counter_t *n4;
4965 ip6_nbr_counter_t *n6;
4968 if (!vam->json_output)
4970 clib_warning ("dump_stats_table supported only in JSON format");
4974 vat_json_init_object (&node);
4976 /* interface counters */
4977 msg_array = vat_json_object_add (&node, "interface_counters");
4978 vat_json_init_array (msg_array);
4979 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4981 msg = vat_json_array_add (msg_array);
4982 vat_json_init_object (msg);
4983 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4984 (u8 *) counter_type_to_str (i, 0));
4985 vat_json_object_add_int (msg, "is_combined", 0);
4986 counter_array = vat_json_object_add (msg, "data");
4987 vat_json_init_array (counter_array);
4988 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4990 packets = vam->simple_interface_counters[i][j];
4991 vat_json_array_add_uint (counter_array, packets);
4994 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4996 msg = vat_json_array_add (msg_array);
4997 vat_json_init_object (msg);
4998 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4999 (u8 *) counter_type_to_str (i, 1));
5000 vat_json_object_add_int (msg, "is_combined", 1);
5001 counter_array = vat_json_object_add (msg, "data");
5002 vat_json_init_array (counter_array);
5003 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5005 c = vam->combined_interface_counters[i][j];
5006 counter = vat_json_array_add (counter_array);
5007 vat_json_init_object (counter);
5008 vat_json_object_add_uint (counter, "packets", c.packets);
5009 vat_json_object_add_uint (counter, "bytes", c.bytes);
5013 /* ip4 fib counters */
5014 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5015 vat_json_init_array (msg_array);
5016 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5018 msg = vat_json_array_add (msg_array);
5019 vat_json_init_object (msg);
5020 vat_json_object_add_uint (msg, "vrf_id",
5021 vam->ip4_fib_counters_vrf_id_by_index[i]);
5022 counter_array = vat_json_object_add (msg, "c");
5023 vat_json_init_array (counter_array);
5024 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5026 counter = vat_json_array_add (counter_array);
5027 vat_json_init_object (counter);
5028 c4 = &vam->ip4_fib_counters[i][j];
5029 vat_json_object_add_ip4 (counter, "address", c4->address);
5030 vat_json_object_add_uint (counter, "address_length",
5031 c4->address_length);
5032 vat_json_object_add_uint (counter, "packets", c4->packets);
5033 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5037 /* ip6 fib counters */
5038 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5039 vat_json_init_array (msg_array);
5040 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5042 msg = vat_json_array_add (msg_array);
5043 vat_json_init_object (msg);
5044 vat_json_object_add_uint (msg, "vrf_id",
5045 vam->ip6_fib_counters_vrf_id_by_index[i]);
5046 counter_array = vat_json_object_add (msg, "c");
5047 vat_json_init_array (counter_array);
5048 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5050 counter = vat_json_array_add (counter_array);
5051 vat_json_init_object (counter);
5052 c6 = &vam->ip6_fib_counters[i][j];
5053 vat_json_object_add_ip6 (counter, "address", c6->address);
5054 vat_json_object_add_uint (counter, "address_length",
5055 c6->address_length);
5056 vat_json_object_add_uint (counter, "packets", c6->packets);
5057 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5061 /* ip4 nbr counters */
5062 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5063 vat_json_init_array (msg_array);
5064 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5066 msg = vat_json_array_add (msg_array);
5067 vat_json_init_object (msg);
5068 vat_json_object_add_uint (msg, "sw_if_index", i);
5069 counter_array = vat_json_object_add (msg, "c");
5070 vat_json_init_array (counter_array);
5071 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5073 counter = vat_json_array_add (counter_array);
5074 vat_json_init_object (counter);
5075 n4 = &vam->ip4_nbr_counters[i][j];
5076 vat_json_object_add_ip4 (counter, "address", n4->address);
5077 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5078 vat_json_object_add_uint (counter, "packets", n4->packets);
5079 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5083 /* ip6 nbr counters */
5084 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5085 vat_json_init_array (msg_array);
5086 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5088 msg = vat_json_array_add (msg_array);
5089 vat_json_init_object (msg);
5090 vat_json_object_add_uint (msg, "sw_if_index", i);
5091 counter_array = vat_json_object_add (msg, "c");
5092 vat_json_init_array (counter_array);
5093 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5095 counter = vat_json_array_add (counter_array);
5096 vat_json_init_object (counter);
5097 n6 = &vam->ip6_nbr_counters[i][j];
5098 vat_json_object_add_ip6 (counter, "address", n6->address);
5099 vat_json_object_add_uint (counter, "packets", n6->packets);
5100 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5104 vat_json_print (vam->ofp, &node);
5105 vat_json_free (&node);
5111 exec (vat_main_t * vam)
5113 api_main_t *am = &api_main;
5118 unformat_input_t *i = vam->input;
5120 if (vec_len (i->buffer) == 0)
5123 if (vam->exec_mode == 0 && unformat (i, "mode"))
5128 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5138 * Copy cmd into shared memory.
5139 * In order for the CLI command to work, it
5140 * must be a vector ending in \n, not a C-string ending
5143 pthread_mutex_lock (&am->vlib_rp->mutex);
5144 oldheap = svm_push_data_heap (am->vlib_rp);
5146 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
5147 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
5149 svm_pop_heap (oldheap);
5150 pthread_mutex_unlock (&am->vlib_rp->mutex);
5152 mp->cmd_in_shmem = pointer_to_uword (cmd);
5154 timeout = vat_time_now (vam) + 10.0;
5156 while (vat_time_now (vam) < timeout)
5158 if (vam->result_ready == 1)
5161 if (vam->shmem_result != NULL)
5162 print (vam->ofp, "%s", vam->shmem_result);
5163 pthread_mutex_lock (&am->vlib_rp->mutex);
5164 oldheap = svm_push_data_heap (am->vlib_rp);
5166 free_me = (u8 *) vam->shmem_result;
5169 svm_pop_heap (oldheap);
5170 pthread_mutex_unlock (&am->vlib_rp->mutex);
5178 * Future replacement of exec() that passes CLI buffers directly in
5179 * the API messages instead of an additional shared memory area.
5182 exec_inband (vat_main_t * vam)
5184 vl_api_cli_inband_t *mp;
5185 unformat_input_t *i = vam->input;
5188 if (vec_len (i->buffer) == 0)
5191 if (vam->exec_mode == 0 && unformat (i, "mode"))
5196 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5203 * In order for the CLI command to work, it
5204 * must be a vector ending in \n, not a C-string ending
5207 u32 len = vec_len (vam->input->buffer);
5208 M2 (CLI_INBAND, mp, len);
5209 clib_memcpy (mp->cmd, vam->input->buffer, len);
5210 mp->length = htonl (len);
5213 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
5218 api_create_loopback (vat_main_t * vam)
5220 unformat_input_t *i = vam->input;
5221 vl_api_create_loopback_t *mp;
5222 vl_api_create_loopback_instance_t *mp_lbi;
5225 u8 is_specified = 0;
5226 u32 user_instance = 0;
5229 memset (mac_address, 0, sizeof (mac_address));
5231 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5233 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5235 if (unformat (i, "instance %d", &user_instance))
5243 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5244 mp_lbi->is_specified = is_specified;
5246 mp_lbi->user_instance = htonl (user_instance);
5248 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5253 /* Construct the API message */
5254 M (CREATE_LOOPBACK, mp);
5256 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5265 api_delete_loopback (vat_main_t * vam)
5267 unformat_input_t *i = vam->input;
5268 vl_api_delete_loopback_t *mp;
5269 u32 sw_if_index = ~0;
5272 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5274 if (unformat (i, "sw_if_index %d", &sw_if_index))
5280 if (sw_if_index == ~0)
5282 errmsg ("missing sw_if_index");
5286 /* Construct the API message */
5287 M (DELETE_LOOPBACK, mp);
5288 mp->sw_if_index = ntohl (sw_if_index);
5296 api_want_stats (vat_main_t * vam)
5298 unformat_input_t *i = vam->input;
5299 vl_api_want_stats_t *mp;
5303 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5305 if (unformat (i, "enable"))
5307 else if (unformat (i, "disable"))
5315 errmsg ("missing enable|disable");
5320 mp->enable_disable = enable;
5328 api_want_interface_events (vat_main_t * vam)
5330 unformat_input_t *i = vam->input;
5331 vl_api_want_interface_events_t *mp;
5335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5337 if (unformat (i, "enable"))
5339 else if (unformat (i, "disable"))
5347 errmsg ("missing enable|disable");
5351 M (WANT_INTERFACE_EVENTS, mp);
5352 mp->enable_disable = enable;
5354 vam->interface_event_display = enable;
5362 /* Note: non-static, called once to set up the initial intfc table */
5364 api_sw_interface_dump (vat_main_t * vam)
5366 vl_api_sw_interface_dump_t *mp;
5367 vl_api_control_ping_t *mp_ping;
5369 name_sort_t *nses = 0, *ns;
5370 sw_interface_subif_t *sub = NULL;
5373 /* Toss the old name table */
5375 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5377 vec_add2 (nses, ns, 1);
5378 ns->name = (u8 *)(p->key);
5379 ns->value = (u32) p->value[0];
5383 hash_free (vam->sw_if_index_by_interface_name);
5385 vec_foreach (ns, nses) vec_free (ns->name);
5389 vec_foreach (sub, vam->sw_if_subif_table)
5391 vec_free (sub->interface_name);
5393 vec_free (vam->sw_if_subif_table);
5395 /* recreate the interface name hash table */
5396 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5398 /* Get list of ethernets */
5399 M (SW_INTERFACE_DUMP, mp);
5400 mp->name_filter_valid = 1;
5401 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
5404 /* and local / loopback interfaces */
5405 M (SW_INTERFACE_DUMP, mp);
5406 mp->name_filter_valid = 1;
5407 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
5410 /* and packet-generator interfaces */
5411 M (SW_INTERFACE_DUMP, mp);
5412 mp->name_filter_valid = 1;
5413 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
5416 /* and vxlan-gpe tunnel interfaces */
5417 M (SW_INTERFACE_DUMP, mp);
5418 mp->name_filter_valid = 1;
5419 strncpy ((char *) mp->name_filter, "vxlan_gpe",
5420 sizeof (mp->name_filter) - 1);
5423 /* and vxlan tunnel interfaces */
5424 M (SW_INTERFACE_DUMP, mp);
5425 mp->name_filter_valid = 1;
5426 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
5429 /* and host (af_packet) interfaces */
5430 M (SW_INTERFACE_DUMP, mp);
5431 mp->name_filter_valid = 1;
5432 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
5435 /* and l2tpv3 tunnel interfaces */
5436 M (SW_INTERFACE_DUMP, mp);
5437 mp->name_filter_valid = 1;
5438 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
5439 sizeof (mp->name_filter) - 1);
5442 /* and GRE tunnel interfaces */
5443 M (SW_INTERFACE_DUMP, mp);
5444 mp->name_filter_valid = 1;
5445 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
5448 /* and LISP-GPE interfaces */
5449 M (SW_INTERFACE_DUMP, mp);
5450 mp->name_filter_valid = 1;
5451 strncpy ((char *) mp->name_filter, "lisp_gpe",
5452 sizeof (mp->name_filter) - 1);
5455 /* and IPSEC tunnel interfaces */
5456 M (SW_INTERFACE_DUMP, mp);
5457 mp->name_filter_valid = 1;
5458 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
5461 /* Use a control ping for synchronization */
5462 M (CONTROL_PING, mp_ping);
5470 api_sw_interface_set_flags (vat_main_t * vam)
5472 unformat_input_t *i = vam->input;
5473 vl_api_sw_interface_set_flags_t *mp;
5475 u8 sw_if_index_set = 0;
5476 u8 admin_up = 0, link_up = 0;
5479 /* Parse args required to build the message */
5480 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5482 if (unformat (i, "admin-up"))
5484 else if (unformat (i, "admin-down"))
5486 else if (unformat (i, "link-up"))
5488 else if (unformat (i, "link-down"))
5491 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5492 sw_if_index_set = 1;
5493 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5494 sw_if_index_set = 1;
5499 if (sw_if_index_set == 0)
5501 errmsg ("missing interface name or sw_if_index");
5505 /* Construct the API message */
5506 M (SW_INTERFACE_SET_FLAGS, mp);
5507 mp->sw_if_index = ntohl (sw_if_index);
5508 mp->admin_up_down = admin_up;
5509 mp->link_up_down = link_up;
5514 /* Wait for a reply, return the good/bad news... */
5520 api_sw_interface_clear_stats (vat_main_t * vam)
5522 unformat_input_t *i = vam->input;
5523 vl_api_sw_interface_clear_stats_t *mp;
5525 u8 sw_if_index_set = 0;
5528 /* Parse args required to build the message */
5529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5531 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5532 sw_if_index_set = 1;
5533 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5534 sw_if_index_set = 1;
5539 /* Construct the API message */
5540 M (SW_INTERFACE_CLEAR_STATS, mp);
5542 if (sw_if_index_set == 1)
5543 mp->sw_if_index = ntohl (sw_if_index);
5545 mp->sw_if_index = ~0;
5550 /* Wait for a reply, return the good/bad news... */
5556 api_sw_interface_add_del_address (vat_main_t * vam)
5558 unformat_input_t *i = vam->input;
5559 vl_api_sw_interface_add_del_address_t *mp;
5561 u8 sw_if_index_set = 0;
5562 u8 is_add = 1, del_all = 0;
5563 u32 address_length = 0;
5564 u8 v4_address_set = 0;
5565 u8 v6_address_set = 0;
5566 ip4_address_t v4address;
5567 ip6_address_t v6address;
5570 /* Parse args required to build the message */
5571 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5573 if (unformat (i, "del-all"))
5575 else if (unformat (i, "del"))
5578 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5579 sw_if_index_set = 1;
5580 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5581 sw_if_index_set = 1;
5582 else if (unformat (i, "%U/%d",
5583 unformat_ip4_address, &v4address, &address_length))
5585 else if (unformat (i, "%U/%d",
5586 unformat_ip6_address, &v6address, &address_length))
5592 if (sw_if_index_set == 0)
5594 errmsg ("missing interface name or sw_if_index");
5597 if (v4_address_set && v6_address_set)
5599 errmsg ("both v4 and v6 addresses set");
5602 if (!v4_address_set && !v6_address_set && !del_all)
5604 errmsg ("no addresses set");
5608 /* Construct the API message */
5609 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5611 mp->sw_if_index = ntohl (sw_if_index);
5612 mp->is_add = is_add;
5613 mp->del_all = del_all;
5617 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5621 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5623 mp->address_length = address_length;
5628 /* Wait for a reply, return good/bad news */
5634 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5636 unformat_input_t *i = vam->input;
5637 vl_api_sw_interface_set_mpls_enable_t *mp;
5639 u8 sw_if_index_set = 0;
5643 /* Parse args required to build the message */
5644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5646 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5647 sw_if_index_set = 1;
5648 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5649 sw_if_index_set = 1;
5650 else if (unformat (i, "disable"))
5652 else if (unformat (i, "dis"))
5658 if (sw_if_index_set == 0)
5660 errmsg ("missing interface name or sw_if_index");
5664 /* Construct the API message */
5665 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5667 mp->sw_if_index = ntohl (sw_if_index);
5668 mp->enable = enable;
5673 /* Wait for a reply... */
5679 api_sw_interface_set_table (vat_main_t * vam)
5681 unformat_input_t *i = vam->input;
5682 vl_api_sw_interface_set_table_t *mp;
5683 u32 sw_if_index, vrf_id = 0;
5684 u8 sw_if_index_set = 0;
5688 /* Parse args required to build the message */
5689 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5691 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5692 sw_if_index_set = 1;
5693 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5694 sw_if_index_set = 1;
5695 else if (unformat (i, "vrf %d", &vrf_id))
5697 else if (unformat (i, "ipv6"))
5703 if (sw_if_index_set == 0)
5705 errmsg ("missing interface name or sw_if_index");
5709 /* Construct the API message */
5710 M (SW_INTERFACE_SET_TABLE, mp);
5712 mp->sw_if_index = ntohl (sw_if_index);
5713 mp->is_ipv6 = is_ipv6;
5714 mp->vrf_id = ntohl (vrf_id);
5719 /* Wait for a reply... */
5724 static void vl_api_sw_interface_get_table_reply_t_handler
5725 (vl_api_sw_interface_get_table_reply_t * mp)
5727 vat_main_t *vam = &vat_main;
5729 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5731 vam->retval = ntohl (mp->retval);
5732 vam->result_ready = 1;
5736 static void vl_api_sw_interface_get_table_reply_t_handler_json
5737 (vl_api_sw_interface_get_table_reply_t * mp)
5739 vat_main_t *vam = &vat_main;
5740 vat_json_node_t node;
5742 vat_json_init_object (&node);
5743 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5744 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5746 vat_json_print (vam->ofp, &node);
5747 vat_json_free (&node);
5749 vam->retval = ntohl (mp->retval);
5750 vam->result_ready = 1;
5754 api_sw_interface_get_table (vat_main_t * vam)
5756 unformat_input_t *i = vam->input;
5757 vl_api_sw_interface_get_table_t *mp;
5759 u8 sw_if_index_set = 0;
5763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5765 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5766 sw_if_index_set = 1;
5767 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5768 sw_if_index_set = 1;
5769 else if (unformat (i, "ipv6"))
5775 if (sw_if_index_set == 0)
5777 errmsg ("missing interface name or sw_if_index");
5781 M (SW_INTERFACE_GET_TABLE, mp);
5782 mp->sw_if_index = htonl (sw_if_index);
5783 mp->is_ipv6 = is_ipv6;
5791 api_sw_interface_set_vpath (vat_main_t * vam)
5793 unformat_input_t *i = vam->input;
5794 vl_api_sw_interface_set_vpath_t *mp;
5795 u32 sw_if_index = 0;
5796 u8 sw_if_index_set = 0;
5800 /* Parse args required to build the message */
5801 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5803 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5804 sw_if_index_set = 1;
5805 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5806 sw_if_index_set = 1;
5807 else if (unformat (i, "enable"))
5809 else if (unformat (i, "disable"))
5815 if (sw_if_index_set == 0)
5817 errmsg ("missing interface name or sw_if_index");
5821 /* Construct the API message */
5822 M (SW_INTERFACE_SET_VPATH, mp);
5824 mp->sw_if_index = ntohl (sw_if_index);
5825 mp->enable = is_enable;
5830 /* Wait for a reply... */
5836 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5838 unformat_input_t *i = vam->input;
5839 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5840 u32 sw_if_index = 0;
5841 u8 sw_if_index_set = 0;
5846 /* Parse args required to build the message */
5847 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5849 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5850 sw_if_index_set = 1;
5851 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5852 sw_if_index_set = 1;
5853 else if (unformat (i, "enable"))
5855 else if (unformat (i, "disable"))
5857 else if (unformat (i, "ip4"))
5859 else if (unformat (i, "ip6"))
5865 if (sw_if_index_set == 0)
5867 errmsg ("missing interface name or sw_if_index");
5871 /* Construct the API message */
5872 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5874 mp->sw_if_index = ntohl (sw_if_index);
5875 mp->enable = is_enable;
5876 mp->is_ipv6 = is_ipv6;
5881 /* Wait for a reply... */
5887 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5889 unformat_input_t *i = vam->input;
5890 vl_api_sw_interface_set_l2_xconnect_t *mp;
5892 u8 rx_sw_if_index_set = 0;
5894 u8 tx_sw_if_index_set = 0;
5898 /* Parse args required to build the message */
5899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5901 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5902 rx_sw_if_index_set = 1;
5903 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5904 tx_sw_if_index_set = 1;
5905 else if (unformat (i, "rx"))
5907 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5909 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5911 rx_sw_if_index_set = 1;
5916 else if (unformat (i, "tx"))
5918 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5920 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5922 tx_sw_if_index_set = 1;
5927 else if (unformat (i, "enable"))
5929 else if (unformat (i, "disable"))
5935 if (rx_sw_if_index_set == 0)
5937 errmsg ("missing rx interface name or rx_sw_if_index");
5941 if (enable && (tx_sw_if_index_set == 0))
5943 errmsg ("missing tx interface name or tx_sw_if_index");
5947 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5949 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5950 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5951 mp->enable = enable;
5959 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5961 unformat_input_t *i = vam->input;
5962 vl_api_sw_interface_set_l2_bridge_t *mp;
5964 u8 rx_sw_if_index_set = 0;
5972 /* Parse args required to build the message */
5973 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5975 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5976 rx_sw_if_index_set = 1;
5977 else if (unformat (i, "bd_id %d", &bd_id))
5981 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5982 rx_sw_if_index_set = 1;
5983 else if (unformat (i, "shg %d", &shg))
5985 else if (unformat (i, "bvi"))
5987 else if (unformat (i, "enable"))
5989 else if (unformat (i, "disable"))
5995 if (rx_sw_if_index_set == 0)
5997 errmsg ("missing rx interface name or sw_if_index");
6001 if (enable && (bd_id_set == 0))
6003 errmsg ("missing bridge domain");
6007 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6009 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6010 mp->bd_id = ntohl (bd_id);
6013 mp->enable = enable;
6021 api_bridge_domain_dump (vat_main_t * vam)
6023 unformat_input_t *i = vam->input;
6024 vl_api_bridge_domain_dump_t *mp;
6025 vl_api_control_ping_t *mp_ping;
6029 /* Parse args required to build the message */
6030 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6032 if (unformat (i, "bd_id %d", &bd_id))
6038 M (BRIDGE_DOMAIN_DUMP, mp);
6039 mp->bd_id = ntohl (bd_id);
6042 /* Use a control ping for synchronization */
6043 M (CONTROL_PING, mp_ping);
6051 api_bridge_domain_add_del (vat_main_t * vam)
6053 unformat_input_t *i = vam->input;
6054 vl_api_bridge_domain_add_del_t *mp;
6057 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6061 /* Parse args required to build the message */
6062 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6064 if (unformat (i, "bd_id %d", &bd_id))
6066 else if (unformat (i, "flood %d", &flood))
6068 else if (unformat (i, "uu-flood %d", &uu_flood))
6070 else if (unformat (i, "forward %d", &forward))
6072 else if (unformat (i, "learn %d", &learn))
6074 else if (unformat (i, "arp-term %d", &arp_term))
6076 else if (unformat (i, "mac-age %d", &mac_age))
6078 else if (unformat (i, "del"))
6081 flood = uu_flood = forward = learn = 0;
6089 errmsg ("missing bridge domain");
6095 errmsg ("mac age must be less than 256 ");
6099 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6101 mp->bd_id = ntohl (bd_id);
6103 mp->uu_flood = uu_flood;
6104 mp->forward = forward;
6106 mp->arp_term = arp_term;
6107 mp->is_add = is_add;
6108 mp->mac_age = (u8) mac_age;
6116 api_l2fib_flush_bd (vat_main_t * vam)
6118 unformat_input_t *i = vam->input;
6119 vl_api_l2fib_flush_bd_t *mp;
6123 /* Parse args required to build the message */
6124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6126 if (unformat (i, "bd_id %d", &bd_id));
6133 errmsg ("missing bridge domain");
6137 M (L2FIB_FLUSH_BD, mp);
6139 mp->bd_id = htonl (bd_id);
6147 api_l2fib_flush_int (vat_main_t * vam)
6149 unformat_input_t *i = vam->input;
6150 vl_api_l2fib_flush_int_t *mp;
6151 u32 sw_if_index = ~0;
6154 /* Parse args required to build the message */
6155 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6157 if (unformat (i, "sw_if_index %d", &sw_if_index));
6159 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6164 if (sw_if_index == ~0)
6166 errmsg ("missing interface name or sw_if_index");
6170 M (L2FIB_FLUSH_INT, mp);
6172 mp->sw_if_index = ntohl (sw_if_index);
6180 api_l2fib_add_del (vat_main_t * vam)
6182 unformat_input_t *i = vam->input;
6183 vl_api_l2fib_add_del_t *mp;
6189 u32 sw_if_index = ~0;
6190 u8 sw_if_index_set = 0;
6199 /* Parse args required to build the message */
6200 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6202 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6204 else if (unformat (i, "bd_id %d", &bd_id))
6206 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6207 sw_if_index_set = 1;
6208 else if (unformat (i, "sw_if"))
6210 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6213 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6214 sw_if_index_set = 1;
6219 else if (unformat (i, "static"))
6221 else if (unformat (i, "filter"))
6226 else if (unformat (i, "bvi"))
6231 else if (unformat (i, "del"))
6233 else if (unformat (i, "count %d", &count))
6241 errmsg ("missing mac address");
6247 errmsg ("missing bridge domain");
6251 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6253 errmsg ("missing interface name or sw_if_index");
6259 /* Turn on async mode */
6260 vam->async_mode = 1;
6261 vam->async_errors = 0;
6262 before = vat_time_now (vam);
6265 for (j = 0; j < count; j++)
6267 M (L2FIB_ADD_DEL, mp);
6270 mp->bd_id = ntohl (bd_id);
6271 mp->is_add = is_add;
6275 mp->sw_if_index = ntohl (sw_if_index);
6276 mp->static_mac = static_mac;
6277 mp->filter_mac = filter_mac;
6278 mp->bvi_mac = bvi_mac;
6280 increment_mac_address (&mac);
6287 vl_api_control_ping_t *mp_ping;
6290 /* Shut off async mode */
6291 vam->async_mode = 0;
6293 M (CONTROL_PING, mp_ping);
6296 timeout = vat_time_now (vam) + 1.0;
6297 while (vat_time_now (vam) < timeout)
6298 if (vam->result_ready == 1)
6303 if (vam->retval == -99)
6306 if (vam->async_errors > 0)
6308 errmsg ("%d asynchronous errors", vam->async_errors);
6311 vam->async_errors = 0;
6312 after = vat_time_now (vam);
6314 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6315 count, after - before, count / (after - before));
6321 /* Wait for a reply... */
6325 /* Return the good/bad news */
6326 return (vam->retval);
6330 api_bridge_domain_set_mac_age (vat_main_t * vam)
6332 unformat_input_t *i = vam->input;
6333 vl_api_bridge_domain_set_mac_age_t *mp;
6338 /* Parse args required to build the message */
6339 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6341 if (unformat (i, "bd_id %d", &bd_id));
6342 else if (unformat (i, "mac-age %d", &mac_age));
6349 errmsg ("missing bridge domain");
6355 errmsg ("mac age must be less than 256 ");
6359 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6361 mp->bd_id = htonl (bd_id);
6362 mp->mac_age = (u8) mac_age;
6370 api_l2_flags (vat_main_t * vam)
6372 unformat_input_t *i = vam->input;
6373 vl_api_l2_flags_t *mp;
6375 u32 feature_bitmap = 0;
6376 u8 sw_if_index_set = 0;
6379 /* Parse args required to build the message */
6380 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6382 if (unformat (i, "sw_if_index %d", &sw_if_index))
6383 sw_if_index_set = 1;
6384 else if (unformat (i, "sw_if"))
6386 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6389 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6390 sw_if_index_set = 1;
6395 else if (unformat (i, "learn"))
6396 feature_bitmap |= L2INPUT_FEAT_LEARN;
6397 else if (unformat (i, "forward"))
6398 feature_bitmap |= L2INPUT_FEAT_FWD;
6399 else if (unformat (i, "flood"))
6400 feature_bitmap |= L2INPUT_FEAT_FLOOD;
6401 else if (unformat (i, "uu-flood"))
6402 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
6407 if (sw_if_index_set == 0)
6409 errmsg ("missing interface name or sw_if_index");
6415 mp->sw_if_index = ntohl (sw_if_index);
6416 mp->feature_bitmap = ntohl (feature_bitmap);
6424 api_bridge_flags (vat_main_t * vam)
6426 unformat_input_t *i = vam->input;
6427 vl_api_bridge_flags_t *mp;
6434 /* Parse args required to build the message */
6435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6437 if (unformat (i, "bd_id %d", &bd_id))
6439 else if (unformat (i, "learn"))
6441 else if (unformat (i, "forward"))
6443 else if (unformat (i, "flood"))
6445 else if (unformat (i, "uu-flood"))
6446 flags |= L2_UU_FLOOD;
6447 else if (unformat (i, "arp-term"))
6448 flags |= L2_ARP_TERM;
6449 else if (unformat (i, "off"))
6451 else if (unformat (i, "disable"))
6459 errmsg ("missing bridge domain");
6463 M (BRIDGE_FLAGS, mp);
6465 mp->bd_id = ntohl (bd_id);
6466 mp->feature_bitmap = ntohl (flags);
6467 mp->is_set = is_set;
6475 api_bd_ip_mac_add_del (vat_main_t * vam)
6477 unformat_input_t *i = vam->input;
6478 vl_api_bd_ip_mac_add_del_t *mp;
6485 ip4_address_t v4addr;
6486 ip6_address_t v6addr;
6491 /* Parse args required to build the message */
6492 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6494 if (unformat (i, "bd_id %d", &bd_id))
6498 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6502 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6507 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6511 else if (unformat (i, "del"))
6519 errmsg ("missing bridge domain");
6522 else if (ip_set == 0)
6524 errmsg ("missing IP address");
6527 else if (mac_set == 0)
6529 errmsg ("missing MAC address");
6533 M (BD_IP_MAC_ADD_DEL, mp);
6535 mp->bd_id = ntohl (bd_id);
6536 mp->is_ipv6 = is_ipv6;
6537 mp->is_add = is_add;
6539 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6541 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6542 clib_memcpy (mp->mac_address, macaddr, 6);
6549 api_tap_connect (vat_main_t * vam)
6551 unformat_input_t *i = vam->input;
6552 vl_api_tap_connect_t *mp;
6558 ip4_address_t ip4_address;
6560 int ip4_address_set = 0;
6561 ip6_address_t ip6_address;
6563 int ip6_address_set = 0;
6566 memset (mac_address, 0, sizeof (mac_address));
6568 /* Parse args required to build the message */
6569 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6571 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6575 else if (unformat (i, "random-mac"))
6577 else if (unformat (i, "tapname %s", &tap_name))
6579 else if (unformat (i, "tag %s", &tag))
6581 else if (unformat (i, "address %U/%d",
6582 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6583 ip4_address_set = 1;
6584 else if (unformat (i, "address %U/%d",
6585 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6586 ip6_address_set = 1;
6593 errmsg ("missing tap name");
6596 if (vec_len (tap_name) > 63)
6598 errmsg ("tap name too long");
6601 vec_add1 (tap_name, 0);
6603 if (vec_len (tag) > 63)
6605 errmsg ("tag too long");
6609 /* Construct the API message */
6610 M (TAP_CONNECT, mp);
6612 mp->use_random_mac = random_mac;
6613 clib_memcpy (mp->mac_address, mac_address, 6);
6614 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6616 clib_memcpy (mp->tag, tag, vec_len (tag));
6618 if (ip4_address_set)
6620 mp->ip4_address_set = 1;
6621 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6622 mp->ip4_mask_width = ip4_mask_width;
6624 if (ip6_address_set)
6626 mp->ip6_address_set = 1;
6627 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6628 mp->ip6_mask_width = ip6_mask_width;
6631 vec_free (tap_name);
6637 /* Wait for a reply... */
6643 api_tap_modify (vat_main_t * vam)
6645 unformat_input_t *i = vam->input;
6646 vl_api_tap_modify_t *mp;
6651 u32 sw_if_index = ~0;
6652 u8 sw_if_index_set = 0;
6655 memset (mac_address, 0, sizeof (mac_address));
6657 /* Parse args required to build the message */
6658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6660 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6661 sw_if_index_set = 1;
6662 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6663 sw_if_index_set = 1;
6664 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6668 else if (unformat (i, "random-mac"))
6670 else if (unformat (i, "tapname %s", &tap_name))
6676 if (sw_if_index_set == 0)
6678 errmsg ("missing vpp interface name");
6683 errmsg ("missing tap name");
6686 if (vec_len (tap_name) > 63)
6688 errmsg ("tap name too long");
6690 vec_add1 (tap_name, 0);
6692 /* Construct the API message */
6695 mp->use_random_mac = random_mac;
6696 mp->sw_if_index = ntohl (sw_if_index);
6697 clib_memcpy (mp->mac_address, mac_address, 6);
6698 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6699 vec_free (tap_name);
6704 /* Wait for a reply... */
6710 api_tap_delete (vat_main_t * vam)
6712 unformat_input_t *i = vam->input;
6713 vl_api_tap_delete_t *mp;
6714 u32 sw_if_index = ~0;
6715 u8 sw_if_index_set = 0;
6718 /* Parse args required to build the message */
6719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6721 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6722 sw_if_index_set = 1;
6723 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6724 sw_if_index_set = 1;
6729 if (sw_if_index_set == 0)
6731 errmsg ("missing vpp interface name");
6735 /* Construct the API message */
6738 mp->sw_if_index = ntohl (sw_if_index);
6743 /* Wait for a reply... */
6749 api_ip_add_del_route (vat_main_t * vam)
6751 unformat_input_t *i = vam->input;
6752 vl_api_ip_add_del_route_t *mp;
6753 u32 sw_if_index = ~0, vrf_id = 0;
6755 u8 is_local = 0, is_drop = 0;
6756 u8 is_unreach = 0, is_prohibit = 0;
6757 u8 create_vrf_if_needed = 0;
6759 u32 next_hop_weight = 1;
6761 u8 is_multipath = 0;
6763 u8 address_length_set = 0;
6764 u32 next_hop_table_id = 0;
6765 u32 resolve_attempts = 0;
6766 u32 dst_address_length = 0;
6767 u8 next_hop_set = 0;
6768 ip4_address_t v4_dst_address, v4_next_hop_address;
6769 ip6_address_t v6_dst_address, v6_next_hop_address;
6773 u32 random_add_del = 0;
6774 u32 *random_vector = 0;
6776 u32 random_seed = 0xdeaddabe;
6777 u32 classify_table_index = ~0;
6779 u8 resolve_host = 0, resolve_attached = 0;
6780 mpls_label_t *next_hop_out_label_stack = NULL;
6781 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6782 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6784 /* Parse args required to build the message */
6785 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6787 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6789 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6791 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6796 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6801 else if (unformat (i, "/%d", &dst_address_length))
6803 address_length_set = 1;
6806 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6807 &v4_next_hop_address))
6811 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6812 &v6_next_hop_address))
6816 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6818 else if (unformat (i, "weight %d", &next_hop_weight))
6820 else if (unformat (i, "drop"))
6824 else if (unformat (i, "null-send-unreach"))
6828 else if (unformat (i, "null-send-prohibit"))
6832 else if (unformat (i, "local"))
6836 else if (unformat (i, "classify %d", &classify_table_index))
6840 else if (unformat (i, "del"))
6842 else if (unformat (i, "add"))
6844 else if (unformat (i, "not-last"))
6846 else if (unformat (i, "resolve-via-host"))
6848 else if (unformat (i, "resolve-via-attached"))
6849 resolve_attached = 1;
6850 else if (unformat (i, "multipath"))
6852 else if (unformat (i, "vrf %d", &vrf_id))
6854 else if (unformat (i, "create-vrf"))
6855 create_vrf_if_needed = 1;
6856 else if (unformat (i, "count %d", &count))
6858 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6860 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6862 else if (unformat (i, "out-label %d", &next_hop_out_label))
6863 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6864 else if (unformat (i, "via-label %d", &next_hop_via_label))
6866 else if (unformat (i, "random"))
6868 else if (unformat (i, "seed %d", &random_seed))
6872 clib_warning ("parse error '%U'", format_unformat_error, i);
6877 if (!next_hop_set && !is_drop && !is_local &&
6878 !is_classify && !is_unreach && !is_prohibit &&
6879 MPLS_LABEL_INVALID == next_hop_via_label)
6882 ("next hop / local / drop / unreach / prohibit / classify not set");
6886 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6888 errmsg ("next hop and next-hop via label set");
6891 if (address_set == 0)
6893 errmsg ("missing addresses");
6897 if (address_length_set == 0)
6899 errmsg ("missing address length");
6903 /* Generate a pile of unique, random routes */
6906 u32 this_random_address;
6907 random_hash = hash_create (count, sizeof (uword));
6909 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6910 for (j = 0; j <= count; j++)
6914 this_random_address = random_u32 (&random_seed);
6915 this_random_address =
6916 clib_host_to_net_u32 (this_random_address);
6918 while (hash_get (random_hash, this_random_address));
6919 vec_add1 (random_vector, this_random_address);
6920 hash_set (random_hash, this_random_address, 1);
6922 hash_free (random_hash);
6923 v4_dst_address.as_u32 = random_vector[0];
6928 /* Turn on async mode */
6929 vam->async_mode = 1;
6930 vam->async_errors = 0;
6931 before = vat_time_now (vam);
6934 for (j = 0; j < count; j++)
6936 /* Construct the API message */
6937 M2 (IP_ADD_DEL_ROUTE, mp,
6938 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6940 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6941 mp->table_id = ntohl (vrf_id);
6942 mp->create_vrf_if_needed = create_vrf_if_needed;
6944 mp->is_add = is_add;
6945 mp->is_drop = is_drop;
6946 mp->is_unreach = is_unreach;
6947 mp->is_prohibit = is_prohibit;
6948 mp->is_ipv6 = is_ipv6;
6949 mp->is_local = is_local;
6950 mp->is_classify = is_classify;
6951 mp->is_multipath = is_multipath;
6952 mp->is_resolve_host = resolve_host;
6953 mp->is_resolve_attached = resolve_attached;
6954 mp->not_last = not_last;
6955 mp->next_hop_weight = next_hop_weight;
6956 mp->dst_address_length = dst_address_length;
6957 mp->next_hop_table_id = ntohl (next_hop_table_id);
6958 mp->classify_table_index = ntohl (classify_table_index);
6959 mp->next_hop_via_label = ntohl (next_hop_via_label);
6960 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6961 if (0 != mp->next_hop_n_out_labels)
6963 memcpy (mp->next_hop_out_label_stack,
6964 next_hop_out_label_stack,
6965 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6966 vec_free (next_hop_out_label_stack);
6971 clib_memcpy (mp->dst_address, &v6_dst_address,
6972 sizeof (v6_dst_address));
6974 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6975 sizeof (v6_next_hop_address));
6976 increment_v6_address (&v6_dst_address);
6980 clib_memcpy (mp->dst_address, &v4_dst_address,
6981 sizeof (v4_dst_address));
6983 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6984 sizeof (v4_next_hop_address));
6986 v4_dst_address.as_u32 = random_vector[j + 1];
6988 increment_v4_address (&v4_dst_address);
6992 /* If we receive SIGTERM, stop now... */
6997 /* When testing multiple add/del ops, use a control-ping to sync */
7000 vl_api_control_ping_t *mp_ping;
7004 /* Shut off async mode */
7005 vam->async_mode = 0;
7007 M (CONTROL_PING, mp_ping);
7010 timeout = vat_time_now (vam) + 1.0;
7011 while (vat_time_now (vam) < timeout)
7012 if (vam->result_ready == 1)
7017 if (vam->retval == -99)
7020 if (vam->async_errors > 0)
7022 errmsg ("%d asynchronous errors", vam->async_errors);
7025 vam->async_errors = 0;
7026 after = vat_time_now (vam);
7028 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7032 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7033 count, after - before, count / (after - before));
7039 /* Wait for a reply... */
7044 /* Return the good/bad news */
7045 return (vam->retval);
7049 api_ip_mroute_add_del (vat_main_t * vam)
7051 unformat_input_t *i = vam->input;
7052 vl_api_ip_mroute_add_del_t *mp;
7053 u32 sw_if_index = ~0, vrf_id = 0;
7056 u8 create_vrf_if_needed = 0;
7059 u32 grp_address_length = 0;
7060 ip4_address_t v4_grp_address, v4_src_address;
7061 ip6_address_t v6_grp_address, v6_src_address;
7062 mfib_itf_flags_t iflags = 0;
7063 mfib_entry_flags_t eflags = 0;
7066 /* Parse args required to build the message */
7067 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7069 if (unformat (i, "sw_if_index %d", &sw_if_index))
7071 else if (unformat (i, "%U %U",
7072 unformat_ip4_address, &v4_src_address,
7073 unformat_ip4_address, &v4_grp_address))
7075 grp_address_length = 64;
7079 else if (unformat (i, "%U %U",
7080 unformat_ip6_address, &v6_src_address,
7081 unformat_ip6_address, &v6_grp_address))
7083 grp_address_length = 256;
7087 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7089 memset (&v4_src_address, 0, sizeof (v4_src_address));
7090 grp_address_length = 32;
7094 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7096 memset (&v6_src_address, 0, sizeof (v6_src_address));
7097 grp_address_length = 128;
7101 else if (unformat (i, "/%d", &grp_address_length))
7103 else if (unformat (i, "local"))
7107 else if (unformat (i, "del"))
7109 else if (unformat (i, "add"))
7111 else if (unformat (i, "vrf %d", &vrf_id))
7113 else if (unformat (i, "create-vrf"))
7114 create_vrf_if_needed = 1;
7115 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7117 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7121 clib_warning ("parse error '%U'", format_unformat_error, i);
7126 if (address_set == 0)
7128 errmsg ("missing addresses\n");
7132 /* Construct the API message */
7133 M (IP_MROUTE_ADD_DEL, mp);
7135 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7136 mp->table_id = ntohl (vrf_id);
7137 mp->create_vrf_if_needed = create_vrf_if_needed;
7139 mp->is_add = is_add;
7140 mp->is_ipv6 = is_ipv6;
7141 mp->is_local = is_local;
7142 mp->itf_flags = ntohl (iflags);
7143 mp->entry_flags = ntohl (eflags);
7144 mp->grp_address_length = grp_address_length;
7145 mp->grp_address_length = ntohs (mp->grp_address_length);
7149 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7150 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7154 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7155 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7161 /* Wait for a reply... */
7167 api_mpls_route_add_del (vat_main_t * vam)
7169 unformat_input_t *i = vam->input;
7170 vl_api_mpls_route_add_del_t *mp;
7171 u32 sw_if_index = ~0, table_id = 0;
7172 u8 create_table_if_needed = 0;
7174 u32 next_hop_weight = 1;
7175 u8 is_multipath = 0;
7176 u32 next_hop_table_id = 0;
7177 u8 next_hop_set = 0;
7178 ip4_address_t v4_next_hop_address = {
7181 ip6_address_t v6_next_hop_address = { {0} };
7185 u32 classify_table_index = ~0;
7187 u8 resolve_host = 0, resolve_attached = 0;
7188 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7189 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7190 mpls_label_t *next_hop_out_label_stack = NULL;
7191 mpls_label_t local_label = MPLS_LABEL_INVALID;
7193 u8 next_hop_proto_is_ip4 = 1;
7195 /* Parse args required to build the message */
7196 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7198 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7200 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7202 else if (unformat (i, "%d", &local_label))
7204 else if (unformat (i, "eos"))
7206 else if (unformat (i, "non-eos"))
7208 else if (unformat (i, "via %U", unformat_ip4_address,
7209 &v4_next_hop_address))
7212 next_hop_proto_is_ip4 = 1;
7214 else if (unformat (i, "via %U", unformat_ip6_address,
7215 &v6_next_hop_address))
7218 next_hop_proto_is_ip4 = 0;
7220 else if (unformat (i, "weight %d", &next_hop_weight))
7222 else if (unformat (i, "create-table"))
7223 create_table_if_needed = 1;
7224 else if (unformat (i, "classify %d", &classify_table_index))
7228 else if (unformat (i, "del"))
7230 else if (unformat (i, "add"))
7232 else if (unformat (i, "resolve-via-host"))
7234 else if (unformat (i, "resolve-via-attached"))
7235 resolve_attached = 1;
7236 else if (unformat (i, "multipath"))
7238 else if (unformat (i, "count %d", &count))
7240 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
7243 next_hop_proto_is_ip4 = 1;
7245 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
7248 next_hop_proto_is_ip4 = 0;
7250 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7252 else if (unformat (i, "via-label %d", &next_hop_via_label))
7254 else if (unformat (i, "out-label %d", &next_hop_out_label))
7255 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7258 clib_warning ("parse error '%U'", format_unformat_error, i);
7263 if (!next_hop_set && !is_classify)
7265 errmsg ("next hop / classify not set");
7269 if (MPLS_LABEL_INVALID == local_label)
7271 errmsg ("missing label");
7277 /* Turn on async mode */
7278 vam->async_mode = 1;
7279 vam->async_errors = 0;
7280 before = vat_time_now (vam);
7283 for (j = 0; j < count; j++)
7285 /* Construct the API message */
7286 M2 (MPLS_ROUTE_ADD_DEL, mp,
7287 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7289 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
7290 mp->mr_table_id = ntohl (table_id);
7291 mp->mr_create_table_if_needed = create_table_if_needed;
7293 mp->mr_is_add = is_add;
7294 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7295 mp->mr_is_classify = is_classify;
7296 mp->mr_is_multipath = is_multipath;
7297 mp->mr_is_resolve_host = resolve_host;
7298 mp->mr_is_resolve_attached = resolve_attached;
7299 mp->mr_next_hop_weight = next_hop_weight;
7300 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
7301 mp->mr_classify_table_index = ntohl (classify_table_index);
7302 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
7303 mp->mr_label = ntohl (local_label);
7304 mp->mr_eos = is_eos;
7306 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7307 if (0 != mp->mr_next_hop_n_out_labels)
7309 memcpy (mp->mr_next_hop_out_label_stack,
7310 next_hop_out_label_stack,
7311 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7312 vec_free (next_hop_out_label_stack);
7317 if (next_hop_proto_is_ip4)
7319 clib_memcpy (mp->mr_next_hop,
7320 &v4_next_hop_address,
7321 sizeof (v4_next_hop_address));
7325 clib_memcpy (mp->mr_next_hop,
7326 &v6_next_hop_address,
7327 sizeof (v6_next_hop_address));
7334 /* If we receive SIGTERM, stop now... */
7339 /* When testing multiple add/del ops, use a control-ping to sync */
7342 vl_api_control_ping_t *mp_ping;
7346 /* Shut off async mode */
7347 vam->async_mode = 0;
7349 M (CONTROL_PING, mp_ping);
7352 timeout = vat_time_now (vam) + 1.0;
7353 while (vat_time_now (vam) < timeout)
7354 if (vam->result_ready == 1)
7359 if (vam->retval == -99)
7362 if (vam->async_errors > 0)
7364 errmsg ("%d asynchronous errors", vam->async_errors);
7367 vam->async_errors = 0;
7368 after = vat_time_now (vam);
7370 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7374 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7375 count, after - before, count / (after - before));
7381 /* Wait for a reply... */
7386 /* Return the good/bad news */
7387 return (vam->retval);
7391 api_mpls_ip_bind_unbind (vat_main_t * vam)
7393 unformat_input_t *i = vam->input;
7394 vl_api_mpls_ip_bind_unbind_t *mp;
7395 u32 ip_table_id = 0;
7396 u8 create_table_if_needed = 0;
7399 ip4_address_t v4_address;
7400 ip6_address_t v6_address;
7403 mpls_label_t local_label = MPLS_LABEL_INVALID;
7406 /* Parse args required to build the message */
7407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7409 if (unformat (i, "%U/%d", unformat_ip4_address,
7410 &v4_address, &address_length))
7415 else if (unformat (i, "%U/%d", unformat_ip6_address,
7416 &v6_address, &address_length))
7421 else if (unformat (i, "%d", &local_label))
7423 else if (unformat (i, "create-table"))
7424 create_table_if_needed = 1;
7425 else if (unformat (i, "table-id %d", &ip_table_id))
7427 else if (unformat (i, "unbind"))
7429 else if (unformat (i, "bind"))
7433 clib_warning ("parse error '%U'", format_unformat_error, i);
7440 errmsg ("IP addres not set");
7444 if (MPLS_LABEL_INVALID == local_label)
7446 errmsg ("missing label");
7450 /* Construct the API message */
7451 M (MPLS_IP_BIND_UNBIND, mp);
7453 mp->mb_create_table_if_needed = create_table_if_needed;
7454 mp->mb_is_bind = is_bind;
7455 mp->mb_is_ip4 = is_ip4;
7456 mp->mb_ip_table_id = ntohl (ip_table_id);
7457 mp->mb_mpls_table_id = 0;
7458 mp->mb_label = ntohl (local_label);
7459 mp->mb_address_length = address_length;
7462 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7464 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7469 /* Wait for a reply... */
7475 api_proxy_arp_add_del (vat_main_t * vam)
7477 unformat_input_t *i = vam->input;
7478 vl_api_proxy_arp_add_del_t *mp;
7481 ip4_address_t lo, hi;
7485 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7487 if (unformat (i, "vrf %d", &vrf_id))
7489 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7490 unformat_ip4_address, &hi))
7492 else if (unformat (i, "del"))
7496 clib_warning ("parse error '%U'", format_unformat_error, i);
7503 errmsg ("address range not set");
7507 M (PROXY_ARP_ADD_DEL, mp);
7509 mp->vrf_id = ntohl (vrf_id);
7510 mp->is_add = is_add;
7511 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7512 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7520 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7522 unformat_input_t *i = vam->input;
7523 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7526 u8 sw_if_index_set = 0;
7529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7531 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7532 sw_if_index_set = 1;
7533 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7534 sw_if_index_set = 1;
7535 else if (unformat (i, "enable"))
7537 else if (unformat (i, "disable"))
7541 clib_warning ("parse error '%U'", format_unformat_error, i);
7546 if (sw_if_index_set == 0)
7548 errmsg ("missing interface name or sw_if_index");
7552 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7554 mp->sw_if_index = ntohl (sw_if_index);
7555 mp->enable_disable = enable;
7563 api_mpls_tunnel_add_del (vat_main_t * vam)
7565 unformat_input_t *i = vam->input;
7566 vl_api_mpls_tunnel_add_del_t *mp;
7570 u32 sw_if_index = ~0;
7571 u32 next_hop_sw_if_index = ~0;
7572 u32 next_hop_proto_is_ip4 = 1;
7574 u32 next_hop_table_id = 0;
7575 ip4_address_t v4_next_hop_address = {
7578 ip6_address_t v6_next_hop_address = { {0} };
7579 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7582 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7584 if (unformat (i, "add"))
7586 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7588 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7590 else if (unformat (i, "via %U",
7591 unformat_ip4_address, &v4_next_hop_address))
7593 next_hop_proto_is_ip4 = 1;
7595 else if (unformat (i, "via %U",
7596 unformat_ip6_address, &v6_next_hop_address))
7598 next_hop_proto_is_ip4 = 0;
7600 else if (unformat (i, "l2-only"))
7602 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7604 else if (unformat (i, "out-label %d", &next_hop_out_label))
7605 vec_add1 (labels, ntohl (next_hop_out_label));
7608 clib_warning ("parse error '%U'", format_unformat_error, i);
7613 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7615 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7616 mp->mt_sw_if_index = ntohl (sw_if_index);
7617 mp->mt_is_add = is_add;
7618 mp->mt_l2_only = l2_only;
7619 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7620 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7622 mp->mt_next_hop_n_out_labels = vec_len (labels);
7624 if (0 != mp->mt_next_hop_n_out_labels)
7626 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7627 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7631 if (next_hop_proto_is_ip4)
7633 clib_memcpy (mp->mt_next_hop,
7634 &v4_next_hop_address, sizeof (v4_next_hop_address));
7638 clib_memcpy (mp->mt_next_hop,
7639 &v6_next_hop_address, sizeof (v6_next_hop_address));
7648 api_sw_interface_set_unnumbered (vat_main_t * vam)
7650 unformat_input_t *i = vam->input;
7651 vl_api_sw_interface_set_unnumbered_t *mp;
7653 u32 unnum_sw_index = ~0;
7655 u8 sw_if_index_set = 0;
7658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7660 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7661 sw_if_index_set = 1;
7662 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7663 sw_if_index_set = 1;
7664 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7666 else if (unformat (i, "del"))
7670 clib_warning ("parse error '%U'", format_unformat_error, i);
7675 if (sw_if_index_set == 0)
7677 errmsg ("missing interface name or sw_if_index");
7681 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7683 mp->sw_if_index = ntohl (sw_if_index);
7684 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7685 mp->is_add = is_add;
7693 api_ip_neighbor_add_del (vat_main_t * vam)
7695 unformat_input_t *i = vam->input;
7696 vl_api_ip_neighbor_add_del_t *mp;
7698 u8 sw_if_index_set = 0;
7701 u8 is_no_fib_entry = 0;
7704 u8 v4_address_set = 0;
7705 u8 v6_address_set = 0;
7706 ip4_address_t v4address;
7707 ip6_address_t v6address;
7710 memset (mac_address, 0, sizeof (mac_address));
7712 /* Parse args required to build the message */
7713 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7715 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7719 else if (unformat (i, "del"))
7722 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7723 sw_if_index_set = 1;
7724 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7725 sw_if_index_set = 1;
7726 else if (unformat (i, "is_static"))
7728 else if (unformat (i, "no-fib-entry"))
7729 is_no_fib_entry = 1;
7730 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7732 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7736 clib_warning ("parse error '%U'", format_unformat_error, i);
7741 if (sw_if_index_set == 0)
7743 errmsg ("missing interface name or sw_if_index");
7746 if (v4_address_set && v6_address_set)
7748 errmsg ("both v4 and v6 addresses set");
7751 if (!v4_address_set && !v6_address_set)
7753 errmsg ("no address set");
7757 /* Construct the API message */
7758 M (IP_NEIGHBOR_ADD_DEL, mp);
7760 mp->sw_if_index = ntohl (sw_if_index);
7761 mp->is_add = is_add;
7762 mp->is_static = is_static;
7763 mp->is_no_adj_fib = is_no_fib_entry;
7765 clib_memcpy (mp->mac_address, mac_address, 6);
7769 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7773 /* mp->is_ipv6 = 0; via memset in M macro above */
7774 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7780 /* Wait for a reply, return good/bad news */
7786 api_reset_vrf (vat_main_t * vam)
7788 unformat_input_t *i = vam->input;
7789 vl_api_reset_vrf_t *mp;
7795 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7797 if (unformat (i, "vrf %d", &vrf_id))
7799 else if (unformat (i, "ipv6"))
7803 clib_warning ("parse error '%U'", format_unformat_error, i);
7808 if (vrf_id_set == 0)
7810 errmsg ("missing vrf id");
7816 mp->vrf_id = ntohl (vrf_id);
7817 mp->is_ipv6 = is_ipv6;
7825 api_create_vlan_subif (vat_main_t * vam)
7827 unformat_input_t *i = vam->input;
7828 vl_api_create_vlan_subif_t *mp;
7830 u8 sw_if_index_set = 0;
7835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7837 if (unformat (i, "sw_if_index %d", &sw_if_index))
7838 sw_if_index_set = 1;
7840 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7841 sw_if_index_set = 1;
7842 else if (unformat (i, "vlan %d", &vlan_id))
7846 clib_warning ("parse error '%U'", format_unformat_error, i);
7851 if (sw_if_index_set == 0)
7853 errmsg ("missing interface name or sw_if_index");
7857 if (vlan_id_set == 0)
7859 errmsg ("missing vlan_id");
7862 M (CREATE_VLAN_SUBIF, mp);
7864 mp->sw_if_index = ntohl (sw_if_index);
7865 mp->vlan_id = ntohl (vlan_id);
7872 #define foreach_create_subif_bit \
7879 _(outer_vlan_id_any) \
7880 _(inner_vlan_id_any)
7883 api_create_subif (vat_main_t * vam)
7885 unformat_input_t *i = vam->input;
7886 vl_api_create_subif_t *mp;
7888 u8 sw_if_index_set = 0;
7895 u32 exact_match = 0;
7896 u32 default_sub = 0;
7897 u32 outer_vlan_id_any = 0;
7898 u32 inner_vlan_id_any = 0;
7900 u16 outer_vlan_id = 0;
7901 u16 inner_vlan_id = 0;
7904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7906 if (unformat (i, "sw_if_index %d", &sw_if_index))
7907 sw_if_index_set = 1;
7909 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7910 sw_if_index_set = 1;
7911 else if (unformat (i, "sub_id %d", &sub_id))
7913 else if (unformat (i, "outer_vlan_id %d", &tmp))
7914 outer_vlan_id = tmp;
7915 else if (unformat (i, "inner_vlan_id %d", &tmp))
7916 inner_vlan_id = tmp;
7918 #define _(a) else if (unformat (i, #a)) a = 1 ;
7919 foreach_create_subif_bit
7923 clib_warning ("parse error '%U'", format_unformat_error, i);
7928 if (sw_if_index_set == 0)
7930 errmsg ("missing interface name or sw_if_index");
7934 if (sub_id_set == 0)
7936 errmsg ("missing sub_id");
7939 M (CREATE_SUBIF, mp);
7941 mp->sw_if_index = ntohl (sw_if_index);
7942 mp->sub_id = ntohl (sub_id);
7944 #define _(a) mp->a = a;
7945 foreach_create_subif_bit;
7948 mp->outer_vlan_id = ntohs (outer_vlan_id);
7949 mp->inner_vlan_id = ntohs (inner_vlan_id);
7957 api_oam_add_del (vat_main_t * vam)
7959 unformat_input_t *i = vam->input;
7960 vl_api_oam_add_del_t *mp;
7963 ip4_address_t src, dst;
7968 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7970 if (unformat (i, "vrf %d", &vrf_id))
7972 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7974 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7976 else if (unformat (i, "del"))
7980 clib_warning ("parse error '%U'", format_unformat_error, i);
7987 errmsg ("missing src addr");
7993 errmsg ("missing dst addr");
7997 M (OAM_ADD_DEL, mp);
7999 mp->vrf_id = ntohl (vrf_id);
8000 mp->is_add = is_add;
8001 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
8002 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8010 api_reset_fib (vat_main_t * vam)
8012 unformat_input_t *i = vam->input;
8013 vl_api_reset_fib_t *mp;
8019 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8021 if (unformat (i, "vrf %d", &vrf_id))
8023 else if (unformat (i, "ipv6"))
8027 clib_warning ("parse error '%U'", format_unformat_error, i);
8032 if (vrf_id_set == 0)
8034 errmsg ("missing vrf id");
8040 mp->vrf_id = ntohl (vrf_id);
8041 mp->is_ipv6 = is_ipv6;
8049 api_dhcp_proxy_config (vat_main_t * vam)
8051 unformat_input_t *i = vam->input;
8052 vl_api_dhcp_proxy_config_t *mp;
8054 u32 server_vrf_id = 0;
8056 u8 v4_address_set = 0;
8057 u8 v6_address_set = 0;
8058 ip4_address_t v4address;
8059 ip6_address_t v6address;
8060 u8 v4_src_address_set = 0;
8061 u8 v6_src_address_set = 0;
8062 ip4_address_t v4srcaddress;
8063 ip6_address_t v6srcaddress;
8066 /* Parse args required to build the message */
8067 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8069 if (unformat (i, "del"))
8071 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8073 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8075 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8077 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8079 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8080 v4_src_address_set = 1;
8081 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8082 v6_src_address_set = 1;
8087 if (v4_address_set && v6_address_set)
8089 errmsg ("both v4 and v6 server addresses set");
8092 if (!v4_address_set && !v6_address_set)
8094 errmsg ("no server addresses set");
8098 if (v4_src_address_set && v6_src_address_set)
8100 errmsg ("both v4 and v6 src addresses set");
8103 if (!v4_src_address_set && !v6_src_address_set)
8105 errmsg ("no src addresses set");
8109 if (!(v4_src_address_set && v4_address_set) &&
8110 !(v6_src_address_set && v6_address_set))
8112 errmsg ("no matching server and src addresses set");
8116 /* Construct the API message */
8117 M (DHCP_PROXY_CONFIG, mp);
8119 mp->is_add = is_add;
8120 mp->rx_vrf_id = ntohl (rx_vrf_id);
8121 mp->server_vrf_id = ntohl (server_vrf_id);
8125 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
8126 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
8130 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
8131 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
8137 /* Wait for a reply, return good/bad news */
8142 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
8143 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
8146 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
8148 vat_main_t *vam = &vat_main;
8149 u32 i, count = mp->count;
8150 vl_api_dhcp_server_t *s;
8154 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8155 ntohl (mp->rx_vrf_id),
8156 format_ip6_address, mp->dhcp_src_address,
8157 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8160 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8161 ntohl (mp->rx_vrf_id),
8162 format_ip4_address, mp->dhcp_src_address,
8163 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8165 for (i = 0; i < count; i++)
8167 s = &mp->servers[i];
8171 " Server Table-ID %d, Server Address %U",
8172 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
8175 " Server Table-ID %d, Server Address %U",
8176 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
8180 static void vl_api_dhcp_proxy_details_t_handler_json
8181 (vl_api_dhcp_proxy_details_t * mp)
8183 vat_main_t *vam = &vat_main;
8184 vat_json_node_t *node = NULL;
8185 u32 i, count = mp->count;
8187 struct in6_addr ip6;
8188 vl_api_dhcp_server_t *s;
8190 if (VAT_JSON_ARRAY != vam->json_tree.type)
8192 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8193 vat_json_init_array (&vam->json_tree);
8195 node = vat_json_array_add (&vam->json_tree);
8197 vat_json_init_object (node);
8198 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
8199 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
8200 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
8204 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
8205 vat_json_object_add_ip6 (node, "src_address", ip6);
8209 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
8210 vat_json_object_add_ip4 (node, "src_address", ip4);
8213 for (i = 0; i < count; i++)
8215 s = &mp->servers[i];
8217 vat_json_object_add_uint (node, "server-table-id",
8218 ntohl (s->server_vrf_id));
8222 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
8223 vat_json_object_add_ip4 (node, "src_address", ip4);
8227 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
8228 vat_json_object_add_ip6 (node, "server_address", ip6);
8234 api_dhcp_proxy_dump (vat_main_t * vam)
8236 unformat_input_t *i = vam->input;
8237 vl_api_control_ping_t *mp_ping;
8238 vl_api_dhcp_proxy_dump_t *mp;
8242 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8244 if (unformat (i, "ipv6"))
8248 clib_warning ("parse error '%U'", format_unformat_error, i);
8253 M (DHCP_PROXY_DUMP, mp);
8255 mp->is_ip6 = is_ipv6;
8258 /* Use a control ping for synchronization */
8259 M (CONTROL_PING, mp_ping);
8267 api_dhcp_proxy_set_vss (vat_main_t * vam)
8269 unformat_input_t *i = vam->input;
8270 vl_api_dhcp_proxy_set_vss_t *mp;
8281 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8283 if (unformat (i, "tbl_id %d", &tbl_id))
8285 if (unformat (i, "fib_id %d", &fib_id))
8287 if (unformat (i, "oui %d", &oui))
8289 else if (unformat (i, "ipv6"))
8291 else if (unformat (i, "del"))
8295 clib_warning ("parse error '%U'", format_unformat_error, i);
8300 if (tbl_id_set == 0)
8302 errmsg ("missing tbl id");
8306 if (fib_id_set == 0)
8308 errmsg ("missing fib id");
8313 errmsg ("missing oui");
8317 M (DHCP_PROXY_SET_VSS, mp);
8318 mp->tbl_id = ntohl (tbl_id);
8319 mp->fib_id = ntohl (fib_id);
8320 mp->oui = ntohl (oui);
8321 mp->is_ipv6 = is_ipv6;
8322 mp->is_add = is_add;
8330 api_dhcp_client_config (vat_main_t * vam)
8332 unformat_input_t *i = vam->input;
8333 vl_api_dhcp_client_config_t *mp;
8335 u8 sw_if_index_set = 0;
8338 u8 disable_event = 0;
8341 /* Parse args required to build the message */
8342 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8344 if (unformat (i, "del"))
8347 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8348 sw_if_index_set = 1;
8349 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8350 sw_if_index_set = 1;
8351 else if (unformat (i, "hostname %s", &hostname))
8353 else if (unformat (i, "disable_event"))
8359 if (sw_if_index_set == 0)
8361 errmsg ("missing interface name or sw_if_index");
8365 if (vec_len (hostname) > 63)
8367 errmsg ("hostname too long");
8369 vec_add1 (hostname, 0);
8371 /* Construct the API message */
8372 M (DHCP_CLIENT_CONFIG, mp);
8374 mp->sw_if_index = htonl (sw_if_index);
8375 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
8376 vec_free (hostname);
8377 mp->is_add = is_add;
8378 mp->want_dhcp_event = disable_event ? 0 : 1;
8379 mp->pid = htonl (getpid ());
8384 /* Wait for a reply, return good/bad news */
8390 api_set_ip_flow_hash (vat_main_t * vam)
8392 unformat_input_t *i = vam->input;
8393 vl_api_set_ip_flow_hash_t *mp;
8405 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8407 if (unformat (i, "vrf %d", &vrf_id))
8409 else if (unformat (i, "ipv6"))
8411 else if (unformat (i, "src"))
8413 else if (unformat (i, "dst"))
8415 else if (unformat (i, "sport"))
8417 else if (unformat (i, "dport"))
8419 else if (unformat (i, "proto"))
8421 else if (unformat (i, "reverse"))
8426 clib_warning ("parse error '%U'", format_unformat_error, i);
8431 if (vrf_id_set == 0)
8433 errmsg ("missing vrf id");
8437 M (SET_IP_FLOW_HASH, mp);
8443 mp->reverse = reverse;
8444 mp->vrf_id = ntohl (vrf_id);
8445 mp->is_ipv6 = is_ipv6;
8453 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8455 unformat_input_t *i = vam->input;
8456 vl_api_sw_interface_ip6_enable_disable_t *mp;
8458 u8 sw_if_index_set = 0;
8462 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8464 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8465 sw_if_index_set = 1;
8466 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8467 sw_if_index_set = 1;
8468 else if (unformat (i, "enable"))
8470 else if (unformat (i, "disable"))
8474 clib_warning ("parse error '%U'", format_unformat_error, i);
8479 if (sw_if_index_set == 0)
8481 errmsg ("missing interface name or sw_if_index");
8485 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8487 mp->sw_if_index = ntohl (sw_if_index);
8488 mp->enable = enable;
8496 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8498 unformat_input_t *i = vam->input;
8499 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8501 u8 sw_if_index_set = 0;
8502 u8 v6_address_set = 0;
8503 ip6_address_t v6address;
8506 /* Parse args required to build the message */
8507 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8509 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8510 sw_if_index_set = 1;
8511 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8512 sw_if_index_set = 1;
8513 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8519 if (sw_if_index_set == 0)
8521 errmsg ("missing interface name or sw_if_index");
8524 if (!v6_address_set)
8526 errmsg ("no address set");
8530 /* Construct the API message */
8531 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8533 mp->sw_if_index = ntohl (sw_if_index);
8534 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8539 /* Wait for a reply, return good/bad news */
8545 api_ip6nd_proxy_add_del (vat_main_t * vam)
8547 unformat_input_t *i = vam->input;
8548 vl_api_ip6nd_proxy_add_del_t *mp;
8549 u32 sw_if_index = ~0;
8550 u8 v6_address_set = 0;
8551 ip6_address_t v6address;
8555 /* Parse args required to build the message */
8556 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8558 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8560 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8562 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8564 if (unformat (i, "del"))
8568 clib_warning ("parse error '%U'", format_unformat_error, i);
8573 if (sw_if_index == ~0)
8575 errmsg ("missing interface name or sw_if_index");
8578 if (!v6_address_set)
8580 errmsg ("no address set");
8584 /* Construct the API message */
8585 M (IP6ND_PROXY_ADD_DEL, mp);
8587 mp->is_del = is_del;
8588 mp->sw_if_index = ntohl (sw_if_index);
8589 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8594 /* Wait for a reply, return good/bad news */
8600 api_ip6nd_proxy_dump (vat_main_t * vam)
8602 vl_api_ip6nd_proxy_dump_t *mp;
8603 vl_api_control_ping_t *mp_ping;
8606 M (IP6ND_PROXY_DUMP, mp);
8610 /* Use a control ping for synchronization */
8611 M (CONTROL_PING, mp_ping);
8618 static void vl_api_ip6nd_proxy_details_t_handler
8619 (vl_api_ip6nd_proxy_details_t * mp)
8621 vat_main_t *vam = &vat_main;
8623 print (vam->ofp, "host %U sw_if_index %d",
8624 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
8627 static void vl_api_ip6nd_proxy_details_t_handler_json
8628 (vl_api_ip6nd_proxy_details_t * mp)
8630 vat_main_t *vam = &vat_main;
8631 struct in6_addr ip6;
8632 vat_json_node_t *node = NULL;
8634 if (VAT_JSON_ARRAY != vam->json_tree.type)
8636 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8637 vat_json_init_array (&vam->json_tree);
8639 node = vat_json_array_add (&vam->json_tree);
8641 vat_json_init_object (node);
8642 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
8644 clib_memcpy (&ip6, mp->address, sizeof (ip6));
8645 vat_json_object_add_ip6 (node, "host", ip6);
8649 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8651 unformat_input_t *i = vam->input;
8652 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8654 u8 sw_if_index_set = 0;
8655 u32 address_length = 0;
8656 u8 v6_address_set = 0;
8657 ip6_address_t v6address;
8659 u8 no_advertise = 0;
8661 u8 no_autoconfig = 0;
8664 u32 val_lifetime = 0;
8665 u32 pref_lifetime = 0;
8668 /* Parse args required to build the message */
8669 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8671 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8672 sw_if_index_set = 1;
8673 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8674 sw_if_index_set = 1;
8675 else if (unformat (i, "%U/%d",
8676 unformat_ip6_address, &v6address, &address_length))
8678 else if (unformat (i, "val_life %d", &val_lifetime))
8680 else if (unformat (i, "pref_life %d", &pref_lifetime))
8682 else if (unformat (i, "def"))
8684 else if (unformat (i, "noadv"))
8686 else if (unformat (i, "offl"))
8688 else if (unformat (i, "noauto"))
8690 else if (unformat (i, "nolink"))
8692 else if (unformat (i, "isno"))
8696 clib_warning ("parse error '%U'", format_unformat_error, i);
8701 if (sw_if_index_set == 0)
8703 errmsg ("missing interface name or sw_if_index");
8706 if (!v6_address_set)
8708 errmsg ("no address set");
8712 /* Construct the API message */
8713 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8715 mp->sw_if_index = ntohl (sw_if_index);
8716 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8717 mp->address_length = address_length;
8718 mp->use_default = use_default;
8719 mp->no_advertise = no_advertise;
8720 mp->off_link = off_link;
8721 mp->no_autoconfig = no_autoconfig;
8722 mp->no_onlink = no_onlink;
8724 mp->val_lifetime = ntohl (val_lifetime);
8725 mp->pref_lifetime = ntohl (pref_lifetime);
8730 /* Wait for a reply, return good/bad news */
8736 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8738 unformat_input_t *i = vam->input;
8739 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8741 u8 sw_if_index_set = 0;
8746 u8 send_unicast = 0;
8749 u8 default_router = 0;
8750 u32 max_interval = 0;
8751 u32 min_interval = 0;
8753 u32 initial_count = 0;
8754 u32 initial_interval = 0;
8758 /* Parse args required to build the message */
8759 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8761 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8762 sw_if_index_set = 1;
8763 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8764 sw_if_index_set = 1;
8765 else if (unformat (i, "maxint %d", &max_interval))
8767 else if (unformat (i, "minint %d", &min_interval))
8769 else if (unformat (i, "life %d", &lifetime))
8771 else if (unformat (i, "count %d", &initial_count))
8773 else if (unformat (i, "interval %d", &initial_interval))
8775 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8777 else if (unformat (i, "managed"))
8779 else if (unformat (i, "other"))
8781 else if (unformat (i, "ll"))
8783 else if (unformat (i, "send"))
8785 else if (unformat (i, "cease"))
8787 else if (unformat (i, "isno"))
8789 else if (unformat (i, "def"))
8793 clib_warning ("parse error '%U'", format_unformat_error, i);
8798 if (sw_if_index_set == 0)
8800 errmsg ("missing interface name or sw_if_index");
8804 /* Construct the API message */
8805 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8807 mp->sw_if_index = ntohl (sw_if_index);
8808 mp->max_interval = ntohl (max_interval);
8809 mp->min_interval = ntohl (min_interval);
8810 mp->lifetime = ntohl (lifetime);
8811 mp->initial_count = ntohl (initial_count);
8812 mp->initial_interval = ntohl (initial_interval);
8813 mp->suppress = suppress;
8814 mp->managed = managed;
8816 mp->ll_option = ll_option;
8817 mp->send_unicast = send_unicast;
8820 mp->default_router = default_router;
8825 /* Wait for a reply, return good/bad news */
8831 api_set_arp_neighbor_limit (vat_main_t * vam)
8833 unformat_input_t *i = vam->input;
8834 vl_api_set_arp_neighbor_limit_t *mp;
8840 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8842 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8844 else if (unformat (i, "ipv6"))
8848 clib_warning ("parse error '%U'", format_unformat_error, i);
8855 errmsg ("missing limit value");
8859 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8861 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8862 mp->is_ipv6 = is_ipv6;
8870 api_l2_patch_add_del (vat_main_t * vam)
8872 unformat_input_t *i = vam->input;
8873 vl_api_l2_patch_add_del_t *mp;
8875 u8 rx_sw_if_index_set = 0;
8877 u8 tx_sw_if_index_set = 0;
8881 /* Parse args required to build the message */
8882 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8884 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8885 rx_sw_if_index_set = 1;
8886 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8887 tx_sw_if_index_set = 1;
8888 else if (unformat (i, "rx"))
8890 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8892 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8894 rx_sw_if_index_set = 1;
8899 else if (unformat (i, "tx"))
8901 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8903 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8905 tx_sw_if_index_set = 1;
8910 else if (unformat (i, "del"))
8916 if (rx_sw_if_index_set == 0)
8918 errmsg ("missing rx interface name or rx_sw_if_index");
8922 if (tx_sw_if_index_set == 0)
8924 errmsg ("missing tx interface name or tx_sw_if_index");
8928 M (L2_PATCH_ADD_DEL, mp);
8930 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8931 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8932 mp->is_add = is_add;
8940 u8 localsid_addr[16];
8949 api_sr_localsid_add_del (vat_main_t * vam)
8951 unformat_input_t *i = vam->input;
8952 vl_api_sr_localsid_add_del_t *mp;
8955 ip6_address_t localsid;
8959 u32 fib_table = ~(u32) 0;
8960 ip6_address_t next_hop;
8962 bool nexthop_set = 0;
8966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8968 if (unformat (i, "del"))
8970 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
8971 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
8973 else if (unformat (i, "behavior %u", &behavior));
8974 else if (unformat (i, "sw_if_index %u", &sw_if_index));
8975 else if (unformat (i, "fib-table %u", &fib_table));
8976 else if (unformat (i, "end.psp %u", &behavior));
8981 M (SR_LOCALSID_ADD_DEL, mp);
8983 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
8985 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
8986 mp->behavior = behavior;
8987 mp->sw_if_index = ntohl (sw_if_index);
8988 mp->fib_table = ntohl (fib_table);
8989 mp->end_psp = end_psp;
8990 mp->is_del = is_del;
8998 api_ioam_enable (vat_main_t * vam)
9000 unformat_input_t *input = vam->input;
9001 vl_api_ioam_enable_t *mp;
9003 int has_trace_option = 0;
9004 int has_pot_option = 0;
9005 int has_seqno_option = 0;
9006 int has_analyse_option = 0;
9009 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9011 if (unformat (input, "trace"))
9012 has_trace_option = 1;
9013 else if (unformat (input, "pot"))
9015 else if (unformat (input, "seqno"))
9016 has_seqno_option = 1;
9017 else if (unformat (input, "analyse"))
9018 has_analyse_option = 1;
9022 M (IOAM_ENABLE, mp);
9023 mp->id = htons (id);
9024 mp->seqno = has_seqno_option;
9025 mp->analyse = has_analyse_option;
9026 mp->pot_enable = has_pot_option;
9027 mp->trace_enable = has_trace_option;
9036 api_ioam_disable (vat_main_t * vam)
9038 vl_api_ioam_disable_t *mp;
9041 M (IOAM_DISABLE, mp);
9047 #define foreach_tcp_proto_field \
9051 #define foreach_udp_proto_field \
9055 #define foreach_ip4_proto_field \
9067 u16 src_port, dst_port;
9070 #if VPP_API_TEST_BUILTIN == 0
9072 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9074 u8 **maskp = va_arg (*args, u8 **);
9076 u8 found_something = 0;
9079 #define _(a) u8 a=0;
9080 foreach_tcp_proto_field;
9083 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9086 #define _(a) else if (unformat (input, #a)) a=1;
9087 foreach_tcp_proto_field
9093 #define _(a) found_something += a;
9094 foreach_tcp_proto_field;
9097 if (found_something == 0)
9100 vec_validate (mask, sizeof (*tcp) - 1);
9102 tcp = (tcp_header_t *) mask;
9104 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9105 foreach_tcp_proto_field;
9113 unformat_udp_mask (unformat_input_t * input, va_list * args)
9115 u8 **maskp = va_arg (*args, u8 **);
9117 u8 found_something = 0;
9120 #define _(a) u8 a=0;
9121 foreach_udp_proto_field;
9124 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9127 #define _(a) else if (unformat (input, #a)) a=1;
9128 foreach_udp_proto_field
9134 #define _(a) found_something += a;
9135 foreach_udp_proto_field;
9138 if (found_something == 0)
9141 vec_validate (mask, sizeof (*udp) - 1);
9143 udp = (udp_header_t *) mask;
9145 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
9146 foreach_udp_proto_field;
9154 unformat_l4_mask (unformat_input_t * input, va_list * args)
9156 u8 **maskp = va_arg (*args, u8 **);
9157 u16 src_port = 0, dst_port = 0;
9158 tcpudp_header_t *tcpudp;
9160 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9162 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9164 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9166 else if (unformat (input, "src_port"))
9168 else if (unformat (input, "dst_port"))
9174 if (!src_port && !dst_port)
9178 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9180 tcpudp = (tcpudp_header_t *) mask;
9181 tcpudp->src_port = src_port;
9182 tcpudp->dst_port = dst_port;
9190 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9192 u8 **maskp = va_arg (*args, u8 **);
9194 u8 found_something = 0;
9197 #define _(a) u8 a=0;
9198 foreach_ip4_proto_field;
9204 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9206 if (unformat (input, "version"))
9208 else if (unformat (input, "hdr_length"))
9210 else if (unformat (input, "src"))
9212 else if (unformat (input, "dst"))
9214 else if (unformat (input, "proto"))
9217 #define _(a) else if (unformat (input, #a)) a=1;
9218 foreach_ip4_proto_field
9224 #define _(a) found_something += a;
9225 foreach_ip4_proto_field;
9228 if (found_something == 0)
9231 vec_validate (mask, sizeof (*ip) - 1);
9233 ip = (ip4_header_t *) mask;
9235 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9236 foreach_ip4_proto_field;
9239 ip->ip_version_and_header_length = 0;
9242 ip->ip_version_and_header_length |= 0xF0;
9245 ip->ip_version_and_header_length |= 0x0F;
9251 #define foreach_ip6_proto_field \
9259 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9261 u8 **maskp = va_arg (*args, u8 **);
9263 u8 found_something = 0;
9265 u32 ip_version_traffic_class_and_flow_label;
9267 #define _(a) u8 a=0;
9268 foreach_ip6_proto_field;
9271 u8 traffic_class = 0;
9274 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9276 if (unformat (input, "version"))
9278 else if (unformat (input, "traffic-class"))
9280 else if (unformat (input, "flow-label"))
9282 else if (unformat (input, "src"))
9284 else if (unformat (input, "dst"))
9286 else if (unformat (input, "proto"))
9289 #define _(a) else if (unformat (input, #a)) a=1;
9290 foreach_ip6_proto_field
9296 #define _(a) found_something += a;
9297 foreach_ip6_proto_field;
9300 if (found_something == 0)
9303 vec_validate (mask, sizeof (*ip) - 1);
9305 ip = (ip6_header_t *) mask;
9307 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9308 foreach_ip6_proto_field;
9311 ip_version_traffic_class_and_flow_label = 0;
9314 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9317 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9320 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9322 ip->ip_version_traffic_class_and_flow_label =
9323 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9330 unformat_l3_mask (unformat_input_t * input, va_list * args)
9332 u8 **maskp = va_arg (*args, u8 **);
9334 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9336 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9338 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9347 unformat_l2_mask (unformat_input_t * input, va_list * args)
9349 u8 **maskp = va_arg (*args, u8 **);
9364 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9366 if (unformat (input, "src"))
9368 else if (unformat (input, "dst"))
9370 else if (unformat (input, "proto"))
9372 else if (unformat (input, "tag1"))
9374 else if (unformat (input, "tag2"))
9376 else if (unformat (input, "ignore-tag1"))
9378 else if (unformat (input, "ignore-tag2"))
9380 else if (unformat (input, "cos1"))
9382 else if (unformat (input, "cos2"))
9384 else if (unformat (input, "dot1q"))
9386 else if (unformat (input, "dot1ad"))
9391 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9392 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9395 if (tag1 || ignore_tag1 || cos1 || dot1q)
9397 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9400 vec_validate (mask, len - 1);
9403 memset (mask, 0xff, 6);
9406 memset (mask + 6, 0xff, 6);
9410 /* inner vlan tag */
9419 mask[21] = mask[20] = 0xff;
9440 mask[16] = mask[17] = 0xff;
9450 mask[12] = mask[13] = 0xff;
9457 unformat_classify_mask (unformat_input_t * input, va_list * args)
9459 u8 **maskp = va_arg (*args, u8 **);
9460 u32 *skipp = va_arg (*args, u32 *);
9461 u32 *matchp = va_arg (*args, u32 *);
9469 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9471 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9473 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9475 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9477 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9491 if (mask || l2 || l3 || l4)
9495 /* "With a free Ethernet header in every package" */
9497 vec_validate (l2, 13);
9501 vec_append (mask, l3);
9506 vec_append (mask, l4);
9511 /* Scan forward looking for the first significant mask octet */
9512 for (i = 0; i < vec_len (mask); i++)
9516 /* compute (skip, match) params */
9517 *skipp = i / sizeof (u32x4);
9518 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9520 /* Pad mask to an even multiple of the vector size */
9521 while (vec_len (mask) % sizeof (u32x4))
9524 match = vec_len (mask) / sizeof (u32x4);
9526 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9528 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9529 if (*tmp || *(tmp + 1))
9534 clib_warning ("BUG: match 0");
9536 _vec_len (mask) = match * sizeof (u32x4);
9546 #endif /* VPP_API_TEST_BUILTIN */
9548 #define foreach_l2_next \
9550 _(ethernet, ETHERNET_INPUT) \
9555 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9557 u32 *miss_next_indexp = va_arg (*args, u32 *);
9562 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9566 if (unformat (input, "%d", &tmp))
9575 *miss_next_indexp = next_index;
9579 #define foreach_ip_next \
9585 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9587 u32 *miss_next_indexp = va_arg (*args, u32 *);
9592 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9596 if (unformat (input, "%d", &tmp))
9605 *miss_next_indexp = next_index;
9609 #define foreach_acl_next \
9613 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9615 u32 *miss_next_indexp = va_arg (*args, u32 *);
9620 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9624 if (unformat (input, "permit"))
9629 else if (unformat (input, "%d", &tmp))
9638 *miss_next_indexp = next_index;
9643 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9645 u32 *r = va_arg (*args, u32 *);
9647 if (unformat (input, "conform-color"))
9648 *r = POLICE_CONFORM;
9649 else if (unformat (input, "exceed-color"))
9658 api_classify_add_del_table (vat_main_t * vam)
9660 unformat_input_t *i = vam->input;
9661 vl_api_classify_add_del_table_t *mp;
9668 u32 table_index = ~0;
9669 u32 next_table_index = ~0;
9670 u32 miss_next_index = ~0;
9671 u32 memory_size = 32 << 20;
9673 u32 current_data_flag = 0;
9674 int current_data_offset = 0;
9677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9679 if (unformat (i, "del"))
9681 else if (unformat (i, "del-chain"))
9686 else if (unformat (i, "buckets %d", &nbuckets))
9688 else if (unformat (i, "memory_size %d", &memory_size))
9690 else if (unformat (i, "skip %d", &skip))
9692 else if (unformat (i, "match %d", &match))
9694 else if (unformat (i, "table %d", &table_index))
9696 else if (unformat (i, "mask %U", unformat_classify_mask,
9697 &mask, &skip, &match))
9699 else if (unformat (i, "next-table %d", &next_table_index))
9701 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9704 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9707 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9710 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9712 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9718 if (is_add && mask == 0)
9720 errmsg ("Mask required");
9724 if (is_add && skip == ~0)
9726 errmsg ("skip count required");
9730 if (is_add && match == ~0)
9732 errmsg ("match count required");
9736 if (!is_add && table_index == ~0)
9738 errmsg ("table index required for delete");
9742 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9744 mp->is_add = is_add;
9745 mp->del_chain = del_chain;
9746 mp->table_index = ntohl (table_index);
9747 mp->nbuckets = ntohl (nbuckets);
9748 mp->memory_size = ntohl (memory_size);
9749 mp->skip_n_vectors = ntohl (skip);
9750 mp->match_n_vectors = ntohl (match);
9751 mp->next_table_index = ntohl (next_table_index);
9752 mp->miss_next_index = ntohl (miss_next_index);
9753 mp->current_data_flag = ntohl (current_data_flag);
9754 mp->current_data_offset = ntohl (current_data_offset);
9755 clib_memcpy (mp->mask, mask, vec_len (mask));
9764 #if VPP_API_TEST_BUILTIN == 0
9766 unformat_l4_match (unformat_input_t * input, va_list * args)
9768 u8 **matchp = va_arg (*args, u8 **);
9770 u8 *proto_header = 0;
9776 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9778 if (unformat (input, "src_port %d", &src_port))
9780 else if (unformat (input, "dst_port %d", &dst_port))
9786 h.src_port = clib_host_to_net_u16 (src_port);
9787 h.dst_port = clib_host_to_net_u16 (dst_port);
9788 vec_validate (proto_header, sizeof (h) - 1);
9789 memcpy (proto_header, &h, sizeof (h));
9791 *matchp = proto_header;
9797 unformat_ip4_match (unformat_input_t * input, va_list * args)
9799 u8 **matchp = va_arg (*args, u8 **);
9806 int src = 0, dst = 0;
9807 ip4_address_t src_val, dst_val;
9814 int fragment_id = 0;
9815 u32 fragment_id_val;
9821 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9823 if (unformat (input, "version %d", &version_val))
9825 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9827 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9829 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9831 else if (unformat (input, "proto %d", &proto_val))
9833 else if (unformat (input, "tos %d", &tos_val))
9835 else if (unformat (input, "length %d", &length_val))
9837 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9839 else if (unformat (input, "ttl %d", &ttl_val))
9841 else if (unformat (input, "checksum %d", &checksum_val))
9847 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9848 + ttl + checksum == 0)
9852 * Aligned because we use the real comparison functions
9854 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9856 ip = (ip4_header_t *) match;
9858 /* These are realistically matched in practice */
9860 ip->src_address.as_u32 = src_val.as_u32;
9863 ip->dst_address.as_u32 = dst_val.as_u32;
9866 ip->protocol = proto_val;
9869 /* These are not, but they're included for completeness */
9871 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9874 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9880 ip->length = clib_host_to_net_u16 (length_val);
9886 ip->checksum = clib_host_to_net_u16 (checksum_val);
9893 unformat_ip6_match (unformat_input_t * input, va_list * args)
9895 u8 **matchp = va_arg (*args, u8 **);
9900 u8 traffic_class = 0;
9901 u32 traffic_class_val = 0;
9904 int src = 0, dst = 0;
9905 ip6_address_t src_val, dst_val;
9908 int payload_length = 0;
9909 u32 payload_length_val;
9912 u32 ip_version_traffic_class_and_flow_label;
9914 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9916 if (unformat (input, "version %d", &version_val))
9918 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9920 else if (unformat (input, "flow_label %d", &flow_label_val))
9922 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9924 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9926 else if (unformat (input, "proto %d", &proto_val))
9928 else if (unformat (input, "payload_length %d", &payload_length_val))
9930 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9936 if (version + traffic_class + flow_label + src + dst + proto +
9937 payload_length + hop_limit == 0)
9941 * Aligned because we use the real comparison functions
9943 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9945 ip = (ip6_header_t *) match;
9948 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9951 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9954 ip->protocol = proto_val;
9956 ip_version_traffic_class_and_flow_label = 0;
9959 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9962 ip_version_traffic_class_and_flow_label |=
9963 (traffic_class_val & 0xFF) << 20;
9966 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9968 ip->ip_version_traffic_class_and_flow_label =
9969 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9972 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9975 ip->hop_limit = hop_limit_val;
9982 unformat_l3_match (unformat_input_t * input, va_list * args)
9984 u8 **matchp = va_arg (*args, u8 **);
9986 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9988 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9990 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9999 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10001 u8 *tagp = va_arg (*args, u8 *);
10004 if (unformat (input, "%d", &tag))
10006 tagp[0] = (tag >> 8) & 0x0F;
10007 tagp[1] = tag & 0xFF;
10015 unformat_l2_match (unformat_input_t * input, va_list * args)
10017 u8 **matchp = va_arg (*args, u8 **);
10030 u8 ignore_tag1 = 0;
10031 u8 ignore_tag2 = 0;
10037 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10039 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10042 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10044 else if (unformat (input, "proto %U",
10045 unformat_ethernet_type_host_byte_order, &proto_val))
10047 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10049 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10051 else if (unformat (input, "ignore-tag1"))
10053 else if (unformat (input, "ignore-tag2"))
10055 else if (unformat (input, "cos1 %d", &cos1_val))
10057 else if (unformat (input, "cos2 %d", &cos2_val))
10062 if ((src + dst + proto + tag1 + tag2 +
10063 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10066 if (tag1 || ignore_tag1 || cos1)
10068 if (tag2 || ignore_tag2 || cos2)
10071 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10074 clib_memcpy (match, dst_val, 6);
10077 clib_memcpy (match + 6, src_val, 6);
10081 /* inner vlan tag */
10082 match[19] = tag2_val[1];
10083 match[18] = tag2_val[0];
10085 match[18] |= (cos2_val & 0x7) << 5;
10088 match[21] = proto_val & 0xff;
10089 match[20] = proto_val >> 8;
10093 match[15] = tag1_val[1];
10094 match[14] = tag1_val[0];
10097 match[14] |= (cos1_val & 0x7) << 5;
10103 match[15] = tag1_val[1];
10104 match[14] = tag1_val[0];
10107 match[17] = proto_val & 0xff;
10108 match[16] = proto_val >> 8;
10111 match[14] |= (cos1_val & 0x7) << 5;
10117 match[18] |= (cos2_val & 0x7) << 5;
10119 match[14] |= (cos1_val & 0x7) << 5;
10122 match[13] = proto_val & 0xff;
10123 match[12] = proto_val >> 8;
10132 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10134 u8 **matchp = va_arg (*args, u8 **);
10135 u32 skip_n_vectors = va_arg (*args, u32);
10136 u32 match_n_vectors = va_arg (*args, u32);
10143 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10145 if (unformat (input, "hex %U", unformat_hex_string, &match))
10147 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10149 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10151 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10165 if (match || l2 || l3 || l4)
10167 if (l2 || l3 || l4)
10169 /* "Win a free Ethernet header in every packet" */
10171 vec_validate_aligned (l2, 13, sizeof (u32x4));
10175 vec_append_aligned (match, l3, sizeof (u32x4));
10180 vec_append_aligned (match, l4, sizeof (u32x4));
10185 /* Make sure the vector is big enough even if key is all 0's */
10186 vec_validate_aligned
10187 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10190 /* Set size, include skipped vectors */
10191 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10202 api_classify_add_del_session (vat_main_t * vam)
10204 unformat_input_t *i = vam->input;
10205 vl_api_classify_add_del_session_t *mp;
10207 u32 table_index = ~0;
10208 u32 hit_next_index = ~0;
10209 u32 opaque_index = ~0;
10212 u32 skip_n_vectors = 0;
10213 u32 match_n_vectors = 0;
10219 * Warning: you have to supply skip_n and match_n
10220 * because the API client cant simply look at the classify
10224 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10226 if (unformat (i, "del"))
10228 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10231 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10234 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10237 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10239 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10241 else if (unformat (i, "opaque-index %d", &opaque_index))
10243 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10245 else if (unformat (i, "match_n %d", &match_n_vectors))
10247 else if (unformat (i, "match %U", api_unformat_classify_match,
10248 &match, skip_n_vectors, match_n_vectors))
10250 else if (unformat (i, "advance %d", &advance))
10252 else if (unformat (i, "table-index %d", &table_index))
10254 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10256 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10258 else if (unformat (i, "action %d", &action))
10260 else if (unformat (i, "metadata %d", &metadata))
10266 if (table_index == ~0)
10268 errmsg ("Table index required");
10272 if (is_add && match == 0)
10274 errmsg ("Match value required");
10278 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10280 mp->is_add = is_add;
10281 mp->table_index = ntohl (table_index);
10282 mp->hit_next_index = ntohl (hit_next_index);
10283 mp->opaque_index = ntohl (opaque_index);
10284 mp->advance = ntohl (advance);
10285 mp->action = action;
10286 mp->metadata = ntohl (metadata);
10287 clib_memcpy (mp->match, match, vec_len (match));
10296 api_classify_set_interface_ip_table (vat_main_t * vam)
10298 unformat_input_t *i = vam->input;
10299 vl_api_classify_set_interface_ip_table_t *mp;
10301 int sw_if_index_set;
10302 u32 table_index = ~0;
10306 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10308 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10309 sw_if_index_set = 1;
10310 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10311 sw_if_index_set = 1;
10312 else if (unformat (i, "table %d", &table_index))
10316 clib_warning ("parse error '%U'", format_unformat_error, i);
10321 if (sw_if_index_set == 0)
10323 errmsg ("missing interface name or sw_if_index");
10328 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10330 mp->sw_if_index = ntohl (sw_if_index);
10331 mp->table_index = ntohl (table_index);
10332 mp->is_ipv6 = is_ipv6;
10340 api_classify_set_interface_l2_tables (vat_main_t * vam)
10342 unformat_input_t *i = vam->input;
10343 vl_api_classify_set_interface_l2_tables_t *mp;
10345 int sw_if_index_set;
10346 u32 ip4_table_index = ~0;
10347 u32 ip6_table_index = ~0;
10348 u32 other_table_index = ~0;
10352 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10354 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10355 sw_if_index_set = 1;
10356 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10357 sw_if_index_set = 1;
10358 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10360 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10362 else if (unformat (i, "other-table %d", &other_table_index))
10364 else if (unformat (i, "is-input %d", &is_input))
10368 clib_warning ("parse error '%U'", format_unformat_error, i);
10373 if (sw_if_index_set == 0)
10375 errmsg ("missing interface name or sw_if_index");
10380 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10382 mp->sw_if_index = ntohl (sw_if_index);
10383 mp->ip4_table_index = ntohl (ip4_table_index);
10384 mp->ip6_table_index = ntohl (ip6_table_index);
10385 mp->other_table_index = ntohl (other_table_index);
10386 mp->is_input = (u8) is_input;
10394 api_set_ipfix_exporter (vat_main_t * vam)
10396 unformat_input_t *i = vam->input;
10397 vl_api_set_ipfix_exporter_t *mp;
10398 ip4_address_t collector_address;
10399 u8 collector_address_set = 0;
10400 u32 collector_port = ~0;
10401 ip4_address_t src_address;
10402 u8 src_address_set = 0;
10405 u32 template_interval = ~0;
10406 u8 udp_checksum = 0;
10409 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10411 if (unformat (i, "collector_address %U", unformat_ip4_address,
10412 &collector_address))
10413 collector_address_set = 1;
10414 else if (unformat (i, "collector_port %d", &collector_port))
10416 else if (unformat (i, "src_address %U", unformat_ip4_address,
10418 src_address_set = 1;
10419 else if (unformat (i, "vrf_id %d", &vrf_id))
10421 else if (unformat (i, "path_mtu %d", &path_mtu))
10423 else if (unformat (i, "template_interval %d", &template_interval))
10425 else if (unformat (i, "udp_checksum"))
10431 if (collector_address_set == 0)
10433 errmsg ("collector_address required");
10437 if (src_address_set == 0)
10439 errmsg ("src_address required");
10443 M (SET_IPFIX_EXPORTER, mp);
10445 memcpy (mp->collector_address, collector_address.data,
10446 sizeof (collector_address.data));
10447 mp->collector_port = htons ((u16) collector_port);
10448 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10449 mp->vrf_id = htonl (vrf_id);
10450 mp->path_mtu = htonl (path_mtu);
10451 mp->template_interval = htonl (template_interval);
10452 mp->udp_checksum = udp_checksum;
10460 api_set_ipfix_classify_stream (vat_main_t * vam)
10462 unformat_input_t *i = vam->input;
10463 vl_api_set_ipfix_classify_stream_t *mp;
10465 u32 src_port = UDP_DST_PORT_ipfix;
10468 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10470 if (unformat (i, "domain %d", &domain_id))
10472 else if (unformat (i, "src_port %d", &src_port))
10476 errmsg ("unknown input `%U'", format_unformat_error, i);
10481 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10483 mp->domain_id = htonl (domain_id);
10484 mp->src_port = htons ((u16) src_port);
10492 api_ipfix_classify_table_add_del (vat_main_t * vam)
10494 unformat_input_t *i = vam->input;
10495 vl_api_ipfix_classify_table_add_del_t *mp;
10497 u32 classify_table_index = ~0;
10499 u8 transport_protocol = 255;
10502 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10504 if (unformat (i, "add"))
10506 else if (unformat (i, "del"))
10508 else if (unformat (i, "table %d", &classify_table_index))
10510 else if (unformat (i, "ip4"))
10512 else if (unformat (i, "ip6"))
10514 else if (unformat (i, "tcp"))
10515 transport_protocol = 6;
10516 else if (unformat (i, "udp"))
10517 transport_protocol = 17;
10520 errmsg ("unknown input `%U'", format_unformat_error, i);
10527 errmsg ("expecting: add|del");
10530 if (classify_table_index == ~0)
10532 errmsg ("classifier table not specified");
10535 if (ip_version == 0)
10537 errmsg ("IP version not specified");
10541 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10543 mp->is_add = is_add;
10544 mp->table_id = htonl (classify_table_index);
10545 mp->ip_version = ip_version;
10546 mp->transport_protocol = transport_protocol;
10554 api_get_node_index (vat_main_t * vam)
10556 unformat_input_t *i = vam->input;
10557 vl_api_get_node_index_t *mp;
10561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10563 if (unformat (i, "node %s", &name))
10570 errmsg ("node name required");
10573 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10575 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10579 M (GET_NODE_INDEX, mp);
10580 clib_memcpy (mp->node_name, name, vec_len (name));
10589 api_get_next_index (vat_main_t * vam)
10591 unformat_input_t *i = vam->input;
10592 vl_api_get_next_index_t *mp;
10593 u8 *node_name = 0, *next_node_name = 0;
10596 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10598 if (unformat (i, "node-name %s", &node_name))
10600 else if (unformat (i, "next-node-name %s", &next_node_name))
10604 if (node_name == 0)
10606 errmsg ("node name required");
10609 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10611 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10615 if (next_node_name == 0)
10617 errmsg ("next node name required");
10620 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10622 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10626 M (GET_NEXT_INDEX, mp);
10627 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10628 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10629 vec_free (node_name);
10630 vec_free (next_node_name);
10638 api_add_node_next (vat_main_t * vam)
10640 unformat_input_t *i = vam->input;
10641 vl_api_add_node_next_t *mp;
10646 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10648 if (unformat (i, "node %s", &name))
10650 else if (unformat (i, "next %s", &next))
10657 errmsg ("node name required");
10660 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10662 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10667 errmsg ("next node required");
10670 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10672 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10676 M (ADD_NODE_NEXT, mp);
10677 clib_memcpy (mp->node_name, name, vec_len (name));
10678 clib_memcpy (mp->next_name, next, vec_len (next));
10688 api_l2tpv3_create_tunnel (vat_main_t * vam)
10690 unformat_input_t *i = vam->input;
10691 ip6_address_t client_address, our_address;
10692 int client_address_set = 0;
10693 int our_address_set = 0;
10694 u32 local_session_id = 0;
10695 u32 remote_session_id = 0;
10696 u64 local_cookie = 0;
10697 u64 remote_cookie = 0;
10698 u8 l2_sublayer_present = 0;
10699 vl_api_l2tpv3_create_tunnel_t *mp;
10702 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10704 if (unformat (i, "client_address %U", unformat_ip6_address,
10706 client_address_set = 1;
10707 else if (unformat (i, "our_address %U", unformat_ip6_address,
10709 our_address_set = 1;
10710 else if (unformat (i, "local_session_id %d", &local_session_id))
10712 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10714 else if (unformat (i, "local_cookie %lld", &local_cookie))
10716 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10718 else if (unformat (i, "l2-sublayer-present"))
10719 l2_sublayer_present = 1;
10724 if (client_address_set == 0)
10726 errmsg ("client_address required");
10730 if (our_address_set == 0)
10732 errmsg ("our_address required");
10736 M (L2TPV3_CREATE_TUNNEL, mp);
10738 clib_memcpy (mp->client_address, client_address.as_u8,
10739 sizeof (mp->client_address));
10741 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10743 mp->local_session_id = ntohl (local_session_id);
10744 mp->remote_session_id = ntohl (remote_session_id);
10745 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10746 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10747 mp->l2_sublayer_present = l2_sublayer_present;
10756 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10758 unformat_input_t *i = vam->input;
10760 u8 sw_if_index_set = 0;
10761 u64 new_local_cookie = 0;
10762 u64 new_remote_cookie = 0;
10763 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10766 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10768 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10769 sw_if_index_set = 1;
10770 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10771 sw_if_index_set = 1;
10772 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10774 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10780 if (sw_if_index_set == 0)
10782 errmsg ("missing interface name or sw_if_index");
10786 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10788 mp->sw_if_index = ntohl (sw_if_index);
10789 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10790 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10798 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10800 unformat_input_t *i = vam->input;
10801 vl_api_l2tpv3_interface_enable_disable_t *mp;
10803 u8 sw_if_index_set = 0;
10804 u8 enable_disable = 1;
10807 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10809 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10810 sw_if_index_set = 1;
10811 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10812 sw_if_index_set = 1;
10813 else if (unformat (i, "enable"))
10814 enable_disable = 1;
10815 else if (unformat (i, "disable"))
10816 enable_disable = 0;
10821 if (sw_if_index_set == 0)
10823 errmsg ("missing interface name or sw_if_index");
10827 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10829 mp->sw_if_index = ntohl (sw_if_index);
10830 mp->enable_disable = enable_disable;
10838 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10840 unformat_input_t *i = vam->input;
10841 vl_api_l2tpv3_set_lookup_key_t *mp;
10845 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10847 if (unformat (i, "lookup_v6_src"))
10848 key = L2T_LOOKUP_SRC_ADDRESS;
10849 else if (unformat (i, "lookup_v6_dst"))
10850 key = L2T_LOOKUP_DST_ADDRESS;
10851 else if (unformat (i, "lookup_session_id"))
10852 key = L2T_LOOKUP_SESSION_ID;
10857 if (key == (u8) ~ 0)
10859 errmsg ("l2tp session lookup key unset");
10863 M (L2TPV3_SET_LOOKUP_KEY, mp);
10872 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10873 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10875 vat_main_t *vam = &vat_main;
10877 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10878 format_ip6_address, mp->our_address,
10879 format_ip6_address, mp->client_address,
10880 clib_net_to_host_u32 (mp->sw_if_index));
10883 " local cookies %016llx %016llx remote cookie %016llx",
10884 clib_net_to_host_u64 (mp->local_cookie[0]),
10885 clib_net_to_host_u64 (mp->local_cookie[1]),
10886 clib_net_to_host_u64 (mp->remote_cookie));
10888 print (vam->ofp, " local session-id %d remote session-id %d",
10889 clib_net_to_host_u32 (mp->local_session_id),
10890 clib_net_to_host_u32 (mp->remote_session_id));
10892 print (vam->ofp, " l2 specific sublayer %s\n",
10893 mp->l2_sublayer_present ? "preset" : "absent");
10897 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10898 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10900 vat_main_t *vam = &vat_main;
10901 vat_json_node_t *node = NULL;
10902 struct in6_addr addr;
10904 if (VAT_JSON_ARRAY != vam->json_tree.type)
10906 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10907 vat_json_init_array (&vam->json_tree);
10909 node = vat_json_array_add (&vam->json_tree);
10911 vat_json_init_object (node);
10913 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10914 vat_json_object_add_ip6 (node, "our_address", addr);
10915 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10916 vat_json_object_add_ip6 (node, "client_address", addr);
10918 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10919 vat_json_init_array (lc);
10920 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10921 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10922 vat_json_object_add_uint (node, "remote_cookie",
10923 clib_net_to_host_u64 (mp->remote_cookie));
10925 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10926 vat_json_object_add_uint (node, "local_session_id",
10927 clib_net_to_host_u32 (mp->local_session_id));
10928 vat_json_object_add_uint (node, "remote_session_id",
10929 clib_net_to_host_u32 (mp->remote_session_id));
10930 vat_json_object_add_string_copy (node, "l2_sublayer",
10931 mp->l2_sublayer_present ? (u8 *) "present"
10932 : (u8 *) "absent");
10936 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10938 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10939 vl_api_control_ping_t *mp_ping;
10942 /* Get list of l2tpv3-tunnel interfaces */
10943 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10946 /* Use a control ping for synchronization */
10947 M (CONTROL_PING, mp_ping);
10955 static void vl_api_sw_interface_tap_details_t_handler
10956 (vl_api_sw_interface_tap_details_t * mp)
10958 vat_main_t *vam = &vat_main;
10960 print (vam->ofp, "%-16s %d",
10961 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10964 static void vl_api_sw_interface_tap_details_t_handler_json
10965 (vl_api_sw_interface_tap_details_t * mp)
10967 vat_main_t *vam = &vat_main;
10968 vat_json_node_t *node = NULL;
10970 if (VAT_JSON_ARRAY != vam->json_tree.type)
10972 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10973 vat_json_init_array (&vam->json_tree);
10975 node = vat_json_array_add (&vam->json_tree);
10977 vat_json_init_object (node);
10978 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10979 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10983 api_sw_interface_tap_dump (vat_main_t * vam)
10985 vl_api_sw_interface_tap_dump_t *mp;
10986 vl_api_control_ping_t *mp_ping;
10989 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10990 /* Get list of tap interfaces */
10991 M (SW_INTERFACE_TAP_DUMP, mp);
10994 /* Use a control ping for synchronization */
10995 M (CONTROL_PING, mp_ping);
11002 static uword unformat_vxlan_decap_next
11003 (unformat_input_t * input, va_list * args)
11005 u32 *result = va_arg (*args, u32 *);
11008 if (unformat (input, "l2"))
11009 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11010 else if (unformat (input, "%d", &tmp))
11018 api_vxlan_add_del_tunnel (vat_main_t * vam)
11020 unformat_input_t *line_input = vam->input;
11021 vl_api_vxlan_add_del_tunnel_t *mp;
11022 ip46_address_t src, dst;
11024 u8 ipv4_set = 0, ipv6_set = 0;
11028 u32 mcast_sw_if_index = ~0;
11029 u32 encap_vrf_id = 0;
11030 u32 decap_next_index = ~0;
11034 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11035 memset (&src, 0, sizeof src);
11036 memset (&dst, 0, sizeof dst);
11038 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11040 if (unformat (line_input, "del"))
11043 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11049 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11055 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11061 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11066 else if (unformat (line_input, "group %U %U",
11067 unformat_ip4_address, &dst.ip4,
11068 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11070 grp_set = dst_set = 1;
11073 else if (unformat (line_input, "group %U",
11074 unformat_ip4_address, &dst.ip4))
11076 grp_set = dst_set = 1;
11079 else if (unformat (line_input, "group %U %U",
11080 unformat_ip6_address, &dst.ip6,
11081 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11083 grp_set = dst_set = 1;
11086 else if (unformat (line_input, "group %U",
11087 unformat_ip6_address, &dst.ip6))
11089 grp_set = dst_set = 1;
11093 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11095 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11097 else if (unformat (line_input, "decap-next %U",
11098 unformat_vxlan_decap_next, &decap_next_index))
11100 else if (unformat (line_input, "vni %d", &vni))
11104 errmsg ("parse error '%U'", format_unformat_error, line_input);
11111 errmsg ("tunnel src address not specified");
11116 errmsg ("tunnel dst address not specified");
11120 if (grp_set && !ip46_address_is_multicast (&dst))
11122 errmsg ("tunnel group address not multicast");
11125 if (grp_set && mcast_sw_if_index == ~0)
11127 errmsg ("tunnel nonexistent multicast device");
11130 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11132 errmsg ("tunnel dst address must be unicast");
11137 if (ipv4_set && ipv6_set)
11139 errmsg ("both IPv4 and IPv6 addresses specified");
11143 if ((vni == 0) || (vni >> 24))
11145 errmsg ("vni not specified or out of range");
11149 M (VXLAN_ADD_DEL_TUNNEL, mp);
11153 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
11154 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
11158 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
11159 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
11161 mp->encap_vrf_id = ntohl (encap_vrf_id);
11162 mp->decap_next_index = ntohl (decap_next_index);
11163 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11164 mp->vni = ntohl (vni);
11165 mp->is_add = is_add;
11166 mp->is_ipv6 = ipv6_set;
11173 static void vl_api_vxlan_tunnel_details_t_handler
11174 (vl_api_vxlan_tunnel_details_t * mp)
11176 vat_main_t *vam = &vat_main;
11177 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
11178 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
11180 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
11181 ntohl (mp->sw_if_index),
11182 format_ip46_address, &src, IP46_TYPE_ANY,
11183 format_ip46_address, &dst, IP46_TYPE_ANY,
11184 ntohl (mp->encap_vrf_id),
11185 ntohl (mp->decap_next_index), ntohl (mp->vni),
11186 ntohl (mp->mcast_sw_if_index));
11189 static void vl_api_vxlan_tunnel_details_t_handler_json
11190 (vl_api_vxlan_tunnel_details_t * mp)
11192 vat_main_t *vam = &vat_main;
11193 vat_json_node_t *node = NULL;
11195 if (VAT_JSON_ARRAY != vam->json_tree.type)
11197 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11198 vat_json_init_array (&vam->json_tree);
11200 node = vat_json_array_add (&vam->json_tree);
11202 vat_json_init_object (node);
11203 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11206 struct in6_addr ip6;
11208 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
11209 vat_json_object_add_ip6 (node, "src_address", ip6);
11210 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
11211 vat_json_object_add_ip6 (node, "dst_address", ip6);
11215 struct in_addr ip4;
11217 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
11218 vat_json_object_add_ip4 (node, "src_address", ip4);
11219 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
11220 vat_json_object_add_ip4 (node, "dst_address", ip4);
11222 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11223 vat_json_object_add_uint (node, "decap_next_index",
11224 ntohl (mp->decap_next_index));
11225 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11226 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11227 vat_json_object_add_uint (node, "mcast_sw_if_index",
11228 ntohl (mp->mcast_sw_if_index));
11232 api_vxlan_tunnel_dump (vat_main_t * vam)
11234 unformat_input_t *i = vam->input;
11235 vl_api_vxlan_tunnel_dump_t *mp;
11236 vl_api_control_ping_t *mp_ping;
11238 u8 sw_if_index_set = 0;
11241 /* Parse args required to build the message */
11242 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11244 if (unformat (i, "sw_if_index %d", &sw_if_index))
11245 sw_if_index_set = 1;
11250 if (sw_if_index_set == 0)
11255 if (!vam->json_output)
11257 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
11258 "sw_if_index", "src_address", "dst_address",
11259 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11262 /* Get list of vxlan-tunnel interfaces */
11263 M (VXLAN_TUNNEL_DUMP, mp);
11265 mp->sw_if_index = htonl (sw_if_index);
11269 /* Use a control ping for synchronization */
11270 M (CONTROL_PING, mp_ping);
11278 api_gre_add_del_tunnel (vat_main_t * vam)
11280 unformat_input_t *line_input = vam->input;
11281 vl_api_gre_add_del_tunnel_t *mp;
11282 ip4_address_t src4, dst4;
11283 ip6_address_t src6, dst6;
11290 u32 outer_fib_id = 0;
11293 memset (&src4, 0, sizeof src4);
11294 memset (&dst4, 0, sizeof dst4);
11295 memset (&src6, 0, sizeof src6);
11296 memset (&dst6, 0, sizeof dst6);
11298 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11300 if (unformat (line_input, "del"))
11302 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
11307 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
11312 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
11317 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
11322 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
11324 else if (unformat (line_input, "teb"))
11328 errmsg ("parse error '%U'", format_unformat_error, line_input);
11335 errmsg ("tunnel src address not specified");
11340 errmsg ("tunnel dst address not specified");
11343 if (ipv4_set && ipv6_set)
11345 errmsg ("both IPv4 and IPv6 addresses specified");
11350 M (GRE_ADD_DEL_TUNNEL, mp);
11354 clib_memcpy (&mp->src_address, &src4, 4);
11355 clib_memcpy (&mp->dst_address, &dst4, 4);
11359 clib_memcpy (&mp->src_address, &src6, 16);
11360 clib_memcpy (&mp->dst_address, &dst6, 16);
11362 mp->outer_fib_id = ntohl (outer_fib_id);
11363 mp->is_add = is_add;
11365 mp->is_ipv6 = ipv6_set;
11372 static void vl_api_gre_tunnel_details_t_handler
11373 (vl_api_gre_tunnel_details_t * mp)
11375 vat_main_t *vam = &vat_main;
11376 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
11377 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
11379 print (vam->ofp, "%11d%24U%24U%6d%14d",
11380 ntohl (mp->sw_if_index),
11381 format_ip46_address, &src, IP46_TYPE_ANY,
11382 format_ip46_address, &dst, IP46_TYPE_ANY,
11383 mp->teb, ntohl (mp->outer_fib_id));
11386 static void vl_api_gre_tunnel_details_t_handler_json
11387 (vl_api_gre_tunnel_details_t * mp)
11389 vat_main_t *vam = &vat_main;
11390 vat_json_node_t *node = NULL;
11391 struct in_addr ip4;
11392 struct in6_addr ip6;
11394 if (VAT_JSON_ARRAY != vam->json_tree.type)
11396 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11397 vat_json_init_array (&vam->json_tree);
11399 node = vat_json_array_add (&vam->json_tree);
11401 vat_json_init_object (node);
11402 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11405 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11406 vat_json_object_add_ip4 (node, "src_address", ip4);
11407 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11408 vat_json_object_add_ip4 (node, "dst_address", ip4);
11412 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
11413 vat_json_object_add_ip6 (node, "src_address", ip6);
11414 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
11415 vat_json_object_add_ip6 (node, "dst_address", ip6);
11417 vat_json_object_add_uint (node, "teb", mp->teb);
11418 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11419 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
11423 api_gre_tunnel_dump (vat_main_t * vam)
11425 unformat_input_t *i = vam->input;
11426 vl_api_gre_tunnel_dump_t *mp;
11427 vl_api_control_ping_t *mp_ping;
11429 u8 sw_if_index_set = 0;
11432 /* Parse args required to build the message */
11433 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11435 if (unformat (i, "sw_if_index %d", &sw_if_index))
11436 sw_if_index_set = 1;
11441 if (sw_if_index_set == 0)
11446 if (!vam->json_output)
11448 print (vam->ofp, "%11s%24s%24s%6s%14s",
11449 "sw_if_index", "src_address", "dst_address", "teb",
11453 /* Get list of gre-tunnel interfaces */
11454 M (GRE_TUNNEL_DUMP, mp);
11456 mp->sw_if_index = htonl (sw_if_index);
11460 /* Use a control ping for synchronization */
11461 M (CONTROL_PING, mp_ping);
11469 api_l2_fib_clear_table (vat_main_t * vam)
11471 // unformat_input_t * i = vam->input;
11472 vl_api_l2_fib_clear_table_t *mp;
11475 M (L2_FIB_CLEAR_TABLE, mp);
11483 api_l2_interface_efp_filter (vat_main_t * vam)
11485 unformat_input_t *i = vam->input;
11486 vl_api_l2_interface_efp_filter_t *mp;
11489 u8 sw_if_index_set = 0;
11492 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11494 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11495 sw_if_index_set = 1;
11496 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11497 sw_if_index_set = 1;
11498 else if (unformat (i, "enable"))
11500 else if (unformat (i, "disable"))
11504 clib_warning ("parse error '%U'", format_unformat_error, i);
11509 if (sw_if_index_set == 0)
11511 errmsg ("missing sw_if_index");
11515 M (L2_INTERFACE_EFP_FILTER, mp);
11517 mp->sw_if_index = ntohl (sw_if_index);
11518 mp->enable_disable = enable;
11525 #define foreach_vtr_op \
11526 _("disable", L2_VTR_DISABLED) \
11527 _("push-1", L2_VTR_PUSH_1) \
11528 _("push-2", L2_VTR_PUSH_2) \
11529 _("pop-1", L2_VTR_POP_1) \
11530 _("pop-2", L2_VTR_POP_2) \
11531 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11532 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11533 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11534 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11537 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11539 unformat_input_t *i = vam->input;
11540 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11542 u8 sw_if_index_set = 0;
11545 u32 push_dot1q = 1;
11550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11552 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11553 sw_if_index_set = 1;
11554 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11555 sw_if_index_set = 1;
11556 else if (unformat (i, "vtr_op %d", &vtr_op))
11558 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11561 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11563 else if (unformat (i, "tag1 %d", &tag1))
11565 else if (unformat (i, "tag2 %d", &tag2))
11569 clib_warning ("parse error '%U'", format_unformat_error, i);
11574 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11576 errmsg ("missing vtr operation or sw_if_index");
11580 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11581 mp->sw_if_index = ntohl (sw_if_index);
11582 mp->vtr_op = ntohl (vtr_op);
11583 mp->push_dot1q = ntohl (push_dot1q);
11584 mp->tag1 = ntohl (tag1);
11585 mp->tag2 = ntohl (tag2);
11593 api_create_vhost_user_if (vat_main_t * vam)
11595 unformat_input_t *i = vam->input;
11596 vl_api_create_vhost_user_if_t *mp;
11599 u8 file_name_set = 0;
11600 u32 custom_dev_instance = ~0;
11602 u8 use_custom_mac = 0;
11606 /* Shut up coverity */
11607 memset (hwaddr, 0, sizeof (hwaddr));
11609 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11611 if (unformat (i, "socket %s", &file_name))
11615 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11617 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11618 use_custom_mac = 1;
11619 else if (unformat (i, "server"))
11621 else if (unformat (i, "tag %s", &tag))
11627 if (file_name_set == 0)
11629 errmsg ("missing socket file name");
11633 if (vec_len (file_name) > 255)
11635 errmsg ("socket file name too long");
11638 vec_add1 (file_name, 0);
11640 M (CREATE_VHOST_USER_IF, mp);
11642 mp->is_server = is_server;
11643 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11644 vec_free (file_name);
11645 if (custom_dev_instance != ~0)
11648 mp->custom_dev_instance = ntohl (custom_dev_instance);
11650 mp->use_custom_mac = use_custom_mac;
11651 clib_memcpy (mp->mac_address, hwaddr, 6);
11653 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11662 api_modify_vhost_user_if (vat_main_t * vam)
11664 unformat_input_t *i = vam->input;
11665 vl_api_modify_vhost_user_if_t *mp;
11668 u8 file_name_set = 0;
11669 u32 custom_dev_instance = ~0;
11670 u8 sw_if_index_set = 0;
11671 u32 sw_if_index = (u32) ~ 0;
11674 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11676 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11677 sw_if_index_set = 1;
11678 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11679 sw_if_index_set = 1;
11680 else if (unformat (i, "socket %s", &file_name))
11684 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11686 else if (unformat (i, "server"))
11692 if (sw_if_index_set == 0)
11694 errmsg ("missing sw_if_index or interface name");
11698 if (file_name_set == 0)
11700 errmsg ("missing socket file name");
11704 if (vec_len (file_name) > 255)
11706 errmsg ("socket file name too long");
11709 vec_add1 (file_name, 0);
11711 M (MODIFY_VHOST_USER_IF, mp);
11713 mp->sw_if_index = ntohl (sw_if_index);
11714 mp->is_server = is_server;
11715 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11716 vec_free (file_name);
11717 if (custom_dev_instance != ~0)
11720 mp->custom_dev_instance = ntohl (custom_dev_instance);
11729 api_delete_vhost_user_if (vat_main_t * vam)
11731 unformat_input_t *i = vam->input;
11732 vl_api_delete_vhost_user_if_t *mp;
11733 u32 sw_if_index = ~0;
11734 u8 sw_if_index_set = 0;
11737 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11739 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11740 sw_if_index_set = 1;
11741 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11742 sw_if_index_set = 1;
11747 if (sw_if_index_set == 0)
11749 errmsg ("missing sw_if_index or interface name");
11754 M (DELETE_VHOST_USER_IF, mp);
11756 mp->sw_if_index = ntohl (sw_if_index);
11763 static void vl_api_sw_interface_vhost_user_details_t_handler
11764 (vl_api_sw_interface_vhost_user_details_t * mp)
11766 vat_main_t *vam = &vat_main;
11768 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11769 (char *) mp->interface_name,
11770 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11771 clib_net_to_host_u64 (mp->features), mp->is_server,
11772 ntohl (mp->num_regions), (char *) mp->sock_filename);
11773 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11776 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11777 (vl_api_sw_interface_vhost_user_details_t * mp)
11779 vat_main_t *vam = &vat_main;
11780 vat_json_node_t *node = NULL;
11782 if (VAT_JSON_ARRAY != vam->json_tree.type)
11784 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11785 vat_json_init_array (&vam->json_tree);
11787 node = vat_json_array_add (&vam->json_tree);
11789 vat_json_init_object (node);
11790 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11791 vat_json_object_add_string_copy (node, "interface_name",
11792 mp->interface_name);
11793 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11794 ntohl (mp->virtio_net_hdr_sz));
11795 vat_json_object_add_uint (node, "features",
11796 clib_net_to_host_u64 (mp->features));
11797 vat_json_object_add_uint (node, "is_server", mp->is_server);
11798 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11799 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11800 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11804 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11806 vl_api_sw_interface_vhost_user_dump_t *mp;
11807 vl_api_control_ping_t *mp_ping;
11810 "Interface name idx hdr_sz features server regions filename");
11812 /* Get list of vhost-user interfaces */
11813 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11816 /* Use a control ping for synchronization */
11817 M (CONTROL_PING, mp_ping);
11825 api_show_version (vat_main_t * vam)
11827 vl_api_show_version_t *mp;
11830 M (SHOW_VERSION, mp);
11839 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11841 unformat_input_t *line_input = vam->input;
11842 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11843 ip4_address_t local4, remote4;
11844 ip6_address_t local6, remote6;
11846 u8 ipv4_set = 0, ipv6_set = 0;
11849 u32 encap_vrf_id = 0;
11850 u32 decap_vrf_id = 0;
11856 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11858 if (unformat (line_input, "del"))
11860 else if (unformat (line_input, "local %U",
11861 unformat_ip4_address, &local4))
11866 else if (unformat (line_input, "remote %U",
11867 unformat_ip4_address, &remote4))
11872 else if (unformat (line_input, "local %U",
11873 unformat_ip6_address, &local6))
11878 else if (unformat (line_input, "remote %U",
11879 unformat_ip6_address, &remote6))
11884 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11886 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11888 else if (unformat (line_input, "vni %d", &vni))
11890 else if (unformat (line_input, "next-ip4"))
11892 else if (unformat (line_input, "next-ip6"))
11894 else if (unformat (line_input, "next-ethernet"))
11896 else if (unformat (line_input, "next-nsh"))
11900 errmsg ("parse error '%U'", format_unformat_error, line_input);
11905 if (local_set == 0)
11907 errmsg ("tunnel local address not specified");
11910 if (remote_set == 0)
11912 errmsg ("tunnel remote address not specified");
11915 if (ipv4_set && ipv6_set)
11917 errmsg ("both IPv4 and IPv6 addresses specified");
11923 errmsg ("vni not specified");
11927 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11932 clib_memcpy (&mp->local, &local6, sizeof (local6));
11933 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11937 clib_memcpy (&mp->local, &local4, sizeof (local4));
11938 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11941 mp->encap_vrf_id = ntohl (encap_vrf_id);
11942 mp->decap_vrf_id = ntohl (decap_vrf_id);
11943 mp->protocol = protocol;
11944 mp->vni = ntohl (vni);
11945 mp->is_add = is_add;
11946 mp->is_ipv6 = ipv6_set;
11953 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11954 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11956 vat_main_t *vam = &vat_main;
11958 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11959 ntohl (mp->sw_if_index),
11960 format_ip46_address, &(mp->local[0]),
11961 format_ip46_address, &(mp->remote[0]),
11963 ntohl (mp->protocol),
11964 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11967 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11968 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11970 vat_main_t *vam = &vat_main;
11971 vat_json_node_t *node = NULL;
11972 struct in_addr ip4;
11973 struct in6_addr ip6;
11975 if (VAT_JSON_ARRAY != vam->json_tree.type)
11977 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11978 vat_json_init_array (&vam->json_tree);
11980 node = vat_json_array_add (&vam->json_tree);
11982 vat_json_init_object (node);
11983 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11986 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11987 vat_json_object_add_ip6 (node, "local", ip6);
11988 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11989 vat_json_object_add_ip6 (node, "remote", ip6);
11993 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11994 vat_json_object_add_ip4 (node, "local", ip4);
11995 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11996 vat_json_object_add_ip4 (node, "remote", ip4);
11998 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11999 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
12000 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12001 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
12002 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12006 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
12008 unformat_input_t *i = vam->input;
12009 vl_api_vxlan_gpe_tunnel_dump_t *mp;
12010 vl_api_control_ping_t *mp_ping;
12012 u8 sw_if_index_set = 0;
12015 /* Parse args required to build the message */
12016 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12018 if (unformat (i, "sw_if_index %d", &sw_if_index))
12019 sw_if_index_set = 1;
12024 if (sw_if_index_set == 0)
12029 if (!vam->json_output)
12031 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
12032 "sw_if_index", "local", "remote", "vni",
12033 "protocol", "encap_vrf_id", "decap_vrf_id");
12036 /* Get list of vxlan-tunnel interfaces */
12037 M (VXLAN_GPE_TUNNEL_DUMP, mp);
12039 mp->sw_if_index = htonl (sw_if_index);
12043 /* Use a control ping for synchronization */
12044 M (CONTROL_PING, mp_ping);
12052 format_l2_fib_mac_address (u8 * s, va_list * args)
12054 u8 *a = va_arg (*args, u8 *);
12056 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
12057 a[2], a[3], a[4], a[5], a[6], a[7]);
12060 static void vl_api_l2_fib_table_details_t_handler
12061 (vl_api_l2_fib_table_details_t * mp)
12063 vat_main_t *vam = &vat_main;
12065 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
12067 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
12068 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
12072 static void vl_api_l2_fib_table_details_t_handler_json
12073 (vl_api_l2_fib_table_details_t * mp)
12075 vat_main_t *vam = &vat_main;
12076 vat_json_node_t *node = NULL;
12078 if (VAT_JSON_ARRAY != vam->json_tree.type)
12080 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12081 vat_json_init_array (&vam->json_tree);
12083 node = vat_json_array_add (&vam->json_tree);
12085 vat_json_init_object (node);
12086 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
12087 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
12088 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12089 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
12090 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
12091 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
12095 api_l2_fib_table_dump (vat_main_t * vam)
12097 unformat_input_t *i = vam->input;
12098 vl_api_l2_fib_table_dump_t *mp;
12099 vl_api_control_ping_t *mp_ping;
12104 /* Parse args required to build the message */
12105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12107 if (unformat (i, "bd_id %d", &bd_id))
12113 if (bd_id_set == 0)
12115 errmsg ("missing bridge domain");
12119 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
12121 /* Get list of l2 fib entries */
12122 M (L2_FIB_TABLE_DUMP, mp);
12124 mp->bd_id = ntohl (bd_id);
12127 /* Use a control ping for synchronization */
12128 M (CONTROL_PING, mp_ping);
12137 api_interface_name_renumber (vat_main_t * vam)
12139 unformat_input_t *line_input = vam->input;
12140 vl_api_interface_name_renumber_t *mp;
12141 u32 sw_if_index = ~0;
12142 u32 new_show_dev_instance = ~0;
12145 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12147 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
12150 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12152 else if (unformat (line_input, "new_show_dev_instance %d",
12153 &new_show_dev_instance))
12159 if (sw_if_index == ~0)
12161 errmsg ("missing interface name or sw_if_index");
12165 if (new_show_dev_instance == ~0)
12167 errmsg ("missing new_show_dev_instance");
12171 M (INTERFACE_NAME_RENUMBER, mp);
12173 mp->sw_if_index = ntohl (sw_if_index);
12174 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
12182 api_want_ip4_arp_events (vat_main_t * vam)
12184 unformat_input_t *line_input = vam->input;
12185 vl_api_want_ip4_arp_events_t *mp;
12186 ip4_address_t address;
12187 int address_set = 0;
12188 u32 enable_disable = 1;
12191 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12193 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
12195 else if (unformat (line_input, "del"))
12196 enable_disable = 0;
12201 if (address_set == 0)
12203 errmsg ("missing addresses");
12207 M (WANT_IP4_ARP_EVENTS, mp);
12208 mp->enable_disable = enable_disable;
12209 mp->pid = htonl (getpid ());
12210 mp->address = address.as_u32;
12218 api_want_ip6_nd_events (vat_main_t * vam)
12220 unformat_input_t *line_input = vam->input;
12221 vl_api_want_ip6_nd_events_t *mp;
12222 ip6_address_t address;
12223 int address_set = 0;
12224 u32 enable_disable = 1;
12227 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12229 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
12231 else if (unformat (line_input, "del"))
12232 enable_disable = 0;
12237 if (address_set == 0)
12239 errmsg ("missing addresses");
12243 M (WANT_IP6_ND_EVENTS, mp);
12244 mp->enable_disable = enable_disable;
12245 mp->pid = htonl (getpid ());
12246 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
12254 api_input_acl_set_interface (vat_main_t * vam)
12256 unformat_input_t *i = vam->input;
12257 vl_api_input_acl_set_interface_t *mp;
12259 int sw_if_index_set;
12260 u32 ip4_table_index = ~0;
12261 u32 ip6_table_index = ~0;
12262 u32 l2_table_index = ~0;
12266 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12268 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12269 sw_if_index_set = 1;
12270 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12271 sw_if_index_set = 1;
12272 else if (unformat (i, "del"))
12274 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12276 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12278 else if (unformat (i, "l2-table %d", &l2_table_index))
12282 clib_warning ("parse error '%U'", format_unformat_error, i);
12287 if (sw_if_index_set == 0)
12289 errmsg ("missing interface name or sw_if_index");
12293 M (INPUT_ACL_SET_INTERFACE, mp);
12295 mp->sw_if_index = ntohl (sw_if_index);
12296 mp->ip4_table_index = ntohl (ip4_table_index);
12297 mp->ip6_table_index = ntohl (ip6_table_index);
12298 mp->l2_table_index = ntohl (l2_table_index);
12299 mp->is_add = is_add;
12307 api_ip_address_dump (vat_main_t * vam)
12309 unformat_input_t *i = vam->input;
12310 vl_api_ip_address_dump_t *mp;
12311 vl_api_control_ping_t *mp_ping;
12312 u32 sw_if_index = ~0;
12313 u8 sw_if_index_set = 0;
12318 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12320 if (unformat (i, "sw_if_index %d", &sw_if_index))
12321 sw_if_index_set = 1;
12323 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12324 sw_if_index_set = 1;
12325 else if (unformat (i, "ipv4"))
12327 else if (unformat (i, "ipv6"))
12333 if (ipv4_set && ipv6_set)
12335 errmsg ("ipv4 and ipv6 flags cannot be both set");
12339 if ((!ipv4_set) && (!ipv6_set))
12341 errmsg ("no ipv4 nor ipv6 flag set");
12345 if (sw_if_index_set == 0)
12347 errmsg ("missing interface name or sw_if_index");
12351 vam->current_sw_if_index = sw_if_index;
12352 vam->is_ipv6 = ipv6_set;
12354 M (IP_ADDRESS_DUMP, mp);
12355 mp->sw_if_index = ntohl (sw_if_index);
12356 mp->is_ipv6 = ipv6_set;
12359 /* Use a control ping for synchronization */
12360 M (CONTROL_PING, mp_ping);
12368 api_ip_dump (vat_main_t * vam)
12370 vl_api_ip_dump_t *mp;
12371 vl_api_control_ping_t *mp_ping;
12372 unformat_input_t *in = vam->input;
12379 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
12381 if (unformat (in, "ipv4"))
12383 else if (unformat (in, "ipv6"))
12389 if (ipv4_set && ipv6_set)
12391 errmsg ("ipv4 and ipv6 flags cannot be both set");
12395 if ((!ipv4_set) && (!ipv6_set))
12397 errmsg ("no ipv4 nor ipv6 flag set");
12401 is_ipv6 = ipv6_set;
12402 vam->is_ipv6 = is_ipv6;
12404 /* free old data */
12405 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12407 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12409 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12412 mp->is_ipv6 = ipv6_set;
12415 /* Use a control ping for synchronization */
12416 M (CONTROL_PING, mp_ping);
12424 api_ipsec_spd_add_del (vat_main_t * vam)
12426 unformat_input_t *i = vam->input;
12427 vl_api_ipsec_spd_add_del_t *mp;
12432 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12434 if (unformat (i, "spd_id %d", &spd_id))
12436 else if (unformat (i, "del"))
12440 clib_warning ("parse error '%U'", format_unformat_error, i);
12446 errmsg ("spd_id must be set");
12450 M (IPSEC_SPD_ADD_DEL, mp);
12452 mp->spd_id = ntohl (spd_id);
12453 mp->is_add = is_add;
12461 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12463 unformat_input_t *i = vam->input;
12464 vl_api_ipsec_interface_add_del_spd_t *mp;
12466 u8 sw_if_index_set = 0;
12467 u32 spd_id = (u32) ~ 0;
12471 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12473 if (unformat (i, "del"))
12475 else if (unformat (i, "spd_id %d", &spd_id))
12478 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12479 sw_if_index_set = 1;
12480 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12481 sw_if_index_set = 1;
12484 clib_warning ("parse error '%U'", format_unformat_error, i);
12490 if (spd_id == (u32) ~ 0)
12492 errmsg ("spd_id must be set");
12496 if (sw_if_index_set == 0)
12498 errmsg ("missing interface name or sw_if_index");
12502 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12504 mp->spd_id = ntohl (spd_id);
12505 mp->sw_if_index = ntohl (sw_if_index);
12506 mp->is_add = is_add;
12514 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12516 unformat_input_t *i = vam->input;
12517 vl_api_ipsec_spd_add_del_entry_t *mp;
12518 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12519 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12521 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12522 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12523 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12524 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12527 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12528 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12529 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12530 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12531 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12532 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12534 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12536 if (unformat (i, "del"))
12538 if (unformat (i, "outbound"))
12540 if (unformat (i, "inbound"))
12542 else if (unformat (i, "spd_id %d", &spd_id))
12544 else if (unformat (i, "sa_id %d", &sa_id))
12546 else if (unformat (i, "priority %d", &priority))
12548 else if (unformat (i, "protocol %d", &protocol))
12550 else if (unformat (i, "lport_start %d", &lport_start))
12552 else if (unformat (i, "lport_stop %d", &lport_stop))
12554 else if (unformat (i, "rport_start %d", &rport_start))
12556 else if (unformat (i, "rport_stop %d", &rport_stop))
12560 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12566 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12573 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12579 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12586 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12592 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12599 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12605 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12611 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12613 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12615 clib_warning ("unsupported action: 'resolve'");
12621 clib_warning ("parse error '%U'", format_unformat_error, i);
12627 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12629 mp->spd_id = ntohl (spd_id);
12630 mp->priority = ntohl (priority);
12631 mp->is_outbound = is_outbound;
12633 mp->is_ipv6 = is_ipv6;
12634 if (is_ipv6 || is_ip_any)
12636 clib_memcpy (mp->remote_address_start, &raddr6_start,
12637 sizeof (ip6_address_t));
12638 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12639 sizeof (ip6_address_t));
12640 clib_memcpy (mp->local_address_start, &laddr6_start,
12641 sizeof (ip6_address_t));
12642 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12643 sizeof (ip6_address_t));
12647 clib_memcpy (mp->remote_address_start, &raddr4_start,
12648 sizeof (ip4_address_t));
12649 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12650 sizeof (ip4_address_t));
12651 clib_memcpy (mp->local_address_start, &laddr4_start,
12652 sizeof (ip4_address_t));
12653 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12654 sizeof (ip4_address_t));
12656 mp->protocol = (u8) protocol;
12657 mp->local_port_start = ntohs ((u16) lport_start);
12658 mp->local_port_stop = ntohs ((u16) lport_stop);
12659 mp->remote_port_start = ntohs ((u16) rport_start);
12660 mp->remote_port_stop = ntohs ((u16) rport_stop);
12661 mp->policy = (u8) policy;
12662 mp->sa_id = ntohl (sa_id);
12663 mp->is_add = is_add;
12664 mp->is_ip_any = is_ip_any;
12671 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12673 unformat_input_t *i = vam->input;
12674 vl_api_ipsec_sad_add_del_entry_t *mp;
12675 u32 sad_id = 0, spi = 0;
12676 u8 *ck = 0, *ik = 0;
12679 u8 protocol = IPSEC_PROTOCOL_AH;
12680 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12681 u32 crypto_alg = 0, integ_alg = 0;
12682 ip4_address_t tun_src4;
12683 ip4_address_t tun_dst4;
12684 ip6_address_t tun_src6;
12685 ip6_address_t tun_dst6;
12688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12690 if (unformat (i, "del"))
12692 else if (unformat (i, "sad_id %d", &sad_id))
12694 else if (unformat (i, "spi %d", &spi))
12696 else if (unformat (i, "esp"))
12697 protocol = IPSEC_PROTOCOL_ESP;
12698 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12701 is_tunnel_ipv6 = 0;
12703 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12706 is_tunnel_ipv6 = 0;
12708 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12711 is_tunnel_ipv6 = 1;
12713 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12716 is_tunnel_ipv6 = 1;
12720 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12722 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12723 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12725 clib_warning ("unsupported crypto-alg: '%U'",
12726 format_ipsec_crypto_alg, crypto_alg);
12730 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12734 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12736 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12737 integ_alg >= IPSEC_INTEG_N_ALG)
12739 clib_warning ("unsupported integ-alg: '%U'",
12740 format_ipsec_integ_alg, integ_alg);
12744 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12748 clib_warning ("parse error '%U'", format_unformat_error, i);
12754 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12756 mp->sad_id = ntohl (sad_id);
12757 mp->is_add = is_add;
12758 mp->protocol = protocol;
12759 mp->spi = ntohl (spi);
12760 mp->is_tunnel = is_tunnel;
12761 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12762 mp->crypto_algorithm = crypto_alg;
12763 mp->integrity_algorithm = integ_alg;
12764 mp->crypto_key_length = vec_len (ck);
12765 mp->integrity_key_length = vec_len (ik);
12767 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12768 mp->crypto_key_length = sizeof (mp->crypto_key);
12770 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12771 mp->integrity_key_length = sizeof (mp->integrity_key);
12774 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12776 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12780 if (is_tunnel_ipv6)
12782 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12783 sizeof (ip6_address_t));
12784 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12785 sizeof (ip6_address_t));
12789 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12790 sizeof (ip4_address_t));
12791 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12792 sizeof (ip4_address_t));
12802 api_ipsec_sa_set_key (vat_main_t * vam)
12804 unformat_input_t *i = vam->input;
12805 vl_api_ipsec_sa_set_key_t *mp;
12807 u8 *ck = 0, *ik = 0;
12810 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12812 if (unformat (i, "sa_id %d", &sa_id))
12814 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12816 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12820 clib_warning ("parse error '%U'", format_unformat_error, i);
12825 M (IPSEC_SA_SET_KEY, mp);
12827 mp->sa_id = ntohl (sa_id);
12828 mp->crypto_key_length = vec_len (ck);
12829 mp->integrity_key_length = vec_len (ik);
12831 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12832 mp->crypto_key_length = sizeof (mp->crypto_key);
12834 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12835 mp->integrity_key_length = sizeof (mp->integrity_key);
12838 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12840 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12848 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
12850 unformat_input_t *i = vam->input;
12851 vl_api_ipsec_tunnel_if_add_del_t *mp;
12852 u32 local_spi = 0, remote_spi = 0;
12853 u32 crypto_alg = 0, integ_alg = 0;
12854 u8 *lck = NULL, *rck = NULL;
12855 u8 *lik = NULL, *rik = NULL;
12856 ip4_address_t local_ip = { {0} };
12857 ip4_address_t remote_ip = { {0} };
12860 u8 anti_replay = 0;
12863 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12865 if (unformat (i, "del"))
12867 else if (unformat (i, "esn"))
12869 else if (unformat (i, "anti_replay"))
12871 else if (unformat (i, "local_spi %d", &local_spi))
12873 else if (unformat (i, "remote_spi %d", &remote_spi))
12875 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
12877 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
12879 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
12882 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
12884 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
12886 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
12890 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12892 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12893 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12895 errmsg ("unsupported crypto-alg: '%U'\n",
12896 format_ipsec_crypto_alg, crypto_alg);
12902 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12904 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12905 integ_alg >= IPSEC_INTEG_N_ALG)
12907 errmsg ("unsupported integ-alg: '%U'\n",
12908 format_ipsec_integ_alg, integ_alg);
12914 errmsg ("parse error '%U'\n", format_unformat_error, i);
12919 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
12921 mp->is_add = is_add;
12923 mp->anti_replay = anti_replay;
12925 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
12926 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
12928 mp->local_spi = htonl (local_spi);
12929 mp->remote_spi = htonl (remote_spi);
12930 mp->crypto_alg = (u8) crypto_alg;
12932 mp->local_crypto_key_len = 0;
12935 mp->local_crypto_key_len = vec_len (lck);
12936 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
12937 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
12938 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
12941 mp->remote_crypto_key_len = 0;
12944 mp->remote_crypto_key_len = vec_len (rck);
12945 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
12946 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
12947 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
12950 mp->integ_alg = (u8) integ_alg;
12952 mp->local_integ_key_len = 0;
12955 mp->local_integ_key_len = vec_len (lik);
12956 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
12957 mp->local_integ_key_len = sizeof (mp->local_integ_key);
12958 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
12961 mp->remote_integ_key_len = 0;
12964 mp->remote_integ_key_len = vec_len (rik);
12965 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
12966 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
12967 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
12976 api_ikev2_profile_add_del (vat_main_t * vam)
12978 unformat_input_t *i = vam->input;
12979 vl_api_ikev2_profile_add_del_t *mp;
12984 const char *valid_chars = "a-zA-Z0-9_";
12986 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12988 if (unformat (i, "del"))
12990 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12991 vec_add1 (name, 0);
12994 errmsg ("parse error '%U'", format_unformat_error, i);
12999 if (!vec_len (name))
13001 errmsg ("profile name must be specified");
13005 if (vec_len (name) > 64)
13007 errmsg ("profile name too long");
13011 M (IKEV2_PROFILE_ADD_DEL, mp);
13013 clib_memcpy (mp->name, name, vec_len (name));
13014 mp->is_add = is_add;
13023 api_ikev2_profile_set_auth (vat_main_t * vam)
13025 unformat_input_t *i = vam->input;
13026 vl_api_ikev2_profile_set_auth_t *mp;
13029 u32 auth_method = 0;
13033 const char *valid_chars = "a-zA-Z0-9_";
13035 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13037 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13038 vec_add1 (name, 0);
13039 else if (unformat (i, "auth_method %U",
13040 unformat_ikev2_auth_method, &auth_method))
13042 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
13044 else if (unformat (i, "auth_data %v", &data))
13048 errmsg ("parse error '%U'", format_unformat_error, i);
13053 if (!vec_len (name))
13055 errmsg ("profile name must be specified");
13059 if (vec_len (name) > 64)
13061 errmsg ("profile name too long");
13065 if (!vec_len (data))
13067 errmsg ("auth_data must be specified");
13073 errmsg ("auth_method must be specified");
13077 M (IKEV2_PROFILE_SET_AUTH, mp);
13079 mp->is_hex = is_hex;
13080 mp->auth_method = (u8) auth_method;
13081 mp->data_len = vec_len (data);
13082 clib_memcpy (mp->name, name, vec_len (name));
13083 clib_memcpy (mp->data, data, vec_len (data));
13093 api_ikev2_profile_set_id (vat_main_t * vam)
13095 unformat_input_t *i = vam->input;
13096 vl_api_ikev2_profile_set_id_t *mp;
13104 const char *valid_chars = "a-zA-Z0-9_";
13106 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13108 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13109 vec_add1 (name, 0);
13110 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
13112 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
13114 data = vec_new (u8, 4);
13115 clib_memcpy (data, ip4.as_u8, 4);
13117 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
13119 else if (unformat (i, "id_data %v", &data))
13121 else if (unformat (i, "local"))
13123 else if (unformat (i, "remote"))
13127 errmsg ("parse error '%U'", format_unformat_error, i);
13132 if (!vec_len (name))
13134 errmsg ("profile name must be specified");
13138 if (vec_len (name) > 64)
13140 errmsg ("profile name too long");
13144 if (!vec_len (data))
13146 errmsg ("id_data must be specified");
13152 errmsg ("id_type must be specified");
13156 M (IKEV2_PROFILE_SET_ID, mp);
13158 mp->is_local = is_local;
13159 mp->id_type = (u8) id_type;
13160 mp->data_len = vec_len (data);
13161 clib_memcpy (mp->name, name, vec_len (name));
13162 clib_memcpy (mp->data, data, vec_len (data));
13172 api_ikev2_profile_set_ts (vat_main_t * vam)
13174 unformat_input_t *i = vam->input;
13175 vl_api_ikev2_profile_set_ts_t *mp;
13178 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
13179 ip4_address_t start_addr, end_addr;
13181 const char *valid_chars = "a-zA-Z0-9_";
13184 start_addr.as_u32 = 0;
13185 end_addr.as_u32 = (u32) ~ 0;
13187 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13189 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13190 vec_add1 (name, 0);
13191 else if (unformat (i, "protocol %d", &proto))
13193 else if (unformat (i, "start_port %d", &start_port))
13195 else if (unformat (i, "end_port %d", &end_port))
13198 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
13200 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
13202 else if (unformat (i, "local"))
13204 else if (unformat (i, "remote"))
13208 errmsg ("parse error '%U'", format_unformat_error, i);
13213 if (!vec_len (name))
13215 errmsg ("profile name must be specified");
13219 if (vec_len (name) > 64)
13221 errmsg ("profile name too long");
13225 M (IKEV2_PROFILE_SET_TS, mp);
13227 mp->is_local = is_local;
13228 mp->proto = (u8) proto;
13229 mp->start_port = (u16) start_port;
13230 mp->end_port = (u16) end_port;
13231 mp->start_addr = start_addr.as_u32;
13232 mp->end_addr = end_addr.as_u32;
13233 clib_memcpy (mp->name, name, vec_len (name));
13242 api_ikev2_set_local_key (vat_main_t * vam)
13244 unformat_input_t *i = vam->input;
13245 vl_api_ikev2_set_local_key_t *mp;
13249 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13251 if (unformat (i, "file %v", &file))
13252 vec_add1 (file, 0);
13255 errmsg ("parse error '%U'", format_unformat_error, i);
13260 if (!vec_len (file))
13262 errmsg ("RSA key file must be specified");
13266 if (vec_len (file) > 256)
13268 errmsg ("file name too long");
13272 M (IKEV2_SET_LOCAL_KEY, mp);
13274 clib_memcpy (mp->key_file, file, vec_len (file));
13283 api_ikev2_set_responder (vat_main_t * vam)
13285 unformat_input_t *i = vam->input;
13286 vl_api_ikev2_set_responder_t *mp;
13289 u32 sw_if_index = ~0;
13290 ip4_address_t address;
13292 const char *valid_chars = "a-zA-Z0-9_";
13294 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13297 (i, "%U interface %d address %U", unformat_token, valid_chars,
13298 &name, &sw_if_index, unformat_ip4_address, &address))
13299 vec_add1 (name, 0);
13302 errmsg ("parse error '%U'", format_unformat_error, i);
13307 if (!vec_len (name))
13309 errmsg ("profile name must be specified");
13313 if (vec_len (name) > 64)
13315 errmsg ("profile name too long");
13319 M (IKEV2_SET_RESPONDER, mp);
13321 clib_memcpy (mp->name, name, vec_len (name));
13324 mp->sw_if_index = sw_if_index;
13325 clib_memcpy (mp->address, &address, sizeof (address));
13333 api_ikev2_set_ike_transforms (vat_main_t * vam)
13335 unformat_input_t *i = vam->input;
13336 vl_api_ikev2_set_ike_transforms_t *mp;
13339 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13341 const char *valid_chars = "a-zA-Z0-9_";
13343 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13345 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13346 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13347 vec_add1 (name, 0);
13350 errmsg ("parse error '%U'", format_unformat_error, i);
13355 if (!vec_len (name))
13357 errmsg ("profile name must be specified");
13361 if (vec_len (name) > 64)
13363 errmsg ("profile name too long");
13367 M (IKEV2_SET_IKE_TRANSFORMS, mp);
13369 clib_memcpy (mp->name, name, vec_len (name));
13371 mp->crypto_alg = crypto_alg;
13372 mp->crypto_key_size = crypto_key_size;
13373 mp->integ_alg = integ_alg;
13374 mp->dh_group = dh_group;
13383 api_ikev2_set_esp_transforms (vat_main_t * vam)
13385 unformat_input_t *i = vam->input;
13386 vl_api_ikev2_set_esp_transforms_t *mp;
13389 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13391 const char *valid_chars = "a-zA-Z0-9_";
13393 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13395 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13396 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13397 vec_add1 (name, 0);
13400 errmsg ("parse error '%U'", format_unformat_error, i);
13405 if (!vec_len (name))
13407 errmsg ("profile name must be specified");
13411 if (vec_len (name) > 64)
13413 errmsg ("profile name too long");
13417 M (IKEV2_SET_ESP_TRANSFORMS, mp);
13419 clib_memcpy (mp->name, name, vec_len (name));
13421 mp->crypto_alg = crypto_alg;
13422 mp->crypto_key_size = crypto_key_size;
13423 mp->integ_alg = integ_alg;
13424 mp->dh_group = dh_group;
13432 api_ikev2_set_sa_lifetime (vat_main_t * vam)
13434 unformat_input_t *i = vam->input;
13435 vl_api_ikev2_set_sa_lifetime_t *mp;
13438 u64 lifetime, lifetime_maxdata;
13439 u32 lifetime_jitter, handover;
13441 const char *valid_chars = "a-zA-Z0-9_";
13443 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13445 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
13446 &lifetime, &lifetime_jitter, &handover,
13447 &lifetime_maxdata))
13448 vec_add1 (name, 0);
13451 errmsg ("parse error '%U'", format_unformat_error, i);
13456 if (!vec_len (name))
13458 errmsg ("profile name must be specified");
13462 if (vec_len (name) > 64)
13464 errmsg ("profile name too long");
13468 M (IKEV2_SET_SA_LIFETIME, mp);
13470 clib_memcpy (mp->name, name, vec_len (name));
13472 mp->lifetime = lifetime;
13473 mp->lifetime_jitter = lifetime_jitter;
13474 mp->handover = handover;
13475 mp->lifetime_maxdata = lifetime_maxdata;
13483 api_ikev2_initiate_sa_init (vat_main_t * vam)
13485 unformat_input_t *i = vam->input;
13486 vl_api_ikev2_initiate_sa_init_t *mp;
13490 const char *valid_chars = "a-zA-Z0-9_";
13492 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13494 if (unformat (i, "%U", unformat_token, valid_chars, &name))
13495 vec_add1 (name, 0);
13498 errmsg ("parse error '%U'", format_unformat_error, i);
13503 if (!vec_len (name))
13505 errmsg ("profile name must be specified");
13509 if (vec_len (name) > 64)
13511 errmsg ("profile name too long");
13515 M (IKEV2_INITIATE_SA_INIT, mp);
13517 clib_memcpy (mp->name, name, vec_len (name));
13526 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
13528 unformat_input_t *i = vam->input;
13529 vl_api_ikev2_initiate_del_ike_sa_t *mp;
13534 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13536 if (unformat (i, "%lx", &ispi))
13540 errmsg ("parse error '%U'", format_unformat_error, i);
13545 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
13555 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13557 unformat_input_t *i = vam->input;
13558 vl_api_ikev2_initiate_del_child_sa_t *mp;
13563 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13565 if (unformat (i, "%x", &ispi))
13569 errmsg ("parse error '%U'", format_unformat_error, i);
13574 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13584 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13586 unformat_input_t *i = vam->input;
13587 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13592 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13594 if (unformat (i, "%x", &ispi))
13598 errmsg ("parse error '%U'", format_unformat_error, i);
13603 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
13616 api_map_add_domain (vat_main_t * vam)
13618 unformat_input_t *i = vam->input;
13619 vl_api_map_add_domain_t *mp;
13621 ip4_address_t ip4_prefix;
13622 ip6_address_t ip6_prefix;
13623 ip6_address_t ip6_src;
13624 u32 num_m_args = 0;
13625 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
13626 0, psid_length = 0;
13627 u8 is_translation = 0;
13629 u32 ip6_src_len = 128;
13632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13634 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
13635 &ip4_prefix, &ip4_prefix_len))
13637 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
13638 &ip6_prefix, &ip6_prefix_len))
13642 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
13645 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
13647 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
13649 else if (unformat (i, "psid-offset %d", &psid_offset))
13651 else if (unformat (i, "psid-len %d", &psid_length))
13653 else if (unformat (i, "mtu %d", &mtu))
13655 else if (unformat (i, "map-t"))
13656 is_translation = 1;
13659 clib_warning ("parse error '%U'", format_unformat_error, i);
13664 if (num_m_args < 3)
13666 errmsg ("mandatory argument(s) missing");
13670 /* Construct the API message */
13671 M (MAP_ADD_DOMAIN, mp);
13673 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
13674 mp->ip4_prefix_len = ip4_prefix_len;
13676 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
13677 mp->ip6_prefix_len = ip6_prefix_len;
13679 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
13680 mp->ip6_src_prefix_len = ip6_src_len;
13682 mp->ea_bits_len = ea_bits_len;
13683 mp->psid_offset = psid_offset;
13684 mp->psid_length = psid_length;
13685 mp->is_translation = is_translation;
13686 mp->mtu = htons (mtu);
13691 /* Wait for a reply, return good/bad news */
13697 api_map_del_domain (vat_main_t * vam)
13699 unformat_input_t *i = vam->input;
13700 vl_api_map_del_domain_t *mp;
13702 u32 num_m_args = 0;
13706 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13708 if (unformat (i, "index %d", &index))
13712 clib_warning ("parse error '%U'", format_unformat_error, i);
13717 if (num_m_args != 1)
13719 errmsg ("mandatory argument(s) missing");
13723 /* Construct the API message */
13724 M (MAP_DEL_DOMAIN, mp);
13726 mp->index = ntohl (index);
13731 /* Wait for a reply, return good/bad news */
13737 api_map_add_del_rule (vat_main_t * vam)
13739 unformat_input_t *i = vam->input;
13740 vl_api_map_add_del_rule_t *mp;
13742 ip6_address_t ip6_dst;
13743 u32 num_m_args = 0, index, psid = 0;
13746 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13748 if (unformat (i, "index %d", &index))
13750 else if (unformat (i, "psid %d", &psid))
13752 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13754 else if (unformat (i, "del"))
13760 clib_warning ("parse error '%U'", format_unformat_error, i);
13765 /* Construct the API message */
13766 M (MAP_ADD_DEL_RULE, mp);
13768 mp->index = ntohl (index);
13769 mp->is_add = is_add;
13770 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13771 mp->psid = ntohs (psid);
13776 /* Wait for a reply, return good/bad news */
13782 api_map_domain_dump (vat_main_t * vam)
13784 vl_api_map_domain_dump_t *mp;
13785 vl_api_control_ping_t *mp_ping;
13788 /* Construct the API message */
13789 M (MAP_DOMAIN_DUMP, mp);
13794 /* Use a control ping for synchronization */
13795 M (CONTROL_PING, mp_ping);
13803 api_map_rule_dump (vat_main_t * vam)
13805 unformat_input_t *i = vam->input;
13806 vl_api_map_rule_dump_t *mp;
13807 vl_api_control_ping_t *mp_ping;
13808 u32 domain_index = ~0;
13811 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13813 if (unformat (i, "index %u", &domain_index))
13819 if (domain_index == ~0)
13821 clib_warning ("parse error: domain index expected");
13825 /* Construct the API message */
13826 M (MAP_RULE_DUMP, mp);
13828 mp->domain_index = htonl (domain_index);
13833 /* Use a control ping for synchronization */
13834 M (CONTROL_PING, mp_ping);
13841 static void vl_api_map_add_domain_reply_t_handler
13842 (vl_api_map_add_domain_reply_t * mp)
13844 vat_main_t *vam = &vat_main;
13845 i32 retval = ntohl (mp->retval);
13847 if (vam->async_mode)
13849 vam->async_errors += (retval < 0);
13853 vam->retval = retval;
13854 vam->result_ready = 1;
13858 static void vl_api_map_add_domain_reply_t_handler_json
13859 (vl_api_map_add_domain_reply_t * mp)
13861 vat_main_t *vam = &vat_main;
13862 vat_json_node_t node;
13864 vat_json_init_object (&node);
13865 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13866 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13868 vat_json_print (vam->ofp, &node);
13869 vat_json_free (&node);
13871 vam->retval = ntohl (mp->retval);
13872 vam->result_ready = 1;
13876 api_get_first_msg_id (vat_main_t * vam)
13878 vl_api_get_first_msg_id_t *mp;
13879 unformat_input_t *i = vam->input;
13884 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13886 if (unformat (i, "client %s", &name))
13894 errmsg ("missing client name");
13897 vec_add1 (name, 0);
13899 if (vec_len (name) > 63)
13901 errmsg ("client name too long");
13905 M (GET_FIRST_MSG_ID, mp);
13906 clib_memcpy (mp->name, name, vec_len (name));
13913 api_cop_interface_enable_disable (vat_main_t * vam)
13915 unformat_input_t *line_input = vam->input;
13916 vl_api_cop_interface_enable_disable_t *mp;
13917 u32 sw_if_index = ~0;
13918 u8 enable_disable = 1;
13921 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13923 if (unformat (line_input, "disable"))
13924 enable_disable = 0;
13925 if (unformat (line_input, "enable"))
13926 enable_disable = 1;
13927 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13928 vam, &sw_if_index))
13930 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13936 if (sw_if_index == ~0)
13938 errmsg ("missing interface name or sw_if_index");
13942 /* Construct the API message */
13943 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13944 mp->sw_if_index = ntohl (sw_if_index);
13945 mp->enable_disable = enable_disable;
13949 /* Wait for the reply */
13955 api_cop_whitelist_enable_disable (vat_main_t * vam)
13957 unformat_input_t *line_input = vam->input;
13958 vl_api_cop_whitelist_enable_disable_t *mp;
13959 u32 sw_if_index = ~0;
13960 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13964 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13966 if (unformat (line_input, "ip4"))
13968 else if (unformat (line_input, "ip6"))
13970 else if (unformat (line_input, "default"))
13972 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13973 vam, &sw_if_index))
13975 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13977 else if (unformat (line_input, "fib-id %d", &fib_id))
13983 if (sw_if_index == ~0)
13985 errmsg ("missing interface name or sw_if_index");
13989 /* Construct the API message */
13990 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13991 mp->sw_if_index = ntohl (sw_if_index);
13992 mp->fib_id = ntohl (fib_id);
13995 mp->default_cop = default_cop;
13999 /* Wait for the reply */
14005 api_get_node_graph (vat_main_t * vam)
14007 vl_api_get_node_graph_t *mp;
14010 M (GET_NODE_GRAPH, mp);
14014 /* Wait for the reply */
14020 /** Used for parsing LISP eids */
14021 typedef CLIB_PACKED(struct{
14022 u8 addr[16]; /**< eid address */
14023 u32 len; /**< prefix length if IP */
14024 u8 type; /**< type of eid */
14029 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14031 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14033 memset (a, 0, sizeof (a[0]));
14035 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
14037 a->type = 0; /* ipv4 type */
14039 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
14041 a->type = 1; /* ipv6 type */
14043 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
14045 a->type = 2; /* mac type */
14052 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
14061 lisp_eid_size_vat (u8 type)
14076 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
14078 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
14082 api_one_add_del_locator_set (vat_main_t * vam)
14084 unformat_input_t *input = vam->input;
14085 vl_api_one_add_del_locator_set_t *mp;
14087 u8 *locator_set_name = NULL;
14088 u8 locator_set_name_set = 0;
14089 vl_api_local_locator_t locator, *locators = 0;
14090 u32 sw_if_index, priority, weight;
14094 /* Parse args required to build the message */
14095 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14097 if (unformat (input, "del"))
14101 else if (unformat (input, "locator-set %s", &locator_set_name))
14103 locator_set_name_set = 1;
14105 else if (unformat (input, "sw_if_index %u p %u w %u",
14106 &sw_if_index, &priority, &weight))
14108 locator.sw_if_index = htonl (sw_if_index);
14109 locator.priority = priority;
14110 locator.weight = weight;
14111 vec_add1 (locators, locator);
14115 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14116 &sw_if_index, &priority, &weight))
14118 locator.sw_if_index = htonl (sw_if_index);
14119 locator.priority = priority;
14120 locator.weight = weight;
14121 vec_add1 (locators, locator);
14127 if (locator_set_name_set == 0)
14129 errmsg ("missing locator-set name");
14130 vec_free (locators);
14134 if (vec_len (locator_set_name) > 64)
14136 errmsg ("locator-set name too long");
14137 vec_free (locator_set_name);
14138 vec_free (locators);
14141 vec_add1 (locator_set_name, 0);
14143 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14145 /* Construct the API message */
14146 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14148 mp->is_add = is_add;
14149 clib_memcpy (mp->locator_set_name, locator_set_name,
14150 vec_len (locator_set_name));
14151 vec_free (locator_set_name);
14153 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14155 clib_memcpy (mp->locators, locators, data_len);
14156 vec_free (locators);
14161 /* Wait for a reply... */
14166 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14169 api_one_add_del_locator (vat_main_t * vam)
14171 unformat_input_t *input = vam->input;
14172 vl_api_one_add_del_locator_t *mp;
14173 u32 tmp_if_index = ~0;
14174 u32 sw_if_index = ~0;
14175 u8 sw_if_index_set = 0;
14176 u8 sw_if_index_if_name_set = 0;
14178 u8 priority_set = 0;
14182 u8 *locator_set_name = NULL;
14183 u8 locator_set_name_set = 0;
14186 /* Parse args required to build the message */
14187 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14189 if (unformat (input, "del"))
14193 else if (unformat (input, "locator-set %s", &locator_set_name))
14195 locator_set_name_set = 1;
14197 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14200 sw_if_index_if_name_set = 1;
14201 sw_if_index = tmp_if_index;
14203 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14205 sw_if_index_set = 1;
14206 sw_if_index = tmp_if_index;
14208 else if (unformat (input, "p %d", &priority))
14212 else if (unformat (input, "w %d", &weight))
14220 if (locator_set_name_set == 0)
14222 errmsg ("missing locator-set name");
14226 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14228 errmsg ("missing sw_if_index");
14229 vec_free (locator_set_name);
14233 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14235 errmsg ("cannot use both params interface name and sw_if_index");
14236 vec_free (locator_set_name);
14240 if (priority_set == 0)
14242 errmsg ("missing locator-set priority");
14243 vec_free (locator_set_name);
14247 if (weight_set == 0)
14249 errmsg ("missing locator-set weight");
14250 vec_free (locator_set_name);
14254 if (vec_len (locator_set_name) > 64)
14256 errmsg ("locator-set name too long");
14257 vec_free (locator_set_name);
14260 vec_add1 (locator_set_name, 0);
14262 /* Construct the API message */
14263 M (ONE_ADD_DEL_LOCATOR, mp);
14265 mp->is_add = is_add;
14266 mp->sw_if_index = ntohl (sw_if_index);
14267 mp->priority = priority;
14268 mp->weight = weight;
14269 clib_memcpy (mp->locator_set_name, locator_set_name,
14270 vec_len (locator_set_name));
14271 vec_free (locator_set_name);
14276 /* Wait for a reply... */
14281 #define api_lisp_add_del_locator api_one_add_del_locator
14284 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14286 u32 *key_id = va_arg (*args, u32 *);
14289 if (unformat (input, "%s", &s))
14291 if (!strcmp ((char *) s, "sha1"))
14292 key_id[0] = HMAC_SHA_1_96;
14293 else if (!strcmp ((char *) s, "sha256"))
14294 key_id[0] = HMAC_SHA_256_128;
14297 clib_warning ("invalid key_id: '%s'", s);
14298 key_id[0] = HMAC_NO_KEY;
14309 api_one_add_del_local_eid (vat_main_t * vam)
14311 unformat_input_t *input = vam->input;
14312 vl_api_one_add_del_local_eid_t *mp;
14315 lisp_eid_vat_t _eid, *eid = &_eid;
14316 u8 *locator_set_name = 0;
14317 u8 locator_set_name_set = 0;
14323 /* Parse args required to build the message */
14324 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14326 if (unformat (input, "del"))
14330 else if (unformat (input, "vni %d", &vni))
14334 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14338 else if (unformat (input, "locator-set %s", &locator_set_name))
14340 locator_set_name_set = 1;
14342 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14344 else if (unformat (input, "secret-key %_%v%_", &key))
14350 if (locator_set_name_set == 0)
14352 errmsg ("missing locator-set name");
14358 errmsg ("EID address not set!");
14359 vec_free (locator_set_name);
14363 if (key && (0 == key_id))
14365 errmsg ("invalid key_id!");
14369 if (vec_len (key) > 64)
14371 errmsg ("key too long");
14376 if (vec_len (locator_set_name) > 64)
14378 errmsg ("locator-set name too long");
14379 vec_free (locator_set_name);
14382 vec_add1 (locator_set_name, 0);
14384 /* Construct the API message */
14385 M (ONE_ADD_DEL_LOCAL_EID, mp);
14387 mp->is_add = is_add;
14388 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14389 mp->eid_type = eid->type;
14390 mp->prefix_len = eid->len;
14391 mp->vni = clib_host_to_net_u32 (vni);
14392 mp->key_id = clib_host_to_net_u16 (key_id);
14393 clib_memcpy (mp->locator_set_name, locator_set_name,
14394 vec_len (locator_set_name));
14395 clib_memcpy (mp->key, key, vec_len (key));
14397 vec_free (locator_set_name);
14403 /* Wait for a reply... */
14408 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14411 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14413 u32 dp_table = 0, vni = 0;;
14414 unformat_input_t *input = vam->input;
14415 vl_api_gpe_add_del_fwd_entry_t *mp;
14417 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14418 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14419 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14420 u32 action = ~0, w;
14421 ip4_address_t rmt_rloc4, lcl_rloc4;
14422 ip6_address_t rmt_rloc6, lcl_rloc6;
14423 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14426 memset (&rloc, 0, sizeof (rloc));
14428 /* Parse args required to build the message */
14429 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14431 if (unformat (input, "del"))
14433 else if (unformat (input, "add"))
14435 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14439 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14443 else if (unformat (input, "vrf %d", &dp_table))
14445 else if (unformat (input, "bd %d", &dp_table))
14447 else if (unformat (input, "vni %d", &vni))
14449 else if (unformat (input, "w %d", &w))
14453 errmsg ("No RLOC configured for setting priority/weight!");
14456 curr_rloc->weight = w;
14458 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14459 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14463 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
14465 vec_add1 (lcl_locs, rloc);
14467 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
14468 vec_add1 (rmt_locs, rloc);
14469 /* weight saved in rmt loc */
14470 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14472 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14473 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14476 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
14478 vec_add1 (lcl_locs, rloc);
14480 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
14481 vec_add1 (rmt_locs, rloc);
14482 /* weight saved in rmt loc */
14483 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14485 else if (unformat (input, "action %d", &action))
14491 clib_warning ("parse error '%U'", format_unformat_error, input);
14498 errmsg ("remote eid addresses not set");
14502 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14504 errmsg ("eid types don't match");
14508 if (0 == rmt_locs && (u32) ~ 0 == action)
14510 errmsg ("action not set for negative mapping");
14514 /* Construct the API message */
14515 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14516 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14518 mp->is_add = is_add;
14519 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14520 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14521 mp->eid_type = rmt_eid->type;
14522 mp->dp_table = clib_host_to_net_u32 (dp_table);
14523 mp->vni = clib_host_to_net_u32 (vni);
14524 mp->rmt_len = rmt_eid->len;
14525 mp->lcl_len = lcl_eid->len;
14526 mp->action = action;
14528 if (0 != rmt_locs && 0 != lcl_locs)
14530 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14531 clib_memcpy (mp->locs, lcl_locs,
14532 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14534 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14535 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14536 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14538 vec_free (lcl_locs);
14539 vec_free (rmt_locs);
14544 /* Wait for a reply... */
14550 api_one_add_del_map_server (vat_main_t * vam)
14552 unformat_input_t *input = vam->input;
14553 vl_api_one_add_del_map_server_t *mp;
14557 ip4_address_t ipv4;
14558 ip6_address_t ipv6;
14561 /* Parse args required to build the message */
14562 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14564 if (unformat (input, "del"))
14568 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14572 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14580 if (ipv4_set && ipv6_set)
14582 errmsg ("both eid v4 and v6 addresses set");
14586 if (!ipv4_set && !ipv6_set)
14588 errmsg ("eid addresses not set");
14592 /* Construct the API message */
14593 M (ONE_ADD_DEL_MAP_SERVER, mp);
14595 mp->is_add = is_add;
14599 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14604 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14610 /* Wait for a reply... */
14615 #define api_lisp_add_del_map_server api_one_add_del_map_server
14618 api_one_add_del_map_resolver (vat_main_t * vam)
14620 unformat_input_t *input = vam->input;
14621 vl_api_one_add_del_map_resolver_t *mp;
14625 ip4_address_t ipv4;
14626 ip6_address_t ipv6;
14629 /* Parse args required to build the message */
14630 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14632 if (unformat (input, "del"))
14636 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14640 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14648 if (ipv4_set && ipv6_set)
14650 errmsg ("both eid v4 and v6 addresses set");
14654 if (!ipv4_set && !ipv6_set)
14656 errmsg ("eid addresses not set");
14660 /* Construct the API message */
14661 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14663 mp->is_add = is_add;
14667 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14672 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14678 /* Wait for a reply... */
14683 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14686 api_lisp_gpe_enable_disable (vat_main_t * vam)
14688 unformat_input_t *input = vam->input;
14689 vl_api_gpe_enable_disable_t *mp;
14694 /* Parse args required to build the message */
14695 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14697 if (unformat (input, "enable"))
14702 else if (unformat (input, "disable"))
14713 errmsg ("Value not set");
14717 /* Construct the API message */
14718 M (GPE_ENABLE_DISABLE, mp);
14725 /* Wait for a reply... */
14731 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14733 unformat_input_t *input = vam->input;
14734 vl_api_one_rloc_probe_enable_disable_t *mp;
14739 /* Parse args required to build the message */
14740 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14742 if (unformat (input, "enable"))
14747 else if (unformat (input, "disable"))
14755 errmsg ("Value not set");
14759 /* Construct the API message */
14760 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14762 mp->is_enabled = is_en;
14767 /* Wait for a reply... */
14772 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14775 api_one_map_register_enable_disable (vat_main_t * vam)
14777 unformat_input_t *input = vam->input;
14778 vl_api_one_map_register_enable_disable_t *mp;
14783 /* Parse args required to build the message */
14784 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14786 if (unformat (input, "enable"))
14791 else if (unformat (input, "disable"))
14799 errmsg ("Value not set");
14803 /* Construct the API message */
14804 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14806 mp->is_enabled = is_en;
14811 /* Wait for a reply... */
14816 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14819 api_one_enable_disable (vat_main_t * vam)
14821 unformat_input_t *input = vam->input;
14822 vl_api_one_enable_disable_t *mp;
14827 /* Parse args required to build the message */
14828 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14830 if (unformat (input, "enable"))
14835 else if (unformat (input, "disable"))
14845 errmsg ("Value not set");
14849 /* Construct the API message */
14850 M (ONE_ENABLE_DISABLE, mp);
14857 /* Wait for a reply... */
14862 #define api_lisp_enable_disable api_one_enable_disable
14865 api_show_one_map_register_state (vat_main_t * vam)
14867 vl_api_show_one_map_register_state_t *mp;
14870 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14875 /* wait for reply */
14880 #define api_show_lisp_map_register_state api_show_one_map_register_state
14883 api_show_one_rloc_probe_state (vat_main_t * vam)
14885 vl_api_show_one_rloc_probe_state_t *mp;
14888 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14893 /* wait for reply */
14898 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14901 api_one_add_del_l2_arp_entry (vat_main_t * vam)
14903 vl_api_one_add_del_l2_arp_entry_t *mp;
14904 unformat_input_t *input = vam->input;
14909 u8 mac[6] = { 0, };
14910 u32 ip4 = 0, bd = ~0;
14913 /* Parse args required to build the message */
14914 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14916 if (unformat (input, "del"))
14918 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
14920 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
14922 else if (unformat (input, "bd %d", &bd))
14926 errmsg ("parse error '%U'", format_unformat_error, input);
14931 if (!bd_set || !ip_set || (!mac_set && is_add))
14933 errmsg ("Missing BD, IP or MAC!");
14937 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
14938 mp->is_add = is_add;
14939 clib_memcpy (mp->mac, mac, 6);
14940 mp->bd = clib_host_to_net_u32 (bd);
14946 /* wait for reply */
14952 api_one_l2_arp_bd_get (vat_main_t * vam)
14954 vl_api_one_l2_arp_bd_get_t *mp;
14957 M (ONE_L2_ARP_BD_GET, mp);
14962 /* wait for reply */
14968 api_one_l2_arp_entries_get (vat_main_t * vam)
14970 vl_api_one_l2_arp_entries_get_t *mp;
14971 unformat_input_t *input = vam->input;
14976 /* Parse args required to build the message */
14977 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14979 if (unformat (input, "bd %d", &bd))
14983 errmsg ("parse error '%U'", format_unformat_error, input);
14990 errmsg ("Expected bridge domain!");
14994 M (ONE_L2_ARP_ENTRIES_GET, mp);
14995 mp->bd = clib_host_to_net_u32 (bd);
15000 /* wait for reply */
15006 api_one_stats_enable_disable (vat_main_t * vam)
15008 vl_api_one_stats_enable_disable_t *mp;
15009 unformat_input_t *input = vam->input;
15014 /* Parse args required to build the message */
15015 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15017 if (unformat (input, "enable"))
15022 else if (unformat (input, "disable"))
15032 errmsg ("Value not set");
15036 M (ONE_STATS_ENABLE_DISABLE, mp);
15042 /* wait for reply */
15048 api_show_one_stats_enable_disable (vat_main_t * vam)
15050 vl_api_show_one_stats_enable_disable_t *mp;
15053 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
15058 /* wait for reply */
15064 api_show_one_map_request_mode (vat_main_t * vam)
15066 vl_api_show_one_map_request_mode_t *mp;
15069 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
15074 /* wait for reply */
15079 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
15082 api_one_map_request_mode (vat_main_t * vam)
15084 unformat_input_t *input = vam->input;
15085 vl_api_one_map_request_mode_t *mp;
15089 /* Parse args required to build the message */
15090 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15092 if (unformat (input, "dst-only"))
15094 else if (unformat (input, "src-dst"))
15098 errmsg ("parse error '%U'", format_unformat_error, input);
15103 M (ONE_MAP_REQUEST_MODE, mp);
15110 /* wait for reply */
15115 #define api_lisp_map_request_mode api_one_map_request_mode
15118 * Enable/disable ONE proxy ITR.
15120 * @param vam vpp API test context
15121 * @return return code
15124 api_one_pitr_set_locator_set (vat_main_t * vam)
15126 u8 ls_name_set = 0;
15127 unformat_input_t *input = vam->input;
15128 vl_api_one_pitr_set_locator_set_t *mp;
15133 /* Parse args required to build the message */
15134 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15136 if (unformat (input, "del"))
15138 else if (unformat (input, "locator-set %s", &ls_name))
15142 errmsg ("parse error '%U'", format_unformat_error, input);
15149 errmsg ("locator-set name not set!");
15153 M (ONE_PITR_SET_LOCATOR_SET, mp);
15155 mp->is_add = is_add;
15156 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15157 vec_free (ls_name);
15162 /* wait for reply */
15167 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
15170 api_show_one_pitr (vat_main_t * vam)
15172 vl_api_show_one_pitr_t *mp;
15175 if (!vam->json_output)
15177 print (vam->ofp, "%=20s", "lisp status:");
15180 M (SHOW_ONE_PITR, mp);
15184 /* Wait for a reply... */
15189 #define api_show_lisp_pitr api_show_one_pitr
15192 api_one_use_petr (vat_main_t * vam)
15194 unformat_input_t *input = vam->input;
15195 vl_api_one_use_petr_t *mp;
15200 memset (&ip, 0, sizeof (ip));
15202 /* Parse args required to build the message */
15203 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15205 if (unformat (input, "disable"))
15208 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
15211 ip_addr_version (&ip) = IP4;
15214 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
15217 ip_addr_version (&ip) = IP6;
15221 errmsg ("parse error '%U'", format_unformat_error, input);
15226 M (ONE_USE_PETR, mp);
15228 mp->is_add = is_add;
15231 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
15233 clib_memcpy (mp->address, &ip, 4);
15235 clib_memcpy (mp->address, &ip, 16);
15241 /* wait for reply */
15246 #define api_lisp_use_petr api_one_use_petr
15249 api_show_one_use_petr (vat_main_t * vam)
15251 vl_api_show_one_use_petr_t *mp;
15254 if (!vam->json_output)
15256 print (vam->ofp, "%=20s", "Proxy-ETR status:");
15259 M (SHOW_ONE_USE_PETR, mp);
15263 /* Wait for a reply... */
15268 #define api_show_lisp_use_petr api_show_one_use_petr
15271 * Add/delete mapping between vni and vrf
15274 api_one_eid_table_add_del_map (vat_main_t * vam)
15276 unformat_input_t *input = vam->input;
15277 vl_api_one_eid_table_add_del_map_t *mp;
15278 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15279 u32 vni, vrf, bd_index;
15282 /* Parse args required to build the message */
15283 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15285 if (unformat (input, "del"))
15287 else if (unformat (input, "vrf %d", &vrf))
15289 else if (unformat (input, "bd_index %d", &bd_index))
15291 else if (unformat (input, "vni %d", &vni))
15297 if (!vni_set || (!vrf_set && !bd_index_set))
15299 errmsg ("missing arguments!");
15303 if (vrf_set && bd_index_set)
15305 errmsg ("error: both vrf and bd entered!");
15309 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15311 mp->is_add = is_add;
15312 mp->vni = htonl (vni);
15313 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15314 mp->is_l2 = bd_index_set;
15319 /* wait for reply */
15324 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15327 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15329 u32 *action = va_arg (*args, u32 *);
15332 if (unformat (input, "%s", &s))
15334 if (!strcmp ((char *) s, "no-action"))
15336 else if (!strcmp ((char *) s, "natively-forward"))
15338 else if (!strcmp ((char *) s, "send-map-request"))
15340 else if (!strcmp ((char *) s, "drop"))
15344 clib_warning ("invalid action: '%s'", s);
15356 * Add/del remote mapping to/from ONE control plane
15358 * @param vam vpp API test context
15359 * @return return code
15362 api_one_add_del_remote_mapping (vat_main_t * vam)
15364 unformat_input_t *input = vam->input;
15365 vl_api_one_add_del_remote_mapping_t *mp;
15367 lisp_eid_vat_t _eid, *eid = &_eid;
15368 lisp_eid_vat_t _seid, *seid = &_seid;
15369 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15370 u32 action = ~0, p, w, data_len;
15371 ip4_address_t rloc4;
15372 ip6_address_t rloc6;
15373 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15376 memset (&rloc, 0, sizeof (rloc));
15378 /* Parse args required to build the message */
15379 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15381 if (unformat (input, "del-all"))
15385 else if (unformat (input, "del"))
15389 else if (unformat (input, "add"))
15393 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15397 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15401 else if (unformat (input, "vni %d", &vni))
15405 else if (unformat (input, "p %d w %d", &p, &w))
15409 errmsg ("No RLOC configured for setting priority/weight!");
15412 curr_rloc->priority = p;
15413 curr_rloc->weight = w;
15415 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15418 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
15419 vec_add1 (rlocs, rloc);
15420 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15422 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15425 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
15426 vec_add1 (rlocs, rloc);
15427 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15429 else if (unformat (input, "action %U",
15430 unformat_negative_mapping_action, &action))
15436 clib_warning ("parse error '%U'", format_unformat_error, input);
15443 errmsg ("missing params!");
15447 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15449 errmsg ("no action set for negative map-reply!");
15453 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15455 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15456 mp->is_add = is_add;
15457 mp->vni = htonl (vni);
15458 mp->action = (u8) action;
15459 mp->is_src_dst = seid_set;
15460 mp->eid_len = eid->len;
15461 mp->seid_len = seid->len;
15462 mp->del_all = del_all;
15463 mp->eid_type = eid->type;
15464 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15465 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
15467 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15468 clib_memcpy (mp->rlocs, rlocs, data_len);
15474 /* Wait for a reply... */
15479 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15482 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15483 * forwarding entries in data-plane accordingly.
15485 * @param vam vpp API test context
15486 * @return return code
15489 api_one_add_del_adjacency (vat_main_t * vam)
15491 unformat_input_t *input = vam->input;
15492 vl_api_one_add_del_adjacency_t *mp;
15494 ip4_address_t leid4, reid4;
15495 ip6_address_t leid6, reid6;
15496 u8 reid_mac[6] = { 0 };
15497 u8 leid_mac[6] = { 0 };
15498 u8 reid_type, leid_type;
15499 u32 leid_len = 0, reid_len = 0, len;
15503 leid_type = reid_type = (u8) ~ 0;
15505 /* Parse args required to build the message */
15506 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15508 if (unformat (input, "del"))
15512 else if (unformat (input, "add"))
15516 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
15519 reid_type = 0; /* ipv4 */
15522 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
15525 reid_type = 1; /* ipv6 */
15528 else if (unformat (input, "reid %U", unformat_ethernet_address,
15531 reid_type = 2; /* mac */
15533 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
15536 leid_type = 0; /* ipv4 */
15539 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
15542 leid_type = 1; /* ipv6 */
15545 else if (unformat (input, "leid %U", unformat_ethernet_address,
15548 leid_type = 2; /* mac */
15550 else if (unformat (input, "vni %d", &vni))
15556 errmsg ("parse error '%U'", format_unformat_error, input);
15561 if ((u8) ~ 0 == reid_type)
15563 errmsg ("missing params!");
15567 if (leid_type != reid_type)
15569 errmsg ("remote and local EIDs are of different types!");
15573 M (ONE_ADD_DEL_ADJACENCY, mp);
15574 mp->is_add = is_add;
15575 mp->vni = htonl (vni);
15576 mp->leid_len = leid_len;
15577 mp->reid_len = reid_len;
15578 mp->eid_type = reid_type;
15580 switch (mp->eid_type)
15583 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
15584 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
15587 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
15588 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
15591 clib_memcpy (mp->leid, leid_mac, 6);
15592 clib_memcpy (mp->reid, reid_mac, 6);
15595 errmsg ("unknown EID type %d!", mp->eid_type);
15602 /* Wait for a reply... */
15607 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
15610 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
15612 u32 *mode = va_arg (*args, u32 *);
15614 if (unformat (input, "lisp"))
15616 else if (unformat (input, "vxlan"))
15625 api_gpe_get_encap_mode (vat_main_t * vam)
15627 vl_api_gpe_get_encap_mode_t *mp;
15630 /* Construct the API message */
15631 M (GPE_GET_ENCAP_MODE, mp);
15636 /* Wait for a reply... */
15642 api_gpe_set_encap_mode (vat_main_t * vam)
15644 unformat_input_t *input = vam->input;
15645 vl_api_gpe_set_encap_mode_t *mp;
15649 /* Parse args required to build the message */
15650 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15652 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
15658 /* Construct the API message */
15659 M (GPE_SET_ENCAP_MODE, mp);
15666 /* Wait for a reply... */
15672 api_lisp_gpe_add_del_iface (vat_main_t * vam)
15674 unformat_input_t *input = vam->input;
15675 vl_api_gpe_add_del_iface_t *mp;
15676 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
15677 u32 dp_table = 0, vni = 0;
15680 /* Parse args required to build the message */
15681 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15683 if (unformat (input, "up"))
15688 else if (unformat (input, "down"))
15693 else if (unformat (input, "table_id %d", &dp_table))
15697 else if (unformat (input, "bd_id %d", &dp_table))
15702 else if (unformat (input, "vni %d", &vni))
15710 if (action_set == 0)
15712 errmsg ("Action not set");
15715 if (dp_table_set == 0 || vni_set == 0)
15717 errmsg ("vni and dp_table must be set");
15721 /* Construct the API message */
15722 M (GPE_ADD_DEL_IFACE, mp);
15724 mp->is_add = is_add;
15725 mp->dp_table = dp_table;
15732 /* Wait for a reply... */
15738 * Add/del map request itr rlocs from ONE control plane and updates
15740 * @param vam vpp API test context
15741 * @return return code
15744 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
15746 unformat_input_t *input = vam->input;
15747 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
15748 u8 *locator_set_name = 0;
15749 u8 locator_set_name_set = 0;
15753 /* Parse args required to build the message */
15754 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15756 if (unformat (input, "del"))
15760 else if (unformat (input, "%_%v%_", &locator_set_name))
15762 locator_set_name_set = 1;
15766 clib_warning ("parse error '%U'", format_unformat_error, input);
15771 if (is_add && !locator_set_name_set)
15773 errmsg ("itr-rloc is not set!");
15777 if (is_add && vec_len (locator_set_name) > 64)
15779 errmsg ("itr-rloc locator-set name too long");
15780 vec_free (locator_set_name);
15784 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
15785 mp->is_add = is_add;
15788 clib_memcpy (mp->locator_set_name, locator_set_name,
15789 vec_len (locator_set_name));
15793 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
15795 vec_free (locator_set_name);
15800 /* Wait for a reply... */
15805 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
15808 api_one_locator_dump (vat_main_t * vam)
15810 unformat_input_t *input = vam->input;
15811 vl_api_one_locator_dump_t *mp;
15812 vl_api_control_ping_t *mp_ping;
15813 u8 is_index_set = 0, is_name_set = 0;
15818 /* Parse args required to build the message */
15819 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15821 if (unformat (input, "ls_name %_%v%_", &ls_name))
15825 else if (unformat (input, "ls_index %d", &ls_index))
15831 errmsg ("parse error '%U'", format_unformat_error, input);
15836 if (!is_index_set && !is_name_set)
15838 errmsg ("error: expected one of index or name!");
15842 if (is_index_set && is_name_set)
15844 errmsg ("error: only one param expected!");
15848 if (vec_len (ls_name) > 62)
15850 errmsg ("error: locator set name too long!");
15854 if (!vam->json_output)
15856 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
15859 M (ONE_LOCATOR_DUMP, mp);
15860 mp->is_index_set = is_index_set;
15863 mp->ls_index = clib_host_to_net_u32 (ls_index);
15866 vec_add1 (ls_name, 0);
15867 strncpy ((char *) mp->ls_name, (char *) ls_name,
15868 sizeof (mp->ls_name) - 1);
15874 /* Use a control ping for synchronization */
15875 M (CONTROL_PING, mp_ping);
15878 /* Wait for a reply... */
15883 #define api_lisp_locator_dump api_one_locator_dump
15886 api_one_locator_set_dump (vat_main_t * vam)
15888 vl_api_one_locator_set_dump_t *mp;
15889 vl_api_control_ping_t *mp_ping;
15890 unformat_input_t *input = vam->input;
15894 /* Parse args required to build the message */
15895 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15897 if (unformat (input, "local"))
15901 else if (unformat (input, "remote"))
15907 errmsg ("parse error '%U'", format_unformat_error, input);
15912 if (!vam->json_output)
15914 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
15917 M (ONE_LOCATOR_SET_DUMP, mp);
15919 mp->filter = filter;
15924 /* Use a control ping for synchronization */
15925 M (CONTROL_PING, mp_ping);
15928 /* Wait for a reply... */
15933 #define api_lisp_locator_set_dump api_one_locator_set_dump
15936 api_one_eid_table_map_dump (vat_main_t * vam)
15940 unformat_input_t *input = vam->input;
15941 vl_api_one_eid_table_map_dump_t *mp;
15942 vl_api_control_ping_t *mp_ping;
15945 /* Parse args required to build the message */
15946 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15948 if (unformat (input, "l2"))
15953 else if (unformat (input, "l3"))
15960 errmsg ("parse error '%U'", format_unformat_error, input);
15967 errmsg ("expected one of 'l2' or 'l3' parameter!");
15971 if (!vam->json_output)
15973 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
15976 M (ONE_EID_TABLE_MAP_DUMP, mp);
15982 /* Use a control ping for synchronization */
15983 M (CONTROL_PING, mp_ping);
15986 /* Wait for a reply... */
15991 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
15994 api_one_eid_table_vni_dump (vat_main_t * vam)
15996 vl_api_one_eid_table_vni_dump_t *mp;
15997 vl_api_control_ping_t *mp_ping;
16000 if (!vam->json_output)
16002 print (vam->ofp, "VNI");
16005 M (ONE_EID_TABLE_VNI_DUMP, mp);
16010 /* Use a control ping for synchronization */
16011 M (CONTROL_PING, mp_ping);
16014 /* Wait for a reply... */
16019 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
16022 api_one_eid_table_dump (vat_main_t * vam)
16024 unformat_input_t *i = vam->input;
16025 vl_api_one_eid_table_dump_t *mp;
16026 vl_api_control_ping_t *mp_ping;
16027 struct in_addr ip4;
16028 struct in6_addr ip6;
16030 u8 eid_type = ~0, eid_set = 0;
16031 u32 prefix_length = ~0, t, vni = 0;
16035 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16037 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
16043 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
16049 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
16054 else if (unformat (i, "vni %d", &t))
16058 else if (unformat (i, "local"))
16062 else if (unformat (i, "remote"))
16068 errmsg ("parse error '%U'", format_unformat_error, i);
16073 if (!vam->json_output)
16075 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
16076 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
16079 M (ONE_EID_TABLE_DUMP, mp);
16081 mp->filter = filter;
16085 mp->vni = htonl (vni);
16086 mp->eid_type = eid_type;
16090 mp->prefix_length = prefix_length;
16091 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
16094 mp->prefix_length = prefix_length;
16095 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
16098 clib_memcpy (mp->eid, mac, sizeof (mac));
16101 errmsg ("unknown EID type %d!", eid_type);
16109 /* Use a control ping for synchronization */
16110 M (CONTROL_PING, mp_ping);
16113 /* Wait for a reply... */
16118 #define api_lisp_eid_table_dump api_one_eid_table_dump
16121 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
16123 unformat_input_t *i = vam->input;
16124 vl_api_gpe_fwd_entries_get_t *mp;
16129 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16131 if (unformat (i, "vni %d", &vni))
16137 errmsg ("parse error '%U'", format_unformat_error, i);
16144 errmsg ("vni not set!");
16148 if (!vam->json_output)
16150 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
16154 M (GPE_FWD_ENTRIES_GET, mp);
16155 mp->vni = clib_host_to_net_u32 (vni);
16160 /* Wait for a reply... */
16165 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
16166 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
16167 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
16168 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
16169 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
16170 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
16173 api_one_adjacencies_get (vat_main_t * vam)
16175 unformat_input_t *i = vam->input;
16176 vl_api_one_adjacencies_get_t *mp;
16181 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16183 if (unformat (i, "vni %d", &vni))
16189 errmsg ("parse error '%U'", format_unformat_error, i);
16196 errmsg ("vni not set!");
16200 if (!vam->json_output)
16202 print (vam->ofp, "%s %40s", "leid", "reid");
16205 M (ONE_ADJACENCIES_GET, mp);
16206 mp->vni = clib_host_to_net_u32 (vni);
16211 /* Wait for a reply... */
16216 #define api_lisp_adjacencies_get api_one_adjacencies_get
16219 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
16221 vl_api_gpe_fwd_entry_vnis_get_t *mp;
16224 if (!vam->json_output)
16226 print (vam->ofp, "VNIs");
16229 M (GPE_FWD_ENTRY_VNIS_GET, mp);
16234 /* Wait for a reply... */
16240 api_one_map_server_dump (vat_main_t * vam)
16242 vl_api_one_map_server_dump_t *mp;
16243 vl_api_control_ping_t *mp_ping;
16246 if (!vam->json_output)
16248 print (vam->ofp, "%=20s", "Map server");
16251 M (ONE_MAP_SERVER_DUMP, mp);
16255 /* Use a control ping for synchronization */
16256 M (CONTROL_PING, mp_ping);
16259 /* Wait for a reply... */
16264 #define api_lisp_map_server_dump api_one_map_server_dump
16267 api_one_map_resolver_dump (vat_main_t * vam)
16269 vl_api_one_map_resolver_dump_t *mp;
16270 vl_api_control_ping_t *mp_ping;
16273 if (!vam->json_output)
16275 print (vam->ofp, "%=20s", "Map resolver");
16278 M (ONE_MAP_RESOLVER_DUMP, mp);
16282 /* Use a control ping for synchronization */
16283 M (CONTROL_PING, mp_ping);
16286 /* Wait for a reply... */
16291 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
16294 api_one_stats_flush (vat_main_t * vam)
16296 vl_api_one_stats_flush_t *mp;
16299 M (ONE_STATS_FLUSH, mp);
16306 api_one_stats_dump (vat_main_t * vam)
16308 vl_api_one_stats_dump_t *mp;
16309 vl_api_control_ping_t *mp_ping;
16312 M (ONE_STATS_DUMP, mp);
16316 /* Use a control ping for synchronization */
16317 M (CONTROL_PING, mp_ping);
16320 /* Wait for a reply... */
16326 api_show_one_status (vat_main_t * vam)
16328 vl_api_show_one_status_t *mp;
16331 if (!vam->json_output)
16333 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
16336 M (SHOW_ONE_STATUS, mp);
16339 /* Wait for a reply... */
16344 #define api_show_lisp_status api_show_one_status
16347 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
16349 vl_api_gpe_fwd_entry_path_dump_t *mp;
16350 vl_api_control_ping_t *mp_ping;
16351 unformat_input_t *i = vam->input;
16352 u32 fwd_entry_index = ~0;
16355 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16357 if (unformat (i, "index %d", &fwd_entry_index))
16363 if (~0 == fwd_entry_index)
16365 errmsg ("no index specified!");
16369 if (!vam->json_output)
16371 print (vam->ofp, "first line");
16374 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
16378 /* Use a control ping for synchronization */
16379 M (CONTROL_PING, mp_ping);
16382 /* Wait for a reply... */
16388 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
16390 vl_api_one_get_map_request_itr_rlocs_t *mp;
16393 if (!vam->json_output)
16395 print (vam->ofp, "%=20s", "itr-rlocs:");
16398 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
16401 /* Wait for a reply... */
16406 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
16409 api_af_packet_create (vat_main_t * vam)
16411 unformat_input_t *i = vam->input;
16412 vl_api_af_packet_create_t *mp;
16413 u8 *host_if_name = 0;
16415 u8 random_hw_addr = 1;
16418 memset (hw_addr, 0, sizeof (hw_addr));
16420 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16422 if (unformat (i, "name %s", &host_if_name))
16423 vec_add1 (host_if_name, 0);
16424 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16425 random_hw_addr = 0;
16430 if (!vec_len (host_if_name))
16432 errmsg ("host-interface name must be specified");
16436 if (vec_len (host_if_name) > 64)
16438 errmsg ("host-interface name too long");
16442 M (AF_PACKET_CREATE, mp);
16444 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16445 clib_memcpy (mp->hw_addr, hw_addr, 6);
16446 mp->use_random_hw_addr = random_hw_addr;
16447 vec_free (host_if_name);
16455 fprintf (vam->ofp ? vam->ofp : stderr,
16456 " new sw_if_index = %d\n", vam->sw_if_index);
16463 api_af_packet_delete (vat_main_t * vam)
16465 unformat_input_t *i = vam->input;
16466 vl_api_af_packet_delete_t *mp;
16467 u8 *host_if_name = 0;
16470 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16472 if (unformat (i, "name %s", &host_if_name))
16473 vec_add1 (host_if_name, 0);
16478 if (!vec_len (host_if_name))
16480 errmsg ("host-interface name must be specified");
16484 if (vec_len (host_if_name) > 64)
16486 errmsg ("host-interface name too long");
16490 M (AF_PACKET_DELETE, mp);
16492 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16493 vec_free (host_if_name);
16501 api_policer_add_del (vat_main_t * vam)
16503 unformat_input_t *i = vam->input;
16504 vl_api_policer_add_del_t *mp;
16514 u8 color_aware = 0;
16515 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
16518 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
16519 conform_action.dscp = 0;
16520 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
16521 exceed_action.dscp = 0;
16522 violate_action.action_type = SSE2_QOS_ACTION_DROP;
16523 violate_action.dscp = 0;
16525 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16527 if (unformat (i, "del"))
16529 else if (unformat (i, "name %s", &name))
16530 vec_add1 (name, 0);
16531 else if (unformat (i, "cir %u", &cir))
16533 else if (unformat (i, "eir %u", &eir))
16535 else if (unformat (i, "cb %u", &cb))
16537 else if (unformat (i, "eb %u", &eb))
16539 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
16542 else if (unformat (i, "round_type %U", unformat_policer_round_type,
16545 else if (unformat (i, "type %U", unformat_policer_type, &type))
16547 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
16550 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
16553 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
16556 else if (unformat (i, "color-aware"))
16562 if (!vec_len (name))
16564 errmsg ("policer name must be specified");
16568 if (vec_len (name) > 64)
16570 errmsg ("policer name too long");
16574 M (POLICER_ADD_DEL, mp);
16576 clib_memcpy (mp->name, name, vec_len (name));
16578 mp->is_add = is_add;
16583 mp->rate_type = rate_type;
16584 mp->round_type = round_type;
16586 mp->conform_action_type = conform_action.action_type;
16587 mp->conform_dscp = conform_action.dscp;
16588 mp->exceed_action_type = exceed_action.action_type;
16589 mp->exceed_dscp = exceed_action.dscp;
16590 mp->violate_action_type = violate_action.action_type;
16591 mp->violate_dscp = violate_action.dscp;
16592 mp->color_aware = color_aware;
16600 api_policer_dump (vat_main_t * vam)
16602 unformat_input_t *i = vam->input;
16603 vl_api_policer_dump_t *mp;
16604 vl_api_control_ping_t *mp_ping;
16605 u8 *match_name = 0;
16606 u8 match_name_valid = 0;
16609 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16611 if (unformat (i, "name %s", &match_name))
16613 vec_add1 (match_name, 0);
16614 match_name_valid = 1;
16620 M (POLICER_DUMP, mp);
16621 mp->match_name_valid = match_name_valid;
16622 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
16623 vec_free (match_name);
16627 /* Use a control ping for synchronization */
16628 M (CONTROL_PING, mp_ping);
16631 /* Wait for a reply... */
16637 api_policer_classify_set_interface (vat_main_t * vam)
16639 unformat_input_t *i = vam->input;
16640 vl_api_policer_classify_set_interface_t *mp;
16642 int sw_if_index_set;
16643 u32 ip4_table_index = ~0;
16644 u32 ip6_table_index = ~0;
16645 u32 l2_table_index = ~0;
16649 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16651 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16652 sw_if_index_set = 1;
16653 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16654 sw_if_index_set = 1;
16655 else if (unformat (i, "del"))
16657 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16659 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16661 else if (unformat (i, "l2-table %d", &l2_table_index))
16665 clib_warning ("parse error '%U'", format_unformat_error, i);
16670 if (sw_if_index_set == 0)
16672 errmsg ("missing interface name or sw_if_index");
16676 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
16678 mp->sw_if_index = ntohl (sw_if_index);
16679 mp->ip4_table_index = ntohl (ip4_table_index);
16680 mp->ip6_table_index = ntohl (ip6_table_index);
16681 mp->l2_table_index = ntohl (l2_table_index);
16682 mp->is_add = is_add;
16690 api_policer_classify_dump (vat_main_t * vam)
16692 unformat_input_t *i = vam->input;
16693 vl_api_policer_classify_dump_t *mp;
16694 vl_api_control_ping_t *mp_ping;
16695 u8 type = POLICER_CLASSIFY_N_TABLES;
16698 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
16702 errmsg ("classify table type must be specified");
16706 if (!vam->json_output)
16708 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
16711 M (POLICER_CLASSIFY_DUMP, mp);
16716 /* Use a control ping for synchronization */
16717 M (CONTROL_PING, mp_ping);
16720 /* Wait for a reply... */
16726 api_netmap_create (vat_main_t * vam)
16728 unformat_input_t *i = vam->input;
16729 vl_api_netmap_create_t *mp;
16732 u8 random_hw_addr = 1;
16737 memset (hw_addr, 0, sizeof (hw_addr));
16739 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16741 if (unformat (i, "name %s", &if_name))
16742 vec_add1 (if_name, 0);
16743 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16744 random_hw_addr = 0;
16745 else if (unformat (i, "pipe"))
16747 else if (unformat (i, "master"))
16749 else if (unformat (i, "slave"))
16755 if (!vec_len (if_name))
16757 errmsg ("interface name must be specified");
16761 if (vec_len (if_name) > 64)
16763 errmsg ("interface name too long");
16767 M (NETMAP_CREATE, mp);
16769 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16770 clib_memcpy (mp->hw_addr, hw_addr, 6);
16771 mp->use_random_hw_addr = random_hw_addr;
16772 mp->is_pipe = is_pipe;
16773 mp->is_master = is_master;
16774 vec_free (if_name);
16782 api_netmap_delete (vat_main_t * vam)
16784 unformat_input_t *i = vam->input;
16785 vl_api_netmap_delete_t *mp;
16789 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16791 if (unformat (i, "name %s", &if_name))
16792 vec_add1 (if_name, 0);
16797 if (!vec_len (if_name))
16799 errmsg ("interface name must be specified");
16803 if (vec_len (if_name) > 64)
16805 errmsg ("interface name too long");
16809 M (NETMAP_DELETE, mp);
16811 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16812 vec_free (if_name);
16820 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
16822 if (fp->afi == IP46_TYPE_IP6)
16824 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16825 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16826 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16827 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16828 format_ip6_address, fp->next_hop);
16829 else if (fp->afi == IP46_TYPE_IP4)
16831 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16832 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16833 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16834 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16835 format_ip4_address, fp->next_hop);
16839 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
16840 vl_api_fib_path2_t * fp)
16842 struct in_addr ip4;
16843 struct in6_addr ip6;
16845 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16846 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16847 vat_json_object_add_uint (node, "is_local", fp->is_local);
16848 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16849 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16850 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16851 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16852 if (fp->afi == IP46_TYPE_IP4)
16854 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16855 vat_json_object_add_ip4 (node, "next_hop", ip4);
16857 else if (fp->afi == IP46_TYPE_IP6)
16859 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16860 vat_json_object_add_ip6 (node, "next_hop", ip6);
16865 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
16867 vat_main_t *vam = &vat_main;
16868 int count = ntohl (mp->mt_count);
16869 vl_api_fib_path2_t *fp;
16872 print (vam->ofp, "[%d]: sw_if_index %d via:",
16873 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
16875 for (i = 0; i < count; i++)
16877 vl_api_mpls_fib_path_print (vam, fp);
16881 print (vam->ofp, "");
16884 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
16885 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
16888 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
16890 vat_main_t *vam = &vat_main;
16891 vat_json_node_t *node = NULL;
16892 int count = ntohl (mp->mt_count);
16893 vl_api_fib_path2_t *fp;
16896 if (VAT_JSON_ARRAY != vam->json_tree.type)
16898 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16899 vat_json_init_array (&vam->json_tree);
16901 node = vat_json_array_add (&vam->json_tree);
16903 vat_json_init_object (node);
16904 vat_json_object_add_uint (node, "tunnel_index",
16905 ntohl (mp->mt_tunnel_index));
16906 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
16908 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
16911 for (i = 0; i < count; i++)
16913 vl_api_mpls_fib_path_json_print (node, fp);
16919 api_mpls_tunnel_dump (vat_main_t * vam)
16921 vl_api_mpls_tunnel_dump_t *mp;
16922 vl_api_control_ping_t *mp_ping;
16926 /* Parse args required to build the message */
16927 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
16929 if (!unformat (vam->input, "tunnel_index %d", &index))
16936 print (vam->ofp, " tunnel_index %d", index);
16938 M (MPLS_TUNNEL_DUMP, mp);
16939 mp->tunnel_index = htonl (index);
16942 /* Use a control ping for synchronization */
16943 M (CONTROL_PING, mp_ping);
16950 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
16951 #define vl_api_mpls_fib_details_t_print vl_noop_handler
16955 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
16957 vat_main_t *vam = &vat_main;
16958 int count = ntohl (mp->count);
16959 vl_api_fib_path2_t *fp;
16963 "table-id %d, label %u, ess_bit %u",
16964 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
16966 for (i = 0; i < count; i++)
16968 vl_api_mpls_fib_path_print (vam, fp);
16973 static void vl_api_mpls_fib_details_t_handler_json
16974 (vl_api_mpls_fib_details_t * mp)
16976 vat_main_t *vam = &vat_main;
16977 int count = ntohl (mp->count);
16978 vat_json_node_t *node = NULL;
16979 vl_api_fib_path2_t *fp;
16982 if (VAT_JSON_ARRAY != vam->json_tree.type)
16984 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16985 vat_json_init_array (&vam->json_tree);
16987 node = vat_json_array_add (&vam->json_tree);
16989 vat_json_init_object (node);
16990 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16991 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
16992 vat_json_object_add_uint (node, "label", ntohl (mp->label));
16993 vat_json_object_add_uint (node, "path_count", count);
16995 for (i = 0; i < count; i++)
16997 vl_api_mpls_fib_path_json_print (node, fp);
17003 api_mpls_fib_dump (vat_main_t * vam)
17005 vl_api_mpls_fib_dump_t *mp;
17006 vl_api_control_ping_t *mp_ping;
17009 M (MPLS_FIB_DUMP, mp);
17012 /* Use a control ping for synchronization */
17013 M (CONTROL_PING, mp_ping);
17020 #define vl_api_ip_fib_details_t_endian vl_noop_handler
17021 #define vl_api_ip_fib_details_t_print vl_noop_handler
17024 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
17026 vat_main_t *vam = &vat_main;
17027 int count = ntohl (mp->count);
17028 vl_api_fib_path_t *fp;
17032 "table-id %d, prefix %U/%d",
17033 ntohl (mp->table_id), format_ip4_address, mp->address,
17034 mp->address_length);
17036 for (i = 0; i < count; i++)
17038 if (fp->afi == IP46_TYPE_IP6)
17040 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17041 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17042 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17043 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17044 format_ip6_address, fp->next_hop);
17045 else if (fp->afi == IP46_TYPE_IP4)
17047 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17048 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17049 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17050 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17051 format_ip4_address, fp->next_hop);
17056 static void vl_api_ip_fib_details_t_handler_json
17057 (vl_api_ip_fib_details_t * mp)
17059 vat_main_t *vam = &vat_main;
17060 int count = ntohl (mp->count);
17061 vat_json_node_t *node = NULL;
17062 struct in_addr ip4;
17063 struct in6_addr ip6;
17064 vl_api_fib_path_t *fp;
17067 if (VAT_JSON_ARRAY != vam->json_tree.type)
17069 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17070 vat_json_init_array (&vam->json_tree);
17072 node = vat_json_array_add (&vam->json_tree);
17074 vat_json_init_object (node);
17075 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17076 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
17077 vat_json_object_add_ip4 (node, "prefix", ip4);
17078 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17079 vat_json_object_add_uint (node, "path_count", count);
17081 for (i = 0; i < count; i++)
17083 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17084 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17085 vat_json_object_add_uint (node, "is_local", fp->is_local);
17086 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17087 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17088 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17089 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17090 if (fp->afi == IP46_TYPE_IP4)
17092 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17093 vat_json_object_add_ip4 (node, "next_hop", ip4);
17095 else if (fp->afi == IP46_TYPE_IP6)
17097 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17098 vat_json_object_add_ip6 (node, "next_hop", ip6);
17104 api_ip_fib_dump (vat_main_t * vam)
17106 vl_api_ip_fib_dump_t *mp;
17107 vl_api_control_ping_t *mp_ping;
17110 M (IP_FIB_DUMP, mp);
17113 /* Use a control ping for synchronization */
17114 M (CONTROL_PING, mp_ping);
17122 api_ip_mfib_dump (vat_main_t * vam)
17124 vl_api_ip_mfib_dump_t *mp;
17125 vl_api_control_ping_t *mp_ping;
17128 M (IP_MFIB_DUMP, mp);
17131 /* Use a control ping for synchronization */
17132 M (CONTROL_PING, mp_ping);
17139 static void vl_api_ip_neighbor_details_t_handler
17140 (vl_api_ip_neighbor_details_t * mp)
17142 vat_main_t *vam = &vat_main;
17144 print (vam->ofp, "%c %U %U",
17145 (mp->is_static) ? 'S' : 'D',
17146 format_ethernet_address, &mp->mac_address,
17147 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
17151 static void vl_api_ip_neighbor_details_t_handler_json
17152 (vl_api_ip_neighbor_details_t * mp)
17155 vat_main_t *vam = &vat_main;
17156 vat_json_node_t *node;
17157 struct in_addr ip4;
17158 struct in6_addr ip6;
17160 if (VAT_JSON_ARRAY != vam->json_tree.type)
17162 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17163 vat_json_init_array (&vam->json_tree);
17165 node = vat_json_array_add (&vam->json_tree);
17167 vat_json_init_object (node);
17168 vat_json_object_add_string_copy (node, "flag",
17169 (mp->is_static) ? (u8 *) "static" : (u8 *)
17172 vat_json_object_add_string_copy (node, "link_layer",
17173 format (0, "%U", format_ethernet_address,
17174 &mp->mac_address));
17178 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
17179 vat_json_object_add_ip6 (node, "ip_address", ip6);
17183 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
17184 vat_json_object_add_ip4 (node, "ip_address", ip4);
17189 api_ip_neighbor_dump (vat_main_t * vam)
17191 unformat_input_t *i = vam->input;
17192 vl_api_ip_neighbor_dump_t *mp;
17193 vl_api_control_ping_t *mp_ping;
17195 u32 sw_if_index = ~0;
17198 /* Parse args required to build the message */
17199 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17201 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17203 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17205 else if (unformat (i, "ip6"))
17211 if (sw_if_index == ~0)
17213 errmsg ("missing interface name or sw_if_index");
17217 M (IP_NEIGHBOR_DUMP, mp);
17218 mp->is_ipv6 = (u8) is_ipv6;
17219 mp->sw_if_index = ntohl (sw_if_index);
17222 /* Use a control ping for synchronization */
17223 M (CONTROL_PING, mp_ping);
17230 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
17231 #define vl_api_ip6_fib_details_t_print vl_noop_handler
17234 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
17236 vat_main_t *vam = &vat_main;
17237 int count = ntohl (mp->count);
17238 vl_api_fib_path_t *fp;
17242 "table-id %d, prefix %U/%d",
17243 ntohl (mp->table_id), format_ip6_address, mp->address,
17244 mp->address_length);
17246 for (i = 0; i < count; i++)
17248 if (fp->afi == IP46_TYPE_IP6)
17250 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17251 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17252 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17253 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17254 format_ip6_address, fp->next_hop);
17255 else if (fp->afi == IP46_TYPE_IP4)
17257 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17258 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17259 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17260 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17261 format_ip4_address, fp->next_hop);
17266 static void vl_api_ip6_fib_details_t_handler_json
17267 (vl_api_ip6_fib_details_t * mp)
17269 vat_main_t *vam = &vat_main;
17270 int count = ntohl (mp->count);
17271 vat_json_node_t *node = NULL;
17272 struct in_addr ip4;
17273 struct in6_addr ip6;
17274 vl_api_fib_path_t *fp;
17277 if (VAT_JSON_ARRAY != vam->json_tree.type)
17279 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17280 vat_json_init_array (&vam->json_tree);
17282 node = vat_json_array_add (&vam->json_tree);
17284 vat_json_init_object (node);
17285 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17286 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
17287 vat_json_object_add_ip6 (node, "prefix", ip6);
17288 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17289 vat_json_object_add_uint (node, "path_count", count);
17291 for (i = 0; i < count; i++)
17293 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17294 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17295 vat_json_object_add_uint (node, "is_local", fp->is_local);
17296 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17297 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17298 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17299 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17300 if (fp->afi == IP46_TYPE_IP4)
17302 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17303 vat_json_object_add_ip4 (node, "next_hop", ip4);
17305 else if (fp->afi == IP46_TYPE_IP6)
17307 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17308 vat_json_object_add_ip6 (node, "next_hop", ip6);
17314 api_ip6_fib_dump (vat_main_t * vam)
17316 vl_api_ip6_fib_dump_t *mp;
17317 vl_api_control_ping_t *mp_ping;
17320 M (IP6_FIB_DUMP, mp);
17323 /* Use a control ping for synchronization */
17324 M (CONTROL_PING, mp_ping);
17332 api_ip6_mfib_dump (vat_main_t * vam)
17334 vl_api_ip6_mfib_dump_t *mp;
17335 vl_api_control_ping_t *mp_ping;
17338 M (IP6_MFIB_DUMP, mp);
17341 /* Use a control ping for synchronization */
17342 M (CONTROL_PING, mp_ping);
17350 api_classify_table_ids (vat_main_t * vam)
17352 vl_api_classify_table_ids_t *mp;
17355 /* Construct the API message */
17356 M (CLASSIFY_TABLE_IDS, mp);
17365 api_classify_table_by_interface (vat_main_t * vam)
17367 unformat_input_t *input = vam->input;
17368 vl_api_classify_table_by_interface_t *mp;
17370 u32 sw_if_index = ~0;
17372 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17374 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17376 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17381 if (sw_if_index == ~0)
17383 errmsg ("missing interface name or sw_if_index");
17387 /* Construct the API message */
17388 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
17390 mp->sw_if_index = ntohl (sw_if_index);
17398 api_classify_table_info (vat_main_t * vam)
17400 unformat_input_t *input = vam->input;
17401 vl_api_classify_table_info_t *mp;
17405 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17407 if (unformat (input, "table_id %d", &table_id))
17412 if (table_id == ~0)
17414 errmsg ("missing table id");
17418 /* Construct the API message */
17419 M (CLASSIFY_TABLE_INFO, mp);
17421 mp->table_id = ntohl (table_id);
17429 api_classify_session_dump (vat_main_t * vam)
17431 unformat_input_t *input = vam->input;
17432 vl_api_classify_session_dump_t *mp;
17433 vl_api_control_ping_t *mp_ping;
17437 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17439 if (unformat (input, "table_id %d", &table_id))
17444 if (table_id == ~0)
17446 errmsg ("missing table id");
17450 /* Construct the API message */
17451 M (CLASSIFY_SESSION_DUMP, mp);
17453 mp->table_id = ntohl (table_id);
17456 /* Use a control ping for synchronization */
17457 M (CONTROL_PING, mp_ping);
17465 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
17467 vat_main_t *vam = &vat_main;
17469 print (vam->ofp, "collector_address %U, collector_port %d, "
17470 "src_address %U, vrf_id %d, path_mtu %u, "
17471 "template_interval %u, udp_checksum %d",
17472 format_ip4_address, mp->collector_address,
17473 ntohs (mp->collector_port),
17474 format_ip4_address, mp->src_address,
17475 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
17476 ntohl (mp->template_interval), mp->udp_checksum);
17479 vam->result_ready = 1;
17483 vl_api_ipfix_exporter_details_t_handler_json
17484 (vl_api_ipfix_exporter_details_t * mp)
17486 vat_main_t *vam = &vat_main;
17487 vat_json_node_t node;
17488 struct in_addr collector_address;
17489 struct in_addr src_address;
17491 vat_json_init_object (&node);
17492 clib_memcpy (&collector_address, &mp->collector_address,
17493 sizeof (collector_address));
17494 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
17495 vat_json_object_add_uint (&node, "collector_port",
17496 ntohs (mp->collector_port));
17497 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
17498 vat_json_object_add_ip4 (&node, "src_address", src_address);
17499 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
17500 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
17501 vat_json_object_add_uint (&node, "template_interval",
17502 ntohl (mp->template_interval));
17503 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
17505 vat_json_print (vam->ofp, &node);
17506 vat_json_free (&node);
17508 vam->result_ready = 1;
17512 api_ipfix_exporter_dump (vat_main_t * vam)
17514 vl_api_ipfix_exporter_dump_t *mp;
17517 /* Construct the API message */
17518 M (IPFIX_EXPORTER_DUMP, mp);
17527 api_ipfix_classify_stream_dump (vat_main_t * vam)
17529 vl_api_ipfix_classify_stream_dump_t *mp;
17532 /* Construct the API message */
17533 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
17544 vl_api_ipfix_classify_stream_details_t_handler
17545 (vl_api_ipfix_classify_stream_details_t * mp)
17547 vat_main_t *vam = &vat_main;
17548 print (vam->ofp, "domain_id %d, src_port %d",
17549 ntohl (mp->domain_id), ntohs (mp->src_port));
17551 vam->result_ready = 1;
17555 vl_api_ipfix_classify_stream_details_t_handler_json
17556 (vl_api_ipfix_classify_stream_details_t * mp)
17558 vat_main_t *vam = &vat_main;
17559 vat_json_node_t node;
17561 vat_json_init_object (&node);
17562 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
17563 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
17565 vat_json_print (vam->ofp, &node);
17566 vat_json_free (&node);
17568 vam->result_ready = 1;
17572 api_ipfix_classify_table_dump (vat_main_t * vam)
17574 vl_api_ipfix_classify_table_dump_t *mp;
17575 vl_api_control_ping_t *mp_ping;
17578 if (!vam->json_output)
17580 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
17581 "transport_protocol");
17584 /* Construct the API message */
17585 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
17590 /* Use a control ping for synchronization */
17591 M (CONTROL_PING, mp_ping);
17599 vl_api_ipfix_classify_table_details_t_handler
17600 (vl_api_ipfix_classify_table_details_t * mp)
17602 vat_main_t *vam = &vat_main;
17603 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
17604 mp->transport_protocol);
17608 vl_api_ipfix_classify_table_details_t_handler_json
17609 (vl_api_ipfix_classify_table_details_t * mp)
17611 vat_json_node_t *node = NULL;
17612 vat_main_t *vam = &vat_main;
17614 if (VAT_JSON_ARRAY != vam->json_tree.type)
17616 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17617 vat_json_init_array (&vam->json_tree);
17620 node = vat_json_array_add (&vam->json_tree);
17621 vat_json_init_object (node);
17623 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
17624 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
17625 vat_json_object_add_uint (node, "transport_protocol",
17626 mp->transport_protocol);
17630 api_sw_interface_span_enable_disable (vat_main_t * vam)
17632 unformat_input_t *i = vam->input;
17633 vl_api_sw_interface_span_enable_disable_t *mp;
17634 u32 src_sw_if_index = ~0;
17635 u32 dst_sw_if_index = ~0;
17639 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17642 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
17644 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
17648 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
17650 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
17652 else if (unformat (i, "disable"))
17654 else if (unformat (i, "rx"))
17656 else if (unformat (i, "tx"))
17658 else if (unformat (i, "both"))
17664 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
17666 mp->sw_if_index_from = htonl (src_sw_if_index);
17667 mp->sw_if_index_to = htonl (dst_sw_if_index);
17676 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
17679 vat_main_t *vam = &vat_main;
17680 u8 *sw_if_from_name = 0;
17681 u8 *sw_if_to_name = 0;
17682 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17683 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17684 char *states[] = { "none", "rx", "tx", "both" };
17688 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17690 if ((u32) p->value[0] == sw_if_index_from)
17692 sw_if_from_name = (u8 *)(p->key);
17696 if ((u32) p->value[0] == sw_if_index_to)
17698 sw_if_to_name = (u8 *)(p->key);
17699 if (sw_if_from_name)
17704 print (vam->ofp, "%20s => %20s (%s)",
17705 sw_if_from_name, sw_if_to_name, states[mp->state]);
17709 vl_api_sw_interface_span_details_t_handler_json
17710 (vl_api_sw_interface_span_details_t * mp)
17712 vat_main_t *vam = &vat_main;
17713 vat_json_node_t *node = NULL;
17714 u8 *sw_if_from_name = 0;
17715 u8 *sw_if_to_name = 0;
17716 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17717 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17721 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17723 if ((u32) p->value[0] == sw_if_index_from)
17725 sw_if_from_name = (u8 *)(p->key);
17729 if ((u32) p->value[0] == sw_if_index_to)
17731 sw_if_to_name = (u8 *)(p->key);
17732 if (sw_if_from_name)
17738 if (VAT_JSON_ARRAY != vam->json_tree.type)
17740 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17741 vat_json_init_array (&vam->json_tree);
17743 node = vat_json_array_add (&vam->json_tree);
17745 vat_json_init_object (node);
17746 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
17747 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
17748 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
17749 if (0 != sw_if_to_name)
17751 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
17753 vat_json_object_add_uint (node, "state", mp->state);
17757 api_sw_interface_span_dump (vat_main_t * vam)
17759 vl_api_sw_interface_span_dump_t *mp;
17760 vl_api_control_ping_t *mp_ping;
17763 M (SW_INTERFACE_SPAN_DUMP, mp);
17766 /* Use a control ping for synchronization */
17767 M (CONTROL_PING, mp_ping);
17775 api_pg_create_interface (vat_main_t * vam)
17777 unformat_input_t *input = vam->input;
17778 vl_api_pg_create_interface_t *mp;
17782 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17784 if (unformat (input, "if_id %d", &if_id))
17791 errmsg ("missing pg interface index");
17795 /* Construct the API message */
17796 M (PG_CREATE_INTERFACE, mp);
17798 mp->interface_id = ntohl (if_id);
17806 api_pg_capture (vat_main_t * vam)
17808 unformat_input_t *input = vam->input;
17809 vl_api_pg_capture_t *mp;
17814 u8 pcap_file_set = 0;
17817 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17819 if (unformat (input, "if_id %d", &if_id))
17821 else if (unformat (input, "pcap %s", &pcap_file))
17823 else if (unformat (input, "count %d", &count))
17825 else if (unformat (input, "disable"))
17832 errmsg ("missing pg interface index");
17835 if (pcap_file_set > 0)
17837 if (vec_len (pcap_file) > 255)
17839 errmsg ("pcap file name is too long");
17844 u32 name_len = vec_len (pcap_file);
17845 /* Construct the API message */
17846 M (PG_CAPTURE, mp);
17848 mp->interface_id = ntohl (if_id);
17849 mp->is_enabled = enable;
17850 mp->count = ntohl (count);
17851 mp->pcap_name_length = ntohl (name_len);
17852 if (pcap_file_set != 0)
17854 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
17856 vec_free (pcap_file);
17864 api_pg_enable_disable (vat_main_t * vam)
17866 unformat_input_t *input = vam->input;
17867 vl_api_pg_enable_disable_t *mp;
17870 u8 stream_name_set = 0;
17871 u8 *stream_name = 0;
17873 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17875 if (unformat (input, "stream %s", &stream_name))
17876 stream_name_set = 1;
17877 else if (unformat (input, "disable"))
17883 if (stream_name_set > 0)
17885 if (vec_len (stream_name) > 255)
17887 errmsg ("stream name too long");
17892 u32 name_len = vec_len (stream_name);
17893 /* Construct the API message */
17894 M (PG_ENABLE_DISABLE, mp);
17896 mp->is_enabled = enable;
17897 if (stream_name_set != 0)
17899 mp->stream_name_length = ntohl (name_len);
17900 clib_memcpy (mp->stream_name, stream_name, name_len);
17902 vec_free (stream_name);
17910 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
17912 unformat_input_t *input = vam->input;
17913 vl_api_ip_source_and_port_range_check_add_del_t *mp;
17915 u16 *low_ports = 0;
17916 u16 *high_ports = 0;
17919 ip4_address_t ip4_addr;
17920 ip6_address_t ip6_addr;
17929 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17931 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
17937 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
17942 else if (unformat (input, "vrf %d", &vrf_id))
17944 else if (unformat (input, "del"))
17946 else if (unformat (input, "port %d", &tmp))
17948 if (tmp == 0 || tmp > 65535)
17950 errmsg ("port %d out of range", tmp);
17954 this_hi = this_low + 1;
17955 vec_add1 (low_ports, this_low);
17956 vec_add1 (high_ports, this_hi);
17958 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
17960 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
17962 errmsg ("incorrect range parameters");
17966 /* Note: in debug CLI +1 is added to high before
17967 passing to real fn that does "the work"
17968 (ip_source_and_port_range_check_add_del).
17969 This fn is a wrapper around the binary API fn a
17970 control plane will call, which expects this increment
17971 to have occurred. Hence letting the binary API control
17972 plane fn do the increment for consistency between VAT
17973 and other control planes.
17976 vec_add1 (low_ports, this_low);
17977 vec_add1 (high_ports, this_hi);
17983 if (prefix_set == 0)
17985 errmsg ("<address>/<mask> not specified");
17991 errmsg ("VRF ID required, not specified");
17998 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18002 if (vec_len (low_ports) == 0)
18004 errmsg ("At least one port or port range required");
18008 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
18010 mp->is_add = is_add;
18015 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
18020 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
18023 mp->mask_length = length;
18024 mp->number_of_ranges = vec_len (low_ports);
18026 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
18027 vec_free (low_ports);
18029 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
18030 vec_free (high_ports);
18032 mp->vrf_id = ntohl (vrf_id);
18040 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
18042 unformat_input_t *input = vam->input;
18043 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
18044 u32 sw_if_index = ~0;
18046 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
18047 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
18051 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18053 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18055 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18057 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
18059 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
18061 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
18063 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
18065 else if (unformat (input, "del"))
18071 if (sw_if_index == ~0)
18073 errmsg ("Interface required but not specified");
18079 errmsg ("VRF ID required but not specified");
18083 if (tcp_out_vrf_id == 0
18084 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
18087 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18091 /* Construct the API message */
18092 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
18094 mp->sw_if_index = ntohl (sw_if_index);
18095 mp->is_add = is_add;
18096 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
18097 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
18098 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
18099 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
18104 /* Wait for a reply... */
18110 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
18112 unformat_input_t *i = vam->input;
18113 vl_api_ipsec_gre_add_del_tunnel_t *mp;
18114 u32 local_sa_id = 0;
18115 u32 remote_sa_id = 0;
18116 ip4_address_t src_address;
18117 ip4_address_t dst_address;
18121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18123 if (unformat (i, "local_sa %d", &local_sa_id))
18125 else if (unformat (i, "remote_sa %d", &remote_sa_id))
18127 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
18129 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
18131 else if (unformat (i, "del"))
18135 clib_warning ("parse error '%U'", format_unformat_error, i);
18140 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
18142 mp->local_sa_id = ntohl (local_sa_id);
18143 mp->remote_sa_id = ntohl (remote_sa_id);
18144 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
18145 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
18146 mp->is_add = is_add;
18154 api_punt (vat_main_t * vam)
18156 unformat_input_t *i = vam->input;
18164 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18166 if (unformat (i, "ip %d", &ipv))
18168 else if (unformat (i, "protocol %d", &protocol))
18170 else if (unformat (i, "port %d", &port))
18172 else if (unformat (i, "del"))
18176 clib_warning ("parse error '%U'", format_unformat_error, i);
18183 mp->is_add = (u8) is_add;
18184 mp->ipv = (u8) ipv;
18185 mp->l4_protocol = (u8) protocol;
18186 mp->l4_port = htons ((u16) port);
18193 static void vl_api_ipsec_gre_tunnel_details_t_handler
18194 (vl_api_ipsec_gre_tunnel_details_t * mp)
18196 vat_main_t *vam = &vat_main;
18198 print (vam->ofp, "%11d%15U%15U%14d%14d",
18199 ntohl (mp->sw_if_index),
18200 format_ip4_address, &mp->src_address,
18201 format_ip4_address, &mp->dst_address,
18202 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
18205 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
18206 (vl_api_ipsec_gre_tunnel_details_t * mp)
18208 vat_main_t *vam = &vat_main;
18209 vat_json_node_t *node = NULL;
18210 struct in_addr ip4;
18212 if (VAT_JSON_ARRAY != vam->json_tree.type)
18214 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18215 vat_json_init_array (&vam->json_tree);
18217 node = vat_json_array_add (&vam->json_tree);
18219 vat_json_init_object (node);
18220 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18221 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
18222 vat_json_object_add_ip4 (node, "src_address", ip4);
18223 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
18224 vat_json_object_add_ip4 (node, "dst_address", ip4);
18225 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
18226 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
18230 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
18232 unformat_input_t *i = vam->input;
18233 vl_api_ipsec_gre_tunnel_dump_t *mp;
18234 vl_api_control_ping_t *mp_ping;
18236 u8 sw_if_index_set = 0;
18239 /* Parse args required to build the message */
18240 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18242 if (unformat (i, "sw_if_index %d", &sw_if_index))
18243 sw_if_index_set = 1;
18248 if (sw_if_index_set == 0)
18253 if (!vam->json_output)
18255 print (vam->ofp, "%11s%15s%15s%14s%14s",
18256 "sw_if_index", "src_address", "dst_address",
18257 "local_sa_id", "remote_sa_id");
18260 /* Get list of gre-tunnel interfaces */
18261 M (IPSEC_GRE_TUNNEL_DUMP, mp);
18263 mp->sw_if_index = htonl (sw_if_index);
18267 /* Use a control ping for synchronization */
18268 M (CONTROL_PING, mp_ping);
18276 api_delete_subif (vat_main_t * vam)
18278 unformat_input_t *i = vam->input;
18279 vl_api_delete_subif_t *mp;
18280 u32 sw_if_index = ~0;
18283 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18285 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18287 if (unformat (i, "sw_if_index %d", &sw_if_index))
18293 if (sw_if_index == ~0)
18295 errmsg ("missing sw_if_index");
18299 /* Construct the API message */
18300 M (DELETE_SUBIF, mp);
18301 mp->sw_if_index = ntohl (sw_if_index);
18308 #define foreach_pbb_vtr_op \
18309 _("disable", L2_VTR_DISABLED) \
18310 _("pop", L2_VTR_POP_2) \
18311 _("push", L2_VTR_PUSH_2)
18314 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
18316 unformat_input_t *i = vam->input;
18317 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
18318 u32 sw_if_index = ~0, vtr_op = ~0;
18319 u16 outer_tag = ~0;
18320 u8 dmac[6], smac[6];
18321 u8 dmac_set = 0, smac_set = 0;
18327 /* Shut up coverity */
18328 memset (dmac, 0, sizeof (dmac));
18329 memset (smac, 0, sizeof (smac));
18331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18333 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18335 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18337 else if (unformat (i, "vtr_op %d", &vtr_op))
18339 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
18342 else if (unformat (i, "translate_pbb_stag"))
18344 if (unformat (i, "%d", &tmp))
18346 vtr_op = L2_VTR_TRANSLATE_2_1;
18352 ("translate_pbb_stag operation requires outer tag definition");
18356 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
18358 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
18360 else if (unformat (i, "sid %d", &sid))
18362 else if (unformat (i, "vlanid %d", &tmp))
18366 clib_warning ("parse error '%U'", format_unformat_error, i);
18371 if ((sw_if_index == ~0) || (vtr_op == ~0))
18373 errmsg ("missing sw_if_index or vtr operation");
18376 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
18377 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
18380 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
18384 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
18385 mp->sw_if_index = ntohl (sw_if_index);
18386 mp->vtr_op = ntohl (vtr_op);
18387 mp->outer_tag = ntohs (outer_tag);
18388 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
18389 clib_memcpy (mp->b_smac, smac, sizeof (smac));
18390 mp->b_vlanid = ntohs (vlanid);
18391 mp->i_sid = ntohl (sid);
18399 api_flow_classify_set_interface (vat_main_t * vam)
18401 unformat_input_t *i = vam->input;
18402 vl_api_flow_classify_set_interface_t *mp;
18404 int sw_if_index_set;
18405 u32 ip4_table_index = ~0;
18406 u32 ip6_table_index = ~0;
18410 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18412 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18413 sw_if_index_set = 1;
18414 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18415 sw_if_index_set = 1;
18416 else if (unformat (i, "del"))
18418 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18420 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18424 clib_warning ("parse error '%U'", format_unformat_error, i);
18429 if (sw_if_index_set == 0)
18431 errmsg ("missing interface name or sw_if_index");
18435 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
18437 mp->sw_if_index = ntohl (sw_if_index);
18438 mp->ip4_table_index = ntohl (ip4_table_index);
18439 mp->ip6_table_index = ntohl (ip6_table_index);
18440 mp->is_add = is_add;
18448 api_flow_classify_dump (vat_main_t * vam)
18450 unformat_input_t *i = vam->input;
18451 vl_api_flow_classify_dump_t *mp;
18452 vl_api_control_ping_t *mp_ping;
18453 u8 type = FLOW_CLASSIFY_N_TABLES;
18456 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
18460 errmsg ("classify table type must be specified");
18464 if (!vam->json_output)
18466 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18469 M (FLOW_CLASSIFY_DUMP, mp);
18474 /* Use a control ping for synchronization */
18475 M (CONTROL_PING, mp_ping);
18478 /* Wait for a reply... */
18484 api_feature_enable_disable (vat_main_t * vam)
18486 unformat_input_t *i = vam->input;
18487 vl_api_feature_enable_disable_t *mp;
18489 u8 *feature_name = 0;
18490 u32 sw_if_index = ~0;
18494 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18496 if (unformat (i, "arc_name %s", &arc_name))
18498 else if (unformat (i, "feature_name %s", &feature_name))
18501 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18503 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18505 else if (unformat (i, "disable"))
18513 errmsg ("missing arc name");
18516 if (vec_len (arc_name) > 63)
18518 errmsg ("arc name too long");
18521 if (feature_name == 0)
18523 errmsg ("missing feature name");
18526 if (vec_len (feature_name) > 63)
18528 errmsg ("feature name too long");
18531 if (sw_if_index == ~0)
18533 errmsg ("missing interface name or sw_if_index");
18537 /* Construct the API message */
18538 M (FEATURE_ENABLE_DISABLE, mp);
18539 mp->sw_if_index = ntohl (sw_if_index);
18540 mp->enable = enable;
18541 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
18542 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
18543 vec_free (arc_name);
18544 vec_free (feature_name);
18552 api_sw_interface_tag_add_del (vat_main_t * vam)
18554 unformat_input_t *i = vam->input;
18555 vl_api_sw_interface_tag_add_del_t *mp;
18556 u32 sw_if_index = ~0;
18561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18563 if (unformat (i, "tag %s", &tag))
18565 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18567 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18569 else if (unformat (i, "del"))
18575 if (sw_if_index == ~0)
18577 errmsg ("missing interface name or sw_if_index");
18581 if (enable && (tag == 0))
18583 errmsg ("no tag specified");
18587 /* Construct the API message */
18588 M (SW_INTERFACE_TAG_ADD_DEL, mp);
18589 mp->sw_if_index = ntohl (sw_if_index);
18590 mp->is_add = enable;
18592 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
18600 static void vl_api_l2_xconnect_details_t_handler
18601 (vl_api_l2_xconnect_details_t * mp)
18603 vat_main_t *vam = &vat_main;
18605 print (vam->ofp, "%15d%15d",
18606 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
18609 static void vl_api_l2_xconnect_details_t_handler_json
18610 (vl_api_l2_xconnect_details_t * mp)
18612 vat_main_t *vam = &vat_main;
18613 vat_json_node_t *node = NULL;
18615 if (VAT_JSON_ARRAY != vam->json_tree.type)
18617 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18618 vat_json_init_array (&vam->json_tree);
18620 node = vat_json_array_add (&vam->json_tree);
18622 vat_json_init_object (node);
18623 vat_json_object_add_uint (node, "rx_sw_if_index",
18624 ntohl (mp->rx_sw_if_index));
18625 vat_json_object_add_uint (node, "tx_sw_if_index",
18626 ntohl (mp->tx_sw_if_index));
18630 api_l2_xconnect_dump (vat_main_t * vam)
18632 vl_api_l2_xconnect_dump_t *mp;
18633 vl_api_control_ping_t *mp_ping;
18636 if (!vam->json_output)
18638 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
18641 M (L2_XCONNECT_DUMP, mp);
18645 /* Use a control ping for synchronization */
18646 M (CONTROL_PING, mp_ping);
18654 api_sw_interface_set_mtu (vat_main_t * vam)
18656 unformat_input_t *i = vam->input;
18657 vl_api_sw_interface_set_mtu_t *mp;
18658 u32 sw_if_index = ~0;
18662 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18664 if (unformat (i, "mtu %d", &mtu))
18666 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18668 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18674 if (sw_if_index == ~0)
18676 errmsg ("missing interface name or sw_if_index");
18682 errmsg ("no mtu specified");
18686 /* Construct the API message */
18687 M (SW_INTERFACE_SET_MTU, mp);
18688 mp->sw_if_index = ntohl (sw_if_index);
18689 mp->mtu = ntohs ((u16) mtu);
18697 api_p2p_ethernet_add (vat_main_t * vam)
18699 unformat_input_t *i = vam->input;
18700 vl_api_p2p_ethernet_add_t *mp;
18701 u32 parent_if_index = ~0;
18706 memset (remote_mac, 0, sizeof (remote_mac));
18707 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18709 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
18711 else if (unformat (i, "sw_if_index %d", &parent_if_index))
18715 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
18719 clib_warning ("parse error '%U'", format_unformat_error, i);
18724 if (parent_if_index == ~0)
18726 errmsg ("missing interface name or sw_if_index");
18731 errmsg ("missing remote mac address");
18735 M (P2P_ETHERNET_ADD, mp);
18736 mp->parent_if_index = ntohl (parent_if_index);
18737 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
18745 api_p2p_ethernet_del (vat_main_t * vam)
18747 unformat_input_t *i = vam->input;
18748 vl_api_p2p_ethernet_del_t *mp;
18749 u32 parent_if_index = ~0;
18754 memset (remote_mac, 0, sizeof (remote_mac));
18755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18757 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
18759 else if (unformat (i, "sw_if_index %d", &parent_if_index))
18763 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
18767 clib_warning ("parse error '%U'", format_unformat_error, i);
18772 if (parent_if_index == ~0)
18774 errmsg ("missing interface name or sw_if_index");
18779 errmsg ("missing remote mac address");
18783 M (P2P_ETHERNET_DEL, mp);
18784 mp->parent_if_index = ntohl (parent_if_index);
18785 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
18793 q_or_quit (vat_main_t * vam)
18795 #if VPP_API_TEST_BUILTIN == 0
18796 longjmp (vam->jump_buf, 1);
18798 return 0; /* not so much */
18802 q (vat_main_t * vam)
18804 return q_or_quit (vam);
18808 quit (vat_main_t * vam)
18810 return q_or_quit (vam);
18814 comment (vat_main_t * vam)
18820 cmd_cmp (void *a1, void *a2)
18825 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
18829 help (vat_main_t * vam)
18834 unformat_input_t *i = vam->input;
18837 if (unformat (i, "%s", &name))
18841 vec_add1 (name, 0);
18843 hs = hash_get_mem (vam->help_by_name, name);
18845 print (vam->ofp, "usage: %s %s", name, hs[0]);
18847 print (vam->ofp, "No such msg / command '%s'", name);
18852 print (vam->ofp, "Help is available for the following:");
18855 hash_foreach_pair (p, vam->function_by_name,
18857 vec_add1 (cmds, (u8 *)(p->key));
18861 vec_sort_with_function (cmds, cmd_cmp);
18863 for (j = 0; j < vec_len (cmds); j++)
18864 print (vam->ofp, "%s", cmds[j]);
18871 set (vat_main_t * vam)
18873 u8 *name = 0, *value = 0;
18874 unformat_input_t *i = vam->input;
18876 if (unformat (i, "%s", &name))
18878 /* The input buffer is a vector, not a string. */
18879 value = vec_dup (i->buffer);
18880 vec_delete (value, i->index, 0);
18881 /* Almost certainly has a trailing newline */
18882 if (value[vec_len (value) - 1] == '\n')
18883 value[vec_len (value) - 1] = 0;
18884 /* Make sure it's a proper string, one way or the other */
18885 vec_add1 (value, 0);
18886 (void) clib_macro_set_value (&vam->macro_main,
18887 (char *) name, (char *) value);
18890 errmsg ("usage: set <name> <value>");
18898 unset (vat_main_t * vam)
18902 if (unformat (vam->input, "%s", &name))
18903 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
18904 errmsg ("unset: %s wasn't set", name);
18917 macro_sort_cmp (void *a1, void *a2)
18919 macro_sort_t *s1 = a1;
18920 macro_sort_t *s2 = a2;
18922 return strcmp ((char *) (s1->name), (char *) (s2->name));
18926 dump_macro_table (vat_main_t * vam)
18928 macro_sort_t *sort_me = 0, *sm;
18933 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
18935 vec_add2 (sort_me, sm, 1);
18936 sm->name = (u8 *)(p->key);
18937 sm->value = (u8 *) (p->value[0]);
18941 vec_sort_with_function (sort_me, macro_sort_cmp);
18943 if (vec_len (sort_me))
18944 print (vam->ofp, "%-15s%s", "Name", "Value");
18946 print (vam->ofp, "The macro table is empty...");
18948 for (i = 0; i < vec_len (sort_me); i++)
18949 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
18954 dump_node_table (vat_main_t * vam)
18957 vlib_node_t *node, *next_node;
18959 if (vec_len (vam->graph_nodes) == 0)
18961 print (vam->ofp, "Node table empty, issue get_node_graph...");
18965 for (i = 0; i < vec_len (vam->graph_nodes); i++)
18967 node = vam->graph_nodes[i];
18968 print (vam->ofp, "[%d] %s", i, node->name);
18969 for (j = 0; j < vec_len (node->next_nodes); j++)
18971 if (node->next_nodes[j] != ~0)
18973 next_node = vam->graph_nodes[node->next_nodes[j]];
18974 print (vam->ofp, " [%d] %s", j, next_node->name);
18982 value_sort_cmp (void *a1, void *a2)
18984 name_sort_t *n1 = a1;
18985 name_sort_t *n2 = a2;
18987 if (n1->value < n2->value)
18989 if (n1->value > n2->value)
18996 dump_msg_api_table (vat_main_t * vam)
18998 api_main_t *am = &api_main;
18999 name_sort_t *nses = 0, *ns;
19004 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
19006 vec_add2 (nses, ns, 1);
19007 ns->name = (u8 *)(hp->key);
19008 ns->value = (u32) hp->value[0];
19012 vec_sort_with_function (nses, value_sort_cmp);
19014 for (i = 0; i < vec_len (nses); i++)
19015 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
19021 get_msg_id (vat_main_t * vam)
19026 if (unformat (vam->input, "%s", &name_and_crc))
19028 message_index = vl_api_get_msg_index (name_and_crc);
19029 if (message_index == ~0)
19031 print (vam->ofp, " '%s' not found", name_and_crc);
19034 print (vam->ofp, " '%s' has message index %d",
19035 name_and_crc, message_index);
19038 errmsg ("name_and_crc required...");
19043 search_node_table (vat_main_t * vam)
19045 unformat_input_t *line_input = vam->input;
19048 vlib_node_t *node, *next_node;
19051 if (vam->graph_node_index_by_name == 0)
19053 print (vam->ofp, "Node table empty, issue get_node_graph...");
19057 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
19059 if (unformat (line_input, "%s", &node_to_find))
19061 vec_add1 (node_to_find, 0);
19062 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
19065 print (vam->ofp, "%s not found...", node_to_find);
19068 node = vam->graph_nodes[p[0]];
19069 print (vam->ofp, "[%d] %s", p[0], node->name);
19070 for (j = 0; j < vec_len (node->next_nodes); j++)
19072 if (node->next_nodes[j] != ~0)
19074 next_node = vam->graph_nodes[node->next_nodes[j]];
19075 print (vam->ofp, " [%d] %s", j, next_node->name);
19082 clib_warning ("parse error '%U'", format_unformat_error,
19088 vec_free (node_to_find);
19097 script (vat_main_t * vam)
19099 #if (VPP_API_TEST_BUILTIN==0)
19101 char *save_current_file;
19102 unformat_input_t save_input;
19103 jmp_buf save_jump_buf;
19104 u32 save_line_number;
19106 FILE *new_fp, *save_ifp;
19108 if (unformat (vam->input, "%s", &s))
19110 new_fp = fopen ((char *) s, "r");
19113 errmsg ("Couldn't open script file %s", s);
19120 errmsg ("Missing script name");
19124 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
19125 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
19126 save_ifp = vam->ifp;
19127 save_line_number = vam->input_line_number;
19128 save_current_file = (char *) vam->current_file;
19130 vam->input_line_number = 0;
19132 vam->current_file = s;
19135 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
19136 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
19137 vam->ifp = save_ifp;
19138 vam->input_line_number = save_line_number;
19139 vam->current_file = (u8 *) save_current_file;
19144 clib_warning ("use the exec command...");
19150 echo (vat_main_t * vam)
19152 print (vam->ofp, "%v", vam->input->buffer);
19156 /* List of API message constructors, CLI names map to api_xxx */
19157 #define foreach_vpe_api_msg \
19158 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
19159 _(sw_interface_dump,"") \
19160 _(sw_interface_set_flags, \
19161 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
19162 _(sw_interface_add_del_address, \
19163 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
19164 _(sw_interface_set_table, \
19165 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
19166 _(sw_interface_set_mpls_enable, \
19167 "<intfc> | sw_if_index [disable | dis]") \
19168 _(sw_interface_set_vpath, \
19169 "<intfc> | sw_if_index <id> enable | disable") \
19170 _(sw_interface_set_vxlan_bypass, \
19171 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
19172 _(sw_interface_set_l2_xconnect, \
19173 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
19174 "enable | disable") \
19175 _(sw_interface_set_l2_bridge, \
19176 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
19177 "[shg <split-horizon-group>] [bvi]\n" \
19178 "enable | disable") \
19179 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
19180 _(bridge_domain_add_del, \
19181 "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") \
19182 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
19184 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
19185 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
19186 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
19188 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
19190 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
19192 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
19194 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
19196 "<vpp-if-name> | sw_if_index <id>") \
19197 _(sw_interface_tap_dump, "") \
19198 _(ip_add_del_route, \
19199 "<addr>/<mask> via <addr> [table-id <n>]\n" \
19200 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
19201 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
19202 "[multipath] [count <n>]") \
19203 _(ip_mroute_add_del, \
19204 "<src> <grp>/<mask> [table-id <n>]\n" \
19205 "[<intfc> | sw_if_index <id>] [local] [del]") \
19206 _(mpls_route_add_del, \
19207 "<label> <eos> via <addr> [table-id <n>]\n" \
19208 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
19209 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
19210 "[multipath] [count <n>]") \
19211 _(mpls_ip_bind_unbind, \
19212 "<label> <addr/len>") \
19213 _(mpls_tunnel_add_del, \
19214 " via <addr> [table-id <n>]\n" \
19215 "sw_if_index <id>] [l2] [del]") \
19216 _(proxy_arp_add_del, \
19217 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
19218 _(proxy_arp_intfc_enable_disable, \
19219 "<intfc> | sw_if_index <id> enable | disable") \
19220 _(sw_interface_set_unnumbered, \
19221 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
19222 _(ip_neighbor_add_del, \
19223 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
19224 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
19225 _(reset_vrf, "vrf <id> [ipv6]") \
19226 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
19227 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
19228 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
19229 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
19230 "[outer_vlan_id_any][inner_vlan_id_any]") \
19231 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
19232 _(reset_fib, "vrf <n> [ipv6]") \
19233 _(dhcp_proxy_config, \
19234 "svr <v46-address> src <v46-address>\n" \
19235 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
19236 _(dhcp_proxy_set_vss, \
19237 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
19238 _(dhcp_proxy_dump, "ip6") \
19239 _(dhcp_client_config, \
19240 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
19241 _(set_ip_flow_hash, \
19242 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
19243 _(sw_interface_ip6_enable_disable, \
19244 "<intfc> | sw_if_index <id> enable | disable") \
19245 _(sw_interface_ip6_set_link_local_address, \
19246 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
19247 _(ip6nd_proxy_add_del, \
19248 "<intfc> | sw_if_index <id> <ip6-address>") \
19249 _(ip6nd_proxy_dump, "") \
19250 _(sw_interface_ip6nd_ra_prefix, \
19251 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
19252 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
19253 "[nolink] [isno]") \
19254 _(sw_interface_ip6nd_ra_config, \
19255 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
19256 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
19257 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
19258 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
19259 _(l2_patch_add_del, \
19260 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
19261 "enable | disable") \
19262 _(sr_localsid_add_del, \
19263 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
19264 "fib-table <num> (end.psp) sw_if_index <num>") \
19265 _(classify_add_del_table, \
19266 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
19267 " [del] [del-chain] mask <mask-value>\n" \
19268 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
19269 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
19270 _(classify_add_del_session, \
19271 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
19272 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
19273 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
19274 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
19275 _(classify_set_interface_ip_table, \
19276 "<intfc> | sw_if_index <nn> table <nn>") \
19277 _(classify_set_interface_l2_tables, \
19278 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19279 " [other-table <nn>]") \
19280 _(get_node_index, "node <node-name") \
19281 _(add_node_next, "node <node-name> next <next-node-name>") \
19282 _(l2tpv3_create_tunnel, \
19283 "client_address <ip6-addr> our_address <ip6-addr>\n" \
19284 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
19285 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
19286 _(l2tpv3_set_tunnel_cookies, \
19287 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
19288 "[new_remote_cookie <nn>]\n") \
19289 _(l2tpv3_interface_enable_disable, \
19290 "<intfc> | sw_if_index <nn> enable | disable") \
19291 _(l2tpv3_set_lookup_key, \
19292 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
19293 _(sw_if_l2tpv3_tunnel_dump, "") \
19294 _(vxlan_add_del_tunnel, \
19295 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
19296 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
19297 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
19298 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19299 _(gre_add_del_tunnel, \
19300 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
19301 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19302 _(l2_fib_clear_table, "") \
19303 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
19304 _(l2_interface_vlan_tag_rewrite, \
19305 "<intfc> | sw_if_index <nn> \n" \
19306 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
19307 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
19308 _(create_vhost_user_if, \
19309 "socket <filename> [server] [renumber <dev_instance>] " \
19310 "[mac <mac_address>]") \
19311 _(modify_vhost_user_if, \
19312 "<intfc> | sw_if_index <nn> socket <filename>\n" \
19313 "[server] [renumber <dev_instance>]") \
19314 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
19315 _(sw_interface_vhost_user_dump, "") \
19316 _(show_version, "") \
19317 _(vxlan_gpe_add_del_tunnel, \
19318 "local <addr> remote <addr> vni <nn>\n" \
19319 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
19320 "[next-ethernet] [next-nsh]\n") \
19321 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19322 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
19323 _(interface_name_renumber, \
19324 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
19325 _(input_acl_set_interface, \
19326 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19327 " [l2-table <nn>] [del]") \
19328 _(want_ip4_arp_events, "address <ip4-address> [del]") \
19329 _(want_ip6_nd_events, "address <ip6-address> [del]") \
19330 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
19331 _(ip_dump, "ipv4 | ipv6") \
19332 _(ipsec_spd_add_del, "spd_id <n> [del]") \
19333 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
19335 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
19336 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
19337 " integ_alg <alg> integ_key <hex>") \
19338 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
19339 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
19340 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
19341 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
19342 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
19343 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
19344 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
19345 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
19346 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
19347 _(ikev2_profile_add_del, "name <profile_name> [del]") \
19348 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
19349 "(auth_data 0x<data> | auth_data <data>)") \
19350 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
19351 "(id_data 0x<data> | id_data <data>) (local|remote)") \
19352 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
19353 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
19354 "(local|remote)") \
19355 _(ikev2_set_local_key, "file <absolute_file_path>") \
19356 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
19357 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
19358 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
19359 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
19360 _(ikev2_initiate_sa_init, "<profile_name>") \
19361 _(ikev2_initiate_del_ike_sa, "<ispi>") \
19362 _(ikev2_initiate_del_child_sa, "<ispi>") \
19363 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
19364 _(delete_loopback,"sw_if_index <nn>") \
19365 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
19366 _(map_add_domain, \
19367 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
19368 "ip6-src <ip6addr> " \
19369 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
19370 _(map_del_domain, "index <n>") \
19371 _(map_add_del_rule, \
19372 "index <n> psid <n> dst <ip6addr> [del]") \
19373 _(map_domain_dump, "") \
19374 _(map_rule_dump, "index <map-domain>") \
19375 _(want_interface_events, "enable|disable") \
19376 _(want_stats,"enable|disable") \
19377 _(get_first_msg_id, "client <name>") \
19378 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
19379 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
19380 "fib-id <nn> [ip4][ip6][default]") \
19381 _(get_node_graph, " ") \
19382 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
19383 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
19384 _(ioam_disable, "") \
19385 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
19386 " sw_if_index <sw_if_index> p <priority> " \
19387 "w <weight>] [del]") \
19388 _(one_add_del_locator, "locator-set <locator_name> " \
19389 "iface <intf> | sw_if_index <sw_if_index> " \
19390 "p <priority> w <weight> [del]") \
19391 _(one_add_del_local_eid,"vni <vni> eid " \
19392 "<ipv4|ipv6>/<prefix> | <L2 address> " \
19393 "locator-set <locator_name> [del]" \
19394 "[key-id sha1|sha256 secret-key <secret-key>]")\
19395 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
19396 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
19397 _(one_enable_disable, "enable|disable") \
19398 _(one_map_register_enable_disable, "enable|disable") \
19399 _(one_rloc_probe_enable_disable, "enable|disable") \
19400 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
19402 "rloc <locator> p <prio> " \
19403 "w <weight> [rloc <loc> ... ] " \
19404 "action <action> [del-all]") \
19405 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
19407 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
19408 _(one_use_petr, "ip-address> | disable") \
19409 _(one_map_request_mode, "src-dst|dst-only") \
19410 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
19411 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
19412 _(one_locator_set_dump, "[local | remote]") \
19413 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
19414 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
19415 "[local] | [remote]") \
19416 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
19417 _(one_l2_arp_bd_get, "") \
19418 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
19419 _(one_stats_enable_disable, "enable|disalbe") \
19420 _(show_one_stats_enable_disable, "") \
19421 _(one_eid_table_vni_dump, "") \
19422 _(one_eid_table_map_dump, "l2|l3") \
19423 _(one_map_resolver_dump, "") \
19424 _(one_map_server_dump, "") \
19425 _(one_adjacencies_get, "vni <vni>") \
19426 _(show_one_rloc_probe_state, "") \
19427 _(show_one_map_register_state, "") \
19428 _(show_one_status, "") \
19429 _(one_stats_dump, "") \
19430 _(one_stats_flush, "") \
19431 _(one_get_map_request_itr_rlocs, "") \
19432 _(show_one_pitr, "") \
19433 _(show_one_use_petr, "") \
19434 _(show_one_map_request_mode, "") \
19435 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
19436 " sw_if_index <sw_if_index> p <priority> " \
19437 "w <weight>] [del]") \
19438 _(lisp_add_del_locator, "locator-set <locator_name> " \
19439 "iface <intf> | sw_if_index <sw_if_index> " \
19440 "p <priority> w <weight> [del]") \
19441 _(lisp_add_del_local_eid,"vni <vni> eid " \
19442 "<ipv4|ipv6>/<prefix> | <L2 address> " \
19443 "locator-set <locator_name> [del]" \
19444 "[key-id sha1|sha256 secret-key <secret-key>]") \
19445 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
19446 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
19447 _(lisp_enable_disable, "enable|disable") \
19448 _(lisp_map_register_enable_disable, "enable|disable") \
19449 _(lisp_rloc_probe_enable_disable, "enable|disable") \
19450 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
19452 "rloc <locator> p <prio> " \
19453 "w <weight> [rloc <loc> ... ] " \
19454 "action <action> [del-all]") \
19455 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
19457 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
19458 _(lisp_use_petr, "<ip-address> | disable") \
19459 _(lisp_map_request_mode, "src-dst|dst-only") \
19460 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
19461 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
19462 _(lisp_locator_set_dump, "[local | remote]") \
19463 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
19464 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
19465 "[local] | [remote]") \
19466 _(lisp_eid_table_vni_dump, "") \
19467 _(lisp_eid_table_map_dump, "l2|l3") \
19468 _(lisp_map_resolver_dump, "") \
19469 _(lisp_map_server_dump, "") \
19470 _(lisp_adjacencies_get, "vni <vni>") \
19471 _(gpe_fwd_entry_vnis_get, "") \
19472 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
19473 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
19474 _(gpe_set_encap_mode, "lisp|vxlan") \
19475 _(gpe_get_encap_mode, "") \
19476 _(lisp_gpe_add_del_iface, "up|down") \
19477 _(lisp_gpe_enable_disable, "enable|disable") \
19478 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
19479 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
19480 _(show_lisp_rloc_probe_state, "") \
19481 _(show_lisp_map_register_state, "") \
19482 _(show_lisp_status, "") \
19483 _(lisp_get_map_request_itr_rlocs, "") \
19484 _(show_lisp_pitr, "") \
19485 _(show_lisp_use_petr, "") \
19486 _(show_lisp_map_request_mode, "") \
19487 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
19488 _(af_packet_delete, "name <host interface name>") \
19489 _(policer_add_del, "name <policer name> <params> [del]") \
19490 _(policer_dump, "[name <policer name>]") \
19491 _(policer_classify_set_interface, \
19492 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19493 " [l2-table <nn>] [del]") \
19494 _(policer_classify_dump, "type [ip4|ip6|l2]") \
19495 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
19496 "[master|slave]") \
19497 _(netmap_delete, "name <interface name>") \
19498 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
19499 _(mpls_fib_dump, "") \
19500 _(classify_table_ids, "") \
19501 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
19502 _(classify_table_info, "table_id <nn>") \
19503 _(classify_session_dump, "table_id <nn>") \
19504 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
19505 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
19506 "[template_interval <nn>] [udp_checksum]") \
19507 _(ipfix_exporter_dump, "") \
19508 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
19509 _(ipfix_classify_stream_dump, "") \
19510 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
19511 _(ipfix_classify_table_dump, "") \
19512 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
19513 _(sw_interface_span_dump, "") \
19514 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
19515 _(pg_create_interface, "if_id <nn>") \
19516 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
19517 _(pg_enable_disable, "[stream <id>] disable") \
19518 _(ip_source_and_port_range_check_add_del, \
19519 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
19520 _(ip_source_and_port_range_check_interface_add_del, \
19521 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
19522 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
19523 _(ipsec_gre_add_del_tunnel, \
19524 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
19525 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
19526 _(delete_subif,"<intfc> | sw_if_index <nn>") \
19527 _(l2_interface_pbb_tag_rewrite, \
19528 "<intfc> | sw_if_index <nn> \n" \
19529 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
19530 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
19531 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
19532 _(flow_classify_set_interface, \
19533 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
19534 _(flow_classify_dump, "type [ip4|ip6]") \
19535 _(ip_fib_dump, "") \
19536 _(ip_mfib_dump, "") \
19537 _(ip6_fib_dump, "") \
19538 _(ip6_mfib_dump, "") \
19539 _(feature_enable_disable, "arc_name <arc_name> " \
19540 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
19541 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
19543 _(l2_xconnect_dump, "") \
19544 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
19545 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
19546 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
19547 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
19548 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>")
19550 /* List of command functions, CLI names map directly to functions */
19551 #define foreach_cli_function \
19552 _(comment, "usage: comment <ignore-rest-of-line>") \
19553 _(dump_interface_table, "usage: dump_interface_table") \
19554 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
19555 _(dump_ipv4_table, "usage: dump_ipv4_table") \
19556 _(dump_ipv6_table, "usage: dump_ipv6_table") \
19557 _(dump_stats_table, "usage: dump_stats_table") \
19558 _(dump_macro_table, "usage: dump_macro_table ") \
19559 _(dump_node_table, "usage: dump_node_table") \
19560 _(dump_msg_api_table, "usage: dump_msg_api_table") \
19561 _(get_msg_id, "usage: get_msg_id name_and_crc") \
19562 _(echo, "usage: echo <message>") \
19563 _(exec, "usage: exec <vpe-debug-CLI-command>") \
19564 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
19565 _(help, "usage: help") \
19566 _(q, "usage: quit") \
19567 _(quit, "usage: quit") \
19568 _(search_node_table, "usage: search_node_table <name>...") \
19569 _(set, "usage: set <variable-name> <value>") \
19570 _(script, "usage: script <file-name>") \
19571 _(unset, "usage: unset <variable-name>")
19574 static void vl_api_##n##_t_handler_uni \
19575 (vl_api_##n##_t * mp) \
19577 vat_main_t * vam = &vat_main; \
19578 if (vam->json_output) { \
19579 vl_api_##n##_t_handler_json(mp); \
19581 vl_api_##n##_t_handler(mp); \
19584 foreach_vpe_api_reply_msg;
19585 #if VPP_API_TEST_BUILTIN == 0
19586 foreach_standalone_reply_msg;
19591 vat_api_hookup (vat_main_t * vam)
19594 vl_msg_api_set_handlers(VL_API_##N, #n, \
19595 vl_api_##n##_t_handler_uni, \
19597 vl_api_##n##_t_endian, \
19598 vl_api_##n##_t_print, \
19599 sizeof(vl_api_##n##_t), 1);
19600 foreach_vpe_api_reply_msg;
19601 #if VPP_API_TEST_BUILTIN == 0
19602 foreach_standalone_reply_msg;
19606 #if (VPP_API_TEST_BUILTIN==0)
19607 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
19609 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
19611 vam->function_by_name = hash_create_string (0, sizeof (uword));
19613 vam->help_by_name = hash_create_string (0, sizeof (uword));
19616 /* API messages we can send */
19617 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
19618 foreach_vpe_api_msg;
19622 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
19623 foreach_vpe_api_msg;
19626 /* CLI functions */
19627 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
19628 foreach_cli_function;
19632 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
19633 foreach_cli_function;
19637 #if VPP_API_TEST_BUILTIN
19638 static clib_error_t *
19639 vat_api_hookup_shim (vlib_main_t * vm)
19641 vat_api_hookup (&vat_main);
19645 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
19649 * fd.io coding-style-patch-verification: ON
19652 * eval: (c-set-style "gnu")