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 */
1287 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1289 u32 n_macs = ntohl (mp->n_macs);
1290 errmsg ("L2MAC event recived with pid %d cl-idx %d for %d macs: \n",
1291 ntohl (mp->pid), mp->client_index, n_macs);
1293 for (i = 0; i < n_macs; i++)
1295 vl_api_mac_entry_t *mac = &mp->mac[i];
1296 errmsg (" [%d] sw_if_index %d mac_addr %U is_del %d \n",
1297 i + 1, ntohl (mac->sw_if_index),
1298 format_ethernet_address, mac->mac_addr, mac->is_del);
1305 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1307 /* JSON output not supported */
1310 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1311 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1314 * Special-case: build the bridge domain table, maintain
1315 * the next bd id vbl.
1317 static void vl_api_bridge_domain_details_t_handler
1318 (vl_api_bridge_domain_details_t * mp)
1320 vat_main_t *vam = &vat_main;
1321 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1324 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1325 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1327 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1328 ntohl (mp->bd_id), mp->learn, mp->forward,
1329 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1333 vl_api_bridge_domain_sw_if_t *sw_ifs;
1334 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1337 sw_ifs = mp->sw_if_details;
1338 for (i = 0; i < n_sw_ifs; i++)
1344 sw_if_index = ntohl (sw_ifs->sw_if_index);
1347 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1349 if ((u32) p->value[0] == sw_if_index)
1351 sw_if_name = (u8 *)(p->key);
1356 print (vam->ofp, "%7d %3d %s", sw_if_index,
1357 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1358 "sw_if_index not found!");
1365 static void vl_api_bridge_domain_details_t_handler_json
1366 (vl_api_bridge_domain_details_t * mp)
1368 vat_main_t *vam = &vat_main;
1369 vat_json_node_t *node, *array = NULL;
1370 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1372 if (VAT_JSON_ARRAY != vam->json_tree.type)
1374 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1375 vat_json_init_array (&vam->json_tree);
1377 node = vat_json_array_add (&vam->json_tree);
1379 vat_json_init_object (node);
1380 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1381 vat_json_object_add_uint (node, "flood", mp->flood);
1382 vat_json_object_add_uint (node, "forward", mp->forward);
1383 vat_json_object_add_uint (node, "learn", mp->learn);
1384 vat_json_object_add_uint (node, "bvi_sw_if_index",
1385 ntohl (mp->bvi_sw_if_index));
1386 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1387 array = vat_json_object_add (node, "sw_if");
1388 vat_json_init_array (array);
1394 vl_api_bridge_domain_sw_if_t *sw_ifs;
1397 sw_ifs = mp->sw_if_details;
1398 for (i = 0; i < n_sw_ifs; i++)
1400 node = vat_json_array_add (array);
1401 vat_json_init_object (node);
1402 vat_json_object_add_uint (node, "sw_if_index",
1403 ntohl (sw_ifs->sw_if_index));
1404 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1410 static void vl_api_control_ping_reply_t_handler
1411 (vl_api_control_ping_reply_t * mp)
1413 vat_main_t *vam = &vat_main;
1414 i32 retval = ntohl (mp->retval);
1415 if (vam->async_mode)
1417 vam->async_errors += (retval < 0);
1421 vam->retval = retval;
1422 vam->result_ready = 1;
1426 static void vl_api_control_ping_reply_t_handler_json
1427 (vl_api_control_ping_reply_t * mp)
1429 vat_main_t *vam = &vat_main;
1430 i32 retval = ntohl (mp->retval);
1432 if (VAT_JSON_NONE != vam->json_tree.type)
1434 vat_json_print (vam->ofp, &vam->json_tree);
1435 vat_json_free (&vam->json_tree);
1436 vam->json_tree.type = VAT_JSON_NONE;
1441 vat_json_init_array (&vam->json_tree);
1442 vat_json_print (vam->ofp, &vam->json_tree);
1443 vam->json_tree.type = VAT_JSON_NONE;
1446 vam->retval = retval;
1447 vam->result_ready = 1;
1451 vl_api_bridge_domain_set_mac_age_reply_t_handler
1452 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1454 vat_main_t *vam = &vat_main;
1455 i32 retval = ntohl (mp->retval);
1456 if (vam->async_mode)
1458 vam->async_errors += (retval < 0);
1462 vam->retval = retval;
1463 vam->result_ready = 1;
1467 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1468 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1470 vat_main_t *vam = &vat_main;
1471 vat_json_node_t node;
1473 vat_json_init_object (&node);
1474 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1476 vat_json_print (vam->ofp, &node);
1477 vat_json_free (&node);
1479 vam->retval = ntohl (mp->retval);
1480 vam->result_ready = 1;
1484 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1486 vat_main_t *vam = &vat_main;
1487 i32 retval = ntohl (mp->retval);
1488 if (vam->async_mode)
1490 vam->async_errors += (retval < 0);
1494 vam->retval = retval;
1495 vam->result_ready = 1;
1499 static void vl_api_l2_flags_reply_t_handler_json
1500 (vl_api_l2_flags_reply_t * mp)
1502 vat_main_t *vam = &vat_main;
1503 vat_json_node_t node;
1505 vat_json_init_object (&node);
1506 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1507 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1508 ntohl (mp->resulting_feature_bitmap));
1510 vat_json_print (vam->ofp, &node);
1511 vat_json_free (&node);
1513 vam->retval = ntohl (mp->retval);
1514 vam->result_ready = 1;
1517 static void vl_api_bridge_flags_reply_t_handler
1518 (vl_api_bridge_flags_reply_t * mp)
1520 vat_main_t *vam = &vat_main;
1521 i32 retval = ntohl (mp->retval);
1522 if (vam->async_mode)
1524 vam->async_errors += (retval < 0);
1528 vam->retval = retval;
1529 vam->result_ready = 1;
1533 static void vl_api_bridge_flags_reply_t_handler_json
1534 (vl_api_bridge_flags_reply_t * mp)
1536 vat_main_t *vam = &vat_main;
1537 vat_json_node_t node;
1539 vat_json_init_object (&node);
1540 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1541 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1542 ntohl (mp->resulting_feature_bitmap));
1544 vat_json_print (vam->ofp, &node);
1545 vat_json_free (&node);
1547 vam->retval = ntohl (mp->retval);
1548 vam->result_ready = 1;
1551 static void vl_api_tap_connect_reply_t_handler
1552 (vl_api_tap_connect_reply_t * mp)
1554 vat_main_t *vam = &vat_main;
1555 i32 retval = ntohl (mp->retval);
1556 if (vam->async_mode)
1558 vam->async_errors += (retval < 0);
1562 vam->retval = retval;
1563 vam->sw_if_index = ntohl (mp->sw_if_index);
1564 vam->result_ready = 1;
1569 static void vl_api_tap_connect_reply_t_handler_json
1570 (vl_api_tap_connect_reply_t * mp)
1572 vat_main_t *vam = &vat_main;
1573 vat_json_node_t node;
1575 vat_json_init_object (&node);
1576 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1577 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1579 vat_json_print (vam->ofp, &node);
1580 vat_json_free (&node);
1582 vam->retval = ntohl (mp->retval);
1583 vam->result_ready = 1;
1588 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1590 vat_main_t *vam = &vat_main;
1591 i32 retval = ntohl (mp->retval);
1592 if (vam->async_mode)
1594 vam->async_errors += (retval < 0);
1598 vam->retval = retval;
1599 vam->sw_if_index = ntohl (mp->sw_if_index);
1600 vam->result_ready = 1;
1604 static void vl_api_tap_modify_reply_t_handler_json
1605 (vl_api_tap_modify_reply_t * mp)
1607 vat_main_t *vam = &vat_main;
1608 vat_json_node_t node;
1610 vat_json_init_object (&node);
1611 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1612 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1614 vat_json_print (vam->ofp, &node);
1615 vat_json_free (&node);
1617 vam->retval = ntohl (mp->retval);
1618 vam->result_ready = 1;
1622 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1624 vat_main_t *vam = &vat_main;
1625 i32 retval = ntohl (mp->retval);
1626 if (vam->async_mode)
1628 vam->async_errors += (retval < 0);
1632 vam->retval = retval;
1633 vam->result_ready = 1;
1637 static void vl_api_tap_delete_reply_t_handler_json
1638 (vl_api_tap_delete_reply_t * mp)
1640 vat_main_t *vam = &vat_main;
1641 vat_json_node_t node;
1643 vat_json_init_object (&node);
1644 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1646 vat_json_print (vam->ofp, &node);
1647 vat_json_free (&node);
1649 vam->retval = ntohl (mp->retval);
1650 vam->result_ready = 1;
1653 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1654 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1656 vat_main_t *vam = &vat_main;
1657 i32 retval = ntohl (mp->retval);
1658 if (vam->async_mode)
1660 vam->async_errors += (retval < 0);
1664 vam->retval = retval;
1665 vam->result_ready = 1;
1669 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1670 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1672 vat_main_t *vam = &vat_main;
1673 vat_json_node_t node;
1675 vat_json_init_object (&node);
1676 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1677 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1678 ntohl (mp->sw_if_index));
1680 vat_json_print (vam->ofp, &node);
1681 vat_json_free (&node);
1683 vam->retval = ntohl (mp->retval);
1684 vam->result_ready = 1;
1687 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1688 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1690 vat_main_t *vam = &vat_main;
1691 i32 retval = ntohl (mp->retval);
1692 if (vam->async_mode)
1694 vam->async_errors += (retval < 0);
1698 vam->retval = retval;
1699 vam->sw_if_index = ntohl (mp->sw_if_index);
1700 vam->result_ready = 1;
1704 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1705 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1707 vat_main_t *vam = &vat_main;
1708 vat_json_node_t node;
1710 vat_json_init_object (&node);
1711 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1712 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1714 vat_json_print (vam->ofp, &node);
1715 vat_json_free (&node);
1717 vam->retval = ntohl (mp->retval);
1718 vam->result_ready = 1;
1721 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
1722 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1724 vat_main_t *vam = &vat_main;
1725 i32 retval = ntohl (mp->retval);
1726 if (vam->async_mode)
1728 vam->async_errors += (retval < 0);
1732 vam->retval = retval;
1733 vam->result_ready = 1;
1737 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
1738 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1740 vat_main_t *vam = &vat_main;
1741 vat_json_node_t node;
1743 vat_json_init_object (&node);
1744 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1745 vat_json_object_add_uint (&node, "fwd_entry_index",
1746 clib_net_to_host_u32 (mp->fwd_entry_index));
1748 vat_json_print (vam->ofp, &node);
1749 vat_json_free (&node);
1751 vam->retval = ntohl (mp->retval);
1752 vam->result_ready = 1;
1755 static void vl_api_one_add_del_locator_set_reply_t_handler
1756 (vl_api_one_add_del_locator_set_reply_t * mp)
1758 vat_main_t *vam = &vat_main;
1759 i32 retval = ntohl (mp->retval);
1760 if (vam->async_mode)
1762 vam->async_errors += (retval < 0);
1766 vam->retval = retval;
1767 vam->result_ready = 1;
1771 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1772 (vl_api_one_add_del_locator_set_reply_t * mp)
1774 vat_main_t *vam = &vat_main;
1775 vat_json_node_t node;
1777 vat_json_init_object (&node);
1778 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1779 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1781 vat_json_print (vam->ofp, &node);
1782 vat_json_free (&node);
1784 vam->retval = ntohl (mp->retval);
1785 vam->result_ready = 1;
1788 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1789 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1791 vat_main_t *vam = &vat_main;
1792 i32 retval = ntohl (mp->retval);
1793 if (vam->async_mode)
1795 vam->async_errors += (retval < 0);
1799 vam->retval = retval;
1800 vam->sw_if_index = ntohl (mp->sw_if_index);
1801 vam->result_ready = 1;
1805 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1806 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1808 vat_main_t *vam = &vat_main;
1809 vat_json_node_t node;
1811 vat_json_init_object (&node);
1812 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1813 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1815 vat_json_print (vam->ofp, &node);
1816 vat_json_free (&node);
1818 vam->retval = ntohl (mp->retval);
1819 vam->result_ready = 1;
1822 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
1823 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1825 vat_main_t *vam = &vat_main;
1826 i32 retval = ntohl (mp->retval);
1827 if (vam->async_mode)
1829 vam->async_errors += (retval < 0);
1833 vam->retval = retval;
1834 vam->sw_if_index = ntohl (mp->sw_if_index);
1835 vam->result_ready = 1;
1839 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
1840 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1842 vat_main_t *vam = &vat_main;
1843 vat_json_node_t node;
1845 vat_json_init_object (&node);
1846 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1847 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1849 vat_json_print (vam->ofp, &node);
1850 vat_json_free (&node);
1852 vam->retval = ntohl (mp->retval);
1853 vam->result_ready = 1;
1856 static void vl_api_gre_add_del_tunnel_reply_t_handler
1857 (vl_api_gre_add_del_tunnel_reply_t * mp)
1859 vat_main_t *vam = &vat_main;
1860 i32 retval = ntohl (mp->retval);
1861 if (vam->async_mode)
1863 vam->async_errors += (retval < 0);
1867 vam->retval = retval;
1868 vam->sw_if_index = ntohl (mp->sw_if_index);
1869 vam->result_ready = 1;
1873 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1874 (vl_api_gre_add_del_tunnel_reply_t * mp)
1876 vat_main_t *vam = &vat_main;
1877 vat_json_node_t node;
1879 vat_json_init_object (&node);
1880 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1881 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1883 vat_json_print (vam->ofp, &node);
1884 vat_json_free (&node);
1886 vam->retval = ntohl (mp->retval);
1887 vam->result_ready = 1;
1890 static void vl_api_create_vhost_user_if_reply_t_handler
1891 (vl_api_create_vhost_user_if_reply_t * mp)
1893 vat_main_t *vam = &vat_main;
1894 i32 retval = ntohl (mp->retval);
1895 if (vam->async_mode)
1897 vam->async_errors += (retval < 0);
1901 vam->retval = retval;
1902 vam->sw_if_index = ntohl (mp->sw_if_index);
1903 vam->result_ready = 1;
1907 static void vl_api_create_vhost_user_if_reply_t_handler_json
1908 (vl_api_create_vhost_user_if_reply_t * mp)
1910 vat_main_t *vam = &vat_main;
1911 vat_json_node_t node;
1913 vat_json_init_object (&node);
1914 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1915 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1917 vat_json_print (vam->ofp, &node);
1918 vat_json_free (&node);
1920 vam->retval = ntohl (mp->retval);
1921 vam->result_ready = 1;
1924 static void vl_api_ip_address_details_t_handler
1925 (vl_api_ip_address_details_t * mp)
1927 vat_main_t *vam = &vat_main;
1928 static ip_address_details_t empty_ip_address_details = { {0} };
1929 ip_address_details_t *address = NULL;
1930 ip_details_t *current_ip_details = NULL;
1931 ip_details_t *details = NULL;
1933 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1935 if (!details || vam->current_sw_if_index >= vec_len (details)
1936 || !details[vam->current_sw_if_index].present)
1938 errmsg ("ip address details arrived but not stored");
1939 errmsg ("ip_dump should be called first");
1943 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1945 #define addresses (current_ip_details->addr)
1947 vec_validate_init_empty (addresses, vec_len (addresses),
1948 empty_ip_address_details);
1950 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1952 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1953 address->prefix_length = mp->prefix_length;
1957 static void vl_api_ip_address_details_t_handler_json
1958 (vl_api_ip_address_details_t * mp)
1960 vat_main_t *vam = &vat_main;
1961 vat_json_node_t *node = NULL;
1962 struct in6_addr ip6;
1965 if (VAT_JSON_ARRAY != vam->json_tree.type)
1967 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1968 vat_json_init_array (&vam->json_tree);
1970 node = vat_json_array_add (&vam->json_tree);
1972 vat_json_init_object (node);
1975 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1976 vat_json_object_add_ip6 (node, "ip", ip6);
1980 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1981 vat_json_object_add_ip4 (node, "ip", ip4);
1983 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1987 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1989 vat_main_t *vam = &vat_main;
1990 static ip_details_t empty_ip_details = { 0 };
1991 ip_details_t *ip = NULL;
1992 u32 sw_if_index = ~0;
1994 sw_if_index = ntohl (mp->sw_if_index);
1996 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1997 sw_if_index, empty_ip_details);
1999 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2006 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2008 vat_main_t *vam = &vat_main;
2010 if (VAT_JSON_ARRAY != vam->json_tree.type)
2012 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2013 vat_json_init_array (&vam->json_tree);
2015 vat_json_array_add_uint (&vam->json_tree,
2016 clib_net_to_host_u32 (mp->sw_if_index));
2019 static void vl_api_map_domain_details_t_handler_json
2020 (vl_api_map_domain_details_t * mp)
2022 vat_json_node_t *node = NULL;
2023 vat_main_t *vam = &vat_main;
2024 struct in6_addr ip6;
2027 if (VAT_JSON_ARRAY != vam->json_tree.type)
2029 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2030 vat_json_init_array (&vam->json_tree);
2033 node = vat_json_array_add (&vam->json_tree);
2034 vat_json_init_object (node);
2036 vat_json_object_add_uint (node, "domain_index",
2037 clib_net_to_host_u32 (mp->domain_index));
2038 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2039 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2040 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2041 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2042 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2043 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2044 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2045 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2046 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2047 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2048 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2049 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2050 vat_json_object_add_uint (node, "flags", mp->flags);
2051 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2052 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2055 static void vl_api_map_domain_details_t_handler
2056 (vl_api_map_domain_details_t * mp)
2058 vat_main_t *vam = &vat_main;
2060 if (mp->is_translation)
2063 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2064 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2065 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2066 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2067 clib_net_to_host_u32 (mp->domain_index));
2072 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2073 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2074 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2075 format_ip6_address, mp->ip6_src,
2076 clib_net_to_host_u32 (mp->domain_index));
2078 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2079 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2080 mp->is_translation ? "map-t" : "");
2083 static void vl_api_map_rule_details_t_handler_json
2084 (vl_api_map_rule_details_t * mp)
2086 struct in6_addr ip6;
2087 vat_json_node_t *node = NULL;
2088 vat_main_t *vam = &vat_main;
2090 if (VAT_JSON_ARRAY != vam->json_tree.type)
2092 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2093 vat_json_init_array (&vam->json_tree);
2096 node = vat_json_array_add (&vam->json_tree);
2097 vat_json_init_object (node);
2099 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2100 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2101 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2105 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2107 vat_main_t *vam = &vat_main;
2108 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2109 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2113 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2115 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2116 "router_addr %U host_mac %U",
2117 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2118 format_ip4_address, &mp->host_address,
2119 format_ip4_address, &mp->router_address,
2120 format_ethernet_address, mp->host_mac);
2123 static void vl_api_dhcp_compl_event_t_handler_json
2124 (vl_api_dhcp_compl_event_t * mp)
2126 /* JSON output not supported */
2130 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2133 vat_main_t *vam = &vat_main;
2134 static u64 default_counter = 0;
2136 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2138 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2139 sw_if_index, default_counter);
2140 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2144 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2145 interface_counter_t counter)
2147 vat_main_t *vam = &vat_main;
2148 static interface_counter_t default_counter = { 0, };
2150 vec_validate_init_empty (vam->combined_interface_counters,
2151 vnet_counter_type, NULL);
2152 vec_validate_init_empty (vam->combined_interface_counters
2153 [vnet_counter_type], sw_if_index, default_counter);
2154 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2157 static void vl_api_vnet_interface_simple_counters_t_handler
2158 (vl_api_vnet_interface_simple_counters_t * mp)
2163 static void vl_api_vnet_interface_combined_counters_t_handler
2164 (vl_api_vnet_interface_combined_counters_t * mp)
2169 static void vl_api_vnet_interface_simple_counters_t_handler_json
2170 (vl_api_vnet_interface_simple_counters_t * mp)
2175 u32 first_sw_if_index;
2178 count = ntohl (mp->count);
2179 first_sw_if_index = ntohl (mp->first_sw_if_index);
2181 v_packets = (u64 *) & mp->data;
2182 for (i = 0; i < count; i++)
2184 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2185 set_simple_interface_counter (mp->vnet_counter_type,
2186 first_sw_if_index + i, packets);
2191 static void vl_api_vnet_interface_combined_counters_t_handler_json
2192 (vl_api_vnet_interface_combined_counters_t * mp)
2194 interface_counter_t counter;
2196 u32 first_sw_if_index;
2200 count = ntohl (mp->count);
2201 first_sw_if_index = ntohl (mp->first_sw_if_index);
2203 v = (vlib_counter_t *) & mp->data;
2204 for (i = 0; i < count; i++)
2207 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2209 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2210 set_combined_interface_counter (mp->vnet_counter_type,
2211 first_sw_if_index + i, counter);
2217 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2219 vat_main_t *vam = &vat_main;
2222 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2224 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2233 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2235 vat_main_t *vam = &vat_main;
2238 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2240 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2248 static void vl_api_vnet_ip4_fib_counters_t_handler
2249 (vl_api_vnet_ip4_fib_counters_t * mp)
2254 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2255 (vl_api_vnet_ip4_fib_counters_t * mp)
2257 vat_main_t *vam = &vat_main;
2258 vl_api_ip4_fib_counter_t *v;
2259 ip4_fib_counter_t *counter;
2266 vrf_id = ntohl (mp->vrf_id);
2267 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2268 if (~0 == vrf_index)
2270 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2271 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2272 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2273 vec_validate (vam->ip4_fib_counters, vrf_index);
2274 vam->ip4_fib_counters[vrf_index] = NULL;
2277 vec_free (vam->ip4_fib_counters[vrf_index]);
2278 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2279 count = ntohl (mp->count);
2280 for (i = 0; i < count; i++)
2282 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2283 counter = &vam->ip4_fib_counters[vrf_index][i];
2284 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2285 counter->address = ip4;
2286 counter->address_length = v->address_length;
2287 counter->packets = clib_net_to_host_u64 (v->packets);
2288 counter->bytes = clib_net_to_host_u64 (v->bytes);
2293 static void vl_api_vnet_ip4_nbr_counters_t_handler
2294 (vl_api_vnet_ip4_nbr_counters_t * mp)
2299 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2300 (vl_api_vnet_ip4_nbr_counters_t * mp)
2302 vat_main_t *vam = &vat_main;
2303 vl_api_ip4_nbr_counter_t *v;
2304 ip4_nbr_counter_t *counter;
2309 sw_if_index = ntohl (mp->sw_if_index);
2310 count = ntohl (mp->count);
2311 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2314 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2316 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2317 for (i = 0; i < count; i++)
2319 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2320 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2321 counter->address.s_addr = v->address;
2322 counter->packets = clib_net_to_host_u64 (v->packets);
2323 counter->bytes = clib_net_to_host_u64 (v->bytes);
2324 counter->linkt = v->link_type;
2329 static void vl_api_vnet_ip6_fib_counters_t_handler
2330 (vl_api_vnet_ip6_fib_counters_t * mp)
2335 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2336 (vl_api_vnet_ip6_fib_counters_t * mp)
2338 vat_main_t *vam = &vat_main;
2339 vl_api_ip6_fib_counter_t *v;
2340 ip6_fib_counter_t *counter;
2341 struct in6_addr ip6;
2347 vrf_id = ntohl (mp->vrf_id);
2348 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2349 if (~0 == vrf_index)
2351 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2352 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2353 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2354 vec_validate (vam->ip6_fib_counters, vrf_index);
2355 vam->ip6_fib_counters[vrf_index] = NULL;
2358 vec_free (vam->ip6_fib_counters[vrf_index]);
2359 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2360 count = ntohl (mp->count);
2361 for (i = 0; i < count; i++)
2363 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2364 counter = &vam->ip6_fib_counters[vrf_index][i];
2365 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2366 counter->address = ip6;
2367 counter->address_length = v->address_length;
2368 counter->packets = clib_net_to_host_u64 (v->packets);
2369 counter->bytes = clib_net_to_host_u64 (v->bytes);
2374 static void vl_api_vnet_ip6_nbr_counters_t_handler
2375 (vl_api_vnet_ip6_nbr_counters_t * mp)
2380 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2381 (vl_api_vnet_ip6_nbr_counters_t * mp)
2383 vat_main_t *vam = &vat_main;
2384 vl_api_ip6_nbr_counter_t *v;
2385 ip6_nbr_counter_t *counter;
2386 struct in6_addr ip6;
2391 sw_if_index = ntohl (mp->sw_if_index);
2392 count = ntohl (mp->count);
2393 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2396 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2398 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2399 for (i = 0; i < count; i++)
2401 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2402 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2403 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2404 counter->address = ip6;
2405 counter->packets = clib_net_to_host_u64 (v->packets);
2406 counter->bytes = clib_net_to_host_u64 (v->bytes);
2411 static void vl_api_get_first_msg_id_reply_t_handler
2412 (vl_api_get_first_msg_id_reply_t * mp)
2414 vat_main_t *vam = &vat_main;
2415 i32 retval = ntohl (mp->retval);
2417 if (vam->async_mode)
2419 vam->async_errors += (retval < 0);
2423 vam->retval = retval;
2424 vam->result_ready = 1;
2428 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2432 static void vl_api_get_first_msg_id_reply_t_handler_json
2433 (vl_api_get_first_msg_id_reply_t * mp)
2435 vat_main_t *vam = &vat_main;
2436 vat_json_node_t node;
2438 vat_json_init_object (&node);
2439 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2440 vat_json_object_add_uint (&node, "first_msg_id",
2441 (uint) ntohs (mp->first_msg_id));
2443 vat_json_print (vam->ofp, &node);
2444 vat_json_free (&node);
2446 vam->retval = ntohl (mp->retval);
2447 vam->result_ready = 1;
2450 static void vl_api_get_node_graph_reply_t_handler
2451 (vl_api_get_node_graph_reply_t * mp)
2453 vat_main_t *vam = &vat_main;
2454 api_main_t *am = &api_main;
2455 i32 retval = ntohl (mp->retval);
2456 u8 *pvt_copy, *reply;
2461 if (vam->async_mode)
2463 vam->async_errors += (retval < 0);
2467 vam->retval = retval;
2468 vam->result_ready = 1;
2471 /* "Should never happen..." */
2475 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2476 pvt_copy = vec_dup (reply);
2478 /* Toss the shared-memory original... */
2479 pthread_mutex_lock (&am->vlib_rp->mutex);
2480 oldheap = svm_push_data_heap (am->vlib_rp);
2484 svm_pop_heap (oldheap);
2485 pthread_mutex_unlock (&am->vlib_rp->mutex);
2487 if (vam->graph_nodes)
2489 hash_free (vam->graph_node_index_by_name);
2491 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2493 node = vam->graph_nodes[i];
2494 vec_free (node->name);
2495 vec_free (node->next_nodes);
2498 vec_free (vam->graph_nodes);
2501 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2502 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2503 vec_free (pvt_copy);
2505 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2507 node = vam->graph_nodes[i];
2508 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2512 static void vl_api_get_node_graph_reply_t_handler_json
2513 (vl_api_get_node_graph_reply_t * mp)
2515 vat_main_t *vam = &vat_main;
2516 api_main_t *am = &api_main;
2518 vat_json_node_t node;
2521 /* $$$$ make this real? */
2522 vat_json_init_object (&node);
2523 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2524 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2526 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2528 /* Toss the shared-memory original... */
2529 pthread_mutex_lock (&am->vlib_rp->mutex);
2530 oldheap = svm_push_data_heap (am->vlib_rp);
2534 svm_pop_heap (oldheap);
2535 pthread_mutex_unlock (&am->vlib_rp->mutex);
2537 vat_json_print (vam->ofp, &node);
2538 vat_json_free (&node);
2540 vam->retval = ntohl (mp->retval);
2541 vam->result_ready = 1;
2545 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2547 vat_main_t *vam = &vat_main;
2552 s = format (s, "%=16d%=16d%=16d",
2553 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2557 s = format (s, "%=16U%=16d%=16d",
2558 mp->is_ipv6 ? format_ip6_address :
2560 mp->ip_address, mp->priority, mp->weight);
2563 print (vam->ofp, "%v", s);
2568 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2570 vat_main_t *vam = &vat_main;
2571 vat_json_node_t *node = NULL;
2572 struct in6_addr ip6;
2575 if (VAT_JSON_ARRAY != vam->json_tree.type)
2577 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2578 vat_json_init_array (&vam->json_tree);
2580 node = vat_json_array_add (&vam->json_tree);
2581 vat_json_init_object (node);
2583 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2584 vat_json_object_add_uint (node, "priority", mp->priority);
2585 vat_json_object_add_uint (node, "weight", mp->weight);
2588 vat_json_object_add_uint (node, "sw_if_index",
2589 clib_net_to_host_u32 (mp->sw_if_index));
2594 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2595 vat_json_object_add_ip6 (node, "address", ip6);
2599 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2600 vat_json_object_add_ip4 (node, "address", ip4);
2606 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2609 vat_main_t *vam = &vat_main;
2612 ls_name = format (0, "%s", mp->ls_name);
2614 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2620 vl_api_one_locator_set_details_t_handler_json
2621 (vl_api_one_locator_set_details_t * mp)
2623 vat_main_t *vam = &vat_main;
2624 vat_json_node_t *node = 0;
2627 ls_name = format (0, "%s", mp->ls_name);
2628 vec_add1 (ls_name, 0);
2630 if (VAT_JSON_ARRAY != vam->json_tree.type)
2632 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2633 vat_json_init_array (&vam->json_tree);
2635 node = vat_json_array_add (&vam->json_tree);
2637 vat_json_init_object (node);
2638 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2639 vat_json_object_add_uint (node, "ls_index",
2640 clib_net_to_host_u32 (mp->ls_index));
2648 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2651 unformat_nsh_address (unformat_input_t * input, va_list * args)
2653 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2654 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2658 format_nsh_address_vat (u8 * s, va_list * args)
2660 nsh_t *a = va_arg (*args, nsh_t *);
2661 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2665 format_lisp_flat_eid (u8 * s, va_list * args)
2667 u32 type = va_arg (*args, u32);
2668 u8 *eid = va_arg (*args, u8 *);
2669 u32 eid_len = va_arg (*args, u32);
2674 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2676 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2678 return format (s, "%U", format_ethernet_address, eid);
2680 return format (s, "%U", format_nsh_address_vat, eid);
2686 format_lisp_eid_vat (u8 * s, va_list * args)
2688 u32 type = va_arg (*args, u32);
2689 u8 *eid = va_arg (*args, u8 *);
2690 u32 eid_len = va_arg (*args, u32);
2691 u8 *seid = va_arg (*args, u8 *);
2692 u32 seid_len = va_arg (*args, u32);
2693 u32 is_src_dst = va_arg (*args, u32);
2696 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2698 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2704 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2706 vat_main_t *vam = &vat_main;
2707 u8 *s = 0, *eid = 0;
2709 if (~0 == mp->locator_set_index)
2710 s = format (0, "action: %d", mp->action);
2712 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2714 eid = format (0, "%U", format_lisp_eid_vat,
2718 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2721 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2722 clib_net_to_host_u32 (mp->vni),
2724 mp->is_local ? "local" : "remote",
2725 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2726 clib_net_to_host_u16 (mp->key_id), mp->key);
2733 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2736 vat_main_t *vam = &vat_main;
2737 vat_json_node_t *node = 0;
2740 if (VAT_JSON_ARRAY != vam->json_tree.type)
2742 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2743 vat_json_init_array (&vam->json_tree);
2745 node = vat_json_array_add (&vam->json_tree);
2747 vat_json_init_object (node);
2748 if (~0 == mp->locator_set_index)
2749 vat_json_object_add_uint (node, "action", mp->action);
2751 vat_json_object_add_uint (node, "locator_set_index",
2752 clib_net_to_host_u32 (mp->locator_set_index));
2754 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2755 if (mp->eid_type == 3)
2757 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
2758 vat_json_init_object (nsh_json);
2759 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
2760 vat_json_object_add_uint (nsh_json, "spi",
2761 clib_net_to_host_u32 (nsh->spi));
2762 vat_json_object_add_uint (nsh_json, "si", nsh->si);
2766 eid = format (0, "%U", format_lisp_eid_vat,
2770 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2772 vat_json_object_add_string_copy (node, "eid", eid);
2775 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2776 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2777 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2781 vat_json_object_add_uint (node, "key_id",
2782 clib_net_to_host_u16 (mp->key_id));
2783 vat_json_object_add_string_copy (node, "key", mp->key);
2788 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
2790 vat_main_t *vam = &vat_main;
2791 u8 *seid = 0, *deid = 0;
2792 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2794 deid = format (0, "%U", format_lisp_eid_vat,
2795 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2797 seid = format (0, "%U", format_lisp_eid_vat,
2798 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2804 format_ip_address_fcn = format_ip4_address;
2806 format_ip_address_fcn = format_ip6_address;
2809 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
2810 clib_net_to_host_u32 (mp->vni),
2812 format_ip_address_fcn, mp->lloc,
2813 format_ip_address_fcn, mp->rloc,
2814 clib_net_to_host_u32 (mp->pkt_count),
2815 clib_net_to_host_u32 (mp->bytes));
2822 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
2824 struct in6_addr ip6;
2826 vat_main_t *vam = &vat_main;
2827 vat_json_node_t *node = 0;
2828 u8 *deid = 0, *seid = 0;
2830 if (VAT_JSON_ARRAY != vam->json_tree.type)
2832 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2833 vat_json_init_array (&vam->json_tree);
2835 node = vat_json_array_add (&vam->json_tree);
2837 vat_json_init_object (node);
2838 deid = format (0, "%U", format_lisp_eid_vat,
2839 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2841 seid = format (0, "%U", format_lisp_eid_vat,
2842 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2847 vat_json_object_add_string_copy (node, "seid", seid);
2848 vat_json_object_add_string_copy (node, "deid", deid);
2849 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2853 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
2854 vat_json_object_add_ip4 (node, "lloc", ip4);
2855 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
2856 vat_json_object_add_ip4 (node, "rloc", ip4);
2860 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
2861 vat_json_object_add_ip6 (node, "lloc", ip6);
2862 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
2863 vat_json_object_add_ip6 (node, "rloc", ip6);
2865 vat_json_object_add_uint (node, "pkt_count",
2866 clib_net_to_host_u32 (mp->pkt_count));
2867 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
2874 vl_api_one_eid_table_map_details_t_handler
2875 (vl_api_one_eid_table_map_details_t * mp)
2877 vat_main_t *vam = &vat_main;
2879 u8 *line = format (0, "%=10d%=10d",
2880 clib_net_to_host_u32 (mp->vni),
2881 clib_net_to_host_u32 (mp->dp_table));
2882 print (vam->ofp, "%v", line);
2887 vl_api_one_eid_table_map_details_t_handler_json
2888 (vl_api_one_eid_table_map_details_t * mp)
2890 vat_main_t *vam = &vat_main;
2891 vat_json_node_t *node = NULL;
2893 if (VAT_JSON_ARRAY != vam->json_tree.type)
2895 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2896 vat_json_init_array (&vam->json_tree);
2898 node = vat_json_array_add (&vam->json_tree);
2899 vat_json_init_object (node);
2900 vat_json_object_add_uint (node, "dp_table",
2901 clib_net_to_host_u32 (mp->dp_table));
2902 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2906 vl_api_one_eid_table_vni_details_t_handler
2907 (vl_api_one_eid_table_vni_details_t * mp)
2909 vat_main_t *vam = &vat_main;
2911 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2912 print (vam->ofp, "%v", line);
2917 vl_api_one_eid_table_vni_details_t_handler_json
2918 (vl_api_one_eid_table_vni_details_t * mp)
2920 vat_main_t *vam = &vat_main;
2921 vat_json_node_t *node = NULL;
2923 if (VAT_JSON_ARRAY != vam->json_tree.type)
2925 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2926 vat_json_init_array (&vam->json_tree);
2928 node = vat_json_array_add (&vam->json_tree);
2929 vat_json_init_object (node);
2930 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2934 vl_api_show_one_map_register_state_reply_t_handler
2935 (vl_api_show_one_map_register_state_reply_t * mp)
2937 vat_main_t *vam = &vat_main;
2938 int retval = clib_net_to_host_u32 (mp->retval);
2940 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2942 vam->retval = retval;
2943 vam->result_ready = 1;
2947 vl_api_show_one_map_register_state_reply_t_handler_json
2948 (vl_api_show_one_map_register_state_reply_t * mp)
2950 vat_main_t *vam = &vat_main;
2951 vat_json_node_t _node, *node = &_node;
2952 int retval = clib_net_to_host_u32 (mp->retval);
2954 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2956 vat_json_init_object (node);
2957 vat_json_object_add_string_copy (node, "state", s);
2959 vat_json_print (vam->ofp, node);
2960 vat_json_free (node);
2962 vam->retval = retval;
2963 vam->result_ready = 1;
2968 vl_api_show_one_rloc_probe_state_reply_t_handler
2969 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2971 vat_main_t *vam = &vat_main;
2972 int retval = clib_net_to_host_u32 (mp->retval);
2977 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2979 vam->retval = retval;
2980 vam->result_ready = 1;
2984 vl_api_show_one_rloc_probe_state_reply_t_handler_json
2985 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2987 vat_main_t *vam = &vat_main;
2988 vat_json_node_t _node, *node = &_node;
2989 int retval = clib_net_to_host_u32 (mp->retval);
2991 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2992 vat_json_init_object (node);
2993 vat_json_object_add_string_copy (node, "state", s);
2995 vat_json_print (vam->ofp, node);
2996 vat_json_free (node);
2998 vam->retval = retval;
2999 vam->result_ready = 1;
3004 vl_api_show_one_stats_enable_disable_reply_t_handler
3005 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3007 vat_main_t *vam = &vat_main;
3008 int retval = clib_net_to_host_u32 (mp->retval);
3013 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3015 vam->retval = retval;
3016 vam->result_ready = 1;
3020 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3021 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3023 vat_main_t *vam = &vat_main;
3024 vat_json_node_t _node, *node = &_node;
3025 int retval = clib_net_to_host_u32 (mp->retval);
3027 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3028 vat_json_init_object (node);
3029 vat_json_object_add_string_copy (node, "state", s);
3031 vat_json_print (vam->ofp, node);
3032 vat_json_free (node);
3034 vam->retval = retval;
3035 vam->result_ready = 1;
3040 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3042 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3043 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3044 e->vni = clib_net_to_host_u32 (e->vni);
3048 gpe_fwd_entries_get_reply_t_net_to_host
3049 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3053 mp->count = clib_net_to_host_u32 (mp->count);
3054 for (i = 0; i < mp->count; i++)
3056 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3061 format_gpe_encap_mode (u8 * s, va_list * args)
3063 u32 mode = va_arg (*args, u32);
3068 return format (s, "lisp");
3070 return format (s, "vxlan");
3076 vl_api_gpe_get_encap_mode_reply_t_handler
3077 (vl_api_gpe_get_encap_mode_reply_t * mp)
3079 vat_main_t *vam = &vat_main;
3081 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3082 vam->retval = ntohl (mp->retval);
3083 vam->result_ready = 1;
3087 vl_api_gpe_get_encap_mode_reply_t_handler_json
3088 (vl_api_gpe_get_encap_mode_reply_t * mp)
3090 vat_main_t *vam = &vat_main;
3091 vat_json_node_t node;
3093 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3094 vec_add1 (encap_mode, 0);
3096 vat_json_init_object (&node);
3097 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3099 vec_free (encap_mode);
3100 vat_json_print (vam->ofp, &node);
3101 vat_json_free (&node);
3103 vam->retval = ntohl (mp->retval);
3104 vam->result_ready = 1;
3108 vl_api_gpe_fwd_entry_path_details_t_handler
3109 (vl_api_gpe_fwd_entry_path_details_t * mp)
3111 vat_main_t *vam = &vat_main;
3112 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3114 if (mp->lcl_loc.is_ip4)
3115 format_ip_address_fcn = format_ip4_address;
3117 format_ip_address_fcn = format_ip6_address;
3119 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3120 format_ip_address_fcn, &mp->lcl_loc,
3121 format_ip_address_fcn, &mp->rmt_loc);
3125 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3127 struct in6_addr ip6;
3132 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3133 vat_json_object_add_ip4 (n, "address", ip4);
3137 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3138 vat_json_object_add_ip6 (n, "address", ip6);
3140 vat_json_object_add_uint (n, "weight", loc->weight);
3144 vl_api_gpe_fwd_entry_path_details_t_handler_json
3145 (vl_api_gpe_fwd_entry_path_details_t * mp)
3147 vat_main_t *vam = &vat_main;
3148 vat_json_node_t *node = NULL;
3149 vat_json_node_t *loc_node;
3151 if (VAT_JSON_ARRAY != vam->json_tree.type)
3153 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3154 vat_json_init_array (&vam->json_tree);
3156 node = vat_json_array_add (&vam->json_tree);
3157 vat_json_init_object (node);
3159 loc_node = vat_json_object_add (node, "local_locator");
3160 vat_json_init_object (loc_node);
3161 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3163 loc_node = vat_json_object_add (node, "remote_locator");
3164 vat_json_init_object (loc_node);
3165 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3169 vl_api_gpe_fwd_entries_get_reply_t_handler
3170 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3172 vat_main_t *vam = &vat_main;
3174 int retval = clib_net_to_host_u32 (mp->retval);
3175 vl_api_gpe_fwd_entry_t *e;
3180 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3182 for (i = 0; i < mp->count; i++)
3184 e = &mp->entries[i];
3185 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3186 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3187 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3191 vam->retval = retval;
3192 vam->result_ready = 1;
3196 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3197 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3200 vat_main_t *vam = &vat_main;
3201 vat_json_node_t *e = 0, root;
3203 int retval = clib_net_to_host_u32 (mp->retval);
3204 vl_api_gpe_fwd_entry_t *fwd;
3209 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3210 vat_json_init_array (&root);
3212 for (i = 0; i < mp->count; i++)
3214 e = vat_json_array_add (&root);
3215 fwd = &mp->entries[i];
3217 vat_json_init_object (e);
3218 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3219 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3220 vat_json_object_add_int (e, "vni", fwd->vni);
3221 vat_json_object_add_int (e, "action", fwd->action);
3223 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3224 fwd->leid_prefix_len);
3226 vat_json_object_add_string_copy (e, "leid", s);
3229 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3230 fwd->reid_prefix_len);
3232 vat_json_object_add_string_copy (e, "reid", s);
3236 vat_json_print (vam->ofp, &root);
3237 vat_json_free (&root);
3240 vam->retval = retval;
3241 vam->result_ready = 1;
3245 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3246 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3248 vat_main_t *vam = &vat_main;
3250 int retval = clib_net_to_host_u32 (mp->retval);
3251 vl_api_gpe_native_fwd_rpath_t *r;
3256 n = clib_net_to_host_u32 (mp->count);
3258 for (i = 0; i < n; i++)
3260 r = &mp->entries[i];
3261 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3262 clib_net_to_host_u32 (r->fib_index),
3263 clib_net_to_host_u32 (r->nh_sw_if_index),
3264 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3268 vam->retval = retval;
3269 vam->result_ready = 1;
3273 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3274 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3276 vat_main_t *vam = &vat_main;
3277 vat_json_node_t root, *e;
3279 int retval = clib_net_to_host_u32 (mp->retval);
3280 vl_api_gpe_native_fwd_rpath_t *r;
3286 n = clib_net_to_host_u32 (mp->count);
3287 vat_json_init_array (&root);
3289 for (i = 0; i < n; i++)
3291 e = vat_json_array_add (&root);
3292 vat_json_init_object (e);
3293 r = &mp->entries[i];
3295 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3298 vat_json_object_add_string_copy (e, "ip4", s);
3301 vat_json_object_add_uint (e, "fib_index",
3302 clib_net_to_host_u32 (r->fib_index));
3303 vat_json_object_add_uint (e, "nh_sw_if_index",
3304 clib_net_to_host_u32 (r->nh_sw_if_index));
3307 vat_json_print (vam->ofp, &root);
3308 vat_json_free (&root);
3311 vam->retval = retval;
3312 vam->result_ready = 1;
3316 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3317 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3319 vat_main_t *vam = &vat_main;
3321 int retval = clib_net_to_host_u32 (mp->retval);
3326 n = clib_net_to_host_u32 (mp->count);
3328 for (i = 0; i < n; i++)
3329 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3332 vam->retval = retval;
3333 vam->result_ready = 1;
3337 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3338 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3340 vat_main_t *vam = &vat_main;
3341 vat_json_node_t root;
3343 int retval = clib_net_to_host_u32 (mp->retval);
3348 n = clib_net_to_host_u32 (mp->count);
3349 vat_json_init_array (&root);
3351 for (i = 0; i < n; i++)
3352 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3354 vat_json_print (vam->ofp, &root);
3355 vat_json_free (&root);
3358 vam->retval = retval;
3359 vam->result_ready = 1;
3363 vl_api_one_l2_arp_entries_get_reply_t_handler
3364 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3366 vat_main_t *vam = &vat_main;
3368 int retval = clib_net_to_host_u32 (mp->retval);
3373 n = clib_net_to_host_u32 (mp->count);
3375 for (i = 0; i < n; i++)
3376 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3377 format_ethernet_address, mp->entries[i].mac);
3380 vam->retval = retval;
3381 vam->result_ready = 1;
3385 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3386 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3389 vat_main_t *vam = &vat_main;
3390 vat_json_node_t *e = 0, root;
3392 int retval = clib_net_to_host_u32 (mp->retval);
3393 vl_api_one_l2_arp_entry_t *arp_entry;
3398 n = clib_net_to_host_u32 (mp->count);
3399 vat_json_init_array (&root);
3401 for (i = 0; i < n; i++)
3403 e = vat_json_array_add (&root);
3404 arp_entry = &mp->entries[i];
3406 vat_json_init_object (e);
3407 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3410 vat_json_object_add_string_copy (e, "mac", s);
3413 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3415 vat_json_object_add_string_copy (e, "ip4", s);
3419 vat_json_print (vam->ofp, &root);
3420 vat_json_free (&root);
3423 vam->retval = retval;
3424 vam->result_ready = 1;
3428 vl_api_one_l2_arp_bd_get_reply_t_handler
3429 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3431 vat_main_t *vam = &vat_main;
3433 int retval = clib_net_to_host_u32 (mp->retval);
3438 n = clib_net_to_host_u32 (mp->count);
3440 for (i = 0; i < n; i++)
3442 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3446 vam->retval = retval;
3447 vam->result_ready = 1;
3451 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3452 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3454 vat_main_t *vam = &vat_main;
3455 vat_json_node_t root;
3457 int retval = clib_net_to_host_u32 (mp->retval);
3462 n = clib_net_to_host_u32 (mp->count);
3463 vat_json_init_array (&root);
3465 for (i = 0; i < n; i++)
3467 vat_json_array_add_uint (&root,
3468 clib_net_to_host_u32 (mp->bridge_domains[i]));
3471 vat_json_print (vam->ofp, &root);
3472 vat_json_free (&root);
3475 vam->retval = retval;
3476 vam->result_ready = 1;
3480 vl_api_one_adjacencies_get_reply_t_handler
3481 (vl_api_one_adjacencies_get_reply_t * mp)
3483 vat_main_t *vam = &vat_main;
3485 int retval = clib_net_to_host_u32 (mp->retval);
3486 vl_api_one_adjacency_t *a;
3491 n = clib_net_to_host_u32 (mp->count);
3493 for (i = 0; i < n; i++)
3495 a = &mp->adjacencies[i];
3496 print (vam->ofp, "%U %40U",
3497 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3498 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3502 vam->retval = retval;
3503 vam->result_ready = 1;
3507 vl_api_one_adjacencies_get_reply_t_handler_json
3508 (vl_api_one_adjacencies_get_reply_t * mp)
3511 vat_main_t *vam = &vat_main;
3512 vat_json_node_t *e = 0, root;
3514 int retval = clib_net_to_host_u32 (mp->retval);
3515 vl_api_one_adjacency_t *a;
3520 n = clib_net_to_host_u32 (mp->count);
3521 vat_json_init_array (&root);
3523 for (i = 0; i < n; i++)
3525 e = vat_json_array_add (&root);
3526 a = &mp->adjacencies[i];
3528 vat_json_init_object (e);
3529 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3530 a->leid_prefix_len);
3532 vat_json_object_add_string_copy (e, "leid", s);
3535 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3536 a->reid_prefix_len);
3538 vat_json_object_add_string_copy (e, "reid", s);
3542 vat_json_print (vam->ofp, &root);
3543 vat_json_free (&root);
3546 vam->retval = retval;
3547 vam->result_ready = 1;
3551 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3553 vat_main_t *vam = &vat_main;
3555 print (vam->ofp, "%=20U",
3556 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3561 vl_api_one_map_server_details_t_handler_json
3562 (vl_api_one_map_server_details_t * mp)
3564 vat_main_t *vam = &vat_main;
3565 vat_json_node_t *node = NULL;
3566 struct in6_addr ip6;
3569 if (VAT_JSON_ARRAY != vam->json_tree.type)
3571 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3572 vat_json_init_array (&vam->json_tree);
3574 node = vat_json_array_add (&vam->json_tree);
3576 vat_json_init_object (node);
3579 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3580 vat_json_object_add_ip6 (node, "map-server", ip6);
3584 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3585 vat_json_object_add_ip4 (node, "map-server", ip4);
3590 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3593 vat_main_t *vam = &vat_main;
3595 print (vam->ofp, "%=20U",
3596 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3601 vl_api_one_map_resolver_details_t_handler_json
3602 (vl_api_one_map_resolver_details_t * mp)
3604 vat_main_t *vam = &vat_main;
3605 vat_json_node_t *node = NULL;
3606 struct in6_addr ip6;
3609 if (VAT_JSON_ARRAY != vam->json_tree.type)
3611 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3612 vat_json_init_array (&vam->json_tree);
3614 node = vat_json_array_add (&vam->json_tree);
3616 vat_json_init_object (node);
3619 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3620 vat_json_object_add_ip6 (node, "map resolver", ip6);
3624 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3625 vat_json_object_add_ip4 (node, "map resolver", ip4);
3630 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3632 vat_main_t *vam = &vat_main;
3633 i32 retval = ntohl (mp->retval);
3637 print (vam->ofp, "feature: %s\ngpe: %s",
3638 mp->feature_status ? "enabled" : "disabled",
3639 mp->gpe_status ? "enabled" : "disabled");
3642 vam->retval = retval;
3643 vam->result_ready = 1;
3647 vl_api_show_one_status_reply_t_handler_json
3648 (vl_api_show_one_status_reply_t * mp)
3650 vat_main_t *vam = &vat_main;
3651 vat_json_node_t node;
3652 u8 *gpe_status = NULL;
3653 u8 *feature_status = NULL;
3655 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3656 feature_status = format (0, "%s",
3657 mp->feature_status ? "enabled" : "disabled");
3658 vec_add1 (gpe_status, 0);
3659 vec_add1 (feature_status, 0);
3661 vat_json_init_object (&node);
3662 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3663 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3665 vec_free (gpe_status);
3666 vec_free (feature_status);
3668 vat_json_print (vam->ofp, &node);
3669 vat_json_free (&node);
3671 vam->retval = ntohl (mp->retval);
3672 vam->result_ready = 1;
3676 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3677 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3679 vat_main_t *vam = &vat_main;
3680 i32 retval = ntohl (mp->retval);
3684 print (vam->ofp, "%=20s", mp->locator_set_name);
3687 vam->retval = retval;
3688 vam->result_ready = 1;
3692 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3693 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3695 vat_main_t *vam = &vat_main;
3696 vat_json_node_t *node = NULL;
3698 if (VAT_JSON_ARRAY != vam->json_tree.type)
3700 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3701 vat_json_init_array (&vam->json_tree);
3703 node = vat_json_array_add (&vam->json_tree);
3705 vat_json_init_object (node);
3706 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3708 vat_json_print (vam->ofp, node);
3709 vat_json_free (node);
3711 vam->retval = ntohl (mp->retval);
3712 vam->result_ready = 1;
3716 format_lisp_map_request_mode (u8 * s, va_list * args)
3718 u32 mode = va_arg (*args, u32);
3723 return format (0, "dst-only");
3725 return format (0, "src-dst");
3731 vl_api_show_one_map_request_mode_reply_t_handler
3732 (vl_api_show_one_map_request_mode_reply_t * mp)
3734 vat_main_t *vam = &vat_main;
3735 i32 retval = ntohl (mp->retval);
3739 u32 mode = mp->mode;
3740 print (vam->ofp, "map_request_mode: %U",
3741 format_lisp_map_request_mode, mode);
3744 vam->retval = retval;
3745 vam->result_ready = 1;
3749 vl_api_show_one_map_request_mode_reply_t_handler_json
3750 (vl_api_show_one_map_request_mode_reply_t * mp)
3752 vat_main_t *vam = &vat_main;
3753 vat_json_node_t node;
3758 s = format (0, "%U", format_lisp_map_request_mode, mode);
3761 vat_json_init_object (&node);
3762 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3763 vat_json_print (vam->ofp, &node);
3764 vat_json_free (&node);
3767 vam->retval = ntohl (mp->retval);
3768 vam->result_ready = 1;
3772 vl_api_show_one_use_petr_reply_t_handler
3773 (vl_api_show_one_use_petr_reply_t * mp)
3775 vat_main_t *vam = &vat_main;
3776 i32 retval = ntohl (mp->retval);
3780 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
3783 print (vam->ofp, "Proxy-ETR address; %U",
3784 mp->is_ip4 ? format_ip4_address : format_ip6_address,
3789 vam->retval = retval;
3790 vam->result_ready = 1;
3794 vl_api_show_one_use_petr_reply_t_handler_json
3795 (vl_api_show_one_use_petr_reply_t * mp)
3797 vat_main_t *vam = &vat_main;
3798 vat_json_node_t node;
3801 struct in6_addr ip6;
3803 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3804 vec_add1 (status, 0);
3806 vat_json_init_object (&node);
3807 vat_json_object_add_string_copy (&node, "status", status);
3812 clib_memcpy (&ip6, mp->address, sizeof (ip6));
3813 vat_json_object_add_ip6 (&node, "address", ip6);
3817 clib_memcpy (&ip4, mp->address, sizeof (ip4));
3818 vat_json_object_add_ip4 (&node, "address", ip4);
3824 vat_json_print (vam->ofp, &node);
3825 vat_json_free (&node);
3827 vam->retval = ntohl (mp->retval);
3828 vam->result_ready = 1;
3832 vl_api_show_one_nsh_mapping_reply_t_handler
3833 (vl_api_show_one_nsh_mapping_reply_t * mp)
3835 vat_main_t *vam = &vat_main;
3836 i32 retval = ntohl (mp->retval);
3840 print (vam->ofp, "%-20s%-16s",
3841 mp->is_set ? "set" : "not-set",
3842 mp->is_set ? (char *) mp->locator_set_name : "");
3845 vam->retval = retval;
3846 vam->result_ready = 1;
3850 vl_api_show_one_nsh_mapping_reply_t_handler_json
3851 (vl_api_show_one_nsh_mapping_reply_t * mp)
3853 vat_main_t *vam = &vat_main;
3854 vat_json_node_t node;
3857 status = format (0, "%s", mp->is_set ? "yes" : "no");
3858 vec_add1 (status, 0);
3860 vat_json_init_object (&node);
3861 vat_json_object_add_string_copy (&node, "is_set", status);
3864 vat_json_object_add_string_copy (&node, "locator_set",
3865 mp->locator_set_name);
3870 vat_json_print (vam->ofp, &node);
3871 vat_json_free (&node);
3873 vam->retval = ntohl (mp->retval);
3874 vam->result_ready = 1;
3878 vl_api_show_one_map_register_ttl_reply_t_handler
3879 (vl_api_show_one_map_register_ttl_reply_t * mp)
3881 vat_main_t *vam = &vat_main;
3882 i32 retval = ntohl (mp->retval);
3884 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
3888 print (vam->ofp, "ttl: %u", mp->ttl);
3891 vam->retval = retval;
3892 vam->result_ready = 1;
3896 vl_api_show_one_map_register_ttl_reply_t_handler_json
3897 (vl_api_show_one_map_register_ttl_reply_t * mp)
3899 vat_main_t *vam = &vat_main;
3900 vat_json_node_t node;
3902 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
3903 vat_json_init_object (&node);
3904 vat_json_object_add_uint (&node, "ttl", mp->ttl);
3906 vat_json_print (vam->ofp, &node);
3907 vat_json_free (&node);
3909 vam->retval = ntohl (mp->retval);
3910 vam->result_ready = 1;
3914 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3916 vat_main_t *vam = &vat_main;
3917 i32 retval = ntohl (mp->retval);
3921 print (vam->ofp, "%-20s%-16s",
3922 mp->status ? "enabled" : "disabled",
3923 mp->status ? (char *) mp->locator_set_name : "");
3926 vam->retval = retval;
3927 vam->result_ready = 1;
3931 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3933 vat_main_t *vam = &vat_main;
3934 vat_json_node_t node;
3937 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3938 vec_add1 (status, 0);
3940 vat_json_init_object (&node);
3941 vat_json_object_add_string_copy (&node, "status", status);
3944 vat_json_object_add_string_copy (&node, "locator_set",
3945 mp->locator_set_name);
3950 vat_json_print (vam->ofp, &node);
3951 vat_json_free (&node);
3953 vam->retval = ntohl (mp->retval);
3954 vam->result_ready = 1;
3958 format_policer_type (u8 * s, va_list * va)
3960 u32 i = va_arg (*va, u32);
3962 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3963 s = format (s, "1r2c");
3964 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3965 s = format (s, "1r3c");
3966 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3967 s = format (s, "2r3c-2698");
3968 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3969 s = format (s, "2r3c-4115");
3970 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3971 s = format (s, "2r3c-mef5cf1");
3973 s = format (s, "ILLEGAL");
3978 format_policer_rate_type (u8 * s, va_list * va)
3980 u32 i = va_arg (*va, u32);
3982 if (i == SSE2_QOS_RATE_KBPS)
3983 s = format (s, "kbps");
3984 else if (i == SSE2_QOS_RATE_PPS)
3985 s = format (s, "pps");
3987 s = format (s, "ILLEGAL");
3992 format_policer_round_type (u8 * s, va_list * va)
3994 u32 i = va_arg (*va, u32);
3996 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3997 s = format (s, "closest");
3998 else if (i == SSE2_QOS_ROUND_TO_UP)
3999 s = format (s, "up");
4000 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4001 s = format (s, "down");
4003 s = format (s, "ILLEGAL");
4008 format_policer_action_type (u8 * s, va_list * va)
4010 u32 i = va_arg (*va, u32);
4012 if (i == SSE2_QOS_ACTION_DROP)
4013 s = format (s, "drop");
4014 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4015 s = format (s, "transmit");
4016 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4017 s = format (s, "mark-and-transmit");
4019 s = format (s, "ILLEGAL");
4024 format_dscp (u8 * s, va_list * va)
4026 u32 i = va_arg (*va, u32);
4031 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4035 return format (s, "ILLEGAL");
4037 s = format (s, "%s", t);
4042 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4044 vat_main_t *vam = &vat_main;
4045 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4047 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4048 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4050 conform_dscp_str = format (0, "");
4052 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4053 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4055 exceed_dscp_str = format (0, "");
4057 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4058 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4060 violate_dscp_str = format (0, "");
4062 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4063 "rate type %U, round type %U, %s rate, %s color-aware, "
4064 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4065 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4066 "conform action %U%s, exceed action %U%s, violate action %U%s",
4068 format_policer_type, mp->type,
4071 clib_net_to_host_u64 (mp->cb),
4072 clib_net_to_host_u64 (mp->eb),
4073 format_policer_rate_type, mp->rate_type,
4074 format_policer_round_type, mp->round_type,
4075 mp->single_rate ? "single" : "dual",
4076 mp->color_aware ? "is" : "not",
4077 ntohl (mp->cir_tokens_per_period),
4078 ntohl (mp->pir_tokens_per_period),
4080 ntohl (mp->current_limit),
4081 ntohl (mp->current_bucket),
4082 ntohl (mp->extended_limit),
4083 ntohl (mp->extended_bucket),
4084 clib_net_to_host_u64 (mp->last_update_time),
4085 format_policer_action_type, mp->conform_action_type,
4087 format_policer_action_type, mp->exceed_action_type,
4089 format_policer_action_type, mp->violate_action_type,
4092 vec_free (conform_dscp_str);
4093 vec_free (exceed_dscp_str);
4094 vec_free (violate_dscp_str);
4097 static void vl_api_policer_details_t_handler_json
4098 (vl_api_policer_details_t * mp)
4100 vat_main_t *vam = &vat_main;
4101 vat_json_node_t *node;
4102 u8 *rate_type_str, *round_type_str, *type_str;
4103 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4105 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4107 format (0, "%U", format_policer_round_type, mp->round_type);
4108 type_str = format (0, "%U", format_policer_type, mp->type);
4109 conform_action_str = format (0, "%U", format_policer_action_type,
4110 mp->conform_action_type);
4111 exceed_action_str = format (0, "%U", format_policer_action_type,
4112 mp->exceed_action_type);
4113 violate_action_str = format (0, "%U", format_policer_action_type,
4114 mp->violate_action_type);
4116 if (VAT_JSON_ARRAY != vam->json_tree.type)
4118 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4119 vat_json_init_array (&vam->json_tree);
4121 node = vat_json_array_add (&vam->json_tree);
4123 vat_json_init_object (node);
4124 vat_json_object_add_string_copy (node, "name", mp->name);
4125 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4126 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4127 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4128 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4129 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4130 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4131 vat_json_object_add_string_copy (node, "type", type_str);
4132 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4133 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4134 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4135 vat_json_object_add_uint (node, "cir_tokens_per_period",
4136 ntohl (mp->cir_tokens_per_period));
4137 vat_json_object_add_uint (node, "eir_tokens_per_period",
4138 ntohl (mp->pir_tokens_per_period));
4139 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4140 vat_json_object_add_uint (node, "current_bucket",
4141 ntohl (mp->current_bucket));
4142 vat_json_object_add_uint (node, "extended_limit",
4143 ntohl (mp->extended_limit));
4144 vat_json_object_add_uint (node, "extended_bucket",
4145 ntohl (mp->extended_bucket));
4146 vat_json_object_add_uint (node, "last_update_time",
4147 ntohl (mp->last_update_time));
4148 vat_json_object_add_string_copy (node, "conform_action",
4149 conform_action_str);
4150 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4152 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4153 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4154 vec_free (dscp_str);
4156 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4157 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4159 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4160 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4161 vec_free (dscp_str);
4163 vat_json_object_add_string_copy (node, "violate_action",
4164 violate_action_str);
4165 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4167 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4168 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4169 vec_free (dscp_str);
4172 vec_free (rate_type_str);
4173 vec_free (round_type_str);
4174 vec_free (type_str);
4175 vec_free (conform_action_str);
4176 vec_free (exceed_action_str);
4177 vec_free (violate_action_str);
4181 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4184 vat_main_t *vam = &vat_main;
4185 int i, count = ntohl (mp->count);
4188 print (vam->ofp, "classify table ids (%d) : ", count);
4189 for (i = 0; i < count; i++)
4191 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4192 print (vam->ofp, (i < count - 1) ? "," : "");
4194 vam->retval = ntohl (mp->retval);
4195 vam->result_ready = 1;
4199 vl_api_classify_table_ids_reply_t_handler_json
4200 (vl_api_classify_table_ids_reply_t * mp)
4202 vat_main_t *vam = &vat_main;
4203 int i, count = ntohl (mp->count);
4207 vat_json_node_t node;
4209 vat_json_init_object (&node);
4210 for (i = 0; i < count; i++)
4212 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4214 vat_json_print (vam->ofp, &node);
4215 vat_json_free (&node);
4217 vam->retval = ntohl (mp->retval);
4218 vam->result_ready = 1;
4222 vl_api_classify_table_by_interface_reply_t_handler
4223 (vl_api_classify_table_by_interface_reply_t * mp)
4225 vat_main_t *vam = &vat_main;
4228 table_id = ntohl (mp->l2_table_id);
4230 print (vam->ofp, "l2 table id : %d", table_id);
4232 print (vam->ofp, "l2 table id : No input ACL tables configured");
4233 table_id = ntohl (mp->ip4_table_id);
4235 print (vam->ofp, "ip4 table id : %d", table_id);
4237 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4238 table_id = ntohl (mp->ip6_table_id);
4240 print (vam->ofp, "ip6 table id : %d", table_id);
4242 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4243 vam->retval = ntohl (mp->retval);
4244 vam->result_ready = 1;
4248 vl_api_classify_table_by_interface_reply_t_handler_json
4249 (vl_api_classify_table_by_interface_reply_t * mp)
4251 vat_main_t *vam = &vat_main;
4252 vat_json_node_t node;
4254 vat_json_init_object (&node);
4256 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4257 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4258 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4260 vat_json_print (vam->ofp, &node);
4261 vat_json_free (&node);
4263 vam->retval = ntohl (mp->retval);
4264 vam->result_ready = 1;
4267 static void vl_api_policer_add_del_reply_t_handler
4268 (vl_api_policer_add_del_reply_t * mp)
4270 vat_main_t *vam = &vat_main;
4271 i32 retval = ntohl (mp->retval);
4272 if (vam->async_mode)
4274 vam->async_errors += (retval < 0);
4278 vam->retval = retval;
4279 vam->result_ready = 1;
4280 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4282 * Note: this is just barely thread-safe, depends on
4283 * the main thread spinning waiting for an answer...
4285 errmsg ("policer index %d", ntohl (mp->policer_index));
4289 static void vl_api_policer_add_del_reply_t_handler_json
4290 (vl_api_policer_add_del_reply_t * mp)
4292 vat_main_t *vam = &vat_main;
4293 vat_json_node_t node;
4295 vat_json_init_object (&node);
4296 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4297 vat_json_object_add_uint (&node, "policer_index",
4298 ntohl (mp->policer_index));
4300 vat_json_print (vam->ofp, &node);
4301 vat_json_free (&node);
4303 vam->retval = ntohl (mp->retval);
4304 vam->result_ready = 1;
4307 /* Format hex dump. */
4309 format_hex_bytes (u8 * s, va_list * va)
4311 u8 *bytes = va_arg (*va, u8 *);
4312 int n_bytes = va_arg (*va, int);
4315 /* Print short or long form depending on byte count. */
4316 uword short_form = n_bytes <= 32;
4317 uword indent = format_get_indent (s);
4322 for (i = 0; i < n_bytes; i++)
4324 if (!short_form && (i % 32) == 0)
4325 s = format (s, "%08x: ", i);
4326 s = format (s, "%02x", bytes[i]);
4327 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4328 s = format (s, "\n%U", format_white_space, indent);
4335 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4338 vat_main_t *vam = &vat_main;
4339 i32 retval = ntohl (mp->retval);
4342 print (vam->ofp, "classify table info :");
4343 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4344 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4345 ntohl (mp->miss_next_index));
4346 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4347 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4348 ntohl (mp->match_n_vectors));
4349 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4350 ntohl (mp->mask_length));
4352 vam->retval = retval;
4353 vam->result_ready = 1;
4357 vl_api_classify_table_info_reply_t_handler_json
4358 (vl_api_classify_table_info_reply_t * mp)
4360 vat_main_t *vam = &vat_main;
4361 vat_json_node_t node;
4363 i32 retval = ntohl (mp->retval);
4366 vat_json_init_object (&node);
4368 vat_json_object_add_int (&node, "sessions",
4369 ntohl (mp->active_sessions));
4370 vat_json_object_add_int (&node, "nexttbl",
4371 ntohl (mp->next_table_index));
4372 vat_json_object_add_int (&node, "nextnode",
4373 ntohl (mp->miss_next_index));
4374 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4375 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4376 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4377 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4378 ntohl (mp->mask_length), 0);
4379 vat_json_object_add_string_copy (&node, "mask", s);
4381 vat_json_print (vam->ofp, &node);
4382 vat_json_free (&node);
4384 vam->retval = ntohl (mp->retval);
4385 vam->result_ready = 1;
4389 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4392 vat_main_t *vam = &vat_main;
4394 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4395 ntohl (mp->hit_next_index), ntohl (mp->advance),
4396 ntohl (mp->opaque_index));
4397 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4398 ntohl (mp->match_length));
4402 vl_api_classify_session_details_t_handler_json
4403 (vl_api_classify_session_details_t * mp)
4405 vat_main_t *vam = &vat_main;
4406 vat_json_node_t *node = NULL;
4408 if (VAT_JSON_ARRAY != vam->json_tree.type)
4410 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4411 vat_json_init_array (&vam->json_tree);
4413 node = vat_json_array_add (&vam->json_tree);
4415 vat_json_init_object (node);
4416 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4417 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4418 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4420 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4422 vat_json_object_add_string_copy (node, "match", s);
4425 static void vl_api_pg_create_interface_reply_t_handler
4426 (vl_api_pg_create_interface_reply_t * mp)
4428 vat_main_t *vam = &vat_main;
4430 vam->retval = ntohl (mp->retval);
4431 vam->result_ready = 1;
4434 static void vl_api_pg_create_interface_reply_t_handler_json
4435 (vl_api_pg_create_interface_reply_t * mp)
4437 vat_main_t *vam = &vat_main;
4438 vat_json_node_t node;
4440 i32 retval = ntohl (mp->retval);
4443 vat_json_init_object (&node);
4445 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4447 vat_json_print (vam->ofp, &node);
4448 vat_json_free (&node);
4450 vam->retval = ntohl (mp->retval);
4451 vam->result_ready = 1;
4454 static void vl_api_policer_classify_details_t_handler
4455 (vl_api_policer_classify_details_t * mp)
4457 vat_main_t *vam = &vat_main;
4459 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4460 ntohl (mp->table_index));
4463 static void vl_api_policer_classify_details_t_handler_json
4464 (vl_api_policer_classify_details_t * mp)
4466 vat_main_t *vam = &vat_main;
4467 vat_json_node_t *node;
4469 if (VAT_JSON_ARRAY != vam->json_tree.type)
4471 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4472 vat_json_init_array (&vam->json_tree);
4474 node = vat_json_array_add (&vam->json_tree);
4476 vat_json_init_object (node);
4477 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4478 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4481 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4482 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4484 vat_main_t *vam = &vat_main;
4485 i32 retval = ntohl (mp->retval);
4486 if (vam->async_mode)
4488 vam->async_errors += (retval < 0);
4492 vam->retval = retval;
4493 vam->sw_if_index = ntohl (mp->sw_if_index);
4494 vam->result_ready = 1;
4498 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4499 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4501 vat_main_t *vam = &vat_main;
4502 vat_json_node_t node;
4504 vat_json_init_object (&node);
4505 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4506 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4508 vat_json_print (vam->ofp, &node);
4509 vat_json_free (&node);
4511 vam->retval = ntohl (mp->retval);
4512 vam->result_ready = 1;
4515 static void vl_api_flow_classify_details_t_handler
4516 (vl_api_flow_classify_details_t * mp)
4518 vat_main_t *vam = &vat_main;
4520 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4521 ntohl (mp->table_index));
4524 static void vl_api_flow_classify_details_t_handler_json
4525 (vl_api_flow_classify_details_t * mp)
4527 vat_main_t *vam = &vat_main;
4528 vat_json_node_t *node;
4530 if (VAT_JSON_ARRAY != vam->json_tree.type)
4532 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4533 vat_json_init_array (&vam->json_tree);
4535 node = vat_json_array_add (&vam->json_tree);
4537 vat_json_init_object (node);
4538 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4539 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4542 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
4543 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
4544 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
4545 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
4546 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4547 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4548 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4549 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4550 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4551 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4552 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4553 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4554 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4555 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4556 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
4557 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
4558 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
4559 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
4562 * Generate boilerplate reply handlers, which
4563 * dig the return value out of the xxx_reply_t API message,
4564 * stick it into vam->retval, and set vam->result_ready
4566 * Could also do this by pointing N message decode slots at
4567 * a single function, but that could break in subtle ways.
4570 #define foreach_standard_reply_retval_handler \
4571 _(sw_interface_set_flags_reply) \
4572 _(sw_interface_add_del_address_reply) \
4573 _(sw_interface_set_table_reply) \
4574 _(sw_interface_set_mpls_enable_reply) \
4575 _(sw_interface_set_vpath_reply) \
4576 _(sw_interface_set_vxlan_bypass_reply) \
4577 _(sw_interface_set_vxlan_gpe_bypass_reply) \
4578 _(sw_interface_set_l2_bridge_reply) \
4579 _(bridge_domain_add_del_reply) \
4580 _(sw_interface_set_l2_xconnect_reply) \
4581 _(l2fib_add_del_reply) \
4582 _(l2fib_flush_int_reply) \
4583 _(l2fib_flush_bd_reply) \
4584 _(ip_add_del_route_reply) \
4585 _(ip_mroute_add_del_reply) \
4586 _(mpls_route_add_del_reply) \
4587 _(mpls_ip_bind_unbind_reply) \
4588 _(proxy_arp_add_del_reply) \
4589 _(proxy_arp_intfc_enable_disable_reply) \
4590 _(sw_interface_set_unnumbered_reply) \
4591 _(ip_neighbor_add_del_reply) \
4592 _(reset_vrf_reply) \
4593 _(oam_add_del_reply) \
4594 _(reset_fib_reply) \
4595 _(dhcp_proxy_config_reply) \
4596 _(dhcp_proxy_set_vss_reply) \
4597 _(dhcp_client_config_reply) \
4598 _(set_ip_flow_hash_reply) \
4599 _(sw_interface_ip6_enable_disable_reply) \
4600 _(sw_interface_ip6_set_link_local_address_reply) \
4601 _(ip6nd_proxy_add_del_reply) \
4602 _(sw_interface_ip6nd_ra_prefix_reply) \
4603 _(sw_interface_ip6nd_ra_config_reply) \
4604 _(set_arp_neighbor_limit_reply) \
4605 _(l2_patch_add_del_reply) \
4606 _(sr_policy_add_reply) \
4607 _(sr_policy_mod_reply) \
4608 _(sr_policy_del_reply) \
4609 _(sr_localsid_add_del_reply) \
4610 _(sr_steering_add_del_reply) \
4611 _(classify_add_del_session_reply) \
4612 _(classify_set_interface_ip_table_reply) \
4613 _(classify_set_interface_l2_tables_reply) \
4614 _(l2tpv3_set_tunnel_cookies_reply) \
4615 _(l2tpv3_interface_enable_disable_reply) \
4616 _(l2tpv3_set_lookup_key_reply) \
4617 _(l2_fib_clear_table_reply) \
4618 _(l2_interface_efp_filter_reply) \
4619 _(l2_interface_vlan_tag_rewrite_reply) \
4620 _(modify_vhost_user_if_reply) \
4621 _(delete_vhost_user_if_reply) \
4622 _(want_ip4_arp_events_reply) \
4623 _(want_ip6_nd_events_reply) \
4624 _(want_l2_macs_events_reply) \
4625 _(input_acl_set_interface_reply) \
4626 _(ipsec_spd_add_del_reply) \
4627 _(ipsec_interface_add_del_spd_reply) \
4628 _(ipsec_spd_add_del_entry_reply) \
4629 _(ipsec_sad_add_del_entry_reply) \
4630 _(ipsec_sa_set_key_reply) \
4631 _(ipsec_tunnel_if_add_del_reply) \
4632 _(ikev2_profile_add_del_reply) \
4633 _(ikev2_profile_set_auth_reply) \
4634 _(ikev2_profile_set_id_reply) \
4635 _(ikev2_profile_set_ts_reply) \
4636 _(ikev2_set_local_key_reply) \
4637 _(ikev2_set_responder_reply) \
4638 _(ikev2_set_ike_transforms_reply) \
4639 _(ikev2_set_esp_transforms_reply) \
4640 _(ikev2_set_sa_lifetime_reply) \
4641 _(ikev2_initiate_sa_init_reply) \
4642 _(ikev2_initiate_del_ike_sa_reply) \
4643 _(ikev2_initiate_del_child_sa_reply) \
4644 _(ikev2_initiate_rekey_child_sa_reply) \
4645 _(delete_loopback_reply) \
4646 _(bd_ip_mac_add_del_reply) \
4647 _(map_del_domain_reply) \
4648 _(map_add_del_rule_reply) \
4649 _(want_interface_events_reply) \
4650 _(want_stats_reply) \
4651 _(cop_interface_enable_disable_reply) \
4652 _(cop_whitelist_enable_disable_reply) \
4653 _(sw_interface_clear_stats_reply) \
4654 _(ioam_enable_reply) \
4655 _(ioam_disable_reply) \
4656 _(one_add_del_locator_reply) \
4657 _(one_add_del_local_eid_reply) \
4658 _(one_add_del_remote_mapping_reply) \
4659 _(one_add_del_adjacency_reply) \
4660 _(one_add_del_map_resolver_reply) \
4661 _(one_add_del_map_server_reply) \
4662 _(one_enable_disable_reply) \
4663 _(one_rloc_probe_enable_disable_reply) \
4664 _(one_map_register_enable_disable_reply) \
4665 _(one_map_register_set_ttl_reply) \
4666 _(one_pitr_set_locator_set_reply) \
4667 _(one_map_request_mode_reply) \
4668 _(one_add_del_map_request_itr_rlocs_reply) \
4669 _(one_eid_table_add_del_map_reply) \
4670 _(one_use_petr_reply) \
4671 _(one_stats_enable_disable_reply) \
4672 _(one_add_del_l2_arp_entry_reply) \
4673 _(one_stats_flush_reply) \
4674 _(gpe_enable_disable_reply) \
4675 _(gpe_set_encap_mode_reply) \
4676 _(gpe_add_del_iface_reply) \
4677 _(gpe_add_del_native_fwd_rpath_reply) \
4678 _(af_packet_delete_reply) \
4679 _(policer_classify_set_interface_reply) \
4680 _(netmap_create_reply) \
4681 _(netmap_delete_reply) \
4682 _(set_ipfix_exporter_reply) \
4683 _(set_ipfix_classify_stream_reply) \
4684 _(ipfix_classify_table_add_del_reply) \
4685 _(flow_classify_set_interface_reply) \
4686 _(sw_interface_span_enable_disable_reply) \
4687 _(pg_capture_reply) \
4688 _(pg_enable_disable_reply) \
4689 _(ip_source_and_port_range_check_add_del_reply) \
4690 _(ip_source_and_port_range_check_interface_add_del_reply)\
4691 _(delete_subif_reply) \
4692 _(l2_interface_pbb_tag_rewrite_reply) \
4694 _(feature_enable_disable_reply) \
4695 _(sw_interface_tag_add_del_reply) \
4696 _(sw_interface_set_mtu_reply) \
4697 _(p2p_ethernet_add_reply) \
4698 _(p2p_ethernet_del_reply) \
4699 _(lldp_config_reply) \
4700 _(sw_interface_set_lldp_reply)
4703 static void vl_api_##n##_t_handler \
4704 (vl_api_##n##_t * mp) \
4706 vat_main_t * vam = &vat_main; \
4707 i32 retval = ntohl(mp->retval); \
4708 if (vam->async_mode) { \
4709 vam->async_errors += (retval < 0); \
4711 vam->retval = retval; \
4712 vam->result_ready = 1; \
4715 foreach_standard_reply_retval_handler;
4719 static void vl_api_##n##_t_handler_json \
4720 (vl_api_##n##_t * mp) \
4722 vat_main_t * vam = &vat_main; \
4723 vat_json_node_t node; \
4724 vat_json_init_object(&node); \
4725 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4726 vat_json_print(vam->ofp, &node); \
4727 vam->retval = ntohl(mp->retval); \
4728 vam->result_ready = 1; \
4730 foreach_standard_reply_retval_handler;
4734 * Table of message reply handlers, must include boilerplate handlers
4738 #define foreach_vpe_api_reply_msg \
4739 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4740 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4741 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4742 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4743 _(CONTROL_PING_REPLY, control_ping_reply) \
4744 _(CLI_REPLY, cli_reply) \
4745 _(CLI_INBAND_REPLY, cli_inband_reply) \
4746 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4747 sw_interface_add_del_address_reply) \
4748 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4749 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4750 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4751 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4752 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
4753 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4754 sw_interface_set_l2_xconnect_reply) \
4755 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4756 sw_interface_set_l2_bridge_reply) \
4757 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4758 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4759 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
4760 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4761 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
4762 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
4763 _(L2_FLAGS_REPLY, l2_flags_reply) \
4764 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4765 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4766 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4767 _(TAP_DELETE_REPLY, tap_delete_reply) \
4768 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4769 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4770 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4771 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4772 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4773 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4774 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4775 proxy_arp_intfc_enable_disable_reply) \
4776 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4777 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4778 sw_interface_set_unnumbered_reply) \
4779 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4780 _(RESET_VRF_REPLY, reset_vrf_reply) \
4781 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4782 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4783 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4784 _(RESET_FIB_REPLY, reset_fib_reply) \
4785 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4786 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4787 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4788 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4789 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4790 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4791 sw_interface_ip6_enable_disable_reply) \
4792 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4793 sw_interface_ip6_set_link_local_address_reply) \
4794 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
4795 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
4796 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4797 sw_interface_ip6nd_ra_prefix_reply) \
4798 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4799 sw_interface_ip6nd_ra_config_reply) \
4800 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4801 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4802 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4803 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4804 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4805 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4806 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4807 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4808 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4809 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4810 classify_set_interface_ip_table_reply) \
4811 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4812 classify_set_interface_l2_tables_reply) \
4813 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4814 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4815 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4816 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4817 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4818 l2tpv3_interface_enable_disable_reply) \
4819 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4820 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4821 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4822 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4823 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4824 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4825 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4826 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4827 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4828 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4829 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4830 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4831 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4832 _(SHOW_VERSION_REPLY, show_version_reply) \
4833 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
4834 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4835 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4836 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4837 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4838 _(IP4_ARP_EVENT, ip4_arp_event) \
4839 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4840 _(IP6_ND_EVENT, ip6_nd_event) \
4841 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
4842 _(L2_MACS_EVENT, l2_macs_event) \
4843 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4844 _(IP_ADDRESS_DETAILS, ip_address_details) \
4845 _(IP_DETAILS, ip_details) \
4846 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4847 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4848 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4849 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4850 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4851 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
4852 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4853 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4854 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4855 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4856 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4857 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4858 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4859 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4860 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4861 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4862 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4863 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4864 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4865 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4866 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4867 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4868 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4869 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4870 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4871 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4872 _(MAP_RULE_DETAILS, map_rule_details) \
4873 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4874 _(WANT_STATS_REPLY, want_stats_reply) \
4875 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4876 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4877 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4878 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4879 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4880 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4881 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4882 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4883 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4884 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4885 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4886 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4887 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4888 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4889 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4890 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4891 one_map_register_enable_disable_reply) \
4892 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
4893 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4894 one_rloc_probe_enable_disable_reply) \
4895 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4896 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
4897 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4898 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4899 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4900 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4901 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4902 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4903 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4904 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4905 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4906 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4907 _(ONE_STATS_DETAILS, one_stats_details) \
4908 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
4909 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
4910 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
4911 show_one_stats_enable_disable_reply) \
4912 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
4913 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
4914 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
4915 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4916 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4917 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4918 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4919 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4920 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
4921 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4922 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
4923 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
4924 gpe_add_del_native_fwd_rpath_reply) \
4925 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4926 gpe_fwd_entry_path_details) \
4927 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4928 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4929 one_add_del_map_request_itr_rlocs_reply) \
4930 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4931 one_get_map_request_itr_rlocs_reply) \
4932 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
4933 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4934 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
4935 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4936 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4937 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4938 show_one_map_register_state_reply) \
4939 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
4940 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4941 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4942 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4943 _(POLICER_DETAILS, policer_details) \
4944 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4945 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4946 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4947 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4948 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4949 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4950 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4951 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4952 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4953 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4954 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4955 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4956 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4957 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4958 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4959 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4960 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4961 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4962 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4963 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4964 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4965 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4966 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4967 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4968 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4969 ip_source_and_port_range_check_add_del_reply) \
4970 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4971 ip_source_and_port_range_check_interface_add_del_reply) \
4972 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4973 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4974 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4975 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4976 _(PUNT_REPLY, punt_reply) \
4977 _(IP_FIB_DETAILS, ip_fib_details) \
4978 _(IP6_FIB_DETAILS, ip6_fib_details) \
4979 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4980 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4981 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4982 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4983 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4984 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
4985 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
4986 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
4987 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
4988 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply)
4990 #define foreach_standalone_reply_msg \
4991 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4992 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
4993 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
4994 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4995 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4996 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4997 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5006 #define STR_VTR_OP_CASE(op) \
5007 case L2_VTR_ ## op: \
5011 str_vtr_op (u32 vtr_op)
5015 STR_VTR_OP_CASE (DISABLED);
5016 STR_VTR_OP_CASE (PUSH_1);
5017 STR_VTR_OP_CASE (PUSH_2);
5018 STR_VTR_OP_CASE (POP_1);
5019 STR_VTR_OP_CASE (POP_2);
5020 STR_VTR_OP_CASE (TRANSLATE_1_1);
5021 STR_VTR_OP_CASE (TRANSLATE_1_2);
5022 STR_VTR_OP_CASE (TRANSLATE_2_1);
5023 STR_VTR_OP_CASE (TRANSLATE_2_2);
5030 dump_sub_interface_table (vat_main_t * vam)
5032 const sw_interface_subif_t *sub = NULL;
5034 if (vam->json_output)
5037 ("JSON output supported only for VPE API calls and dump_stats_table");
5042 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5043 "Interface", "sw_if_index",
5044 "sub id", "dot1ad", "tags", "outer id",
5045 "inner id", "exact", "default", "outer any", "inner any");
5047 vec_foreach (sub, vam->sw_if_subif_table)
5050 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5051 sub->interface_name,
5053 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5054 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5055 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5056 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5057 if (sub->vtr_op != L2_VTR_DISABLED)
5060 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5061 "tag1: %d tag2: %d ]",
5062 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5063 sub->vtr_tag1, sub->vtr_tag2);
5071 name_sort_cmp (void *a1, void *a2)
5073 name_sort_t *n1 = a1;
5074 name_sort_t *n2 = a2;
5076 return strcmp ((char *) n1->name, (char *) n2->name);
5080 dump_interface_table (vat_main_t * vam)
5083 name_sort_t *nses = 0, *ns;
5085 if (vam->json_output)
5088 ("JSON output supported only for VPE API calls and dump_stats_table");
5093 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5095 vec_add2 (nses, ns, 1);
5096 ns->name = (u8 *)(p->key);
5097 ns->value = (u32) p->value[0];
5101 vec_sort_with_function (nses, name_sort_cmp);
5103 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5104 vec_foreach (ns, nses)
5106 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5113 dump_ip_table (vat_main_t * vam, int is_ipv6)
5115 const ip_details_t *det = NULL;
5116 const ip_address_details_t *address = NULL;
5119 print (vam->ofp, "%-12s", "sw_if_index");
5121 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5128 print (vam->ofp, "%-12d", i);
5129 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5134 vec_foreach (address, det->addr)
5138 is_ipv6 ? format_ip6_address : format_ip4_address,
5139 address->ip, address->prefix_length);
5147 dump_ipv4_table (vat_main_t * vam)
5149 if (vam->json_output)
5152 ("JSON output supported only for VPE API calls and dump_stats_table");
5156 return dump_ip_table (vam, 0);
5160 dump_ipv6_table (vat_main_t * vam)
5162 if (vam->json_output)
5165 ("JSON output supported only for VPE API calls and dump_stats_table");
5169 return dump_ip_table (vam, 1);
5173 counter_type_to_str (u8 counter_type, u8 is_combined)
5177 switch (counter_type)
5179 case VNET_INTERFACE_COUNTER_DROP:
5181 case VNET_INTERFACE_COUNTER_PUNT:
5183 case VNET_INTERFACE_COUNTER_IP4:
5185 case VNET_INTERFACE_COUNTER_IP6:
5187 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5189 case VNET_INTERFACE_COUNTER_RX_MISS:
5191 case VNET_INTERFACE_COUNTER_RX_ERROR:
5193 case VNET_INTERFACE_COUNTER_TX_ERROR:
5196 return "INVALID-COUNTER-TYPE";
5201 switch (counter_type)
5203 case VNET_INTERFACE_COUNTER_RX:
5205 case VNET_INTERFACE_COUNTER_TX:
5208 return "INVALID-COUNTER-TYPE";
5214 dump_stats_table (vat_main_t * vam)
5216 vat_json_node_t node;
5217 vat_json_node_t *msg_array;
5218 vat_json_node_t *msg;
5219 vat_json_node_t *counter_array;
5220 vat_json_node_t *counter;
5221 interface_counter_t c;
5223 ip4_fib_counter_t *c4;
5224 ip6_fib_counter_t *c6;
5225 ip4_nbr_counter_t *n4;
5226 ip6_nbr_counter_t *n6;
5229 if (!vam->json_output)
5231 clib_warning ("dump_stats_table supported only in JSON format");
5235 vat_json_init_object (&node);
5237 /* interface counters */
5238 msg_array = vat_json_object_add (&node, "interface_counters");
5239 vat_json_init_array (msg_array);
5240 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5242 msg = vat_json_array_add (msg_array);
5243 vat_json_init_object (msg);
5244 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5245 (u8 *) counter_type_to_str (i, 0));
5246 vat_json_object_add_int (msg, "is_combined", 0);
5247 counter_array = vat_json_object_add (msg, "data");
5248 vat_json_init_array (counter_array);
5249 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5251 packets = vam->simple_interface_counters[i][j];
5252 vat_json_array_add_uint (counter_array, packets);
5255 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5257 msg = vat_json_array_add (msg_array);
5258 vat_json_init_object (msg);
5259 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5260 (u8 *) counter_type_to_str (i, 1));
5261 vat_json_object_add_int (msg, "is_combined", 1);
5262 counter_array = vat_json_object_add (msg, "data");
5263 vat_json_init_array (counter_array);
5264 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5266 c = vam->combined_interface_counters[i][j];
5267 counter = vat_json_array_add (counter_array);
5268 vat_json_init_object (counter);
5269 vat_json_object_add_uint (counter, "packets", c.packets);
5270 vat_json_object_add_uint (counter, "bytes", c.bytes);
5274 /* ip4 fib counters */
5275 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5276 vat_json_init_array (msg_array);
5277 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5279 msg = vat_json_array_add (msg_array);
5280 vat_json_init_object (msg);
5281 vat_json_object_add_uint (msg, "vrf_id",
5282 vam->ip4_fib_counters_vrf_id_by_index[i]);
5283 counter_array = vat_json_object_add (msg, "c");
5284 vat_json_init_array (counter_array);
5285 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5287 counter = vat_json_array_add (counter_array);
5288 vat_json_init_object (counter);
5289 c4 = &vam->ip4_fib_counters[i][j];
5290 vat_json_object_add_ip4 (counter, "address", c4->address);
5291 vat_json_object_add_uint (counter, "address_length",
5292 c4->address_length);
5293 vat_json_object_add_uint (counter, "packets", c4->packets);
5294 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5298 /* ip6 fib counters */
5299 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5300 vat_json_init_array (msg_array);
5301 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5303 msg = vat_json_array_add (msg_array);
5304 vat_json_init_object (msg);
5305 vat_json_object_add_uint (msg, "vrf_id",
5306 vam->ip6_fib_counters_vrf_id_by_index[i]);
5307 counter_array = vat_json_object_add (msg, "c");
5308 vat_json_init_array (counter_array);
5309 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5311 counter = vat_json_array_add (counter_array);
5312 vat_json_init_object (counter);
5313 c6 = &vam->ip6_fib_counters[i][j];
5314 vat_json_object_add_ip6 (counter, "address", c6->address);
5315 vat_json_object_add_uint (counter, "address_length",
5316 c6->address_length);
5317 vat_json_object_add_uint (counter, "packets", c6->packets);
5318 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5322 /* ip4 nbr counters */
5323 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5324 vat_json_init_array (msg_array);
5325 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5327 msg = vat_json_array_add (msg_array);
5328 vat_json_init_object (msg);
5329 vat_json_object_add_uint (msg, "sw_if_index", i);
5330 counter_array = vat_json_object_add (msg, "c");
5331 vat_json_init_array (counter_array);
5332 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5334 counter = vat_json_array_add (counter_array);
5335 vat_json_init_object (counter);
5336 n4 = &vam->ip4_nbr_counters[i][j];
5337 vat_json_object_add_ip4 (counter, "address", n4->address);
5338 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5339 vat_json_object_add_uint (counter, "packets", n4->packets);
5340 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5344 /* ip6 nbr counters */
5345 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5346 vat_json_init_array (msg_array);
5347 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5349 msg = vat_json_array_add (msg_array);
5350 vat_json_init_object (msg);
5351 vat_json_object_add_uint (msg, "sw_if_index", i);
5352 counter_array = vat_json_object_add (msg, "c");
5353 vat_json_init_array (counter_array);
5354 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5356 counter = vat_json_array_add (counter_array);
5357 vat_json_init_object (counter);
5358 n6 = &vam->ip6_nbr_counters[i][j];
5359 vat_json_object_add_ip6 (counter, "address", n6->address);
5360 vat_json_object_add_uint (counter, "packets", n6->packets);
5361 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5365 vat_json_print (vam->ofp, &node);
5366 vat_json_free (&node);
5372 exec (vat_main_t * vam)
5374 api_main_t *am = &api_main;
5379 unformat_input_t *i = vam->input;
5381 if (vec_len (i->buffer) == 0)
5384 if (vam->exec_mode == 0 && unformat (i, "mode"))
5389 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5399 * Copy cmd into shared memory.
5400 * In order for the CLI command to work, it
5401 * must be a vector ending in \n, not a C-string ending
5404 pthread_mutex_lock (&am->vlib_rp->mutex);
5405 oldheap = svm_push_data_heap (am->vlib_rp);
5407 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
5408 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
5410 svm_pop_heap (oldheap);
5411 pthread_mutex_unlock (&am->vlib_rp->mutex);
5413 mp->cmd_in_shmem = pointer_to_uword (cmd);
5415 timeout = vat_time_now (vam) + 10.0;
5417 while (vat_time_now (vam) < timeout)
5419 if (vam->result_ready == 1)
5422 if (vam->shmem_result != NULL)
5423 print (vam->ofp, "%s", vam->shmem_result);
5424 pthread_mutex_lock (&am->vlib_rp->mutex);
5425 oldheap = svm_push_data_heap (am->vlib_rp);
5427 free_me = (u8 *) vam->shmem_result;
5430 svm_pop_heap (oldheap);
5431 pthread_mutex_unlock (&am->vlib_rp->mutex);
5439 * Future replacement of exec() that passes CLI buffers directly in
5440 * the API messages instead of an additional shared memory area.
5443 exec_inband (vat_main_t * vam)
5445 vl_api_cli_inband_t *mp;
5446 unformat_input_t *i = vam->input;
5449 if (vec_len (i->buffer) == 0)
5452 if (vam->exec_mode == 0 && unformat (i, "mode"))
5457 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5464 * In order for the CLI command to work, it
5465 * must be a vector ending in \n, not a C-string ending
5468 u32 len = vec_len (vam->input->buffer);
5469 M2 (CLI_INBAND, mp, len);
5470 clib_memcpy (mp->cmd, vam->input->buffer, len);
5471 mp->length = htonl (len);
5474 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
5479 api_create_loopback (vat_main_t * vam)
5481 unformat_input_t *i = vam->input;
5482 vl_api_create_loopback_t *mp;
5483 vl_api_create_loopback_instance_t *mp_lbi;
5486 u8 is_specified = 0;
5487 u32 user_instance = 0;
5490 memset (mac_address, 0, sizeof (mac_address));
5492 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5494 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5496 if (unformat (i, "instance %d", &user_instance))
5504 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5505 mp_lbi->is_specified = is_specified;
5507 mp_lbi->user_instance = htonl (user_instance);
5509 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5514 /* Construct the API message */
5515 M (CREATE_LOOPBACK, mp);
5517 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5526 api_delete_loopback (vat_main_t * vam)
5528 unformat_input_t *i = vam->input;
5529 vl_api_delete_loopback_t *mp;
5530 u32 sw_if_index = ~0;
5533 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5535 if (unformat (i, "sw_if_index %d", &sw_if_index))
5541 if (sw_if_index == ~0)
5543 errmsg ("missing sw_if_index");
5547 /* Construct the API message */
5548 M (DELETE_LOOPBACK, mp);
5549 mp->sw_if_index = ntohl (sw_if_index);
5557 api_want_stats (vat_main_t * vam)
5559 unformat_input_t *i = vam->input;
5560 vl_api_want_stats_t *mp;
5564 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5566 if (unformat (i, "enable"))
5568 else if (unformat (i, "disable"))
5576 errmsg ("missing enable|disable");
5581 mp->enable_disable = enable;
5589 api_want_interface_events (vat_main_t * vam)
5591 unformat_input_t *i = vam->input;
5592 vl_api_want_interface_events_t *mp;
5596 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5598 if (unformat (i, "enable"))
5600 else if (unformat (i, "disable"))
5608 errmsg ("missing enable|disable");
5612 M (WANT_INTERFACE_EVENTS, mp);
5613 mp->enable_disable = enable;
5615 vam->interface_event_display = enable;
5623 /* Note: non-static, called once to set up the initial intfc table */
5625 api_sw_interface_dump (vat_main_t * vam)
5627 vl_api_sw_interface_dump_t *mp;
5628 vl_api_control_ping_t *mp_ping;
5630 name_sort_t *nses = 0, *ns;
5631 sw_interface_subif_t *sub = NULL;
5634 /* Toss the old name table */
5636 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5638 vec_add2 (nses, ns, 1);
5639 ns->name = (u8 *)(p->key);
5640 ns->value = (u32) p->value[0];
5644 hash_free (vam->sw_if_index_by_interface_name);
5646 vec_foreach (ns, nses) vec_free (ns->name);
5650 vec_foreach (sub, vam->sw_if_subif_table)
5652 vec_free (sub->interface_name);
5654 vec_free (vam->sw_if_subif_table);
5656 /* recreate the interface name hash table */
5657 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5659 /* Get list of ethernets */
5660 M (SW_INTERFACE_DUMP, mp);
5661 mp->name_filter_valid = 1;
5662 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
5665 /* and local / loopback interfaces */
5666 M (SW_INTERFACE_DUMP, mp);
5667 mp->name_filter_valid = 1;
5668 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
5671 /* and packet-generator interfaces */
5672 M (SW_INTERFACE_DUMP, mp);
5673 mp->name_filter_valid = 1;
5674 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
5677 /* and vxlan-gpe tunnel interfaces */
5678 M (SW_INTERFACE_DUMP, mp);
5679 mp->name_filter_valid = 1;
5680 strncpy ((char *) mp->name_filter, "vxlan_gpe",
5681 sizeof (mp->name_filter) - 1);
5684 /* and vxlan tunnel interfaces */
5685 M (SW_INTERFACE_DUMP, mp);
5686 mp->name_filter_valid = 1;
5687 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
5690 /* and host (af_packet) interfaces */
5691 M (SW_INTERFACE_DUMP, mp);
5692 mp->name_filter_valid = 1;
5693 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
5696 /* and l2tpv3 tunnel interfaces */
5697 M (SW_INTERFACE_DUMP, mp);
5698 mp->name_filter_valid = 1;
5699 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
5700 sizeof (mp->name_filter) - 1);
5703 /* and GRE tunnel interfaces */
5704 M (SW_INTERFACE_DUMP, mp);
5705 mp->name_filter_valid = 1;
5706 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
5709 /* and LISP-GPE interfaces */
5710 M (SW_INTERFACE_DUMP, mp);
5711 mp->name_filter_valid = 1;
5712 strncpy ((char *) mp->name_filter, "lisp_gpe",
5713 sizeof (mp->name_filter) - 1);
5716 /* and IPSEC tunnel interfaces */
5717 M (SW_INTERFACE_DUMP, mp);
5718 mp->name_filter_valid = 1;
5719 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
5722 /* Use a control ping for synchronization */
5723 M (CONTROL_PING, mp_ping);
5731 api_sw_interface_set_flags (vat_main_t * vam)
5733 unformat_input_t *i = vam->input;
5734 vl_api_sw_interface_set_flags_t *mp;
5736 u8 sw_if_index_set = 0;
5737 u8 admin_up = 0, link_up = 0;
5740 /* Parse args required to build the message */
5741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5743 if (unformat (i, "admin-up"))
5745 else if (unformat (i, "admin-down"))
5747 else if (unformat (i, "link-up"))
5749 else if (unformat (i, "link-down"))
5752 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5753 sw_if_index_set = 1;
5754 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5755 sw_if_index_set = 1;
5760 if (sw_if_index_set == 0)
5762 errmsg ("missing interface name or sw_if_index");
5766 /* Construct the API message */
5767 M (SW_INTERFACE_SET_FLAGS, mp);
5768 mp->sw_if_index = ntohl (sw_if_index);
5769 mp->admin_up_down = admin_up;
5770 mp->link_up_down = link_up;
5775 /* Wait for a reply, return the good/bad news... */
5781 api_sw_interface_clear_stats (vat_main_t * vam)
5783 unformat_input_t *i = vam->input;
5784 vl_api_sw_interface_clear_stats_t *mp;
5786 u8 sw_if_index_set = 0;
5789 /* Parse args required to build the message */
5790 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5792 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5793 sw_if_index_set = 1;
5794 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5795 sw_if_index_set = 1;
5800 /* Construct the API message */
5801 M (SW_INTERFACE_CLEAR_STATS, mp);
5803 if (sw_if_index_set == 1)
5804 mp->sw_if_index = ntohl (sw_if_index);
5806 mp->sw_if_index = ~0;
5811 /* Wait for a reply, return the good/bad news... */
5817 api_sw_interface_add_del_address (vat_main_t * vam)
5819 unformat_input_t *i = vam->input;
5820 vl_api_sw_interface_add_del_address_t *mp;
5822 u8 sw_if_index_set = 0;
5823 u8 is_add = 1, del_all = 0;
5824 u32 address_length = 0;
5825 u8 v4_address_set = 0;
5826 u8 v6_address_set = 0;
5827 ip4_address_t v4address;
5828 ip6_address_t v6address;
5831 /* Parse args required to build the message */
5832 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5834 if (unformat (i, "del-all"))
5836 else if (unformat (i, "del"))
5839 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5840 sw_if_index_set = 1;
5841 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5842 sw_if_index_set = 1;
5843 else if (unformat (i, "%U/%d",
5844 unformat_ip4_address, &v4address, &address_length))
5846 else if (unformat (i, "%U/%d",
5847 unformat_ip6_address, &v6address, &address_length))
5853 if (sw_if_index_set == 0)
5855 errmsg ("missing interface name or sw_if_index");
5858 if (v4_address_set && v6_address_set)
5860 errmsg ("both v4 and v6 addresses set");
5863 if (!v4_address_set && !v6_address_set && !del_all)
5865 errmsg ("no addresses set");
5869 /* Construct the API message */
5870 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5872 mp->sw_if_index = ntohl (sw_if_index);
5873 mp->is_add = is_add;
5874 mp->del_all = del_all;
5878 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5882 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5884 mp->address_length = address_length;
5889 /* Wait for a reply, return good/bad news */
5895 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5897 unformat_input_t *i = vam->input;
5898 vl_api_sw_interface_set_mpls_enable_t *mp;
5900 u8 sw_if_index_set = 0;
5904 /* Parse args required to build the message */
5905 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5907 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5908 sw_if_index_set = 1;
5909 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5910 sw_if_index_set = 1;
5911 else if (unformat (i, "disable"))
5913 else if (unformat (i, "dis"))
5919 if (sw_if_index_set == 0)
5921 errmsg ("missing interface name or sw_if_index");
5925 /* Construct the API message */
5926 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5928 mp->sw_if_index = ntohl (sw_if_index);
5929 mp->enable = enable;
5934 /* Wait for a reply... */
5940 api_sw_interface_set_table (vat_main_t * vam)
5942 unformat_input_t *i = vam->input;
5943 vl_api_sw_interface_set_table_t *mp;
5944 u32 sw_if_index, vrf_id = 0;
5945 u8 sw_if_index_set = 0;
5949 /* Parse args required to build the message */
5950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5952 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5953 sw_if_index_set = 1;
5954 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5955 sw_if_index_set = 1;
5956 else if (unformat (i, "vrf %d", &vrf_id))
5958 else if (unformat (i, "ipv6"))
5964 if (sw_if_index_set == 0)
5966 errmsg ("missing interface name or sw_if_index");
5970 /* Construct the API message */
5971 M (SW_INTERFACE_SET_TABLE, mp);
5973 mp->sw_if_index = ntohl (sw_if_index);
5974 mp->is_ipv6 = is_ipv6;
5975 mp->vrf_id = ntohl (vrf_id);
5980 /* Wait for a reply... */
5985 static void vl_api_sw_interface_get_table_reply_t_handler
5986 (vl_api_sw_interface_get_table_reply_t * mp)
5988 vat_main_t *vam = &vat_main;
5990 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5992 vam->retval = ntohl (mp->retval);
5993 vam->result_ready = 1;
5997 static void vl_api_sw_interface_get_table_reply_t_handler_json
5998 (vl_api_sw_interface_get_table_reply_t * mp)
6000 vat_main_t *vam = &vat_main;
6001 vat_json_node_t node;
6003 vat_json_init_object (&node);
6004 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6005 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6007 vat_json_print (vam->ofp, &node);
6008 vat_json_free (&node);
6010 vam->retval = ntohl (mp->retval);
6011 vam->result_ready = 1;
6015 api_sw_interface_get_table (vat_main_t * vam)
6017 unformat_input_t *i = vam->input;
6018 vl_api_sw_interface_get_table_t *mp;
6020 u8 sw_if_index_set = 0;
6024 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6026 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6027 sw_if_index_set = 1;
6028 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6029 sw_if_index_set = 1;
6030 else if (unformat (i, "ipv6"))
6036 if (sw_if_index_set == 0)
6038 errmsg ("missing interface name or sw_if_index");
6042 M (SW_INTERFACE_GET_TABLE, mp);
6043 mp->sw_if_index = htonl (sw_if_index);
6044 mp->is_ipv6 = is_ipv6;
6052 api_sw_interface_set_vpath (vat_main_t * vam)
6054 unformat_input_t *i = vam->input;
6055 vl_api_sw_interface_set_vpath_t *mp;
6056 u32 sw_if_index = 0;
6057 u8 sw_if_index_set = 0;
6061 /* Parse args required to build the message */
6062 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6064 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6065 sw_if_index_set = 1;
6066 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6067 sw_if_index_set = 1;
6068 else if (unformat (i, "enable"))
6070 else if (unformat (i, "disable"))
6076 if (sw_if_index_set == 0)
6078 errmsg ("missing interface name or sw_if_index");
6082 /* Construct the API message */
6083 M (SW_INTERFACE_SET_VPATH, mp);
6085 mp->sw_if_index = ntohl (sw_if_index);
6086 mp->enable = is_enable;
6091 /* Wait for a reply... */
6097 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6099 unformat_input_t *i = vam->input;
6100 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6101 u32 sw_if_index = 0;
6102 u8 sw_if_index_set = 0;
6107 /* Parse args required to build the message */
6108 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6110 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6111 sw_if_index_set = 1;
6112 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6113 sw_if_index_set = 1;
6114 else if (unformat (i, "enable"))
6116 else if (unformat (i, "disable"))
6118 else if (unformat (i, "ip4"))
6120 else if (unformat (i, "ip6"))
6126 if (sw_if_index_set == 0)
6128 errmsg ("missing interface name or sw_if_index");
6132 /* Construct the API message */
6133 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6135 mp->sw_if_index = ntohl (sw_if_index);
6136 mp->enable = is_enable;
6137 mp->is_ipv6 = is_ipv6;
6142 /* Wait for a reply... */
6149 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6151 unformat_input_t *i = vam->input;
6152 vl_api_sw_interface_set_l2_xconnect_t *mp;
6154 u8 rx_sw_if_index_set = 0;
6156 u8 tx_sw_if_index_set = 0;
6160 /* Parse args required to build the message */
6161 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6163 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6164 rx_sw_if_index_set = 1;
6165 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6166 tx_sw_if_index_set = 1;
6167 else if (unformat (i, "rx"))
6169 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6171 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6173 rx_sw_if_index_set = 1;
6178 else if (unformat (i, "tx"))
6180 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6182 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6184 tx_sw_if_index_set = 1;
6189 else if (unformat (i, "enable"))
6191 else if (unformat (i, "disable"))
6197 if (rx_sw_if_index_set == 0)
6199 errmsg ("missing rx interface name or rx_sw_if_index");
6203 if (enable && (tx_sw_if_index_set == 0))
6205 errmsg ("missing tx interface name or tx_sw_if_index");
6209 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6211 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6212 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6213 mp->enable = enable;
6221 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6223 unformat_input_t *i = vam->input;
6224 vl_api_sw_interface_set_l2_bridge_t *mp;
6226 u8 rx_sw_if_index_set = 0;
6234 /* Parse args required to build the message */
6235 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6237 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6238 rx_sw_if_index_set = 1;
6239 else if (unformat (i, "bd_id %d", &bd_id))
6243 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6244 rx_sw_if_index_set = 1;
6245 else if (unformat (i, "shg %d", &shg))
6247 else if (unformat (i, "bvi"))
6249 else if (unformat (i, "enable"))
6251 else if (unformat (i, "disable"))
6257 if (rx_sw_if_index_set == 0)
6259 errmsg ("missing rx interface name or sw_if_index");
6263 if (enable && (bd_id_set == 0))
6265 errmsg ("missing bridge domain");
6269 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6271 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6272 mp->bd_id = ntohl (bd_id);
6275 mp->enable = enable;
6283 api_bridge_domain_dump (vat_main_t * vam)
6285 unformat_input_t *i = vam->input;
6286 vl_api_bridge_domain_dump_t *mp;
6287 vl_api_control_ping_t *mp_ping;
6291 /* Parse args required to build the message */
6292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6294 if (unformat (i, "bd_id %d", &bd_id))
6300 M (BRIDGE_DOMAIN_DUMP, mp);
6301 mp->bd_id = ntohl (bd_id);
6304 /* Use a control ping for synchronization */
6305 M (CONTROL_PING, mp_ping);
6313 api_bridge_domain_add_del (vat_main_t * vam)
6315 unformat_input_t *i = vam->input;
6316 vl_api_bridge_domain_add_del_t *mp;
6319 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6323 /* Parse args required to build the message */
6324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6326 if (unformat (i, "bd_id %d", &bd_id))
6328 else if (unformat (i, "flood %d", &flood))
6330 else if (unformat (i, "uu-flood %d", &uu_flood))
6332 else if (unformat (i, "forward %d", &forward))
6334 else if (unformat (i, "learn %d", &learn))
6336 else if (unformat (i, "arp-term %d", &arp_term))
6338 else if (unformat (i, "mac-age %d", &mac_age))
6340 else if (unformat (i, "del"))
6343 flood = uu_flood = forward = learn = 0;
6351 errmsg ("missing bridge domain");
6357 errmsg ("mac age must be less than 256 ");
6361 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6363 mp->bd_id = ntohl (bd_id);
6365 mp->uu_flood = uu_flood;
6366 mp->forward = forward;
6368 mp->arp_term = arp_term;
6369 mp->is_add = is_add;
6370 mp->mac_age = (u8) mac_age;
6378 api_l2fib_flush_bd (vat_main_t * vam)
6380 unformat_input_t *i = vam->input;
6381 vl_api_l2fib_flush_bd_t *mp;
6385 /* Parse args required to build the message */
6386 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6388 if (unformat (i, "bd_id %d", &bd_id));
6395 errmsg ("missing bridge domain");
6399 M (L2FIB_FLUSH_BD, mp);
6401 mp->bd_id = htonl (bd_id);
6409 api_l2fib_flush_int (vat_main_t * vam)
6411 unformat_input_t *i = vam->input;
6412 vl_api_l2fib_flush_int_t *mp;
6413 u32 sw_if_index = ~0;
6416 /* Parse args required to build the message */
6417 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6419 if (unformat (i, "sw_if_index %d", &sw_if_index));
6421 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6426 if (sw_if_index == ~0)
6428 errmsg ("missing interface name or sw_if_index");
6432 M (L2FIB_FLUSH_INT, mp);
6434 mp->sw_if_index = ntohl (sw_if_index);
6442 api_l2fib_add_del (vat_main_t * vam)
6444 unformat_input_t *i = vam->input;
6445 vl_api_l2fib_add_del_t *mp;
6451 u32 sw_if_index = ~0;
6452 u8 sw_if_index_set = 0;
6461 /* Parse args required to build the message */
6462 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6464 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6466 else if (unformat (i, "bd_id %d", &bd_id))
6468 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6469 sw_if_index_set = 1;
6470 else if (unformat (i, "sw_if"))
6472 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6475 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6476 sw_if_index_set = 1;
6481 else if (unformat (i, "static"))
6483 else if (unformat (i, "filter"))
6488 else if (unformat (i, "bvi"))
6493 else if (unformat (i, "del"))
6495 else if (unformat (i, "count %d", &count))
6503 errmsg ("missing mac address");
6509 errmsg ("missing bridge domain");
6513 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6515 errmsg ("missing interface name or sw_if_index");
6521 /* Turn on async mode */
6522 vam->async_mode = 1;
6523 vam->async_errors = 0;
6524 before = vat_time_now (vam);
6527 for (j = 0; j < count; j++)
6529 M (L2FIB_ADD_DEL, mp);
6532 mp->bd_id = ntohl (bd_id);
6533 mp->is_add = is_add;
6537 mp->sw_if_index = ntohl (sw_if_index);
6538 mp->static_mac = static_mac;
6539 mp->filter_mac = filter_mac;
6540 mp->bvi_mac = bvi_mac;
6542 increment_mac_address (&mac);
6549 vl_api_control_ping_t *mp_ping;
6552 /* Shut off async mode */
6553 vam->async_mode = 0;
6555 M (CONTROL_PING, mp_ping);
6558 timeout = vat_time_now (vam) + 1.0;
6559 while (vat_time_now (vam) < timeout)
6560 if (vam->result_ready == 1)
6565 if (vam->retval == -99)
6568 if (vam->async_errors > 0)
6570 errmsg ("%d asynchronous errors", vam->async_errors);
6573 vam->async_errors = 0;
6574 after = vat_time_now (vam);
6576 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6577 count, after - before, count / (after - before));
6583 /* Wait for a reply... */
6587 /* Return the good/bad news */
6588 return (vam->retval);
6592 api_bridge_domain_set_mac_age (vat_main_t * vam)
6594 unformat_input_t *i = vam->input;
6595 vl_api_bridge_domain_set_mac_age_t *mp;
6600 /* Parse args required to build the message */
6601 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6603 if (unformat (i, "bd_id %d", &bd_id));
6604 else if (unformat (i, "mac-age %d", &mac_age));
6611 errmsg ("missing bridge domain");
6617 errmsg ("mac age must be less than 256 ");
6621 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6623 mp->bd_id = htonl (bd_id);
6624 mp->mac_age = (u8) mac_age;
6632 api_l2_flags (vat_main_t * vam)
6634 unformat_input_t *i = vam->input;
6635 vl_api_l2_flags_t *mp;
6638 u8 sw_if_index_set = 0;
6642 /* Parse args required to build the message */
6643 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6645 if (unformat (i, "sw_if_index %d", &sw_if_index))
6646 sw_if_index_set = 1;
6647 else if (unformat (i, "sw_if"))
6649 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6652 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6653 sw_if_index_set = 1;
6658 else if (unformat (i, "learn"))
6660 else if (unformat (i, "forward"))
6662 else if (unformat (i, "flood"))
6664 else if (unformat (i, "uu-flood"))
6665 flags |= L2_UU_FLOOD;
6666 else if (unformat (i, "arp-term"))
6667 flags |= L2_ARP_TERM;
6668 else if (unformat (i, "off"))
6670 else if (unformat (i, "disable"))
6676 if (sw_if_index_set == 0)
6678 errmsg ("missing interface name or sw_if_index");
6684 mp->sw_if_index = ntohl (sw_if_index);
6685 mp->feature_bitmap = ntohl (flags);
6686 mp->is_set = is_set;
6694 api_bridge_flags (vat_main_t * vam)
6696 unformat_input_t *i = vam->input;
6697 vl_api_bridge_flags_t *mp;
6704 /* Parse args required to build the message */
6705 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6707 if (unformat (i, "bd_id %d", &bd_id))
6709 else if (unformat (i, "learn"))
6711 else if (unformat (i, "forward"))
6713 else if (unformat (i, "flood"))
6715 else if (unformat (i, "uu-flood"))
6716 flags |= L2_UU_FLOOD;
6717 else if (unformat (i, "arp-term"))
6718 flags |= L2_ARP_TERM;
6719 else if (unformat (i, "off"))
6721 else if (unformat (i, "disable"))
6729 errmsg ("missing bridge domain");
6733 M (BRIDGE_FLAGS, mp);
6735 mp->bd_id = ntohl (bd_id);
6736 mp->feature_bitmap = ntohl (flags);
6737 mp->is_set = is_set;
6745 api_bd_ip_mac_add_del (vat_main_t * vam)
6747 unformat_input_t *i = vam->input;
6748 vl_api_bd_ip_mac_add_del_t *mp;
6755 ip4_address_t v4addr;
6756 ip6_address_t v6addr;
6761 /* Parse args required to build the message */
6762 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6764 if (unformat (i, "bd_id %d", &bd_id))
6768 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6772 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6777 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6781 else if (unformat (i, "del"))
6789 errmsg ("missing bridge domain");
6792 else if (ip_set == 0)
6794 errmsg ("missing IP address");
6797 else if (mac_set == 0)
6799 errmsg ("missing MAC address");
6803 M (BD_IP_MAC_ADD_DEL, mp);
6805 mp->bd_id = ntohl (bd_id);
6806 mp->is_ipv6 = is_ipv6;
6807 mp->is_add = is_add;
6809 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6811 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6812 clib_memcpy (mp->mac_address, macaddr, 6);
6819 api_tap_connect (vat_main_t * vam)
6821 unformat_input_t *i = vam->input;
6822 vl_api_tap_connect_t *mp;
6828 ip4_address_t ip4_address;
6830 int ip4_address_set = 0;
6831 ip6_address_t ip6_address;
6833 int ip6_address_set = 0;
6836 memset (mac_address, 0, sizeof (mac_address));
6838 /* Parse args required to build the message */
6839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6841 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6845 else if (unformat (i, "random-mac"))
6847 else if (unformat (i, "tapname %s", &tap_name))
6849 else if (unformat (i, "tag %s", &tag))
6851 else if (unformat (i, "address %U/%d",
6852 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6853 ip4_address_set = 1;
6854 else if (unformat (i, "address %U/%d",
6855 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6856 ip6_address_set = 1;
6863 errmsg ("missing tap name");
6866 if (vec_len (tap_name) > 63)
6868 errmsg ("tap name too long");
6871 vec_add1 (tap_name, 0);
6873 if (vec_len (tag) > 63)
6875 errmsg ("tag too long");
6879 /* Construct the API message */
6880 M (TAP_CONNECT, mp);
6882 mp->use_random_mac = random_mac;
6883 clib_memcpy (mp->mac_address, mac_address, 6);
6884 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6886 clib_memcpy (mp->tag, tag, vec_len (tag));
6888 if (ip4_address_set)
6890 mp->ip4_address_set = 1;
6891 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6892 mp->ip4_mask_width = ip4_mask_width;
6894 if (ip6_address_set)
6896 mp->ip6_address_set = 1;
6897 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6898 mp->ip6_mask_width = ip6_mask_width;
6901 vec_free (tap_name);
6907 /* Wait for a reply... */
6913 api_tap_modify (vat_main_t * vam)
6915 unformat_input_t *i = vam->input;
6916 vl_api_tap_modify_t *mp;
6921 u32 sw_if_index = ~0;
6922 u8 sw_if_index_set = 0;
6925 memset (mac_address, 0, sizeof (mac_address));
6927 /* Parse args required to build the message */
6928 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6930 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6931 sw_if_index_set = 1;
6932 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6933 sw_if_index_set = 1;
6934 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6938 else if (unformat (i, "random-mac"))
6940 else if (unformat (i, "tapname %s", &tap_name))
6946 if (sw_if_index_set == 0)
6948 errmsg ("missing vpp interface name");
6953 errmsg ("missing tap name");
6956 if (vec_len (tap_name) > 63)
6958 errmsg ("tap name too long");
6960 vec_add1 (tap_name, 0);
6962 /* Construct the API message */
6965 mp->use_random_mac = random_mac;
6966 mp->sw_if_index = ntohl (sw_if_index);
6967 clib_memcpy (mp->mac_address, mac_address, 6);
6968 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6969 vec_free (tap_name);
6974 /* Wait for a reply... */
6980 api_tap_delete (vat_main_t * vam)
6982 unformat_input_t *i = vam->input;
6983 vl_api_tap_delete_t *mp;
6984 u32 sw_if_index = ~0;
6985 u8 sw_if_index_set = 0;
6988 /* Parse args required to build the message */
6989 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6991 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6992 sw_if_index_set = 1;
6993 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6994 sw_if_index_set = 1;
6999 if (sw_if_index_set == 0)
7001 errmsg ("missing vpp interface name");
7005 /* Construct the API message */
7008 mp->sw_if_index = ntohl (sw_if_index);
7013 /* Wait for a reply... */
7019 api_ip_add_del_route (vat_main_t * vam)
7021 unformat_input_t *i = vam->input;
7022 vl_api_ip_add_del_route_t *mp;
7023 u32 sw_if_index = ~0, vrf_id = 0;
7025 u8 is_local = 0, is_drop = 0;
7026 u8 is_unreach = 0, is_prohibit = 0;
7027 u8 create_vrf_if_needed = 0;
7029 u32 next_hop_weight = 1;
7031 u8 is_multipath = 0;
7033 u8 address_length_set = 0;
7034 u32 next_hop_table_id = 0;
7035 u32 resolve_attempts = 0;
7036 u32 dst_address_length = 0;
7037 u8 next_hop_set = 0;
7038 ip4_address_t v4_dst_address, v4_next_hop_address;
7039 ip6_address_t v6_dst_address, v6_next_hop_address;
7043 u32 random_add_del = 0;
7044 u32 *random_vector = 0;
7046 u32 random_seed = 0xdeaddabe;
7047 u32 classify_table_index = ~0;
7049 u8 resolve_host = 0, resolve_attached = 0;
7050 mpls_label_t *next_hop_out_label_stack = NULL;
7051 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7052 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7054 /* Parse args required to build the message */
7055 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7057 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7059 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7061 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
7066 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
7071 else if (unformat (i, "/%d", &dst_address_length))
7073 address_length_set = 1;
7076 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7077 &v4_next_hop_address))
7081 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7082 &v6_next_hop_address))
7086 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7088 else if (unformat (i, "weight %d", &next_hop_weight))
7090 else if (unformat (i, "drop"))
7094 else if (unformat (i, "null-send-unreach"))
7098 else if (unformat (i, "null-send-prohibit"))
7102 else if (unformat (i, "local"))
7106 else if (unformat (i, "classify %d", &classify_table_index))
7110 else if (unformat (i, "del"))
7112 else if (unformat (i, "add"))
7114 else if (unformat (i, "not-last"))
7116 else if (unformat (i, "resolve-via-host"))
7118 else if (unformat (i, "resolve-via-attached"))
7119 resolve_attached = 1;
7120 else if (unformat (i, "multipath"))
7122 else if (unformat (i, "vrf %d", &vrf_id))
7124 else if (unformat (i, "create-vrf"))
7125 create_vrf_if_needed = 1;
7126 else if (unformat (i, "count %d", &count))
7128 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7130 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7132 else if (unformat (i, "out-label %d", &next_hop_out_label))
7133 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7134 else if (unformat (i, "via-label %d", &next_hop_via_label))
7136 else if (unformat (i, "random"))
7138 else if (unformat (i, "seed %d", &random_seed))
7142 clib_warning ("parse error '%U'", format_unformat_error, i);
7147 if (!next_hop_set && !is_drop && !is_local &&
7148 !is_classify && !is_unreach && !is_prohibit &&
7149 MPLS_LABEL_INVALID == next_hop_via_label)
7152 ("next hop / local / drop / unreach / prohibit / classify not set");
7156 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7158 errmsg ("next hop and next-hop via label set");
7161 if (address_set == 0)
7163 errmsg ("missing addresses");
7167 if (address_length_set == 0)
7169 errmsg ("missing address length");
7173 /* Generate a pile of unique, random routes */
7176 u32 this_random_address;
7177 random_hash = hash_create (count, sizeof (uword));
7179 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7180 for (j = 0; j <= count; j++)
7184 this_random_address = random_u32 (&random_seed);
7185 this_random_address =
7186 clib_host_to_net_u32 (this_random_address);
7188 while (hash_get (random_hash, this_random_address));
7189 vec_add1 (random_vector, this_random_address);
7190 hash_set (random_hash, this_random_address, 1);
7192 hash_free (random_hash);
7193 v4_dst_address.as_u32 = random_vector[0];
7198 /* Turn on async mode */
7199 vam->async_mode = 1;
7200 vam->async_errors = 0;
7201 before = vat_time_now (vam);
7204 for (j = 0; j < count; j++)
7206 /* Construct the API message */
7207 M2 (IP_ADD_DEL_ROUTE, mp,
7208 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7210 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7211 mp->table_id = ntohl (vrf_id);
7212 mp->create_vrf_if_needed = create_vrf_if_needed;
7214 mp->is_add = is_add;
7215 mp->is_drop = is_drop;
7216 mp->is_unreach = is_unreach;
7217 mp->is_prohibit = is_prohibit;
7218 mp->is_ipv6 = is_ipv6;
7219 mp->is_local = is_local;
7220 mp->is_classify = is_classify;
7221 mp->is_multipath = is_multipath;
7222 mp->is_resolve_host = resolve_host;
7223 mp->is_resolve_attached = resolve_attached;
7224 mp->not_last = not_last;
7225 mp->next_hop_weight = next_hop_weight;
7226 mp->dst_address_length = dst_address_length;
7227 mp->next_hop_table_id = ntohl (next_hop_table_id);
7228 mp->classify_table_index = ntohl (classify_table_index);
7229 mp->next_hop_via_label = ntohl (next_hop_via_label);
7230 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7231 if (0 != mp->next_hop_n_out_labels)
7233 memcpy (mp->next_hop_out_label_stack,
7234 next_hop_out_label_stack,
7235 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7236 vec_free (next_hop_out_label_stack);
7241 clib_memcpy (mp->dst_address, &v6_dst_address,
7242 sizeof (v6_dst_address));
7244 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
7245 sizeof (v6_next_hop_address));
7246 increment_v6_address (&v6_dst_address);
7250 clib_memcpy (mp->dst_address, &v4_dst_address,
7251 sizeof (v4_dst_address));
7253 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
7254 sizeof (v4_next_hop_address));
7256 v4_dst_address.as_u32 = random_vector[j + 1];
7258 increment_v4_address (&v4_dst_address);
7262 /* If we receive SIGTERM, stop now... */
7267 /* When testing multiple add/del ops, use a control-ping to sync */
7270 vl_api_control_ping_t *mp_ping;
7274 /* Shut off async mode */
7275 vam->async_mode = 0;
7277 M (CONTROL_PING, mp_ping);
7280 timeout = vat_time_now (vam) + 1.0;
7281 while (vat_time_now (vam) < timeout)
7282 if (vam->result_ready == 1)
7287 if (vam->retval == -99)
7290 if (vam->async_errors > 0)
7292 errmsg ("%d asynchronous errors", vam->async_errors);
7295 vam->async_errors = 0;
7296 after = vat_time_now (vam);
7298 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7302 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7303 count, after - before, count / (after - before));
7309 /* Wait for a reply... */
7314 /* Return the good/bad news */
7315 return (vam->retval);
7319 api_ip_mroute_add_del (vat_main_t * vam)
7321 unformat_input_t *i = vam->input;
7322 vl_api_ip_mroute_add_del_t *mp;
7323 u32 sw_if_index = ~0, vrf_id = 0;
7326 u8 create_vrf_if_needed = 0;
7329 u32 grp_address_length = 0;
7330 ip4_address_t v4_grp_address, v4_src_address;
7331 ip6_address_t v6_grp_address, v6_src_address;
7332 mfib_itf_flags_t iflags = 0;
7333 mfib_entry_flags_t eflags = 0;
7336 /* Parse args required to build the message */
7337 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7339 if (unformat (i, "sw_if_index %d", &sw_if_index))
7341 else if (unformat (i, "%U %U",
7342 unformat_ip4_address, &v4_src_address,
7343 unformat_ip4_address, &v4_grp_address))
7345 grp_address_length = 64;
7349 else if (unformat (i, "%U %U",
7350 unformat_ip6_address, &v6_src_address,
7351 unformat_ip6_address, &v6_grp_address))
7353 grp_address_length = 256;
7357 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7359 memset (&v4_src_address, 0, sizeof (v4_src_address));
7360 grp_address_length = 32;
7364 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7366 memset (&v6_src_address, 0, sizeof (v6_src_address));
7367 grp_address_length = 128;
7371 else if (unformat (i, "/%d", &grp_address_length))
7373 else if (unformat (i, "local"))
7377 else if (unformat (i, "del"))
7379 else if (unformat (i, "add"))
7381 else if (unformat (i, "vrf %d", &vrf_id))
7383 else if (unformat (i, "create-vrf"))
7384 create_vrf_if_needed = 1;
7385 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7387 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7391 clib_warning ("parse error '%U'", format_unformat_error, i);
7396 if (address_set == 0)
7398 errmsg ("missing addresses\n");
7402 /* Construct the API message */
7403 M (IP_MROUTE_ADD_DEL, mp);
7405 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7406 mp->table_id = ntohl (vrf_id);
7407 mp->create_vrf_if_needed = create_vrf_if_needed;
7409 mp->is_add = is_add;
7410 mp->is_ipv6 = is_ipv6;
7411 mp->is_local = is_local;
7412 mp->itf_flags = ntohl (iflags);
7413 mp->entry_flags = ntohl (eflags);
7414 mp->grp_address_length = grp_address_length;
7415 mp->grp_address_length = ntohs (mp->grp_address_length);
7419 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7420 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7424 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7425 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7431 /* Wait for a reply... */
7437 api_mpls_route_add_del (vat_main_t * vam)
7439 unformat_input_t *i = vam->input;
7440 vl_api_mpls_route_add_del_t *mp;
7441 u32 sw_if_index = ~0, table_id = 0;
7442 u8 create_table_if_needed = 0;
7444 u32 next_hop_weight = 1;
7445 u8 is_multipath = 0;
7446 u32 next_hop_table_id = 0;
7447 u8 next_hop_set = 0;
7448 ip4_address_t v4_next_hop_address = {
7451 ip6_address_t v6_next_hop_address = { {0} };
7455 u32 classify_table_index = ~0;
7457 u8 resolve_host = 0, resolve_attached = 0;
7458 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7459 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7460 mpls_label_t *next_hop_out_label_stack = NULL;
7461 mpls_label_t local_label = MPLS_LABEL_INVALID;
7463 u8 next_hop_proto_is_ip4 = 1;
7465 /* Parse args required to build the message */
7466 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7468 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7470 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7472 else if (unformat (i, "%d", &local_label))
7474 else if (unformat (i, "eos"))
7476 else if (unformat (i, "non-eos"))
7478 else if (unformat (i, "via %U", unformat_ip4_address,
7479 &v4_next_hop_address))
7482 next_hop_proto_is_ip4 = 1;
7484 else if (unformat (i, "via %U", unformat_ip6_address,
7485 &v6_next_hop_address))
7488 next_hop_proto_is_ip4 = 0;
7490 else if (unformat (i, "weight %d", &next_hop_weight))
7492 else if (unformat (i, "create-table"))
7493 create_table_if_needed = 1;
7494 else if (unformat (i, "classify %d", &classify_table_index))
7498 else if (unformat (i, "del"))
7500 else if (unformat (i, "add"))
7502 else if (unformat (i, "resolve-via-host"))
7504 else if (unformat (i, "resolve-via-attached"))
7505 resolve_attached = 1;
7506 else if (unformat (i, "multipath"))
7508 else if (unformat (i, "count %d", &count))
7510 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
7513 next_hop_proto_is_ip4 = 1;
7515 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
7518 next_hop_proto_is_ip4 = 0;
7520 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7522 else if (unformat (i, "via-label %d", &next_hop_via_label))
7524 else if (unformat (i, "out-label %d", &next_hop_out_label))
7525 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7528 clib_warning ("parse error '%U'", format_unformat_error, i);
7533 if (!next_hop_set && !is_classify)
7535 errmsg ("next hop / classify not set");
7539 if (MPLS_LABEL_INVALID == local_label)
7541 errmsg ("missing label");
7547 /* Turn on async mode */
7548 vam->async_mode = 1;
7549 vam->async_errors = 0;
7550 before = vat_time_now (vam);
7553 for (j = 0; j < count; j++)
7555 /* Construct the API message */
7556 M2 (MPLS_ROUTE_ADD_DEL, mp,
7557 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7559 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
7560 mp->mr_table_id = ntohl (table_id);
7561 mp->mr_create_table_if_needed = create_table_if_needed;
7563 mp->mr_is_add = is_add;
7564 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7565 mp->mr_is_classify = is_classify;
7566 mp->mr_is_multipath = is_multipath;
7567 mp->mr_is_resolve_host = resolve_host;
7568 mp->mr_is_resolve_attached = resolve_attached;
7569 mp->mr_next_hop_weight = next_hop_weight;
7570 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
7571 mp->mr_classify_table_index = ntohl (classify_table_index);
7572 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
7573 mp->mr_label = ntohl (local_label);
7574 mp->mr_eos = is_eos;
7576 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7577 if (0 != mp->mr_next_hop_n_out_labels)
7579 memcpy (mp->mr_next_hop_out_label_stack,
7580 next_hop_out_label_stack,
7581 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7582 vec_free (next_hop_out_label_stack);
7587 if (next_hop_proto_is_ip4)
7589 clib_memcpy (mp->mr_next_hop,
7590 &v4_next_hop_address,
7591 sizeof (v4_next_hop_address));
7595 clib_memcpy (mp->mr_next_hop,
7596 &v6_next_hop_address,
7597 sizeof (v6_next_hop_address));
7604 /* If we receive SIGTERM, stop now... */
7609 /* When testing multiple add/del ops, use a control-ping to sync */
7612 vl_api_control_ping_t *mp_ping;
7616 /* Shut off async mode */
7617 vam->async_mode = 0;
7619 M (CONTROL_PING, mp_ping);
7622 timeout = vat_time_now (vam) + 1.0;
7623 while (vat_time_now (vam) < timeout)
7624 if (vam->result_ready == 1)
7629 if (vam->retval == -99)
7632 if (vam->async_errors > 0)
7634 errmsg ("%d asynchronous errors", vam->async_errors);
7637 vam->async_errors = 0;
7638 after = vat_time_now (vam);
7640 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7644 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7645 count, after - before, count / (after - before));
7651 /* Wait for a reply... */
7656 /* Return the good/bad news */
7657 return (vam->retval);
7661 api_mpls_ip_bind_unbind (vat_main_t * vam)
7663 unformat_input_t *i = vam->input;
7664 vl_api_mpls_ip_bind_unbind_t *mp;
7665 u32 ip_table_id = 0;
7666 u8 create_table_if_needed = 0;
7669 ip4_address_t v4_address;
7670 ip6_address_t v6_address;
7673 mpls_label_t local_label = MPLS_LABEL_INVALID;
7676 /* Parse args required to build the message */
7677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7679 if (unformat (i, "%U/%d", unformat_ip4_address,
7680 &v4_address, &address_length))
7685 else if (unformat (i, "%U/%d", unformat_ip6_address,
7686 &v6_address, &address_length))
7691 else if (unformat (i, "%d", &local_label))
7693 else if (unformat (i, "create-table"))
7694 create_table_if_needed = 1;
7695 else if (unformat (i, "table-id %d", &ip_table_id))
7697 else if (unformat (i, "unbind"))
7699 else if (unformat (i, "bind"))
7703 clib_warning ("parse error '%U'", format_unformat_error, i);
7710 errmsg ("IP addres not set");
7714 if (MPLS_LABEL_INVALID == local_label)
7716 errmsg ("missing label");
7720 /* Construct the API message */
7721 M (MPLS_IP_BIND_UNBIND, mp);
7723 mp->mb_create_table_if_needed = create_table_if_needed;
7724 mp->mb_is_bind = is_bind;
7725 mp->mb_is_ip4 = is_ip4;
7726 mp->mb_ip_table_id = ntohl (ip_table_id);
7727 mp->mb_mpls_table_id = 0;
7728 mp->mb_label = ntohl (local_label);
7729 mp->mb_address_length = address_length;
7732 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7734 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7739 /* Wait for a reply... */
7745 api_proxy_arp_add_del (vat_main_t * vam)
7747 unformat_input_t *i = vam->input;
7748 vl_api_proxy_arp_add_del_t *mp;
7751 ip4_address_t lo, hi;
7755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7757 if (unformat (i, "vrf %d", &vrf_id))
7759 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7760 unformat_ip4_address, &hi))
7762 else if (unformat (i, "del"))
7766 clib_warning ("parse error '%U'", format_unformat_error, i);
7773 errmsg ("address range not set");
7777 M (PROXY_ARP_ADD_DEL, mp);
7779 mp->vrf_id = ntohl (vrf_id);
7780 mp->is_add = is_add;
7781 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7782 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7790 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7792 unformat_input_t *i = vam->input;
7793 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7796 u8 sw_if_index_set = 0;
7799 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7801 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7802 sw_if_index_set = 1;
7803 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7804 sw_if_index_set = 1;
7805 else if (unformat (i, "enable"))
7807 else if (unformat (i, "disable"))
7811 clib_warning ("parse error '%U'", format_unformat_error, i);
7816 if (sw_if_index_set == 0)
7818 errmsg ("missing interface name or sw_if_index");
7822 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7824 mp->sw_if_index = ntohl (sw_if_index);
7825 mp->enable_disable = enable;
7833 api_mpls_tunnel_add_del (vat_main_t * vam)
7835 unformat_input_t *i = vam->input;
7836 vl_api_mpls_tunnel_add_del_t *mp;
7840 u32 sw_if_index = ~0;
7841 u32 next_hop_sw_if_index = ~0;
7842 u32 next_hop_proto_is_ip4 = 1;
7844 u32 next_hop_table_id = 0;
7845 ip4_address_t v4_next_hop_address = {
7848 ip6_address_t v6_next_hop_address = { {0} };
7849 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7852 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7854 if (unformat (i, "add"))
7856 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7858 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7860 else if (unformat (i, "via %U",
7861 unformat_ip4_address, &v4_next_hop_address))
7863 next_hop_proto_is_ip4 = 1;
7865 else if (unformat (i, "via %U",
7866 unformat_ip6_address, &v6_next_hop_address))
7868 next_hop_proto_is_ip4 = 0;
7870 else if (unformat (i, "l2-only"))
7872 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7874 else if (unformat (i, "out-label %d", &next_hop_out_label))
7875 vec_add1 (labels, ntohl (next_hop_out_label));
7878 clib_warning ("parse error '%U'", format_unformat_error, i);
7883 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7885 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7886 mp->mt_sw_if_index = ntohl (sw_if_index);
7887 mp->mt_is_add = is_add;
7888 mp->mt_l2_only = l2_only;
7889 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7890 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7892 mp->mt_next_hop_n_out_labels = vec_len (labels);
7894 if (0 != mp->mt_next_hop_n_out_labels)
7896 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7897 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7901 if (next_hop_proto_is_ip4)
7903 clib_memcpy (mp->mt_next_hop,
7904 &v4_next_hop_address, sizeof (v4_next_hop_address));
7908 clib_memcpy (mp->mt_next_hop,
7909 &v6_next_hop_address, sizeof (v6_next_hop_address));
7918 api_sw_interface_set_unnumbered (vat_main_t * vam)
7920 unformat_input_t *i = vam->input;
7921 vl_api_sw_interface_set_unnumbered_t *mp;
7923 u32 unnum_sw_index = ~0;
7925 u8 sw_if_index_set = 0;
7928 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7930 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7931 sw_if_index_set = 1;
7932 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7933 sw_if_index_set = 1;
7934 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7936 else if (unformat (i, "del"))
7940 clib_warning ("parse error '%U'", format_unformat_error, i);
7945 if (sw_if_index_set == 0)
7947 errmsg ("missing interface name or sw_if_index");
7951 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7953 mp->sw_if_index = ntohl (sw_if_index);
7954 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7955 mp->is_add = is_add;
7963 api_ip_neighbor_add_del (vat_main_t * vam)
7965 unformat_input_t *i = vam->input;
7966 vl_api_ip_neighbor_add_del_t *mp;
7968 u8 sw_if_index_set = 0;
7971 u8 is_no_fib_entry = 0;
7974 u8 v4_address_set = 0;
7975 u8 v6_address_set = 0;
7976 ip4_address_t v4address;
7977 ip6_address_t v6address;
7980 memset (mac_address, 0, sizeof (mac_address));
7982 /* Parse args required to build the message */
7983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7985 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7989 else if (unformat (i, "del"))
7992 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7993 sw_if_index_set = 1;
7994 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7995 sw_if_index_set = 1;
7996 else if (unformat (i, "is_static"))
7998 else if (unformat (i, "no-fib-entry"))
7999 is_no_fib_entry = 1;
8000 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
8002 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
8006 clib_warning ("parse error '%U'", format_unformat_error, i);
8011 if (sw_if_index_set == 0)
8013 errmsg ("missing interface name or sw_if_index");
8016 if (v4_address_set && v6_address_set)
8018 errmsg ("both v4 and v6 addresses set");
8021 if (!v4_address_set && !v6_address_set)
8023 errmsg ("no address set");
8027 /* Construct the API message */
8028 M (IP_NEIGHBOR_ADD_DEL, mp);
8030 mp->sw_if_index = ntohl (sw_if_index);
8031 mp->is_add = is_add;
8032 mp->is_static = is_static;
8033 mp->is_no_adj_fib = is_no_fib_entry;
8035 clib_memcpy (mp->mac_address, mac_address, 6);
8039 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
8043 /* mp->is_ipv6 = 0; via memset in M macro above */
8044 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
8050 /* Wait for a reply, return good/bad news */
8056 api_reset_vrf (vat_main_t * vam)
8058 unformat_input_t *i = vam->input;
8059 vl_api_reset_vrf_t *mp;
8065 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8067 if (unformat (i, "vrf %d", &vrf_id))
8069 else if (unformat (i, "ipv6"))
8073 clib_warning ("parse error '%U'", format_unformat_error, i);
8078 if (vrf_id_set == 0)
8080 errmsg ("missing vrf id");
8086 mp->vrf_id = ntohl (vrf_id);
8087 mp->is_ipv6 = is_ipv6;
8095 api_create_vlan_subif (vat_main_t * vam)
8097 unformat_input_t *i = vam->input;
8098 vl_api_create_vlan_subif_t *mp;
8100 u8 sw_if_index_set = 0;
8105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8107 if (unformat (i, "sw_if_index %d", &sw_if_index))
8108 sw_if_index_set = 1;
8110 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8111 sw_if_index_set = 1;
8112 else if (unformat (i, "vlan %d", &vlan_id))
8116 clib_warning ("parse error '%U'", format_unformat_error, i);
8121 if (sw_if_index_set == 0)
8123 errmsg ("missing interface name or sw_if_index");
8127 if (vlan_id_set == 0)
8129 errmsg ("missing vlan_id");
8132 M (CREATE_VLAN_SUBIF, mp);
8134 mp->sw_if_index = ntohl (sw_if_index);
8135 mp->vlan_id = ntohl (vlan_id);
8142 #define foreach_create_subif_bit \
8149 _(outer_vlan_id_any) \
8150 _(inner_vlan_id_any)
8153 api_create_subif (vat_main_t * vam)
8155 unformat_input_t *i = vam->input;
8156 vl_api_create_subif_t *mp;
8158 u8 sw_if_index_set = 0;
8165 u32 exact_match = 0;
8166 u32 default_sub = 0;
8167 u32 outer_vlan_id_any = 0;
8168 u32 inner_vlan_id_any = 0;
8170 u16 outer_vlan_id = 0;
8171 u16 inner_vlan_id = 0;
8174 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8176 if (unformat (i, "sw_if_index %d", &sw_if_index))
8177 sw_if_index_set = 1;
8179 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8180 sw_if_index_set = 1;
8181 else if (unformat (i, "sub_id %d", &sub_id))
8183 else if (unformat (i, "outer_vlan_id %d", &tmp))
8184 outer_vlan_id = tmp;
8185 else if (unformat (i, "inner_vlan_id %d", &tmp))
8186 inner_vlan_id = tmp;
8188 #define _(a) else if (unformat (i, #a)) a = 1 ;
8189 foreach_create_subif_bit
8193 clib_warning ("parse error '%U'", format_unformat_error, i);
8198 if (sw_if_index_set == 0)
8200 errmsg ("missing interface name or sw_if_index");
8204 if (sub_id_set == 0)
8206 errmsg ("missing sub_id");
8209 M (CREATE_SUBIF, mp);
8211 mp->sw_if_index = ntohl (sw_if_index);
8212 mp->sub_id = ntohl (sub_id);
8214 #define _(a) mp->a = a;
8215 foreach_create_subif_bit;
8218 mp->outer_vlan_id = ntohs (outer_vlan_id);
8219 mp->inner_vlan_id = ntohs (inner_vlan_id);
8227 api_oam_add_del (vat_main_t * vam)
8229 unformat_input_t *i = vam->input;
8230 vl_api_oam_add_del_t *mp;
8233 ip4_address_t src, dst;
8238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8240 if (unformat (i, "vrf %d", &vrf_id))
8242 else if (unformat (i, "src %U", unformat_ip4_address, &src))
8244 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
8246 else if (unformat (i, "del"))
8250 clib_warning ("parse error '%U'", format_unformat_error, i);
8257 errmsg ("missing src addr");
8263 errmsg ("missing dst addr");
8267 M (OAM_ADD_DEL, mp);
8269 mp->vrf_id = ntohl (vrf_id);
8270 mp->is_add = is_add;
8271 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
8272 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8280 api_reset_fib (vat_main_t * vam)
8282 unformat_input_t *i = vam->input;
8283 vl_api_reset_fib_t *mp;
8289 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8291 if (unformat (i, "vrf %d", &vrf_id))
8293 else if (unformat (i, "ipv6"))
8297 clib_warning ("parse error '%U'", format_unformat_error, i);
8302 if (vrf_id_set == 0)
8304 errmsg ("missing vrf id");
8310 mp->vrf_id = ntohl (vrf_id);
8311 mp->is_ipv6 = is_ipv6;
8319 api_dhcp_proxy_config (vat_main_t * vam)
8321 unformat_input_t *i = vam->input;
8322 vl_api_dhcp_proxy_config_t *mp;
8324 u32 server_vrf_id = 0;
8326 u8 v4_address_set = 0;
8327 u8 v6_address_set = 0;
8328 ip4_address_t v4address;
8329 ip6_address_t v6address;
8330 u8 v4_src_address_set = 0;
8331 u8 v6_src_address_set = 0;
8332 ip4_address_t v4srcaddress;
8333 ip6_address_t v6srcaddress;
8336 /* Parse args required to build the message */
8337 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8339 if (unformat (i, "del"))
8341 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8343 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8345 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8347 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8349 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8350 v4_src_address_set = 1;
8351 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8352 v6_src_address_set = 1;
8357 if (v4_address_set && v6_address_set)
8359 errmsg ("both v4 and v6 server addresses set");
8362 if (!v4_address_set && !v6_address_set)
8364 errmsg ("no server addresses set");
8368 if (v4_src_address_set && v6_src_address_set)
8370 errmsg ("both v4 and v6 src addresses set");
8373 if (!v4_src_address_set && !v6_src_address_set)
8375 errmsg ("no src addresses set");
8379 if (!(v4_src_address_set && v4_address_set) &&
8380 !(v6_src_address_set && v6_address_set))
8382 errmsg ("no matching server and src addresses set");
8386 /* Construct the API message */
8387 M (DHCP_PROXY_CONFIG, mp);
8389 mp->is_add = is_add;
8390 mp->rx_vrf_id = ntohl (rx_vrf_id);
8391 mp->server_vrf_id = ntohl (server_vrf_id);
8395 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
8396 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
8400 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
8401 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
8407 /* Wait for a reply, return good/bad news */
8412 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
8413 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
8416 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
8418 vat_main_t *vam = &vat_main;
8419 u32 i, count = mp->count;
8420 vl_api_dhcp_server_t *s;
8424 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8425 ntohl (mp->rx_vrf_id),
8426 format_ip6_address, mp->dhcp_src_address,
8427 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8430 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8431 ntohl (mp->rx_vrf_id),
8432 format_ip4_address, mp->dhcp_src_address,
8433 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8435 for (i = 0; i < count; i++)
8437 s = &mp->servers[i];
8441 " Server Table-ID %d, Server Address %U",
8442 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
8445 " Server Table-ID %d, Server Address %U",
8446 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
8450 static void vl_api_dhcp_proxy_details_t_handler_json
8451 (vl_api_dhcp_proxy_details_t * mp)
8453 vat_main_t *vam = &vat_main;
8454 vat_json_node_t *node = NULL;
8455 u32 i, count = mp->count;
8457 struct in6_addr ip6;
8458 vl_api_dhcp_server_t *s;
8460 if (VAT_JSON_ARRAY != vam->json_tree.type)
8462 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8463 vat_json_init_array (&vam->json_tree);
8465 node = vat_json_array_add (&vam->json_tree);
8467 vat_json_init_object (node);
8468 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
8469 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
8470 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
8474 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
8475 vat_json_object_add_ip6 (node, "src_address", ip6);
8479 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
8480 vat_json_object_add_ip4 (node, "src_address", ip4);
8483 for (i = 0; i < count; i++)
8485 s = &mp->servers[i];
8487 vat_json_object_add_uint (node, "server-table-id",
8488 ntohl (s->server_vrf_id));
8492 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
8493 vat_json_object_add_ip4 (node, "src_address", ip4);
8497 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
8498 vat_json_object_add_ip6 (node, "server_address", ip6);
8504 api_dhcp_proxy_dump (vat_main_t * vam)
8506 unformat_input_t *i = vam->input;
8507 vl_api_control_ping_t *mp_ping;
8508 vl_api_dhcp_proxy_dump_t *mp;
8512 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8514 if (unformat (i, "ipv6"))
8518 clib_warning ("parse error '%U'", format_unformat_error, i);
8523 M (DHCP_PROXY_DUMP, mp);
8525 mp->is_ip6 = is_ipv6;
8528 /* Use a control ping for synchronization */
8529 M (CONTROL_PING, mp_ping);
8537 api_dhcp_proxy_set_vss (vat_main_t * vam)
8539 unformat_input_t *i = vam->input;
8540 vl_api_dhcp_proxy_set_vss_t *mp;
8551 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8553 if (unformat (i, "tbl_id %d", &tbl_id))
8555 if (unformat (i, "fib_id %d", &fib_id))
8557 if (unformat (i, "oui %d", &oui))
8559 else if (unformat (i, "ipv6"))
8561 else if (unformat (i, "del"))
8565 clib_warning ("parse error '%U'", format_unformat_error, i);
8570 if (tbl_id_set == 0)
8572 errmsg ("missing tbl id");
8576 if (fib_id_set == 0)
8578 errmsg ("missing fib id");
8583 errmsg ("missing oui");
8587 M (DHCP_PROXY_SET_VSS, mp);
8588 mp->tbl_id = ntohl (tbl_id);
8589 mp->fib_id = ntohl (fib_id);
8590 mp->oui = ntohl (oui);
8591 mp->is_ipv6 = is_ipv6;
8592 mp->is_add = is_add;
8600 api_dhcp_client_config (vat_main_t * vam)
8602 unformat_input_t *i = vam->input;
8603 vl_api_dhcp_client_config_t *mp;
8605 u8 sw_if_index_set = 0;
8608 u8 disable_event = 0;
8611 /* Parse args required to build the message */
8612 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8614 if (unformat (i, "del"))
8617 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8618 sw_if_index_set = 1;
8619 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8620 sw_if_index_set = 1;
8621 else if (unformat (i, "hostname %s", &hostname))
8623 else if (unformat (i, "disable_event"))
8629 if (sw_if_index_set == 0)
8631 errmsg ("missing interface name or sw_if_index");
8635 if (vec_len (hostname) > 63)
8637 errmsg ("hostname too long");
8639 vec_add1 (hostname, 0);
8641 /* Construct the API message */
8642 M (DHCP_CLIENT_CONFIG, mp);
8644 mp->sw_if_index = htonl (sw_if_index);
8645 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
8646 vec_free (hostname);
8647 mp->is_add = is_add;
8648 mp->want_dhcp_event = disable_event ? 0 : 1;
8649 mp->pid = htonl (getpid ());
8654 /* Wait for a reply, return good/bad news */
8660 api_set_ip_flow_hash (vat_main_t * vam)
8662 unformat_input_t *i = vam->input;
8663 vl_api_set_ip_flow_hash_t *mp;
8675 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8677 if (unformat (i, "vrf %d", &vrf_id))
8679 else if (unformat (i, "ipv6"))
8681 else if (unformat (i, "src"))
8683 else if (unformat (i, "dst"))
8685 else if (unformat (i, "sport"))
8687 else if (unformat (i, "dport"))
8689 else if (unformat (i, "proto"))
8691 else if (unformat (i, "reverse"))
8696 clib_warning ("parse error '%U'", format_unformat_error, i);
8701 if (vrf_id_set == 0)
8703 errmsg ("missing vrf id");
8707 M (SET_IP_FLOW_HASH, mp);
8713 mp->reverse = reverse;
8714 mp->vrf_id = ntohl (vrf_id);
8715 mp->is_ipv6 = is_ipv6;
8723 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8725 unformat_input_t *i = vam->input;
8726 vl_api_sw_interface_ip6_enable_disable_t *mp;
8728 u8 sw_if_index_set = 0;
8732 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8734 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8735 sw_if_index_set = 1;
8736 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8737 sw_if_index_set = 1;
8738 else if (unformat (i, "enable"))
8740 else if (unformat (i, "disable"))
8744 clib_warning ("parse error '%U'", format_unformat_error, i);
8749 if (sw_if_index_set == 0)
8751 errmsg ("missing interface name or sw_if_index");
8755 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8757 mp->sw_if_index = ntohl (sw_if_index);
8758 mp->enable = enable;
8766 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8768 unformat_input_t *i = vam->input;
8769 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8771 u8 sw_if_index_set = 0;
8772 u8 v6_address_set = 0;
8773 ip6_address_t v6address;
8776 /* Parse args required to build the message */
8777 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8779 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8780 sw_if_index_set = 1;
8781 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8782 sw_if_index_set = 1;
8783 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8789 if (sw_if_index_set == 0)
8791 errmsg ("missing interface name or sw_if_index");
8794 if (!v6_address_set)
8796 errmsg ("no address set");
8800 /* Construct the API message */
8801 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8803 mp->sw_if_index = ntohl (sw_if_index);
8804 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8809 /* Wait for a reply, return good/bad news */
8815 api_ip6nd_proxy_add_del (vat_main_t * vam)
8817 unformat_input_t *i = vam->input;
8818 vl_api_ip6nd_proxy_add_del_t *mp;
8819 u32 sw_if_index = ~0;
8820 u8 v6_address_set = 0;
8821 ip6_address_t v6address;
8825 /* Parse args required to build the message */
8826 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8828 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8830 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8832 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8834 if (unformat (i, "del"))
8838 clib_warning ("parse error '%U'", format_unformat_error, i);
8843 if (sw_if_index == ~0)
8845 errmsg ("missing interface name or sw_if_index");
8848 if (!v6_address_set)
8850 errmsg ("no address set");
8854 /* Construct the API message */
8855 M (IP6ND_PROXY_ADD_DEL, mp);
8857 mp->is_del = is_del;
8858 mp->sw_if_index = ntohl (sw_if_index);
8859 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8864 /* Wait for a reply, return good/bad news */
8870 api_ip6nd_proxy_dump (vat_main_t * vam)
8872 vl_api_ip6nd_proxy_dump_t *mp;
8873 vl_api_control_ping_t *mp_ping;
8876 M (IP6ND_PROXY_DUMP, mp);
8880 /* Use a control ping for synchronization */
8881 M (CONTROL_PING, mp_ping);
8888 static void vl_api_ip6nd_proxy_details_t_handler
8889 (vl_api_ip6nd_proxy_details_t * mp)
8891 vat_main_t *vam = &vat_main;
8893 print (vam->ofp, "host %U sw_if_index %d",
8894 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
8897 static void vl_api_ip6nd_proxy_details_t_handler_json
8898 (vl_api_ip6nd_proxy_details_t * mp)
8900 vat_main_t *vam = &vat_main;
8901 struct in6_addr ip6;
8902 vat_json_node_t *node = NULL;
8904 if (VAT_JSON_ARRAY != vam->json_tree.type)
8906 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8907 vat_json_init_array (&vam->json_tree);
8909 node = vat_json_array_add (&vam->json_tree);
8911 vat_json_init_object (node);
8912 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
8914 clib_memcpy (&ip6, mp->address, sizeof (ip6));
8915 vat_json_object_add_ip6 (node, "host", ip6);
8919 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8921 unformat_input_t *i = vam->input;
8922 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8924 u8 sw_if_index_set = 0;
8925 u32 address_length = 0;
8926 u8 v6_address_set = 0;
8927 ip6_address_t v6address;
8929 u8 no_advertise = 0;
8931 u8 no_autoconfig = 0;
8934 u32 val_lifetime = 0;
8935 u32 pref_lifetime = 0;
8938 /* Parse args required to build the message */
8939 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8941 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8942 sw_if_index_set = 1;
8943 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8944 sw_if_index_set = 1;
8945 else if (unformat (i, "%U/%d",
8946 unformat_ip6_address, &v6address, &address_length))
8948 else if (unformat (i, "val_life %d", &val_lifetime))
8950 else if (unformat (i, "pref_life %d", &pref_lifetime))
8952 else if (unformat (i, "def"))
8954 else if (unformat (i, "noadv"))
8956 else if (unformat (i, "offl"))
8958 else if (unformat (i, "noauto"))
8960 else if (unformat (i, "nolink"))
8962 else if (unformat (i, "isno"))
8966 clib_warning ("parse error '%U'", format_unformat_error, i);
8971 if (sw_if_index_set == 0)
8973 errmsg ("missing interface name or sw_if_index");
8976 if (!v6_address_set)
8978 errmsg ("no address set");
8982 /* Construct the API message */
8983 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8985 mp->sw_if_index = ntohl (sw_if_index);
8986 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8987 mp->address_length = address_length;
8988 mp->use_default = use_default;
8989 mp->no_advertise = no_advertise;
8990 mp->off_link = off_link;
8991 mp->no_autoconfig = no_autoconfig;
8992 mp->no_onlink = no_onlink;
8994 mp->val_lifetime = ntohl (val_lifetime);
8995 mp->pref_lifetime = ntohl (pref_lifetime);
9000 /* Wait for a reply, return good/bad news */
9006 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9008 unformat_input_t *i = vam->input;
9009 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9011 u8 sw_if_index_set = 0;
9016 u8 send_unicast = 0;
9019 u8 default_router = 0;
9020 u32 max_interval = 0;
9021 u32 min_interval = 0;
9023 u32 initial_count = 0;
9024 u32 initial_interval = 0;
9028 /* Parse args required to build the message */
9029 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9031 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9032 sw_if_index_set = 1;
9033 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9034 sw_if_index_set = 1;
9035 else if (unformat (i, "maxint %d", &max_interval))
9037 else if (unformat (i, "minint %d", &min_interval))
9039 else if (unformat (i, "life %d", &lifetime))
9041 else if (unformat (i, "count %d", &initial_count))
9043 else if (unformat (i, "interval %d", &initial_interval))
9045 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9047 else if (unformat (i, "managed"))
9049 else if (unformat (i, "other"))
9051 else if (unformat (i, "ll"))
9053 else if (unformat (i, "send"))
9055 else if (unformat (i, "cease"))
9057 else if (unformat (i, "isno"))
9059 else if (unformat (i, "def"))
9063 clib_warning ("parse error '%U'", format_unformat_error, i);
9068 if (sw_if_index_set == 0)
9070 errmsg ("missing interface name or sw_if_index");
9074 /* Construct the API message */
9075 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9077 mp->sw_if_index = ntohl (sw_if_index);
9078 mp->max_interval = ntohl (max_interval);
9079 mp->min_interval = ntohl (min_interval);
9080 mp->lifetime = ntohl (lifetime);
9081 mp->initial_count = ntohl (initial_count);
9082 mp->initial_interval = ntohl (initial_interval);
9083 mp->suppress = suppress;
9084 mp->managed = managed;
9086 mp->ll_option = ll_option;
9087 mp->send_unicast = send_unicast;
9090 mp->default_router = default_router;
9095 /* Wait for a reply, return good/bad news */
9101 api_set_arp_neighbor_limit (vat_main_t * vam)
9103 unformat_input_t *i = vam->input;
9104 vl_api_set_arp_neighbor_limit_t *mp;
9110 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9112 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9114 else if (unformat (i, "ipv6"))
9118 clib_warning ("parse error '%U'", format_unformat_error, i);
9125 errmsg ("missing limit value");
9129 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9131 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9132 mp->is_ipv6 = is_ipv6;
9140 api_l2_patch_add_del (vat_main_t * vam)
9142 unformat_input_t *i = vam->input;
9143 vl_api_l2_patch_add_del_t *mp;
9145 u8 rx_sw_if_index_set = 0;
9147 u8 tx_sw_if_index_set = 0;
9151 /* Parse args required to build the message */
9152 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9154 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9155 rx_sw_if_index_set = 1;
9156 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9157 tx_sw_if_index_set = 1;
9158 else if (unformat (i, "rx"))
9160 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9162 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9164 rx_sw_if_index_set = 1;
9169 else if (unformat (i, "tx"))
9171 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9173 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9175 tx_sw_if_index_set = 1;
9180 else if (unformat (i, "del"))
9186 if (rx_sw_if_index_set == 0)
9188 errmsg ("missing rx interface name or rx_sw_if_index");
9192 if (tx_sw_if_index_set == 0)
9194 errmsg ("missing tx interface name or tx_sw_if_index");
9198 M (L2_PATCH_ADD_DEL, mp);
9200 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9201 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9202 mp->is_add = is_add;
9210 u8 localsid_addr[16];
9219 api_sr_localsid_add_del (vat_main_t * vam)
9221 unformat_input_t *i = vam->input;
9222 vl_api_sr_localsid_add_del_t *mp;
9225 ip6_address_t localsid;
9229 u32 fib_table = ~(u32) 0;
9230 ip6_address_t next_hop;
9232 bool nexthop_set = 0;
9236 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9238 if (unformat (i, "del"))
9240 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9241 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
9243 else if (unformat (i, "behavior %u", &behavior));
9244 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9245 else if (unformat (i, "fib-table %u", &fib_table));
9246 else if (unformat (i, "end.psp %u", &behavior));
9251 M (SR_LOCALSID_ADD_DEL, mp);
9253 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
9255 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
9256 mp->behavior = behavior;
9257 mp->sw_if_index = ntohl (sw_if_index);
9258 mp->fib_table = ntohl (fib_table);
9259 mp->end_psp = end_psp;
9260 mp->is_del = is_del;
9268 api_ioam_enable (vat_main_t * vam)
9270 unformat_input_t *input = vam->input;
9271 vl_api_ioam_enable_t *mp;
9273 int has_trace_option = 0;
9274 int has_pot_option = 0;
9275 int has_seqno_option = 0;
9276 int has_analyse_option = 0;
9279 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9281 if (unformat (input, "trace"))
9282 has_trace_option = 1;
9283 else if (unformat (input, "pot"))
9285 else if (unformat (input, "seqno"))
9286 has_seqno_option = 1;
9287 else if (unformat (input, "analyse"))
9288 has_analyse_option = 1;
9292 M (IOAM_ENABLE, mp);
9293 mp->id = htons (id);
9294 mp->seqno = has_seqno_option;
9295 mp->analyse = has_analyse_option;
9296 mp->pot_enable = has_pot_option;
9297 mp->trace_enable = has_trace_option;
9306 api_ioam_disable (vat_main_t * vam)
9308 vl_api_ioam_disable_t *mp;
9311 M (IOAM_DISABLE, mp);
9317 #define foreach_tcp_proto_field \
9321 #define foreach_udp_proto_field \
9325 #define foreach_ip4_proto_field \
9337 u16 src_port, dst_port;
9340 #if VPP_API_TEST_BUILTIN == 0
9342 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9344 u8 **maskp = va_arg (*args, u8 **);
9346 u8 found_something = 0;
9349 #define _(a) u8 a=0;
9350 foreach_tcp_proto_field;
9353 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9356 #define _(a) else if (unformat (input, #a)) a=1;
9357 foreach_tcp_proto_field
9363 #define _(a) found_something += a;
9364 foreach_tcp_proto_field;
9367 if (found_something == 0)
9370 vec_validate (mask, sizeof (*tcp) - 1);
9372 tcp = (tcp_header_t *) mask;
9374 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9375 foreach_tcp_proto_field;
9383 unformat_udp_mask (unformat_input_t * input, va_list * args)
9385 u8 **maskp = va_arg (*args, u8 **);
9387 u8 found_something = 0;
9390 #define _(a) u8 a=0;
9391 foreach_udp_proto_field;
9394 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9397 #define _(a) else if (unformat (input, #a)) a=1;
9398 foreach_udp_proto_field
9404 #define _(a) found_something += a;
9405 foreach_udp_proto_field;
9408 if (found_something == 0)
9411 vec_validate (mask, sizeof (*udp) - 1);
9413 udp = (udp_header_t *) mask;
9415 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
9416 foreach_udp_proto_field;
9424 unformat_l4_mask (unformat_input_t * input, va_list * args)
9426 u8 **maskp = va_arg (*args, u8 **);
9427 u16 src_port = 0, dst_port = 0;
9428 tcpudp_header_t *tcpudp;
9430 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9432 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9434 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9436 else if (unformat (input, "src_port"))
9438 else if (unformat (input, "dst_port"))
9444 if (!src_port && !dst_port)
9448 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9450 tcpudp = (tcpudp_header_t *) mask;
9451 tcpudp->src_port = src_port;
9452 tcpudp->dst_port = dst_port;
9460 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9462 u8 **maskp = va_arg (*args, u8 **);
9464 u8 found_something = 0;
9467 #define _(a) u8 a=0;
9468 foreach_ip4_proto_field;
9474 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9476 if (unformat (input, "version"))
9478 else if (unformat (input, "hdr_length"))
9480 else if (unformat (input, "src"))
9482 else if (unformat (input, "dst"))
9484 else if (unformat (input, "proto"))
9487 #define _(a) else if (unformat (input, #a)) a=1;
9488 foreach_ip4_proto_field
9494 #define _(a) found_something += a;
9495 foreach_ip4_proto_field;
9498 if (found_something == 0)
9501 vec_validate (mask, sizeof (*ip) - 1);
9503 ip = (ip4_header_t *) mask;
9505 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9506 foreach_ip4_proto_field;
9509 ip->ip_version_and_header_length = 0;
9512 ip->ip_version_and_header_length |= 0xF0;
9515 ip->ip_version_and_header_length |= 0x0F;
9521 #define foreach_ip6_proto_field \
9529 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9531 u8 **maskp = va_arg (*args, u8 **);
9533 u8 found_something = 0;
9535 u32 ip_version_traffic_class_and_flow_label;
9537 #define _(a) u8 a=0;
9538 foreach_ip6_proto_field;
9541 u8 traffic_class = 0;
9544 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9546 if (unformat (input, "version"))
9548 else if (unformat (input, "traffic-class"))
9550 else if (unformat (input, "flow-label"))
9552 else if (unformat (input, "src"))
9554 else if (unformat (input, "dst"))
9556 else if (unformat (input, "proto"))
9559 #define _(a) else if (unformat (input, #a)) a=1;
9560 foreach_ip6_proto_field
9566 #define _(a) found_something += a;
9567 foreach_ip6_proto_field;
9570 if (found_something == 0)
9573 vec_validate (mask, sizeof (*ip) - 1);
9575 ip = (ip6_header_t *) mask;
9577 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9578 foreach_ip6_proto_field;
9581 ip_version_traffic_class_and_flow_label = 0;
9584 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9587 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9590 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9592 ip->ip_version_traffic_class_and_flow_label =
9593 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9600 unformat_l3_mask (unformat_input_t * input, va_list * args)
9602 u8 **maskp = va_arg (*args, u8 **);
9604 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9606 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9608 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9617 unformat_l2_mask (unformat_input_t * input, va_list * args)
9619 u8 **maskp = va_arg (*args, u8 **);
9634 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9636 if (unformat (input, "src"))
9638 else if (unformat (input, "dst"))
9640 else if (unformat (input, "proto"))
9642 else if (unformat (input, "tag1"))
9644 else if (unformat (input, "tag2"))
9646 else if (unformat (input, "ignore-tag1"))
9648 else if (unformat (input, "ignore-tag2"))
9650 else if (unformat (input, "cos1"))
9652 else if (unformat (input, "cos2"))
9654 else if (unformat (input, "dot1q"))
9656 else if (unformat (input, "dot1ad"))
9661 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9662 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9665 if (tag1 || ignore_tag1 || cos1 || dot1q)
9667 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9670 vec_validate (mask, len - 1);
9673 memset (mask, 0xff, 6);
9676 memset (mask + 6, 0xff, 6);
9680 /* inner vlan tag */
9689 mask[21] = mask[20] = 0xff;
9710 mask[16] = mask[17] = 0xff;
9720 mask[12] = mask[13] = 0xff;
9727 unformat_classify_mask (unformat_input_t * input, va_list * args)
9729 u8 **maskp = va_arg (*args, u8 **);
9730 u32 *skipp = va_arg (*args, u32 *);
9731 u32 *matchp = va_arg (*args, u32 *);
9739 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9741 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9743 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9745 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9747 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9761 if (mask || l2 || l3 || l4)
9765 /* "With a free Ethernet header in every package" */
9767 vec_validate (l2, 13);
9771 vec_append (mask, l3);
9776 vec_append (mask, l4);
9781 /* Scan forward looking for the first significant mask octet */
9782 for (i = 0; i < vec_len (mask); i++)
9786 /* compute (skip, match) params */
9787 *skipp = i / sizeof (u32x4);
9788 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9790 /* Pad mask to an even multiple of the vector size */
9791 while (vec_len (mask) % sizeof (u32x4))
9794 match = vec_len (mask) / sizeof (u32x4);
9796 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9798 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9799 if (*tmp || *(tmp + 1))
9804 clib_warning ("BUG: match 0");
9806 _vec_len (mask) = match * sizeof (u32x4);
9816 #endif /* VPP_API_TEST_BUILTIN */
9818 #define foreach_l2_next \
9820 _(ethernet, ETHERNET_INPUT) \
9825 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9827 u32 *miss_next_indexp = va_arg (*args, u32 *);
9832 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9836 if (unformat (input, "%d", &tmp))
9845 *miss_next_indexp = next_index;
9849 #define foreach_ip_next \
9855 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9857 u32 *miss_next_indexp = va_arg (*args, u32 *);
9862 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9866 if (unformat (input, "%d", &tmp))
9875 *miss_next_indexp = next_index;
9879 #define foreach_acl_next \
9883 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9885 u32 *miss_next_indexp = va_arg (*args, u32 *);
9890 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9894 if (unformat (input, "permit"))
9899 else if (unformat (input, "%d", &tmp))
9908 *miss_next_indexp = next_index;
9913 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9915 u32 *r = va_arg (*args, u32 *);
9917 if (unformat (input, "conform-color"))
9918 *r = POLICE_CONFORM;
9919 else if (unformat (input, "exceed-color"))
9928 api_classify_add_del_table (vat_main_t * vam)
9930 unformat_input_t *i = vam->input;
9931 vl_api_classify_add_del_table_t *mp;
9938 u32 table_index = ~0;
9939 u32 next_table_index = ~0;
9940 u32 miss_next_index = ~0;
9941 u32 memory_size = 32 << 20;
9943 u32 current_data_flag = 0;
9944 int current_data_offset = 0;
9947 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9949 if (unformat (i, "del"))
9951 else if (unformat (i, "del-chain"))
9956 else if (unformat (i, "buckets %d", &nbuckets))
9958 else if (unformat (i, "memory_size %d", &memory_size))
9960 else if (unformat (i, "skip %d", &skip))
9962 else if (unformat (i, "match %d", &match))
9964 else if (unformat (i, "table %d", &table_index))
9966 else if (unformat (i, "mask %U", unformat_classify_mask,
9967 &mask, &skip, &match))
9969 else if (unformat (i, "next-table %d", &next_table_index))
9971 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9974 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9977 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9980 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9982 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9988 if (is_add && mask == 0)
9990 errmsg ("Mask required");
9994 if (is_add && skip == ~0)
9996 errmsg ("skip count required");
10000 if (is_add && match == ~0)
10002 errmsg ("match count required");
10006 if (!is_add && table_index == ~0)
10008 errmsg ("table index required for delete");
10012 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10014 mp->is_add = is_add;
10015 mp->del_chain = del_chain;
10016 mp->table_index = ntohl (table_index);
10017 mp->nbuckets = ntohl (nbuckets);
10018 mp->memory_size = ntohl (memory_size);
10019 mp->skip_n_vectors = ntohl (skip);
10020 mp->match_n_vectors = ntohl (match);
10021 mp->next_table_index = ntohl (next_table_index);
10022 mp->miss_next_index = ntohl (miss_next_index);
10023 mp->current_data_flag = ntohl (current_data_flag);
10024 mp->current_data_offset = ntohl (current_data_offset);
10025 clib_memcpy (mp->mask, mask, vec_len (mask));
10034 #if VPP_API_TEST_BUILTIN == 0
10036 unformat_l4_match (unformat_input_t * input, va_list * args)
10038 u8 **matchp = va_arg (*args, u8 **);
10040 u8 *proto_header = 0;
10046 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10048 if (unformat (input, "src_port %d", &src_port))
10050 else if (unformat (input, "dst_port %d", &dst_port))
10056 h.src_port = clib_host_to_net_u16 (src_port);
10057 h.dst_port = clib_host_to_net_u16 (dst_port);
10058 vec_validate (proto_header, sizeof (h) - 1);
10059 memcpy (proto_header, &h, sizeof (h));
10061 *matchp = proto_header;
10067 unformat_ip4_match (unformat_input_t * input, va_list * args)
10069 u8 **matchp = va_arg (*args, u8 **);
10074 int hdr_length = 0;
10075 u32 hdr_length_val;
10076 int src = 0, dst = 0;
10077 ip4_address_t src_val, dst_val;
10084 int fragment_id = 0;
10085 u32 fragment_id_val;
10091 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10093 if (unformat (input, "version %d", &version_val))
10095 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10097 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10099 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10101 else if (unformat (input, "proto %d", &proto_val))
10103 else if (unformat (input, "tos %d", &tos_val))
10105 else if (unformat (input, "length %d", &length_val))
10107 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10109 else if (unformat (input, "ttl %d", &ttl_val))
10111 else if (unformat (input, "checksum %d", &checksum_val))
10117 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10118 + ttl + checksum == 0)
10122 * Aligned because we use the real comparison functions
10124 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10126 ip = (ip4_header_t *) match;
10128 /* These are realistically matched in practice */
10130 ip->src_address.as_u32 = src_val.as_u32;
10133 ip->dst_address.as_u32 = dst_val.as_u32;
10136 ip->protocol = proto_val;
10139 /* These are not, but they're included for completeness */
10141 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10144 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10150 ip->length = clib_host_to_net_u16 (length_val);
10156 ip->checksum = clib_host_to_net_u16 (checksum_val);
10163 unformat_ip6_match (unformat_input_t * input, va_list * args)
10165 u8 **matchp = va_arg (*args, u8 **);
10170 u8 traffic_class = 0;
10171 u32 traffic_class_val = 0;
10174 int src = 0, dst = 0;
10175 ip6_address_t src_val, dst_val;
10178 int payload_length = 0;
10179 u32 payload_length_val;
10182 u32 ip_version_traffic_class_and_flow_label;
10184 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10186 if (unformat (input, "version %d", &version_val))
10188 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10190 else if (unformat (input, "flow_label %d", &flow_label_val))
10192 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10194 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10196 else if (unformat (input, "proto %d", &proto_val))
10198 else if (unformat (input, "payload_length %d", &payload_length_val))
10199 payload_length = 1;
10200 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10206 if (version + traffic_class + flow_label + src + dst + proto +
10207 payload_length + hop_limit == 0)
10211 * Aligned because we use the real comparison functions
10213 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10215 ip = (ip6_header_t *) match;
10218 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10221 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10224 ip->protocol = proto_val;
10226 ip_version_traffic_class_and_flow_label = 0;
10229 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10232 ip_version_traffic_class_and_flow_label |=
10233 (traffic_class_val & 0xFF) << 20;
10236 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10238 ip->ip_version_traffic_class_and_flow_label =
10239 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10241 if (payload_length)
10242 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10245 ip->hop_limit = hop_limit_val;
10252 unformat_l3_match (unformat_input_t * input, va_list * args)
10254 u8 **matchp = va_arg (*args, u8 **);
10256 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10258 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10260 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10269 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10271 u8 *tagp = va_arg (*args, u8 *);
10274 if (unformat (input, "%d", &tag))
10276 tagp[0] = (tag >> 8) & 0x0F;
10277 tagp[1] = tag & 0xFF;
10285 unformat_l2_match (unformat_input_t * input, va_list * args)
10287 u8 **matchp = va_arg (*args, u8 **);
10300 u8 ignore_tag1 = 0;
10301 u8 ignore_tag2 = 0;
10307 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10309 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10312 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10314 else if (unformat (input, "proto %U",
10315 unformat_ethernet_type_host_byte_order, &proto_val))
10317 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10319 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10321 else if (unformat (input, "ignore-tag1"))
10323 else if (unformat (input, "ignore-tag2"))
10325 else if (unformat (input, "cos1 %d", &cos1_val))
10327 else if (unformat (input, "cos2 %d", &cos2_val))
10332 if ((src + dst + proto + tag1 + tag2 +
10333 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10336 if (tag1 || ignore_tag1 || cos1)
10338 if (tag2 || ignore_tag2 || cos2)
10341 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10344 clib_memcpy (match, dst_val, 6);
10347 clib_memcpy (match + 6, src_val, 6);
10351 /* inner vlan tag */
10352 match[19] = tag2_val[1];
10353 match[18] = tag2_val[0];
10355 match[18] |= (cos2_val & 0x7) << 5;
10358 match[21] = proto_val & 0xff;
10359 match[20] = proto_val >> 8;
10363 match[15] = tag1_val[1];
10364 match[14] = tag1_val[0];
10367 match[14] |= (cos1_val & 0x7) << 5;
10373 match[15] = tag1_val[1];
10374 match[14] = tag1_val[0];
10377 match[17] = proto_val & 0xff;
10378 match[16] = proto_val >> 8;
10381 match[14] |= (cos1_val & 0x7) << 5;
10387 match[18] |= (cos2_val & 0x7) << 5;
10389 match[14] |= (cos1_val & 0x7) << 5;
10392 match[13] = proto_val & 0xff;
10393 match[12] = proto_val >> 8;
10402 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10404 u8 **matchp = va_arg (*args, u8 **);
10405 u32 skip_n_vectors = va_arg (*args, u32);
10406 u32 match_n_vectors = va_arg (*args, u32);
10413 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10415 if (unformat (input, "hex %U", unformat_hex_string, &match))
10417 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10419 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10421 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10435 if (match || l2 || l3 || l4)
10437 if (l2 || l3 || l4)
10439 /* "Win a free Ethernet header in every packet" */
10441 vec_validate_aligned (l2, 13, sizeof (u32x4));
10445 vec_append_aligned (match, l3, sizeof (u32x4));
10450 vec_append_aligned (match, l4, sizeof (u32x4));
10455 /* Make sure the vector is big enough even if key is all 0's */
10456 vec_validate_aligned
10457 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10460 /* Set size, include skipped vectors */
10461 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10472 api_classify_add_del_session (vat_main_t * vam)
10474 unformat_input_t *i = vam->input;
10475 vl_api_classify_add_del_session_t *mp;
10477 u32 table_index = ~0;
10478 u32 hit_next_index = ~0;
10479 u32 opaque_index = ~0;
10482 u32 skip_n_vectors = 0;
10483 u32 match_n_vectors = 0;
10489 * Warning: you have to supply skip_n and match_n
10490 * because the API client cant simply look at the classify
10494 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10496 if (unformat (i, "del"))
10498 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10501 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10504 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10507 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10509 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10511 else if (unformat (i, "opaque-index %d", &opaque_index))
10513 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10515 else if (unformat (i, "match_n %d", &match_n_vectors))
10517 else if (unformat (i, "match %U", api_unformat_classify_match,
10518 &match, skip_n_vectors, match_n_vectors))
10520 else if (unformat (i, "advance %d", &advance))
10522 else if (unformat (i, "table-index %d", &table_index))
10524 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10526 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10528 else if (unformat (i, "action %d", &action))
10530 else if (unformat (i, "metadata %d", &metadata))
10536 if (table_index == ~0)
10538 errmsg ("Table index required");
10542 if (is_add && match == 0)
10544 errmsg ("Match value required");
10548 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10550 mp->is_add = is_add;
10551 mp->table_index = ntohl (table_index);
10552 mp->hit_next_index = ntohl (hit_next_index);
10553 mp->opaque_index = ntohl (opaque_index);
10554 mp->advance = ntohl (advance);
10555 mp->action = action;
10556 mp->metadata = ntohl (metadata);
10557 clib_memcpy (mp->match, match, vec_len (match));
10566 api_classify_set_interface_ip_table (vat_main_t * vam)
10568 unformat_input_t *i = vam->input;
10569 vl_api_classify_set_interface_ip_table_t *mp;
10571 int sw_if_index_set;
10572 u32 table_index = ~0;
10576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10578 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10579 sw_if_index_set = 1;
10580 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10581 sw_if_index_set = 1;
10582 else if (unformat (i, "table %d", &table_index))
10586 clib_warning ("parse error '%U'", format_unformat_error, i);
10591 if (sw_if_index_set == 0)
10593 errmsg ("missing interface name or sw_if_index");
10598 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10600 mp->sw_if_index = ntohl (sw_if_index);
10601 mp->table_index = ntohl (table_index);
10602 mp->is_ipv6 = is_ipv6;
10610 api_classify_set_interface_l2_tables (vat_main_t * vam)
10612 unformat_input_t *i = vam->input;
10613 vl_api_classify_set_interface_l2_tables_t *mp;
10615 int sw_if_index_set;
10616 u32 ip4_table_index = ~0;
10617 u32 ip6_table_index = ~0;
10618 u32 other_table_index = ~0;
10622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10624 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10625 sw_if_index_set = 1;
10626 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10627 sw_if_index_set = 1;
10628 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10630 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10632 else if (unformat (i, "other-table %d", &other_table_index))
10634 else if (unformat (i, "is-input %d", &is_input))
10638 clib_warning ("parse error '%U'", format_unformat_error, i);
10643 if (sw_if_index_set == 0)
10645 errmsg ("missing interface name or sw_if_index");
10650 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10652 mp->sw_if_index = ntohl (sw_if_index);
10653 mp->ip4_table_index = ntohl (ip4_table_index);
10654 mp->ip6_table_index = ntohl (ip6_table_index);
10655 mp->other_table_index = ntohl (other_table_index);
10656 mp->is_input = (u8) is_input;
10664 api_set_ipfix_exporter (vat_main_t * vam)
10666 unformat_input_t *i = vam->input;
10667 vl_api_set_ipfix_exporter_t *mp;
10668 ip4_address_t collector_address;
10669 u8 collector_address_set = 0;
10670 u32 collector_port = ~0;
10671 ip4_address_t src_address;
10672 u8 src_address_set = 0;
10675 u32 template_interval = ~0;
10676 u8 udp_checksum = 0;
10679 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10681 if (unformat (i, "collector_address %U", unformat_ip4_address,
10682 &collector_address))
10683 collector_address_set = 1;
10684 else if (unformat (i, "collector_port %d", &collector_port))
10686 else if (unformat (i, "src_address %U", unformat_ip4_address,
10688 src_address_set = 1;
10689 else if (unformat (i, "vrf_id %d", &vrf_id))
10691 else if (unformat (i, "path_mtu %d", &path_mtu))
10693 else if (unformat (i, "template_interval %d", &template_interval))
10695 else if (unformat (i, "udp_checksum"))
10701 if (collector_address_set == 0)
10703 errmsg ("collector_address required");
10707 if (src_address_set == 0)
10709 errmsg ("src_address required");
10713 M (SET_IPFIX_EXPORTER, mp);
10715 memcpy (mp->collector_address, collector_address.data,
10716 sizeof (collector_address.data));
10717 mp->collector_port = htons ((u16) collector_port);
10718 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10719 mp->vrf_id = htonl (vrf_id);
10720 mp->path_mtu = htonl (path_mtu);
10721 mp->template_interval = htonl (template_interval);
10722 mp->udp_checksum = udp_checksum;
10730 api_set_ipfix_classify_stream (vat_main_t * vam)
10732 unformat_input_t *i = vam->input;
10733 vl_api_set_ipfix_classify_stream_t *mp;
10735 u32 src_port = UDP_DST_PORT_ipfix;
10738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10740 if (unformat (i, "domain %d", &domain_id))
10742 else if (unformat (i, "src_port %d", &src_port))
10746 errmsg ("unknown input `%U'", format_unformat_error, i);
10751 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10753 mp->domain_id = htonl (domain_id);
10754 mp->src_port = htons ((u16) src_port);
10762 api_ipfix_classify_table_add_del (vat_main_t * vam)
10764 unformat_input_t *i = vam->input;
10765 vl_api_ipfix_classify_table_add_del_t *mp;
10767 u32 classify_table_index = ~0;
10769 u8 transport_protocol = 255;
10772 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10774 if (unformat (i, "add"))
10776 else if (unformat (i, "del"))
10778 else if (unformat (i, "table %d", &classify_table_index))
10780 else if (unformat (i, "ip4"))
10782 else if (unformat (i, "ip6"))
10784 else if (unformat (i, "tcp"))
10785 transport_protocol = 6;
10786 else if (unformat (i, "udp"))
10787 transport_protocol = 17;
10790 errmsg ("unknown input `%U'", format_unformat_error, i);
10797 errmsg ("expecting: add|del");
10800 if (classify_table_index == ~0)
10802 errmsg ("classifier table not specified");
10805 if (ip_version == 0)
10807 errmsg ("IP version not specified");
10811 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10813 mp->is_add = is_add;
10814 mp->table_id = htonl (classify_table_index);
10815 mp->ip_version = ip_version;
10816 mp->transport_protocol = transport_protocol;
10824 api_get_node_index (vat_main_t * vam)
10826 unformat_input_t *i = vam->input;
10827 vl_api_get_node_index_t *mp;
10831 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10833 if (unformat (i, "node %s", &name))
10840 errmsg ("node name required");
10843 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10845 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10849 M (GET_NODE_INDEX, mp);
10850 clib_memcpy (mp->node_name, name, vec_len (name));
10859 api_get_next_index (vat_main_t * vam)
10861 unformat_input_t *i = vam->input;
10862 vl_api_get_next_index_t *mp;
10863 u8 *node_name = 0, *next_node_name = 0;
10866 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10868 if (unformat (i, "node-name %s", &node_name))
10870 else if (unformat (i, "next-node-name %s", &next_node_name))
10874 if (node_name == 0)
10876 errmsg ("node name required");
10879 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10881 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10885 if (next_node_name == 0)
10887 errmsg ("next node name required");
10890 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10892 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10896 M (GET_NEXT_INDEX, mp);
10897 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10898 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10899 vec_free (node_name);
10900 vec_free (next_node_name);
10908 api_add_node_next (vat_main_t * vam)
10910 unformat_input_t *i = vam->input;
10911 vl_api_add_node_next_t *mp;
10916 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10918 if (unformat (i, "node %s", &name))
10920 else if (unformat (i, "next %s", &next))
10927 errmsg ("node name required");
10930 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10932 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10937 errmsg ("next node required");
10940 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10942 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10946 M (ADD_NODE_NEXT, mp);
10947 clib_memcpy (mp->node_name, name, vec_len (name));
10948 clib_memcpy (mp->next_name, next, vec_len (next));
10958 api_l2tpv3_create_tunnel (vat_main_t * vam)
10960 unformat_input_t *i = vam->input;
10961 ip6_address_t client_address, our_address;
10962 int client_address_set = 0;
10963 int our_address_set = 0;
10964 u32 local_session_id = 0;
10965 u32 remote_session_id = 0;
10966 u64 local_cookie = 0;
10967 u64 remote_cookie = 0;
10968 u8 l2_sublayer_present = 0;
10969 vl_api_l2tpv3_create_tunnel_t *mp;
10972 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10974 if (unformat (i, "client_address %U", unformat_ip6_address,
10976 client_address_set = 1;
10977 else if (unformat (i, "our_address %U", unformat_ip6_address,
10979 our_address_set = 1;
10980 else if (unformat (i, "local_session_id %d", &local_session_id))
10982 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10984 else if (unformat (i, "local_cookie %lld", &local_cookie))
10986 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10988 else if (unformat (i, "l2-sublayer-present"))
10989 l2_sublayer_present = 1;
10994 if (client_address_set == 0)
10996 errmsg ("client_address required");
11000 if (our_address_set == 0)
11002 errmsg ("our_address required");
11006 M (L2TPV3_CREATE_TUNNEL, mp);
11008 clib_memcpy (mp->client_address, client_address.as_u8,
11009 sizeof (mp->client_address));
11011 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11013 mp->local_session_id = ntohl (local_session_id);
11014 mp->remote_session_id = ntohl (remote_session_id);
11015 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11016 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11017 mp->l2_sublayer_present = l2_sublayer_present;
11026 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11028 unformat_input_t *i = vam->input;
11030 u8 sw_if_index_set = 0;
11031 u64 new_local_cookie = 0;
11032 u64 new_remote_cookie = 0;
11033 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11036 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11038 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11039 sw_if_index_set = 1;
11040 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11041 sw_if_index_set = 1;
11042 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11044 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11050 if (sw_if_index_set == 0)
11052 errmsg ("missing interface name or sw_if_index");
11056 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11058 mp->sw_if_index = ntohl (sw_if_index);
11059 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11060 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11068 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11070 unformat_input_t *i = vam->input;
11071 vl_api_l2tpv3_interface_enable_disable_t *mp;
11073 u8 sw_if_index_set = 0;
11074 u8 enable_disable = 1;
11077 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11079 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11080 sw_if_index_set = 1;
11081 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11082 sw_if_index_set = 1;
11083 else if (unformat (i, "enable"))
11084 enable_disable = 1;
11085 else if (unformat (i, "disable"))
11086 enable_disable = 0;
11091 if (sw_if_index_set == 0)
11093 errmsg ("missing interface name or sw_if_index");
11097 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11099 mp->sw_if_index = ntohl (sw_if_index);
11100 mp->enable_disable = enable_disable;
11108 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11110 unformat_input_t *i = vam->input;
11111 vl_api_l2tpv3_set_lookup_key_t *mp;
11115 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11117 if (unformat (i, "lookup_v6_src"))
11118 key = L2T_LOOKUP_SRC_ADDRESS;
11119 else if (unformat (i, "lookup_v6_dst"))
11120 key = L2T_LOOKUP_DST_ADDRESS;
11121 else if (unformat (i, "lookup_session_id"))
11122 key = L2T_LOOKUP_SESSION_ID;
11127 if (key == (u8) ~ 0)
11129 errmsg ("l2tp session lookup key unset");
11133 M (L2TPV3_SET_LOOKUP_KEY, mp);
11142 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11143 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11145 vat_main_t *vam = &vat_main;
11147 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11148 format_ip6_address, mp->our_address,
11149 format_ip6_address, mp->client_address,
11150 clib_net_to_host_u32 (mp->sw_if_index));
11153 " local cookies %016llx %016llx remote cookie %016llx",
11154 clib_net_to_host_u64 (mp->local_cookie[0]),
11155 clib_net_to_host_u64 (mp->local_cookie[1]),
11156 clib_net_to_host_u64 (mp->remote_cookie));
11158 print (vam->ofp, " local session-id %d remote session-id %d",
11159 clib_net_to_host_u32 (mp->local_session_id),
11160 clib_net_to_host_u32 (mp->remote_session_id));
11162 print (vam->ofp, " l2 specific sublayer %s\n",
11163 mp->l2_sublayer_present ? "preset" : "absent");
11167 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11168 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11170 vat_main_t *vam = &vat_main;
11171 vat_json_node_t *node = NULL;
11172 struct in6_addr addr;
11174 if (VAT_JSON_ARRAY != vam->json_tree.type)
11176 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11177 vat_json_init_array (&vam->json_tree);
11179 node = vat_json_array_add (&vam->json_tree);
11181 vat_json_init_object (node);
11183 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11184 vat_json_object_add_ip6 (node, "our_address", addr);
11185 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11186 vat_json_object_add_ip6 (node, "client_address", addr);
11188 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11189 vat_json_init_array (lc);
11190 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11191 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11192 vat_json_object_add_uint (node, "remote_cookie",
11193 clib_net_to_host_u64 (mp->remote_cookie));
11195 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11196 vat_json_object_add_uint (node, "local_session_id",
11197 clib_net_to_host_u32 (mp->local_session_id));
11198 vat_json_object_add_uint (node, "remote_session_id",
11199 clib_net_to_host_u32 (mp->remote_session_id));
11200 vat_json_object_add_string_copy (node, "l2_sublayer",
11201 mp->l2_sublayer_present ? (u8 *) "present"
11202 : (u8 *) "absent");
11206 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11208 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11209 vl_api_control_ping_t *mp_ping;
11212 /* Get list of l2tpv3-tunnel interfaces */
11213 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11216 /* Use a control ping for synchronization */
11217 M (CONTROL_PING, mp_ping);
11225 static void vl_api_sw_interface_tap_details_t_handler
11226 (vl_api_sw_interface_tap_details_t * mp)
11228 vat_main_t *vam = &vat_main;
11230 print (vam->ofp, "%-16s %d",
11231 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
11234 static void vl_api_sw_interface_tap_details_t_handler_json
11235 (vl_api_sw_interface_tap_details_t * mp)
11237 vat_main_t *vam = &vat_main;
11238 vat_json_node_t *node = NULL;
11240 if (VAT_JSON_ARRAY != vam->json_tree.type)
11242 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11243 vat_json_init_array (&vam->json_tree);
11245 node = vat_json_array_add (&vam->json_tree);
11247 vat_json_init_object (node);
11248 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11249 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11253 api_sw_interface_tap_dump (vat_main_t * vam)
11255 vl_api_sw_interface_tap_dump_t *mp;
11256 vl_api_control_ping_t *mp_ping;
11259 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
11260 /* Get list of tap interfaces */
11261 M (SW_INTERFACE_TAP_DUMP, mp);
11264 /* Use a control ping for synchronization */
11265 M (CONTROL_PING, mp_ping);
11272 static uword unformat_vxlan_decap_next
11273 (unformat_input_t * input, va_list * args)
11275 u32 *result = va_arg (*args, u32 *);
11278 if (unformat (input, "l2"))
11279 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11280 else if (unformat (input, "%d", &tmp))
11288 api_vxlan_add_del_tunnel (vat_main_t * vam)
11290 unformat_input_t *line_input = vam->input;
11291 vl_api_vxlan_add_del_tunnel_t *mp;
11292 ip46_address_t src, dst;
11294 u8 ipv4_set = 0, ipv6_set = 0;
11298 u32 mcast_sw_if_index = ~0;
11299 u32 encap_vrf_id = 0;
11300 u32 decap_next_index = ~0;
11304 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11305 memset (&src, 0, sizeof src);
11306 memset (&dst, 0, sizeof dst);
11308 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11310 if (unformat (line_input, "del"))
11313 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11319 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11325 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11331 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11336 else if (unformat (line_input, "group %U %U",
11337 unformat_ip4_address, &dst.ip4,
11338 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11340 grp_set = dst_set = 1;
11343 else if (unformat (line_input, "group %U",
11344 unformat_ip4_address, &dst.ip4))
11346 grp_set = dst_set = 1;
11349 else if (unformat (line_input, "group %U %U",
11350 unformat_ip6_address, &dst.ip6,
11351 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11353 grp_set = dst_set = 1;
11356 else if (unformat (line_input, "group %U",
11357 unformat_ip6_address, &dst.ip6))
11359 grp_set = dst_set = 1;
11363 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11365 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11367 else if (unformat (line_input, "decap-next %U",
11368 unformat_vxlan_decap_next, &decap_next_index))
11370 else if (unformat (line_input, "vni %d", &vni))
11374 errmsg ("parse error '%U'", format_unformat_error, line_input);
11381 errmsg ("tunnel src address not specified");
11386 errmsg ("tunnel dst address not specified");
11390 if (grp_set && !ip46_address_is_multicast (&dst))
11392 errmsg ("tunnel group address not multicast");
11395 if (grp_set && mcast_sw_if_index == ~0)
11397 errmsg ("tunnel nonexistent multicast device");
11400 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11402 errmsg ("tunnel dst address must be unicast");
11407 if (ipv4_set && ipv6_set)
11409 errmsg ("both IPv4 and IPv6 addresses specified");
11413 if ((vni == 0) || (vni >> 24))
11415 errmsg ("vni not specified or out of range");
11419 M (VXLAN_ADD_DEL_TUNNEL, mp);
11423 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
11424 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
11428 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
11429 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
11431 mp->encap_vrf_id = ntohl (encap_vrf_id);
11432 mp->decap_next_index = ntohl (decap_next_index);
11433 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11434 mp->vni = ntohl (vni);
11435 mp->is_add = is_add;
11436 mp->is_ipv6 = ipv6_set;
11443 static void vl_api_vxlan_tunnel_details_t_handler
11444 (vl_api_vxlan_tunnel_details_t * mp)
11446 vat_main_t *vam = &vat_main;
11447 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
11448 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
11450 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
11451 ntohl (mp->sw_if_index),
11452 format_ip46_address, &src, IP46_TYPE_ANY,
11453 format_ip46_address, &dst, IP46_TYPE_ANY,
11454 ntohl (mp->encap_vrf_id),
11455 ntohl (mp->decap_next_index), ntohl (mp->vni),
11456 ntohl (mp->mcast_sw_if_index));
11459 static void vl_api_vxlan_tunnel_details_t_handler_json
11460 (vl_api_vxlan_tunnel_details_t * mp)
11462 vat_main_t *vam = &vat_main;
11463 vat_json_node_t *node = NULL;
11465 if (VAT_JSON_ARRAY != vam->json_tree.type)
11467 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11468 vat_json_init_array (&vam->json_tree);
11470 node = vat_json_array_add (&vam->json_tree);
11472 vat_json_init_object (node);
11473 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11476 struct in6_addr ip6;
11478 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
11479 vat_json_object_add_ip6 (node, "src_address", ip6);
11480 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
11481 vat_json_object_add_ip6 (node, "dst_address", ip6);
11485 struct in_addr ip4;
11487 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
11488 vat_json_object_add_ip4 (node, "src_address", ip4);
11489 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
11490 vat_json_object_add_ip4 (node, "dst_address", ip4);
11492 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11493 vat_json_object_add_uint (node, "decap_next_index",
11494 ntohl (mp->decap_next_index));
11495 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11496 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11497 vat_json_object_add_uint (node, "mcast_sw_if_index",
11498 ntohl (mp->mcast_sw_if_index));
11502 api_vxlan_tunnel_dump (vat_main_t * vam)
11504 unformat_input_t *i = vam->input;
11505 vl_api_vxlan_tunnel_dump_t *mp;
11506 vl_api_control_ping_t *mp_ping;
11508 u8 sw_if_index_set = 0;
11511 /* Parse args required to build the message */
11512 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11514 if (unformat (i, "sw_if_index %d", &sw_if_index))
11515 sw_if_index_set = 1;
11520 if (sw_if_index_set == 0)
11525 if (!vam->json_output)
11527 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
11528 "sw_if_index", "src_address", "dst_address",
11529 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11532 /* Get list of vxlan-tunnel interfaces */
11533 M (VXLAN_TUNNEL_DUMP, mp);
11535 mp->sw_if_index = htonl (sw_if_index);
11539 /* Use a control ping for synchronization */
11540 M (CONTROL_PING, mp_ping);
11548 api_gre_add_del_tunnel (vat_main_t * vam)
11550 unformat_input_t *line_input = vam->input;
11551 vl_api_gre_add_del_tunnel_t *mp;
11552 ip4_address_t src4, dst4;
11553 ip6_address_t src6, dst6;
11560 u32 outer_fib_id = 0;
11563 memset (&src4, 0, sizeof src4);
11564 memset (&dst4, 0, sizeof dst4);
11565 memset (&src6, 0, sizeof src6);
11566 memset (&dst6, 0, sizeof dst6);
11568 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11570 if (unformat (line_input, "del"))
11572 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
11577 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
11582 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
11587 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
11592 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
11594 else if (unformat (line_input, "teb"))
11598 errmsg ("parse error '%U'", format_unformat_error, line_input);
11605 errmsg ("tunnel src address not specified");
11610 errmsg ("tunnel dst address not specified");
11613 if (ipv4_set && ipv6_set)
11615 errmsg ("both IPv4 and IPv6 addresses specified");
11620 M (GRE_ADD_DEL_TUNNEL, mp);
11624 clib_memcpy (&mp->src_address, &src4, 4);
11625 clib_memcpy (&mp->dst_address, &dst4, 4);
11629 clib_memcpy (&mp->src_address, &src6, 16);
11630 clib_memcpy (&mp->dst_address, &dst6, 16);
11632 mp->outer_fib_id = ntohl (outer_fib_id);
11633 mp->is_add = is_add;
11635 mp->is_ipv6 = ipv6_set;
11642 static void vl_api_gre_tunnel_details_t_handler
11643 (vl_api_gre_tunnel_details_t * mp)
11645 vat_main_t *vam = &vat_main;
11646 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
11647 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
11649 print (vam->ofp, "%11d%24U%24U%6d%14d",
11650 ntohl (mp->sw_if_index),
11651 format_ip46_address, &src, IP46_TYPE_ANY,
11652 format_ip46_address, &dst, IP46_TYPE_ANY,
11653 mp->teb, ntohl (mp->outer_fib_id));
11656 static void vl_api_gre_tunnel_details_t_handler_json
11657 (vl_api_gre_tunnel_details_t * mp)
11659 vat_main_t *vam = &vat_main;
11660 vat_json_node_t *node = NULL;
11661 struct in_addr ip4;
11662 struct in6_addr ip6;
11664 if (VAT_JSON_ARRAY != vam->json_tree.type)
11666 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11667 vat_json_init_array (&vam->json_tree);
11669 node = vat_json_array_add (&vam->json_tree);
11671 vat_json_init_object (node);
11672 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11675 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11676 vat_json_object_add_ip4 (node, "src_address", ip4);
11677 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11678 vat_json_object_add_ip4 (node, "dst_address", ip4);
11682 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
11683 vat_json_object_add_ip6 (node, "src_address", ip6);
11684 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
11685 vat_json_object_add_ip6 (node, "dst_address", ip6);
11687 vat_json_object_add_uint (node, "teb", mp->teb);
11688 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11689 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
11693 api_gre_tunnel_dump (vat_main_t * vam)
11695 unformat_input_t *i = vam->input;
11696 vl_api_gre_tunnel_dump_t *mp;
11697 vl_api_control_ping_t *mp_ping;
11699 u8 sw_if_index_set = 0;
11702 /* Parse args required to build the message */
11703 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11705 if (unformat (i, "sw_if_index %d", &sw_if_index))
11706 sw_if_index_set = 1;
11711 if (sw_if_index_set == 0)
11716 if (!vam->json_output)
11718 print (vam->ofp, "%11s%24s%24s%6s%14s",
11719 "sw_if_index", "src_address", "dst_address", "teb",
11723 /* Get list of gre-tunnel interfaces */
11724 M (GRE_TUNNEL_DUMP, mp);
11726 mp->sw_if_index = htonl (sw_if_index);
11730 /* Use a control ping for synchronization */
11731 M (CONTROL_PING, mp_ping);
11739 api_l2_fib_clear_table (vat_main_t * vam)
11741 // unformat_input_t * i = vam->input;
11742 vl_api_l2_fib_clear_table_t *mp;
11745 M (L2_FIB_CLEAR_TABLE, mp);
11753 api_l2_interface_efp_filter (vat_main_t * vam)
11755 unformat_input_t *i = vam->input;
11756 vl_api_l2_interface_efp_filter_t *mp;
11759 u8 sw_if_index_set = 0;
11762 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11764 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11765 sw_if_index_set = 1;
11766 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11767 sw_if_index_set = 1;
11768 else if (unformat (i, "enable"))
11770 else if (unformat (i, "disable"))
11774 clib_warning ("parse error '%U'", format_unformat_error, i);
11779 if (sw_if_index_set == 0)
11781 errmsg ("missing sw_if_index");
11785 M (L2_INTERFACE_EFP_FILTER, mp);
11787 mp->sw_if_index = ntohl (sw_if_index);
11788 mp->enable_disable = enable;
11795 #define foreach_vtr_op \
11796 _("disable", L2_VTR_DISABLED) \
11797 _("push-1", L2_VTR_PUSH_1) \
11798 _("push-2", L2_VTR_PUSH_2) \
11799 _("pop-1", L2_VTR_POP_1) \
11800 _("pop-2", L2_VTR_POP_2) \
11801 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11802 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11803 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11804 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11807 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11809 unformat_input_t *i = vam->input;
11810 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11812 u8 sw_if_index_set = 0;
11815 u32 push_dot1q = 1;
11820 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11822 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11823 sw_if_index_set = 1;
11824 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11825 sw_if_index_set = 1;
11826 else if (unformat (i, "vtr_op %d", &vtr_op))
11828 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11831 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11833 else if (unformat (i, "tag1 %d", &tag1))
11835 else if (unformat (i, "tag2 %d", &tag2))
11839 clib_warning ("parse error '%U'", format_unformat_error, i);
11844 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11846 errmsg ("missing vtr operation or sw_if_index");
11850 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11851 mp->sw_if_index = ntohl (sw_if_index);
11852 mp->vtr_op = ntohl (vtr_op);
11853 mp->push_dot1q = ntohl (push_dot1q);
11854 mp->tag1 = ntohl (tag1);
11855 mp->tag2 = ntohl (tag2);
11863 api_create_vhost_user_if (vat_main_t * vam)
11865 unformat_input_t *i = vam->input;
11866 vl_api_create_vhost_user_if_t *mp;
11869 u8 file_name_set = 0;
11870 u32 custom_dev_instance = ~0;
11872 u8 use_custom_mac = 0;
11876 /* Shut up coverity */
11877 memset (hwaddr, 0, sizeof (hwaddr));
11879 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11881 if (unformat (i, "socket %s", &file_name))
11885 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11887 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11888 use_custom_mac = 1;
11889 else if (unformat (i, "server"))
11891 else if (unformat (i, "tag %s", &tag))
11897 if (file_name_set == 0)
11899 errmsg ("missing socket file name");
11903 if (vec_len (file_name) > 255)
11905 errmsg ("socket file name too long");
11908 vec_add1 (file_name, 0);
11910 M (CREATE_VHOST_USER_IF, mp);
11912 mp->is_server = is_server;
11913 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11914 vec_free (file_name);
11915 if (custom_dev_instance != ~0)
11918 mp->custom_dev_instance = ntohl (custom_dev_instance);
11920 mp->use_custom_mac = use_custom_mac;
11921 clib_memcpy (mp->mac_address, hwaddr, 6);
11923 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11932 api_modify_vhost_user_if (vat_main_t * vam)
11934 unformat_input_t *i = vam->input;
11935 vl_api_modify_vhost_user_if_t *mp;
11938 u8 file_name_set = 0;
11939 u32 custom_dev_instance = ~0;
11940 u8 sw_if_index_set = 0;
11941 u32 sw_if_index = (u32) ~ 0;
11944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11946 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11947 sw_if_index_set = 1;
11948 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11949 sw_if_index_set = 1;
11950 else if (unformat (i, "socket %s", &file_name))
11954 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11956 else if (unformat (i, "server"))
11962 if (sw_if_index_set == 0)
11964 errmsg ("missing sw_if_index or interface name");
11968 if (file_name_set == 0)
11970 errmsg ("missing socket file name");
11974 if (vec_len (file_name) > 255)
11976 errmsg ("socket file name too long");
11979 vec_add1 (file_name, 0);
11981 M (MODIFY_VHOST_USER_IF, mp);
11983 mp->sw_if_index = ntohl (sw_if_index);
11984 mp->is_server = is_server;
11985 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11986 vec_free (file_name);
11987 if (custom_dev_instance != ~0)
11990 mp->custom_dev_instance = ntohl (custom_dev_instance);
11999 api_delete_vhost_user_if (vat_main_t * vam)
12001 unformat_input_t *i = vam->input;
12002 vl_api_delete_vhost_user_if_t *mp;
12003 u32 sw_if_index = ~0;
12004 u8 sw_if_index_set = 0;
12007 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12009 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12010 sw_if_index_set = 1;
12011 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12012 sw_if_index_set = 1;
12017 if (sw_if_index_set == 0)
12019 errmsg ("missing sw_if_index or interface name");
12024 M (DELETE_VHOST_USER_IF, mp);
12026 mp->sw_if_index = ntohl (sw_if_index);
12033 static void vl_api_sw_interface_vhost_user_details_t_handler
12034 (vl_api_sw_interface_vhost_user_details_t * mp)
12036 vat_main_t *vam = &vat_main;
12038 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12039 (char *) mp->interface_name,
12040 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12041 clib_net_to_host_u64 (mp->features), mp->is_server,
12042 ntohl (mp->num_regions), (char *) mp->sock_filename);
12043 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12046 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12047 (vl_api_sw_interface_vhost_user_details_t * mp)
12049 vat_main_t *vam = &vat_main;
12050 vat_json_node_t *node = NULL;
12052 if (VAT_JSON_ARRAY != vam->json_tree.type)
12054 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12055 vat_json_init_array (&vam->json_tree);
12057 node = vat_json_array_add (&vam->json_tree);
12059 vat_json_init_object (node);
12060 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12061 vat_json_object_add_string_copy (node, "interface_name",
12062 mp->interface_name);
12063 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12064 ntohl (mp->virtio_net_hdr_sz));
12065 vat_json_object_add_uint (node, "features",
12066 clib_net_to_host_u64 (mp->features));
12067 vat_json_object_add_uint (node, "is_server", mp->is_server);
12068 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12069 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12070 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12074 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12076 vl_api_sw_interface_vhost_user_dump_t *mp;
12077 vl_api_control_ping_t *mp_ping;
12080 "Interface name idx hdr_sz features server regions filename");
12082 /* Get list of vhost-user interfaces */
12083 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12086 /* Use a control ping for synchronization */
12087 M (CONTROL_PING, mp_ping);
12095 api_show_version (vat_main_t * vam)
12097 vl_api_show_version_t *mp;
12100 M (SHOW_VERSION, mp);
12109 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12111 unformat_input_t *line_input = vam->input;
12112 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12113 ip4_address_t local4, remote4;
12114 ip6_address_t local6, remote6;
12116 u8 ipv4_set = 0, ipv6_set = 0;
12120 u32 mcast_sw_if_index = ~0;
12121 u32 encap_vrf_id = 0;
12122 u32 decap_vrf_id = 0;
12128 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12129 memset (&local4, 0, sizeof local4);
12130 memset (&remote4, 0, sizeof remote4);
12131 memset (&local6, 0, sizeof local6);
12132 memset (&remote6, 0, sizeof remote6);
12134 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12136 if (unformat (line_input, "del"))
12138 else if (unformat (line_input, "local %U",
12139 unformat_ip4_address, &local4))
12144 else if (unformat (line_input, "remote %U",
12145 unformat_ip4_address, &remote4))
12150 else if (unformat (line_input, "local %U",
12151 unformat_ip6_address, &local6))
12156 else if (unformat (line_input, "remote %U",
12157 unformat_ip6_address, &remote6))
12162 else if (unformat (line_input, "group %U %U",
12163 unformat_ip4_address, &remote4,
12164 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12166 grp_set = remote_set = 1;
12169 else if (unformat (line_input, "group %U",
12170 unformat_ip4_address, &remote4))
12172 grp_set = remote_set = 1;
12175 else if (unformat (line_input, "group %U %U",
12176 unformat_ip6_address, &remote6,
12177 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12179 grp_set = remote_set = 1;
12182 else if (unformat (line_input, "group %U",
12183 unformat_ip6_address, &remote6))
12185 grp_set = remote_set = 1;
12189 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12191 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12193 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
12195 else if (unformat (line_input, "vni %d", &vni))
12197 else if (unformat (line_input, "next-ip4"))
12199 else if (unformat (line_input, "next-ip6"))
12201 else if (unformat (line_input, "next-ethernet"))
12203 else if (unformat (line_input, "next-nsh"))
12207 errmsg ("parse error '%U'", format_unformat_error, line_input);
12212 if (local_set == 0)
12214 errmsg ("tunnel local address not specified");
12217 if (remote_set == 0)
12219 errmsg ("tunnel remote address not specified");
12222 if (grp_set && mcast_sw_if_index == ~0)
12224 errmsg ("tunnel nonexistent multicast device");
12227 if (ipv4_set && ipv6_set)
12229 errmsg ("both IPv4 and IPv6 addresses specified");
12235 errmsg ("vni not specified");
12239 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
12244 clib_memcpy (&mp->local, &local6, sizeof (local6));
12245 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
12249 clib_memcpy (&mp->local, &local4, sizeof (local4));
12250 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
12253 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12254 mp->encap_vrf_id = ntohl (encap_vrf_id);
12255 mp->decap_vrf_id = ntohl (decap_vrf_id);
12256 mp->protocol = protocol;
12257 mp->vni = ntohl (vni);
12258 mp->is_add = is_add;
12259 mp->is_ipv6 = ipv6_set;
12266 static void vl_api_vxlan_gpe_tunnel_details_t_handler
12267 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12269 vat_main_t *vam = &vat_main;
12270 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
12271 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
12273 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
12274 ntohl (mp->sw_if_index),
12275 format_ip46_address, &local, IP46_TYPE_ANY,
12276 format_ip46_address, &remote, IP46_TYPE_ANY,
12277 ntohl (mp->vni), mp->protocol,
12278 ntohl (mp->mcast_sw_if_index),
12279 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
12283 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
12284 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12286 vat_main_t *vam = &vat_main;
12287 vat_json_node_t *node = NULL;
12288 struct in_addr ip4;
12289 struct in6_addr ip6;
12291 if (VAT_JSON_ARRAY != vam->json_tree.type)
12293 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12294 vat_json_init_array (&vam->json_tree);
12296 node = vat_json_array_add (&vam->json_tree);
12298 vat_json_init_object (node);
12299 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12302 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
12303 vat_json_object_add_ip6 (node, "local", ip6);
12304 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
12305 vat_json_object_add_ip6 (node, "remote", ip6);
12309 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
12310 vat_json_object_add_ip4 (node, "local", ip4);
12311 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
12312 vat_json_object_add_ip4 (node, "remote", ip4);
12314 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12315 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
12316 vat_json_object_add_uint (node, "mcast_sw_if_index",
12317 ntohl (mp->mcast_sw_if_index));
12318 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12319 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
12320 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12324 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
12326 unformat_input_t *i = vam->input;
12327 vl_api_vxlan_gpe_tunnel_dump_t *mp;
12328 vl_api_control_ping_t *mp_ping;
12330 u8 sw_if_index_set = 0;
12333 /* Parse args required to build the message */
12334 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12336 if (unformat (i, "sw_if_index %d", &sw_if_index))
12337 sw_if_index_set = 1;
12342 if (sw_if_index_set == 0)
12347 if (!vam->json_output)
12349 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
12350 "sw_if_index", "local", "remote", "vni",
12351 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
12354 /* Get list of vxlan-tunnel interfaces */
12355 M (VXLAN_GPE_TUNNEL_DUMP, mp);
12357 mp->sw_if_index = htonl (sw_if_index);
12361 /* Use a control ping for synchronization */
12362 M (CONTROL_PING, mp_ping);
12371 format_l2_fib_mac_address (u8 * s, va_list * args)
12373 u8 *a = va_arg (*args, u8 *);
12375 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
12376 a[2], a[3], a[4], a[5], a[6], a[7]);
12379 static void vl_api_l2_fib_table_details_t_handler
12380 (vl_api_l2_fib_table_details_t * mp)
12382 vat_main_t *vam = &vat_main;
12384 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
12386 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
12387 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
12391 static void vl_api_l2_fib_table_details_t_handler_json
12392 (vl_api_l2_fib_table_details_t * mp)
12394 vat_main_t *vam = &vat_main;
12395 vat_json_node_t *node = NULL;
12397 if (VAT_JSON_ARRAY != vam->json_tree.type)
12399 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12400 vat_json_init_array (&vam->json_tree);
12402 node = vat_json_array_add (&vam->json_tree);
12404 vat_json_init_object (node);
12405 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
12406 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
12407 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12408 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
12409 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
12410 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
12414 api_l2_fib_table_dump (vat_main_t * vam)
12416 unformat_input_t *i = vam->input;
12417 vl_api_l2_fib_table_dump_t *mp;
12418 vl_api_control_ping_t *mp_ping;
12423 /* Parse args required to build the message */
12424 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12426 if (unformat (i, "bd_id %d", &bd_id))
12432 if (bd_id_set == 0)
12434 errmsg ("missing bridge domain");
12438 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
12440 /* Get list of l2 fib entries */
12441 M (L2_FIB_TABLE_DUMP, mp);
12443 mp->bd_id = ntohl (bd_id);
12446 /* Use a control ping for synchronization */
12447 M (CONTROL_PING, mp_ping);
12456 api_interface_name_renumber (vat_main_t * vam)
12458 unformat_input_t *line_input = vam->input;
12459 vl_api_interface_name_renumber_t *mp;
12460 u32 sw_if_index = ~0;
12461 u32 new_show_dev_instance = ~0;
12464 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12466 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
12469 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12471 else if (unformat (line_input, "new_show_dev_instance %d",
12472 &new_show_dev_instance))
12478 if (sw_if_index == ~0)
12480 errmsg ("missing interface name or sw_if_index");
12484 if (new_show_dev_instance == ~0)
12486 errmsg ("missing new_show_dev_instance");
12490 M (INTERFACE_NAME_RENUMBER, mp);
12492 mp->sw_if_index = ntohl (sw_if_index);
12493 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
12501 api_want_ip4_arp_events (vat_main_t * vam)
12503 unformat_input_t *line_input = vam->input;
12504 vl_api_want_ip4_arp_events_t *mp;
12505 ip4_address_t address;
12506 int address_set = 0;
12507 u32 enable_disable = 1;
12510 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12512 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
12514 else if (unformat (line_input, "del"))
12515 enable_disable = 0;
12520 if (address_set == 0)
12522 errmsg ("missing addresses");
12526 M (WANT_IP4_ARP_EVENTS, mp);
12527 mp->enable_disable = enable_disable;
12528 mp->pid = htonl (getpid ());
12529 mp->address = address.as_u32;
12537 api_want_ip6_nd_events (vat_main_t * vam)
12539 unformat_input_t *line_input = vam->input;
12540 vl_api_want_ip6_nd_events_t *mp;
12541 ip6_address_t address;
12542 int address_set = 0;
12543 u32 enable_disable = 1;
12546 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12548 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
12550 else if (unformat (line_input, "del"))
12551 enable_disable = 0;
12556 if (address_set == 0)
12558 errmsg ("missing addresses");
12562 M (WANT_IP6_ND_EVENTS, mp);
12563 mp->enable_disable = enable_disable;
12564 mp->pid = htonl (getpid ());
12565 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
12573 api_want_l2_macs_events (vat_main_t * vam)
12575 unformat_input_t *line_input = vam->input;
12576 vl_api_want_l2_macs_events_t *mp;
12577 u8 enable_disable = 1;
12578 u32 scan_delay = 0;
12579 u32 max_macs_in_event = 0;
12580 u32 learn_limit = 0;
12583 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12585 if (unformat (line_input, "learn-limit %d", &learn_limit))
12587 else if (unformat (line_input, "scan-delay %d", &scan_delay))
12589 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
12591 else if (unformat (line_input, "disable"))
12592 enable_disable = 0;
12597 M (WANT_L2_MACS_EVENTS, mp);
12598 mp->enable_disable = enable_disable;
12599 mp->pid = htonl (getpid ());
12600 mp->learn_limit = htonl (learn_limit);
12601 mp->scan_delay = (u8) scan_delay;
12602 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
12609 api_input_acl_set_interface (vat_main_t * vam)
12611 unformat_input_t *i = vam->input;
12612 vl_api_input_acl_set_interface_t *mp;
12614 int sw_if_index_set;
12615 u32 ip4_table_index = ~0;
12616 u32 ip6_table_index = ~0;
12617 u32 l2_table_index = ~0;
12621 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12623 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12624 sw_if_index_set = 1;
12625 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12626 sw_if_index_set = 1;
12627 else if (unformat (i, "del"))
12629 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12631 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12633 else if (unformat (i, "l2-table %d", &l2_table_index))
12637 clib_warning ("parse error '%U'", format_unformat_error, i);
12642 if (sw_if_index_set == 0)
12644 errmsg ("missing interface name or sw_if_index");
12648 M (INPUT_ACL_SET_INTERFACE, mp);
12650 mp->sw_if_index = ntohl (sw_if_index);
12651 mp->ip4_table_index = ntohl (ip4_table_index);
12652 mp->ip6_table_index = ntohl (ip6_table_index);
12653 mp->l2_table_index = ntohl (l2_table_index);
12654 mp->is_add = is_add;
12662 api_ip_address_dump (vat_main_t * vam)
12664 unformat_input_t *i = vam->input;
12665 vl_api_ip_address_dump_t *mp;
12666 vl_api_control_ping_t *mp_ping;
12667 u32 sw_if_index = ~0;
12668 u8 sw_if_index_set = 0;
12673 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12675 if (unformat (i, "sw_if_index %d", &sw_if_index))
12676 sw_if_index_set = 1;
12678 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12679 sw_if_index_set = 1;
12680 else if (unformat (i, "ipv4"))
12682 else if (unformat (i, "ipv6"))
12688 if (ipv4_set && ipv6_set)
12690 errmsg ("ipv4 and ipv6 flags cannot be both set");
12694 if ((!ipv4_set) && (!ipv6_set))
12696 errmsg ("no ipv4 nor ipv6 flag set");
12700 if (sw_if_index_set == 0)
12702 errmsg ("missing interface name or sw_if_index");
12706 vam->current_sw_if_index = sw_if_index;
12707 vam->is_ipv6 = ipv6_set;
12709 M (IP_ADDRESS_DUMP, mp);
12710 mp->sw_if_index = ntohl (sw_if_index);
12711 mp->is_ipv6 = ipv6_set;
12714 /* Use a control ping for synchronization */
12715 M (CONTROL_PING, mp_ping);
12723 api_ip_dump (vat_main_t * vam)
12725 vl_api_ip_dump_t *mp;
12726 vl_api_control_ping_t *mp_ping;
12727 unformat_input_t *in = vam->input;
12734 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
12736 if (unformat (in, "ipv4"))
12738 else if (unformat (in, "ipv6"))
12744 if (ipv4_set && ipv6_set)
12746 errmsg ("ipv4 and ipv6 flags cannot be both set");
12750 if ((!ipv4_set) && (!ipv6_set))
12752 errmsg ("no ipv4 nor ipv6 flag set");
12756 is_ipv6 = ipv6_set;
12757 vam->is_ipv6 = is_ipv6;
12759 /* free old data */
12760 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12762 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12764 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12767 mp->is_ipv6 = ipv6_set;
12770 /* Use a control ping for synchronization */
12771 M (CONTROL_PING, mp_ping);
12779 api_ipsec_spd_add_del (vat_main_t * vam)
12781 unformat_input_t *i = vam->input;
12782 vl_api_ipsec_spd_add_del_t *mp;
12787 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12789 if (unformat (i, "spd_id %d", &spd_id))
12791 else if (unformat (i, "del"))
12795 clib_warning ("parse error '%U'", format_unformat_error, i);
12801 errmsg ("spd_id must be set");
12805 M (IPSEC_SPD_ADD_DEL, mp);
12807 mp->spd_id = ntohl (spd_id);
12808 mp->is_add = is_add;
12816 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12818 unformat_input_t *i = vam->input;
12819 vl_api_ipsec_interface_add_del_spd_t *mp;
12821 u8 sw_if_index_set = 0;
12822 u32 spd_id = (u32) ~ 0;
12826 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12828 if (unformat (i, "del"))
12830 else if (unformat (i, "spd_id %d", &spd_id))
12833 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12834 sw_if_index_set = 1;
12835 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12836 sw_if_index_set = 1;
12839 clib_warning ("parse error '%U'", format_unformat_error, i);
12845 if (spd_id == (u32) ~ 0)
12847 errmsg ("spd_id must be set");
12851 if (sw_if_index_set == 0)
12853 errmsg ("missing interface name or sw_if_index");
12857 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12859 mp->spd_id = ntohl (spd_id);
12860 mp->sw_if_index = ntohl (sw_if_index);
12861 mp->is_add = is_add;
12869 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12871 unformat_input_t *i = vam->input;
12872 vl_api_ipsec_spd_add_del_entry_t *mp;
12873 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12874 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12876 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12877 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12878 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12879 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12882 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12883 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12884 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12885 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12886 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12887 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12889 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12891 if (unformat (i, "del"))
12893 if (unformat (i, "outbound"))
12895 if (unformat (i, "inbound"))
12897 else if (unformat (i, "spd_id %d", &spd_id))
12899 else if (unformat (i, "sa_id %d", &sa_id))
12901 else if (unformat (i, "priority %d", &priority))
12903 else if (unformat (i, "protocol %d", &protocol))
12905 else if (unformat (i, "lport_start %d", &lport_start))
12907 else if (unformat (i, "lport_stop %d", &lport_stop))
12909 else if (unformat (i, "rport_start %d", &rport_start))
12911 else if (unformat (i, "rport_stop %d", &rport_stop))
12915 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12921 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12928 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12934 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12941 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12947 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12954 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12960 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12966 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12968 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12970 clib_warning ("unsupported action: 'resolve'");
12976 clib_warning ("parse error '%U'", format_unformat_error, i);
12982 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12984 mp->spd_id = ntohl (spd_id);
12985 mp->priority = ntohl (priority);
12986 mp->is_outbound = is_outbound;
12988 mp->is_ipv6 = is_ipv6;
12989 if (is_ipv6 || is_ip_any)
12991 clib_memcpy (mp->remote_address_start, &raddr6_start,
12992 sizeof (ip6_address_t));
12993 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12994 sizeof (ip6_address_t));
12995 clib_memcpy (mp->local_address_start, &laddr6_start,
12996 sizeof (ip6_address_t));
12997 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12998 sizeof (ip6_address_t));
13002 clib_memcpy (mp->remote_address_start, &raddr4_start,
13003 sizeof (ip4_address_t));
13004 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
13005 sizeof (ip4_address_t));
13006 clib_memcpy (mp->local_address_start, &laddr4_start,
13007 sizeof (ip4_address_t));
13008 clib_memcpy (mp->local_address_stop, &laddr4_stop,
13009 sizeof (ip4_address_t));
13011 mp->protocol = (u8) protocol;
13012 mp->local_port_start = ntohs ((u16) lport_start);
13013 mp->local_port_stop = ntohs ((u16) lport_stop);
13014 mp->remote_port_start = ntohs ((u16) rport_start);
13015 mp->remote_port_stop = ntohs ((u16) rport_stop);
13016 mp->policy = (u8) policy;
13017 mp->sa_id = ntohl (sa_id);
13018 mp->is_add = is_add;
13019 mp->is_ip_any = is_ip_any;
13026 api_ipsec_sad_add_del_entry (vat_main_t * vam)
13028 unformat_input_t *i = vam->input;
13029 vl_api_ipsec_sad_add_del_entry_t *mp;
13030 u32 sad_id = 0, spi = 0;
13031 u8 *ck = 0, *ik = 0;
13034 u8 protocol = IPSEC_PROTOCOL_AH;
13035 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
13036 u32 crypto_alg = 0, integ_alg = 0;
13037 ip4_address_t tun_src4;
13038 ip4_address_t tun_dst4;
13039 ip6_address_t tun_src6;
13040 ip6_address_t tun_dst6;
13043 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13045 if (unformat (i, "del"))
13047 else if (unformat (i, "sad_id %d", &sad_id))
13049 else if (unformat (i, "spi %d", &spi))
13051 else if (unformat (i, "esp"))
13052 protocol = IPSEC_PROTOCOL_ESP;
13053 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
13056 is_tunnel_ipv6 = 0;
13058 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
13061 is_tunnel_ipv6 = 0;
13063 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
13066 is_tunnel_ipv6 = 1;
13068 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
13071 is_tunnel_ipv6 = 1;
13075 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13077 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13078 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13080 clib_warning ("unsupported crypto-alg: '%U'",
13081 format_ipsec_crypto_alg, crypto_alg);
13085 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13089 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13091 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13092 integ_alg >= IPSEC_INTEG_N_ALG)
13094 clib_warning ("unsupported integ-alg: '%U'",
13095 format_ipsec_integ_alg, integ_alg);
13099 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13103 clib_warning ("parse error '%U'", format_unformat_error, i);
13109 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
13111 mp->sad_id = ntohl (sad_id);
13112 mp->is_add = is_add;
13113 mp->protocol = protocol;
13114 mp->spi = ntohl (spi);
13115 mp->is_tunnel = is_tunnel;
13116 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
13117 mp->crypto_algorithm = crypto_alg;
13118 mp->integrity_algorithm = integ_alg;
13119 mp->crypto_key_length = vec_len (ck);
13120 mp->integrity_key_length = vec_len (ik);
13122 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13123 mp->crypto_key_length = sizeof (mp->crypto_key);
13125 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13126 mp->integrity_key_length = sizeof (mp->integrity_key);
13129 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13131 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13135 if (is_tunnel_ipv6)
13137 clib_memcpy (mp->tunnel_src_address, &tun_src6,
13138 sizeof (ip6_address_t));
13139 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
13140 sizeof (ip6_address_t));
13144 clib_memcpy (mp->tunnel_src_address, &tun_src4,
13145 sizeof (ip4_address_t));
13146 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
13147 sizeof (ip4_address_t));
13157 api_ipsec_sa_set_key (vat_main_t * vam)
13159 unformat_input_t *i = vam->input;
13160 vl_api_ipsec_sa_set_key_t *mp;
13162 u8 *ck = 0, *ik = 0;
13165 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13167 if (unformat (i, "sa_id %d", &sa_id))
13169 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13171 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13175 clib_warning ("parse error '%U'", format_unformat_error, i);
13180 M (IPSEC_SA_SET_KEY, mp);
13182 mp->sa_id = ntohl (sa_id);
13183 mp->crypto_key_length = vec_len (ck);
13184 mp->integrity_key_length = vec_len (ik);
13186 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13187 mp->crypto_key_length = sizeof (mp->crypto_key);
13189 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13190 mp->integrity_key_length = sizeof (mp->integrity_key);
13193 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13195 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13203 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
13205 unformat_input_t *i = vam->input;
13206 vl_api_ipsec_tunnel_if_add_del_t *mp;
13207 u32 local_spi = 0, remote_spi = 0;
13208 u32 crypto_alg = 0, integ_alg = 0;
13209 u8 *lck = NULL, *rck = NULL;
13210 u8 *lik = NULL, *rik = NULL;
13211 ip4_address_t local_ip = { {0} };
13212 ip4_address_t remote_ip = { {0} };
13215 u8 anti_replay = 0;
13218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13220 if (unformat (i, "del"))
13222 else if (unformat (i, "esn"))
13224 else if (unformat (i, "anti_replay"))
13226 else if (unformat (i, "local_spi %d", &local_spi))
13228 else if (unformat (i, "remote_spi %d", &remote_spi))
13230 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
13232 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
13234 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
13237 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
13239 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
13241 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
13245 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13247 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13248 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13250 errmsg ("unsupported crypto-alg: '%U'\n",
13251 format_ipsec_crypto_alg, crypto_alg);
13257 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13259 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13260 integ_alg >= IPSEC_INTEG_N_ALG)
13262 errmsg ("unsupported integ-alg: '%U'\n",
13263 format_ipsec_integ_alg, integ_alg);
13269 errmsg ("parse error '%U'\n", format_unformat_error, i);
13274 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
13276 mp->is_add = is_add;
13278 mp->anti_replay = anti_replay;
13280 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
13281 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
13283 mp->local_spi = htonl (local_spi);
13284 mp->remote_spi = htonl (remote_spi);
13285 mp->crypto_alg = (u8) crypto_alg;
13287 mp->local_crypto_key_len = 0;
13290 mp->local_crypto_key_len = vec_len (lck);
13291 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
13292 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
13293 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
13296 mp->remote_crypto_key_len = 0;
13299 mp->remote_crypto_key_len = vec_len (rck);
13300 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
13301 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
13302 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
13305 mp->integ_alg = (u8) integ_alg;
13307 mp->local_integ_key_len = 0;
13310 mp->local_integ_key_len = vec_len (lik);
13311 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
13312 mp->local_integ_key_len = sizeof (mp->local_integ_key);
13313 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
13316 mp->remote_integ_key_len = 0;
13319 mp->remote_integ_key_len = vec_len (rik);
13320 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
13321 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
13322 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
13331 api_ikev2_profile_add_del (vat_main_t * vam)
13333 unformat_input_t *i = vam->input;
13334 vl_api_ikev2_profile_add_del_t *mp;
13339 const char *valid_chars = "a-zA-Z0-9_";
13341 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13343 if (unformat (i, "del"))
13345 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13346 vec_add1 (name, 0);
13349 errmsg ("parse error '%U'", format_unformat_error, i);
13354 if (!vec_len (name))
13356 errmsg ("profile name must be specified");
13360 if (vec_len (name) > 64)
13362 errmsg ("profile name too long");
13366 M (IKEV2_PROFILE_ADD_DEL, mp);
13368 clib_memcpy (mp->name, name, vec_len (name));
13369 mp->is_add = is_add;
13378 api_ikev2_profile_set_auth (vat_main_t * vam)
13380 unformat_input_t *i = vam->input;
13381 vl_api_ikev2_profile_set_auth_t *mp;
13384 u32 auth_method = 0;
13388 const char *valid_chars = "a-zA-Z0-9_";
13390 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13392 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13393 vec_add1 (name, 0);
13394 else if (unformat (i, "auth_method %U",
13395 unformat_ikev2_auth_method, &auth_method))
13397 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
13399 else if (unformat (i, "auth_data %v", &data))
13403 errmsg ("parse error '%U'", format_unformat_error, i);
13408 if (!vec_len (name))
13410 errmsg ("profile name must be specified");
13414 if (vec_len (name) > 64)
13416 errmsg ("profile name too long");
13420 if (!vec_len (data))
13422 errmsg ("auth_data must be specified");
13428 errmsg ("auth_method must be specified");
13432 M (IKEV2_PROFILE_SET_AUTH, mp);
13434 mp->is_hex = is_hex;
13435 mp->auth_method = (u8) auth_method;
13436 mp->data_len = vec_len (data);
13437 clib_memcpy (mp->name, name, vec_len (name));
13438 clib_memcpy (mp->data, data, vec_len (data));
13448 api_ikev2_profile_set_id (vat_main_t * vam)
13450 unformat_input_t *i = vam->input;
13451 vl_api_ikev2_profile_set_id_t *mp;
13459 const char *valid_chars = "a-zA-Z0-9_";
13461 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13463 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13464 vec_add1 (name, 0);
13465 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
13467 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
13469 data = vec_new (u8, 4);
13470 clib_memcpy (data, ip4.as_u8, 4);
13472 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
13474 else if (unformat (i, "id_data %v", &data))
13476 else if (unformat (i, "local"))
13478 else if (unformat (i, "remote"))
13482 errmsg ("parse error '%U'", format_unformat_error, i);
13487 if (!vec_len (name))
13489 errmsg ("profile name must be specified");
13493 if (vec_len (name) > 64)
13495 errmsg ("profile name too long");
13499 if (!vec_len (data))
13501 errmsg ("id_data must be specified");
13507 errmsg ("id_type must be specified");
13511 M (IKEV2_PROFILE_SET_ID, mp);
13513 mp->is_local = is_local;
13514 mp->id_type = (u8) id_type;
13515 mp->data_len = vec_len (data);
13516 clib_memcpy (mp->name, name, vec_len (name));
13517 clib_memcpy (mp->data, data, vec_len (data));
13527 api_ikev2_profile_set_ts (vat_main_t * vam)
13529 unformat_input_t *i = vam->input;
13530 vl_api_ikev2_profile_set_ts_t *mp;
13533 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
13534 ip4_address_t start_addr, end_addr;
13536 const char *valid_chars = "a-zA-Z0-9_";
13539 start_addr.as_u32 = 0;
13540 end_addr.as_u32 = (u32) ~ 0;
13542 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13544 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13545 vec_add1 (name, 0);
13546 else if (unformat (i, "protocol %d", &proto))
13548 else if (unformat (i, "start_port %d", &start_port))
13550 else if (unformat (i, "end_port %d", &end_port))
13553 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
13555 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
13557 else if (unformat (i, "local"))
13559 else if (unformat (i, "remote"))
13563 errmsg ("parse error '%U'", format_unformat_error, i);
13568 if (!vec_len (name))
13570 errmsg ("profile name must be specified");
13574 if (vec_len (name) > 64)
13576 errmsg ("profile name too long");
13580 M (IKEV2_PROFILE_SET_TS, mp);
13582 mp->is_local = is_local;
13583 mp->proto = (u8) proto;
13584 mp->start_port = (u16) start_port;
13585 mp->end_port = (u16) end_port;
13586 mp->start_addr = start_addr.as_u32;
13587 mp->end_addr = end_addr.as_u32;
13588 clib_memcpy (mp->name, name, vec_len (name));
13597 api_ikev2_set_local_key (vat_main_t * vam)
13599 unformat_input_t *i = vam->input;
13600 vl_api_ikev2_set_local_key_t *mp;
13604 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13606 if (unformat (i, "file %v", &file))
13607 vec_add1 (file, 0);
13610 errmsg ("parse error '%U'", format_unformat_error, i);
13615 if (!vec_len (file))
13617 errmsg ("RSA key file must be specified");
13621 if (vec_len (file) > 256)
13623 errmsg ("file name too long");
13627 M (IKEV2_SET_LOCAL_KEY, mp);
13629 clib_memcpy (mp->key_file, file, vec_len (file));
13638 api_ikev2_set_responder (vat_main_t * vam)
13640 unformat_input_t *i = vam->input;
13641 vl_api_ikev2_set_responder_t *mp;
13644 u32 sw_if_index = ~0;
13645 ip4_address_t address;
13647 const char *valid_chars = "a-zA-Z0-9_";
13649 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13652 (i, "%U interface %d address %U", unformat_token, valid_chars,
13653 &name, &sw_if_index, unformat_ip4_address, &address))
13654 vec_add1 (name, 0);
13657 errmsg ("parse error '%U'", format_unformat_error, i);
13662 if (!vec_len (name))
13664 errmsg ("profile name must be specified");
13668 if (vec_len (name) > 64)
13670 errmsg ("profile name too long");
13674 M (IKEV2_SET_RESPONDER, mp);
13676 clib_memcpy (mp->name, name, vec_len (name));
13679 mp->sw_if_index = sw_if_index;
13680 clib_memcpy (mp->address, &address, sizeof (address));
13688 api_ikev2_set_ike_transforms (vat_main_t * vam)
13690 unformat_input_t *i = vam->input;
13691 vl_api_ikev2_set_ike_transforms_t *mp;
13694 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13696 const char *valid_chars = "a-zA-Z0-9_";
13698 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13700 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13701 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13702 vec_add1 (name, 0);
13705 errmsg ("parse error '%U'", format_unformat_error, i);
13710 if (!vec_len (name))
13712 errmsg ("profile name must be specified");
13716 if (vec_len (name) > 64)
13718 errmsg ("profile name too long");
13722 M (IKEV2_SET_IKE_TRANSFORMS, mp);
13724 clib_memcpy (mp->name, name, vec_len (name));
13726 mp->crypto_alg = crypto_alg;
13727 mp->crypto_key_size = crypto_key_size;
13728 mp->integ_alg = integ_alg;
13729 mp->dh_group = dh_group;
13738 api_ikev2_set_esp_transforms (vat_main_t * vam)
13740 unformat_input_t *i = vam->input;
13741 vl_api_ikev2_set_esp_transforms_t *mp;
13744 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13746 const char *valid_chars = "a-zA-Z0-9_";
13748 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13750 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13751 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13752 vec_add1 (name, 0);
13755 errmsg ("parse error '%U'", format_unformat_error, i);
13760 if (!vec_len (name))
13762 errmsg ("profile name must be specified");
13766 if (vec_len (name) > 64)
13768 errmsg ("profile name too long");
13772 M (IKEV2_SET_ESP_TRANSFORMS, mp);
13774 clib_memcpy (mp->name, name, vec_len (name));
13776 mp->crypto_alg = crypto_alg;
13777 mp->crypto_key_size = crypto_key_size;
13778 mp->integ_alg = integ_alg;
13779 mp->dh_group = dh_group;
13787 api_ikev2_set_sa_lifetime (vat_main_t * vam)
13789 unformat_input_t *i = vam->input;
13790 vl_api_ikev2_set_sa_lifetime_t *mp;
13793 u64 lifetime, lifetime_maxdata;
13794 u32 lifetime_jitter, handover;
13796 const char *valid_chars = "a-zA-Z0-9_";
13798 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13800 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
13801 &lifetime, &lifetime_jitter, &handover,
13802 &lifetime_maxdata))
13803 vec_add1 (name, 0);
13806 errmsg ("parse error '%U'", format_unformat_error, i);
13811 if (!vec_len (name))
13813 errmsg ("profile name must be specified");
13817 if (vec_len (name) > 64)
13819 errmsg ("profile name too long");
13823 M (IKEV2_SET_SA_LIFETIME, mp);
13825 clib_memcpy (mp->name, name, vec_len (name));
13827 mp->lifetime = lifetime;
13828 mp->lifetime_jitter = lifetime_jitter;
13829 mp->handover = handover;
13830 mp->lifetime_maxdata = lifetime_maxdata;
13838 api_ikev2_initiate_sa_init (vat_main_t * vam)
13840 unformat_input_t *i = vam->input;
13841 vl_api_ikev2_initiate_sa_init_t *mp;
13845 const char *valid_chars = "a-zA-Z0-9_";
13847 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13849 if (unformat (i, "%U", unformat_token, valid_chars, &name))
13850 vec_add1 (name, 0);
13853 errmsg ("parse error '%U'", format_unformat_error, i);
13858 if (!vec_len (name))
13860 errmsg ("profile name must be specified");
13864 if (vec_len (name) > 64)
13866 errmsg ("profile name too long");
13870 M (IKEV2_INITIATE_SA_INIT, mp);
13872 clib_memcpy (mp->name, name, vec_len (name));
13881 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
13883 unformat_input_t *i = vam->input;
13884 vl_api_ikev2_initiate_del_ike_sa_t *mp;
13889 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13891 if (unformat (i, "%lx", &ispi))
13895 errmsg ("parse error '%U'", format_unformat_error, i);
13900 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
13910 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13912 unformat_input_t *i = vam->input;
13913 vl_api_ikev2_initiate_del_child_sa_t *mp;
13918 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13920 if (unformat (i, "%x", &ispi))
13924 errmsg ("parse error '%U'", format_unformat_error, i);
13929 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13939 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13941 unformat_input_t *i = vam->input;
13942 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13947 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13949 if (unformat (i, "%x", &ispi))
13953 errmsg ("parse error '%U'", format_unformat_error, i);
13958 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
13971 api_map_add_domain (vat_main_t * vam)
13973 unformat_input_t *i = vam->input;
13974 vl_api_map_add_domain_t *mp;
13976 ip4_address_t ip4_prefix;
13977 ip6_address_t ip6_prefix;
13978 ip6_address_t ip6_src;
13979 u32 num_m_args = 0;
13980 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
13981 0, psid_length = 0;
13982 u8 is_translation = 0;
13984 u32 ip6_src_len = 128;
13987 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13989 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
13990 &ip4_prefix, &ip4_prefix_len))
13992 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
13993 &ip6_prefix, &ip6_prefix_len))
13997 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
14000 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
14002 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
14004 else if (unformat (i, "psid-offset %d", &psid_offset))
14006 else if (unformat (i, "psid-len %d", &psid_length))
14008 else if (unformat (i, "mtu %d", &mtu))
14010 else if (unformat (i, "map-t"))
14011 is_translation = 1;
14014 clib_warning ("parse error '%U'", format_unformat_error, i);
14019 if (num_m_args < 3)
14021 errmsg ("mandatory argument(s) missing");
14025 /* Construct the API message */
14026 M (MAP_ADD_DOMAIN, mp);
14028 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
14029 mp->ip4_prefix_len = ip4_prefix_len;
14031 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
14032 mp->ip6_prefix_len = ip6_prefix_len;
14034 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
14035 mp->ip6_src_prefix_len = ip6_src_len;
14037 mp->ea_bits_len = ea_bits_len;
14038 mp->psid_offset = psid_offset;
14039 mp->psid_length = psid_length;
14040 mp->is_translation = is_translation;
14041 mp->mtu = htons (mtu);
14046 /* Wait for a reply, return good/bad news */
14052 api_map_del_domain (vat_main_t * vam)
14054 unformat_input_t *i = vam->input;
14055 vl_api_map_del_domain_t *mp;
14057 u32 num_m_args = 0;
14061 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14063 if (unformat (i, "index %d", &index))
14067 clib_warning ("parse error '%U'", format_unformat_error, i);
14072 if (num_m_args != 1)
14074 errmsg ("mandatory argument(s) missing");
14078 /* Construct the API message */
14079 M (MAP_DEL_DOMAIN, mp);
14081 mp->index = ntohl (index);
14086 /* Wait for a reply, return good/bad news */
14092 api_map_add_del_rule (vat_main_t * vam)
14094 unformat_input_t *i = vam->input;
14095 vl_api_map_add_del_rule_t *mp;
14097 ip6_address_t ip6_dst;
14098 u32 num_m_args = 0, index, psid = 0;
14101 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14103 if (unformat (i, "index %d", &index))
14105 else if (unformat (i, "psid %d", &psid))
14107 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
14109 else if (unformat (i, "del"))
14115 clib_warning ("parse error '%U'", format_unformat_error, i);
14120 /* Construct the API message */
14121 M (MAP_ADD_DEL_RULE, mp);
14123 mp->index = ntohl (index);
14124 mp->is_add = is_add;
14125 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
14126 mp->psid = ntohs (psid);
14131 /* Wait for a reply, return good/bad news */
14137 api_map_domain_dump (vat_main_t * vam)
14139 vl_api_map_domain_dump_t *mp;
14140 vl_api_control_ping_t *mp_ping;
14143 /* Construct the API message */
14144 M (MAP_DOMAIN_DUMP, mp);
14149 /* Use a control ping for synchronization */
14150 M (CONTROL_PING, mp_ping);
14158 api_map_rule_dump (vat_main_t * vam)
14160 unformat_input_t *i = vam->input;
14161 vl_api_map_rule_dump_t *mp;
14162 vl_api_control_ping_t *mp_ping;
14163 u32 domain_index = ~0;
14166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14168 if (unformat (i, "index %u", &domain_index))
14174 if (domain_index == ~0)
14176 clib_warning ("parse error: domain index expected");
14180 /* Construct the API message */
14181 M (MAP_RULE_DUMP, mp);
14183 mp->domain_index = htonl (domain_index);
14188 /* Use a control ping for synchronization */
14189 M (CONTROL_PING, mp_ping);
14196 static void vl_api_map_add_domain_reply_t_handler
14197 (vl_api_map_add_domain_reply_t * mp)
14199 vat_main_t *vam = &vat_main;
14200 i32 retval = ntohl (mp->retval);
14202 if (vam->async_mode)
14204 vam->async_errors += (retval < 0);
14208 vam->retval = retval;
14209 vam->result_ready = 1;
14213 static void vl_api_map_add_domain_reply_t_handler_json
14214 (vl_api_map_add_domain_reply_t * mp)
14216 vat_main_t *vam = &vat_main;
14217 vat_json_node_t node;
14219 vat_json_init_object (&node);
14220 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
14221 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
14223 vat_json_print (vam->ofp, &node);
14224 vat_json_free (&node);
14226 vam->retval = ntohl (mp->retval);
14227 vam->result_ready = 1;
14231 api_get_first_msg_id (vat_main_t * vam)
14233 vl_api_get_first_msg_id_t *mp;
14234 unformat_input_t *i = vam->input;
14239 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14241 if (unformat (i, "client %s", &name))
14249 errmsg ("missing client name");
14252 vec_add1 (name, 0);
14254 if (vec_len (name) > 63)
14256 errmsg ("client name too long");
14260 M (GET_FIRST_MSG_ID, mp);
14261 clib_memcpy (mp->name, name, vec_len (name));
14268 api_cop_interface_enable_disable (vat_main_t * vam)
14270 unformat_input_t *line_input = vam->input;
14271 vl_api_cop_interface_enable_disable_t *mp;
14272 u32 sw_if_index = ~0;
14273 u8 enable_disable = 1;
14276 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14278 if (unformat (line_input, "disable"))
14279 enable_disable = 0;
14280 if (unformat (line_input, "enable"))
14281 enable_disable = 1;
14282 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14283 vam, &sw_if_index))
14285 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14291 if (sw_if_index == ~0)
14293 errmsg ("missing interface name or sw_if_index");
14297 /* Construct the API message */
14298 M (COP_INTERFACE_ENABLE_DISABLE, mp);
14299 mp->sw_if_index = ntohl (sw_if_index);
14300 mp->enable_disable = enable_disable;
14304 /* Wait for the reply */
14310 api_cop_whitelist_enable_disable (vat_main_t * vam)
14312 unformat_input_t *line_input = vam->input;
14313 vl_api_cop_whitelist_enable_disable_t *mp;
14314 u32 sw_if_index = ~0;
14315 u8 ip4 = 0, ip6 = 0, default_cop = 0;
14319 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14321 if (unformat (line_input, "ip4"))
14323 else if (unformat (line_input, "ip6"))
14325 else if (unformat (line_input, "default"))
14327 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14328 vam, &sw_if_index))
14330 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14332 else if (unformat (line_input, "fib-id %d", &fib_id))
14338 if (sw_if_index == ~0)
14340 errmsg ("missing interface name or sw_if_index");
14344 /* Construct the API message */
14345 M (COP_WHITELIST_ENABLE_DISABLE, mp);
14346 mp->sw_if_index = ntohl (sw_if_index);
14347 mp->fib_id = ntohl (fib_id);
14350 mp->default_cop = default_cop;
14354 /* Wait for the reply */
14360 api_get_node_graph (vat_main_t * vam)
14362 vl_api_get_node_graph_t *mp;
14365 M (GET_NODE_GRAPH, mp);
14369 /* Wait for the reply */
14375 /** Used for parsing LISP eids */
14376 typedef CLIB_PACKED(struct{
14377 u8 addr[16]; /**< eid address */
14378 u32 len; /**< prefix length if IP */
14379 u8 type; /**< type of eid */
14384 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14386 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14388 memset (a, 0, sizeof (a[0]));
14390 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
14392 a->type = 0; /* ipv4 type */
14394 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
14396 a->type = 1; /* ipv6 type */
14398 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
14400 a->type = 2; /* mac type */
14402 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
14404 a->type = 3; /* NSH type */
14405 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
14406 nsh->spi = clib_host_to_net_u32 (nsh->spi);
14413 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
14422 lisp_eid_size_vat (u8 type)
14439 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
14441 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
14445 api_one_add_del_locator_set (vat_main_t * vam)
14447 unformat_input_t *input = vam->input;
14448 vl_api_one_add_del_locator_set_t *mp;
14450 u8 *locator_set_name = NULL;
14451 u8 locator_set_name_set = 0;
14452 vl_api_local_locator_t locator, *locators = 0;
14453 u32 sw_if_index, priority, weight;
14457 /* Parse args required to build the message */
14458 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14460 if (unformat (input, "del"))
14464 else if (unformat (input, "locator-set %s", &locator_set_name))
14466 locator_set_name_set = 1;
14468 else if (unformat (input, "sw_if_index %u p %u w %u",
14469 &sw_if_index, &priority, &weight))
14471 locator.sw_if_index = htonl (sw_if_index);
14472 locator.priority = priority;
14473 locator.weight = weight;
14474 vec_add1 (locators, locator);
14478 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14479 &sw_if_index, &priority, &weight))
14481 locator.sw_if_index = htonl (sw_if_index);
14482 locator.priority = priority;
14483 locator.weight = weight;
14484 vec_add1 (locators, locator);
14490 if (locator_set_name_set == 0)
14492 errmsg ("missing locator-set name");
14493 vec_free (locators);
14497 if (vec_len (locator_set_name) > 64)
14499 errmsg ("locator-set name too long");
14500 vec_free (locator_set_name);
14501 vec_free (locators);
14504 vec_add1 (locator_set_name, 0);
14506 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14508 /* Construct the API message */
14509 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14511 mp->is_add = is_add;
14512 clib_memcpy (mp->locator_set_name, locator_set_name,
14513 vec_len (locator_set_name));
14514 vec_free (locator_set_name);
14516 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14518 clib_memcpy (mp->locators, locators, data_len);
14519 vec_free (locators);
14524 /* Wait for a reply... */
14529 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14532 api_one_add_del_locator (vat_main_t * vam)
14534 unformat_input_t *input = vam->input;
14535 vl_api_one_add_del_locator_t *mp;
14536 u32 tmp_if_index = ~0;
14537 u32 sw_if_index = ~0;
14538 u8 sw_if_index_set = 0;
14539 u8 sw_if_index_if_name_set = 0;
14541 u8 priority_set = 0;
14545 u8 *locator_set_name = NULL;
14546 u8 locator_set_name_set = 0;
14549 /* Parse args required to build the message */
14550 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14552 if (unformat (input, "del"))
14556 else if (unformat (input, "locator-set %s", &locator_set_name))
14558 locator_set_name_set = 1;
14560 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14563 sw_if_index_if_name_set = 1;
14564 sw_if_index = tmp_if_index;
14566 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14568 sw_if_index_set = 1;
14569 sw_if_index = tmp_if_index;
14571 else if (unformat (input, "p %d", &priority))
14575 else if (unformat (input, "w %d", &weight))
14583 if (locator_set_name_set == 0)
14585 errmsg ("missing locator-set name");
14589 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14591 errmsg ("missing sw_if_index");
14592 vec_free (locator_set_name);
14596 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14598 errmsg ("cannot use both params interface name and sw_if_index");
14599 vec_free (locator_set_name);
14603 if (priority_set == 0)
14605 errmsg ("missing locator-set priority");
14606 vec_free (locator_set_name);
14610 if (weight_set == 0)
14612 errmsg ("missing locator-set weight");
14613 vec_free (locator_set_name);
14617 if (vec_len (locator_set_name) > 64)
14619 errmsg ("locator-set name too long");
14620 vec_free (locator_set_name);
14623 vec_add1 (locator_set_name, 0);
14625 /* Construct the API message */
14626 M (ONE_ADD_DEL_LOCATOR, mp);
14628 mp->is_add = is_add;
14629 mp->sw_if_index = ntohl (sw_if_index);
14630 mp->priority = priority;
14631 mp->weight = weight;
14632 clib_memcpy (mp->locator_set_name, locator_set_name,
14633 vec_len (locator_set_name));
14634 vec_free (locator_set_name);
14639 /* Wait for a reply... */
14644 #define api_lisp_add_del_locator api_one_add_del_locator
14647 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14649 u32 *key_id = va_arg (*args, u32 *);
14652 if (unformat (input, "%s", &s))
14654 if (!strcmp ((char *) s, "sha1"))
14655 key_id[0] = HMAC_SHA_1_96;
14656 else if (!strcmp ((char *) s, "sha256"))
14657 key_id[0] = HMAC_SHA_256_128;
14660 clib_warning ("invalid key_id: '%s'", s);
14661 key_id[0] = HMAC_NO_KEY;
14672 api_one_add_del_local_eid (vat_main_t * vam)
14674 unformat_input_t *input = vam->input;
14675 vl_api_one_add_del_local_eid_t *mp;
14678 lisp_eid_vat_t _eid, *eid = &_eid;
14679 u8 *locator_set_name = 0;
14680 u8 locator_set_name_set = 0;
14686 /* Parse args required to build the message */
14687 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14689 if (unformat (input, "del"))
14693 else if (unformat (input, "vni %d", &vni))
14697 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14701 else if (unformat (input, "locator-set %s", &locator_set_name))
14703 locator_set_name_set = 1;
14705 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14707 else if (unformat (input, "secret-key %_%v%_", &key))
14713 if (locator_set_name_set == 0)
14715 errmsg ("missing locator-set name");
14721 errmsg ("EID address not set!");
14722 vec_free (locator_set_name);
14726 if (key && (0 == key_id))
14728 errmsg ("invalid key_id!");
14732 if (vec_len (key) > 64)
14734 errmsg ("key too long");
14739 if (vec_len (locator_set_name) > 64)
14741 errmsg ("locator-set name too long");
14742 vec_free (locator_set_name);
14745 vec_add1 (locator_set_name, 0);
14747 /* Construct the API message */
14748 M (ONE_ADD_DEL_LOCAL_EID, mp);
14750 mp->is_add = is_add;
14751 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14752 mp->eid_type = eid->type;
14753 mp->prefix_len = eid->len;
14754 mp->vni = clib_host_to_net_u32 (vni);
14755 mp->key_id = clib_host_to_net_u16 (key_id);
14756 clib_memcpy (mp->locator_set_name, locator_set_name,
14757 vec_len (locator_set_name));
14758 clib_memcpy (mp->key, key, vec_len (key));
14760 vec_free (locator_set_name);
14766 /* Wait for a reply... */
14771 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14774 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14776 u32 dp_table = 0, vni = 0;;
14777 unformat_input_t *input = vam->input;
14778 vl_api_gpe_add_del_fwd_entry_t *mp;
14780 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14781 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14782 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14783 u32 action = ~0, w;
14784 ip4_address_t rmt_rloc4, lcl_rloc4;
14785 ip6_address_t rmt_rloc6, lcl_rloc6;
14786 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14789 memset (&rloc, 0, sizeof (rloc));
14791 /* Parse args required to build the message */
14792 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14794 if (unformat (input, "del"))
14796 else if (unformat (input, "add"))
14798 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14802 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14806 else if (unformat (input, "vrf %d", &dp_table))
14808 else if (unformat (input, "bd %d", &dp_table))
14810 else if (unformat (input, "vni %d", &vni))
14812 else if (unformat (input, "w %d", &w))
14816 errmsg ("No RLOC configured for setting priority/weight!");
14819 curr_rloc->weight = w;
14821 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14822 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14826 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
14828 vec_add1 (lcl_locs, rloc);
14830 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
14831 vec_add1 (rmt_locs, rloc);
14832 /* weight saved in rmt loc */
14833 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14835 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14836 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14839 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
14841 vec_add1 (lcl_locs, rloc);
14843 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
14844 vec_add1 (rmt_locs, rloc);
14845 /* weight saved in rmt loc */
14846 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14848 else if (unformat (input, "action %d", &action))
14854 clib_warning ("parse error '%U'", format_unformat_error, input);
14861 errmsg ("remote eid addresses not set");
14865 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14867 errmsg ("eid types don't match");
14871 if (0 == rmt_locs && (u32) ~ 0 == action)
14873 errmsg ("action not set for negative mapping");
14877 /* Construct the API message */
14878 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14879 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14881 mp->is_add = is_add;
14882 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14883 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14884 mp->eid_type = rmt_eid->type;
14885 mp->dp_table = clib_host_to_net_u32 (dp_table);
14886 mp->vni = clib_host_to_net_u32 (vni);
14887 mp->rmt_len = rmt_eid->len;
14888 mp->lcl_len = lcl_eid->len;
14889 mp->action = action;
14891 if (0 != rmt_locs && 0 != lcl_locs)
14893 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14894 clib_memcpy (mp->locs, lcl_locs,
14895 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14897 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14898 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14899 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14901 vec_free (lcl_locs);
14902 vec_free (rmt_locs);
14907 /* Wait for a reply... */
14913 api_one_add_del_map_server (vat_main_t * vam)
14915 unformat_input_t *input = vam->input;
14916 vl_api_one_add_del_map_server_t *mp;
14920 ip4_address_t ipv4;
14921 ip6_address_t ipv6;
14924 /* Parse args required to build the message */
14925 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14927 if (unformat (input, "del"))
14931 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14935 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14943 if (ipv4_set && ipv6_set)
14945 errmsg ("both eid v4 and v6 addresses set");
14949 if (!ipv4_set && !ipv6_set)
14951 errmsg ("eid addresses not set");
14955 /* Construct the API message */
14956 M (ONE_ADD_DEL_MAP_SERVER, mp);
14958 mp->is_add = is_add;
14962 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14967 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14973 /* Wait for a reply... */
14978 #define api_lisp_add_del_map_server api_one_add_del_map_server
14981 api_one_add_del_map_resolver (vat_main_t * vam)
14983 unformat_input_t *input = vam->input;
14984 vl_api_one_add_del_map_resolver_t *mp;
14988 ip4_address_t ipv4;
14989 ip6_address_t ipv6;
14992 /* Parse args required to build the message */
14993 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14995 if (unformat (input, "del"))
14999 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15003 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15011 if (ipv4_set && ipv6_set)
15013 errmsg ("both eid v4 and v6 addresses set");
15017 if (!ipv4_set && !ipv6_set)
15019 errmsg ("eid addresses not set");
15023 /* Construct the API message */
15024 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15026 mp->is_add = is_add;
15030 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15035 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15041 /* Wait for a reply... */
15046 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
15049 api_lisp_gpe_enable_disable (vat_main_t * vam)
15051 unformat_input_t *input = vam->input;
15052 vl_api_gpe_enable_disable_t *mp;
15057 /* Parse args required to build the message */
15058 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15060 if (unformat (input, "enable"))
15065 else if (unformat (input, "disable"))
15076 errmsg ("Value not set");
15080 /* Construct the API message */
15081 M (GPE_ENABLE_DISABLE, mp);
15088 /* Wait for a reply... */
15094 api_one_rloc_probe_enable_disable (vat_main_t * vam)
15096 unformat_input_t *input = vam->input;
15097 vl_api_one_rloc_probe_enable_disable_t *mp;
15102 /* Parse args required to build the message */
15103 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15105 if (unformat (input, "enable"))
15110 else if (unformat (input, "disable"))
15118 errmsg ("Value not set");
15122 /* Construct the API message */
15123 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15125 mp->is_enabled = is_en;
15130 /* Wait for a reply... */
15135 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15138 api_one_map_register_enable_disable (vat_main_t * vam)
15140 unformat_input_t *input = vam->input;
15141 vl_api_one_map_register_enable_disable_t *mp;
15146 /* Parse args required to build the message */
15147 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15149 if (unformat (input, "enable"))
15154 else if (unformat (input, "disable"))
15162 errmsg ("Value not set");
15166 /* Construct the API message */
15167 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15169 mp->is_enabled = is_en;
15174 /* Wait for a reply... */
15179 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15182 api_one_enable_disable (vat_main_t * vam)
15184 unformat_input_t *input = vam->input;
15185 vl_api_one_enable_disable_t *mp;
15190 /* Parse args required to build the message */
15191 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15193 if (unformat (input, "enable"))
15198 else if (unformat (input, "disable"))
15208 errmsg ("Value not set");
15212 /* Construct the API message */
15213 M (ONE_ENABLE_DISABLE, mp);
15220 /* Wait for a reply... */
15225 #define api_lisp_enable_disable api_one_enable_disable
15228 api_show_one_map_register_state (vat_main_t * vam)
15230 vl_api_show_one_map_register_state_t *mp;
15233 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
15238 /* wait for reply */
15243 #define api_show_lisp_map_register_state api_show_one_map_register_state
15246 api_show_one_rloc_probe_state (vat_main_t * vam)
15248 vl_api_show_one_rloc_probe_state_t *mp;
15251 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
15256 /* wait for reply */
15261 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
15264 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15266 vl_api_one_add_del_l2_arp_entry_t *mp;
15267 unformat_input_t *input = vam->input;
15272 u8 mac[6] = { 0, };
15273 u32 ip4 = 0, bd = ~0;
15276 /* Parse args required to build the message */
15277 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15279 if (unformat (input, "del"))
15281 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15283 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15285 else if (unformat (input, "bd %d", &bd))
15289 errmsg ("parse error '%U'", format_unformat_error, input);
15294 if (!bd_set || !ip_set || (!mac_set && is_add))
15296 errmsg ("Missing BD, IP or MAC!");
15300 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15301 mp->is_add = is_add;
15302 clib_memcpy (mp->mac, mac, 6);
15303 mp->bd = clib_host_to_net_u32 (bd);
15309 /* wait for reply */
15315 api_one_l2_arp_bd_get (vat_main_t * vam)
15317 vl_api_one_l2_arp_bd_get_t *mp;
15320 M (ONE_L2_ARP_BD_GET, mp);
15325 /* wait for reply */
15331 api_one_l2_arp_entries_get (vat_main_t * vam)
15333 vl_api_one_l2_arp_entries_get_t *mp;
15334 unformat_input_t *input = vam->input;
15339 /* Parse args required to build the message */
15340 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15342 if (unformat (input, "bd %d", &bd))
15346 errmsg ("parse error '%U'", format_unformat_error, input);
15353 errmsg ("Expected bridge domain!");
15357 M (ONE_L2_ARP_ENTRIES_GET, mp);
15358 mp->bd = clib_host_to_net_u32 (bd);
15363 /* wait for reply */
15369 api_one_stats_enable_disable (vat_main_t * vam)
15371 vl_api_one_stats_enable_disable_t *mp;
15372 unformat_input_t *input = vam->input;
15377 /* Parse args required to build the message */
15378 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15380 if (unformat (input, "enable"))
15385 else if (unformat (input, "disable"))
15395 errmsg ("Value not set");
15399 M (ONE_STATS_ENABLE_DISABLE, mp);
15405 /* wait for reply */
15411 api_show_one_stats_enable_disable (vat_main_t * vam)
15413 vl_api_show_one_stats_enable_disable_t *mp;
15416 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
15421 /* wait for reply */
15427 api_show_one_map_request_mode (vat_main_t * vam)
15429 vl_api_show_one_map_request_mode_t *mp;
15432 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
15437 /* wait for reply */
15442 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
15445 api_one_map_request_mode (vat_main_t * vam)
15447 unformat_input_t *input = vam->input;
15448 vl_api_one_map_request_mode_t *mp;
15452 /* Parse args required to build the message */
15453 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15455 if (unformat (input, "dst-only"))
15457 else if (unformat (input, "src-dst"))
15461 errmsg ("parse error '%U'", format_unformat_error, input);
15466 M (ONE_MAP_REQUEST_MODE, mp);
15473 /* wait for reply */
15478 #define api_lisp_map_request_mode api_one_map_request_mode
15481 * Enable/disable ONE proxy ITR.
15483 * @param vam vpp API test context
15484 * @return return code
15487 api_one_pitr_set_locator_set (vat_main_t * vam)
15489 u8 ls_name_set = 0;
15490 unformat_input_t *input = vam->input;
15491 vl_api_one_pitr_set_locator_set_t *mp;
15496 /* Parse args required to build the message */
15497 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15499 if (unformat (input, "del"))
15501 else if (unformat (input, "locator-set %s", &ls_name))
15505 errmsg ("parse error '%U'", format_unformat_error, input);
15512 errmsg ("locator-set name not set!");
15516 M (ONE_PITR_SET_LOCATOR_SET, mp);
15518 mp->is_add = is_add;
15519 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15520 vec_free (ls_name);
15525 /* wait for reply */
15530 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
15533 api_one_nsh_set_locator_set (vat_main_t * vam)
15535 u8 ls_name_set = 0;
15536 unformat_input_t *input = vam->input;
15537 vl_api_one_nsh_set_locator_set_t *mp;
15542 /* Parse args required to build the message */
15543 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15545 if (unformat (input, "del"))
15547 else if (unformat (input, "ls %s", &ls_name))
15551 errmsg ("parse error '%U'", format_unformat_error, input);
15556 if (!ls_name_set && is_add)
15558 errmsg ("locator-set name not set!");
15562 M (ONE_NSH_SET_LOCATOR_SET, mp);
15564 mp->is_add = is_add;
15565 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15566 vec_free (ls_name);
15571 /* wait for reply */
15577 api_show_one_pitr (vat_main_t * vam)
15579 vl_api_show_one_pitr_t *mp;
15582 if (!vam->json_output)
15584 print (vam->ofp, "%=20s", "lisp status:");
15587 M (SHOW_ONE_PITR, mp);
15591 /* Wait for a reply... */
15596 #define api_show_lisp_pitr api_show_one_pitr
15599 api_one_use_petr (vat_main_t * vam)
15601 unformat_input_t *input = vam->input;
15602 vl_api_one_use_petr_t *mp;
15607 memset (&ip, 0, sizeof (ip));
15609 /* Parse args required to build the message */
15610 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15612 if (unformat (input, "disable"))
15615 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
15618 ip_addr_version (&ip) = IP4;
15621 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
15624 ip_addr_version (&ip) = IP6;
15628 errmsg ("parse error '%U'", format_unformat_error, input);
15633 M (ONE_USE_PETR, mp);
15635 mp->is_add = is_add;
15638 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
15640 clib_memcpy (mp->address, &ip, 4);
15642 clib_memcpy (mp->address, &ip, 16);
15648 /* wait for reply */
15653 #define api_lisp_use_petr api_one_use_petr
15656 api_show_one_nsh_mapping (vat_main_t * vam)
15658 vl_api_show_one_use_petr_t *mp;
15661 if (!vam->json_output)
15663 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
15666 M (SHOW_ONE_NSH_MAPPING, mp);
15670 /* Wait for a reply... */
15676 api_show_one_use_petr (vat_main_t * vam)
15678 vl_api_show_one_use_petr_t *mp;
15681 if (!vam->json_output)
15683 print (vam->ofp, "%=20s", "Proxy-ETR status:");
15686 M (SHOW_ONE_USE_PETR, mp);
15690 /* Wait for a reply... */
15695 #define api_show_lisp_use_petr api_show_one_use_petr
15698 * Add/delete mapping between vni and vrf
15701 api_one_eid_table_add_del_map (vat_main_t * vam)
15703 unformat_input_t *input = vam->input;
15704 vl_api_one_eid_table_add_del_map_t *mp;
15705 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15706 u32 vni, vrf, bd_index;
15709 /* Parse args required to build the message */
15710 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15712 if (unformat (input, "del"))
15714 else if (unformat (input, "vrf %d", &vrf))
15716 else if (unformat (input, "bd_index %d", &bd_index))
15718 else if (unformat (input, "vni %d", &vni))
15724 if (!vni_set || (!vrf_set && !bd_index_set))
15726 errmsg ("missing arguments!");
15730 if (vrf_set && bd_index_set)
15732 errmsg ("error: both vrf and bd entered!");
15736 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15738 mp->is_add = is_add;
15739 mp->vni = htonl (vni);
15740 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15741 mp->is_l2 = bd_index_set;
15746 /* wait for reply */
15751 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15754 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15756 u32 *action = va_arg (*args, u32 *);
15759 if (unformat (input, "%s", &s))
15761 if (!strcmp ((char *) s, "no-action"))
15763 else if (!strcmp ((char *) s, "natively-forward"))
15765 else if (!strcmp ((char *) s, "send-map-request"))
15767 else if (!strcmp ((char *) s, "drop"))
15771 clib_warning ("invalid action: '%s'", s);
15783 * Add/del remote mapping to/from ONE control plane
15785 * @param vam vpp API test context
15786 * @return return code
15789 api_one_add_del_remote_mapping (vat_main_t * vam)
15791 unformat_input_t *input = vam->input;
15792 vl_api_one_add_del_remote_mapping_t *mp;
15794 lisp_eid_vat_t _eid, *eid = &_eid;
15795 lisp_eid_vat_t _seid, *seid = &_seid;
15796 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15797 u32 action = ~0, p, w, data_len;
15798 ip4_address_t rloc4;
15799 ip6_address_t rloc6;
15800 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15803 memset (&rloc, 0, sizeof (rloc));
15805 /* Parse args required to build the message */
15806 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15808 if (unformat (input, "del-all"))
15812 else if (unformat (input, "del"))
15816 else if (unformat (input, "add"))
15820 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15824 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15828 else if (unformat (input, "vni %d", &vni))
15832 else if (unformat (input, "p %d w %d", &p, &w))
15836 errmsg ("No RLOC configured for setting priority/weight!");
15839 curr_rloc->priority = p;
15840 curr_rloc->weight = w;
15842 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15845 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
15846 vec_add1 (rlocs, rloc);
15847 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15849 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15852 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
15853 vec_add1 (rlocs, rloc);
15854 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15856 else if (unformat (input, "action %U",
15857 unformat_negative_mapping_action, &action))
15863 clib_warning ("parse error '%U'", format_unformat_error, input);
15870 errmsg ("missing params!");
15874 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15876 errmsg ("no action set for negative map-reply!");
15880 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15882 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15883 mp->is_add = is_add;
15884 mp->vni = htonl (vni);
15885 mp->action = (u8) action;
15886 mp->is_src_dst = seid_set;
15887 mp->eid_len = eid->len;
15888 mp->seid_len = seid->len;
15889 mp->del_all = del_all;
15890 mp->eid_type = eid->type;
15891 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15892 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
15894 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15895 clib_memcpy (mp->rlocs, rlocs, data_len);
15901 /* Wait for a reply... */
15906 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15909 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15910 * forwarding entries in data-plane accordingly.
15912 * @param vam vpp API test context
15913 * @return return code
15916 api_one_add_del_adjacency (vat_main_t * vam)
15918 unformat_input_t *input = vam->input;
15919 vl_api_one_add_del_adjacency_t *mp;
15921 ip4_address_t leid4, reid4;
15922 ip6_address_t leid6, reid6;
15923 u8 reid_mac[6] = { 0 };
15924 u8 leid_mac[6] = { 0 };
15925 u8 reid_type, leid_type;
15926 u32 leid_len = 0, reid_len = 0, len;
15930 leid_type = reid_type = (u8) ~ 0;
15932 /* Parse args required to build the message */
15933 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15935 if (unformat (input, "del"))
15939 else if (unformat (input, "add"))
15943 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
15946 reid_type = 0; /* ipv4 */
15949 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
15952 reid_type = 1; /* ipv6 */
15955 else if (unformat (input, "reid %U", unformat_ethernet_address,
15958 reid_type = 2; /* mac */
15960 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
15963 leid_type = 0; /* ipv4 */
15966 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
15969 leid_type = 1; /* ipv6 */
15972 else if (unformat (input, "leid %U", unformat_ethernet_address,
15975 leid_type = 2; /* mac */
15977 else if (unformat (input, "vni %d", &vni))
15983 errmsg ("parse error '%U'", format_unformat_error, input);
15988 if ((u8) ~ 0 == reid_type)
15990 errmsg ("missing params!");
15994 if (leid_type != reid_type)
15996 errmsg ("remote and local EIDs are of different types!");
16000 M (ONE_ADD_DEL_ADJACENCY, mp);
16001 mp->is_add = is_add;
16002 mp->vni = htonl (vni);
16003 mp->leid_len = leid_len;
16004 mp->reid_len = reid_len;
16005 mp->eid_type = reid_type;
16007 switch (mp->eid_type)
16010 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
16011 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
16014 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
16015 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
16018 clib_memcpy (mp->leid, leid_mac, 6);
16019 clib_memcpy (mp->reid, reid_mac, 6);
16022 errmsg ("unknown EID type %d!", mp->eid_type);
16029 /* Wait for a reply... */
16034 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
16037 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
16039 u32 *mode = va_arg (*args, u32 *);
16041 if (unformat (input, "lisp"))
16043 else if (unformat (input, "vxlan"))
16052 api_gpe_get_encap_mode (vat_main_t * vam)
16054 vl_api_gpe_get_encap_mode_t *mp;
16057 /* Construct the API message */
16058 M (GPE_GET_ENCAP_MODE, mp);
16063 /* Wait for a reply... */
16069 api_gpe_set_encap_mode (vat_main_t * vam)
16071 unformat_input_t *input = vam->input;
16072 vl_api_gpe_set_encap_mode_t *mp;
16076 /* Parse args required to build the message */
16077 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16079 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
16085 /* Construct the API message */
16086 M (GPE_SET_ENCAP_MODE, mp);
16093 /* Wait for a reply... */
16099 api_lisp_gpe_add_del_iface (vat_main_t * vam)
16101 unformat_input_t *input = vam->input;
16102 vl_api_gpe_add_del_iface_t *mp;
16103 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
16104 u32 dp_table = 0, vni = 0;
16107 /* Parse args required to build the message */
16108 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16110 if (unformat (input, "up"))
16115 else if (unformat (input, "down"))
16120 else if (unformat (input, "table_id %d", &dp_table))
16124 else if (unformat (input, "bd_id %d", &dp_table))
16129 else if (unformat (input, "vni %d", &vni))
16137 if (action_set == 0)
16139 errmsg ("Action not set");
16142 if (dp_table_set == 0 || vni_set == 0)
16144 errmsg ("vni and dp_table must be set");
16148 /* Construct the API message */
16149 M (GPE_ADD_DEL_IFACE, mp);
16151 mp->is_add = is_add;
16152 mp->dp_table = clib_host_to_net_u32 (dp_table);
16154 mp->vni = clib_host_to_net_u32 (vni);
16159 /* Wait for a reply... */
16165 api_one_map_register_set_ttl (vat_main_t * vam)
16167 unformat_input_t *input = vam->input;
16168 vl_api_one_map_register_set_ttl_t *mp;
16173 /* Parse args required to build the message */
16174 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16176 if (unformat (input, "%u", &ttl))
16180 clib_warning ("parse error '%U'", format_unformat_error, input);
16187 errmsg ("TTL value missing!");
16191 M (ONE_MAP_REGISTER_SET_TTL, mp);
16192 mp->ttl = clib_host_to_net_u32 (ttl);
16197 /* Wait for a reply... */
16203 api_show_one_map_register_ttl (vat_main_t * vam)
16205 vl_api_show_one_map_register_ttl_t *mp;
16208 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
16213 /* Wait for a reply... */
16219 * Add/del map request itr rlocs from ONE control plane and updates
16221 * @param vam vpp API test context
16222 * @return return code
16225 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
16227 unformat_input_t *input = vam->input;
16228 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
16229 u8 *locator_set_name = 0;
16230 u8 locator_set_name_set = 0;
16234 /* Parse args required to build the message */
16235 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16237 if (unformat (input, "del"))
16241 else if (unformat (input, "%_%v%_", &locator_set_name))
16243 locator_set_name_set = 1;
16247 clib_warning ("parse error '%U'", format_unformat_error, input);
16252 if (is_add && !locator_set_name_set)
16254 errmsg ("itr-rloc is not set!");
16258 if (is_add && vec_len (locator_set_name) > 64)
16260 errmsg ("itr-rloc locator-set name too long");
16261 vec_free (locator_set_name);
16265 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
16266 mp->is_add = is_add;
16269 clib_memcpy (mp->locator_set_name, locator_set_name,
16270 vec_len (locator_set_name));
16274 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
16276 vec_free (locator_set_name);
16281 /* Wait for a reply... */
16286 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
16289 api_one_locator_dump (vat_main_t * vam)
16291 unformat_input_t *input = vam->input;
16292 vl_api_one_locator_dump_t *mp;
16293 vl_api_control_ping_t *mp_ping;
16294 u8 is_index_set = 0, is_name_set = 0;
16299 /* Parse args required to build the message */
16300 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16302 if (unformat (input, "ls_name %_%v%_", &ls_name))
16306 else if (unformat (input, "ls_index %d", &ls_index))
16312 errmsg ("parse error '%U'", format_unformat_error, input);
16317 if (!is_index_set && !is_name_set)
16319 errmsg ("error: expected one of index or name!");
16323 if (is_index_set && is_name_set)
16325 errmsg ("error: only one param expected!");
16329 if (vec_len (ls_name) > 62)
16331 errmsg ("error: locator set name too long!");
16335 if (!vam->json_output)
16337 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
16340 M (ONE_LOCATOR_DUMP, mp);
16341 mp->is_index_set = is_index_set;
16344 mp->ls_index = clib_host_to_net_u32 (ls_index);
16347 vec_add1 (ls_name, 0);
16348 strncpy ((char *) mp->ls_name, (char *) ls_name,
16349 sizeof (mp->ls_name) - 1);
16355 /* Use a control ping for synchronization */
16356 M (CONTROL_PING, mp_ping);
16359 /* Wait for a reply... */
16364 #define api_lisp_locator_dump api_one_locator_dump
16367 api_one_locator_set_dump (vat_main_t * vam)
16369 vl_api_one_locator_set_dump_t *mp;
16370 vl_api_control_ping_t *mp_ping;
16371 unformat_input_t *input = vam->input;
16375 /* Parse args required to build the message */
16376 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16378 if (unformat (input, "local"))
16382 else if (unformat (input, "remote"))
16388 errmsg ("parse error '%U'", format_unformat_error, input);
16393 if (!vam->json_output)
16395 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
16398 M (ONE_LOCATOR_SET_DUMP, mp);
16400 mp->filter = filter;
16405 /* Use a control ping for synchronization */
16406 M (CONTROL_PING, mp_ping);
16409 /* Wait for a reply... */
16414 #define api_lisp_locator_set_dump api_one_locator_set_dump
16417 api_one_eid_table_map_dump (vat_main_t * vam)
16421 unformat_input_t *input = vam->input;
16422 vl_api_one_eid_table_map_dump_t *mp;
16423 vl_api_control_ping_t *mp_ping;
16426 /* Parse args required to build the message */
16427 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16429 if (unformat (input, "l2"))
16434 else if (unformat (input, "l3"))
16441 errmsg ("parse error '%U'", format_unformat_error, input);
16448 errmsg ("expected one of 'l2' or 'l3' parameter!");
16452 if (!vam->json_output)
16454 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
16457 M (ONE_EID_TABLE_MAP_DUMP, mp);
16463 /* Use a control ping for synchronization */
16464 M (CONTROL_PING, mp_ping);
16467 /* Wait for a reply... */
16472 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
16475 api_one_eid_table_vni_dump (vat_main_t * vam)
16477 vl_api_one_eid_table_vni_dump_t *mp;
16478 vl_api_control_ping_t *mp_ping;
16481 if (!vam->json_output)
16483 print (vam->ofp, "VNI");
16486 M (ONE_EID_TABLE_VNI_DUMP, mp);
16491 /* Use a control ping for synchronization */
16492 M (CONTROL_PING, mp_ping);
16495 /* Wait for a reply... */
16500 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
16503 api_one_eid_table_dump (vat_main_t * vam)
16505 unformat_input_t *i = vam->input;
16506 vl_api_one_eid_table_dump_t *mp;
16507 vl_api_control_ping_t *mp_ping;
16508 struct in_addr ip4;
16509 struct in6_addr ip6;
16511 u8 eid_type = ~0, eid_set = 0;
16512 u32 prefix_length = ~0, t, vni = 0;
16515 lisp_nsh_api_t nsh;
16517 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16519 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
16525 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
16531 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
16536 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
16541 else if (unformat (i, "vni %d", &t))
16545 else if (unformat (i, "local"))
16549 else if (unformat (i, "remote"))
16555 errmsg ("parse error '%U'", format_unformat_error, i);
16560 if (!vam->json_output)
16562 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
16563 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
16566 M (ONE_EID_TABLE_DUMP, mp);
16568 mp->filter = filter;
16572 mp->vni = htonl (vni);
16573 mp->eid_type = eid_type;
16577 mp->prefix_length = prefix_length;
16578 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
16581 mp->prefix_length = prefix_length;
16582 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
16585 clib_memcpy (mp->eid, mac, sizeof (mac));
16588 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
16591 errmsg ("unknown EID type %d!", eid_type);
16599 /* Use a control ping for synchronization */
16600 M (CONTROL_PING, mp_ping);
16603 /* Wait for a reply... */
16608 #define api_lisp_eid_table_dump api_one_eid_table_dump
16611 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
16613 unformat_input_t *i = vam->input;
16614 vl_api_gpe_fwd_entries_get_t *mp;
16619 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16621 if (unformat (i, "vni %d", &vni))
16627 errmsg ("parse error '%U'", format_unformat_error, i);
16634 errmsg ("vni not set!");
16638 if (!vam->json_output)
16640 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
16644 M (GPE_FWD_ENTRIES_GET, mp);
16645 mp->vni = clib_host_to_net_u32 (vni);
16650 /* Wait for a reply... */
16655 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
16656 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
16657 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
16658 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
16659 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
16660 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
16661 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
16662 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
16665 api_one_adjacencies_get (vat_main_t * vam)
16667 unformat_input_t *i = vam->input;
16668 vl_api_one_adjacencies_get_t *mp;
16673 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16675 if (unformat (i, "vni %d", &vni))
16681 errmsg ("parse error '%U'", format_unformat_error, i);
16688 errmsg ("vni not set!");
16692 if (!vam->json_output)
16694 print (vam->ofp, "%s %40s", "leid", "reid");
16697 M (ONE_ADJACENCIES_GET, mp);
16698 mp->vni = clib_host_to_net_u32 (vni);
16703 /* Wait for a reply... */
16708 #define api_lisp_adjacencies_get api_one_adjacencies_get
16711 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
16713 unformat_input_t *i = vam->input;
16714 vl_api_gpe_native_fwd_rpaths_get_t *mp;
16716 u8 ip_family_set = 0, is_ip4 = 1;
16718 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16720 if (unformat (i, "ip4"))
16725 else if (unformat (i, "ip6"))
16732 errmsg ("parse error '%U'", format_unformat_error, i);
16737 if (!ip_family_set)
16739 errmsg ("ip family not set!");
16743 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
16744 mp->is_ip4 = is_ip4;
16749 /* Wait for a reply... */
16755 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
16757 vl_api_gpe_fwd_entry_vnis_get_t *mp;
16760 if (!vam->json_output)
16762 print (vam->ofp, "VNIs");
16765 M (GPE_FWD_ENTRY_VNIS_GET, mp);
16770 /* Wait for a reply... */
16776 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
16778 unformat_input_t *i = vam->input;
16779 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
16781 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
16782 struct in_addr ip4;
16783 struct in6_addr ip6;
16784 u32 table_id = 0, nh_sw_if_index = ~0;
16786 memset (&ip4, 0, sizeof (ip4));
16787 memset (&ip6, 0, sizeof (ip6));
16789 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16791 if (unformat (i, "del"))
16793 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
16794 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16799 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
16800 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16805 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
16809 nh_sw_if_index = ~0;
16811 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
16815 nh_sw_if_index = ~0;
16817 else if (unformat (i, "table %d", &table_id))
16821 errmsg ("parse error '%U'", format_unformat_error, i);
16828 errmsg ("nh addr not set!");
16832 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
16833 mp->is_add = is_add;
16834 mp->table_id = clib_host_to_net_u32 (table_id);
16835 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
16836 mp->is_ip4 = is_ip4;
16838 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
16840 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
16845 /* Wait for a reply... */
16851 api_one_map_server_dump (vat_main_t * vam)
16853 vl_api_one_map_server_dump_t *mp;
16854 vl_api_control_ping_t *mp_ping;
16857 if (!vam->json_output)
16859 print (vam->ofp, "%=20s", "Map server");
16862 M (ONE_MAP_SERVER_DUMP, mp);
16866 /* Use a control ping for synchronization */
16867 M (CONTROL_PING, mp_ping);
16870 /* Wait for a reply... */
16875 #define api_lisp_map_server_dump api_one_map_server_dump
16878 api_one_map_resolver_dump (vat_main_t * vam)
16880 vl_api_one_map_resolver_dump_t *mp;
16881 vl_api_control_ping_t *mp_ping;
16884 if (!vam->json_output)
16886 print (vam->ofp, "%=20s", "Map resolver");
16889 M (ONE_MAP_RESOLVER_DUMP, mp);
16893 /* Use a control ping for synchronization */
16894 M (CONTROL_PING, mp_ping);
16897 /* Wait for a reply... */
16902 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
16905 api_one_stats_flush (vat_main_t * vam)
16907 vl_api_one_stats_flush_t *mp;
16910 M (ONE_STATS_FLUSH, mp);
16917 api_one_stats_dump (vat_main_t * vam)
16919 vl_api_one_stats_dump_t *mp;
16920 vl_api_control_ping_t *mp_ping;
16923 M (ONE_STATS_DUMP, mp);
16927 /* Use a control ping for synchronization */
16928 M (CONTROL_PING, mp_ping);
16931 /* Wait for a reply... */
16937 api_show_one_status (vat_main_t * vam)
16939 vl_api_show_one_status_t *mp;
16942 if (!vam->json_output)
16944 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
16947 M (SHOW_ONE_STATUS, mp);
16950 /* Wait for a reply... */
16955 #define api_show_lisp_status api_show_one_status
16958 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
16960 vl_api_gpe_fwd_entry_path_dump_t *mp;
16961 vl_api_control_ping_t *mp_ping;
16962 unformat_input_t *i = vam->input;
16963 u32 fwd_entry_index = ~0;
16966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16968 if (unformat (i, "index %d", &fwd_entry_index))
16974 if (~0 == fwd_entry_index)
16976 errmsg ("no index specified!");
16980 if (!vam->json_output)
16982 print (vam->ofp, "first line");
16985 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
16989 /* Use a control ping for synchronization */
16990 M (CONTROL_PING, mp_ping);
16993 /* Wait for a reply... */
16999 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
17001 vl_api_one_get_map_request_itr_rlocs_t *mp;
17004 if (!vam->json_output)
17006 print (vam->ofp, "%=20s", "itr-rlocs:");
17009 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
17012 /* Wait for a reply... */
17017 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
17020 api_af_packet_create (vat_main_t * vam)
17022 unformat_input_t *i = vam->input;
17023 vl_api_af_packet_create_t *mp;
17024 u8 *host_if_name = 0;
17026 u8 random_hw_addr = 1;
17029 memset (hw_addr, 0, sizeof (hw_addr));
17031 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17033 if (unformat (i, "name %s", &host_if_name))
17034 vec_add1 (host_if_name, 0);
17035 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17036 random_hw_addr = 0;
17041 if (!vec_len (host_if_name))
17043 errmsg ("host-interface name must be specified");
17047 if (vec_len (host_if_name) > 64)
17049 errmsg ("host-interface name too long");
17053 M (AF_PACKET_CREATE, mp);
17055 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17056 clib_memcpy (mp->hw_addr, hw_addr, 6);
17057 mp->use_random_hw_addr = random_hw_addr;
17058 vec_free (host_if_name);
17066 fprintf (vam->ofp ? vam->ofp : stderr,
17067 " new sw_if_index = %d\n", vam->sw_if_index);
17074 api_af_packet_delete (vat_main_t * vam)
17076 unformat_input_t *i = vam->input;
17077 vl_api_af_packet_delete_t *mp;
17078 u8 *host_if_name = 0;
17081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17083 if (unformat (i, "name %s", &host_if_name))
17084 vec_add1 (host_if_name, 0);
17089 if (!vec_len (host_if_name))
17091 errmsg ("host-interface name must be specified");
17095 if (vec_len (host_if_name) > 64)
17097 errmsg ("host-interface name too long");
17101 M (AF_PACKET_DELETE, mp);
17103 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17104 vec_free (host_if_name);
17112 api_policer_add_del (vat_main_t * vam)
17114 unformat_input_t *i = vam->input;
17115 vl_api_policer_add_del_t *mp;
17125 u8 color_aware = 0;
17126 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
17129 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
17130 conform_action.dscp = 0;
17131 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
17132 exceed_action.dscp = 0;
17133 violate_action.action_type = SSE2_QOS_ACTION_DROP;
17134 violate_action.dscp = 0;
17136 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17138 if (unformat (i, "del"))
17140 else if (unformat (i, "name %s", &name))
17141 vec_add1 (name, 0);
17142 else if (unformat (i, "cir %u", &cir))
17144 else if (unformat (i, "eir %u", &eir))
17146 else if (unformat (i, "cb %u", &cb))
17148 else if (unformat (i, "eb %u", &eb))
17150 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
17153 else if (unformat (i, "round_type %U", unformat_policer_round_type,
17156 else if (unformat (i, "type %U", unformat_policer_type, &type))
17158 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
17161 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
17164 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
17167 else if (unformat (i, "color-aware"))
17173 if (!vec_len (name))
17175 errmsg ("policer name must be specified");
17179 if (vec_len (name) > 64)
17181 errmsg ("policer name too long");
17185 M (POLICER_ADD_DEL, mp);
17187 clib_memcpy (mp->name, name, vec_len (name));
17189 mp->is_add = is_add;
17194 mp->rate_type = rate_type;
17195 mp->round_type = round_type;
17197 mp->conform_action_type = conform_action.action_type;
17198 mp->conform_dscp = conform_action.dscp;
17199 mp->exceed_action_type = exceed_action.action_type;
17200 mp->exceed_dscp = exceed_action.dscp;
17201 mp->violate_action_type = violate_action.action_type;
17202 mp->violate_dscp = violate_action.dscp;
17203 mp->color_aware = color_aware;
17211 api_policer_dump (vat_main_t * vam)
17213 unformat_input_t *i = vam->input;
17214 vl_api_policer_dump_t *mp;
17215 vl_api_control_ping_t *mp_ping;
17216 u8 *match_name = 0;
17217 u8 match_name_valid = 0;
17220 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17222 if (unformat (i, "name %s", &match_name))
17224 vec_add1 (match_name, 0);
17225 match_name_valid = 1;
17231 M (POLICER_DUMP, mp);
17232 mp->match_name_valid = match_name_valid;
17233 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
17234 vec_free (match_name);
17238 /* Use a control ping for synchronization */
17239 M (CONTROL_PING, mp_ping);
17242 /* Wait for a reply... */
17248 api_policer_classify_set_interface (vat_main_t * vam)
17250 unformat_input_t *i = vam->input;
17251 vl_api_policer_classify_set_interface_t *mp;
17253 int sw_if_index_set;
17254 u32 ip4_table_index = ~0;
17255 u32 ip6_table_index = ~0;
17256 u32 l2_table_index = ~0;
17260 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17262 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17263 sw_if_index_set = 1;
17264 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17265 sw_if_index_set = 1;
17266 else if (unformat (i, "del"))
17268 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17270 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17272 else if (unformat (i, "l2-table %d", &l2_table_index))
17276 clib_warning ("parse error '%U'", format_unformat_error, i);
17281 if (sw_if_index_set == 0)
17283 errmsg ("missing interface name or sw_if_index");
17287 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
17289 mp->sw_if_index = ntohl (sw_if_index);
17290 mp->ip4_table_index = ntohl (ip4_table_index);
17291 mp->ip6_table_index = ntohl (ip6_table_index);
17292 mp->l2_table_index = ntohl (l2_table_index);
17293 mp->is_add = is_add;
17301 api_policer_classify_dump (vat_main_t * vam)
17303 unformat_input_t *i = vam->input;
17304 vl_api_policer_classify_dump_t *mp;
17305 vl_api_control_ping_t *mp_ping;
17306 u8 type = POLICER_CLASSIFY_N_TABLES;
17309 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
17313 errmsg ("classify table type must be specified");
17317 if (!vam->json_output)
17319 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17322 M (POLICER_CLASSIFY_DUMP, mp);
17327 /* Use a control ping for synchronization */
17328 M (CONTROL_PING, mp_ping);
17331 /* Wait for a reply... */
17337 api_netmap_create (vat_main_t * vam)
17339 unformat_input_t *i = vam->input;
17340 vl_api_netmap_create_t *mp;
17343 u8 random_hw_addr = 1;
17348 memset (hw_addr, 0, sizeof (hw_addr));
17350 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17352 if (unformat (i, "name %s", &if_name))
17353 vec_add1 (if_name, 0);
17354 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17355 random_hw_addr = 0;
17356 else if (unformat (i, "pipe"))
17358 else if (unformat (i, "master"))
17360 else if (unformat (i, "slave"))
17366 if (!vec_len (if_name))
17368 errmsg ("interface name must be specified");
17372 if (vec_len (if_name) > 64)
17374 errmsg ("interface name too long");
17378 M (NETMAP_CREATE, mp);
17380 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
17381 clib_memcpy (mp->hw_addr, hw_addr, 6);
17382 mp->use_random_hw_addr = random_hw_addr;
17383 mp->is_pipe = is_pipe;
17384 mp->is_master = is_master;
17385 vec_free (if_name);
17393 api_netmap_delete (vat_main_t * vam)
17395 unformat_input_t *i = vam->input;
17396 vl_api_netmap_delete_t *mp;
17400 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17402 if (unformat (i, "name %s", &if_name))
17403 vec_add1 (if_name, 0);
17408 if (!vec_len (if_name))
17410 errmsg ("interface name must be specified");
17414 if (vec_len (if_name) > 64)
17416 errmsg ("interface name too long");
17420 M (NETMAP_DELETE, mp);
17422 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
17423 vec_free (if_name);
17431 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
17433 if (fp->afi == IP46_TYPE_IP6)
17435 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17436 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17437 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17438 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17439 format_ip6_address, fp->next_hop);
17440 else if (fp->afi == IP46_TYPE_IP4)
17442 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17443 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17444 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17445 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17446 format_ip4_address, fp->next_hop);
17450 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
17451 vl_api_fib_path2_t * fp)
17453 struct in_addr ip4;
17454 struct in6_addr ip6;
17456 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17457 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17458 vat_json_object_add_uint (node, "is_local", fp->is_local);
17459 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17460 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17461 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17462 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17463 if (fp->afi == IP46_TYPE_IP4)
17465 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17466 vat_json_object_add_ip4 (node, "next_hop", ip4);
17468 else if (fp->afi == IP46_TYPE_IP6)
17470 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17471 vat_json_object_add_ip6 (node, "next_hop", ip6);
17476 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
17478 vat_main_t *vam = &vat_main;
17479 int count = ntohl (mp->mt_count);
17480 vl_api_fib_path2_t *fp;
17483 print (vam->ofp, "[%d]: sw_if_index %d via:",
17484 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
17486 for (i = 0; i < count; i++)
17488 vl_api_mpls_fib_path_print (vam, fp);
17492 print (vam->ofp, "");
17495 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
17496 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
17499 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
17501 vat_main_t *vam = &vat_main;
17502 vat_json_node_t *node = NULL;
17503 int count = ntohl (mp->mt_count);
17504 vl_api_fib_path2_t *fp;
17507 if (VAT_JSON_ARRAY != vam->json_tree.type)
17509 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17510 vat_json_init_array (&vam->json_tree);
17512 node = vat_json_array_add (&vam->json_tree);
17514 vat_json_init_object (node);
17515 vat_json_object_add_uint (node, "tunnel_index",
17516 ntohl (mp->mt_tunnel_index));
17517 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
17519 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
17522 for (i = 0; i < count; i++)
17524 vl_api_mpls_fib_path_json_print (node, fp);
17530 api_mpls_tunnel_dump (vat_main_t * vam)
17532 vl_api_mpls_tunnel_dump_t *mp;
17533 vl_api_control_ping_t *mp_ping;
17537 /* Parse args required to build the message */
17538 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
17540 if (!unformat (vam->input, "tunnel_index %d", &index))
17547 print (vam->ofp, " tunnel_index %d", index);
17549 M (MPLS_TUNNEL_DUMP, mp);
17550 mp->tunnel_index = htonl (index);
17553 /* Use a control ping for synchronization */
17554 M (CONTROL_PING, mp_ping);
17561 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
17562 #define vl_api_mpls_fib_details_t_print vl_noop_handler
17566 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
17568 vat_main_t *vam = &vat_main;
17569 int count = ntohl (mp->count);
17570 vl_api_fib_path2_t *fp;
17574 "table-id %d, label %u, ess_bit %u",
17575 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
17577 for (i = 0; i < count; i++)
17579 vl_api_mpls_fib_path_print (vam, fp);
17584 static void vl_api_mpls_fib_details_t_handler_json
17585 (vl_api_mpls_fib_details_t * mp)
17587 vat_main_t *vam = &vat_main;
17588 int count = ntohl (mp->count);
17589 vat_json_node_t *node = NULL;
17590 vl_api_fib_path2_t *fp;
17593 if (VAT_JSON_ARRAY != vam->json_tree.type)
17595 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17596 vat_json_init_array (&vam->json_tree);
17598 node = vat_json_array_add (&vam->json_tree);
17600 vat_json_init_object (node);
17601 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17602 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
17603 vat_json_object_add_uint (node, "label", ntohl (mp->label));
17604 vat_json_object_add_uint (node, "path_count", count);
17606 for (i = 0; i < count; i++)
17608 vl_api_mpls_fib_path_json_print (node, fp);
17614 api_mpls_fib_dump (vat_main_t * vam)
17616 vl_api_mpls_fib_dump_t *mp;
17617 vl_api_control_ping_t *mp_ping;
17620 M (MPLS_FIB_DUMP, mp);
17623 /* Use a control ping for synchronization */
17624 M (CONTROL_PING, mp_ping);
17631 #define vl_api_ip_fib_details_t_endian vl_noop_handler
17632 #define vl_api_ip_fib_details_t_print vl_noop_handler
17635 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
17637 vat_main_t *vam = &vat_main;
17638 int count = ntohl (mp->count);
17639 vl_api_fib_path_t *fp;
17643 "table-id %d, prefix %U/%d",
17644 ntohl (mp->table_id), format_ip4_address, mp->address,
17645 mp->address_length);
17647 for (i = 0; i < count; i++)
17649 if (fp->afi == IP46_TYPE_IP6)
17651 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17652 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17653 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17654 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17655 format_ip6_address, fp->next_hop);
17656 else if (fp->afi == IP46_TYPE_IP4)
17658 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17659 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17660 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17661 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17662 format_ip4_address, fp->next_hop);
17667 static void vl_api_ip_fib_details_t_handler_json
17668 (vl_api_ip_fib_details_t * mp)
17670 vat_main_t *vam = &vat_main;
17671 int count = ntohl (mp->count);
17672 vat_json_node_t *node = NULL;
17673 struct in_addr ip4;
17674 struct in6_addr ip6;
17675 vl_api_fib_path_t *fp;
17678 if (VAT_JSON_ARRAY != vam->json_tree.type)
17680 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17681 vat_json_init_array (&vam->json_tree);
17683 node = vat_json_array_add (&vam->json_tree);
17685 vat_json_init_object (node);
17686 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17687 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
17688 vat_json_object_add_ip4 (node, "prefix", ip4);
17689 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17690 vat_json_object_add_uint (node, "path_count", count);
17692 for (i = 0; i < count; i++)
17694 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17695 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17696 vat_json_object_add_uint (node, "is_local", fp->is_local);
17697 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17698 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17699 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17700 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17701 if (fp->afi == IP46_TYPE_IP4)
17703 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17704 vat_json_object_add_ip4 (node, "next_hop", ip4);
17706 else if (fp->afi == IP46_TYPE_IP6)
17708 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17709 vat_json_object_add_ip6 (node, "next_hop", ip6);
17715 api_ip_fib_dump (vat_main_t * vam)
17717 vl_api_ip_fib_dump_t *mp;
17718 vl_api_control_ping_t *mp_ping;
17721 M (IP_FIB_DUMP, mp);
17724 /* Use a control ping for synchronization */
17725 M (CONTROL_PING, mp_ping);
17733 api_ip_mfib_dump (vat_main_t * vam)
17735 vl_api_ip_mfib_dump_t *mp;
17736 vl_api_control_ping_t *mp_ping;
17739 M (IP_MFIB_DUMP, mp);
17742 /* Use a control ping for synchronization */
17743 M (CONTROL_PING, mp_ping);
17750 static void vl_api_ip_neighbor_details_t_handler
17751 (vl_api_ip_neighbor_details_t * mp)
17753 vat_main_t *vam = &vat_main;
17755 print (vam->ofp, "%c %U %U",
17756 (mp->is_static) ? 'S' : 'D',
17757 format_ethernet_address, &mp->mac_address,
17758 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
17762 static void vl_api_ip_neighbor_details_t_handler_json
17763 (vl_api_ip_neighbor_details_t * mp)
17766 vat_main_t *vam = &vat_main;
17767 vat_json_node_t *node;
17768 struct in_addr ip4;
17769 struct in6_addr ip6;
17771 if (VAT_JSON_ARRAY != vam->json_tree.type)
17773 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17774 vat_json_init_array (&vam->json_tree);
17776 node = vat_json_array_add (&vam->json_tree);
17778 vat_json_init_object (node);
17779 vat_json_object_add_string_copy (node, "flag",
17780 (mp->is_static) ? (u8 *) "static" : (u8 *)
17783 vat_json_object_add_string_copy (node, "link_layer",
17784 format (0, "%U", format_ethernet_address,
17785 &mp->mac_address));
17789 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
17790 vat_json_object_add_ip6 (node, "ip_address", ip6);
17794 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
17795 vat_json_object_add_ip4 (node, "ip_address", ip4);
17800 api_ip_neighbor_dump (vat_main_t * vam)
17802 unformat_input_t *i = vam->input;
17803 vl_api_ip_neighbor_dump_t *mp;
17804 vl_api_control_ping_t *mp_ping;
17806 u32 sw_if_index = ~0;
17809 /* Parse args required to build the message */
17810 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17812 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17814 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17816 else if (unformat (i, "ip6"))
17822 if (sw_if_index == ~0)
17824 errmsg ("missing interface name or sw_if_index");
17828 M (IP_NEIGHBOR_DUMP, mp);
17829 mp->is_ipv6 = (u8) is_ipv6;
17830 mp->sw_if_index = ntohl (sw_if_index);
17833 /* Use a control ping for synchronization */
17834 M (CONTROL_PING, mp_ping);
17841 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
17842 #define vl_api_ip6_fib_details_t_print vl_noop_handler
17845 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
17847 vat_main_t *vam = &vat_main;
17848 int count = ntohl (mp->count);
17849 vl_api_fib_path_t *fp;
17853 "table-id %d, prefix %U/%d",
17854 ntohl (mp->table_id), format_ip6_address, mp->address,
17855 mp->address_length);
17857 for (i = 0; i < count; i++)
17859 if (fp->afi == IP46_TYPE_IP6)
17861 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17862 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17863 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17864 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17865 format_ip6_address, fp->next_hop);
17866 else if (fp->afi == IP46_TYPE_IP4)
17868 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17869 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17870 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17871 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17872 format_ip4_address, fp->next_hop);
17877 static void vl_api_ip6_fib_details_t_handler_json
17878 (vl_api_ip6_fib_details_t * mp)
17880 vat_main_t *vam = &vat_main;
17881 int count = ntohl (mp->count);
17882 vat_json_node_t *node = NULL;
17883 struct in_addr ip4;
17884 struct in6_addr ip6;
17885 vl_api_fib_path_t *fp;
17888 if (VAT_JSON_ARRAY != vam->json_tree.type)
17890 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17891 vat_json_init_array (&vam->json_tree);
17893 node = vat_json_array_add (&vam->json_tree);
17895 vat_json_init_object (node);
17896 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17897 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
17898 vat_json_object_add_ip6 (node, "prefix", ip6);
17899 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17900 vat_json_object_add_uint (node, "path_count", count);
17902 for (i = 0; i < count; i++)
17904 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17905 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17906 vat_json_object_add_uint (node, "is_local", fp->is_local);
17907 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17908 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17909 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17910 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17911 if (fp->afi == IP46_TYPE_IP4)
17913 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17914 vat_json_object_add_ip4 (node, "next_hop", ip4);
17916 else if (fp->afi == IP46_TYPE_IP6)
17918 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17919 vat_json_object_add_ip6 (node, "next_hop", ip6);
17925 api_ip6_fib_dump (vat_main_t * vam)
17927 vl_api_ip6_fib_dump_t *mp;
17928 vl_api_control_ping_t *mp_ping;
17931 M (IP6_FIB_DUMP, mp);
17934 /* Use a control ping for synchronization */
17935 M (CONTROL_PING, mp_ping);
17943 api_ip6_mfib_dump (vat_main_t * vam)
17945 vl_api_ip6_mfib_dump_t *mp;
17946 vl_api_control_ping_t *mp_ping;
17949 M (IP6_MFIB_DUMP, mp);
17952 /* Use a control ping for synchronization */
17953 M (CONTROL_PING, mp_ping);
17961 api_classify_table_ids (vat_main_t * vam)
17963 vl_api_classify_table_ids_t *mp;
17966 /* Construct the API message */
17967 M (CLASSIFY_TABLE_IDS, mp);
17976 api_classify_table_by_interface (vat_main_t * vam)
17978 unformat_input_t *input = vam->input;
17979 vl_api_classify_table_by_interface_t *mp;
17981 u32 sw_if_index = ~0;
17983 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17985 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17987 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17992 if (sw_if_index == ~0)
17994 errmsg ("missing interface name or sw_if_index");
17998 /* Construct the API message */
17999 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
18001 mp->sw_if_index = ntohl (sw_if_index);
18009 api_classify_table_info (vat_main_t * vam)
18011 unformat_input_t *input = vam->input;
18012 vl_api_classify_table_info_t *mp;
18016 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18018 if (unformat (input, "table_id %d", &table_id))
18023 if (table_id == ~0)
18025 errmsg ("missing table id");
18029 /* Construct the API message */
18030 M (CLASSIFY_TABLE_INFO, mp);
18032 mp->table_id = ntohl (table_id);
18040 api_classify_session_dump (vat_main_t * vam)
18042 unformat_input_t *input = vam->input;
18043 vl_api_classify_session_dump_t *mp;
18044 vl_api_control_ping_t *mp_ping;
18048 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18050 if (unformat (input, "table_id %d", &table_id))
18055 if (table_id == ~0)
18057 errmsg ("missing table id");
18061 /* Construct the API message */
18062 M (CLASSIFY_SESSION_DUMP, mp);
18064 mp->table_id = ntohl (table_id);
18067 /* Use a control ping for synchronization */
18068 M (CONTROL_PING, mp_ping);
18076 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
18078 vat_main_t *vam = &vat_main;
18080 print (vam->ofp, "collector_address %U, collector_port %d, "
18081 "src_address %U, vrf_id %d, path_mtu %u, "
18082 "template_interval %u, udp_checksum %d",
18083 format_ip4_address, mp->collector_address,
18084 ntohs (mp->collector_port),
18085 format_ip4_address, mp->src_address,
18086 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
18087 ntohl (mp->template_interval), mp->udp_checksum);
18090 vam->result_ready = 1;
18094 vl_api_ipfix_exporter_details_t_handler_json
18095 (vl_api_ipfix_exporter_details_t * mp)
18097 vat_main_t *vam = &vat_main;
18098 vat_json_node_t node;
18099 struct in_addr collector_address;
18100 struct in_addr src_address;
18102 vat_json_init_object (&node);
18103 clib_memcpy (&collector_address, &mp->collector_address,
18104 sizeof (collector_address));
18105 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
18106 vat_json_object_add_uint (&node, "collector_port",
18107 ntohs (mp->collector_port));
18108 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
18109 vat_json_object_add_ip4 (&node, "src_address", src_address);
18110 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
18111 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
18112 vat_json_object_add_uint (&node, "template_interval",
18113 ntohl (mp->template_interval));
18114 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
18116 vat_json_print (vam->ofp, &node);
18117 vat_json_free (&node);
18119 vam->result_ready = 1;
18123 api_ipfix_exporter_dump (vat_main_t * vam)
18125 vl_api_ipfix_exporter_dump_t *mp;
18128 /* Construct the API message */
18129 M (IPFIX_EXPORTER_DUMP, mp);
18138 api_ipfix_classify_stream_dump (vat_main_t * vam)
18140 vl_api_ipfix_classify_stream_dump_t *mp;
18143 /* Construct the API message */
18144 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
18155 vl_api_ipfix_classify_stream_details_t_handler
18156 (vl_api_ipfix_classify_stream_details_t * mp)
18158 vat_main_t *vam = &vat_main;
18159 print (vam->ofp, "domain_id %d, src_port %d",
18160 ntohl (mp->domain_id), ntohs (mp->src_port));
18162 vam->result_ready = 1;
18166 vl_api_ipfix_classify_stream_details_t_handler_json
18167 (vl_api_ipfix_classify_stream_details_t * mp)
18169 vat_main_t *vam = &vat_main;
18170 vat_json_node_t node;
18172 vat_json_init_object (&node);
18173 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
18174 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
18176 vat_json_print (vam->ofp, &node);
18177 vat_json_free (&node);
18179 vam->result_ready = 1;
18183 api_ipfix_classify_table_dump (vat_main_t * vam)
18185 vl_api_ipfix_classify_table_dump_t *mp;
18186 vl_api_control_ping_t *mp_ping;
18189 if (!vam->json_output)
18191 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
18192 "transport_protocol");
18195 /* Construct the API message */
18196 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
18201 /* Use a control ping for synchronization */
18202 M (CONTROL_PING, mp_ping);
18210 vl_api_ipfix_classify_table_details_t_handler
18211 (vl_api_ipfix_classify_table_details_t * mp)
18213 vat_main_t *vam = &vat_main;
18214 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
18215 mp->transport_protocol);
18219 vl_api_ipfix_classify_table_details_t_handler_json
18220 (vl_api_ipfix_classify_table_details_t * mp)
18222 vat_json_node_t *node = NULL;
18223 vat_main_t *vam = &vat_main;
18225 if (VAT_JSON_ARRAY != vam->json_tree.type)
18227 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18228 vat_json_init_array (&vam->json_tree);
18231 node = vat_json_array_add (&vam->json_tree);
18232 vat_json_init_object (node);
18234 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
18235 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
18236 vat_json_object_add_uint (node, "transport_protocol",
18237 mp->transport_protocol);
18241 api_sw_interface_span_enable_disable (vat_main_t * vam)
18243 unformat_input_t *i = vam->input;
18244 vl_api_sw_interface_span_enable_disable_t *mp;
18245 u32 src_sw_if_index = ~0;
18246 u32 dst_sw_if_index = ~0;
18251 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18254 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
18256 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
18260 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
18262 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
18264 else if (unformat (i, "disable"))
18266 else if (unformat (i, "rx"))
18268 else if (unformat (i, "tx"))
18270 else if (unformat (i, "both"))
18272 else if (unformat (i, "l2"))
18278 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
18280 mp->sw_if_index_from = htonl (src_sw_if_index);
18281 mp->sw_if_index_to = htonl (dst_sw_if_index);
18291 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
18294 vat_main_t *vam = &vat_main;
18295 u8 *sw_if_from_name = 0;
18296 u8 *sw_if_to_name = 0;
18297 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18298 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18299 char *states[] = { "none", "rx", "tx", "both" };
18303 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18305 if ((u32) p->value[0] == sw_if_index_from)
18307 sw_if_from_name = (u8 *)(p->key);
18311 if ((u32) p->value[0] == sw_if_index_to)
18313 sw_if_to_name = (u8 *)(p->key);
18314 if (sw_if_from_name)
18319 print (vam->ofp, "%20s => %20s (%s)",
18320 sw_if_from_name, sw_if_to_name, states[mp->state]);
18324 vl_api_sw_interface_span_details_t_handler_json
18325 (vl_api_sw_interface_span_details_t * mp)
18327 vat_main_t *vam = &vat_main;
18328 vat_json_node_t *node = NULL;
18329 u8 *sw_if_from_name = 0;
18330 u8 *sw_if_to_name = 0;
18331 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18332 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18336 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18338 if ((u32) p->value[0] == sw_if_index_from)
18340 sw_if_from_name = (u8 *)(p->key);
18344 if ((u32) p->value[0] == sw_if_index_to)
18346 sw_if_to_name = (u8 *)(p->key);
18347 if (sw_if_from_name)
18353 if (VAT_JSON_ARRAY != vam->json_tree.type)
18355 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18356 vat_json_init_array (&vam->json_tree);
18358 node = vat_json_array_add (&vam->json_tree);
18360 vat_json_init_object (node);
18361 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
18362 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
18363 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
18364 if (0 != sw_if_to_name)
18366 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
18368 vat_json_object_add_uint (node, "state", mp->state);
18372 api_sw_interface_span_dump (vat_main_t * vam)
18374 unformat_input_t *input = vam->input;
18375 vl_api_sw_interface_span_dump_t *mp;
18376 vl_api_control_ping_t *mp_ping;
18380 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18382 if (unformat (input, "l2"))
18388 M (SW_INTERFACE_SPAN_DUMP, mp);
18392 /* Use a control ping for synchronization */
18393 M (CONTROL_PING, mp_ping);
18401 api_pg_create_interface (vat_main_t * vam)
18403 unformat_input_t *input = vam->input;
18404 vl_api_pg_create_interface_t *mp;
18408 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18410 if (unformat (input, "if_id %d", &if_id))
18417 errmsg ("missing pg interface index");
18421 /* Construct the API message */
18422 M (PG_CREATE_INTERFACE, mp);
18424 mp->interface_id = ntohl (if_id);
18432 api_pg_capture (vat_main_t * vam)
18434 unformat_input_t *input = vam->input;
18435 vl_api_pg_capture_t *mp;
18440 u8 pcap_file_set = 0;
18443 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18445 if (unformat (input, "if_id %d", &if_id))
18447 else if (unformat (input, "pcap %s", &pcap_file))
18449 else if (unformat (input, "count %d", &count))
18451 else if (unformat (input, "disable"))
18458 errmsg ("missing pg interface index");
18461 if (pcap_file_set > 0)
18463 if (vec_len (pcap_file) > 255)
18465 errmsg ("pcap file name is too long");
18470 u32 name_len = vec_len (pcap_file);
18471 /* Construct the API message */
18472 M (PG_CAPTURE, mp);
18474 mp->interface_id = ntohl (if_id);
18475 mp->is_enabled = enable;
18476 mp->count = ntohl (count);
18477 mp->pcap_name_length = ntohl (name_len);
18478 if (pcap_file_set != 0)
18480 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
18482 vec_free (pcap_file);
18490 api_pg_enable_disable (vat_main_t * vam)
18492 unformat_input_t *input = vam->input;
18493 vl_api_pg_enable_disable_t *mp;
18496 u8 stream_name_set = 0;
18497 u8 *stream_name = 0;
18499 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18501 if (unformat (input, "stream %s", &stream_name))
18502 stream_name_set = 1;
18503 else if (unformat (input, "disable"))
18509 if (stream_name_set > 0)
18511 if (vec_len (stream_name) > 255)
18513 errmsg ("stream name too long");
18518 u32 name_len = vec_len (stream_name);
18519 /* Construct the API message */
18520 M (PG_ENABLE_DISABLE, mp);
18522 mp->is_enabled = enable;
18523 if (stream_name_set != 0)
18525 mp->stream_name_length = ntohl (name_len);
18526 clib_memcpy (mp->stream_name, stream_name, name_len);
18528 vec_free (stream_name);
18536 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
18538 unformat_input_t *input = vam->input;
18539 vl_api_ip_source_and_port_range_check_add_del_t *mp;
18541 u16 *low_ports = 0;
18542 u16 *high_ports = 0;
18545 ip4_address_t ip4_addr;
18546 ip6_address_t ip6_addr;
18555 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18557 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
18563 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
18568 else if (unformat (input, "vrf %d", &vrf_id))
18570 else if (unformat (input, "del"))
18572 else if (unformat (input, "port %d", &tmp))
18574 if (tmp == 0 || tmp > 65535)
18576 errmsg ("port %d out of range", tmp);
18580 this_hi = this_low + 1;
18581 vec_add1 (low_ports, this_low);
18582 vec_add1 (high_ports, this_hi);
18584 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
18586 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
18588 errmsg ("incorrect range parameters");
18592 /* Note: in debug CLI +1 is added to high before
18593 passing to real fn that does "the work"
18594 (ip_source_and_port_range_check_add_del).
18595 This fn is a wrapper around the binary API fn a
18596 control plane will call, which expects this increment
18597 to have occurred. Hence letting the binary API control
18598 plane fn do the increment for consistency between VAT
18599 and other control planes.
18602 vec_add1 (low_ports, this_low);
18603 vec_add1 (high_ports, this_hi);
18609 if (prefix_set == 0)
18611 errmsg ("<address>/<mask> not specified");
18617 errmsg ("VRF ID required, not specified");
18624 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18628 if (vec_len (low_ports) == 0)
18630 errmsg ("At least one port or port range required");
18634 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
18636 mp->is_add = is_add;
18641 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
18646 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
18649 mp->mask_length = length;
18650 mp->number_of_ranges = vec_len (low_ports);
18652 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
18653 vec_free (low_ports);
18655 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
18656 vec_free (high_ports);
18658 mp->vrf_id = ntohl (vrf_id);
18666 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
18668 unformat_input_t *input = vam->input;
18669 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
18670 u32 sw_if_index = ~0;
18672 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
18673 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
18677 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18679 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18681 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18683 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
18685 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
18687 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
18689 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
18691 else if (unformat (input, "del"))
18697 if (sw_if_index == ~0)
18699 errmsg ("Interface required but not specified");
18705 errmsg ("VRF ID required but not specified");
18709 if (tcp_out_vrf_id == 0
18710 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
18713 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18717 /* Construct the API message */
18718 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
18720 mp->sw_if_index = ntohl (sw_if_index);
18721 mp->is_add = is_add;
18722 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
18723 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
18724 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
18725 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
18730 /* Wait for a reply... */
18736 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
18738 unformat_input_t *i = vam->input;
18739 vl_api_ipsec_gre_add_del_tunnel_t *mp;
18740 u32 local_sa_id = 0;
18741 u32 remote_sa_id = 0;
18742 ip4_address_t src_address;
18743 ip4_address_t dst_address;
18747 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18749 if (unformat (i, "local_sa %d", &local_sa_id))
18751 else if (unformat (i, "remote_sa %d", &remote_sa_id))
18753 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
18755 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
18757 else if (unformat (i, "del"))
18761 clib_warning ("parse error '%U'", format_unformat_error, i);
18766 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
18768 mp->local_sa_id = ntohl (local_sa_id);
18769 mp->remote_sa_id = ntohl (remote_sa_id);
18770 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
18771 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
18772 mp->is_add = is_add;
18780 api_punt (vat_main_t * vam)
18782 unformat_input_t *i = vam->input;
18790 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18792 if (unformat (i, "ip %d", &ipv))
18794 else if (unformat (i, "protocol %d", &protocol))
18796 else if (unformat (i, "port %d", &port))
18798 else if (unformat (i, "del"))
18802 clib_warning ("parse error '%U'", format_unformat_error, i);
18809 mp->is_add = (u8) is_add;
18810 mp->ipv = (u8) ipv;
18811 mp->l4_protocol = (u8) protocol;
18812 mp->l4_port = htons ((u16) port);
18819 static void vl_api_ipsec_gre_tunnel_details_t_handler
18820 (vl_api_ipsec_gre_tunnel_details_t * mp)
18822 vat_main_t *vam = &vat_main;
18824 print (vam->ofp, "%11d%15U%15U%14d%14d",
18825 ntohl (mp->sw_if_index),
18826 format_ip4_address, &mp->src_address,
18827 format_ip4_address, &mp->dst_address,
18828 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
18831 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
18832 (vl_api_ipsec_gre_tunnel_details_t * mp)
18834 vat_main_t *vam = &vat_main;
18835 vat_json_node_t *node = NULL;
18836 struct in_addr ip4;
18838 if (VAT_JSON_ARRAY != vam->json_tree.type)
18840 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18841 vat_json_init_array (&vam->json_tree);
18843 node = vat_json_array_add (&vam->json_tree);
18845 vat_json_init_object (node);
18846 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18847 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
18848 vat_json_object_add_ip4 (node, "src_address", ip4);
18849 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
18850 vat_json_object_add_ip4 (node, "dst_address", ip4);
18851 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
18852 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
18856 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
18858 unformat_input_t *i = vam->input;
18859 vl_api_ipsec_gre_tunnel_dump_t *mp;
18860 vl_api_control_ping_t *mp_ping;
18862 u8 sw_if_index_set = 0;
18865 /* Parse args required to build the message */
18866 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18868 if (unformat (i, "sw_if_index %d", &sw_if_index))
18869 sw_if_index_set = 1;
18874 if (sw_if_index_set == 0)
18879 if (!vam->json_output)
18881 print (vam->ofp, "%11s%15s%15s%14s%14s",
18882 "sw_if_index", "src_address", "dst_address",
18883 "local_sa_id", "remote_sa_id");
18886 /* Get list of gre-tunnel interfaces */
18887 M (IPSEC_GRE_TUNNEL_DUMP, mp);
18889 mp->sw_if_index = htonl (sw_if_index);
18893 /* Use a control ping for synchronization */
18894 M (CONTROL_PING, mp_ping);
18902 api_delete_subif (vat_main_t * vam)
18904 unformat_input_t *i = vam->input;
18905 vl_api_delete_subif_t *mp;
18906 u32 sw_if_index = ~0;
18909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18911 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18913 if (unformat (i, "sw_if_index %d", &sw_if_index))
18919 if (sw_if_index == ~0)
18921 errmsg ("missing sw_if_index");
18925 /* Construct the API message */
18926 M (DELETE_SUBIF, mp);
18927 mp->sw_if_index = ntohl (sw_if_index);
18934 #define foreach_pbb_vtr_op \
18935 _("disable", L2_VTR_DISABLED) \
18936 _("pop", L2_VTR_POP_2) \
18937 _("push", L2_VTR_PUSH_2)
18940 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
18942 unformat_input_t *i = vam->input;
18943 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
18944 u32 sw_if_index = ~0, vtr_op = ~0;
18945 u16 outer_tag = ~0;
18946 u8 dmac[6], smac[6];
18947 u8 dmac_set = 0, smac_set = 0;
18953 /* Shut up coverity */
18954 memset (dmac, 0, sizeof (dmac));
18955 memset (smac, 0, sizeof (smac));
18957 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18959 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18961 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18963 else if (unformat (i, "vtr_op %d", &vtr_op))
18965 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
18968 else if (unformat (i, "translate_pbb_stag"))
18970 if (unformat (i, "%d", &tmp))
18972 vtr_op = L2_VTR_TRANSLATE_2_1;
18978 ("translate_pbb_stag operation requires outer tag definition");
18982 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
18984 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
18986 else if (unformat (i, "sid %d", &sid))
18988 else if (unformat (i, "vlanid %d", &tmp))
18992 clib_warning ("parse error '%U'", format_unformat_error, i);
18997 if ((sw_if_index == ~0) || (vtr_op == ~0))
18999 errmsg ("missing sw_if_index or vtr operation");
19002 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
19003 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
19006 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
19010 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
19011 mp->sw_if_index = ntohl (sw_if_index);
19012 mp->vtr_op = ntohl (vtr_op);
19013 mp->outer_tag = ntohs (outer_tag);
19014 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
19015 clib_memcpy (mp->b_smac, smac, sizeof (smac));
19016 mp->b_vlanid = ntohs (vlanid);
19017 mp->i_sid = ntohl (sid);
19025 api_flow_classify_set_interface (vat_main_t * vam)
19027 unformat_input_t *i = vam->input;
19028 vl_api_flow_classify_set_interface_t *mp;
19030 int sw_if_index_set;
19031 u32 ip4_table_index = ~0;
19032 u32 ip6_table_index = ~0;
19036 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19038 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19039 sw_if_index_set = 1;
19040 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19041 sw_if_index_set = 1;
19042 else if (unformat (i, "del"))
19044 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19046 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19050 clib_warning ("parse error '%U'", format_unformat_error, i);
19055 if (sw_if_index_set == 0)
19057 errmsg ("missing interface name or sw_if_index");
19061 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
19063 mp->sw_if_index = ntohl (sw_if_index);
19064 mp->ip4_table_index = ntohl (ip4_table_index);
19065 mp->ip6_table_index = ntohl (ip6_table_index);
19066 mp->is_add = is_add;
19074 api_flow_classify_dump (vat_main_t * vam)
19076 unformat_input_t *i = vam->input;
19077 vl_api_flow_classify_dump_t *mp;
19078 vl_api_control_ping_t *mp_ping;
19079 u8 type = FLOW_CLASSIFY_N_TABLES;
19082 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
19086 errmsg ("classify table type must be specified");
19090 if (!vam->json_output)
19092 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19095 M (FLOW_CLASSIFY_DUMP, mp);
19100 /* Use a control ping for synchronization */
19101 M (CONTROL_PING, mp_ping);
19104 /* Wait for a reply... */
19110 api_feature_enable_disable (vat_main_t * vam)
19112 unformat_input_t *i = vam->input;
19113 vl_api_feature_enable_disable_t *mp;
19115 u8 *feature_name = 0;
19116 u32 sw_if_index = ~0;
19120 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19122 if (unformat (i, "arc_name %s", &arc_name))
19124 else if (unformat (i, "feature_name %s", &feature_name))
19127 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19129 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19131 else if (unformat (i, "disable"))
19139 errmsg ("missing arc name");
19142 if (vec_len (arc_name) > 63)
19144 errmsg ("arc name too long");
19147 if (feature_name == 0)
19149 errmsg ("missing feature name");
19152 if (vec_len (feature_name) > 63)
19154 errmsg ("feature name too long");
19157 if (sw_if_index == ~0)
19159 errmsg ("missing interface name or sw_if_index");
19163 /* Construct the API message */
19164 M (FEATURE_ENABLE_DISABLE, mp);
19165 mp->sw_if_index = ntohl (sw_if_index);
19166 mp->enable = enable;
19167 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
19168 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
19169 vec_free (arc_name);
19170 vec_free (feature_name);
19178 api_sw_interface_tag_add_del (vat_main_t * vam)
19180 unformat_input_t *i = vam->input;
19181 vl_api_sw_interface_tag_add_del_t *mp;
19182 u32 sw_if_index = ~0;
19187 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19189 if (unformat (i, "tag %s", &tag))
19191 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19193 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19195 else if (unformat (i, "del"))
19201 if (sw_if_index == ~0)
19203 errmsg ("missing interface name or sw_if_index");
19207 if (enable && (tag == 0))
19209 errmsg ("no tag specified");
19213 /* Construct the API message */
19214 M (SW_INTERFACE_TAG_ADD_DEL, mp);
19215 mp->sw_if_index = ntohl (sw_if_index);
19216 mp->is_add = enable;
19218 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
19226 static void vl_api_l2_xconnect_details_t_handler
19227 (vl_api_l2_xconnect_details_t * mp)
19229 vat_main_t *vam = &vat_main;
19231 print (vam->ofp, "%15d%15d",
19232 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
19235 static void vl_api_l2_xconnect_details_t_handler_json
19236 (vl_api_l2_xconnect_details_t * mp)
19238 vat_main_t *vam = &vat_main;
19239 vat_json_node_t *node = NULL;
19241 if (VAT_JSON_ARRAY != vam->json_tree.type)
19243 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19244 vat_json_init_array (&vam->json_tree);
19246 node = vat_json_array_add (&vam->json_tree);
19248 vat_json_init_object (node);
19249 vat_json_object_add_uint (node, "rx_sw_if_index",
19250 ntohl (mp->rx_sw_if_index));
19251 vat_json_object_add_uint (node, "tx_sw_if_index",
19252 ntohl (mp->tx_sw_if_index));
19256 api_l2_xconnect_dump (vat_main_t * vam)
19258 vl_api_l2_xconnect_dump_t *mp;
19259 vl_api_control_ping_t *mp_ping;
19262 if (!vam->json_output)
19264 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
19267 M (L2_XCONNECT_DUMP, mp);
19271 /* Use a control ping for synchronization */
19272 M (CONTROL_PING, mp_ping);
19280 api_sw_interface_set_mtu (vat_main_t * vam)
19282 unformat_input_t *i = vam->input;
19283 vl_api_sw_interface_set_mtu_t *mp;
19284 u32 sw_if_index = ~0;
19288 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19290 if (unformat (i, "mtu %d", &mtu))
19292 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19294 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19300 if (sw_if_index == ~0)
19302 errmsg ("missing interface name or sw_if_index");
19308 errmsg ("no mtu specified");
19312 /* Construct the API message */
19313 M (SW_INTERFACE_SET_MTU, mp);
19314 mp->sw_if_index = ntohl (sw_if_index);
19315 mp->mtu = ntohs ((u16) mtu);
19323 api_p2p_ethernet_add (vat_main_t * vam)
19325 unformat_input_t *i = vam->input;
19326 vl_api_p2p_ethernet_add_t *mp;
19327 u32 parent_if_index = ~0;
19333 memset (remote_mac, 0, sizeof (remote_mac));
19334 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19336 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19338 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19342 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19344 else if (unformat (i, "sub_id %d", &sub_id))
19348 clib_warning ("parse error '%U'", format_unformat_error, i);
19353 if (parent_if_index == ~0)
19355 errmsg ("missing interface name or sw_if_index");
19360 errmsg ("missing remote mac address");
19365 errmsg ("missing sub-interface id");
19369 M (P2P_ETHERNET_ADD, mp);
19370 mp->parent_if_index = ntohl (parent_if_index);
19371 mp->subif_id = ntohl (sub_id);
19372 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19380 api_p2p_ethernet_del (vat_main_t * vam)
19382 unformat_input_t *i = vam->input;
19383 vl_api_p2p_ethernet_del_t *mp;
19384 u32 parent_if_index = ~0;
19389 memset (remote_mac, 0, sizeof (remote_mac));
19390 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19392 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19394 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19398 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19402 clib_warning ("parse error '%U'", format_unformat_error, i);
19407 if (parent_if_index == ~0)
19409 errmsg ("missing interface name or sw_if_index");
19414 errmsg ("missing remote mac address");
19418 M (P2P_ETHERNET_DEL, mp);
19419 mp->parent_if_index = ntohl (parent_if_index);
19420 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19428 api_lldp_config (vat_main_t * vam)
19430 unformat_input_t *i = vam->input;
19431 vl_api_lldp_config_t *mp;
19433 int tx_interval = 0;
19434 u8 *sys_name = NULL;
19437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19439 if (unformat (i, "system-name %s", &sys_name))
19441 else if (unformat (i, "tx-hold %d", &tx_hold))
19443 else if (unformat (i, "tx-interval %d", &tx_interval))
19447 clib_warning ("parse error '%U'", format_unformat_error, i);
19452 vec_add1 (sys_name, 0);
19454 M (LLDP_CONFIG, mp);
19455 mp->tx_hold = htonl (tx_hold);
19456 mp->tx_interval = htonl (tx_interval);
19457 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
19458 vec_free (sys_name);
19466 api_sw_interface_set_lldp (vat_main_t * vam)
19468 unformat_input_t *i = vam->input;
19469 vl_api_sw_interface_set_lldp_t *mp;
19470 u32 sw_if_index = ~0;
19472 u8 *port_desc = NULL;
19475 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19477 if (unformat (i, "disable"))
19480 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19482 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19484 else if (unformat (i, "port-desc %s", &port_desc))
19490 if (sw_if_index == ~0)
19492 errmsg ("missing interface name or sw_if_index");
19496 /* Construct the API message */
19497 vec_add1 (port_desc, 0);
19498 M (SW_INTERFACE_SET_LLDP, mp);
19499 mp->sw_if_index = ntohl (sw_if_index);
19500 mp->enable = enable;
19501 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
19502 vec_free (port_desc);
19510 q_or_quit (vat_main_t * vam)
19512 #if VPP_API_TEST_BUILTIN == 0
19513 longjmp (vam->jump_buf, 1);
19515 return 0; /* not so much */
19519 q (vat_main_t * vam)
19521 return q_or_quit (vam);
19525 quit (vat_main_t * vam)
19527 return q_or_quit (vam);
19531 comment (vat_main_t * vam)
19537 cmd_cmp (void *a1, void *a2)
19542 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
19546 help (vat_main_t * vam)
19551 unformat_input_t *i = vam->input;
19554 if (unformat (i, "%s", &name))
19558 vec_add1 (name, 0);
19560 hs = hash_get_mem (vam->help_by_name, name);
19562 print (vam->ofp, "usage: %s %s", name, hs[0]);
19564 print (vam->ofp, "No such msg / command '%s'", name);
19569 print (vam->ofp, "Help is available for the following:");
19572 hash_foreach_pair (p, vam->function_by_name,
19574 vec_add1 (cmds, (u8 *)(p->key));
19578 vec_sort_with_function (cmds, cmd_cmp);
19580 for (j = 0; j < vec_len (cmds); j++)
19581 print (vam->ofp, "%s", cmds[j]);
19588 set (vat_main_t * vam)
19590 u8 *name = 0, *value = 0;
19591 unformat_input_t *i = vam->input;
19593 if (unformat (i, "%s", &name))
19595 /* The input buffer is a vector, not a string. */
19596 value = vec_dup (i->buffer);
19597 vec_delete (value, i->index, 0);
19598 /* Almost certainly has a trailing newline */
19599 if (value[vec_len (value) - 1] == '\n')
19600 value[vec_len (value) - 1] = 0;
19601 /* Make sure it's a proper string, one way or the other */
19602 vec_add1 (value, 0);
19603 (void) clib_macro_set_value (&vam->macro_main,
19604 (char *) name, (char *) value);
19607 errmsg ("usage: set <name> <value>");
19615 unset (vat_main_t * vam)
19619 if (unformat (vam->input, "%s", &name))
19620 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
19621 errmsg ("unset: %s wasn't set", name);
19634 macro_sort_cmp (void *a1, void *a2)
19636 macro_sort_t *s1 = a1;
19637 macro_sort_t *s2 = a2;
19639 return strcmp ((char *) (s1->name), (char *) (s2->name));
19643 dump_macro_table (vat_main_t * vam)
19645 macro_sort_t *sort_me = 0, *sm;
19650 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
19652 vec_add2 (sort_me, sm, 1);
19653 sm->name = (u8 *)(p->key);
19654 sm->value = (u8 *) (p->value[0]);
19658 vec_sort_with_function (sort_me, macro_sort_cmp);
19660 if (vec_len (sort_me))
19661 print (vam->ofp, "%-15s%s", "Name", "Value");
19663 print (vam->ofp, "The macro table is empty...");
19665 for (i = 0; i < vec_len (sort_me); i++)
19666 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
19671 dump_node_table (vat_main_t * vam)
19674 vlib_node_t *node, *next_node;
19676 if (vec_len (vam->graph_nodes) == 0)
19678 print (vam->ofp, "Node table empty, issue get_node_graph...");
19682 for (i = 0; i < vec_len (vam->graph_nodes); i++)
19684 node = vam->graph_nodes[i];
19685 print (vam->ofp, "[%d] %s", i, node->name);
19686 for (j = 0; j < vec_len (node->next_nodes); j++)
19688 if (node->next_nodes[j] != ~0)
19690 next_node = vam->graph_nodes[node->next_nodes[j]];
19691 print (vam->ofp, " [%d] %s", j, next_node->name);
19699 value_sort_cmp (void *a1, void *a2)
19701 name_sort_t *n1 = a1;
19702 name_sort_t *n2 = a2;
19704 if (n1->value < n2->value)
19706 if (n1->value > n2->value)
19713 dump_msg_api_table (vat_main_t * vam)
19715 api_main_t *am = &api_main;
19716 name_sort_t *nses = 0, *ns;
19721 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
19723 vec_add2 (nses, ns, 1);
19724 ns->name = (u8 *)(hp->key);
19725 ns->value = (u32) hp->value[0];
19729 vec_sort_with_function (nses, value_sort_cmp);
19731 for (i = 0; i < vec_len (nses); i++)
19732 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
19738 get_msg_id (vat_main_t * vam)
19743 if (unformat (vam->input, "%s", &name_and_crc))
19745 message_index = vl_api_get_msg_index (name_and_crc);
19746 if (message_index == ~0)
19748 print (vam->ofp, " '%s' not found", name_and_crc);
19751 print (vam->ofp, " '%s' has message index %d",
19752 name_and_crc, message_index);
19755 errmsg ("name_and_crc required...");
19760 search_node_table (vat_main_t * vam)
19762 unformat_input_t *line_input = vam->input;
19765 vlib_node_t *node, *next_node;
19768 if (vam->graph_node_index_by_name == 0)
19770 print (vam->ofp, "Node table empty, issue get_node_graph...");
19774 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
19776 if (unformat (line_input, "%s", &node_to_find))
19778 vec_add1 (node_to_find, 0);
19779 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
19782 print (vam->ofp, "%s not found...", node_to_find);
19785 node = vam->graph_nodes[p[0]];
19786 print (vam->ofp, "[%d] %s", p[0], node->name);
19787 for (j = 0; j < vec_len (node->next_nodes); j++)
19789 if (node->next_nodes[j] != ~0)
19791 next_node = vam->graph_nodes[node->next_nodes[j]];
19792 print (vam->ofp, " [%d] %s", j, next_node->name);
19799 clib_warning ("parse error '%U'", format_unformat_error,
19805 vec_free (node_to_find);
19814 script (vat_main_t * vam)
19816 #if (VPP_API_TEST_BUILTIN==0)
19818 char *save_current_file;
19819 unformat_input_t save_input;
19820 jmp_buf save_jump_buf;
19821 u32 save_line_number;
19823 FILE *new_fp, *save_ifp;
19825 if (unformat (vam->input, "%s", &s))
19827 new_fp = fopen ((char *) s, "r");
19830 errmsg ("Couldn't open script file %s", s);
19837 errmsg ("Missing script name");
19841 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
19842 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
19843 save_ifp = vam->ifp;
19844 save_line_number = vam->input_line_number;
19845 save_current_file = (char *) vam->current_file;
19847 vam->input_line_number = 0;
19849 vam->current_file = s;
19852 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
19853 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
19854 vam->ifp = save_ifp;
19855 vam->input_line_number = save_line_number;
19856 vam->current_file = (u8 *) save_current_file;
19861 clib_warning ("use the exec command...");
19867 echo (vat_main_t * vam)
19869 print (vam->ofp, "%v", vam->input->buffer);
19873 /* List of API message constructors, CLI names map to api_xxx */
19874 #define foreach_vpe_api_msg \
19875 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
19876 _(sw_interface_dump,"") \
19877 _(sw_interface_set_flags, \
19878 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
19879 _(sw_interface_add_del_address, \
19880 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
19881 _(sw_interface_set_table, \
19882 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
19883 _(sw_interface_set_mpls_enable, \
19884 "<intfc> | sw_if_index [disable | dis]") \
19885 _(sw_interface_set_vpath, \
19886 "<intfc> | sw_if_index <id> enable | disable") \
19887 _(sw_interface_set_vxlan_bypass, \
19888 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
19889 _(sw_interface_set_l2_xconnect, \
19890 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
19891 "enable | disable") \
19892 _(sw_interface_set_l2_bridge, \
19893 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
19894 "[shg <split-horizon-group>] [bvi]\n" \
19895 "enable | disable") \
19896 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
19897 _(bridge_domain_add_del, \
19898 "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") \
19899 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
19901 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
19902 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
19903 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
19905 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
19907 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
19909 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
19911 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
19913 "<vpp-if-name> | sw_if_index <id>") \
19914 _(sw_interface_tap_dump, "") \
19915 _(ip_add_del_route, \
19916 "<addr>/<mask> via <addr> [table-id <n>]\n" \
19917 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
19918 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
19919 "[multipath] [count <n>]") \
19920 _(ip_mroute_add_del, \
19921 "<src> <grp>/<mask> [table-id <n>]\n" \
19922 "[<intfc> | sw_if_index <id>] [local] [del]") \
19923 _(mpls_route_add_del, \
19924 "<label> <eos> via <addr> [table-id <n>]\n" \
19925 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
19926 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
19927 "[multipath] [count <n>]") \
19928 _(mpls_ip_bind_unbind, \
19929 "<label> <addr/len>") \
19930 _(mpls_tunnel_add_del, \
19931 " via <addr> [table-id <n>]\n" \
19932 "sw_if_index <id>] [l2] [del]") \
19933 _(proxy_arp_add_del, \
19934 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
19935 _(proxy_arp_intfc_enable_disable, \
19936 "<intfc> | sw_if_index <id> enable | disable") \
19937 _(sw_interface_set_unnumbered, \
19938 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
19939 _(ip_neighbor_add_del, \
19940 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
19941 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
19942 _(reset_vrf, "vrf <id> [ipv6]") \
19943 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
19944 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
19945 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
19946 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
19947 "[outer_vlan_id_any][inner_vlan_id_any]") \
19948 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
19949 _(reset_fib, "vrf <n> [ipv6]") \
19950 _(dhcp_proxy_config, \
19951 "svr <v46-address> src <v46-address>\n" \
19952 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
19953 _(dhcp_proxy_set_vss, \
19954 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
19955 _(dhcp_proxy_dump, "ip6") \
19956 _(dhcp_client_config, \
19957 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
19958 _(set_ip_flow_hash, \
19959 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
19960 _(sw_interface_ip6_enable_disable, \
19961 "<intfc> | sw_if_index <id> enable | disable") \
19962 _(sw_interface_ip6_set_link_local_address, \
19963 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
19964 _(ip6nd_proxy_add_del, \
19965 "<intfc> | sw_if_index <id> <ip6-address>") \
19966 _(ip6nd_proxy_dump, "") \
19967 _(sw_interface_ip6nd_ra_prefix, \
19968 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
19969 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
19970 "[nolink] [isno]") \
19971 _(sw_interface_ip6nd_ra_config, \
19972 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
19973 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
19974 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
19975 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
19976 _(l2_patch_add_del, \
19977 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
19978 "enable | disable") \
19979 _(sr_localsid_add_del, \
19980 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
19981 "fib-table <num> (end.psp) sw_if_index <num>") \
19982 _(classify_add_del_table, \
19983 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
19984 " [del] [del-chain] mask <mask-value>\n" \
19985 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
19986 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
19987 _(classify_add_del_session, \
19988 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
19989 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
19990 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
19991 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
19992 _(classify_set_interface_ip_table, \
19993 "<intfc> | sw_if_index <nn> table <nn>") \
19994 _(classify_set_interface_l2_tables, \
19995 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19996 " [other-table <nn>]") \
19997 _(get_node_index, "node <node-name") \
19998 _(add_node_next, "node <node-name> next <next-node-name>") \
19999 _(l2tpv3_create_tunnel, \
20000 "client_address <ip6-addr> our_address <ip6-addr>\n" \
20001 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
20002 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
20003 _(l2tpv3_set_tunnel_cookies, \
20004 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
20005 "[new_remote_cookie <nn>]\n") \
20006 _(l2tpv3_interface_enable_disable, \
20007 "<intfc> | sw_if_index <nn> enable | disable") \
20008 _(l2tpv3_set_lookup_key, \
20009 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
20010 _(sw_if_l2tpv3_tunnel_dump, "") \
20011 _(vxlan_add_del_tunnel, \
20012 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
20013 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20014 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
20015 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20016 _(gre_add_del_tunnel, \
20017 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
20018 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20019 _(l2_fib_clear_table, "") \
20020 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
20021 _(l2_interface_vlan_tag_rewrite, \
20022 "<intfc> | sw_if_index <nn> \n" \
20023 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
20024 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
20025 _(create_vhost_user_if, \
20026 "socket <filename> [server] [renumber <dev_instance>] " \
20027 "[mac <mac_address>]") \
20028 _(modify_vhost_user_if, \
20029 "<intfc> | sw_if_index <nn> socket <filename>\n" \
20030 "[server] [renumber <dev_instance>]") \
20031 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
20032 _(sw_interface_vhost_user_dump, "") \
20033 _(show_version, "") \
20034 _(vxlan_gpe_add_del_tunnel, \
20035 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
20036 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20037 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
20038 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
20039 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20040 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
20041 _(interface_name_renumber, \
20042 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
20043 _(input_acl_set_interface, \
20044 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20045 " [l2-table <nn>] [del]") \
20046 _(want_ip4_arp_events, "address <ip4-address> [del]") \
20047 _(want_ip6_nd_events, "address <ip6-address> [del]") \
20048 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
20049 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
20050 _(ip_dump, "ipv4 | ipv6") \
20051 _(ipsec_spd_add_del, "spd_id <n> [del]") \
20052 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
20054 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
20055 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
20056 " integ_alg <alg> integ_key <hex>") \
20057 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
20058 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
20059 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
20060 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
20061 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
20062 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
20063 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
20064 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
20065 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
20066 _(ikev2_profile_add_del, "name <profile_name> [del]") \
20067 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
20068 "(auth_data 0x<data> | auth_data <data>)") \
20069 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
20070 "(id_data 0x<data> | id_data <data>) (local|remote)") \
20071 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
20072 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
20073 "(local|remote)") \
20074 _(ikev2_set_local_key, "file <absolute_file_path>") \
20075 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
20076 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
20077 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
20078 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
20079 _(ikev2_initiate_sa_init, "<profile_name>") \
20080 _(ikev2_initiate_del_ike_sa, "<ispi>") \
20081 _(ikev2_initiate_del_child_sa, "<ispi>") \
20082 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
20083 _(delete_loopback,"sw_if_index <nn>") \
20084 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
20085 _(map_add_domain, \
20086 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
20087 "ip6-src <ip6addr> " \
20088 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
20089 _(map_del_domain, "index <n>") \
20090 _(map_add_del_rule, \
20091 "index <n> psid <n> dst <ip6addr> [del]") \
20092 _(map_domain_dump, "") \
20093 _(map_rule_dump, "index <map-domain>") \
20094 _(want_interface_events, "enable|disable") \
20095 _(want_stats,"enable|disable") \
20096 _(get_first_msg_id, "client <name>") \
20097 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
20098 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
20099 "fib-id <nn> [ip4][ip6][default]") \
20100 _(get_node_graph, " ") \
20101 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
20102 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
20103 _(ioam_disable, "") \
20104 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
20105 " sw_if_index <sw_if_index> p <priority> " \
20106 "w <weight>] [del]") \
20107 _(one_add_del_locator, "locator-set <locator_name> " \
20108 "iface <intf> | sw_if_index <sw_if_index> " \
20109 "p <priority> w <weight> [del]") \
20110 _(one_add_del_local_eid,"vni <vni> eid " \
20111 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20112 "locator-set <locator_name> [del]" \
20113 "[key-id sha1|sha256 secret-key <secret-key>]")\
20114 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
20115 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
20116 _(one_enable_disable, "enable|disable") \
20117 _(one_map_register_enable_disable, "enable|disable") \
20118 _(one_rloc_probe_enable_disable, "enable|disable") \
20119 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20121 "rloc <locator> p <prio> " \
20122 "w <weight> [rloc <loc> ... ] " \
20123 "action <action> [del-all]") \
20124 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20126 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20127 _(one_use_petr, "ip-address> | disable") \
20128 _(one_map_request_mode, "src-dst|dst-only") \
20129 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20130 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20131 _(one_locator_set_dump, "[local | remote]") \
20132 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
20133 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20134 "[local] | [remote]") \
20135 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
20136 _(one_l2_arp_bd_get, "") \
20137 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
20138 _(one_stats_enable_disable, "enable|disalbe") \
20139 _(show_one_stats_enable_disable, "") \
20140 _(one_eid_table_vni_dump, "") \
20141 _(one_eid_table_map_dump, "l2|l3") \
20142 _(one_map_resolver_dump, "") \
20143 _(one_map_server_dump, "") \
20144 _(one_adjacencies_get, "vni <vni>") \
20145 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
20146 _(show_one_rloc_probe_state, "") \
20147 _(show_one_map_register_state, "") \
20148 _(show_one_status, "") \
20149 _(one_stats_dump, "") \
20150 _(one_stats_flush, "") \
20151 _(one_get_map_request_itr_rlocs, "") \
20152 _(one_map_register_set_ttl, "<ttl>") \
20153 _(show_one_nsh_mapping, "") \
20154 _(show_one_pitr, "") \
20155 _(show_one_use_petr, "") \
20156 _(show_one_map_request_mode, "") \
20157 _(show_one_map_register_ttl, "") \
20158 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
20159 " sw_if_index <sw_if_index> p <priority> " \
20160 "w <weight>] [del]") \
20161 _(lisp_add_del_locator, "locator-set <locator_name> " \
20162 "iface <intf> | sw_if_index <sw_if_index> " \
20163 "p <priority> w <weight> [del]") \
20164 _(lisp_add_del_local_eid,"vni <vni> eid " \
20165 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20166 "locator-set <locator_name> [del]" \
20167 "[key-id sha1|sha256 secret-key <secret-key>]") \
20168 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
20169 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
20170 _(lisp_enable_disable, "enable|disable") \
20171 _(lisp_map_register_enable_disable, "enable|disable") \
20172 _(lisp_rloc_probe_enable_disable, "enable|disable") \
20173 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20175 "rloc <locator> p <prio> " \
20176 "w <weight> [rloc <loc> ... ] " \
20177 "action <action> [del-all]") \
20178 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20180 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20181 _(lisp_use_petr, "<ip-address> | disable") \
20182 _(lisp_map_request_mode, "src-dst|dst-only") \
20183 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20184 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20185 _(lisp_locator_set_dump, "[local | remote]") \
20186 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
20187 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20188 "[local] | [remote]") \
20189 _(lisp_eid_table_vni_dump, "") \
20190 _(lisp_eid_table_map_dump, "l2|l3") \
20191 _(lisp_map_resolver_dump, "") \
20192 _(lisp_map_server_dump, "") \
20193 _(lisp_adjacencies_get, "vni <vni>") \
20194 _(gpe_fwd_entry_vnis_get, "") \
20195 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
20196 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
20197 "[table <table-id>]") \
20198 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
20199 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
20200 _(gpe_set_encap_mode, "lisp|vxlan") \
20201 _(gpe_get_encap_mode, "") \
20202 _(lisp_gpe_add_del_iface, "up|down") \
20203 _(lisp_gpe_enable_disable, "enable|disable") \
20204 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
20205 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
20206 _(show_lisp_rloc_probe_state, "") \
20207 _(show_lisp_map_register_state, "") \
20208 _(show_lisp_status, "") \
20209 _(lisp_get_map_request_itr_rlocs, "") \
20210 _(show_lisp_pitr, "") \
20211 _(show_lisp_use_petr, "") \
20212 _(show_lisp_map_request_mode, "") \
20213 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
20214 _(af_packet_delete, "name <host interface name>") \
20215 _(policer_add_del, "name <policer name> <params> [del]") \
20216 _(policer_dump, "[name <policer name>]") \
20217 _(policer_classify_set_interface, \
20218 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20219 " [l2-table <nn>] [del]") \
20220 _(policer_classify_dump, "type [ip4|ip6|l2]") \
20221 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
20222 "[master|slave]") \
20223 _(netmap_delete, "name <interface name>") \
20224 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
20225 _(mpls_fib_dump, "") \
20226 _(classify_table_ids, "") \
20227 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
20228 _(classify_table_info, "table_id <nn>") \
20229 _(classify_session_dump, "table_id <nn>") \
20230 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
20231 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
20232 "[template_interval <nn>] [udp_checksum]") \
20233 _(ipfix_exporter_dump, "") \
20234 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
20235 _(ipfix_classify_stream_dump, "") \
20236 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
20237 _(ipfix_classify_table_dump, "") \
20238 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
20239 _(sw_interface_span_dump, "[l2]") \
20240 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
20241 _(pg_create_interface, "if_id <nn>") \
20242 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
20243 _(pg_enable_disable, "[stream <id>] disable") \
20244 _(ip_source_and_port_range_check_add_del, \
20245 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
20246 _(ip_source_and_port_range_check_interface_add_del, \
20247 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
20248 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
20249 _(ipsec_gre_add_del_tunnel, \
20250 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
20251 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
20252 _(delete_subif,"<intfc> | sw_if_index <nn>") \
20253 _(l2_interface_pbb_tag_rewrite, \
20254 "<intfc> | sw_if_index <nn> \n" \
20255 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
20256 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
20257 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
20258 _(flow_classify_set_interface, \
20259 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
20260 _(flow_classify_dump, "type [ip4|ip6]") \
20261 _(ip_fib_dump, "") \
20262 _(ip_mfib_dump, "") \
20263 _(ip6_fib_dump, "") \
20264 _(ip6_mfib_dump, "") \
20265 _(feature_enable_disable, "arc_name <arc_name> " \
20266 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
20267 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
20269 _(l2_xconnect_dump, "") \
20270 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
20271 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
20272 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
20273 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
20274 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
20275 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
20276 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>] [disable]")
20278 /* List of command functions, CLI names map directly to functions */
20279 #define foreach_cli_function \
20280 _(comment, "usage: comment <ignore-rest-of-line>") \
20281 _(dump_interface_table, "usage: dump_interface_table") \
20282 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
20283 _(dump_ipv4_table, "usage: dump_ipv4_table") \
20284 _(dump_ipv6_table, "usage: dump_ipv6_table") \
20285 _(dump_stats_table, "usage: dump_stats_table") \
20286 _(dump_macro_table, "usage: dump_macro_table ") \
20287 _(dump_node_table, "usage: dump_node_table") \
20288 _(dump_msg_api_table, "usage: dump_msg_api_table") \
20289 _(get_msg_id, "usage: get_msg_id name_and_crc") \
20290 _(echo, "usage: echo <message>") \
20291 _(exec, "usage: exec <vpe-debug-CLI-command>") \
20292 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
20293 _(help, "usage: help") \
20294 _(q, "usage: quit") \
20295 _(quit, "usage: quit") \
20296 _(search_node_table, "usage: search_node_table <name>...") \
20297 _(set, "usage: set <variable-name> <value>") \
20298 _(script, "usage: script <file-name>") \
20299 _(unset, "usage: unset <variable-name>")
20301 static void vl_api_##n##_t_handler_uni \
20302 (vl_api_##n##_t * mp) \
20304 vat_main_t * vam = &vat_main; \
20305 if (vam->json_output) { \
20306 vl_api_##n##_t_handler_json(mp); \
20308 vl_api_##n##_t_handler(mp); \
20311 foreach_vpe_api_reply_msg;
20312 #if VPP_API_TEST_BUILTIN == 0
20313 foreach_standalone_reply_msg;
20318 vat_api_hookup (vat_main_t * vam)
20321 vl_msg_api_set_handlers(VL_API_##N, #n, \
20322 vl_api_##n##_t_handler_uni, \
20324 vl_api_##n##_t_endian, \
20325 vl_api_##n##_t_print, \
20326 sizeof(vl_api_##n##_t), 1);
20327 foreach_vpe_api_reply_msg;
20328 #if VPP_API_TEST_BUILTIN == 0
20329 foreach_standalone_reply_msg;
20333 #if (VPP_API_TEST_BUILTIN==0)
20334 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
20336 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
20338 vam->function_by_name = hash_create_string (0, sizeof (uword));
20340 vam->help_by_name = hash_create_string (0, sizeof (uword));
20343 /* API messages we can send */
20344 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
20345 foreach_vpe_api_msg;
20349 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
20350 foreach_vpe_api_msg;
20353 /* CLI functions */
20354 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
20355 foreach_cli_function;
20359 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
20360 foreach_cli_function;
20364 #if VPP_API_TEST_BUILTIN
20365 static clib_error_t *
20366 vat_api_hookup_shim (vlib_main_t * vm)
20368 vat_api_hookup (&vat_main);
20372 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
20376 * fd.io coding-style-patch-verification: ON
20379 * eval: (c-set-style "gnu")