2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vlibapi/api.h>
22 #include <vlibmemory/api.h>
23 #include <vlibsocket/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/l2/l2_input.h>
26 #include <vnet/l2tp/l2tp.h>
27 #include <vnet/vxlan/vxlan.h>
28 #include <vnet/gre/gre.h>
29 #include <vnet/vxlan-gpe/vxlan_gpe.h>
30 #include <vnet/lisp-gpe/lisp_gpe.h>
32 #include <vpp/api/vpe_msg_enum.h>
33 #include <vnet/l2/l2_classify.h>
34 #include <vnet/l2/l2_vtr.h>
35 #include <vnet/classify/input_acl.h>
36 #include <vnet/classify/policer_classify.h>
37 #include <vnet/classify/flow_classify.h>
38 #include <vnet/mpls/mpls.h>
39 #include <vnet/ipsec/ipsec.h>
40 #include <vnet/ipsec/ikev2.h>
42 #include <vnet/map/map.h>
43 #include <vnet/cop/cop.h>
44 #include <vnet/ip/ip6_hop_by_hop.h>
45 #include <vnet/ip/ip_source_and_port_range_check.h>
46 #include <vnet/policer/xlate.h>
47 #include <vnet/span/span.h>
48 #include <vnet/policer/policer.h>
49 #include <vnet/policer/police.h>
50 #include <vnet/mfib/mfib_types.h>
52 #include "vat/json_format.h"
57 #define vl_typedefs /* define message structures */
58 #include <vpp/api/vpe_all_api_h.h>
61 /* declare message handlers for each api */
63 #define vl_endianfun /* define message structures */
64 #include <vpp/api/vpe_all_api_h.h>
67 /* instantiate all the print functions we know about */
68 #define vl_print(handle, ...)
70 #include <vpp/api/vpe_all_api_h.h>
73 #define __plugin_msg_base 0
74 #include <vlibapi/vat_helper_macros.h>
77 vat_time_now (vat_main_t * vam)
79 #if VPP_API_TEST_BUILTIN
80 return vlib_time_now (vam->vlib_main);
82 return clib_time_now (&vam->clib_time);
87 errmsg (char *fmt, ...)
89 vat_main_t *vam = &vat_main;
94 s = va_format (0, fmt, &va);
99 #if VPP_API_TEST_BUILTIN
100 vlib_cli_output (vam->vlib_main, (char *) s);
103 if (vam->ifp != stdin)
104 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
105 vam->input_line_number);
106 fformat (vam->ofp, (char *) s);
114 #if VPP_API_TEST_BUILTIN == 0
116 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
118 vat_main_t *vam = va_arg (*args, vat_main_t *);
119 u32 *result = va_arg (*args, u32 *);
123 if (!unformat (input, "%s", &if_name))
126 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
133 /* Parse an IP4 address %d.%d.%d.%d. */
135 unformat_ip4_address (unformat_input_t * input, va_list * args)
137 u8 *result = va_arg (*args, u8 *);
140 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
143 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
155 unformat_ethernet_address (unformat_input_t * input, va_list * args)
157 u8 *result = va_arg (*args, u8 *);
160 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
161 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
165 for (i = 0; i < 6; i++)
166 if (a[i] >= (1 << 8))
169 for (i = 0; i < 6; i++)
175 /* Returns ethernet type as an int in host byte order. */
177 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
180 u16 *result = va_arg (*args, u16 *);
184 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
186 if (type >= (1 << 16))
194 /* Parse an IP6 address. */
196 unformat_ip6_address (unformat_input_t * input, va_list * args)
198 ip6_address_t *result = va_arg (*args, ip6_address_t *);
200 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
201 uword c, n_colon, double_colon_index;
203 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
204 double_colon_index = ARRAY_LEN (hex_quads);
205 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
208 if (c >= '0' && c <= '9')
210 else if (c >= 'a' && c <= 'f')
211 hex_digit = c + 10 - 'a';
212 else if (c >= 'A' && c <= 'F')
213 hex_digit = c + 10 - 'A';
214 else if (c == ':' && n_colon < 2)
218 unformat_put_input (input);
222 /* Too many hex quads. */
223 if (n_hex_quads >= ARRAY_LEN (hex_quads))
228 hex_quad = (hex_quad << 4) | hex_digit;
230 /* Hex quad must fit in 16 bits. */
231 if (n_hex_digits >= 4)
238 /* Save position of :: */
241 /* More than one :: ? */
242 if (double_colon_index < ARRAY_LEN (hex_quads))
244 double_colon_index = n_hex_quads;
247 if (n_colon > 0 && n_hex_digits > 0)
249 hex_quads[n_hex_quads++] = hex_quad;
255 if (n_hex_digits > 0)
256 hex_quads[n_hex_quads++] = hex_quad;
261 /* Expand :: to appropriate number of zero hex quads. */
262 if (double_colon_index < ARRAY_LEN (hex_quads))
264 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
266 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
267 hex_quads[n_zero + i] = hex_quads[i];
269 for (i = 0; i < n_zero; i++)
270 hex_quads[double_colon_index + i] = 0;
272 n_hex_quads = ARRAY_LEN (hex_quads);
275 /* Too few hex quads given. */
276 if (n_hex_quads < ARRAY_LEN (hex_quads))
279 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
280 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
287 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
289 u32 *r = va_arg (*args, u32 *);
292 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
293 foreach_ipsec_policy_action
301 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
303 u32 *r = va_arg (*args, u32 *);
306 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
307 foreach_ipsec_crypto_alg
315 format_ipsec_crypto_alg (u8 * s, va_list * args)
317 u32 i = va_arg (*args, u32);
322 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
323 foreach_ipsec_crypto_alg
326 return format (s, "unknown");
328 return format (s, "%s", t);
332 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
334 u32 *r = va_arg (*args, u32 *);
337 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
338 foreach_ipsec_integ_alg
346 format_ipsec_integ_alg (u8 * s, va_list * args)
348 u32 i = va_arg (*args, u32);
353 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
354 foreach_ipsec_integ_alg
357 return format (s, "unknown");
359 return format (s, "%s", t);
363 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
365 u32 *r = va_arg (*args, u32 *);
368 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
369 foreach_ikev2_auth_method
377 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
379 u32 *r = va_arg (*args, u32 *);
382 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
383 foreach_ikev2_id_type
389 #else /* VPP_API_TEST_BUILTIN == 1 */
391 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
393 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
394 vnet_main_t *vnm = vnet_get_main ();
395 u32 *result = va_arg (*args, u32 *);
398 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
401 *result = sw_if_index;
404 #endif /* VPP_API_TEST_BUILTIN */
407 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
409 u8 *r = va_arg (*args, u8 *);
411 if (unformat (input, "kbps"))
412 *r = SSE2_QOS_RATE_KBPS;
413 else if (unformat (input, "pps"))
414 *r = SSE2_QOS_RATE_PPS;
421 unformat_policer_round_type (unformat_input_t * input, va_list * args)
423 u8 *r = va_arg (*args, u8 *);
425 if (unformat (input, "closest"))
426 *r = SSE2_QOS_ROUND_TO_CLOSEST;
427 else if (unformat (input, "up"))
428 *r = SSE2_QOS_ROUND_TO_UP;
429 else if (unformat (input, "down"))
430 *r = SSE2_QOS_ROUND_TO_DOWN;
437 unformat_policer_type (unformat_input_t * input, va_list * args)
439 u8 *r = va_arg (*args, u8 *);
441 if (unformat (input, "1r2c"))
442 *r = SSE2_QOS_POLICER_TYPE_1R2C;
443 else if (unformat (input, "1r3c"))
444 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
445 else if (unformat (input, "2r3c-2698"))
446 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
447 else if (unformat (input, "2r3c-4115"))
448 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
449 else if (unformat (input, "2r3c-mef5cf1"))
450 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
457 unformat_dscp (unformat_input_t * input, va_list * va)
459 u8 *r = va_arg (*va, u8 *);
462 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
471 unformat_policer_action_type (unformat_input_t * input, va_list * va)
473 sse2_qos_pol_action_params_st *a
474 = va_arg (*va, sse2_qos_pol_action_params_st *);
476 if (unformat (input, "drop"))
477 a->action_type = SSE2_QOS_ACTION_DROP;
478 else if (unformat (input, "transmit"))
479 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
480 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
481 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
488 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
490 u32 *r = va_arg (*va, u32 *);
493 if (unformat (input, "ip4"))
494 tid = POLICER_CLASSIFY_TABLE_IP4;
495 else if (unformat (input, "ip6"))
496 tid = POLICER_CLASSIFY_TABLE_IP6;
497 else if (unformat (input, "l2"))
498 tid = POLICER_CLASSIFY_TABLE_L2;
507 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
509 u32 *r = va_arg (*va, u32 *);
512 if (unformat (input, "ip4"))
513 tid = FLOW_CLASSIFY_TABLE_IP4;
514 else if (unformat (input, "ip6"))
515 tid = FLOW_CLASSIFY_TABLE_IP6;
523 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
524 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
525 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
526 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
528 #if (VPP_API_TEST_BUILTIN==0)
530 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
532 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
533 mfib_itf_attribute_t attr;
536 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
538 if (unformat (input, mfib_itf_flag_long_names[attr]))
539 *iflags |= (1 << attr);
541 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
543 if (unformat (input, mfib_itf_flag_names[attr]))
544 *iflags |= (1 << attr);
547 return (old == *iflags ? 0 : 1);
551 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
553 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
554 mfib_entry_attribute_t attr;
557 FOR_EACH_MFIB_ATTRIBUTE (attr)
559 if (unformat (input, mfib_flag_long_names[attr]))
560 *eflags |= (1 << attr);
562 FOR_EACH_MFIB_ATTRIBUTE (attr)
564 if (unformat (input, mfib_flag_names[attr]))
565 *eflags |= (1 << attr);
568 return (old == *eflags ? 0 : 1);
572 format_ip4_address (u8 * s, va_list * args)
574 u8 *a = va_arg (*args, u8 *);
575 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
579 format_ip6_address (u8 * s, va_list * args)
581 ip6_address_t *a = va_arg (*args, ip6_address_t *);
582 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
584 i_max_n_zero = ARRAY_LEN (a->as_u16);
586 i_first_zero = i_max_n_zero;
588 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
590 u32 is_zero = a->as_u16[i] == 0;
591 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
597 if ((!is_zero && n_zeros > max_n_zeros)
598 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
600 i_max_n_zero = i_first_zero;
601 max_n_zeros = n_zeros;
602 i_first_zero = ARRAY_LEN (a->as_u16);
607 last_double_colon = 0;
608 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
610 if (i == i_max_n_zero && max_n_zeros > 1)
612 s = format (s, "::");
613 i += max_n_zeros - 1;
614 last_double_colon = 1;
618 s = format (s, "%s%x",
619 (last_double_colon || i == 0) ? "" : ":",
620 clib_net_to_host_u16 (a->as_u16[i]));
621 last_double_colon = 0;
628 /* Format an IP46 address. */
630 format_ip46_address (u8 * s, va_list * args)
632 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
633 ip46_type_t type = va_arg (*args, ip46_type_t);
639 is_ip4 = ip46_address_is_ip4 (ip46);
650 format (s, "%U", format_ip4_address, &ip46->ip4) :
651 format (s, "%U", format_ip6_address, &ip46->ip6);
655 format_ethernet_address (u8 * s, va_list * args)
657 u8 *a = va_arg (*args, u8 *);
659 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
660 a[0], a[1], a[2], a[3], a[4], a[5]);
665 increment_v4_address (ip4_address_t * a)
669 v = ntohl (a->as_u32) + 1;
670 a->as_u32 = ntohl (v);
674 increment_v6_address (ip6_address_t * a)
678 v0 = clib_net_to_host_u64 (a->as_u64[0]);
679 v1 = clib_net_to_host_u64 (a->as_u64[1]);
684 a->as_u64[0] = clib_net_to_host_u64 (v0);
685 a->as_u64[1] = clib_net_to_host_u64 (v1);
689 increment_mac_address (u64 * mac)
693 tmp = clib_net_to_host_u64 (tmp);
694 tmp += 1 << 16; /* skip unused (least significant) octets */
695 tmp = clib_host_to_net_u64 (tmp);
699 static void vl_api_create_loopback_reply_t_handler
700 (vl_api_create_loopback_reply_t * mp)
702 vat_main_t *vam = &vat_main;
703 i32 retval = ntohl (mp->retval);
705 vam->retval = retval;
706 vam->regenerate_interface_table = 1;
707 vam->sw_if_index = ntohl (mp->sw_if_index);
708 vam->result_ready = 1;
711 static void vl_api_create_loopback_reply_t_handler_json
712 (vl_api_create_loopback_reply_t * mp)
714 vat_main_t *vam = &vat_main;
715 vat_json_node_t node;
717 vat_json_init_object (&node);
718 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
719 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
721 vat_json_print (vam->ofp, &node);
722 vat_json_free (&node);
723 vam->retval = ntohl (mp->retval);
724 vam->result_ready = 1;
727 static void vl_api_create_loopback_instance_reply_t_handler
728 (vl_api_create_loopback_instance_reply_t * mp)
730 vat_main_t *vam = &vat_main;
731 i32 retval = ntohl (mp->retval);
733 vam->retval = retval;
734 vam->regenerate_interface_table = 1;
735 vam->sw_if_index = ntohl (mp->sw_if_index);
736 vam->result_ready = 1;
739 static void vl_api_create_loopback_instance_reply_t_handler_json
740 (vl_api_create_loopback_instance_reply_t * mp)
742 vat_main_t *vam = &vat_main;
743 vat_json_node_t node;
745 vat_json_init_object (&node);
746 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
747 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
749 vat_json_print (vam->ofp, &node);
750 vat_json_free (&node);
751 vam->retval = ntohl (mp->retval);
752 vam->result_ready = 1;
755 static void vl_api_af_packet_create_reply_t_handler
756 (vl_api_af_packet_create_reply_t * mp)
758 vat_main_t *vam = &vat_main;
759 i32 retval = ntohl (mp->retval);
761 vam->retval = retval;
762 vam->regenerate_interface_table = 1;
763 vam->sw_if_index = ntohl (mp->sw_if_index);
764 vam->result_ready = 1;
767 static void vl_api_af_packet_create_reply_t_handler_json
768 (vl_api_af_packet_create_reply_t * mp)
770 vat_main_t *vam = &vat_main;
771 vat_json_node_t node;
773 vat_json_init_object (&node);
774 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
775 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
777 vat_json_print (vam->ofp, &node);
778 vat_json_free (&node);
780 vam->retval = ntohl (mp->retval);
781 vam->result_ready = 1;
784 static void vl_api_create_vlan_subif_reply_t_handler
785 (vl_api_create_vlan_subif_reply_t * mp)
787 vat_main_t *vam = &vat_main;
788 i32 retval = ntohl (mp->retval);
790 vam->retval = retval;
791 vam->regenerate_interface_table = 1;
792 vam->sw_if_index = ntohl (mp->sw_if_index);
793 vam->result_ready = 1;
796 static void vl_api_create_vlan_subif_reply_t_handler_json
797 (vl_api_create_vlan_subif_reply_t * mp)
799 vat_main_t *vam = &vat_main;
800 vat_json_node_t node;
802 vat_json_init_object (&node);
803 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
804 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
806 vat_json_print (vam->ofp, &node);
807 vat_json_free (&node);
809 vam->retval = ntohl (mp->retval);
810 vam->result_ready = 1;
813 static void vl_api_create_subif_reply_t_handler
814 (vl_api_create_subif_reply_t * mp)
816 vat_main_t *vam = &vat_main;
817 i32 retval = ntohl (mp->retval);
819 vam->retval = retval;
820 vam->regenerate_interface_table = 1;
821 vam->sw_if_index = ntohl (mp->sw_if_index);
822 vam->result_ready = 1;
825 static void vl_api_create_subif_reply_t_handler_json
826 (vl_api_create_subif_reply_t * mp)
828 vat_main_t *vam = &vat_main;
829 vat_json_node_t node;
831 vat_json_init_object (&node);
832 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
833 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
835 vat_json_print (vam->ofp, &node);
836 vat_json_free (&node);
838 vam->retval = ntohl (mp->retval);
839 vam->result_ready = 1;
842 static void vl_api_interface_name_renumber_reply_t_handler
843 (vl_api_interface_name_renumber_reply_t * mp)
845 vat_main_t *vam = &vat_main;
846 i32 retval = ntohl (mp->retval);
848 vam->retval = retval;
849 vam->regenerate_interface_table = 1;
850 vam->result_ready = 1;
853 static void vl_api_interface_name_renumber_reply_t_handler_json
854 (vl_api_interface_name_renumber_reply_t * mp)
856 vat_main_t *vam = &vat_main;
857 vat_json_node_t node;
859 vat_json_init_object (&node);
860 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
862 vat_json_print (vam->ofp, &node);
863 vat_json_free (&node);
865 vam->retval = ntohl (mp->retval);
866 vam->result_ready = 1;
870 * Special-case: build the interface table, maintain
871 * the next loopback sw_if_index vbl.
873 static void vl_api_sw_interface_details_t_handler
874 (vl_api_sw_interface_details_t * mp)
876 vat_main_t *vam = &vat_main;
877 u8 *s = format (0, "%s%c", mp->interface_name, 0);
879 hash_set_mem (vam->sw_if_index_by_interface_name, s,
880 ntohl (mp->sw_if_index));
882 /* In sub interface case, fill the sub interface table entry */
883 if (mp->sw_if_index != mp->sup_sw_if_index)
885 sw_interface_subif_t *sub = NULL;
887 vec_add2 (vam->sw_if_subif_table, sub, 1);
889 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
890 strncpy ((char *) sub->interface_name, (char *) s,
891 vec_len (sub->interface_name));
892 sub->sw_if_index = ntohl (mp->sw_if_index);
893 sub->sub_id = ntohl (mp->sub_id);
895 sub->sub_dot1ad = mp->sub_dot1ad;
896 sub->sub_number_of_tags = mp->sub_number_of_tags;
897 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
898 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
899 sub->sub_exact_match = mp->sub_exact_match;
900 sub->sub_default = mp->sub_default;
901 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
902 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
904 /* vlan tag rewrite */
905 sub->vtr_op = ntohl (mp->vtr_op);
906 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
907 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
908 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
912 static void vl_api_sw_interface_details_t_handler_json
913 (vl_api_sw_interface_details_t * mp)
915 vat_main_t *vam = &vat_main;
916 vat_json_node_t *node = NULL;
918 if (VAT_JSON_ARRAY != vam->json_tree.type)
920 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
921 vat_json_init_array (&vam->json_tree);
923 node = vat_json_array_add (&vam->json_tree);
925 vat_json_init_object (node);
926 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
927 vat_json_object_add_uint (node, "sup_sw_if_index",
928 ntohl (mp->sup_sw_if_index));
929 vat_json_object_add_uint (node, "l2_address_length",
930 ntohl (mp->l2_address_length));
931 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
932 sizeof (mp->l2_address));
933 vat_json_object_add_string_copy (node, "interface_name",
935 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
936 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
937 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
938 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
939 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
940 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
941 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
942 vat_json_object_add_uint (node, "sub_number_of_tags",
943 mp->sub_number_of_tags);
944 vat_json_object_add_uint (node, "sub_outer_vlan_id",
945 ntohs (mp->sub_outer_vlan_id));
946 vat_json_object_add_uint (node, "sub_inner_vlan_id",
947 ntohs (mp->sub_inner_vlan_id));
948 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
949 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
950 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
951 mp->sub_outer_vlan_id_any);
952 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
953 mp->sub_inner_vlan_id_any);
954 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
955 vat_json_object_add_uint (node, "vtr_push_dot1q",
956 ntohl (mp->vtr_push_dot1q));
957 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
958 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
961 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
963 format_ethernet_address,
965 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
967 format_ethernet_address,
969 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
970 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
974 #if VPP_API_TEST_BUILTIN == 0
975 static void vl_api_sw_interface_set_flags_t_handler
976 (vl_api_sw_interface_set_flags_t * mp)
978 vat_main_t *vam = &vat_main;
979 if (vam->interface_event_display)
980 errmsg ("interface flags: sw_if_index %d %s %s",
981 ntohl (mp->sw_if_index),
982 mp->admin_up_down ? "admin-up" : "admin-down",
983 mp->link_up_down ? "link-up" : "link-down");
987 static void vl_api_sw_interface_set_flags_t_handler_json
988 (vl_api_sw_interface_set_flags_t * mp)
990 /* JSON output not supported */
994 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
996 vat_main_t *vam = &vat_main;
997 i32 retval = ntohl (mp->retval);
999 vam->retval = retval;
1000 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1001 vam->result_ready = 1;
1005 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1007 vat_main_t *vam = &vat_main;
1008 vat_json_node_t node;
1009 api_main_t *am = &api_main;
1013 vat_json_init_object (&node);
1014 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1015 vat_json_object_add_uint (&node, "reply_in_shmem",
1016 ntohl (mp->reply_in_shmem));
1017 /* Toss the shared-memory original... */
1018 pthread_mutex_lock (&am->vlib_rp->mutex);
1019 oldheap = svm_push_data_heap (am->vlib_rp);
1021 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1024 svm_pop_heap (oldheap);
1025 pthread_mutex_unlock (&am->vlib_rp->mutex);
1027 vat_json_print (vam->ofp, &node);
1028 vat_json_free (&node);
1030 vam->retval = ntohl (mp->retval);
1031 vam->result_ready = 1;
1035 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1037 vat_main_t *vam = &vat_main;
1038 i32 retval = ntohl (mp->retval);
1040 vam->retval = retval;
1041 vam->cmd_reply = mp->reply;
1042 vam->result_ready = 1;
1046 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1048 vat_main_t *vam = &vat_main;
1049 vat_json_node_t node;
1051 vat_json_init_object (&node);
1052 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1053 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1055 vat_json_print (vam->ofp, &node);
1056 vat_json_free (&node);
1058 vam->retval = ntohl (mp->retval);
1059 vam->result_ready = 1;
1062 static void vl_api_classify_add_del_table_reply_t_handler
1063 (vl_api_classify_add_del_table_reply_t * mp)
1065 vat_main_t *vam = &vat_main;
1066 i32 retval = ntohl (mp->retval);
1067 if (vam->async_mode)
1069 vam->async_errors += (retval < 0);
1073 vam->retval = retval;
1075 ((mp->new_table_index != 0xFFFFFFFF) ||
1076 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1077 (mp->match_n_vectors != 0xFFFFFFFF)))
1079 * Note: this is just barely thread-safe, depends on
1080 * the main thread spinning waiting for an answer...
1082 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1083 ntohl (mp->new_table_index),
1084 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1085 vam->result_ready = 1;
1089 static void vl_api_classify_add_del_table_reply_t_handler_json
1090 (vl_api_classify_add_del_table_reply_t * mp)
1092 vat_main_t *vam = &vat_main;
1093 vat_json_node_t node;
1095 vat_json_init_object (&node);
1096 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1097 vat_json_object_add_uint (&node, "new_table_index",
1098 ntohl (mp->new_table_index));
1099 vat_json_object_add_uint (&node, "skip_n_vectors",
1100 ntohl (mp->skip_n_vectors));
1101 vat_json_object_add_uint (&node, "match_n_vectors",
1102 ntohl (mp->match_n_vectors));
1104 vat_json_print (vam->ofp, &node);
1105 vat_json_free (&node);
1107 vam->retval = ntohl (mp->retval);
1108 vam->result_ready = 1;
1111 static void vl_api_get_node_index_reply_t_handler
1112 (vl_api_get_node_index_reply_t * mp)
1114 vat_main_t *vam = &vat_main;
1115 i32 retval = ntohl (mp->retval);
1116 if (vam->async_mode)
1118 vam->async_errors += (retval < 0);
1122 vam->retval = retval;
1124 errmsg ("node index %d", ntohl (mp->node_index));
1125 vam->result_ready = 1;
1129 static void vl_api_get_node_index_reply_t_handler_json
1130 (vl_api_get_node_index_reply_t * mp)
1132 vat_main_t *vam = &vat_main;
1133 vat_json_node_t node;
1135 vat_json_init_object (&node);
1136 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1137 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1139 vat_json_print (vam->ofp, &node);
1140 vat_json_free (&node);
1142 vam->retval = ntohl (mp->retval);
1143 vam->result_ready = 1;
1146 static void vl_api_get_next_index_reply_t_handler
1147 (vl_api_get_next_index_reply_t * mp)
1149 vat_main_t *vam = &vat_main;
1150 i32 retval = ntohl (mp->retval);
1151 if (vam->async_mode)
1153 vam->async_errors += (retval < 0);
1157 vam->retval = retval;
1159 errmsg ("next node index %d", ntohl (mp->next_index));
1160 vam->result_ready = 1;
1164 static void vl_api_get_next_index_reply_t_handler_json
1165 (vl_api_get_next_index_reply_t * mp)
1167 vat_main_t *vam = &vat_main;
1168 vat_json_node_t node;
1170 vat_json_init_object (&node);
1171 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1172 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1174 vat_json_print (vam->ofp, &node);
1175 vat_json_free (&node);
1177 vam->retval = ntohl (mp->retval);
1178 vam->result_ready = 1;
1181 static void vl_api_add_node_next_reply_t_handler
1182 (vl_api_add_node_next_reply_t * mp)
1184 vat_main_t *vam = &vat_main;
1185 i32 retval = ntohl (mp->retval);
1186 if (vam->async_mode)
1188 vam->async_errors += (retval < 0);
1192 vam->retval = retval;
1194 errmsg ("next index %d", ntohl (mp->next_index));
1195 vam->result_ready = 1;
1199 static void vl_api_add_node_next_reply_t_handler_json
1200 (vl_api_add_node_next_reply_t * mp)
1202 vat_main_t *vam = &vat_main;
1203 vat_json_node_t node;
1205 vat_json_init_object (&node);
1206 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1207 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1209 vat_json_print (vam->ofp, &node);
1210 vat_json_free (&node);
1212 vam->retval = ntohl (mp->retval);
1213 vam->result_ready = 1;
1216 static void vl_api_show_version_reply_t_handler
1217 (vl_api_show_version_reply_t * mp)
1219 vat_main_t *vam = &vat_main;
1220 i32 retval = ntohl (mp->retval);
1224 errmsg (" program: %s", mp->program);
1225 errmsg (" version: %s", mp->version);
1226 errmsg (" build date: %s", mp->build_date);
1227 errmsg ("build directory: %s", mp->build_directory);
1229 vam->retval = retval;
1230 vam->result_ready = 1;
1233 static void vl_api_show_version_reply_t_handler_json
1234 (vl_api_show_version_reply_t * mp)
1236 vat_main_t *vam = &vat_main;
1237 vat_json_node_t node;
1239 vat_json_init_object (&node);
1240 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1241 vat_json_object_add_string_copy (&node, "program", mp->program);
1242 vat_json_object_add_string_copy (&node, "version", mp->version);
1243 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1244 vat_json_object_add_string_copy (&node, "build_directory",
1245 mp->build_directory);
1247 vat_json_print (vam->ofp, &node);
1248 vat_json_free (&node);
1250 vam->retval = ntohl (mp->retval);
1251 vam->result_ready = 1;
1255 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1257 u32 sw_if_index = ntohl (mp->sw_if_index);
1258 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1259 mp->mac_ip ? "mac/ip binding" : "address resolution",
1260 ntohl (mp->pid), format_ip4_address, &mp->address,
1261 format_ethernet_address, mp->new_mac, sw_if_index);
1265 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1267 /* JSON output not supported */
1271 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1273 u32 sw_if_index = ntohl (mp->sw_if_index);
1274 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1275 mp->mac_ip ? "mac/ip binding" : "address resolution",
1276 ntohl (mp->pid), format_ip6_address, mp->address,
1277 format_ethernet_address, mp->new_mac, sw_if_index);
1281 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1283 /* JSON output not supported */
1286 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1287 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1290 * Special-case: build the bridge domain table, maintain
1291 * the next bd id vbl.
1293 static void vl_api_bridge_domain_details_t_handler
1294 (vl_api_bridge_domain_details_t * mp)
1296 vat_main_t *vam = &vat_main;
1297 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1300 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1301 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1303 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1304 ntohl (mp->bd_id), mp->learn, mp->forward,
1305 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1309 vl_api_bridge_domain_sw_if_t *sw_ifs;
1310 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1313 sw_ifs = mp->sw_if_details;
1314 for (i = 0; i < n_sw_ifs; i++)
1320 sw_if_index = ntohl (sw_ifs->sw_if_index);
1323 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1325 if ((u32) p->value[0] == sw_if_index)
1327 sw_if_name = (u8 *)(p->key);
1332 print (vam->ofp, "%7d %3d %s", sw_if_index,
1333 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1334 "sw_if_index not found!");
1341 static void vl_api_bridge_domain_details_t_handler_json
1342 (vl_api_bridge_domain_details_t * mp)
1344 vat_main_t *vam = &vat_main;
1345 vat_json_node_t *node, *array = NULL;
1346 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1348 if (VAT_JSON_ARRAY != vam->json_tree.type)
1350 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1351 vat_json_init_array (&vam->json_tree);
1353 node = vat_json_array_add (&vam->json_tree);
1355 vat_json_init_object (node);
1356 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1357 vat_json_object_add_uint (node, "flood", mp->flood);
1358 vat_json_object_add_uint (node, "forward", mp->forward);
1359 vat_json_object_add_uint (node, "learn", mp->learn);
1360 vat_json_object_add_uint (node, "bvi_sw_if_index",
1361 ntohl (mp->bvi_sw_if_index));
1362 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1363 array = vat_json_object_add (node, "sw_if");
1364 vat_json_init_array (array);
1370 vl_api_bridge_domain_sw_if_t *sw_ifs;
1373 sw_ifs = mp->sw_if_details;
1374 for (i = 0; i < n_sw_ifs; i++)
1376 node = vat_json_array_add (array);
1377 vat_json_init_object (node);
1378 vat_json_object_add_uint (node, "sw_if_index",
1379 ntohl (sw_ifs->sw_if_index));
1380 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1386 static void vl_api_control_ping_reply_t_handler
1387 (vl_api_control_ping_reply_t * mp)
1389 vat_main_t *vam = &vat_main;
1390 i32 retval = ntohl (mp->retval);
1391 if (vam->async_mode)
1393 vam->async_errors += (retval < 0);
1397 vam->retval = retval;
1398 vam->result_ready = 1;
1402 static void vl_api_control_ping_reply_t_handler_json
1403 (vl_api_control_ping_reply_t * mp)
1405 vat_main_t *vam = &vat_main;
1406 i32 retval = ntohl (mp->retval);
1408 if (VAT_JSON_NONE != vam->json_tree.type)
1410 vat_json_print (vam->ofp, &vam->json_tree);
1411 vat_json_free (&vam->json_tree);
1412 vam->json_tree.type = VAT_JSON_NONE;
1417 vat_json_init_array (&vam->json_tree);
1418 vat_json_print (vam->ofp, &vam->json_tree);
1419 vam->json_tree.type = VAT_JSON_NONE;
1422 vam->retval = retval;
1423 vam->result_ready = 1;
1427 vl_api_bridge_domain_set_mac_age_reply_t_handler
1428 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1430 vat_main_t *vam = &vat_main;
1431 i32 retval = ntohl (mp->retval);
1432 if (vam->async_mode)
1434 vam->async_errors += (retval < 0);
1438 vam->retval = retval;
1439 vam->result_ready = 1;
1443 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1444 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1446 vat_main_t *vam = &vat_main;
1447 vat_json_node_t node;
1449 vat_json_init_object (&node);
1450 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1452 vat_json_print (vam->ofp, &node);
1453 vat_json_free (&node);
1455 vam->retval = ntohl (mp->retval);
1456 vam->result_ready = 1;
1460 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1462 vat_main_t *vam = &vat_main;
1463 i32 retval = ntohl (mp->retval);
1464 if (vam->async_mode)
1466 vam->async_errors += (retval < 0);
1470 vam->retval = retval;
1471 vam->result_ready = 1;
1475 static void vl_api_l2_flags_reply_t_handler_json
1476 (vl_api_l2_flags_reply_t * mp)
1478 vat_main_t *vam = &vat_main;
1479 vat_json_node_t node;
1481 vat_json_init_object (&node);
1482 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1483 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1484 ntohl (mp->resulting_feature_bitmap));
1486 vat_json_print (vam->ofp, &node);
1487 vat_json_free (&node);
1489 vam->retval = ntohl (mp->retval);
1490 vam->result_ready = 1;
1493 static void vl_api_bridge_flags_reply_t_handler
1494 (vl_api_bridge_flags_reply_t * mp)
1496 vat_main_t *vam = &vat_main;
1497 i32 retval = ntohl (mp->retval);
1498 if (vam->async_mode)
1500 vam->async_errors += (retval < 0);
1504 vam->retval = retval;
1505 vam->result_ready = 1;
1509 static void vl_api_bridge_flags_reply_t_handler_json
1510 (vl_api_bridge_flags_reply_t * mp)
1512 vat_main_t *vam = &vat_main;
1513 vat_json_node_t node;
1515 vat_json_init_object (&node);
1516 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1517 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1518 ntohl (mp->resulting_feature_bitmap));
1520 vat_json_print (vam->ofp, &node);
1521 vat_json_free (&node);
1523 vam->retval = ntohl (mp->retval);
1524 vam->result_ready = 1;
1527 static void vl_api_tap_connect_reply_t_handler
1528 (vl_api_tap_connect_reply_t * mp)
1530 vat_main_t *vam = &vat_main;
1531 i32 retval = ntohl (mp->retval);
1532 if (vam->async_mode)
1534 vam->async_errors += (retval < 0);
1538 vam->retval = retval;
1539 vam->sw_if_index = ntohl (mp->sw_if_index);
1540 vam->result_ready = 1;
1545 static void vl_api_tap_connect_reply_t_handler_json
1546 (vl_api_tap_connect_reply_t * mp)
1548 vat_main_t *vam = &vat_main;
1549 vat_json_node_t node;
1551 vat_json_init_object (&node);
1552 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1553 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1555 vat_json_print (vam->ofp, &node);
1556 vat_json_free (&node);
1558 vam->retval = ntohl (mp->retval);
1559 vam->result_ready = 1;
1564 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1566 vat_main_t *vam = &vat_main;
1567 i32 retval = ntohl (mp->retval);
1568 if (vam->async_mode)
1570 vam->async_errors += (retval < 0);
1574 vam->retval = retval;
1575 vam->sw_if_index = ntohl (mp->sw_if_index);
1576 vam->result_ready = 1;
1580 static void vl_api_tap_modify_reply_t_handler_json
1581 (vl_api_tap_modify_reply_t * mp)
1583 vat_main_t *vam = &vat_main;
1584 vat_json_node_t node;
1586 vat_json_init_object (&node);
1587 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1588 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1590 vat_json_print (vam->ofp, &node);
1591 vat_json_free (&node);
1593 vam->retval = ntohl (mp->retval);
1594 vam->result_ready = 1;
1598 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1600 vat_main_t *vam = &vat_main;
1601 i32 retval = ntohl (mp->retval);
1602 if (vam->async_mode)
1604 vam->async_errors += (retval < 0);
1608 vam->retval = retval;
1609 vam->result_ready = 1;
1613 static void vl_api_tap_delete_reply_t_handler_json
1614 (vl_api_tap_delete_reply_t * mp)
1616 vat_main_t *vam = &vat_main;
1617 vat_json_node_t node;
1619 vat_json_init_object (&node);
1620 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1622 vat_json_print (vam->ofp, &node);
1623 vat_json_free (&node);
1625 vam->retval = ntohl (mp->retval);
1626 vam->result_ready = 1;
1629 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1630 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1632 vat_main_t *vam = &vat_main;
1633 i32 retval = ntohl (mp->retval);
1634 if (vam->async_mode)
1636 vam->async_errors += (retval < 0);
1640 vam->retval = retval;
1641 vam->result_ready = 1;
1645 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1646 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1648 vat_main_t *vam = &vat_main;
1649 vat_json_node_t node;
1651 vat_json_init_object (&node);
1652 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1653 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1654 ntohl (mp->sw_if_index));
1656 vat_json_print (vam->ofp, &node);
1657 vat_json_free (&node);
1659 vam->retval = ntohl (mp->retval);
1660 vam->result_ready = 1;
1663 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1664 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1666 vat_main_t *vam = &vat_main;
1667 i32 retval = ntohl (mp->retval);
1668 if (vam->async_mode)
1670 vam->async_errors += (retval < 0);
1674 vam->retval = retval;
1675 vam->sw_if_index = ntohl (mp->sw_if_index);
1676 vam->result_ready = 1;
1680 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1681 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1683 vat_main_t *vam = &vat_main;
1684 vat_json_node_t node;
1686 vat_json_init_object (&node);
1687 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1688 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1690 vat_json_print (vam->ofp, &node);
1691 vat_json_free (&node);
1693 vam->retval = ntohl (mp->retval);
1694 vam->result_ready = 1;
1697 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
1698 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1700 vat_main_t *vam = &vat_main;
1701 i32 retval = ntohl (mp->retval);
1702 if (vam->async_mode)
1704 vam->async_errors += (retval < 0);
1708 vam->retval = retval;
1709 vam->result_ready = 1;
1713 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
1714 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1716 vat_main_t *vam = &vat_main;
1717 vat_json_node_t node;
1719 vat_json_init_object (&node);
1720 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1721 vat_json_object_add_uint (&node, "fwd_entry_index",
1722 clib_net_to_host_u32 (mp->fwd_entry_index));
1724 vat_json_print (vam->ofp, &node);
1725 vat_json_free (&node);
1727 vam->retval = ntohl (mp->retval);
1728 vam->result_ready = 1;
1731 static void vl_api_one_add_del_locator_set_reply_t_handler
1732 (vl_api_one_add_del_locator_set_reply_t * mp)
1734 vat_main_t *vam = &vat_main;
1735 i32 retval = ntohl (mp->retval);
1736 if (vam->async_mode)
1738 vam->async_errors += (retval < 0);
1742 vam->retval = retval;
1743 vam->result_ready = 1;
1747 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1748 (vl_api_one_add_del_locator_set_reply_t * mp)
1750 vat_main_t *vam = &vat_main;
1751 vat_json_node_t node;
1753 vat_json_init_object (&node);
1754 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1755 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1757 vat_json_print (vam->ofp, &node);
1758 vat_json_free (&node);
1760 vam->retval = ntohl (mp->retval);
1761 vam->result_ready = 1;
1764 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1765 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1767 vat_main_t *vam = &vat_main;
1768 i32 retval = ntohl (mp->retval);
1769 if (vam->async_mode)
1771 vam->async_errors += (retval < 0);
1775 vam->retval = retval;
1776 vam->sw_if_index = ntohl (mp->sw_if_index);
1777 vam->result_ready = 1;
1781 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1782 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1784 vat_main_t *vam = &vat_main;
1785 vat_json_node_t node;
1787 vat_json_init_object (&node);
1788 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1789 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1791 vat_json_print (vam->ofp, &node);
1792 vat_json_free (&node);
1794 vam->retval = ntohl (mp->retval);
1795 vam->result_ready = 1;
1798 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
1799 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1801 vat_main_t *vam = &vat_main;
1802 i32 retval = ntohl (mp->retval);
1803 if (vam->async_mode)
1805 vam->async_errors += (retval < 0);
1809 vam->retval = retval;
1810 vam->sw_if_index = ntohl (mp->sw_if_index);
1811 vam->result_ready = 1;
1815 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
1816 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1818 vat_main_t *vam = &vat_main;
1819 vat_json_node_t node;
1821 vat_json_init_object (&node);
1822 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1823 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1825 vat_json_print (vam->ofp, &node);
1826 vat_json_free (&node);
1828 vam->retval = ntohl (mp->retval);
1829 vam->result_ready = 1;
1832 static void vl_api_gre_add_del_tunnel_reply_t_handler
1833 (vl_api_gre_add_del_tunnel_reply_t * mp)
1835 vat_main_t *vam = &vat_main;
1836 i32 retval = ntohl (mp->retval);
1837 if (vam->async_mode)
1839 vam->async_errors += (retval < 0);
1843 vam->retval = retval;
1844 vam->sw_if_index = ntohl (mp->sw_if_index);
1845 vam->result_ready = 1;
1849 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1850 (vl_api_gre_add_del_tunnel_reply_t * mp)
1852 vat_main_t *vam = &vat_main;
1853 vat_json_node_t node;
1855 vat_json_init_object (&node);
1856 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1857 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1859 vat_json_print (vam->ofp, &node);
1860 vat_json_free (&node);
1862 vam->retval = ntohl (mp->retval);
1863 vam->result_ready = 1;
1866 static void vl_api_create_vhost_user_if_reply_t_handler
1867 (vl_api_create_vhost_user_if_reply_t * mp)
1869 vat_main_t *vam = &vat_main;
1870 i32 retval = ntohl (mp->retval);
1871 if (vam->async_mode)
1873 vam->async_errors += (retval < 0);
1877 vam->retval = retval;
1878 vam->sw_if_index = ntohl (mp->sw_if_index);
1879 vam->result_ready = 1;
1883 static void vl_api_create_vhost_user_if_reply_t_handler_json
1884 (vl_api_create_vhost_user_if_reply_t * mp)
1886 vat_main_t *vam = &vat_main;
1887 vat_json_node_t node;
1889 vat_json_init_object (&node);
1890 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1891 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1893 vat_json_print (vam->ofp, &node);
1894 vat_json_free (&node);
1896 vam->retval = ntohl (mp->retval);
1897 vam->result_ready = 1;
1900 static void vl_api_ip_address_details_t_handler
1901 (vl_api_ip_address_details_t * mp)
1903 vat_main_t *vam = &vat_main;
1904 static ip_address_details_t empty_ip_address_details = { {0} };
1905 ip_address_details_t *address = NULL;
1906 ip_details_t *current_ip_details = NULL;
1907 ip_details_t *details = NULL;
1909 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1911 if (!details || vam->current_sw_if_index >= vec_len (details)
1912 || !details[vam->current_sw_if_index].present)
1914 errmsg ("ip address details arrived but not stored");
1915 errmsg ("ip_dump should be called first");
1919 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1921 #define addresses (current_ip_details->addr)
1923 vec_validate_init_empty (addresses, vec_len (addresses),
1924 empty_ip_address_details);
1926 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1928 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1929 address->prefix_length = mp->prefix_length;
1933 static void vl_api_ip_address_details_t_handler_json
1934 (vl_api_ip_address_details_t * mp)
1936 vat_main_t *vam = &vat_main;
1937 vat_json_node_t *node = NULL;
1938 struct in6_addr ip6;
1941 if (VAT_JSON_ARRAY != vam->json_tree.type)
1943 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1944 vat_json_init_array (&vam->json_tree);
1946 node = vat_json_array_add (&vam->json_tree);
1948 vat_json_init_object (node);
1951 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1952 vat_json_object_add_ip6 (node, "ip", ip6);
1956 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1957 vat_json_object_add_ip4 (node, "ip", ip4);
1959 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1963 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1965 vat_main_t *vam = &vat_main;
1966 static ip_details_t empty_ip_details = { 0 };
1967 ip_details_t *ip = NULL;
1968 u32 sw_if_index = ~0;
1970 sw_if_index = ntohl (mp->sw_if_index);
1972 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1973 sw_if_index, empty_ip_details);
1975 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1982 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1984 vat_main_t *vam = &vat_main;
1986 if (VAT_JSON_ARRAY != vam->json_tree.type)
1988 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1989 vat_json_init_array (&vam->json_tree);
1991 vat_json_array_add_uint (&vam->json_tree,
1992 clib_net_to_host_u32 (mp->sw_if_index));
1995 static void vl_api_map_domain_details_t_handler_json
1996 (vl_api_map_domain_details_t * mp)
1998 vat_json_node_t *node = NULL;
1999 vat_main_t *vam = &vat_main;
2000 struct in6_addr ip6;
2003 if (VAT_JSON_ARRAY != vam->json_tree.type)
2005 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2006 vat_json_init_array (&vam->json_tree);
2009 node = vat_json_array_add (&vam->json_tree);
2010 vat_json_init_object (node);
2012 vat_json_object_add_uint (node, "domain_index",
2013 clib_net_to_host_u32 (mp->domain_index));
2014 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2015 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2016 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2017 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2018 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2019 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2020 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2021 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2022 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2023 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2024 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2025 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2026 vat_json_object_add_uint (node, "flags", mp->flags);
2027 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2028 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2031 static void vl_api_map_domain_details_t_handler
2032 (vl_api_map_domain_details_t * mp)
2034 vat_main_t *vam = &vat_main;
2036 if (mp->is_translation)
2039 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2040 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2041 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2042 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2043 clib_net_to_host_u32 (mp->domain_index));
2048 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2049 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2050 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2051 format_ip6_address, mp->ip6_src,
2052 clib_net_to_host_u32 (mp->domain_index));
2054 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2055 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2056 mp->is_translation ? "map-t" : "");
2059 static void vl_api_map_rule_details_t_handler_json
2060 (vl_api_map_rule_details_t * mp)
2062 struct in6_addr ip6;
2063 vat_json_node_t *node = NULL;
2064 vat_main_t *vam = &vat_main;
2066 if (VAT_JSON_ARRAY != vam->json_tree.type)
2068 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2069 vat_json_init_array (&vam->json_tree);
2072 node = vat_json_array_add (&vam->json_tree);
2073 vat_json_init_object (node);
2075 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2076 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2077 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2081 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2083 vat_main_t *vam = &vat_main;
2084 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2085 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2089 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2091 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2092 "router_addr %U host_mac %U",
2093 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2094 format_ip4_address, &mp->host_address,
2095 format_ip4_address, &mp->router_address,
2096 format_ethernet_address, mp->host_mac);
2099 static void vl_api_dhcp_compl_event_t_handler_json
2100 (vl_api_dhcp_compl_event_t * mp)
2102 /* JSON output not supported */
2106 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2109 vat_main_t *vam = &vat_main;
2110 static u64 default_counter = 0;
2112 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2114 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2115 sw_if_index, default_counter);
2116 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2120 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2121 interface_counter_t counter)
2123 vat_main_t *vam = &vat_main;
2124 static interface_counter_t default_counter = { 0, };
2126 vec_validate_init_empty (vam->combined_interface_counters,
2127 vnet_counter_type, NULL);
2128 vec_validate_init_empty (vam->combined_interface_counters
2129 [vnet_counter_type], sw_if_index, default_counter);
2130 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2133 static void vl_api_vnet_interface_simple_counters_t_handler
2134 (vl_api_vnet_interface_simple_counters_t * mp)
2139 static void vl_api_vnet_interface_combined_counters_t_handler
2140 (vl_api_vnet_interface_combined_counters_t * mp)
2145 static void vl_api_vnet_interface_simple_counters_t_handler_json
2146 (vl_api_vnet_interface_simple_counters_t * mp)
2151 u32 first_sw_if_index;
2154 count = ntohl (mp->count);
2155 first_sw_if_index = ntohl (mp->first_sw_if_index);
2157 v_packets = (u64 *) & mp->data;
2158 for (i = 0; i < count; i++)
2160 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2161 set_simple_interface_counter (mp->vnet_counter_type,
2162 first_sw_if_index + i, packets);
2167 static void vl_api_vnet_interface_combined_counters_t_handler_json
2168 (vl_api_vnet_interface_combined_counters_t * mp)
2170 interface_counter_t counter;
2172 u32 first_sw_if_index;
2176 count = ntohl (mp->count);
2177 first_sw_if_index = ntohl (mp->first_sw_if_index);
2179 v = (vlib_counter_t *) & mp->data;
2180 for (i = 0; i < count; i++)
2183 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2185 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2186 set_combined_interface_counter (mp->vnet_counter_type,
2187 first_sw_if_index + i, counter);
2193 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2195 vat_main_t *vam = &vat_main;
2198 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2200 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2209 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2211 vat_main_t *vam = &vat_main;
2214 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2216 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2224 static void vl_api_vnet_ip4_fib_counters_t_handler
2225 (vl_api_vnet_ip4_fib_counters_t * mp)
2230 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2231 (vl_api_vnet_ip4_fib_counters_t * mp)
2233 vat_main_t *vam = &vat_main;
2234 vl_api_ip4_fib_counter_t *v;
2235 ip4_fib_counter_t *counter;
2242 vrf_id = ntohl (mp->vrf_id);
2243 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2244 if (~0 == vrf_index)
2246 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2247 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2248 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2249 vec_validate (vam->ip4_fib_counters, vrf_index);
2250 vam->ip4_fib_counters[vrf_index] = NULL;
2253 vec_free (vam->ip4_fib_counters[vrf_index]);
2254 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2255 count = ntohl (mp->count);
2256 for (i = 0; i < count; i++)
2258 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2259 counter = &vam->ip4_fib_counters[vrf_index][i];
2260 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2261 counter->address = ip4;
2262 counter->address_length = v->address_length;
2263 counter->packets = clib_net_to_host_u64 (v->packets);
2264 counter->bytes = clib_net_to_host_u64 (v->bytes);
2269 static void vl_api_vnet_ip4_nbr_counters_t_handler
2270 (vl_api_vnet_ip4_nbr_counters_t * mp)
2275 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2276 (vl_api_vnet_ip4_nbr_counters_t * mp)
2278 vat_main_t *vam = &vat_main;
2279 vl_api_ip4_nbr_counter_t *v;
2280 ip4_nbr_counter_t *counter;
2285 sw_if_index = ntohl (mp->sw_if_index);
2286 count = ntohl (mp->count);
2287 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2290 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2292 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2293 for (i = 0; i < count; i++)
2295 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2296 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2297 counter->address.s_addr = v->address;
2298 counter->packets = clib_net_to_host_u64 (v->packets);
2299 counter->bytes = clib_net_to_host_u64 (v->bytes);
2300 counter->linkt = v->link_type;
2305 static void vl_api_vnet_ip6_fib_counters_t_handler
2306 (vl_api_vnet_ip6_fib_counters_t * mp)
2311 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2312 (vl_api_vnet_ip6_fib_counters_t * mp)
2314 vat_main_t *vam = &vat_main;
2315 vl_api_ip6_fib_counter_t *v;
2316 ip6_fib_counter_t *counter;
2317 struct in6_addr ip6;
2323 vrf_id = ntohl (mp->vrf_id);
2324 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2325 if (~0 == vrf_index)
2327 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2328 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2329 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2330 vec_validate (vam->ip6_fib_counters, vrf_index);
2331 vam->ip6_fib_counters[vrf_index] = NULL;
2334 vec_free (vam->ip6_fib_counters[vrf_index]);
2335 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2336 count = ntohl (mp->count);
2337 for (i = 0; i < count; i++)
2339 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2340 counter = &vam->ip6_fib_counters[vrf_index][i];
2341 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2342 counter->address = ip6;
2343 counter->address_length = v->address_length;
2344 counter->packets = clib_net_to_host_u64 (v->packets);
2345 counter->bytes = clib_net_to_host_u64 (v->bytes);
2350 static void vl_api_vnet_ip6_nbr_counters_t_handler
2351 (vl_api_vnet_ip6_nbr_counters_t * mp)
2356 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2357 (vl_api_vnet_ip6_nbr_counters_t * mp)
2359 vat_main_t *vam = &vat_main;
2360 vl_api_ip6_nbr_counter_t *v;
2361 ip6_nbr_counter_t *counter;
2362 struct in6_addr ip6;
2367 sw_if_index = ntohl (mp->sw_if_index);
2368 count = ntohl (mp->count);
2369 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2372 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2374 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2375 for (i = 0; i < count; i++)
2377 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2378 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2379 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2380 counter->address = ip6;
2381 counter->packets = clib_net_to_host_u64 (v->packets);
2382 counter->bytes = clib_net_to_host_u64 (v->bytes);
2387 static void vl_api_get_first_msg_id_reply_t_handler
2388 (vl_api_get_first_msg_id_reply_t * mp)
2390 vat_main_t *vam = &vat_main;
2391 i32 retval = ntohl (mp->retval);
2393 if (vam->async_mode)
2395 vam->async_errors += (retval < 0);
2399 vam->retval = retval;
2400 vam->result_ready = 1;
2404 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2408 static void vl_api_get_first_msg_id_reply_t_handler_json
2409 (vl_api_get_first_msg_id_reply_t * mp)
2411 vat_main_t *vam = &vat_main;
2412 vat_json_node_t node;
2414 vat_json_init_object (&node);
2415 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2416 vat_json_object_add_uint (&node, "first_msg_id",
2417 (uint) ntohs (mp->first_msg_id));
2419 vat_json_print (vam->ofp, &node);
2420 vat_json_free (&node);
2422 vam->retval = ntohl (mp->retval);
2423 vam->result_ready = 1;
2426 static void vl_api_get_node_graph_reply_t_handler
2427 (vl_api_get_node_graph_reply_t * mp)
2429 vat_main_t *vam = &vat_main;
2430 api_main_t *am = &api_main;
2431 i32 retval = ntohl (mp->retval);
2432 u8 *pvt_copy, *reply;
2437 if (vam->async_mode)
2439 vam->async_errors += (retval < 0);
2443 vam->retval = retval;
2444 vam->result_ready = 1;
2447 /* "Should never happen..." */
2451 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2452 pvt_copy = vec_dup (reply);
2454 /* Toss the shared-memory original... */
2455 pthread_mutex_lock (&am->vlib_rp->mutex);
2456 oldheap = svm_push_data_heap (am->vlib_rp);
2460 svm_pop_heap (oldheap);
2461 pthread_mutex_unlock (&am->vlib_rp->mutex);
2463 if (vam->graph_nodes)
2465 hash_free (vam->graph_node_index_by_name);
2467 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2469 node = vam->graph_nodes[i];
2470 vec_free (node->name);
2471 vec_free (node->next_nodes);
2474 vec_free (vam->graph_nodes);
2477 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2478 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2479 vec_free (pvt_copy);
2481 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2483 node = vam->graph_nodes[i];
2484 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2488 static void vl_api_get_node_graph_reply_t_handler_json
2489 (vl_api_get_node_graph_reply_t * mp)
2491 vat_main_t *vam = &vat_main;
2492 api_main_t *am = &api_main;
2494 vat_json_node_t node;
2497 /* $$$$ make this real? */
2498 vat_json_init_object (&node);
2499 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2500 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2502 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2504 /* Toss the shared-memory original... */
2505 pthread_mutex_lock (&am->vlib_rp->mutex);
2506 oldheap = svm_push_data_heap (am->vlib_rp);
2510 svm_pop_heap (oldheap);
2511 pthread_mutex_unlock (&am->vlib_rp->mutex);
2513 vat_json_print (vam->ofp, &node);
2514 vat_json_free (&node);
2516 vam->retval = ntohl (mp->retval);
2517 vam->result_ready = 1;
2521 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2523 vat_main_t *vam = &vat_main;
2528 s = format (s, "%=16d%=16d%=16d",
2529 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2533 s = format (s, "%=16U%=16d%=16d",
2534 mp->is_ipv6 ? format_ip6_address :
2536 mp->ip_address, mp->priority, mp->weight);
2539 print (vam->ofp, "%v", s);
2544 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2546 vat_main_t *vam = &vat_main;
2547 vat_json_node_t *node = NULL;
2548 struct in6_addr ip6;
2551 if (VAT_JSON_ARRAY != vam->json_tree.type)
2553 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2554 vat_json_init_array (&vam->json_tree);
2556 node = vat_json_array_add (&vam->json_tree);
2557 vat_json_init_object (node);
2559 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2560 vat_json_object_add_uint (node, "priority", mp->priority);
2561 vat_json_object_add_uint (node, "weight", mp->weight);
2564 vat_json_object_add_uint (node, "sw_if_index",
2565 clib_net_to_host_u32 (mp->sw_if_index));
2570 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2571 vat_json_object_add_ip6 (node, "address", ip6);
2575 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2576 vat_json_object_add_ip4 (node, "address", ip4);
2582 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2585 vat_main_t *vam = &vat_main;
2588 ls_name = format (0, "%s", mp->ls_name);
2590 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2596 vl_api_one_locator_set_details_t_handler_json
2597 (vl_api_one_locator_set_details_t * mp)
2599 vat_main_t *vam = &vat_main;
2600 vat_json_node_t *node = 0;
2603 ls_name = format (0, "%s", mp->ls_name);
2604 vec_add1 (ls_name, 0);
2606 if (VAT_JSON_ARRAY != vam->json_tree.type)
2608 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2609 vat_json_init_array (&vam->json_tree);
2611 node = vat_json_array_add (&vam->json_tree);
2613 vat_json_init_object (node);
2614 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2615 vat_json_object_add_uint (node, "ls_index",
2616 clib_net_to_host_u32 (mp->ls_index));
2624 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2627 unformat_nsh_address (unformat_input_t * input, va_list * args)
2629 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2630 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2634 format_nsh_address_vat (u8 * s, va_list * args)
2636 nsh_t *a = va_arg (*args, nsh_t *);
2637 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2641 format_lisp_flat_eid (u8 * s, va_list * args)
2643 u32 type = va_arg (*args, u32);
2644 u8 *eid = va_arg (*args, u8 *);
2645 u32 eid_len = va_arg (*args, u32);
2650 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2652 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2654 return format (s, "%U", format_ethernet_address, eid);
2656 return format (s, "%U", format_nsh_address_vat, eid);
2662 format_lisp_eid_vat (u8 * s, va_list * args)
2664 u32 type = va_arg (*args, u32);
2665 u8 *eid = va_arg (*args, u8 *);
2666 u32 eid_len = va_arg (*args, u32);
2667 u8 *seid = va_arg (*args, u8 *);
2668 u32 seid_len = va_arg (*args, u32);
2669 u32 is_src_dst = va_arg (*args, u32);
2672 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2674 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2680 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2682 vat_main_t *vam = &vat_main;
2683 u8 *s = 0, *eid = 0;
2685 if (~0 == mp->locator_set_index)
2686 s = format (0, "action: %d", mp->action);
2688 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2690 eid = format (0, "%U", format_lisp_eid_vat,
2694 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2697 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2698 clib_net_to_host_u32 (mp->vni),
2700 mp->is_local ? "local" : "remote",
2701 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2702 clib_net_to_host_u16 (mp->key_id), mp->key);
2709 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2712 vat_main_t *vam = &vat_main;
2713 vat_json_node_t *node = 0;
2716 if (VAT_JSON_ARRAY != vam->json_tree.type)
2718 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2719 vat_json_init_array (&vam->json_tree);
2721 node = vat_json_array_add (&vam->json_tree);
2723 vat_json_init_object (node);
2724 if (~0 == mp->locator_set_index)
2725 vat_json_object_add_uint (node, "action", mp->action);
2727 vat_json_object_add_uint (node, "locator_set_index",
2728 clib_net_to_host_u32 (mp->locator_set_index));
2730 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2731 if (mp->eid_type == 3)
2733 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
2734 vat_json_init_object (nsh_json);
2735 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
2736 vat_json_object_add_uint (nsh_json, "spi",
2737 clib_net_to_host_u32 (nsh->spi));
2738 vat_json_object_add_uint (nsh_json, "si", nsh->si);
2742 eid = format (0, "%U", format_lisp_eid_vat,
2746 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2748 vat_json_object_add_string_copy (node, "eid", eid);
2751 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2752 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2753 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2757 vat_json_object_add_uint (node, "key_id",
2758 clib_net_to_host_u16 (mp->key_id));
2759 vat_json_object_add_string_copy (node, "key", mp->key);
2764 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
2766 vat_main_t *vam = &vat_main;
2767 u8 *seid = 0, *deid = 0;
2768 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2770 deid = format (0, "%U", format_lisp_eid_vat,
2771 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2773 seid = format (0, "%U", format_lisp_eid_vat,
2774 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2780 format_ip_address_fcn = format_ip4_address;
2782 format_ip_address_fcn = format_ip6_address;
2785 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
2786 clib_net_to_host_u32 (mp->vni),
2788 format_ip_address_fcn, mp->lloc,
2789 format_ip_address_fcn, mp->rloc,
2790 clib_net_to_host_u32 (mp->pkt_count),
2791 clib_net_to_host_u32 (mp->bytes));
2798 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
2800 struct in6_addr ip6;
2802 vat_main_t *vam = &vat_main;
2803 vat_json_node_t *node = 0;
2804 u8 *deid = 0, *seid = 0;
2806 if (VAT_JSON_ARRAY != vam->json_tree.type)
2808 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2809 vat_json_init_array (&vam->json_tree);
2811 node = vat_json_array_add (&vam->json_tree);
2813 vat_json_init_object (node);
2814 deid = format (0, "%U", format_lisp_eid_vat,
2815 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2817 seid = format (0, "%U", format_lisp_eid_vat,
2818 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2823 vat_json_object_add_string_copy (node, "seid", seid);
2824 vat_json_object_add_string_copy (node, "deid", deid);
2825 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2829 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
2830 vat_json_object_add_ip4 (node, "lloc", ip4);
2831 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
2832 vat_json_object_add_ip4 (node, "rloc", ip4);
2836 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
2837 vat_json_object_add_ip6 (node, "lloc", ip6);
2838 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
2839 vat_json_object_add_ip6 (node, "rloc", ip6);
2841 vat_json_object_add_uint (node, "pkt_count",
2842 clib_net_to_host_u32 (mp->pkt_count));
2843 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
2850 vl_api_one_eid_table_map_details_t_handler
2851 (vl_api_one_eid_table_map_details_t * mp)
2853 vat_main_t *vam = &vat_main;
2855 u8 *line = format (0, "%=10d%=10d",
2856 clib_net_to_host_u32 (mp->vni),
2857 clib_net_to_host_u32 (mp->dp_table));
2858 print (vam->ofp, "%v", line);
2863 vl_api_one_eid_table_map_details_t_handler_json
2864 (vl_api_one_eid_table_map_details_t * mp)
2866 vat_main_t *vam = &vat_main;
2867 vat_json_node_t *node = NULL;
2869 if (VAT_JSON_ARRAY != vam->json_tree.type)
2871 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2872 vat_json_init_array (&vam->json_tree);
2874 node = vat_json_array_add (&vam->json_tree);
2875 vat_json_init_object (node);
2876 vat_json_object_add_uint (node, "dp_table",
2877 clib_net_to_host_u32 (mp->dp_table));
2878 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2882 vl_api_one_eid_table_vni_details_t_handler
2883 (vl_api_one_eid_table_vni_details_t * mp)
2885 vat_main_t *vam = &vat_main;
2887 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2888 print (vam->ofp, "%v", line);
2893 vl_api_one_eid_table_vni_details_t_handler_json
2894 (vl_api_one_eid_table_vni_details_t * mp)
2896 vat_main_t *vam = &vat_main;
2897 vat_json_node_t *node = NULL;
2899 if (VAT_JSON_ARRAY != vam->json_tree.type)
2901 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2902 vat_json_init_array (&vam->json_tree);
2904 node = vat_json_array_add (&vam->json_tree);
2905 vat_json_init_object (node);
2906 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2910 vl_api_show_one_map_register_state_reply_t_handler
2911 (vl_api_show_one_map_register_state_reply_t * mp)
2913 vat_main_t *vam = &vat_main;
2914 int retval = clib_net_to_host_u32 (mp->retval);
2916 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2918 vam->retval = retval;
2919 vam->result_ready = 1;
2923 vl_api_show_one_map_register_state_reply_t_handler_json
2924 (vl_api_show_one_map_register_state_reply_t * mp)
2926 vat_main_t *vam = &vat_main;
2927 vat_json_node_t _node, *node = &_node;
2928 int retval = clib_net_to_host_u32 (mp->retval);
2930 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2932 vat_json_init_object (node);
2933 vat_json_object_add_string_copy (node, "state", s);
2935 vat_json_print (vam->ofp, node);
2936 vat_json_free (node);
2938 vam->retval = retval;
2939 vam->result_ready = 1;
2944 vl_api_show_one_rloc_probe_state_reply_t_handler
2945 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2947 vat_main_t *vam = &vat_main;
2948 int retval = clib_net_to_host_u32 (mp->retval);
2953 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2955 vam->retval = retval;
2956 vam->result_ready = 1;
2960 vl_api_show_one_rloc_probe_state_reply_t_handler_json
2961 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2963 vat_main_t *vam = &vat_main;
2964 vat_json_node_t _node, *node = &_node;
2965 int retval = clib_net_to_host_u32 (mp->retval);
2967 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2968 vat_json_init_object (node);
2969 vat_json_object_add_string_copy (node, "state", s);
2971 vat_json_print (vam->ofp, node);
2972 vat_json_free (node);
2974 vam->retval = retval;
2975 vam->result_ready = 1;
2980 vl_api_show_one_stats_enable_disable_reply_t_handler
2981 (vl_api_show_one_stats_enable_disable_reply_t * mp)
2983 vat_main_t *vam = &vat_main;
2984 int retval = clib_net_to_host_u32 (mp->retval);
2989 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
2991 vam->retval = retval;
2992 vam->result_ready = 1;
2996 vl_api_show_one_stats_enable_disable_reply_t_handler_json
2997 (vl_api_show_one_stats_enable_disable_reply_t * mp)
2999 vat_main_t *vam = &vat_main;
3000 vat_json_node_t _node, *node = &_node;
3001 int retval = clib_net_to_host_u32 (mp->retval);
3003 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3004 vat_json_init_object (node);
3005 vat_json_object_add_string_copy (node, "state", s);
3007 vat_json_print (vam->ofp, node);
3008 vat_json_free (node);
3010 vam->retval = retval;
3011 vam->result_ready = 1;
3016 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3018 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3019 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3020 e->vni = clib_net_to_host_u32 (e->vni);
3024 gpe_fwd_entries_get_reply_t_net_to_host
3025 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3029 mp->count = clib_net_to_host_u32 (mp->count);
3030 for (i = 0; i < mp->count; i++)
3032 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3037 format_gpe_encap_mode (u8 * s, va_list * args)
3039 u32 mode = va_arg (*args, u32);
3044 return format (s, "lisp");
3046 return format (s, "vxlan");
3052 vl_api_gpe_get_encap_mode_reply_t_handler
3053 (vl_api_gpe_get_encap_mode_reply_t * mp)
3055 vat_main_t *vam = &vat_main;
3057 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3058 vam->retval = ntohl (mp->retval);
3059 vam->result_ready = 1;
3063 vl_api_gpe_get_encap_mode_reply_t_handler_json
3064 (vl_api_gpe_get_encap_mode_reply_t * mp)
3066 vat_main_t *vam = &vat_main;
3067 vat_json_node_t node;
3069 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3070 vec_add1 (encap_mode, 0);
3072 vat_json_init_object (&node);
3073 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3075 vec_free (encap_mode);
3076 vat_json_print (vam->ofp, &node);
3077 vat_json_free (&node);
3079 vam->retval = ntohl (mp->retval);
3080 vam->result_ready = 1;
3084 vl_api_gpe_fwd_entry_path_details_t_handler
3085 (vl_api_gpe_fwd_entry_path_details_t * mp)
3087 vat_main_t *vam = &vat_main;
3088 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3090 if (mp->lcl_loc.is_ip4)
3091 format_ip_address_fcn = format_ip4_address;
3093 format_ip_address_fcn = format_ip6_address;
3095 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3096 format_ip_address_fcn, &mp->lcl_loc,
3097 format_ip_address_fcn, &mp->rmt_loc);
3101 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3103 struct in6_addr ip6;
3108 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3109 vat_json_object_add_ip4 (n, "address", ip4);
3113 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3114 vat_json_object_add_ip6 (n, "address", ip6);
3116 vat_json_object_add_uint (n, "weight", loc->weight);
3120 vl_api_gpe_fwd_entry_path_details_t_handler_json
3121 (vl_api_gpe_fwd_entry_path_details_t * mp)
3123 vat_main_t *vam = &vat_main;
3124 vat_json_node_t *node = NULL;
3125 vat_json_node_t *loc_node;
3127 if (VAT_JSON_ARRAY != vam->json_tree.type)
3129 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3130 vat_json_init_array (&vam->json_tree);
3132 node = vat_json_array_add (&vam->json_tree);
3133 vat_json_init_object (node);
3135 loc_node = vat_json_object_add (node, "local_locator");
3136 vat_json_init_object (loc_node);
3137 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3139 loc_node = vat_json_object_add (node, "remote_locator");
3140 vat_json_init_object (loc_node);
3141 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3145 vl_api_gpe_fwd_entries_get_reply_t_handler
3146 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3148 vat_main_t *vam = &vat_main;
3150 int retval = clib_net_to_host_u32 (mp->retval);
3151 vl_api_gpe_fwd_entry_t *e;
3156 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3158 for (i = 0; i < mp->count; i++)
3160 e = &mp->entries[i];
3161 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3162 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3163 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3167 vam->retval = retval;
3168 vam->result_ready = 1;
3172 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3173 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3176 vat_main_t *vam = &vat_main;
3177 vat_json_node_t *e = 0, root;
3179 int retval = clib_net_to_host_u32 (mp->retval);
3180 vl_api_gpe_fwd_entry_t *fwd;
3185 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3186 vat_json_init_array (&root);
3188 for (i = 0; i < mp->count; i++)
3190 e = vat_json_array_add (&root);
3191 fwd = &mp->entries[i];
3193 vat_json_init_object (e);
3194 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3195 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3196 vat_json_object_add_int (e, "vni", fwd->vni);
3197 vat_json_object_add_int (e, "action", fwd->action);
3199 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3200 fwd->leid_prefix_len);
3202 vat_json_object_add_string_copy (e, "leid", s);
3205 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3206 fwd->reid_prefix_len);
3208 vat_json_object_add_string_copy (e, "reid", s);
3212 vat_json_print (vam->ofp, &root);
3213 vat_json_free (&root);
3216 vam->retval = retval;
3217 vam->result_ready = 1;
3221 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3222 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3224 vat_main_t *vam = &vat_main;
3226 int retval = clib_net_to_host_u32 (mp->retval);
3227 vl_api_gpe_native_fwd_rpath_t *r;
3232 n = clib_net_to_host_u32 (mp->count);
3234 for (i = 0; i < n; i++)
3236 r = &mp->entries[i];
3237 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3238 clib_net_to_host_u32 (r->fib_index),
3239 clib_net_to_host_u32 (r->nh_sw_if_index),
3240 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3244 vam->retval = retval;
3245 vam->result_ready = 1;
3249 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3250 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3252 vat_main_t *vam = &vat_main;
3253 vat_json_node_t root, *e;
3255 int retval = clib_net_to_host_u32 (mp->retval);
3256 vl_api_gpe_native_fwd_rpath_t *r;
3262 n = clib_net_to_host_u32 (mp->count);
3263 vat_json_init_array (&root);
3265 for (i = 0; i < n; i++)
3267 e = vat_json_array_add (&root);
3268 vat_json_init_object (e);
3269 r = &mp->entries[i];
3271 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3274 vat_json_object_add_string_copy (e, "ip4", s);
3277 vat_json_object_add_uint (e, "fib_index",
3278 clib_net_to_host_u32 (r->fib_index));
3279 vat_json_object_add_uint (e, "nh_sw_if_index",
3280 clib_net_to_host_u32 (r->nh_sw_if_index));
3283 vat_json_print (vam->ofp, &root);
3284 vat_json_free (&root);
3287 vam->retval = retval;
3288 vam->result_ready = 1;
3292 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3293 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3295 vat_main_t *vam = &vat_main;
3297 int retval = clib_net_to_host_u32 (mp->retval);
3302 n = clib_net_to_host_u32 (mp->count);
3304 for (i = 0; i < n; i++)
3305 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3308 vam->retval = retval;
3309 vam->result_ready = 1;
3313 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3314 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3316 vat_main_t *vam = &vat_main;
3317 vat_json_node_t root;
3319 int retval = clib_net_to_host_u32 (mp->retval);
3324 n = clib_net_to_host_u32 (mp->count);
3325 vat_json_init_array (&root);
3327 for (i = 0; i < n; i++)
3328 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3330 vat_json_print (vam->ofp, &root);
3331 vat_json_free (&root);
3334 vam->retval = retval;
3335 vam->result_ready = 1;
3339 vl_api_one_l2_arp_entries_get_reply_t_handler
3340 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3342 vat_main_t *vam = &vat_main;
3344 int retval = clib_net_to_host_u32 (mp->retval);
3349 n = clib_net_to_host_u32 (mp->count);
3351 for (i = 0; i < n; i++)
3352 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3353 format_ethernet_address, mp->entries[i].mac);
3356 vam->retval = retval;
3357 vam->result_ready = 1;
3361 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3362 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3365 vat_main_t *vam = &vat_main;
3366 vat_json_node_t *e = 0, root;
3368 int retval = clib_net_to_host_u32 (mp->retval);
3369 vl_api_one_l2_arp_entry_t *arp_entry;
3374 n = clib_net_to_host_u32 (mp->count);
3375 vat_json_init_array (&root);
3377 for (i = 0; i < n; i++)
3379 e = vat_json_array_add (&root);
3380 arp_entry = &mp->entries[i];
3382 vat_json_init_object (e);
3383 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3386 vat_json_object_add_string_copy (e, "mac", s);
3389 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3391 vat_json_object_add_string_copy (e, "ip4", s);
3395 vat_json_print (vam->ofp, &root);
3396 vat_json_free (&root);
3399 vam->retval = retval;
3400 vam->result_ready = 1;
3404 vl_api_one_l2_arp_bd_get_reply_t_handler
3405 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3407 vat_main_t *vam = &vat_main;
3409 int retval = clib_net_to_host_u32 (mp->retval);
3414 n = clib_net_to_host_u32 (mp->count);
3416 for (i = 0; i < n; i++)
3418 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3422 vam->retval = retval;
3423 vam->result_ready = 1;
3427 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3428 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3430 vat_main_t *vam = &vat_main;
3431 vat_json_node_t root;
3433 int retval = clib_net_to_host_u32 (mp->retval);
3438 n = clib_net_to_host_u32 (mp->count);
3439 vat_json_init_array (&root);
3441 for (i = 0; i < n; i++)
3443 vat_json_array_add_uint (&root,
3444 clib_net_to_host_u32 (mp->bridge_domains[i]));
3447 vat_json_print (vam->ofp, &root);
3448 vat_json_free (&root);
3451 vam->retval = retval;
3452 vam->result_ready = 1;
3456 vl_api_one_adjacencies_get_reply_t_handler
3457 (vl_api_one_adjacencies_get_reply_t * mp)
3459 vat_main_t *vam = &vat_main;
3461 int retval = clib_net_to_host_u32 (mp->retval);
3462 vl_api_one_adjacency_t *a;
3467 n = clib_net_to_host_u32 (mp->count);
3469 for (i = 0; i < n; i++)
3471 a = &mp->adjacencies[i];
3472 print (vam->ofp, "%U %40U",
3473 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3474 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3478 vam->retval = retval;
3479 vam->result_ready = 1;
3483 vl_api_one_adjacencies_get_reply_t_handler_json
3484 (vl_api_one_adjacencies_get_reply_t * mp)
3487 vat_main_t *vam = &vat_main;
3488 vat_json_node_t *e = 0, root;
3490 int retval = clib_net_to_host_u32 (mp->retval);
3491 vl_api_one_adjacency_t *a;
3496 n = clib_net_to_host_u32 (mp->count);
3497 vat_json_init_array (&root);
3499 for (i = 0; i < n; i++)
3501 e = vat_json_array_add (&root);
3502 a = &mp->adjacencies[i];
3504 vat_json_init_object (e);
3505 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3506 a->leid_prefix_len);
3508 vat_json_object_add_string_copy (e, "leid", s);
3511 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3512 a->reid_prefix_len);
3514 vat_json_object_add_string_copy (e, "reid", s);
3518 vat_json_print (vam->ofp, &root);
3519 vat_json_free (&root);
3522 vam->retval = retval;
3523 vam->result_ready = 1;
3527 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3529 vat_main_t *vam = &vat_main;
3531 print (vam->ofp, "%=20U",
3532 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3537 vl_api_one_map_server_details_t_handler_json
3538 (vl_api_one_map_server_details_t * mp)
3540 vat_main_t *vam = &vat_main;
3541 vat_json_node_t *node = NULL;
3542 struct in6_addr ip6;
3545 if (VAT_JSON_ARRAY != vam->json_tree.type)
3547 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3548 vat_json_init_array (&vam->json_tree);
3550 node = vat_json_array_add (&vam->json_tree);
3552 vat_json_init_object (node);
3555 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3556 vat_json_object_add_ip6 (node, "map-server", ip6);
3560 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3561 vat_json_object_add_ip4 (node, "map-server", ip4);
3566 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3569 vat_main_t *vam = &vat_main;
3571 print (vam->ofp, "%=20U",
3572 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3577 vl_api_one_map_resolver_details_t_handler_json
3578 (vl_api_one_map_resolver_details_t * mp)
3580 vat_main_t *vam = &vat_main;
3581 vat_json_node_t *node = NULL;
3582 struct in6_addr ip6;
3585 if (VAT_JSON_ARRAY != vam->json_tree.type)
3587 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3588 vat_json_init_array (&vam->json_tree);
3590 node = vat_json_array_add (&vam->json_tree);
3592 vat_json_init_object (node);
3595 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3596 vat_json_object_add_ip6 (node, "map resolver", ip6);
3600 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3601 vat_json_object_add_ip4 (node, "map resolver", ip4);
3606 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3608 vat_main_t *vam = &vat_main;
3609 i32 retval = ntohl (mp->retval);
3613 print (vam->ofp, "feature: %s\ngpe: %s",
3614 mp->feature_status ? "enabled" : "disabled",
3615 mp->gpe_status ? "enabled" : "disabled");
3618 vam->retval = retval;
3619 vam->result_ready = 1;
3623 vl_api_show_one_status_reply_t_handler_json
3624 (vl_api_show_one_status_reply_t * mp)
3626 vat_main_t *vam = &vat_main;
3627 vat_json_node_t node;
3628 u8 *gpe_status = NULL;
3629 u8 *feature_status = NULL;
3631 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3632 feature_status = format (0, "%s",
3633 mp->feature_status ? "enabled" : "disabled");
3634 vec_add1 (gpe_status, 0);
3635 vec_add1 (feature_status, 0);
3637 vat_json_init_object (&node);
3638 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3639 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3641 vec_free (gpe_status);
3642 vec_free (feature_status);
3644 vat_json_print (vam->ofp, &node);
3645 vat_json_free (&node);
3647 vam->retval = ntohl (mp->retval);
3648 vam->result_ready = 1;
3652 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3653 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3655 vat_main_t *vam = &vat_main;
3656 i32 retval = ntohl (mp->retval);
3660 print (vam->ofp, "%=20s", mp->locator_set_name);
3663 vam->retval = retval;
3664 vam->result_ready = 1;
3668 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3669 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3671 vat_main_t *vam = &vat_main;
3672 vat_json_node_t *node = NULL;
3674 if (VAT_JSON_ARRAY != vam->json_tree.type)
3676 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3677 vat_json_init_array (&vam->json_tree);
3679 node = vat_json_array_add (&vam->json_tree);
3681 vat_json_init_object (node);
3682 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3684 vat_json_print (vam->ofp, node);
3685 vat_json_free (node);
3687 vam->retval = ntohl (mp->retval);
3688 vam->result_ready = 1;
3692 format_lisp_map_request_mode (u8 * s, va_list * args)
3694 u32 mode = va_arg (*args, u32);
3699 return format (0, "dst-only");
3701 return format (0, "src-dst");
3707 vl_api_show_one_map_request_mode_reply_t_handler
3708 (vl_api_show_one_map_request_mode_reply_t * mp)
3710 vat_main_t *vam = &vat_main;
3711 i32 retval = ntohl (mp->retval);
3715 u32 mode = mp->mode;
3716 print (vam->ofp, "map_request_mode: %U",
3717 format_lisp_map_request_mode, mode);
3720 vam->retval = retval;
3721 vam->result_ready = 1;
3725 vl_api_show_one_map_request_mode_reply_t_handler_json
3726 (vl_api_show_one_map_request_mode_reply_t * mp)
3728 vat_main_t *vam = &vat_main;
3729 vat_json_node_t node;
3734 s = format (0, "%U", format_lisp_map_request_mode, mode);
3737 vat_json_init_object (&node);
3738 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3739 vat_json_print (vam->ofp, &node);
3740 vat_json_free (&node);
3743 vam->retval = ntohl (mp->retval);
3744 vam->result_ready = 1;
3748 vl_api_show_one_use_petr_reply_t_handler
3749 (vl_api_show_one_use_petr_reply_t * mp)
3751 vat_main_t *vam = &vat_main;
3752 i32 retval = ntohl (mp->retval);
3756 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
3759 print (vam->ofp, "Proxy-ETR address; %U",
3760 mp->is_ip4 ? format_ip4_address : format_ip6_address,
3765 vam->retval = retval;
3766 vam->result_ready = 1;
3770 vl_api_show_one_use_petr_reply_t_handler_json
3771 (vl_api_show_one_use_petr_reply_t * mp)
3773 vat_main_t *vam = &vat_main;
3774 vat_json_node_t node;
3777 struct in6_addr ip6;
3779 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3780 vec_add1 (status, 0);
3782 vat_json_init_object (&node);
3783 vat_json_object_add_string_copy (&node, "status", status);
3788 clib_memcpy (&ip6, mp->address, sizeof (ip6));
3789 vat_json_object_add_ip6 (&node, "address", ip6);
3793 clib_memcpy (&ip4, mp->address, sizeof (ip4));
3794 vat_json_object_add_ip4 (&node, "address", ip4);
3800 vat_json_print (vam->ofp, &node);
3801 vat_json_free (&node);
3803 vam->retval = ntohl (mp->retval);
3804 vam->result_ready = 1;
3808 vl_api_show_one_nsh_mapping_reply_t_handler
3809 (vl_api_show_one_nsh_mapping_reply_t * mp)
3811 vat_main_t *vam = &vat_main;
3812 i32 retval = ntohl (mp->retval);
3816 print (vam->ofp, "%-20s%-16s",
3817 mp->is_set ? "set" : "not-set",
3818 mp->is_set ? (char *) mp->locator_set_name : "");
3821 vam->retval = retval;
3822 vam->result_ready = 1;
3826 vl_api_show_one_nsh_mapping_reply_t_handler_json
3827 (vl_api_show_one_nsh_mapping_reply_t * mp)
3829 vat_main_t *vam = &vat_main;
3830 vat_json_node_t node;
3833 status = format (0, "%s", mp->is_set ? "yes" : "no");
3834 vec_add1 (status, 0);
3836 vat_json_init_object (&node);
3837 vat_json_object_add_string_copy (&node, "is_set", status);
3840 vat_json_object_add_string_copy (&node, "locator_set",
3841 mp->locator_set_name);
3846 vat_json_print (vam->ofp, &node);
3847 vat_json_free (&node);
3849 vam->retval = ntohl (mp->retval);
3850 vam->result_ready = 1;
3854 vl_api_show_one_map_register_ttl_reply_t_handler
3855 (vl_api_show_one_map_register_ttl_reply_t * mp)
3857 vat_main_t *vam = &vat_main;
3858 i32 retval = ntohl (mp->retval);
3860 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
3864 print (vam->ofp, "ttl: %u", mp->ttl);
3867 vam->retval = retval;
3868 vam->result_ready = 1;
3872 vl_api_show_one_map_register_ttl_reply_t_handler_json
3873 (vl_api_show_one_map_register_ttl_reply_t * mp)
3875 vat_main_t *vam = &vat_main;
3876 vat_json_node_t node;
3878 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
3879 vat_json_init_object (&node);
3880 vat_json_object_add_uint (&node, "ttl", mp->ttl);
3882 vat_json_print (vam->ofp, &node);
3883 vat_json_free (&node);
3885 vam->retval = ntohl (mp->retval);
3886 vam->result_ready = 1;
3890 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3892 vat_main_t *vam = &vat_main;
3893 i32 retval = ntohl (mp->retval);
3897 print (vam->ofp, "%-20s%-16s",
3898 mp->status ? "enabled" : "disabled",
3899 mp->status ? (char *) mp->locator_set_name : "");
3902 vam->retval = retval;
3903 vam->result_ready = 1;
3907 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3909 vat_main_t *vam = &vat_main;
3910 vat_json_node_t node;
3913 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3914 vec_add1 (status, 0);
3916 vat_json_init_object (&node);
3917 vat_json_object_add_string_copy (&node, "status", status);
3920 vat_json_object_add_string_copy (&node, "locator_set",
3921 mp->locator_set_name);
3926 vat_json_print (vam->ofp, &node);
3927 vat_json_free (&node);
3929 vam->retval = ntohl (mp->retval);
3930 vam->result_ready = 1;
3934 format_policer_type (u8 * s, va_list * va)
3936 u32 i = va_arg (*va, u32);
3938 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3939 s = format (s, "1r2c");
3940 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3941 s = format (s, "1r3c");
3942 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3943 s = format (s, "2r3c-2698");
3944 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3945 s = format (s, "2r3c-4115");
3946 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3947 s = format (s, "2r3c-mef5cf1");
3949 s = format (s, "ILLEGAL");
3954 format_policer_rate_type (u8 * s, va_list * va)
3956 u32 i = va_arg (*va, u32);
3958 if (i == SSE2_QOS_RATE_KBPS)
3959 s = format (s, "kbps");
3960 else if (i == SSE2_QOS_RATE_PPS)
3961 s = format (s, "pps");
3963 s = format (s, "ILLEGAL");
3968 format_policer_round_type (u8 * s, va_list * va)
3970 u32 i = va_arg (*va, u32);
3972 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3973 s = format (s, "closest");
3974 else if (i == SSE2_QOS_ROUND_TO_UP)
3975 s = format (s, "up");
3976 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3977 s = format (s, "down");
3979 s = format (s, "ILLEGAL");
3984 format_policer_action_type (u8 * s, va_list * va)
3986 u32 i = va_arg (*va, u32);
3988 if (i == SSE2_QOS_ACTION_DROP)
3989 s = format (s, "drop");
3990 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3991 s = format (s, "transmit");
3992 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3993 s = format (s, "mark-and-transmit");
3995 s = format (s, "ILLEGAL");
4000 format_dscp (u8 * s, va_list * va)
4002 u32 i = va_arg (*va, u32);
4007 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4011 return format (s, "ILLEGAL");
4013 s = format (s, "%s", t);
4018 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4020 vat_main_t *vam = &vat_main;
4021 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4023 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4024 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4026 conform_dscp_str = format (0, "");
4028 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4029 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4031 exceed_dscp_str = format (0, "");
4033 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4034 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4036 violate_dscp_str = format (0, "");
4038 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4039 "rate type %U, round type %U, %s rate, %s color-aware, "
4040 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4041 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4042 "conform action %U%s, exceed action %U%s, violate action %U%s",
4044 format_policer_type, mp->type,
4047 clib_net_to_host_u64 (mp->cb),
4048 clib_net_to_host_u64 (mp->eb),
4049 format_policer_rate_type, mp->rate_type,
4050 format_policer_round_type, mp->round_type,
4051 mp->single_rate ? "single" : "dual",
4052 mp->color_aware ? "is" : "not",
4053 ntohl (mp->cir_tokens_per_period),
4054 ntohl (mp->pir_tokens_per_period),
4056 ntohl (mp->current_limit),
4057 ntohl (mp->current_bucket),
4058 ntohl (mp->extended_limit),
4059 ntohl (mp->extended_bucket),
4060 clib_net_to_host_u64 (mp->last_update_time),
4061 format_policer_action_type, mp->conform_action_type,
4063 format_policer_action_type, mp->exceed_action_type,
4065 format_policer_action_type, mp->violate_action_type,
4068 vec_free (conform_dscp_str);
4069 vec_free (exceed_dscp_str);
4070 vec_free (violate_dscp_str);
4073 static void vl_api_policer_details_t_handler_json
4074 (vl_api_policer_details_t * mp)
4076 vat_main_t *vam = &vat_main;
4077 vat_json_node_t *node;
4078 u8 *rate_type_str, *round_type_str, *type_str;
4079 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4081 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4083 format (0, "%U", format_policer_round_type, mp->round_type);
4084 type_str = format (0, "%U", format_policer_type, mp->type);
4085 conform_action_str = format (0, "%U", format_policer_action_type,
4086 mp->conform_action_type);
4087 exceed_action_str = format (0, "%U", format_policer_action_type,
4088 mp->exceed_action_type);
4089 violate_action_str = format (0, "%U", format_policer_action_type,
4090 mp->violate_action_type);
4092 if (VAT_JSON_ARRAY != vam->json_tree.type)
4094 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4095 vat_json_init_array (&vam->json_tree);
4097 node = vat_json_array_add (&vam->json_tree);
4099 vat_json_init_object (node);
4100 vat_json_object_add_string_copy (node, "name", mp->name);
4101 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4102 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4103 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4104 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4105 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4106 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4107 vat_json_object_add_string_copy (node, "type", type_str);
4108 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4109 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4110 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4111 vat_json_object_add_uint (node, "cir_tokens_per_period",
4112 ntohl (mp->cir_tokens_per_period));
4113 vat_json_object_add_uint (node, "eir_tokens_per_period",
4114 ntohl (mp->pir_tokens_per_period));
4115 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4116 vat_json_object_add_uint (node, "current_bucket",
4117 ntohl (mp->current_bucket));
4118 vat_json_object_add_uint (node, "extended_limit",
4119 ntohl (mp->extended_limit));
4120 vat_json_object_add_uint (node, "extended_bucket",
4121 ntohl (mp->extended_bucket));
4122 vat_json_object_add_uint (node, "last_update_time",
4123 ntohl (mp->last_update_time));
4124 vat_json_object_add_string_copy (node, "conform_action",
4125 conform_action_str);
4126 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4128 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4129 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4130 vec_free (dscp_str);
4132 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4133 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4135 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4136 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4137 vec_free (dscp_str);
4139 vat_json_object_add_string_copy (node, "violate_action",
4140 violate_action_str);
4141 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4143 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4144 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4145 vec_free (dscp_str);
4148 vec_free (rate_type_str);
4149 vec_free (round_type_str);
4150 vec_free (type_str);
4151 vec_free (conform_action_str);
4152 vec_free (exceed_action_str);
4153 vec_free (violate_action_str);
4157 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4160 vat_main_t *vam = &vat_main;
4161 int i, count = ntohl (mp->count);
4164 print (vam->ofp, "classify table ids (%d) : ", count);
4165 for (i = 0; i < count; i++)
4167 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4168 print (vam->ofp, (i < count - 1) ? "," : "");
4170 vam->retval = ntohl (mp->retval);
4171 vam->result_ready = 1;
4175 vl_api_classify_table_ids_reply_t_handler_json
4176 (vl_api_classify_table_ids_reply_t * mp)
4178 vat_main_t *vam = &vat_main;
4179 int i, count = ntohl (mp->count);
4183 vat_json_node_t node;
4185 vat_json_init_object (&node);
4186 for (i = 0; i < count; i++)
4188 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4190 vat_json_print (vam->ofp, &node);
4191 vat_json_free (&node);
4193 vam->retval = ntohl (mp->retval);
4194 vam->result_ready = 1;
4198 vl_api_classify_table_by_interface_reply_t_handler
4199 (vl_api_classify_table_by_interface_reply_t * mp)
4201 vat_main_t *vam = &vat_main;
4204 table_id = ntohl (mp->l2_table_id);
4206 print (vam->ofp, "l2 table id : %d", table_id);
4208 print (vam->ofp, "l2 table id : No input ACL tables configured");
4209 table_id = ntohl (mp->ip4_table_id);
4211 print (vam->ofp, "ip4 table id : %d", table_id);
4213 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4214 table_id = ntohl (mp->ip6_table_id);
4216 print (vam->ofp, "ip6 table id : %d", table_id);
4218 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4219 vam->retval = ntohl (mp->retval);
4220 vam->result_ready = 1;
4224 vl_api_classify_table_by_interface_reply_t_handler_json
4225 (vl_api_classify_table_by_interface_reply_t * mp)
4227 vat_main_t *vam = &vat_main;
4228 vat_json_node_t node;
4230 vat_json_init_object (&node);
4232 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4233 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4234 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4236 vat_json_print (vam->ofp, &node);
4237 vat_json_free (&node);
4239 vam->retval = ntohl (mp->retval);
4240 vam->result_ready = 1;
4243 static void vl_api_policer_add_del_reply_t_handler
4244 (vl_api_policer_add_del_reply_t * mp)
4246 vat_main_t *vam = &vat_main;
4247 i32 retval = ntohl (mp->retval);
4248 if (vam->async_mode)
4250 vam->async_errors += (retval < 0);
4254 vam->retval = retval;
4255 vam->result_ready = 1;
4256 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4258 * Note: this is just barely thread-safe, depends on
4259 * the main thread spinning waiting for an answer...
4261 errmsg ("policer index %d", ntohl (mp->policer_index));
4265 static void vl_api_policer_add_del_reply_t_handler_json
4266 (vl_api_policer_add_del_reply_t * mp)
4268 vat_main_t *vam = &vat_main;
4269 vat_json_node_t node;
4271 vat_json_init_object (&node);
4272 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4273 vat_json_object_add_uint (&node, "policer_index",
4274 ntohl (mp->policer_index));
4276 vat_json_print (vam->ofp, &node);
4277 vat_json_free (&node);
4279 vam->retval = ntohl (mp->retval);
4280 vam->result_ready = 1;
4283 /* Format hex dump. */
4285 format_hex_bytes (u8 * s, va_list * va)
4287 u8 *bytes = va_arg (*va, u8 *);
4288 int n_bytes = va_arg (*va, int);
4291 /* Print short or long form depending on byte count. */
4292 uword short_form = n_bytes <= 32;
4293 uword indent = format_get_indent (s);
4298 for (i = 0; i < n_bytes; i++)
4300 if (!short_form && (i % 32) == 0)
4301 s = format (s, "%08x: ", i);
4302 s = format (s, "%02x", bytes[i]);
4303 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4304 s = format (s, "\n%U", format_white_space, indent);
4311 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4314 vat_main_t *vam = &vat_main;
4315 i32 retval = ntohl (mp->retval);
4318 print (vam->ofp, "classify table info :");
4319 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4320 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4321 ntohl (mp->miss_next_index));
4322 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4323 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4324 ntohl (mp->match_n_vectors));
4325 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4326 ntohl (mp->mask_length));
4328 vam->retval = retval;
4329 vam->result_ready = 1;
4333 vl_api_classify_table_info_reply_t_handler_json
4334 (vl_api_classify_table_info_reply_t * mp)
4336 vat_main_t *vam = &vat_main;
4337 vat_json_node_t node;
4339 i32 retval = ntohl (mp->retval);
4342 vat_json_init_object (&node);
4344 vat_json_object_add_int (&node, "sessions",
4345 ntohl (mp->active_sessions));
4346 vat_json_object_add_int (&node, "nexttbl",
4347 ntohl (mp->next_table_index));
4348 vat_json_object_add_int (&node, "nextnode",
4349 ntohl (mp->miss_next_index));
4350 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4351 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4352 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4353 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4354 ntohl (mp->mask_length), 0);
4355 vat_json_object_add_string_copy (&node, "mask", s);
4357 vat_json_print (vam->ofp, &node);
4358 vat_json_free (&node);
4360 vam->retval = ntohl (mp->retval);
4361 vam->result_ready = 1;
4365 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4368 vat_main_t *vam = &vat_main;
4370 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4371 ntohl (mp->hit_next_index), ntohl (mp->advance),
4372 ntohl (mp->opaque_index));
4373 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4374 ntohl (mp->match_length));
4378 vl_api_classify_session_details_t_handler_json
4379 (vl_api_classify_session_details_t * mp)
4381 vat_main_t *vam = &vat_main;
4382 vat_json_node_t *node = NULL;
4384 if (VAT_JSON_ARRAY != vam->json_tree.type)
4386 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4387 vat_json_init_array (&vam->json_tree);
4389 node = vat_json_array_add (&vam->json_tree);
4391 vat_json_init_object (node);
4392 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4393 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4394 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4396 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4398 vat_json_object_add_string_copy (node, "match", s);
4401 static void vl_api_pg_create_interface_reply_t_handler
4402 (vl_api_pg_create_interface_reply_t * mp)
4404 vat_main_t *vam = &vat_main;
4406 vam->retval = ntohl (mp->retval);
4407 vam->result_ready = 1;
4410 static void vl_api_pg_create_interface_reply_t_handler_json
4411 (vl_api_pg_create_interface_reply_t * mp)
4413 vat_main_t *vam = &vat_main;
4414 vat_json_node_t node;
4416 i32 retval = ntohl (mp->retval);
4419 vat_json_init_object (&node);
4421 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4423 vat_json_print (vam->ofp, &node);
4424 vat_json_free (&node);
4426 vam->retval = ntohl (mp->retval);
4427 vam->result_ready = 1;
4430 static void vl_api_policer_classify_details_t_handler
4431 (vl_api_policer_classify_details_t * mp)
4433 vat_main_t *vam = &vat_main;
4435 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4436 ntohl (mp->table_index));
4439 static void vl_api_policer_classify_details_t_handler_json
4440 (vl_api_policer_classify_details_t * mp)
4442 vat_main_t *vam = &vat_main;
4443 vat_json_node_t *node;
4445 if (VAT_JSON_ARRAY != vam->json_tree.type)
4447 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4448 vat_json_init_array (&vam->json_tree);
4450 node = vat_json_array_add (&vam->json_tree);
4452 vat_json_init_object (node);
4453 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4454 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4457 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4458 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4460 vat_main_t *vam = &vat_main;
4461 i32 retval = ntohl (mp->retval);
4462 if (vam->async_mode)
4464 vam->async_errors += (retval < 0);
4468 vam->retval = retval;
4469 vam->sw_if_index = ntohl (mp->sw_if_index);
4470 vam->result_ready = 1;
4474 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4475 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4477 vat_main_t *vam = &vat_main;
4478 vat_json_node_t node;
4480 vat_json_init_object (&node);
4481 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4482 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4484 vat_json_print (vam->ofp, &node);
4485 vat_json_free (&node);
4487 vam->retval = ntohl (mp->retval);
4488 vam->result_ready = 1;
4491 static void vl_api_flow_classify_details_t_handler
4492 (vl_api_flow_classify_details_t * mp)
4494 vat_main_t *vam = &vat_main;
4496 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4497 ntohl (mp->table_index));
4500 static void vl_api_flow_classify_details_t_handler_json
4501 (vl_api_flow_classify_details_t * mp)
4503 vat_main_t *vam = &vat_main;
4504 vat_json_node_t *node;
4506 if (VAT_JSON_ARRAY != vam->json_tree.type)
4508 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4509 vat_json_init_array (&vam->json_tree);
4511 node = vat_json_array_add (&vam->json_tree);
4513 vat_json_init_object (node);
4514 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4515 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4518 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
4519 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
4520 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
4521 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
4522 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4523 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4524 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4525 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4526 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4527 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4528 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4529 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4530 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4531 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4532 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
4533 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
4534 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
4535 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
4538 * Generate boilerplate reply handlers, which
4539 * dig the return value out of the xxx_reply_t API message,
4540 * stick it into vam->retval, and set vam->result_ready
4542 * Could also do this by pointing N message decode slots at
4543 * a single function, but that could break in subtle ways.
4546 #define foreach_standard_reply_retval_handler \
4547 _(sw_interface_set_flags_reply) \
4548 _(sw_interface_add_del_address_reply) \
4549 _(sw_interface_set_table_reply) \
4550 _(sw_interface_set_mpls_enable_reply) \
4551 _(sw_interface_set_vpath_reply) \
4552 _(sw_interface_set_vxlan_bypass_reply) \
4553 _(sw_interface_set_vxlan_gpe_bypass_reply) \
4554 _(sw_interface_set_l2_bridge_reply) \
4555 _(bridge_domain_add_del_reply) \
4556 _(sw_interface_set_l2_xconnect_reply) \
4557 _(l2fib_add_del_reply) \
4558 _(l2fib_flush_int_reply) \
4559 _(l2fib_flush_bd_reply) \
4560 _(ip_add_del_route_reply) \
4561 _(ip_mroute_add_del_reply) \
4562 _(mpls_route_add_del_reply) \
4563 _(mpls_ip_bind_unbind_reply) \
4564 _(proxy_arp_add_del_reply) \
4565 _(proxy_arp_intfc_enable_disable_reply) \
4566 _(sw_interface_set_unnumbered_reply) \
4567 _(ip_neighbor_add_del_reply) \
4568 _(reset_vrf_reply) \
4569 _(oam_add_del_reply) \
4570 _(reset_fib_reply) \
4571 _(dhcp_proxy_config_reply) \
4572 _(dhcp_proxy_set_vss_reply) \
4573 _(dhcp_client_config_reply) \
4574 _(set_ip_flow_hash_reply) \
4575 _(sw_interface_ip6_enable_disable_reply) \
4576 _(sw_interface_ip6_set_link_local_address_reply) \
4577 _(ip6nd_proxy_add_del_reply) \
4578 _(sw_interface_ip6nd_ra_prefix_reply) \
4579 _(sw_interface_ip6nd_ra_config_reply) \
4580 _(set_arp_neighbor_limit_reply) \
4581 _(l2_patch_add_del_reply) \
4582 _(sr_policy_add_reply) \
4583 _(sr_policy_mod_reply) \
4584 _(sr_policy_del_reply) \
4585 _(sr_localsid_add_del_reply) \
4586 _(sr_steering_add_del_reply) \
4587 _(classify_add_del_session_reply) \
4588 _(classify_set_interface_ip_table_reply) \
4589 _(classify_set_interface_l2_tables_reply) \
4590 _(l2tpv3_set_tunnel_cookies_reply) \
4591 _(l2tpv3_interface_enable_disable_reply) \
4592 _(l2tpv3_set_lookup_key_reply) \
4593 _(l2_fib_clear_table_reply) \
4594 _(l2_interface_efp_filter_reply) \
4595 _(l2_interface_vlan_tag_rewrite_reply) \
4596 _(modify_vhost_user_if_reply) \
4597 _(delete_vhost_user_if_reply) \
4598 _(want_ip4_arp_events_reply) \
4599 _(want_ip6_nd_events_reply) \
4600 _(input_acl_set_interface_reply) \
4601 _(ipsec_spd_add_del_reply) \
4602 _(ipsec_interface_add_del_spd_reply) \
4603 _(ipsec_spd_add_del_entry_reply) \
4604 _(ipsec_sad_add_del_entry_reply) \
4605 _(ipsec_sa_set_key_reply) \
4606 _(ipsec_tunnel_if_add_del_reply) \
4607 _(ikev2_profile_add_del_reply) \
4608 _(ikev2_profile_set_auth_reply) \
4609 _(ikev2_profile_set_id_reply) \
4610 _(ikev2_profile_set_ts_reply) \
4611 _(ikev2_set_local_key_reply) \
4612 _(ikev2_set_responder_reply) \
4613 _(ikev2_set_ike_transforms_reply) \
4614 _(ikev2_set_esp_transforms_reply) \
4615 _(ikev2_set_sa_lifetime_reply) \
4616 _(ikev2_initiate_sa_init_reply) \
4617 _(ikev2_initiate_del_ike_sa_reply) \
4618 _(ikev2_initiate_del_child_sa_reply) \
4619 _(ikev2_initiate_rekey_child_sa_reply) \
4620 _(delete_loopback_reply) \
4621 _(bd_ip_mac_add_del_reply) \
4622 _(map_del_domain_reply) \
4623 _(map_add_del_rule_reply) \
4624 _(want_interface_events_reply) \
4625 _(want_stats_reply) \
4626 _(cop_interface_enable_disable_reply) \
4627 _(cop_whitelist_enable_disable_reply) \
4628 _(sw_interface_clear_stats_reply) \
4629 _(ioam_enable_reply) \
4630 _(ioam_disable_reply) \
4631 _(one_add_del_locator_reply) \
4632 _(one_add_del_local_eid_reply) \
4633 _(one_add_del_remote_mapping_reply) \
4634 _(one_add_del_adjacency_reply) \
4635 _(one_add_del_map_resolver_reply) \
4636 _(one_add_del_map_server_reply) \
4637 _(one_enable_disable_reply) \
4638 _(one_rloc_probe_enable_disable_reply) \
4639 _(one_map_register_enable_disable_reply) \
4640 _(one_map_register_set_ttl_reply) \
4641 _(one_pitr_set_locator_set_reply) \
4642 _(one_map_request_mode_reply) \
4643 _(one_add_del_map_request_itr_rlocs_reply) \
4644 _(one_eid_table_add_del_map_reply) \
4645 _(one_use_petr_reply) \
4646 _(one_stats_enable_disable_reply) \
4647 _(one_add_del_l2_arp_entry_reply) \
4648 _(one_stats_flush_reply) \
4649 _(gpe_enable_disable_reply) \
4650 _(gpe_set_encap_mode_reply) \
4651 _(gpe_add_del_iface_reply) \
4652 _(gpe_add_del_native_fwd_rpath_reply) \
4653 _(af_packet_delete_reply) \
4654 _(policer_classify_set_interface_reply) \
4655 _(netmap_create_reply) \
4656 _(netmap_delete_reply) \
4657 _(set_ipfix_exporter_reply) \
4658 _(set_ipfix_classify_stream_reply) \
4659 _(ipfix_classify_table_add_del_reply) \
4660 _(flow_classify_set_interface_reply) \
4661 _(sw_interface_span_enable_disable_reply) \
4662 _(pg_capture_reply) \
4663 _(pg_enable_disable_reply) \
4664 _(ip_source_and_port_range_check_add_del_reply) \
4665 _(ip_source_and_port_range_check_interface_add_del_reply)\
4666 _(delete_subif_reply) \
4667 _(l2_interface_pbb_tag_rewrite_reply) \
4669 _(feature_enable_disable_reply) \
4670 _(sw_interface_tag_add_del_reply) \
4671 _(sw_interface_set_mtu_reply) \
4672 _(p2p_ethernet_add_reply) \
4673 _(p2p_ethernet_del_reply) \
4674 _(lldp_config_reply) \
4675 _(sw_interface_set_lldp_reply)
4678 static void vl_api_##n##_t_handler \
4679 (vl_api_##n##_t * mp) \
4681 vat_main_t * vam = &vat_main; \
4682 i32 retval = ntohl(mp->retval); \
4683 if (vam->async_mode) { \
4684 vam->async_errors += (retval < 0); \
4686 vam->retval = retval; \
4687 vam->result_ready = 1; \
4690 foreach_standard_reply_retval_handler;
4694 static void vl_api_##n##_t_handler_json \
4695 (vl_api_##n##_t * mp) \
4697 vat_main_t * vam = &vat_main; \
4698 vat_json_node_t node; \
4699 vat_json_init_object(&node); \
4700 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4701 vat_json_print(vam->ofp, &node); \
4702 vam->retval = ntohl(mp->retval); \
4703 vam->result_ready = 1; \
4705 foreach_standard_reply_retval_handler;
4709 * Table of message reply handlers, must include boilerplate handlers
4713 #define foreach_vpe_api_reply_msg \
4714 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4715 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4716 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4717 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4718 _(CONTROL_PING_REPLY, control_ping_reply) \
4719 _(CLI_REPLY, cli_reply) \
4720 _(CLI_INBAND_REPLY, cli_inband_reply) \
4721 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4722 sw_interface_add_del_address_reply) \
4723 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4724 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4725 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4726 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4727 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
4728 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4729 sw_interface_set_l2_xconnect_reply) \
4730 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4731 sw_interface_set_l2_bridge_reply) \
4732 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4733 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4734 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
4735 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4736 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
4737 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
4738 _(L2_FLAGS_REPLY, l2_flags_reply) \
4739 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4740 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4741 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4742 _(TAP_DELETE_REPLY, tap_delete_reply) \
4743 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4744 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4745 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4746 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4747 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4748 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4749 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4750 proxy_arp_intfc_enable_disable_reply) \
4751 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4752 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4753 sw_interface_set_unnumbered_reply) \
4754 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4755 _(RESET_VRF_REPLY, reset_vrf_reply) \
4756 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4757 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4758 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4759 _(RESET_FIB_REPLY, reset_fib_reply) \
4760 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4761 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4762 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4763 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4764 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4765 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4766 sw_interface_ip6_enable_disable_reply) \
4767 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4768 sw_interface_ip6_set_link_local_address_reply) \
4769 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
4770 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
4771 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4772 sw_interface_ip6nd_ra_prefix_reply) \
4773 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4774 sw_interface_ip6nd_ra_config_reply) \
4775 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4776 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4777 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4778 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4779 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4780 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4781 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4782 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4783 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4784 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4785 classify_set_interface_ip_table_reply) \
4786 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4787 classify_set_interface_l2_tables_reply) \
4788 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4789 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4790 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4791 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4792 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4793 l2tpv3_interface_enable_disable_reply) \
4794 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4795 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4796 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4797 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4798 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4799 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4800 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4801 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4802 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4803 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4804 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4805 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4806 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4807 _(SHOW_VERSION_REPLY, show_version_reply) \
4808 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
4809 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4810 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4811 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4812 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4813 _(IP4_ARP_EVENT, ip4_arp_event) \
4814 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4815 _(IP6_ND_EVENT, ip6_nd_event) \
4816 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4817 _(IP_ADDRESS_DETAILS, ip_address_details) \
4818 _(IP_DETAILS, ip_details) \
4819 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4820 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4821 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4822 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4823 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4824 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
4825 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4826 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4827 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4828 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4829 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4830 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4831 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4832 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4833 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4834 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4835 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4836 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4837 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4838 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4839 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4840 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4841 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4842 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4843 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4844 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4845 _(MAP_RULE_DETAILS, map_rule_details) \
4846 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4847 _(WANT_STATS_REPLY, want_stats_reply) \
4848 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4849 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4850 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4851 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4852 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4853 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4854 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4855 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4856 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4857 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4858 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4859 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4860 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4861 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4862 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4863 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4864 one_map_register_enable_disable_reply) \
4865 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
4866 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4867 one_rloc_probe_enable_disable_reply) \
4868 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4869 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
4870 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4871 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4872 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4873 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4874 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4875 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4876 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4877 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4878 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4879 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4880 _(ONE_STATS_DETAILS, one_stats_details) \
4881 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
4882 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
4883 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
4884 show_one_stats_enable_disable_reply) \
4885 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
4886 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
4887 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
4888 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4889 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4890 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4891 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4892 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4893 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
4894 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4895 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
4896 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
4897 gpe_add_del_native_fwd_rpath_reply) \
4898 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4899 gpe_fwd_entry_path_details) \
4900 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4901 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4902 one_add_del_map_request_itr_rlocs_reply) \
4903 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4904 one_get_map_request_itr_rlocs_reply) \
4905 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
4906 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4907 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
4908 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4909 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4910 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4911 show_one_map_register_state_reply) \
4912 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
4913 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4914 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4915 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4916 _(POLICER_DETAILS, policer_details) \
4917 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4918 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4919 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4920 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4921 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4922 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4923 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4924 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4925 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4926 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4927 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4928 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4929 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4930 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4931 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4932 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4933 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4934 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4935 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4936 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4937 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4938 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4939 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4940 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4941 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4942 ip_source_and_port_range_check_add_del_reply) \
4943 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4944 ip_source_and_port_range_check_interface_add_del_reply) \
4945 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4946 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4947 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4948 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4949 _(PUNT_REPLY, punt_reply) \
4950 _(IP_FIB_DETAILS, ip_fib_details) \
4951 _(IP6_FIB_DETAILS, ip6_fib_details) \
4952 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4953 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4954 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4955 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4956 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4957 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
4958 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
4959 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
4960 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
4961 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply)
4963 #define foreach_standalone_reply_msg \
4964 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4965 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
4966 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
4967 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4968 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4969 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4970 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
4979 #define STR_VTR_OP_CASE(op) \
4980 case L2_VTR_ ## op: \
4984 str_vtr_op (u32 vtr_op)
4988 STR_VTR_OP_CASE (DISABLED);
4989 STR_VTR_OP_CASE (PUSH_1);
4990 STR_VTR_OP_CASE (PUSH_2);
4991 STR_VTR_OP_CASE (POP_1);
4992 STR_VTR_OP_CASE (POP_2);
4993 STR_VTR_OP_CASE (TRANSLATE_1_1);
4994 STR_VTR_OP_CASE (TRANSLATE_1_2);
4995 STR_VTR_OP_CASE (TRANSLATE_2_1);
4996 STR_VTR_OP_CASE (TRANSLATE_2_2);
5003 dump_sub_interface_table (vat_main_t * vam)
5005 const sw_interface_subif_t *sub = NULL;
5007 if (vam->json_output)
5010 ("JSON output supported only for VPE API calls and dump_stats_table");
5015 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5016 "Interface", "sw_if_index",
5017 "sub id", "dot1ad", "tags", "outer id",
5018 "inner id", "exact", "default", "outer any", "inner any");
5020 vec_foreach (sub, vam->sw_if_subif_table)
5023 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5024 sub->interface_name,
5026 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5027 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5028 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5029 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5030 if (sub->vtr_op != L2_VTR_DISABLED)
5033 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5034 "tag1: %d tag2: %d ]",
5035 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5036 sub->vtr_tag1, sub->vtr_tag2);
5044 name_sort_cmp (void *a1, void *a2)
5046 name_sort_t *n1 = a1;
5047 name_sort_t *n2 = a2;
5049 return strcmp ((char *) n1->name, (char *) n2->name);
5053 dump_interface_table (vat_main_t * vam)
5056 name_sort_t *nses = 0, *ns;
5058 if (vam->json_output)
5061 ("JSON output supported only for VPE API calls and dump_stats_table");
5066 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5068 vec_add2 (nses, ns, 1);
5069 ns->name = (u8 *)(p->key);
5070 ns->value = (u32) p->value[0];
5074 vec_sort_with_function (nses, name_sort_cmp);
5076 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5077 vec_foreach (ns, nses)
5079 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5086 dump_ip_table (vat_main_t * vam, int is_ipv6)
5088 const ip_details_t *det = NULL;
5089 const ip_address_details_t *address = NULL;
5092 print (vam->ofp, "%-12s", "sw_if_index");
5094 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5101 print (vam->ofp, "%-12d", i);
5102 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5107 vec_foreach (address, det->addr)
5111 is_ipv6 ? format_ip6_address : format_ip4_address,
5112 address->ip, address->prefix_length);
5120 dump_ipv4_table (vat_main_t * vam)
5122 if (vam->json_output)
5125 ("JSON output supported only for VPE API calls and dump_stats_table");
5129 return dump_ip_table (vam, 0);
5133 dump_ipv6_table (vat_main_t * vam)
5135 if (vam->json_output)
5138 ("JSON output supported only for VPE API calls and dump_stats_table");
5142 return dump_ip_table (vam, 1);
5146 counter_type_to_str (u8 counter_type, u8 is_combined)
5150 switch (counter_type)
5152 case VNET_INTERFACE_COUNTER_DROP:
5154 case VNET_INTERFACE_COUNTER_PUNT:
5156 case VNET_INTERFACE_COUNTER_IP4:
5158 case VNET_INTERFACE_COUNTER_IP6:
5160 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5162 case VNET_INTERFACE_COUNTER_RX_MISS:
5164 case VNET_INTERFACE_COUNTER_RX_ERROR:
5166 case VNET_INTERFACE_COUNTER_TX_ERROR:
5169 return "INVALID-COUNTER-TYPE";
5174 switch (counter_type)
5176 case VNET_INTERFACE_COUNTER_RX:
5178 case VNET_INTERFACE_COUNTER_TX:
5181 return "INVALID-COUNTER-TYPE";
5187 dump_stats_table (vat_main_t * vam)
5189 vat_json_node_t node;
5190 vat_json_node_t *msg_array;
5191 vat_json_node_t *msg;
5192 vat_json_node_t *counter_array;
5193 vat_json_node_t *counter;
5194 interface_counter_t c;
5196 ip4_fib_counter_t *c4;
5197 ip6_fib_counter_t *c6;
5198 ip4_nbr_counter_t *n4;
5199 ip6_nbr_counter_t *n6;
5202 if (!vam->json_output)
5204 clib_warning ("dump_stats_table supported only in JSON format");
5208 vat_json_init_object (&node);
5210 /* interface counters */
5211 msg_array = vat_json_object_add (&node, "interface_counters");
5212 vat_json_init_array (msg_array);
5213 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5215 msg = vat_json_array_add (msg_array);
5216 vat_json_init_object (msg);
5217 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5218 (u8 *) counter_type_to_str (i, 0));
5219 vat_json_object_add_int (msg, "is_combined", 0);
5220 counter_array = vat_json_object_add (msg, "data");
5221 vat_json_init_array (counter_array);
5222 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5224 packets = vam->simple_interface_counters[i][j];
5225 vat_json_array_add_uint (counter_array, packets);
5228 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5230 msg = vat_json_array_add (msg_array);
5231 vat_json_init_object (msg);
5232 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5233 (u8 *) counter_type_to_str (i, 1));
5234 vat_json_object_add_int (msg, "is_combined", 1);
5235 counter_array = vat_json_object_add (msg, "data");
5236 vat_json_init_array (counter_array);
5237 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5239 c = vam->combined_interface_counters[i][j];
5240 counter = vat_json_array_add (counter_array);
5241 vat_json_init_object (counter);
5242 vat_json_object_add_uint (counter, "packets", c.packets);
5243 vat_json_object_add_uint (counter, "bytes", c.bytes);
5247 /* ip4 fib counters */
5248 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5249 vat_json_init_array (msg_array);
5250 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5252 msg = vat_json_array_add (msg_array);
5253 vat_json_init_object (msg);
5254 vat_json_object_add_uint (msg, "vrf_id",
5255 vam->ip4_fib_counters_vrf_id_by_index[i]);
5256 counter_array = vat_json_object_add (msg, "c");
5257 vat_json_init_array (counter_array);
5258 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5260 counter = vat_json_array_add (counter_array);
5261 vat_json_init_object (counter);
5262 c4 = &vam->ip4_fib_counters[i][j];
5263 vat_json_object_add_ip4 (counter, "address", c4->address);
5264 vat_json_object_add_uint (counter, "address_length",
5265 c4->address_length);
5266 vat_json_object_add_uint (counter, "packets", c4->packets);
5267 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5271 /* ip6 fib counters */
5272 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5273 vat_json_init_array (msg_array);
5274 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5276 msg = vat_json_array_add (msg_array);
5277 vat_json_init_object (msg);
5278 vat_json_object_add_uint (msg, "vrf_id",
5279 vam->ip6_fib_counters_vrf_id_by_index[i]);
5280 counter_array = vat_json_object_add (msg, "c");
5281 vat_json_init_array (counter_array);
5282 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5284 counter = vat_json_array_add (counter_array);
5285 vat_json_init_object (counter);
5286 c6 = &vam->ip6_fib_counters[i][j];
5287 vat_json_object_add_ip6 (counter, "address", c6->address);
5288 vat_json_object_add_uint (counter, "address_length",
5289 c6->address_length);
5290 vat_json_object_add_uint (counter, "packets", c6->packets);
5291 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5295 /* ip4 nbr counters */
5296 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5297 vat_json_init_array (msg_array);
5298 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5300 msg = vat_json_array_add (msg_array);
5301 vat_json_init_object (msg);
5302 vat_json_object_add_uint (msg, "sw_if_index", i);
5303 counter_array = vat_json_object_add (msg, "c");
5304 vat_json_init_array (counter_array);
5305 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5307 counter = vat_json_array_add (counter_array);
5308 vat_json_init_object (counter);
5309 n4 = &vam->ip4_nbr_counters[i][j];
5310 vat_json_object_add_ip4 (counter, "address", n4->address);
5311 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5312 vat_json_object_add_uint (counter, "packets", n4->packets);
5313 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5317 /* ip6 nbr counters */
5318 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5319 vat_json_init_array (msg_array);
5320 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5322 msg = vat_json_array_add (msg_array);
5323 vat_json_init_object (msg);
5324 vat_json_object_add_uint (msg, "sw_if_index", i);
5325 counter_array = vat_json_object_add (msg, "c");
5326 vat_json_init_array (counter_array);
5327 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5329 counter = vat_json_array_add (counter_array);
5330 vat_json_init_object (counter);
5331 n6 = &vam->ip6_nbr_counters[i][j];
5332 vat_json_object_add_ip6 (counter, "address", n6->address);
5333 vat_json_object_add_uint (counter, "packets", n6->packets);
5334 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5338 vat_json_print (vam->ofp, &node);
5339 vat_json_free (&node);
5345 exec (vat_main_t * vam)
5347 api_main_t *am = &api_main;
5352 unformat_input_t *i = vam->input;
5354 if (vec_len (i->buffer) == 0)
5357 if (vam->exec_mode == 0 && unformat (i, "mode"))
5362 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5372 * Copy cmd into shared memory.
5373 * In order for the CLI command to work, it
5374 * must be a vector ending in \n, not a C-string ending
5377 pthread_mutex_lock (&am->vlib_rp->mutex);
5378 oldheap = svm_push_data_heap (am->vlib_rp);
5380 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
5381 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
5383 svm_pop_heap (oldheap);
5384 pthread_mutex_unlock (&am->vlib_rp->mutex);
5386 mp->cmd_in_shmem = pointer_to_uword (cmd);
5388 timeout = vat_time_now (vam) + 10.0;
5390 while (vat_time_now (vam) < timeout)
5392 if (vam->result_ready == 1)
5395 if (vam->shmem_result != NULL)
5396 print (vam->ofp, "%s", vam->shmem_result);
5397 pthread_mutex_lock (&am->vlib_rp->mutex);
5398 oldheap = svm_push_data_heap (am->vlib_rp);
5400 free_me = (u8 *) vam->shmem_result;
5403 svm_pop_heap (oldheap);
5404 pthread_mutex_unlock (&am->vlib_rp->mutex);
5412 * Future replacement of exec() that passes CLI buffers directly in
5413 * the API messages instead of an additional shared memory area.
5416 exec_inband (vat_main_t * vam)
5418 vl_api_cli_inband_t *mp;
5419 unformat_input_t *i = vam->input;
5422 if (vec_len (i->buffer) == 0)
5425 if (vam->exec_mode == 0 && unformat (i, "mode"))
5430 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5437 * In order for the CLI command to work, it
5438 * must be a vector ending in \n, not a C-string ending
5441 u32 len = vec_len (vam->input->buffer);
5442 M2 (CLI_INBAND, mp, len);
5443 clib_memcpy (mp->cmd, vam->input->buffer, len);
5444 mp->length = htonl (len);
5447 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
5452 api_create_loopback (vat_main_t * vam)
5454 unformat_input_t *i = vam->input;
5455 vl_api_create_loopback_t *mp;
5456 vl_api_create_loopback_instance_t *mp_lbi;
5459 u8 is_specified = 0;
5460 u32 user_instance = 0;
5463 memset (mac_address, 0, sizeof (mac_address));
5465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5467 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5469 if (unformat (i, "instance %d", &user_instance))
5477 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5478 mp_lbi->is_specified = is_specified;
5480 mp_lbi->user_instance = htonl (user_instance);
5482 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5487 /* Construct the API message */
5488 M (CREATE_LOOPBACK, mp);
5490 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5499 api_delete_loopback (vat_main_t * vam)
5501 unformat_input_t *i = vam->input;
5502 vl_api_delete_loopback_t *mp;
5503 u32 sw_if_index = ~0;
5506 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5508 if (unformat (i, "sw_if_index %d", &sw_if_index))
5514 if (sw_if_index == ~0)
5516 errmsg ("missing sw_if_index");
5520 /* Construct the API message */
5521 M (DELETE_LOOPBACK, mp);
5522 mp->sw_if_index = ntohl (sw_if_index);
5530 api_want_stats (vat_main_t * vam)
5532 unformat_input_t *i = vam->input;
5533 vl_api_want_stats_t *mp;
5537 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5539 if (unformat (i, "enable"))
5541 else if (unformat (i, "disable"))
5549 errmsg ("missing enable|disable");
5554 mp->enable_disable = enable;
5562 api_want_interface_events (vat_main_t * vam)
5564 unformat_input_t *i = vam->input;
5565 vl_api_want_interface_events_t *mp;
5569 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5571 if (unformat (i, "enable"))
5573 else if (unformat (i, "disable"))
5581 errmsg ("missing enable|disable");
5585 M (WANT_INTERFACE_EVENTS, mp);
5586 mp->enable_disable = enable;
5588 vam->interface_event_display = enable;
5596 /* Note: non-static, called once to set up the initial intfc table */
5598 api_sw_interface_dump (vat_main_t * vam)
5600 vl_api_sw_interface_dump_t *mp;
5601 vl_api_control_ping_t *mp_ping;
5603 name_sort_t *nses = 0, *ns;
5604 sw_interface_subif_t *sub = NULL;
5607 /* Toss the old name table */
5609 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5611 vec_add2 (nses, ns, 1);
5612 ns->name = (u8 *)(p->key);
5613 ns->value = (u32) p->value[0];
5617 hash_free (vam->sw_if_index_by_interface_name);
5619 vec_foreach (ns, nses) vec_free (ns->name);
5623 vec_foreach (sub, vam->sw_if_subif_table)
5625 vec_free (sub->interface_name);
5627 vec_free (vam->sw_if_subif_table);
5629 /* recreate the interface name hash table */
5630 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5632 /* Get list of ethernets */
5633 M (SW_INTERFACE_DUMP, mp);
5634 mp->name_filter_valid = 1;
5635 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
5638 /* and local / loopback interfaces */
5639 M (SW_INTERFACE_DUMP, mp);
5640 mp->name_filter_valid = 1;
5641 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
5644 /* and packet-generator interfaces */
5645 M (SW_INTERFACE_DUMP, mp);
5646 mp->name_filter_valid = 1;
5647 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
5650 /* and vxlan-gpe tunnel interfaces */
5651 M (SW_INTERFACE_DUMP, mp);
5652 mp->name_filter_valid = 1;
5653 strncpy ((char *) mp->name_filter, "vxlan_gpe",
5654 sizeof (mp->name_filter) - 1);
5657 /* and vxlan tunnel interfaces */
5658 M (SW_INTERFACE_DUMP, mp);
5659 mp->name_filter_valid = 1;
5660 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
5663 /* and host (af_packet) interfaces */
5664 M (SW_INTERFACE_DUMP, mp);
5665 mp->name_filter_valid = 1;
5666 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
5669 /* and l2tpv3 tunnel interfaces */
5670 M (SW_INTERFACE_DUMP, mp);
5671 mp->name_filter_valid = 1;
5672 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
5673 sizeof (mp->name_filter) - 1);
5676 /* and GRE tunnel interfaces */
5677 M (SW_INTERFACE_DUMP, mp);
5678 mp->name_filter_valid = 1;
5679 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
5682 /* and LISP-GPE interfaces */
5683 M (SW_INTERFACE_DUMP, mp);
5684 mp->name_filter_valid = 1;
5685 strncpy ((char *) mp->name_filter, "lisp_gpe",
5686 sizeof (mp->name_filter) - 1);
5689 /* and IPSEC tunnel interfaces */
5690 M (SW_INTERFACE_DUMP, mp);
5691 mp->name_filter_valid = 1;
5692 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
5695 /* Use a control ping for synchronization */
5696 M (CONTROL_PING, mp_ping);
5704 api_sw_interface_set_flags (vat_main_t * vam)
5706 unformat_input_t *i = vam->input;
5707 vl_api_sw_interface_set_flags_t *mp;
5709 u8 sw_if_index_set = 0;
5710 u8 admin_up = 0, link_up = 0;
5713 /* Parse args required to build the message */
5714 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5716 if (unformat (i, "admin-up"))
5718 else if (unformat (i, "admin-down"))
5720 else if (unformat (i, "link-up"))
5722 else if (unformat (i, "link-down"))
5725 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5726 sw_if_index_set = 1;
5727 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5728 sw_if_index_set = 1;
5733 if (sw_if_index_set == 0)
5735 errmsg ("missing interface name or sw_if_index");
5739 /* Construct the API message */
5740 M (SW_INTERFACE_SET_FLAGS, mp);
5741 mp->sw_if_index = ntohl (sw_if_index);
5742 mp->admin_up_down = admin_up;
5743 mp->link_up_down = link_up;
5748 /* Wait for a reply, return the good/bad news... */
5754 api_sw_interface_clear_stats (vat_main_t * vam)
5756 unformat_input_t *i = vam->input;
5757 vl_api_sw_interface_clear_stats_t *mp;
5759 u8 sw_if_index_set = 0;
5762 /* Parse args required to build the message */
5763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5765 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5766 sw_if_index_set = 1;
5767 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5768 sw_if_index_set = 1;
5773 /* Construct the API message */
5774 M (SW_INTERFACE_CLEAR_STATS, mp);
5776 if (sw_if_index_set == 1)
5777 mp->sw_if_index = ntohl (sw_if_index);
5779 mp->sw_if_index = ~0;
5784 /* Wait for a reply, return the good/bad news... */
5790 api_sw_interface_add_del_address (vat_main_t * vam)
5792 unformat_input_t *i = vam->input;
5793 vl_api_sw_interface_add_del_address_t *mp;
5795 u8 sw_if_index_set = 0;
5796 u8 is_add = 1, del_all = 0;
5797 u32 address_length = 0;
5798 u8 v4_address_set = 0;
5799 u8 v6_address_set = 0;
5800 ip4_address_t v4address;
5801 ip6_address_t v6address;
5804 /* Parse args required to build the message */
5805 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5807 if (unformat (i, "del-all"))
5809 else if (unformat (i, "del"))
5812 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5813 sw_if_index_set = 1;
5814 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5815 sw_if_index_set = 1;
5816 else if (unformat (i, "%U/%d",
5817 unformat_ip4_address, &v4address, &address_length))
5819 else if (unformat (i, "%U/%d",
5820 unformat_ip6_address, &v6address, &address_length))
5826 if (sw_if_index_set == 0)
5828 errmsg ("missing interface name or sw_if_index");
5831 if (v4_address_set && v6_address_set)
5833 errmsg ("both v4 and v6 addresses set");
5836 if (!v4_address_set && !v6_address_set && !del_all)
5838 errmsg ("no addresses set");
5842 /* Construct the API message */
5843 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5845 mp->sw_if_index = ntohl (sw_if_index);
5846 mp->is_add = is_add;
5847 mp->del_all = del_all;
5851 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5855 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5857 mp->address_length = address_length;
5862 /* Wait for a reply, return good/bad news */
5868 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5870 unformat_input_t *i = vam->input;
5871 vl_api_sw_interface_set_mpls_enable_t *mp;
5873 u8 sw_if_index_set = 0;
5877 /* Parse args required to build the message */
5878 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5880 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5881 sw_if_index_set = 1;
5882 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5883 sw_if_index_set = 1;
5884 else if (unformat (i, "disable"))
5886 else if (unformat (i, "dis"))
5892 if (sw_if_index_set == 0)
5894 errmsg ("missing interface name or sw_if_index");
5898 /* Construct the API message */
5899 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5901 mp->sw_if_index = ntohl (sw_if_index);
5902 mp->enable = enable;
5907 /* Wait for a reply... */
5913 api_sw_interface_set_table (vat_main_t * vam)
5915 unformat_input_t *i = vam->input;
5916 vl_api_sw_interface_set_table_t *mp;
5917 u32 sw_if_index, vrf_id = 0;
5918 u8 sw_if_index_set = 0;
5922 /* Parse args required to build the message */
5923 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5925 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5926 sw_if_index_set = 1;
5927 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5928 sw_if_index_set = 1;
5929 else if (unformat (i, "vrf %d", &vrf_id))
5931 else if (unformat (i, "ipv6"))
5937 if (sw_if_index_set == 0)
5939 errmsg ("missing interface name or sw_if_index");
5943 /* Construct the API message */
5944 M (SW_INTERFACE_SET_TABLE, mp);
5946 mp->sw_if_index = ntohl (sw_if_index);
5947 mp->is_ipv6 = is_ipv6;
5948 mp->vrf_id = ntohl (vrf_id);
5953 /* Wait for a reply... */
5958 static void vl_api_sw_interface_get_table_reply_t_handler
5959 (vl_api_sw_interface_get_table_reply_t * mp)
5961 vat_main_t *vam = &vat_main;
5963 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5965 vam->retval = ntohl (mp->retval);
5966 vam->result_ready = 1;
5970 static void vl_api_sw_interface_get_table_reply_t_handler_json
5971 (vl_api_sw_interface_get_table_reply_t * mp)
5973 vat_main_t *vam = &vat_main;
5974 vat_json_node_t node;
5976 vat_json_init_object (&node);
5977 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5978 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5980 vat_json_print (vam->ofp, &node);
5981 vat_json_free (&node);
5983 vam->retval = ntohl (mp->retval);
5984 vam->result_ready = 1;
5988 api_sw_interface_get_table (vat_main_t * vam)
5990 unformat_input_t *i = vam->input;
5991 vl_api_sw_interface_get_table_t *mp;
5993 u8 sw_if_index_set = 0;
5997 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5999 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6000 sw_if_index_set = 1;
6001 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6002 sw_if_index_set = 1;
6003 else if (unformat (i, "ipv6"))
6009 if (sw_if_index_set == 0)
6011 errmsg ("missing interface name or sw_if_index");
6015 M (SW_INTERFACE_GET_TABLE, mp);
6016 mp->sw_if_index = htonl (sw_if_index);
6017 mp->is_ipv6 = is_ipv6;
6025 api_sw_interface_set_vpath (vat_main_t * vam)
6027 unformat_input_t *i = vam->input;
6028 vl_api_sw_interface_set_vpath_t *mp;
6029 u32 sw_if_index = 0;
6030 u8 sw_if_index_set = 0;
6034 /* Parse args required to build the message */
6035 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6037 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6038 sw_if_index_set = 1;
6039 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6040 sw_if_index_set = 1;
6041 else if (unformat (i, "enable"))
6043 else if (unformat (i, "disable"))
6049 if (sw_if_index_set == 0)
6051 errmsg ("missing interface name or sw_if_index");
6055 /* Construct the API message */
6056 M (SW_INTERFACE_SET_VPATH, mp);
6058 mp->sw_if_index = ntohl (sw_if_index);
6059 mp->enable = is_enable;
6064 /* Wait for a reply... */
6070 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6072 unformat_input_t *i = vam->input;
6073 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6074 u32 sw_if_index = 0;
6075 u8 sw_if_index_set = 0;
6080 /* Parse args required to build the message */
6081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6083 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6084 sw_if_index_set = 1;
6085 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6086 sw_if_index_set = 1;
6087 else if (unformat (i, "enable"))
6089 else if (unformat (i, "disable"))
6091 else if (unformat (i, "ip4"))
6093 else if (unformat (i, "ip6"))
6099 if (sw_if_index_set == 0)
6101 errmsg ("missing interface name or sw_if_index");
6105 /* Construct the API message */
6106 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6108 mp->sw_if_index = ntohl (sw_if_index);
6109 mp->enable = is_enable;
6110 mp->is_ipv6 = is_ipv6;
6115 /* Wait for a reply... */
6122 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6124 unformat_input_t *i = vam->input;
6125 vl_api_sw_interface_set_l2_xconnect_t *mp;
6127 u8 rx_sw_if_index_set = 0;
6129 u8 tx_sw_if_index_set = 0;
6133 /* Parse args required to build the message */
6134 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6136 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6137 rx_sw_if_index_set = 1;
6138 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6139 tx_sw_if_index_set = 1;
6140 else if (unformat (i, "rx"))
6142 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6144 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6146 rx_sw_if_index_set = 1;
6151 else if (unformat (i, "tx"))
6153 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6155 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6157 tx_sw_if_index_set = 1;
6162 else if (unformat (i, "enable"))
6164 else if (unformat (i, "disable"))
6170 if (rx_sw_if_index_set == 0)
6172 errmsg ("missing rx interface name or rx_sw_if_index");
6176 if (enable && (tx_sw_if_index_set == 0))
6178 errmsg ("missing tx interface name or tx_sw_if_index");
6182 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6184 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6185 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6186 mp->enable = enable;
6194 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6196 unformat_input_t *i = vam->input;
6197 vl_api_sw_interface_set_l2_bridge_t *mp;
6199 u8 rx_sw_if_index_set = 0;
6207 /* Parse args required to build the message */
6208 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6210 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6211 rx_sw_if_index_set = 1;
6212 else if (unformat (i, "bd_id %d", &bd_id))
6216 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6217 rx_sw_if_index_set = 1;
6218 else if (unformat (i, "shg %d", &shg))
6220 else if (unformat (i, "bvi"))
6222 else if (unformat (i, "enable"))
6224 else if (unformat (i, "disable"))
6230 if (rx_sw_if_index_set == 0)
6232 errmsg ("missing rx interface name or sw_if_index");
6236 if (enable && (bd_id_set == 0))
6238 errmsg ("missing bridge domain");
6242 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6244 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6245 mp->bd_id = ntohl (bd_id);
6248 mp->enable = enable;
6256 api_bridge_domain_dump (vat_main_t * vam)
6258 unformat_input_t *i = vam->input;
6259 vl_api_bridge_domain_dump_t *mp;
6260 vl_api_control_ping_t *mp_ping;
6264 /* Parse args required to build the message */
6265 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6267 if (unformat (i, "bd_id %d", &bd_id))
6273 M (BRIDGE_DOMAIN_DUMP, mp);
6274 mp->bd_id = ntohl (bd_id);
6277 /* Use a control ping for synchronization */
6278 M (CONTROL_PING, mp_ping);
6286 api_bridge_domain_add_del (vat_main_t * vam)
6288 unformat_input_t *i = vam->input;
6289 vl_api_bridge_domain_add_del_t *mp;
6292 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6296 /* Parse args required to build the message */
6297 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6299 if (unformat (i, "bd_id %d", &bd_id))
6301 else if (unformat (i, "flood %d", &flood))
6303 else if (unformat (i, "uu-flood %d", &uu_flood))
6305 else if (unformat (i, "forward %d", &forward))
6307 else if (unformat (i, "learn %d", &learn))
6309 else if (unformat (i, "arp-term %d", &arp_term))
6311 else if (unformat (i, "mac-age %d", &mac_age))
6313 else if (unformat (i, "del"))
6316 flood = uu_flood = forward = learn = 0;
6324 errmsg ("missing bridge domain");
6330 errmsg ("mac age must be less than 256 ");
6334 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6336 mp->bd_id = ntohl (bd_id);
6338 mp->uu_flood = uu_flood;
6339 mp->forward = forward;
6341 mp->arp_term = arp_term;
6342 mp->is_add = is_add;
6343 mp->mac_age = (u8) mac_age;
6351 api_l2fib_flush_bd (vat_main_t * vam)
6353 unformat_input_t *i = vam->input;
6354 vl_api_l2fib_flush_bd_t *mp;
6358 /* Parse args required to build the message */
6359 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6361 if (unformat (i, "bd_id %d", &bd_id));
6368 errmsg ("missing bridge domain");
6372 M (L2FIB_FLUSH_BD, mp);
6374 mp->bd_id = htonl (bd_id);
6382 api_l2fib_flush_int (vat_main_t * vam)
6384 unformat_input_t *i = vam->input;
6385 vl_api_l2fib_flush_int_t *mp;
6386 u32 sw_if_index = ~0;
6389 /* Parse args required to build the message */
6390 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6392 if (unformat (i, "sw_if_index %d", &sw_if_index));
6394 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6399 if (sw_if_index == ~0)
6401 errmsg ("missing interface name or sw_if_index");
6405 M (L2FIB_FLUSH_INT, mp);
6407 mp->sw_if_index = ntohl (sw_if_index);
6415 api_l2fib_add_del (vat_main_t * vam)
6417 unformat_input_t *i = vam->input;
6418 vl_api_l2fib_add_del_t *mp;
6424 u32 sw_if_index = ~0;
6425 u8 sw_if_index_set = 0;
6434 /* Parse args required to build the message */
6435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6437 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6439 else if (unformat (i, "bd_id %d", &bd_id))
6441 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6442 sw_if_index_set = 1;
6443 else if (unformat (i, "sw_if"))
6445 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6448 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6449 sw_if_index_set = 1;
6454 else if (unformat (i, "static"))
6456 else if (unformat (i, "filter"))
6461 else if (unformat (i, "bvi"))
6466 else if (unformat (i, "del"))
6468 else if (unformat (i, "count %d", &count))
6476 errmsg ("missing mac address");
6482 errmsg ("missing bridge domain");
6486 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6488 errmsg ("missing interface name or sw_if_index");
6494 /* Turn on async mode */
6495 vam->async_mode = 1;
6496 vam->async_errors = 0;
6497 before = vat_time_now (vam);
6500 for (j = 0; j < count; j++)
6502 M (L2FIB_ADD_DEL, mp);
6505 mp->bd_id = ntohl (bd_id);
6506 mp->is_add = is_add;
6510 mp->sw_if_index = ntohl (sw_if_index);
6511 mp->static_mac = static_mac;
6512 mp->filter_mac = filter_mac;
6513 mp->bvi_mac = bvi_mac;
6515 increment_mac_address (&mac);
6522 vl_api_control_ping_t *mp_ping;
6525 /* Shut off async mode */
6526 vam->async_mode = 0;
6528 M (CONTROL_PING, mp_ping);
6531 timeout = vat_time_now (vam) + 1.0;
6532 while (vat_time_now (vam) < timeout)
6533 if (vam->result_ready == 1)
6538 if (vam->retval == -99)
6541 if (vam->async_errors > 0)
6543 errmsg ("%d asynchronous errors", vam->async_errors);
6546 vam->async_errors = 0;
6547 after = vat_time_now (vam);
6549 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6550 count, after - before, count / (after - before));
6556 /* Wait for a reply... */
6560 /* Return the good/bad news */
6561 return (vam->retval);
6565 api_bridge_domain_set_mac_age (vat_main_t * vam)
6567 unformat_input_t *i = vam->input;
6568 vl_api_bridge_domain_set_mac_age_t *mp;
6573 /* Parse args required to build the message */
6574 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6576 if (unformat (i, "bd_id %d", &bd_id));
6577 else if (unformat (i, "mac-age %d", &mac_age));
6584 errmsg ("missing bridge domain");
6590 errmsg ("mac age must be less than 256 ");
6594 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6596 mp->bd_id = htonl (bd_id);
6597 mp->mac_age = (u8) mac_age;
6605 api_l2_flags (vat_main_t * vam)
6607 unformat_input_t *i = vam->input;
6608 vl_api_l2_flags_t *mp;
6610 u32 feature_bitmap = 0;
6611 u8 sw_if_index_set = 0;
6614 /* Parse args required to build the message */
6615 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6617 if (unformat (i, "sw_if_index %d", &sw_if_index))
6618 sw_if_index_set = 1;
6619 else if (unformat (i, "sw_if"))
6621 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6624 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6625 sw_if_index_set = 1;
6630 else if (unformat (i, "learn"))
6631 feature_bitmap |= L2INPUT_FEAT_LEARN;
6632 else if (unformat (i, "forward"))
6633 feature_bitmap |= L2INPUT_FEAT_FWD;
6634 else if (unformat (i, "flood"))
6635 feature_bitmap |= L2INPUT_FEAT_FLOOD;
6636 else if (unformat (i, "uu-flood"))
6637 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
6642 if (sw_if_index_set == 0)
6644 errmsg ("missing interface name or sw_if_index");
6650 mp->sw_if_index = ntohl (sw_if_index);
6651 mp->feature_bitmap = ntohl (feature_bitmap);
6659 api_bridge_flags (vat_main_t * vam)
6661 unformat_input_t *i = vam->input;
6662 vl_api_bridge_flags_t *mp;
6669 /* Parse args required to build the message */
6670 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6672 if (unformat (i, "bd_id %d", &bd_id))
6674 else if (unformat (i, "learn"))
6676 else if (unformat (i, "forward"))
6678 else if (unformat (i, "flood"))
6680 else if (unformat (i, "uu-flood"))
6681 flags |= L2_UU_FLOOD;
6682 else if (unformat (i, "arp-term"))
6683 flags |= L2_ARP_TERM;
6684 else if (unformat (i, "off"))
6686 else if (unformat (i, "disable"))
6694 errmsg ("missing bridge domain");
6698 M (BRIDGE_FLAGS, mp);
6700 mp->bd_id = ntohl (bd_id);
6701 mp->feature_bitmap = ntohl (flags);
6702 mp->is_set = is_set;
6710 api_bd_ip_mac_add_del (vat_main_t * vam)
6712 unformat_input_t *i = vam->input;
6713 vl_api_bd_ip_mac_add_del_t *mp;
6720 ip4_address_t v4addr;
6721 ip6_address_t v6addr;
6726 /* Parse args required to build the message */
6727 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6729 if (unformat (i, "bd_id %d", &bd_id))
6733 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6737 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6742 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6746 else if (unformat (i, "del"))
6754 errmsg ("missing bridge domain");
6757 else if (ip_set == 0)
6759 errmsg ("missing IP address");
6762 else if (mac_set == 0)
6764 errmsg ("missing MAC address");
6768 M (BD_IP_MAC_ADD_DEL, mp);
6770 mp->bd_id = ntohl (bd_id);
6771 mp->is_ipv6 = is_ipv6;
6772 mp->is_add = is_add;
6774 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6776 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6777 clib_memcpy (mp->mac_address, macaddr, 6);
6784 api_tap_connect (vat_main_t * vam)
6786 unformat_input_t *i = vam->input;
6787 vl_api_tap_connect_t *mp;
6793 ip4_address_t ip4_address;
6795 int ip4_address_set = 0;
6796 ip6_address_t ip6_address;
6798 int ip6_address_set = 0;
6801 memset (mac_address, 0, sizeof (mac_address));
6803 /* Parse args required to build the message */
6804 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6806 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6810 else if (unformat (i, "random-mac"))
6812 else if (unformat (i, "tapname %s", &tap_name))
6814 else if (unformat (i, "tag %s", &tag))
6816 else if (unformat (i, "address %U/%d",
6817 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6818 ip4_address_set = 1;
6819 else if (unformat (i, "address %U/%d",
6820 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6821 ip6_address_set = 1;
6828 errmsg ("missing tap name");
6831 if (vec_len (tap_name) > 63)
6833 errmsg ("tap name too long");
6836 vec_add1 (tap_name, 0);
6838 if (vec_len (tag) > 63)
6840 errmsg ("tag too long");
6844 /* Construct the API message */
6845 M (TAP_CONNECT, mp);
6847 mp->use_random_mac = random_mac;
6848 clib_memcpy (mp->mac_address, mac_address, 6);
6849 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6851 clib_memcpy (mp->tag, tag, vec_len (tag));
6853 if (ip4_address_set)
6855 mp->ip4_address_set = 1;
6856 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6857 mp->ip4_mask_width = ip4_mask_width;
6859 if (ip6_address_set)
6861 mp->ip6_address_set = 1;
6862 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6863 mp->ip6_mask_width = ip6_mask_width;
6866 vec_free (tap_name);
6872 /* Wait for a reply... */
6878 api_tap_modify (vat_main_t * vam)
6880 unformat_input_t *i = vam->input;
6881 vl_api_tap_modify_t *mp;
6886 u32 sw_if_index = ~0;
6887 u8 sw_if_index_set = 0;
6890 memset (mac_address, 0, sizeof (mac_address));
6892 /* Parse args required to build the message */
6893 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6895 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6896 sw_if_index_set = 1;
6897 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6898 sw_if_index_set = 1;
6899 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6903 else if (unformat (i, "random-mac"))
6905 else if (unformat (i, "tapname %s", &tap_name))
6911 if (sw_if_index_set == 0)
6913 errmsg ("missing vpp interface name");
6918 errmsg ("missing tap name");
6921 if (vec_len (tap_name) > 63)
6923 errmsg ("tap name too long");
6925 vec_add1 (tap_name, 0);
6927 /* Construct the API message */
6930 mp->use_random_mac = random_mac;
6931 mp->sw_if_index = ntohl (sw_if_index);
6932 clib_memcpy (mp->mac_address, mac_address, 6);
6933 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6934 vec_free (tap_name);
6939 /* Wait for a reply... */
6945 api_tap_delete (vat_main_t * vam)
6947 unformat_input_t *i = vam->input;
6948 vl_api_tap_delete_t *mp;
6949 u32 sw_if_index = ~0;
6950 u8 sw_if_index_set = 0;
6953 /* Parse args required to build the message */
6954 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6956 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6957 sw_if_index_set = 1;
6958 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6959 sw_if_index_set = 1;
6964 if (sw_if_index_set == 0)
6966 errmsg ("missing vpp interface name");
6970 /* Construct the API message */
6973 mp->sw_if_index = ntohl (sw_if_index);
6978 /* Wait for a reply... */
6984 api_ip_add_del_route (vat_main_t * vam)
6986 unformat_input_t *i = vam->input;
6987 vl_api_ip_add_del_route_t *mp;
6988 u32 sw_if_index = ~0, vrf_id = 0;
6990 u8 is_local = 0, is_drop = 0;
6991 u8 is_unreach = 0, is_prohibit = 0;
6992 u8 create_vrf_if_needed = 0;
6994 u32 next_hop_weight = 1;
6996 u8 is_multipath = 0;
6998 u8 address_length_set = 0;
6999 u32 next_hop_table_id = 0;
7000 u32 resolve_attempts = 0;
7001 u32 dst_address_length = 0;
7002 u8 next_hop_set = 0;
7003 ip4_address_t v4_dst_address, v4_next_hop_address;
7004 ip6_address_t v6_dst_address, v6_next_hop_address;
7008 u32 random_add_del = 0;
7009 u32 *random_vector = 0;
7011 u32 random_seed = 0xdeaddabe;
7012 u32 classify_table_index = ~0;
7014 u8 resolve_host = 0, resolve_attached = 0;
7015 mpls_label_t *next_hop_out_label_stack = NULL;
7016 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7017 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7019 /* Parse args required to build the message */
7020 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7022 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7024 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7026 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
7031 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
7036 else if (unformat (i, "/%d", &dst_address_length))
7038 address_length_set = 1;
7041 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7042 &v4_next_hop_address))
7046 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7047 &v6_next_hop_address))
7051 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7053 else if (unformat (i, "weight %d", &next_hop_weight))
7055 else if (unformat (i, "drop"))
7059 else if (unformat (i, "null-send-unreach"))
7063 else if (unformat (i, "null-send-prohibit"))
7067 else if (unformat (i, "local"))
7071 else if (unformat (i, "classify %d", &classify_table_index))
7075 else if (unformat (i, "del"))
7077 else if (unformat (i, "add"))
7079 else if (unformat (i, "not-last"))
7081 else if (unformat (i, "resolve-via-host"))
7083 else if (unformat (i, "resolve-via-attached"))
7084 resolve_attached = 1;
7085 else if (unformat (i, "multipath"))
7087 else if (unformat (i, "vrf %d", &vrf_id))
7089 else if (unformat (i, "create-vrf"))
7090 create_vrf_if_needed = 1;
7091 else if (unformat (i, "count %d", &count))
7093 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7095 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7097 else if (unformat (i, "out-label %d", &next_hop_out_label))
7098 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7099 else if (unformat (i, "via-label %d", &next_hop_via_label))
7101 else if (unformat (i, "random"))
7103 else if (unformat (i, "seed %d", &random_seed))
7107 clib_warning ("parse error '%U'", format_unformat_error, i);
7112 if (!next_hop_set && !is_drop && !is_local &&
7113 !is_classify && !is_unreach && !is_prohibit &&
7114 MPLS_LABEL_INVALID == next_hop_via_label)
7117 ("next hop / local / drop / unreach / prohibit / classify not set");
7121 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7123 errmsg ("next hop and next-hop via label set");
7126 if (address_set == 0)
7128 errmsg ("missing addresses");
7132 if (address_length_set == 0)
7134 errmsg ("missing address length");
7138 /* Generate a pile of unique, random routes */
7141 u32 this_random_address;
7142 random_hash = hash_create (count, sizeof (uword));
7144 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7145 for (j = 0; j <= count; j++)
7149 this_random_address = random_u32 (&random_seed);
7150 this_random_address =
7151 clib_host_to_net_u32 (this_random_address);
7153 while (hash_get (random_hash, this_random_address));
7154 vec_add1 (random_vector, this_random_address);
7155 hash_set (random_hash, this_random_address, 1);
7157 hash_free (random_hash);
7158 v4_dst_address.as_u32 = random_vector[0];
7163 /* Turn on async mode */
7164 vam->async_mode = 1;
7165 vam->async_errors = 0;
7166 before = vat_time_now (vam);
7169 for (j = 0; j < count; j++)
7171 /* Construct the API message */
7172 M2 (IP_ADD_DEL_ROUTE, mp,
7173 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7175 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7176 mp->table_id = ntohl (vrf_id);
7177 mp->create_vrf_if_needed = create_vrf_if_needed;
7179 mp->is_add = is_add;
7180 mp->is_drop = is_drop;
7181 mp->is_unreach = is_unreach;
7182 mp->is_prohibit = is_prohibit;
7183 mp->is_ipv6 = is_ipv6;
7184 mp->is_local = is_local;
7185 mp->is_classify = is_classify;
7186 mp->is_multipath = is_multipath;
7187 mp->is_resolve_host = resolve_host;
7188 mp->is_resolve_attached = resolve_attached;
7189 mp->not_last = not_last;
7190 mp->next_hop_weight = next_hop_weight;
7191 mp->dst_address_length = dst_address_length;
7192 mp->next_hop_table_id = ntohl (next_hop_table_id);
7193 mp->classify_table_index = ntohl (classify_table_index);
7194 mp->next_hop_via_label = ntohl (next_hop_via_label);
7195 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7196 if (0 != mp->next_hop_n_out_labels)
7198 memcpy (mp->next_hop_out_label_stack,
7199 next_hop_out_label_stack,
7200 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7201 vec_free (next_hop_out_label_stack);
7206 clib_memcpy (mp->dst_address, &v6_dst_address,
7207 sizeof (v6_dst_address));
7209 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
7210 sizeof (v6_next_hop_address));
7211 increment_v6_address (&v6_dst_address);
7215 clib_memcpy (mp->dst_address, &v4_dst_address,
7216 sizeof (v4_dst_address));
7218 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
7219 sizeof (v4_next_hop_address));
7221 v4_dst_address.as_u32 = random_vector[j + 1];
7223 increment_v4_address (&v4_dst_address);
7227 /* If we receive SIGTERM, stop now... */
7232 /* When testing multiple add/del ops, use a control-ping to sync */
7235 vl_api_control_ping_t *mp_ping;
7239 /* Shut off async mode */
7240 vam->async_mode = 0;
7242 M (CONTROL_PING, mp_ping);
7245 timeout = vat_time_now (vam) + 1.0;
7246 while (vat_time_now (vam) < timeout)
7247 if (vam->result_ready == 1)
7252 if (vam->retval == -99)
7255 if (vam->async_errors > 0)
7257 errmsg ("%d asynchronous errors", vam->async_errors);
7260 vam->async_errors = 0;
7261 after = vat_time_now (vam);
7263 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7267 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7268 count, after - before, count / (after - before));
7274 /* Wait for a reply... */
7279 /* Return the good/bad news */
7280 return (vam->retval);
7284 api_ip_mroute_add_del (vat_main_t * vam)
7286 unformat_input_t *i = vam->input;
7287 vl_api_ip_mroute_add_del_t *mp;
7288 u32 sw_if_index = ~0, vrf_id = 0;
7291 u8 create_vrf_if_needed = 0;
7294 u32 grp_address_length = 0;
7295 ip4_address_t v4_grp_address, v4_src_address;
7296 ip6_address_t v6_grp_address, v6_src_address;
7297 mfib_itf_flags_t iflags = 0;
7298 mfib_entry_flags_t eflags = 0;
7301 /* Parse args required to build the message */
7302 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7304 if (unformat (i, "sw_if_index %d", &sw_if_index))
7306 else if (unformat (i, "%U %U",
7307 unformat_ip4_address, &v4_src_address,
7308 unformat_ip4_address, &v4_grp_address))
7310 grp_address_length = 64;
7314 else if (unformat (i, "%U %U",
7315 unformat_ip6_address, &v6_src_address,
7316 unformat_ip6_address, &v6_grp_address))
7318 grp_address_length = 256;
7322 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7324 memset (&v4_src_address, 0, sizeof (v4_src_address));
7325 grp_address_length = 32;
7329 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7331 memset (&v6_src_address, 0, sizeof (v6_src_address));
7332 grp_address_length = 128;
7336 else if (unformat (i, "/%d", &grp_address_length))
7338 else if (unformat (i, "local"))
7342 else if (unformat (i, "del"))
7344 else if (unformat (i, "add"))
7346 else if (unformat (i, "vrf %d", &vrf_id))
7348 else if (unformat (i, "create-vrf"))
7349 create_vrf_if_needed = 1;
7350 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7352 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7356 clib_warning ("parse error '%U'", format_unformat_error, i);
7361 if (address_set == 0)
7363 errmsg ("missing addresses\n");
7367 /* Construct the API message */
7368 M (IP_MROUTE_ADD_DEL, mp);
7370 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7371 mp->table_id = ntohl (vrf_id);
7372 mp->create_vrf_if_needed = create_vrf_if_needed;
7374 mp->is_add = is_add;
7375 mp->is_ipv6 = is_ipv6;
7376 mp->is_local = is_local;
7377 mp->itf_flags = ntohl (iflags);
7378 mp->entry_flags = ntohl (eflags);
7379 mp->grp_address_length = grp_address_length;
7380 mp->grp_address_length = ntohs (mp->grp_address_length);
7384 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7385 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7389 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7390 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7396 /* Wait for a reply... */
7402 api_mpls_route_add_del (vat_main_t * vam)
7404 unformat_input_t *i = vam->input;
7405 vl_api_mpls_route_add_del_t *mp;
7406 u32 sw_if_index = ~0, table_id = 0;
7407 u8 create_table_if_needed = 0;
7409 u32 next_hop_weight = 1;
7410 u8 is_multipath = 0;
7411 u32 next_hop_table_id = 0;
7412 u8 next_hop_set = 0;
7413 ip4_address_t v4_next_hop_address = {
7416 ip6_address_t v6_next_hop_address = { {0} };
7420 u32 classify_table_index = ~0;
7422 u8 resolve_host = 0, resolve_attached = 0;
7423 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7424 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7425 mpls_label_t *next_hop_out_label_stack = NULL;
7426 mpls_label_t local_label = MPLS_LABEL_INVALID;
7428 u8 next_hop_proto_is_ip4 = 1;
7430 /* Parse args required to build the message */
7431 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7433 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7435 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7437 else if (unformat (i, "%d", &local_label))
7439 else if (unformat (i, "eos"))
7441 else if (unformat (i, "non-eos"))
7443 else if (unformat (i, "via %U", unformat_ip4_address,
7444 &v4_next_hop_address))
7447 next_hop_proto_is_ip4 = 1;
7449 else if (unformat (i, "via %U", unformat_ip6_address,
7450 &v6_next_hop_address))
7453 next_hop_proto_is_ip4 = 0;
7455 else if (unformat (i, "weight %d", &next_hop_weight))
7457 else if (unformat (i, "create-table"))
7458 create_table_if_needed = 1;
7459 else if (unformat (i, "classify %d", &classify_table_index))
7463 else if (unformat (i, "del"))
7465 else if (unformat (i, "add"))
7467 else if (unformat (i, "resolve-via-host"))
7469 else if (unformat (i, "resolve-via-attached"))
7470 resolve_attached = 1;
7471 else if (unformat (i, "multipath"))
7473 else if (unformat (i, "count %d", &count))
7475 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
7478 next_hop_proto_is_ip4 = 1;
7480 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
7483 next_hop_proto_is_ip4 = 0;
7485 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7487 else if (unformat (i, "via-label %d", &next_hop_via_label))
7489 else if (unformat (i, "out-label %d", &next_hop_out_label))
7490 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7493 clib_warning ("parse error '%U'", format_unformat_error, i);
7498 if (!next_hop_set && !is_classify)
7500 errmsg ("next hop / classify not set");
7504 if (MPLS_LABEL_INVALID == local_label)
7506 errmsg ("missing label");
7512 /* Turn on async mode */
7513 vam->async_mode = 1;
7514 vam->async_errors = 0;
7515 before = vat_time_now (vam);
7518 for (j = 0; j < count; j++)
7520 /* Construct the API message */
7521 M2 (MPLS_ROUTE_ADD_DEL, mp,
7522 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7524 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
7525 mp->mr_table_id = ntohl (table_id);
7526 mp->mr_create_table_if_needed = create_table_if_needed;
7528 mp->mr_is_add = is_add;
7529 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7530 mp->mr_is_classify = is_classify;
7531 mp->mr_is_multipath = is_multipath;
7532 mp->mr_is_resolve_host = resolve_host;
7533 mp->mr_is_resolve_attached = resolve_attached;
7534 mp->mr_next_hop_weight = next_hop_weight;
7535 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
7536 mp->mr_classify_table_index = ntohl (classify_table_index);
7537 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
7538 mp->mr_label = ntohl (local_label);
7539 mp->mr_eos = is_eos;
7541 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7542 if (0 != mp->mr_next_hop_n_out_labels)
7544 memcpy (mp->mr_next_hop_out_label_stack,
7545 next_hop_out_label_stack,
7546 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7547 vec_free (next_hop_out_label_stack);
7552 if (next_hop_proto_is_ip4)
7554 clib_memcpy (mp->mr_next_hop,
7555 &v4_next_hop_address,
7556 sizeof (v4_next_hop_address));
7560 clib_memcpy (mp->mr_next_hop,
7561 &v6_next_hop_address,
7562 sizeof (v6_next_hop_address));
7569 /* If we receive SIGTERM, stop now... */
7574 /* When testing multiple add/del ops, use a control-ping to sync */
7577 vl_api_control_ping_t *mp_ping;
7581 /* Shut off async mode */
7582 vam->async_mode = 0;
7584 M (CONTROL_PING, mp_ping);
7587 timeout = vat_time_now (vam) + 1.0;
7588 while (vat_time_now (vam) < timeout)
7589 if (vam->result_ready == 1)
7594 if (vam->retval == -99)
7597 if (vam->async_errors > 0)
7599 errmsg ("%d asynchronous errors", vam->async_errors);
7602 vam->async_errors = 0;
7603 after = vat_time_now (vam);
7605 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7609 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7610 count, after - before, count / (after - before));
7616 /* Wait for a reply... */
7621 /* Return the good/bad news */
7622 return (vam->retval);
7626 api_mpls_ip_bind_unbind (vat_main_t * vam)
7628 unformat_input_t *i = vam->input;
7629 vl_api_mpls_ip_bind_unbind_t *mp;
7630 u32 ip_table_id = 0;
7631 u8 create_table_if_needed = 0;
7634 ip4_address_t v4_address;
7635 ip6_address_t v6_address;
7638 mpls_label_t local_label = MPLS_LABEL_INVALID;
7641 /* Parse args required to build the message */
7642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7644 if (unformat (i, "%U/%d", unformat_ip4_address,
7645 &v4_address, &address_length))
7650 else if (unformat (i, "%U/%d", unformat_ip6_address,
7651 &v6_address, &address_length))
7656 else if (unformat (i, "%d", &local_label))
7658 else if (unformat (i, "create-table"))
7659 create_table_if_needed = 1;
7660 else if (unformat (i, "table-id %d", &ip_table_id))
7662 else if (unformat (i, "unbind"))
7664 else if (unformat (i, "bind"))
7668 clib_warning ("parse error '%U'", format_unformat_error, i);
7675 errmsg ("IP addres not set");
7679 if (MPLS_LABEL_INVALID == local_label)
7681 errmsg ("missing label");
7685 /* Construct the API message */
7686 M (MPLS_IP_BIND_UNBIND, mp);
7688 mp->mb_create_table_if_needed = create_table_if_needed;
7689 mp->mb_is_bind = is_bind;
7690 mp->mb_is_ip4 = is_ip4;
7691 mp->mb_ip_table_id = ntohl (ip_table_id);
7692 mp->mb_mpls_table_id = 0;
7693 mp->mb_label = ntohl (local_label);
7694 mp->mb_address_length = address_length;
7697 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7699 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7704 /* Wait for a reply... */
7710 api_proxy_arp_add_del (vat_main_t * vam)
7712 unformat_input_t *i = vam->input;
7713 vl_api_proxy_arp_add_del_t *mp;
7716 ip4_address_t lo, hi;
7720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7722 if (unformat (i, "vrf %d", &vrf_id))
7724 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7725 unformat_ip4_address, &hi))
7727 else if (unformat (i, "del"))
7731 clib_warning ("parse error '%U'", format_unformat_error, i);
7738 errmsg ("address range not set");
7742 M (PROXY_ARP_ADD_DEL, mp);
7744 mp->vrf_id = ntohl (vrf_id);
7745 mp->is_add = is_add;
7746 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7747 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7755 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7757 unformat_input_t *i = vam->input;
7758 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7761 u8 sw_if_index_set = 0;
7764 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7766 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7767 sw_if_index_set = 1;
7768 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7769 sw_if_index_set = 1;
7770 else if (unformat (i, "enable"))
7772 else if (unformat (i, "disable"))
7776 clib_warning ("parse error '%U'", format_unformat_error, i);
7781 if (sw_if_index_set == 0)
7783 errmsg ("missing interface name or sw_if_index");
7787 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7789 mp->sw_if_index = ntohl (sw_if_index);
7790 mp->enable_disable = enable;
7798 api_mpls_tunnel_add_del (vat_main_t * vam)
7800 unformat_input_t *i = vam->input;
7801 vl_api_mpls_tunnel_add_del_t *mp;
7805 u32 sw_if_index = ~0;
7806 u32 next_hop_sw_if_index = ~0;
7807 u32 next_hop_proto_is_ip4 = 1;
7809 u32 next_hop_table_id = 0;
7810 ip4_address_t v4_next_hop_address = {
7813 ip6_address_t v6_next_hop_address = { {0} };
7814 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7817 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7819 if (unformat (i, "add"))
7821 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7823 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7825 else if (unformat (i, "via %U",
7826 unformat_ip4_address, &v4_next_hop_address))
7828 next_hop_proto_is_ip4 = 1;
7830 else if (unformat (i, "via %U",
7831 unformat_ip6_address, &v6_next_hop_address))
7833 next_hop_proto_is_ip4 = 0;
7835 else if (unformat (i, "l2-only"))
7837 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7839 else if (unformat (i, "out-label %d", &next_hop_out_label))
7840 vec_add1 (labels, ntohl (next_hop_out_label));
7843 clib_warning ("parse error '%U'", format_unformat_error, i);
7848 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7850 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7851 mp->mt_sw_if_index = ntohl (sw_if_index);
7852 mp->mt_is_add = is_add;
7853 mp->mt_l2_only = l2_only;
7854 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7855 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7857 mp->mt_next_hop_n_out_labels = vec_len (labels);
7859 if (0 != mp->mt_next_hop_n_out_labels)
7861 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7862 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7866 if (next_hop_proto_is_ip4)
7868 clib_memcpy (mp->mt_next_hop,
7869 &v4_next_hop_address, sizeof (v4_next_hop_address));
7873 clib_memcpy (mp->mt_next_hop,
7874 &v6_next_hop_address, sizeof (v6_next_hop_address));
7883 api_sw_interface_set_unnumbered (vat_main_t * vam)
7885 unformat_input_t *i = vam->input;
7886 vl_api_sw_interface_set_unnumbered_t *mp;
7888 u32 unnum_sw_index = ~0;
7890 u8 sw_if_index_set = 0;
7893 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7895 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7896 sw_if_index_set = 1;
7897 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7898 sw_if_index_set = 1;
7899 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7901 else if (unformat (i, "del"))
7905 clib_warning ("parse error '%U'", format_unformat_error, i);
7910 if (sw_if_index_set == 0)
7912 errmsg ("missing interface name or sw_if_index");
7916 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7918 mp->sw_if_index = ntohl (sw_if_index);
7919 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7920 mp->is_add = is_add;
7928 api_ip_neighbor_add_del (vat_main_t * vam)
7930 unformat_input_t *i = vam->input;
7931 vl_api_ip_neighbor_add_del_t *mp;
7933 u8 sw_if_index_set = 0;
7936 u8 is_no_fib_entry = 0;
7939 u8 v4_address_set = 0;
7940 u8 v6_address_set = 0;
7941 ip4_address_t v4address;
7942 ip6_address_t v6address;
7945 memset (mac_address, 0, sizeof (mac_address));
7947 /* Parse args required to build the message */
7948 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7950 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7954 else if (unformat (i, "del"))
7957 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7958 sw_if_index_set = 1;
7959 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7960 sw_if_index_set = 1;
7961 else if (unformat (i, "is_static"))
7963 else if (unformat (i, "no-fib-entry"))
7964 is_no_fib_entry = 1;
7965 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7967 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7971 clib_warning ("parse error '%U'", format_unformat_error, i);
7976 if (sw_if_index_set == 0)
7978 errmsg ("missing interface name or sw_if_index");
7981 if (v4_address_set && v6_address_set)
7983 errmsg ("both v4 and v6 addresses set");
7986 if (!v4_address_set && !v6_address_set)
7988 errmsg ("no address set");
7992 /* Construct the API message */
7993 M (IP_NEIGHBOR_ADD_DEL, mp);
7995 mp->sw_if_index = ntohl (sw_if_index);
7996 mp->is_add = is_add;
7997 mp->is_static = is_static;
7998 mp->is_no_adj_fib = is_no_fib_entry;
8000 clib_memcpy (mp->mac_address, mac_address, 6);
8004 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
8008 /* mp->is_ipv6 = 0; via memset in M macro above */
8009 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
8015 /* Wait for a reply, return good/bad news */
8021 api_reset_vrf (vat_main_t * vam)
8023 unformat_input_t *i = vam->input;
8024 vl_api_reset_vrf_t *mp;
8030 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8032 if (unformat (i, "vrf %d", &vrf_id))
8034 else if (unformat (i, "ipv6"))
8038 clib_warning ("parse error '%U'", format_unformat_error, i);
8043 if (vrf_id_set == 0)
8045 errmsg ("missing vrf id");
8051 mp->vrf_id = ntohl (vrf_id);
8052 mp->is_ipv6 = is_ipv6;
8060 api_create_vlan_subif (vat_main_t * vam)
8062 unformat_input_t *i = vam->input;
8063 vl_api_create_vlan_subif_t *mp;
8065 u8 sw_if_index_set = 0;
8070 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8072 if (unformat (i, "sw_if_index %d", &sw_if_index))
8073 sw_if_index_set = 1;
8075 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8076 sw_if_index_set = 1;
8077 else if (unformat (i, "vlan %d", &vlan_id))
8081 clib_warning ("parse error '%U'", format_unformat_error, i);
8086 if (sw_if_index_set == 0)
8088 errmsg ("missing interface name or sw_if_index");
8092 if (vlan_id_set == 0)
8094 errmsg ("missing vlan_id");
8097 M (CREATE_VLAN_SUBIF, mp);
8099 mp->sw_if_index = ntohl (sw_if_index);
8100 mp->vlan_id = ntohl (vlan_id);
8107 #define foreach_create_subif_bit \
8114 _(outer_vlan_id_any) \
8115 _(inner_vlan_id_any)
8118 api_create_subif (vat_main_t * vam)
8120 unformat_input_t *i = vam->input;
8121 vl_api_create_subif_t *mp;
8123 u8 sw_if_index_set = 0;
8130 u32 exact_match = 0;
8131 u32 default_sub = 0;
8132 u32 outer_vlan_id_any = 0;
8133 u32 inner_vlan_id_any = 0;
8135 u16 outer_vlan_id = 0;
8136 u16 inner_vlan_id = 0;
8139 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8141 if (unformat (i, "sw_if_index %d", &sw_if_index))
8142 sw_if_index_set = 1;
8144 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8145 sw_if_index_set = 1;
8146 else if (unformat (i, "sub_id %d", &sub_id))
8148 else if (unformat (i, "outer_vlan_id %d", &tmp))
8149 outer_vlan_id = tmp;
8150 else if (unformat (i, "inner_vlan_id %d", &tmp))
8151 inner_vlan_id = tmp;
8153 #define _(a) else if (unformat (i, #a)) a = 1 ;
8154 foreach_create_subif_bit
8158 clib_warning ("parse error '%U'", format_unformat_error, i);
8163 if (sw_if_index_set == 0)
8165 errmsg ("missing interface name or sw_if_index");
8169 if (sub_id_set == 0)
8171 errmsg ("missing sub_id");
8174 M (CREATE_SUBIF, mp);
8176 mp->sw_if_index = ntohl (sw_if_index);
8177 mp->sub_id = ntohl (sub_id);
8179 #define _(a) mp->a = a;
8180 foreach_create_subif_bit;
8183 mp->outer_vlan_id = ntohs (outer_vlan_id);
8184 mp->inner_vlan_id = ntohs (inner_vlan_id);
8192 api_oam_add_del (vat_main_t * vam)
8194 unformat_input_t *i = vam->input;
8195 vl_api_oam_add_del_t *mp;
8198 ip4_address_t src, dst;
8203 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8205 if (unformat (i, "vrf %d", &vrf_id))
8207 else if (unformat (i, "src %U", unformat_ip4_address, &src))
8209 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
8211 else if (unformat (i, "del"))
8215 clib_warning ("parse error '%U'", format_unformat_error, i);
8222 errmsg ("missing src addr");
8228 errmsg ("missing dst addr");
8232 M (OAM_ADD_DEL, mp);
8234 mp->vrf_id = ntohl (vrf_id);
8235 mp->is_add = is_add;
8236 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
8237 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8245 api_reset_fib (vat_main_t * vam)
8247 unformat_input_t *i = vam->input;
8248 vl_api_reset_fib_t *mp;
8254 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8256 if (unformat (i, "vrf %d", &vrf_id))
8258 else if (unformat (i, "ipv6"))
8262 clib_warning ("parse error '%U'", format_unformat_error, i);
8267 if (vrf_id_set == 0)
8269 errmsg ("missing vrf id");
8275 mp->vrf_id = ntohl (vrf_id);
8276 mp->is_ipv6 = is_ipv6;
8284 api_dhcp_proxy_config (vat_main_t * vam)
8286 unformat_input_t *i = vam->input;
8287 vl_api_dhcp_proxy_config_t *mp;
8289 u32 server_vrf_id = 0;
8291 u8 v4_address_set = 0;
8292 u8 v6_address_set = 0;
8293 ip4_address_t v4address;
8294 ip6_address_t v6address;
8295 u8 v4_src_address_set = 0;
8296 u8 v6_src_address_set = 0;
8297 ip4_address_t v4srcaddress;
8298 ip6_address_t v6srcaddress;
8301 /* Parse args required to build the message */
8302 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8304 if (unformat (i, "del"))
8306 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8308 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8310 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8312 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8314 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8315 v4_src_address_set = 1;
8316 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8317 v6_src_address_set = 1;
8322 if (v4_address_set && v6_address_set)
8324 errmsg ("both v4 and v6 server addresses set");
8327 if (!v4_address_set && !v6_address_set)
8329 errmsg ("no server addresses set");
8333 if (v4_src_address_set && v6_src_address_set)
8335 errmsg ("both v4 and v6 src addresses set");
8338 if (!v4_src_address_set && !v6_src_address_set)
8340 errmsg ("no src addresses set");
8344 if (!(v4_src_address_set && v4_address_set) &&
8345 !(v6_src_address_set && v6_address_set))
8347 errmsg ("no matching server and src addresses set");
8351 /* Construct the API message */
8352 M (DHCP_PROXY_CONFIG, mp);
8354 mp->is_add = is_add;
8355 mp->rx_vrf_id = ntohl (rx_vrf_id);
8356 mp->server_vrf_id = ntohl (server_vrf_id);
8360 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
8361 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
8365 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
8366 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
8372 /* Wait for a reply, return good/bad news */
8377 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
8378 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
8381 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
8383 vat_main_t *vam = &vat_main;
8384 u32 i, count = mp->count;
8385 vl_api_dhcp_server_t *s;
8389 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8390 ntohl (mp->rx_vrf_id),
8391 format_ip6_address, mp->dhcp_src_address,
8392 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8395 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8396 ntohl (mp->rx_vrf_id),
8397 format_ip4_address, mp->dhcp_src_address,
8398 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8400 for (i = 0; i < count; i++)
8402 s = &mp->servers[i];
8406 " Server Table-ID %d, Server Address %U",
8407 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
8410 " Server Table-ID %d, Server Address %U",
8411 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
8415 static void vl_api_dhcp_proxy_details_t_handler_json
8416 (vl_api_dhcp_proxy_details_t * mp)
8418 vat_main_t *vam = &vat_main;
8419 vat_json_node_t *node = NULL;
8420 u32 i, count = mp->count;
8422 struct in6_addr ip6;
8423 vl_api_dhcp_server_t *s;
8425 if (VAT_JSON_ARRAY != vam->json_tree.type)
8427 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8428 vat_json_init_array (&vam->json_tree);
8430 node = vat_json_array_add (&vam->json_tree);
8432 vat_json_init_object (node);
8433 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
8434 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
8435 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
8439 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
8440 vat_json_object_add_ip6 (node, "src_address", ip6);
8444 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
8445 vat_json_object_add_ip4 (node, "src_address", ip4);
8448 for (i = 0; i < count; i++)
8450 s = &mp->servers[i];
8452 vat_json_object_add_uint (node, "server-table-id",
8453 ntohl (s->server_vrf_id));
8457 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
8458 vat_json_object_add_ip4 (node, "src_address", ip4);
8462 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
8463 vat_json_object_add_ip6 (node, "server_address", ip6);
8469 api_dhcp_proxy_dump (vat_main_t * vam)
8471 unformat_input_t *i = vam->input;
8472 vl_api_control_ping_t *mp_ping;
8473 vl_api_dhcp_proxy_dump_t *mp;
8477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8479 if (unformat (i, "ipv6"))
8483 clib_warning ("parse error '%U'", format_unformat_error, i);
8488 M (DHCP_PROXY_DUMP, mp);
8490 mp->is_ip6 = is_ipv6;
8493 /* Use a control ping for synchronization */
8494 M (CONTROL_PING, mp_ping);
8502 api_dhcp_proxy_set_vss (vat_main_t * vam)
8504 unformat_input_t *i = vam->input;
8505 vl_api_dhcp_proxy_set_vss_t *mp;
8516 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8518 if (unformat (i, "tbl_id %d", &tbl_id))
8520 if (unformat (i, "fib_id %d", &fib_id))
8522 if (unformat (i, "oui %d", &oui))
8524 else if (unformat (i, "ipv6"))
8526 else if (unformat (i, "del"))
8530 clib_warning ("parse error '%U'", format_unformat_error, i);
8535 if (tbl_id_set == 0)
8537 errmsg ("missing tbl id");
8541 if (fib_id_set == 0)
8543 errmsg ("missing fib id");
8548 errmsg ("missing oui");
8552 M (DHCP_PROXY_SET_VSS, mp);
8553 mp->tbl_id = ntohl (tbl_id);
8554 mp->fib_id = ntohl (fib_id);
8555 mp->oui = ntohl (oui);
8556 mp->is_ipv6 = is_ipv6;
8557 mp->is_add = is_add;
8565 api_dhcp_client_config (vat_main_t * vam)
8567 unformat_input_t *i = vam->input;
8568 vl_api_dhcp_client_config_t *mp;
8570 u8 sw_if_index_set = 0;
8573 u8 disable_event = 0;
8576 /* Parse args required to build the message */
8577 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8579 if (unformat (i, "del"))
8582 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8583 sw_if_index_set = 1;
8584 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8585 sw_if_index_set = 1;
8586 else if (unformat (i, "hostname %s", &hostname))
8588 else if (unformat (i, "disable_event"))
8594 if (sw_if_index_set == 0)
8596 errmsg ("missing interface name or sw_if_index");
8600 if (vec_len (hostname) > 63)
8602 errmsg ("hostname too long");
8604 vec_add1 (hostname, 0);
8606 /* Construct the API message */
8607 M (DHCP_CLIENT_CONFIG, mp);
8609 mp->sw_if_index = htonl (sw_if_index);
8610 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
8611 vec_free (hostname);
8612 mp->is_add = is_add;
8613 mp->want_dhcp_event = disable_event ? 0 : 1;
8614 mp->pid = htonl (getpid ());
8619 /* Wait for a reply, return good/bad news */
8625 api_set_ip_flow_hash (vat_main_t * vam)
8627 unformat_input_t *i = vam->input;
8628 vl_api_set_ip_flow_hash_t *mp;
8640 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8642 if (unformat (i, "vrf %d", &vrf_id))
8644 else if (unformat (i, "ipv6"))
8646 else if (unformat (i, "src"))
8648 else if (unformat (i, "dst"))
8650 else if (unformat (i, "sport"))
8652 else if (unformat (i, "dport"))
8654 else if (unformat (i, "proto"))
8656 else if (unformat (i, "reverse"))
8661 clib_warning ("parse error '%U'", format_unformat_error, i);
8666 if (vrf_id_set == 0)
8668 errmsg ("missing vrf id");
8672 M (SET_IP_FLOW_HASH, mp);
8678 mp->reverse = reverse;
8679 mp->vrf_id = ntohl (vrf_id);
8680 mp->is_ipv6 = is_ipv6;
8688 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8690 unformat_input_t *i = vam->input;
8691 vl_api_sw_interface_ip6_enable_disable_t *mp;
8693 u8 sw_if_index_set = 0;
8697 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8699 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8700 sw_if_index_set = 1;
8701 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8702 sw_if_index_set = 1;
8703 else if (unformat (i, "enable"))
8705 else if (unformat (i, "disable"))
8709 clib_warning ("parse error '%U'", format_unformat_error, i);
8714 if (sw_if_index_set == 0)
8716 errmsg ("missing interface name or sw_if_index");
8720 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8722 mp->sw_if_index = ntohl (sw_if_index);
8723 mp->enable = enable;
8731 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8733 unformat_input_t *i = vam->input;
8734 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8736 u8 sw_if_index_set = 0;
8737 u8 v6_address_set = 0;
8738 ip6_address_t v6address;
8741 /* Parse args required to build the message */
8742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8744 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8745 sw_if_index_set = 1;
8746 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8747 sw_if_index_set = 1;
8748 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8754 if (sw_if_index_set == 0)
8756 errmsg ("missing interface name or sw_if_index");
8759 if (!v6_address_set)
8761 errmsg ("no address set");
8765 /* Construct the API message */
8766 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8768 mp->sw_if_index = ntohl (sw_if_index);
8769 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8774 /* Wait for a reply, return good/bad news */
8780 api_ip6nd_proxy_add_del (vat_main_t * vam)
8782 unformat_input_t *i = vam->input;
8783 vl_api_ip6nd_proxy_add_del_t *mp;
8784 u32 sw_if_index = ~0;
8785 u8 v6_address_set = 0;
8786 ip6_address_t v6address;
8790 /* Parse args required to build the message */
8791 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8793 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8795 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8797 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8799 if (unformat (i, "del"))
8803 clib_warning ("parse error '%U'", format_unformat_error, i);
8808 if (sw_if_index == ~0)
8810 errmsg ("missing interface name or sw_if_index");
8813 if (!v6_address_set)
8815 errmsg ("no address set");
8819 /* Construct the API message */
8820 M (IP6ND_PROXY_ADD_DEL, mp);
8822 mp->is_del = is_del;
8823 mp->sw_if_index = ntohl (sw_if_index);
8824 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8829 /* Wait for a reply, return good/bad news */
8835 api_ip6nd_proxy_dump (vat_main_t * vam)
8837 vl_api_ip6nd_proxy_dump_t *mp;
8838 vl_api_control_ping_t *mp_ping;
8841 M (IP6ND_PROXY_DUMP, mp);
8845 /* Use a control ping for synchronization */
8846 M (CONTROL_PING, mp_ping);
8853 static void vl_api_ip6nd_proxy_details_t_handler
8854 (vl_api_ip6nd_proxy_details_t * mp)
8856 vat_main_t *vam = &vat_main;
8858 print (vam->ofp, "host %U sw_if_index %d",
8859 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
8862 static void vl_api_ip6nd_proxy_details_t_handler_json
8863 (vl_api_ip6nd_proxy_details_t * mp)
8865 vat_main_t *vam = &vat_main;
8866 struct in6_addr ip6;
8867 vat_json_node_t *node = NULL;
8869 if (VAT_JSON_ARRAY != vam->json_tree.type)
8871 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8872 vat_json_init_array (&vam->json_tree);
8874 node = vat_json_array_add (&vam->json_tree);
8876 vat_json_init_object (node);
8877 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
8879 clib_memcpy (&ip6, mp->address, sizeof (ip6));
8880 vat_json_object_add_ip6 (node, "host", ip6);
8884 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8886 unformat_input_t *i = vam->input;
8887 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8889 u8 sw_if_index_set = 0;
8890 u32 address_length = 0;
8891 u8 v6_address_set = 0;
8892 ip6_address_t v6address;
8894 u8 no_advertise = 0;
8896 u8 no_autoconfig = 0;
8899 u32 val_lifetime = 0;
8900 u32 pref_lifetime = 0;
8903 /* Parse args required to build the message */
8904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8906 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8907 sw_if_index_set = 1;
8908 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8909 sw_if_index_set = 1;
8910 else if (unformat (i, "%U/%d",
8911 unformat_ip6_address, &v6address, &address_length))
8913 else if (unformat (i, "val_life %d", &val_lifetime))
8915 else if (unformat (i, "pref_life %d", &pref_lifetime))
8917 else if (unformat (i, "def"))
8919 else if (unformat (i, "noadv"))
8921 else if (unformat (i, "offl"))
8923 else if (unformat (i, "noauto"))
8925 else if (unformat (i, "nolink"))
8927 else if (unformat (i, "isno"))
8931 clib_warning ("parse error '%U'", format_unformat_error, i);
8936 if (sw_if_index_set == 0)
8938 errmsg ("missing interface name or sw_if_index");
8941 if (!v6_address_set)
8943 errmsg ("no address set");
8947 /* Construct the API message */
8948 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8950 mp->sw_if_index = ntohl (sw_if_index);
8951 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8952 mp->address_length = address_length;
8953 mp->use_default = use_default;
8954 mp->no_advertise = no_advertise;
8955 mp->off_link = off_link;
8956 mp->no_autoconfig = no_autoconfig;
8957 mp->no_onlink = no_onlink;
8959 mp->val_lifetime = ntohl (val_lifetime);
8960 mp->pref_lifetime = ntohl (pref_lifetime);
8965 /* Wait for a reply, return good/bad news */
8971 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8973 unformat_input_t *i = vam->input;
8974 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8976 u8 sw_if_index_set = 0;
8981 u8 send_unicast = 0;
8984 u8 default_router = 0;
8985 u32 max_interval = 0;
8986 u32 min_interval = 0;
8988 u32 initial_count = 0;
8989 u32 initial_interval = 0;
8993 /* Parse args required to build the message */
8994 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8996 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8997 sw_if_index_set = 1;
8998 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8999 sw_if_index_set = 1;
9000 else if (unformat (i, "maxint %d", &max_interval))
9002 else if (unformat (i, "minint %d", &min_interval))
9004 else if (unformat (i, "life %d", &lifetime))
9006 else if (unformat (i, "count %d", &initial_count))
9008 else if (unformat (i, "interval %d", &initial_interval))
9010 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9012 else if (unformat (i, "managed"))
9014 else if (unformat (i, "other"))
9016 else if (unformat (i, "ll"))
9018 else if (unformat (i, "send"))
9020 else if (unformat (i, "cease"))
9022 else if (unformat (i, "isno"))
9024 else if (unformat (i, "def"))
9028 clib_warning ("parse error '%U'", format_unformat_error, i);
9033 if (sw_if_index_set == 0)
9035 errmsg ("missing interface name or sw_if_index");
9039 /* Construct the API message */
9040 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9042 mp->sw_if_index = ntohl (sw_if_index);
9043 mp->max_interval = ntohl (max_interval);
9044 mp->min_interval = ntohl (min_interval);
9045 mp->lifetime = ntohl (lifetime);
9046 mp->initial_count = ntohl (initial_count);
9047 mp->initial_interval = ntohl (initial_interval);
9048 mp->suppress = suppress;
9049 mp->managed = managed;
9051 mp->ll_option = ll_option;
9052 mp->send_unicast = send_unicast;
9055 mp->default_router = default_router;
9060 /* Wait for a reply, return good/bad news */
9066 api_set_arp_neighbor_limit (vat_main_t * vam)
9068 unformat_input_t *i = vam->input;
9069 vl_api_set_arp_neighbor_limit_t *mp;
9075 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9077 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9079 else if (unformat (i, "ipv6"))
9083 clib_warning ("parse error '%U'", format_unformat_error, i);
9090 errmsg ("missing limit value");
9094 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9096 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9097 mp->is_ipv6 = is_ipv6;
9105 api_l2_patch_add_del (vat_main_t * vam)
9107 unformat_input_t *i = vam->input;
9108 vl_api_l2_patch_add_del_t *mp;
9110 u8 rx_sw_if_index_set = 0;
9112 u8 tx_sw_if_index_set = 0;
9116 /* Parse args required to build the message */
9117 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9119 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9120 rx_sw_if_index_set = 1;
9121 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9122 tx_sw_if_index_set = 1;
9123 else if (unformat (i, "rx"))
9125 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9127 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9129 rx_sw_if_index_set = 1;
9134 else if (unformat (i, "tx"))
9136 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9138 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9140 tx_sw_if_index_set = 1;
9145 else if (unformat (i, "del"))
9151 if (rx_sw_if_index_set == 0)
9153 errmsg ("missing rx interface name or rx_sw_if_index");
9157 if (tx_sw_if_index_set == 0)
9159 errmsg ("missing tx interface name or tx_sw_if_index");
9163 M (L2_PATCH_ADD_DEL, mp);
9165 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9166 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9167 mp->is_add = is_add;
9175 u8 localsid_addr[16];
9184 api_sr_localsid_add_del (vat_main_t * vam)
9186 unformat_input_t *i = vam->input;
9187 vl_api_sr_localsid_add_del_t *mp;
9190 ip6_address_t localsid;
9194 u32 fib_table = ~(u32) 0;
9195 ip6_address_t next_hop;
9197 bool nexthop_set = 0;
9201 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9203 if (unformat (i, "del"))
9205 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9206 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
9208 else if (unformat (i, "behavior %u", &behavior));
9209 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9210 else if (unformat (i, "fib-table %u", &fib_table));
9211 else if (unformat (i, "end.psp %u", &behavior));
9216 M (SR_LOCALSID_ADD_DEL, mp);
9218 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
9220 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
9221 mp->behavior = behavior;
9222 mp->sw_if_index = ntohl (sw_if_index);
9223 mp->fib_table = ntohl (fib_table);
9224 mp->end_psp = end_psp;
9225 mp->is_del = is_del;
9233 api_ioam_enable (vat_main_t * vam)
9235 unformat_input_t *input = vam->input;
9236 vl_api_ioam_enable_t *mp;
9238 int has_trace_option = 0;
9239 int has_pot_option = 0;
9240 int has_seqno_option = 0;
9241 int has_analyse_option = 0;
9244 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9246 if (unformat (input, "trace"))
9247 has_trace_option = 1;
9248 else if (unformat (input, "pot"))
9250 else if (unformat (input, "seqno"))
9251 has_seqno_option = 1;
9252 else if (unformat (input, "analyse"))
9253 has_analyse_option = 1;
9257 M (IOAM_ENABLE, mp);
9258 mp->id = htons (id);
9259 mp->seqno = has_seqno_option;
9260 mp->analyse = has_analyse_option;
9261 mp->pot_enable = has_pot_option;
9262 mp->trace_enable = has_trace_option;
9271 api_ioam_disable (vat_main_t * vam)
9273 vl_api_ioam_disable_t *mp;
9276 M (IOAM_DISABLE, mp);
9282 #define foreach_tcp_proto_field \
9286 #define foreach_udp_proto_field \
9290 #define foreach_ip4_proto_field \
9302 u16 src_port, dst_port;
9305 #if VPP_API_TEST_BUILTIN == 0
9307 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9309 u8 **maskp = va_arg (*args, u8 **);
9311 u8 found_something = 0;
9314 #define _(a) u8 a=0;
9315 foreach_tcp_proto_field;
9318 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9321 #define _(a) else if (unformat (input, #a)) a=1;
9322 foreach_tcp_proto_field
9328 #define _(a) found_something += a;
9329 foreach_tcp_proto_field;
9332 if (found_something == 0)
9335 vec_validate (mask, sizeof (*tcp) - 1);
9337 tcp = (tcp_header_t *) mask;
9339 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9340 foreach_tcp_proto_field;
9348 unformat_udp_mask (unformat_input_t * input, va_list * args)
9350 u8 **maskp = va_arg (*args, u8 **);
9352 u8 found_something = 0;
9355 #define _(a) u8 a=0;
9356 foreach_udp_proto_field;
9359 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9362 #define _(a) else if (unformat (input, #a)) a=1;
9363 foreach_udp_proto_field
9369 #define _(a) found_something += a;
9370 foreach_udp_proto_field;
9373 if (found_something == 0)
9376 vec_validate (mask, sizeof (*udp) - 1);
9378 udp = (udp_header_t *) mask;
9380 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
9381 foreach_udp_proto_field;
9389 unformat_l4_mask (unformat_input_t * input, va_list * args)
9391 u8 **maskp = va_arg (*args, u8 **);
9392 u16 src_port = 0, dst_port = 0;
9393 tcpudp_header_t *tcpudp;
9395 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9397 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9399 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9401 else if (unformat (input, "src_port"))
9403 else if (unformat (input, "dst_port"))
9409 if (!src_port && !dst_port)
9413 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9415 tcpudp = (tcpudp_header_t *) mask;
9416 tcpudp->src_port = src_port;
9417 tcpudp->dst_port = dst_port;
9425 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9427 u8 **maskp = va_arg (*args, u8 **);
9429 u8 found_something = 0;
9432 #define _(a) u8 a=0;
9433 foreach_ip4_proto_field;
9439 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9441 if (unformat (input, "version"))
9443 else if (unformat (input, "hdr_length"))
9445 else if (unformat (input, "src"))
9447 else if (unformat (input, "dst"))
9449 else if (unformat (input, "proto"))
9452 #define _(a) else if (unformat (input, #a)) a=1;
9453 foreach_ip4_proto_field
9459 #define _(a) found_something += a;
9460 foreach_ip4_proto_field;
9463 if (found_something == 0)
9466 vec_validate (mask, sizeof (*ip) - 1);
9468 ip = (ip4_header_t *) mask;
9470 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9471 foreach_ip4_proto_field;
9474 ip->ip_version_and_header_length = 0;
9477 ip->ip_version_and_header_length |= 0xF0;
9480 ip->ip_version_and_header_length |= 0x0F;
9486 #define foreach_ip6_proto_field \
9494 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9496 u8 **maskp = va_arg (*args, u8 **);
9498 u8 found_something = 0;
9500 u32 ip_version_traffic_class_and_flow_label;
9502 #define _(a) u8 a=0;
9503 foreach_ip6_proto_field;
9506 u8 traffic_class = 0;
9509 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9511 if (unformat (input, "version"))
9513 else if (unformat (input, "traffic-class"))
9515 else if (unformat (input, "flow-label"))
9517 else if (unformat (input, "src"))
9519 else if (unformat (input, "dst"))
9521 else if (unformat (input, "proto"))
9524 #define _(a) else if (unformat (input, #a)) a=1;
9525 foreach_ip6_proto_field
9531 #define _(a) found_something += a;
9532 foreach_ip6_proto_field;
9535 if (found_something == 0)
9538 vec_validate (mask, sizeof (*ip) - 1);
9540 ip = (ip6_header_t *) mask;
9542 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9543 foreach_ip6_proto_field;
9546 ip_version_traffic_class_and_flow_label = 0;
9549 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9552 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9555 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9557 ip->ip_version_traffic_class_and_flow_label =
9558 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9565 unformat_l3_mask (unformat_input_t * input, va_list * args)
9567 u8 **maskp = va_arg (*args, u8 **);
9569 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9571 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9573 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9582 unformat_l2_mask (unformat_input_t * input, va_list * args)
9584 u8 **maskp = va_arg (*args, u8 **);
9599 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9601 if (unformat (input, "src"))
9603 else if (unformat (input, "dst"))
9605 else if (unformat (input, "proto"))
9607 else if (unformat (input, "tag1"))
9609 else if (unformat (input, "tag2"))
9611 else if (unformat (input, "ignore-tag1"))
9613 else if (unformat (input, "ignore-tag2"))
9615 else if (unformat (input, "cos1"))
9617 else if (unformat (input, "cos2"))
9619 else if (unformat (input, "dot1q"))
9621 else if (unformat (input, "dot1ad"))
9626 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9627 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9630 if (tag1 || ignore_tag1 || cos1 || dot1q)
9632 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9635 vec_validate (mask, len - 1);
9638 memset (mask, 0xff, 6);
9641 memset (mask + 6, 0xff, 6);
9645 /* inner vlan tag */
9654 mask[21] = mask[20] = 0xff;
9675 mask[16] = mask[17] = 0xff;
9685 mask[12] = mask[13] = 0xff;
9692 unformat_classify_mask (unformat_input_t * input, va_list * args)
9694 u8 **maskp = va_arg (*args, u8 **);
9695 u32 *skipp = va_arg (*args, u32 *);
9696 u32 *matchp = va_arg (*args, u32 *);
9704 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9706 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9708 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9710 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9712 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9726 if (mask || l2 || l3 || l4)
9730 /* "With a free Ethernet header in every package" */
9732 vec_validate (l2, 13);
9736 vec_append (mask, l3);
9741 vec_append (mask, l4);
9746 /* Scan forward looking for the first significant mask octet */
9747 for (i = 0; i < vec_len (mask); i++)
9751 /* compute (skip, match) params */
9752 *skipp = i / sizeof (u32x4);
9753 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9755 /* Pad mask to an even multiple of the vector size */
9756 while (vec_len (mask) % sizeof (u32x4))
9759 match = vec_len (mask) / sizeof (u32x4);
9761 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9763 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9764 if (*tmp || *(tmp + 1))
9769 clib_warning ("BUG: match 0");
9771 _vec_len (mask) = match * sizeof (u32x4);
9781 #endif /* VPP_API_TEST_BUILTIN */
9783 #define foreach_l2_next \
9785 _(ethernet, ETHERNET_INPUT) \
9790 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9792 u32 *miss_next_indexp = va_arg (*args, u32 *);
9797 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9801 if (unformat (input, "%d", &tmp))
9810 *miss_next_indexp = next_index;
9814 #define foreach_ip_next \
9820 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9822 u32 *miss_next_indexp = va_arg (*args, u32 *);
9827 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9831 if (unformat (input, "%d", &tmp))
9840 *miss_next_indexp = next_index;
9844 #define foreach_acl_next \
9848 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9850 u32 *miss_next_indexp = va_arg (*args, u32 *);
9855 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9859 if (unformat (input, "permit"))
9864 else if (unformat (input, "%d", &tmp))
9873 *miss_next_indexp = next_index;
9878 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9880 u32 *r = va_arg (*args, u32 *);
9882 if (unformat (input, "conform-color"))
9883 *r = POLICE_CONFORM;
9884 else if (unformat (input, "exceed-color"))
9893 api_classify_add_del_table (vat_main_t * vam)
9895 unformat_input_t *i = vam->input;
9896 vl_api_classify_add_del_table_t *mp;
9903 u32 table_index = ~0;
9904 u32 next_table_index = ~0;
9905 u32 miss_next_index = ~0;
9906 u32 memory_size = 32 << 20;
9908 u32 current_data_flag = 0;
9909 int current_data_offset = 0;
9912 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9914 if (unformat (i, "del"))
9916 else if (unformat (i, "del-chain"))
9921 else if (unformat (i, "buckets %d", &nbuckets))
9923 else if (unformat (i, "memory_size %d", &memory_size))
9925 else if (unformat (i, "skip %d", &skip))
9927 else if (unformat (i, "match %d", &match))
9929 else if (unformat (i, "table %d", &table_index))
9931 else if (unformat (i, "mask %U", unformat_classify_mask,
9932 &mask, &skip, &match))
9934 else if (unformat (i, "next-table %d", &next_table_index))
9936 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9939 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9942 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9945 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9947 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9953 if (is_add && mask == 0)
9955 errmsg ("Mask required");
9959 if (is_add && skip == ~0)
9961 errmsg ("skip count required");
9965 if (is_add && match == ~0)
9967 errmsg ("match count required");
9971 if (!is_add && table_index == ~0)
9973 errmsg ("table index required for delete");
9977 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9979 mp->is_add = is_add;
9980 mp->del_chain = del_chain;
9981 mp->table_index = ntohl (table_index);
9982 mp->nbuckets = ntohl (nbuckets);
9983 mp->memory_size = ntohl (memory_size);
9984 mp->skip_n_vectors = ntohl (skip);
9985 mp->match_n_vectors = ntohl (match);
9986 mp->next_table_index = ntohl (next_table_index);
9987 mp->miss_next_index = ntohl (miss_next_index);
9988 mp->current_data_flag = ntohl (current_data_flag);
9989 mp->current_data_offset = ntohl (current_data_offset);
9990 clib_memcpy (mp->mask, mask, vec_len (mask));
9999 #if VPP_API_TEST_BUILTIN == 0
10001 unformat_l4_match (unformat_input_t * input, va_list * args)
10003 u8 **matchp = va_arg (*args, u8 **);
10005 u8 *proto_header = 0;
10011 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10013 if (unformat (input, "src_port %d", &src_port))
10015 else if (unformat (input, "dst_port %d", &dst_port))
10021 h.src_port = clib_host_to_net_u16 (src_port);
10022 h.dst_port = clib_host_to_net_u16 (dst_port);
10023 vec_validate (proto_header, sizeof (h) - 1);
10024 memcpy (proto_header, &h, sizeof (h));
10026 *matchp = proto_header;
10032 unformat_ip4_match (unformat_input_t * input, va_list * args)
10034 u8 **matchp = va_arg (*args, u8 **);
10039 int hdr_length = 0;
10040 u32 hdr_length_val;
10041 int src = 0, dst = 0;
10042 ip4_address_t src_val, dst_val;
10049 int fragment_id = 0;
10050 u32 fragment_id_val;
10056 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10058 if (unformat (input, "version %d", &version_val))
10060 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10062 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10064 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10066 else if (unformat (input, "proto %d", &proto_val))
10068 else if (unformat (input, "tos %d", &tos_val))
10070 else if (unformat (input, "length %d", &length_val))
10072 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10074 else if (unformat (input, "ttl %d", &ttl_val))
10076 else if (unformat (input, "checksum %d", &checksum_val))
10082 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10083 + ttl + checksum == 0)
10087 * Aligned because we use the real comparison functions
10089 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10091 ip = (ip4_header_t *) match;
10093 /* These are realistically matched in practice */
10095 ip->src_address.as_u32 = src_val.as_u32;
10098 ip->dst_address.as_u32 = dst_val.as_u32;
10101 ip->protocol = proto_val;
10104 /* These are not, but they're included for completeness */
10106 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10109 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10115 ip->length = clib_host_to_net_u16 (length_val);
10121 ip->checksum = clib_host_to_net_u16 (checksum_val);
10128 unformat_ip6_match (unformat_input_t * input, va_list * args)
10130 u8 **matchp = va_arg (*args, u8 **);
10135 u8 traffic_class = 0;
10136 u32 traffic_class_val = 0;
10139 int src = 0, dst = 0;
10140 ip6_address_t src_val, dst_val;
10143 int payload_length = 0;
10144 u32 payload_length_val;
10147 u32 ip_version_traffic_class_and_flow_label;
10149 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10151 if (unformat (input, "version %d", &version_val))
10153 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10155 else if (unformat (input, "flow_label %d", &flow_label_val))
10157 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10159 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10161 else if (unformat (input, "proto %d", &proto_val))
10163 else if (unformat (input, "payload_length %d", &payload_length_val))
10164 payload_length = 1;
10165 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10171 if (version + traffic_class + flow_label + src + dst + proto +
10172 payload_length + hop_limit == 0)
10176 * Aligned because we use the real comparison functions
10178 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10180 ip = (ip6_header_t *) match;
10183 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10186 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10189 ip->protocol = proto_val;
10191 ip_version_traffic_class_and_flow_label = 0;
10194 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10197 ip_version_traffic_class_and_flow_label |=
10198 (traffic_class_val & 0xFF) << 20;
10201 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10203 ip->ip_version_traffic_class_and_flow_label =
10204 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10206 if (payload_length)
10207 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10210 ip->hop_limit = hop_limit_val;
10217 unformat_l3_match (unformat_input_t * input, va_list * args)
10219 u8 **matchp = va_arg (*args, u8 **);
10221 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10223 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10225 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10234 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10236 u8 *tagp = va_arg (*args, u8 *);
10239 if (unformat (input, "%d", &tag))
10241 tagp[0] = (tag >> 8) & 0x0F;
10242 tagp[1] = tag & 0xFF;
10250 unformat_l2_match (unformat_input_t * input, va_list * args)
10252 u8 **matchp = va_arg (*args, u8 **);
10265 u8 ignore_tag1 = 0;
10266 u8 ignore_tag2 = 0;
10272 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10274 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10277 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10279 else if (unformat (input, "proto %U",
10280 unformat_ethernet_type_host_byte_order, &proto_val))
10282 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10284 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10286 else if (unformat (input, "ignore-tag1"))
10288 else if (unformat (input, "ignore-tag2"))
10290 else if (unformat (input, "cos1 %d", &cos1_val))
10292 else if (unformat (input, "cos2 %d", &cos2_val))
10297 if ((src + dst + proto + tag1 + tag2 +
10298 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10301 if (tag1 || ignore_tag1 || cos1)
10303 if (tag2 || ignore_tag2 || cos2)
10306 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10309 clib_memcpy (match, dst_val, 6);
10312 clib_memcpy (match + 6, src_val, 6);
10316 /* inner vlan tag */
10317 match[19] = tag2_val[1];
10318 match[18] = tag2_val[0];
10320 match[18] |= (cos2_val & 0x7) << 5;
10323 match[21] = proto_val & 0xff;
10324 match[20] = proto_val >> 8;
10328 match[15] = tag1_val[1];
10329 match[14] = tag1_val[0];
10332 match[14] |= (cos1_val & 0x7) << 5;
10338 match[15] = tag1_val[1];
10339 match[14] = tag1_val[0];
10342 match[17] = proto_val & 0xff;
10343 match[16] = proto_val >> 8;
10346 match[14] |= (cos1_val & 0x7) << 5;
10352 match[18] |= (cos2_val & 0x7) << 5;
10354 match[14] |= (cos1_val & 0x7) << 5;
10357 match[13] = proto_val & 0xff;
10358 match[12] = proto_val >> 8;
10367 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10369 u8 **matchp = va_arg (*args, u8 **);
10370 u32 skip_n_vectors = va_arg (*args, u32);
10371 u32 match_n_vectors = va_arg (*args, u32);
10378 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10380 if (unformat (input, "hex %U", unformat_hex_string, &match))
10382 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10384 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10386 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10400 if (match || l2 || l3 || l4)
10402 if (l2 || l3 || l4)
10404 /* "Win a free Ethernet header in every packet" */
10406 vec_validate_aligned (l2, 13, sizeof (u32x4));
10410 vec_append_aligned (match, l3, sizeof (u32x4));
10415 vec_append_aligned (match, l4, sizeof (u32x4));
10420 /* Make sure the vector is big enough even if key is all 0's */
10421 vec_validate_aligned
10422 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10425 /* Set size, include skipped vectors */
10426 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10437 api_classify_add_del_session (vat_main_t * vam)
10439 unformat_input_t *i = vam->input;
10440 vl_api_classify_add_del_session_t *mp;
10442 u32 table_index = ~0;
10443 u32 hit_next_index = ~0;
10444 u32 opaque_index = ~0;
10447 u32 skip_n_vectors = 0;
10448 u32 match_n_vectors = 0;
10454 * Warning: you have to supply skip_n and match_n
10455 * because the API client cant simply look at the classify
10459 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10461 if (unformat (i, "del"))
10463 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10466 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10469 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10472 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10474 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10476 else if (unformat (i, "opaque-index %d", &opaque_index))
10478 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10480 else if (unformat (i, "match_n %d", &match_n_vectors))
10482 else if (unformat (i, "match %U", api_unformat_classify_match,
10483 &match, skip_n_vectors, match_n_vectors))
10485 else if (unformat (i, "advance %d", &advance))
10487 else if (unformat (i, "table-index %d", &table_index))
10489 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10491 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10493 else if (unformat (i, "action %d", &action))
10495 else if (unformat (i, "metadata %d", &metadata))
10501 if (table_index == ~0)
10503 errmsg ("Table index required");
10507 if (is_add && match == 0)
10509 errmsg ("Match value required");
10513 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10515 mp->is_add = is_add;
10516 mp->table_index = ntohl (table_index);
10517 mp->hit_next_index = ntohl (hit_next_index);
10518 mp->opaque_index = ntohl (opaque_index);
10519 mp->advance = ntohl (advance);
10520 mp->action = action;
10521 mp->metadata = ntohl (metadata);
10522 clib_memcpy (mp->match, match, vec_len (match));
10531 api_classify_set_interface_ip_table (vat_main_t * vam)
10533 unformat_input_t *i = vam->input;
10534 vl_api_classify_set_interface_ip_table_t *mp;
10536 int sw_if_index_set;
10537 u32 table_index = ~0;
10541 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10543 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10544 sw_if_index_set = 1;
10545 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10546 sw_if_index_set = 1;
10547 else if (unformat (i, "table %d", &table_index))
10551 clib_warning ("parse error '%U'", format_unformat_error, i);
10556 if (sw_if_index_set == 0)
10558 errmsg ("missing interface name or sw_if_index");
10563 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10565 mp->sw_if_index = ntohl (sw_if_index);
10566 mp->table_index = ntohl (table_index);
10567 mp->is_ipv6 = is_ipv6;
10575 api_classify_set_interface_l2_tables (vat_main_t * vam)
10577 unformat_input_t *i = vam->input;
10578 vl_api_classify_set_interface_l2_tables_t *mp;
10580 int sw_if_index_set;
10581 u32 ip4_table_index = ~0;
10582 u32 ip6_table_index = ~0;
10583 u32 other_table_index = ~0;
10587 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10589 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10590 sw_if_index_set = 1;
10591 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10592 sw_if_index_set = 1;
10593 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10595 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10597 else if (unformat (i, "other-table %d", &other_table_index))
10599 else if (unformat (i, "is-input %d", &is_input))
10603 clib_warning ("parse error '%U'", format_unformat_error, i);
10608 if (sw_if_index_set == 0)
10610 errmsg ("missing interface name or sw_if_index");
10615 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10617 mp->sw_if_index = ntohl (sw_if_index);
10618 mp->ip4_table_index = ntohl (ip4_table_index);
10619 mp->ip6_table_index = ntohl (ip6_table_index);
10620 mp->other_table_index = ntohl (other_table_index);
10621 mp->is_input = (u8) is_input;
10629 api_set_ipfix_exporter (vat_main_t * vam)
10631 unformat_input_t *i = vam->input;
10632 vl_api_set_ipfix_exporter_t *mp;
10633 ip4_address_t collector_address;
10634 u8 collector_address_set = 0;
10635 u32 collector_port = ~0;
10636 ip4_address_t src_address;
10637 u8 src_address_set = 0;
10640 u32 template_interval = ~0;
10641 u8 udp_checksum = 0;
10644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10646 if (unformat (i, "collector_address %U", unformat_ip4_address,
10647 &collector_address))
10648 collector_address_set = 1;
10649 else if (unformat (i, "collector_port %d", &collector_port))
10651 else if (unformat (i, "src_address %U", unformat_ip4_address,
10653 src_address_set = 1;
10654 else if (unformat (i, "vrf_id %d", &vrf_id))
10656 else if (unformat (i, "path_mtu %d", &path_mtu))
10658 else if (unformat (i, "template_interval %d", &template_interval))
10660 else if (unformat (i, "udp_checksum"))
10666 if (collector_address_set == 0)
10668 errmsg ("collector_address required");
10672 if (src_address_set == 0)
10674 errmsg ("src_address required");
10678 M (SET_IPFIX_EXPORTER, mp);
10680 memcpy (mp->collector_address, collector_address.data,
10681 sizeof (collector_address.data));
10682 mp->collector_port = htons ((u16) collector_port);
10683 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10684 mp->vrf_id = htonl (vrf_id);
10685 mp->path_mtu = htonl (path_mtu);
10686 mp->template_interval = htonl (template_interval);
10687 mp->udp_checksum = udp_checksum;
10695 api_set_ipfix_classify_stream (vat_main_t * vam)
10697 unformat_input_t *i = vam->input;
10698 vl_api_set_ipfix_classify_stream_t *mp;
10700 u32 src_port = UDP_DST_PORT_ipfix;
10703 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10705 if (unformat (i, "domain %d", &domain_id))
10707 else if (unformat (i, "src_port %d", &src_port))
10711 errmsg ("unknown input `%U'", format_unformat_error, i);
10716 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10718 mp->domain_id = htonl (domain_id);
10719 mp->src_port = htons ((u16) src_port);
10727 api_ipfix_classify_table_add_del (vat_main_t * vam)
10729 unformat_input_t *i = vam->input;
10730 vl_api_ipfix_classify_table_add_del_t *mp;
10732 u32 classify_table_index = ~0;
10734 u8 transport_protocol = 255;
10737 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10739 if (unformat (i, "add"))
10741 else if (unformat (i, "del"))
10743 else if (unformat (i, "table %d", &classify_table_index))
10745 else if (unformat (i, "ip4"))
10747 else if (unformat (i, "ip6"))
10749 else if (unformat (i, "tcp"))
10750 transport_protocol = 6;
10751 else if (unformat (i, "udp"))
10752 transport_protocol = 17;
10755 errmsg ("unknown input `%U'", format_unformat_error, i);
10762 errmsg ("expecting: add|del");
10765 if (classify_table_index == ~0)
10767 errmsg ("classifier table not specified");
10770 if (ip_version == 0)
10772 errmsg ("IP version not specified");
10776 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10778 mp->is_add = is_add;
10779 mp->table_id = htonl (classify_table_index);
10780 mp->ip_version = ip_version;
10781 mp->transport_protocol = transport_protocol;
10789 api_get_node_index (vat_main_t * vam)
10791 unformat_input_t *i = vam->input;
10792 vl_api_get_node_index_t *mp;
10796 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10798 if (unformat (i, "node %s", &name))
10805 errmsg ("node name required");
10808 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10810 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10814 M (GET_NODE_INDEX, mp);
10815 clib_memcpy (mp->node_name, name, vec_len (name));
10824 api_get_next_index (vat_main_t * vam)
10826 unformat_input_t *i = vam->input;
10827 vl_api_get_next_index_t *mp;
10828 u8 *node_name = 0, *next_node_name = 0;
10831 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10833 if (unformat (i, "node-name %s", &node_name))
10835 else if (unformat (i, "next-node-name %s", &next_node_name))
10839 if (node_name == 0)
10841 errmsg ("node name required");
10844 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10846 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10850 if (next_node_name == 0)
10852 errmsg ("next node name required");
10855 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10857 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10861 M (GET_NEXT_INDEX, mp);
10862 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10863 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10864 vec_free (node_name);
10865 vec_free (next_node_name);
10873 api_add_node_next (vat_main_t * vam)
10875 unformat_input_t *i = vam->input;
10876 vl_api_add_node_next_t *mp;
10881 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10883 if (unformat (i, "node %s", &name))
10885 else if (unformat (i, "next %s", &next))
10892 errmsg ("node name required");
10895 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10897 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10902 errmsg ("next node required");
10905 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10907 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10911 M (ADD_NODE_NEXT, mp);
10912 clib_memcpy (mp->node_name, name, vec_len (name));
10913 clib_memcpy (mp->next_name, next, vec_len (next));
10923 api_l2tpv3_create_tunnel (vat_main_t * vam)
10925 unformat_input_t *i = vam->input;
10926 ip6_address_t client_address, our_address;
10927 int client_address_set = 0;
10928 int our_address_set = 0;
10929 u32 local_session_id = 0;
10930 u32 remote_session_id = 0;
10931 u64 local_cookie = 0;
10932 u64 remote_cookie = 0;
10933 u8 l2_sublayer_present = 0;
10934 vl_api_l2tpv3_create_tunnel_t *mp;
10937 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10939 if (unformat (i, "client_address %U", unformat_ip6_address,
10941 client_address_set = 1;
10942 else if (unformat (i, "our_address %U", unformat_ip6_address,
10944 our_address_set = 1;
10945 else if (unformat (i, "local_session_id %d", &local_session_id))
10947 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10949 else if (unformat (i, "local_cookie %lld", &local_cookie))
10951 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10953 else if (unformat (i, "l2-sublayer-present"))
10954 l2_sublayer_present = 1;
10959 if (client_address_set == 0)
10961 errmsg ("client_address required");
10965 if (our_address_set == 0)
10967 errmsg ("our_address required");
10971 M (L2TPV3_CREATE_TUNNEL, mp);
10973 clib_memcpy (mp->client_address, client_address.as_u8,
10974 sizeof (mp->client_address));
10976 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10978 mp->local_session_id = ntohl (local_session_id);
10979 mp->remote_session_id = ntohl (remote_session_id);
10980 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10981 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10982 mp->l2_sublayer_present = l2_sublayer_present;
10991 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10993 unformat_input_t *i = vam->input;
10995 u8 sw_if_index_set = 0;
10996 u64 new_local_cookie = 0;
10997 u64 new_remote_cookie = 0;
10998 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11001 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11003 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11004 sw_if_index_set = 1;
11005 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11006 sw_if_index_set = 1;
11007 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11009 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11015 if (sw_if_index_set == 0)
11017 errmsg ("missing interface name or sw_if_index");
11021 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11023 mp->sw_if_index = ntohl (sw_if_index);
11024 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11025 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11033 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11035 unformat_input_t *i = vam->input;
11036 vl_api_l2tpv3_interface_enable_disable_t *mp;
11038 u8 sw_if_index_set = 0;
11039 u8 enable_disable = 1;
11042 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11044 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11045 sw_if_index_set = 1;
11046 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11047 sw_if_index_set = 1;
11048 else if (unformat (i, "enable"))
11049 enable_disable = 1;
11050 else if (unformat (i, "disable"))
11051 enable_disable = 0;
11056 if (sw_if_index_set == 0)
11058 errmsg ("missing interface name or sw_if_index");
11062 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11064 mp->sw_if_index = ntohl (sw_if_index);
11065 mp->enable_disable = enable_disable;
11073 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11075 unformat_input_t *i = vam->input;
11076 vl_api_l2tpv3_set_lookup_key_t *mp;
11080 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11082 if (unformat (i, "lookup_v6_src"))
11083 key = L2T_LOOKUP_SRC_ADDRESS;
11084 else if (unformat (i, "lookup_v6_dst"))
11085 key = L2T_LOOKUP_DST_ADDRESS;
11086 else if (unformat (i, "lookup_session_id"))
11087 key = L2T_LOOKUP_SESSION_ID;
11092 if (key == (u8) ~ 0)
11094 errmsg ("l2tp session lookup key unset");
11098 M (L2TPV3_SET_LOOKUP_KEY, mp);
11107 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11108 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11110 vat_main_t *vam = &vat_main;
11112 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11113 format_ip6_address, mp->our_address,
11114 format_ip6_address, mp->client_address,
11115 clib_net_to_host_u32 (mp->sw_if_index));
11118 " local cookies %016llx %016llx remote cookie %016llx",
11119 clib_net_to_host_u64 (mp->local_cookie[0]),
11120 clib_net_to_host_u64 (mp->local_cookie[1]),
11121 clib_net_to_host_u64 (mp->remote_cookie));
11123 print (vam->ofp, " local session-id %d remote session-id %d",
11124 clib_net_to_host_u32 (mp->local_session_id),
11125 clib_net_to_host_u32 (mp->remote_session_id));
11127 print (vam->ofp, " l2 specific sublayer %s\n",
11128 mp->l2_sublayer_present ? "preset" : "absent");
11132 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11133 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11135 vat_main_t *vam = &vat_main;
11136 vat_json_node_t *node = NULL;
11137 struct in6_addr addr;
11139 if (VAT_JSON_ARRAY != vam->json_tree.type)
11141 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11142 vat_json_init_array (&vam->json_tree);
11144 node = vat_json_array_add (&vam->json_tree);
11146 vat_json_init_object (node);
11148 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11149 vat_json_object_add_ip6 (node, "our_address", addr);
11150 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11151 vat_json_object_add_ip6 (node, "client_address", addr);
11153 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11154 vat_json_init_array (lc);
11155 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11156 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11157 vat_json_object_add_uint (node, "remote_cookie",
11158 clib_net_to_host_u64 (mp->remote_cookie));
11160 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11161 vat_json_object_add_uint (node, "local_session_id",
11162 clib_net_to_host_u32 (mp->local_session_id));
11163 vat_json_object_add_uint (node, "remote_session_id",
11164 clib_net_to_host_u32 (mp->remote_session_id));
11165 vat_json_object_add_string_copy (node, "l2_sublayer",
11166 mp->l2_sublayer_present ? (u8 *) "present"
11167 : (u8 *) "absent");
11171 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11173 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11174 vl_api_control_ping_t *mp_ping;
11177 /* Get list of l2tpv3-tunnel interfaces */
11178 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11181 /* Use a control ping for synchronization */
11182 M (CONTROL_PING, mp_ping);
11190 static void vl_api_sw_interface_tap_details_t_handler
11191 (vl_api_sw_interface_tap_details_t * mp)
11193 vat_main_t *vam = &vat_main;
11195 print (vam->ofp, "%-16s %d",
11196 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
11199 static void vl_api_sw_interface_tap_details_t_handler_json
11200 (vl_api_sw_interface_tap_details_t * mp)
11202 vat_main_t *vam = &vat_main;
11203 vat_json_node_t *node = NULL;
11205 if (VAT_JSON_ARRAY != vam->json_tree.type)
11207 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11208 vat_json_init_array (&vam->json_tree);
11210 node = vat_json_array_add (&vam->json_tree);
11212 vat_json_init_object (node);
11213 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11214 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11218 api_sw_interface_tap_dump (vat_main_t * vam)
11220 vl_api_sw_interface_tap_dump_t *mp;
11221 vl_api_control_ping_t *mp_ping;
11224 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
11225 /* Get list of tap interfaces */
11226 M (SW_INTERFACE_TAP_DUMP, mp);
11229 /* Use a control ping for synchronization */
11230 M (CONTROL_PING, mp_ping);
11237 static uword unformat_vxlan_decap_next
11238 (unformat_input_t * input, va_list * args)
11240 u32 *result = va_arg (*args, u32 *);
11243 if (unformat (input, "l2"))
11244 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11245 else if (unformat (input, "%d", &tmp))
11253 api_vxlan_add_del_tunnel (vat_main_t * vam)
11255 unformat_input_t *line_input = vam->input;
11256 vl_api_vxlan_add_del_tunnel_t *mp;
11257 ip46_address_t src, dst;
11259 u8 ipv4_set = 0, ipv6_set = 0;
11263 u32 mcast_sw_if_index = ~0;
11264 u32 encap_vrf_id = 0;
11265 u32 decap_next_index = ~0;
11269 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11270 memset (&src, 0, sizeof src);
11271 memset (&dst, 0, sizeof dst);
11273 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11275 if (unformat (line_input, "del"))
11278 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11284 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11290 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11296 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11301 else if (unformat (line_input, "group %U %U",
11302 unformat_ip4_address, &dst.ip4,
11303 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11305 grp_set = dst_set = 1;
11308 else if (unformat (line_input, "group %U",
11309 unformat_ip4_address, &dst.ip4))
11311 grp_set = dst_set = 1;
11314 else if (unformat (line_input, "group %U %U",
11315 unformat_ip6_address, &dst.ip6,
11316 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11318 grp_set = dst_set = 1;
11321 else if (unformat (line_input, "group %U",
11322 unformat_ip6_address, &dst.ip6))
11324 grp_set = dst_set = 1;
11328 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11330 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11332 else if (unformat (line_input, "decap-next %U",
11333 unformat_vxlan_decap_next, &decap_next_index))
11335 else if (unformat (line_input, "vni %d", &vni))
11339 errmsg ("parse error '%U'", format_unformat_error, line_input);
11346 errmsg ("tunnel src address not specified");
11351 errmsg ("tunnel dst address not specified");
11355 if (grp_set && !ip46_address_is_multicast (&dst))
11357 errmsg ("tunnel group address not multicast");
11360 if (grp_set && mcast_sw_if_index == ~0)
11362 errmsg ("tunnel nonexistent multicast device");
11365 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11367 errmsg ("tunnel dst address must be unicast");
11372 if (ipv4_set && ipv6_set)
11374 errmsg ("both IPv4 and IPv6 addresses specified");
11378 if ((vni == 0) || (vni >> 24))
11380 errmsg ("vni not specified or out of range");
11384 M (VXLAN_ADD_DEL_TUNNEL, mp);
11388 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
11389 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
11393 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
11394 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
11396 mp->encap_vrf_id = ntohl (encap_vrf_id);
11397 mp->decap_next_index = ntohl (decap_next_index);
11398 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11399 mp->vni = ntohl (vni);
11400 mp->is_add = is_add;
11401 mp->is_ipv6 = ipv6_set;
11408 static void vl_api_vxlan_tunnel_details_t_handler
11409 (vl_api_vxlan_tunnel_details_t * mp)
11411 vat_main_t *vam = &vat_main;
11412 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
11413 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
11415 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
11416 ntohl (mp->sw_if_index),
11417 format_ip46_address, &src, IP46_TYPE_ANY,
11418 format_ip46_address, &dst, IP46_TYPE_ANY,
11419 ntohl (mp->encap_vrf_id),
11420 ntohl (mp->decap_next_index), ntohl (mp->vni),
11421 ntohl (mp->mcast_sw_if_index));
11424 static void vl_api_vxlan_tunnel_details_t_handler_json
11425 (vl_api_vxlan_tunnel_details_t * mp)
11427 vat_main_t *vam = &vat_main;
11428 vat_json_node_t *node = NULL;
11430 if (VAT_JSON_ARRAY != vam->json_tree.type)
11432 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11433 vat_json_init_array (&vam->json_tree);
11435 node = vat_json_array_add (&vam->json_tree);
11437 vat_json_init_object (node);
11438 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11441 struct in6_addr ip6;
11443 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
11444 vat_json_object_add_ip6 (node, "src_address", ip6);
11445 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
11446 vat_json_object_add_ip6 (node, "dst_address", ip6);
11450 struct in_addr ip4;
11452 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
11453 vat_json_object_add_ip4 (node, "src_address", ip4);
11454 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
11455 vat_json_object_add_ip4 (node, "dst_address", ip4);
11457 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11458 vat_json_object_add_uint (node, "decap_next_index",
11459 ntohl (mp->decap_next_index));
11460 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11461 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11462 vat_json_object_add_uint (node, "mcast_sw_if_index",
11463 ntohl (mp->mcast_sw_if_index));
11467 api_vxlan_tunnel_dump (vat_main_t * vam)
11469 unformat_input_t *i = vam->input;
11470 vl_api_vxlan_tunnel_dump_t *mp;
11471 vl_api_control_ping_t *mp_ping;
11473 u8 sw_if_index_set = 0;
11476 /* Parse args required to build the message */
11477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11479 if (unformat (i, "sw_if_index %d", &sw_if_index))
11480 sw_if_index_set = 1;
11485 if (sw_if_index_set == 0)
11490 if (!vam->json_output)
11492 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
11493 "sw_if_index", "src_address", "dst_address",
11494 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11497 /* Get list of vxlan-tunnel interfaces */
11498 M (VXLAN_TUNNEL_DUMP, mp);
11500 mp->sw_if_index = htonl (sw_if_index);
11504 /* Use a control ping for synchronization */
11505 M (CONTROL_PING, mp_ping);
11513 api_gre_add_del_tunnel (vat_main_t * vam)
11515 unformat_input_t *line_input = vam->input;
11516 vl_api_gre_add_del_tunnel_t *mp;
11517 ip4_address_t src4, dst4;
11518 ip6_address_t src6, dst6;
11525 u32 outer_fib_id = 0;
11528 memset (&src4, 0, sizeof src4);
11529 memset (&dst4, 0, sizeof dst4);
11530 memset (&src6, 0, sizeof src6);
11531 memset (&dst6, 0, sizeof dst6);
11533 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11535 if (unformat (line_input, "del"))
11537 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
11542 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
11547 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
11552 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
11557 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
11559 else if (unformat (line_input, "teb"))
11563 errmsg ("parse error '%U'", format_unformat_error, line_input);
11570 errmsg ("tunnel src address not specified");
11575 errmsg ("tunnel dst address not specified");
11578 if (ipv4_set && ipv6_set)
11580 errmsg ("both IPv4 and IPv6 addresses specified");
11585 M (GRE_ADD_DEL_TUNNEL, mp);
11589 clib_memcpy (&mp->src_address, &src4, 4);
11590 clib_memcpy (&mp->dst_address, &dst4, 4);
11594 clib_memcpy (&mp->src_address, &src6, 16);
11595 clib_memcpy (&mp->dst_address, &dst6, 16);
11597 mp->outer_fib_id = ntohl (outer_fib_id);
11598 mp->is_add = is_add;
11600 mp->is_ipv6 = ipv6_set;
11607 static void vl_api_gre_tunnel_details_t_handler
11608 (vl_api_gre_tunnel_details_t * mp)
11610 vat_main_t *vam = &vat_main;
11611 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
11612 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
11614 print (vam->ofp, "%11d%24U%24U%6d%14d",
11615 ntohl (mp->sw_if_index),
11616 format_ip46_address, &src, IP46_TYPE_ANY,
11617 format_ip46_address, &dst, IP46_TYPE_ANY,
11618 mp->teb, ntohl (mp->outer_fib_id));
11621 static void vl_api_gre_tunnel_details_t_handler_json
11622 (vl_api_gre_tunnel_details_t * mp)
11624 vat_main_t *vam = &vat_main;
11625 vat_json_node_t *node = NULL;
11626 struct in_addr ip4;
11627 struct in6_addr ip6;
11629 if (VAT_JSON_ARRAY != vam->json_tree.type)
11631 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11632 vat_json_init_array (&vam->json_tree);
11634 node = vat_json_array_add (&vam->json_tree);
11636 vat_json_init_object (node);
11637 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11640 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11641 vat_json_object_add_ip4 (node, "src_address", ip4);
11642 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11643 vat_json_object_add_ip4 (node, "dst_address", ip4);
11647 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
11648 vat_json_object_add_ip6 (node, "src_address", ip6);
11649 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
11650 vat_json_object_add_ip6 (node, "dst_address", ip6);
11652 vat_json_object_add_uint (node, "teb", mp->teb);
11653 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11654 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
11658 api_gre_tunnel_dump (vat_main_t * vam)
11660 unformat_input_t *i = vam->input;
11661 vl_api_gre_tunnel_dump_t *mp;
11662 vl_api_control_ping_t *mp_ping;
11664 u8 sw_if_index_set = 0;
11667 /* Parse args required to build the message */
11668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11670 if (unformat (i, "sw_if_index %d", &sw_if_index))
11671 sw_if_index_set = 1;
11676 if (sw_if_index_set == 0)
11681 if (!vam->json_output)
11683 print (vam->ofp, "%11s%24s%24s%6s%14s",
11684 "sw_if_index", "src_address", "dst_address", "teb",
11688 /* Get list of gre-tunnel interfaces */
11689 M (GRE_TUNNEL_DUMP, mp);
11691 mp->sw_if_index = htonl (sw_if_index);
11695 /* Use a control ping for synchronization */
11696 M (CONTROL_PING, mp_ping);
11704 api_l2_fib_clear_table (vat_main_t * vam)
11706 // unformat_input_t * i = vam->input;
11707 vl_api_l2_fib_clear_table_t *mp;
11710 M (L2_FIB_CLEAR_TABLE, mp);
11718 api_l2_interface_efp_filter (vat_main_t * vam)
11720 unformat_input_t *i = vam->input;
11721 vl_api_l2_interface_efp_filter_t *mp;
11724 u8 sw_if_index_set = 0;
11727 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11729 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11730 sw_if_index_set = 1;
11731 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11732 sw_if_index_set = 1;
11733 else if (unformat (i, "enable"))
11735 else if (unformat (i, "disable"))
11739 clib_warning ("parse error '%U'", format_unformat_error, i);
11744 if (sw_if_index_set == 0)
11746 errmsg ("missing sw_if_index");
11750 M (L2_INTERFACE_EFP_FILTER, mp);
11752 mp->sw_if_index = ntohl (sw_if_index);
11753 mp->enable_disable = enable;
11760 #define foreach_vtr_op \
11761 _("disable", L2_VTR_DISABLED) \
11762 _("push-1", L2_VTR_PUSH_1) \
11763 _("push-2", L2_VTR_PUSH_2) \
11764 _("pop-1", L2_VTR_POP_1) \
11765 _("pop-2", L2_VTR_POP_2) \
11766 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11767 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11768 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11769 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11772 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11774 unformat_input_t *i = vam->input;
11775 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11777 u8 sw_if_index_set = 0;
11780 u32 push_dot1q = 1;
11785 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11787 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11788 sw_if_index_set = 1;
11789 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11790 sw_if_index_set = 1;
11791 else if (unformat (i, "vtr_op %d", &vtr_op))
11793 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11796 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11798 else if (unformat (i, "tag1 %d", &tag1))
11800 else if (unformat (i, "tag2 %d", &tag2))
11804 clib_warning ("parse error '%U'", format_unformat_error, i);
11809 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11811 errmsg ("missing vtr operation or sw_if_index");
11815 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11816 mp->sw_if_index = ntohl (sw_if_index);
11817 mp->vtr_op = ntohl (vtr_op);
11818 mp->push_dot1q = ntohl (push_dot1q);
11819 mp->tag1 = ntohl (tag1);
11820 mp->tag2 = ntohl (tag2);
11828 api_create_vhost_user_if (vat_main_t * vam)
11830 unformat_input_t *i = vam->input;
11831 vl_api_create_vhost_user_if_t *mp;
11834 u8 file_name_set = 0;
11835 u32 custom_dev_instance = ~0;
11837 u8 use_custom_mac = 0;
11841 /* Shut up coverity */
11842 memset (hwaddr, 0, sizeof (hwaddr));
11844 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11846 if (unformat (i, "socket %s", &file_name))
11850 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11852 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11853 use_custom_mac = 1;
11854 else if (unformat (i, "server"))
11856 else if (unformat (i, "tag %s", &tag))
11862 if (file_name_set == 0)
11864 errmsg ("missing socket file name");
11868 if (vec_len (file_name) > 255)
11870 errmsg ("socket file name too long");
11873 vec_add1 (file_name, 0);
11875 M (CREATE_VHOST_USER_IF, mp);
11877 mp->is_server = is_server;
11878 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11879 vec_free (file_name);
11880 if (custom_dev_instance != ~0)
11883 mp->custom_dev_instance = ntohl (custom_dev_instance);
11885 mp->use_custom_mac = use_custom_mac;
11886 clib_memcpy (mp->mac_address, hwaddr, 6);
11888 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11897 api_modify_vhost_user_if (vat_main_t * vam)
11899 unformat_input_t *i = vam->input;
11900 vl_api_modify_vhost_user_if_t *mp;
11903 u8 file_name_set = 0;
11904 u32 custom_dev_instance = ~0;
11905 u8 sw_if_index_set = 0;
11906 u32 sw_if_index = (u32) ~ 0;
11909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11911 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11912 sw_if_index_set = 1;
11913 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11914 sw_if_index_set = 1;
11915 else if (unformat (i, "socket %s", &file_name))
11919 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11921 else if (unformat (i, "server"))
11927 if (sw_if_index_set == 0)
11929 errmsg ("missing sw_if_index or interface name");
11933 if (file_name_set == 0)
11935 errmsg ("missing socket file name");
11939 if (vec_len (file_name) > 255)
11941 errmsg ("socket file name too long");
11944 vec_add1 (file_name, 0);
11946 M (MODIFY_VHOST_USER_IF, mp);
11948 mp->sw_if_index = ntohl (sw_if_index);
11949 mp->is_server = is_server;
11950 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11951 vec_free (file_name);
11952 if (custom_dev_instance != ~0)
11955 mp->custom_dev_instance = ntohl (custom_dev_instance);
11964 api_delete_vhost_user_if (vat_main_t * vam)
11966 unformat_input_t *i = vam->input;
11967 vl_api_delete_vhost_user_if_t *mp;
11968 u32 sw_if_index = ~0;
11969 u8 sw_if_index_set = 0;
11972 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11974 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11975 sw_if_index_set = 1;
11976 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11977 sw_if_index_set = 1;
11982 if (sw_if_index_set == 0)
11984 errmsg ("missing sw_if_index or interface name");
11989 M (DELETE_VHOST_USER_IF, mp);
11991 mp->sw_if_index = ntohl (sw_if_index);
11998 static void vl_api_sw_interface_vhost_user_details_t_handler
11999 (vl_api_sw_interface_vhost_user_details_t * mp)
12001 vat_main_t *vam = &vat_main;
12003 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12004 (char *) mp->interface_name,
12005 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12006 clib_net_to_host_u64 (mp->features), mp->is_server,
12007 ntohl (mp->num_regions), (char *) mp->sock_filename);
12008 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12011 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12012 (vl_api_sw_interface_vhost_user_details_t * mp)
12014 vat_main_t *vam = &vat_main;
12015 vat_json_node_t *node = NULL;
12017 if (VAT_JSON_ARRAY != vam->json_tree.type)
12019 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12020 vat_json_init_array (&vam->json_tree);
12022 node = vat_json_array_add (&vam->json_tree);
12024 vat_json_init_object (node);
12025 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12026 vat_json_object_add_string_copy (node, "interface_name",
12027 mp->interface_name);
12028 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12029 ntohl (mp->virtio_net_hdr_sz));
12030 vat_json_object_add_uint (node, "features",
12031 clib_net_to_host_u64 (mp->features));
12032 vat_json_object_add_uint (node, "is_server", mp->is_server);
12033 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12034 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12035 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12039 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12041 vl_api_sw_interface_vhost_user_dump_t *mp;
12042 vl_api_control_ping_t *mp_ping;
12045 "Interface name idx hdr_sz features server regions filename");
12047 /* Get list of vhost-user interfaces */
12048 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12051 /* Use a control ping for synchronization */
12052 M (CONTROL_PING, mp_ping);
12060 api_show_version (vat_main_t * vam)
12062 vl_api_show_version_t *mp;
12065 M (SHOW_VERSION, mp);
12074 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12076 unformat_input_t *line_input = vam->input;
12077 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12078 ip4_address_t local4, remote4;
12079 ip6_address_t local6, remote6;
12081 u8 ipv4_set = 0, ipv6_set = 0;
12085 u32 mcast_sw_if_index = ~0;
12086 u32 encap_vrf_id = 0;
12087 u32 decap_vrf_id = 0;
12093 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12094 memset (&local4, 0, sizeof local4);
12095 memset (&remote4, 0, sizeof remote4);
12096 memset (&local6, 0, sizeof local6);
12097 memset (&remote6, 0, sizeof remote6);
12099 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12101 if (unformat (line_input, "del"))
12103 else if (unformat (line_input, "local %U",
12104 unformat_ip4_address, &local4))
12109 else if (unformat (line_input, "remote %U",
12110 unformat_ip4_address, &remote4))
12115 else if (unformat (line_input, "local %U",
12116 unformat_ip6_address, &local6))
12121 else if (unformat (line_input, "remote %U",
12122 unformat_ip6_address, &remote6))
12127 else if (unformat (line_input, "group %U %U",
12128 unformat_ip4_address, &remote4,
12129 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12131 grp_set = remote_set = 1;
12134 else if (unformat (line_input, "group %U",
12135 unformat_ip4_address, &remote4))
12137 grp_set = remote_set = 1;
12140 else if (unformat (line_input, "group %U %U",
12141 unformat_ip6_address, &remote6,
12142 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12144 grp_set = remote_set = 1;
12147 else if (unformat (line_input, "group %U",
12148 unformat_ip6_address, &remote6))
12150 grp_set = remote_set = 1;
12154 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12156 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12158 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
12160 else if (unformat (line_input, "vni %d", &vni))
12162 else if (unformat (line_input, "next-ip4"))
12164 else if (unformat (line_input, "next-ip6"))
12166 else if (unformat (line_input, "next-ethernet"))
12168 else if (unformat (line_input, "next-nsh"))
12172 errmsg ("parse error '%U'", format_unformat_error, line_input);
12177 if (local_set == 0)
12179 errmsg ("tunnel local address not specified");
12182 if (remote_set == 0)
12184 errmsg ("tunnel remote address not specified");
12187 if (grp_set && mcast_sw_if_index == ~0)
12189 errmsg ("tunnel nonexistent multicast device");
12192 if (ipv4_set && ipv6_set)
12194 errmsg ("both IPv4 and IPv6 addresses specified");
12200 errmsg ("vni not specified");
12204 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
12209 clib_memcpy (&mp->local, &local6, sizeof (local6));
12210 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
12214 clib_memcpy (&mp->local, &local4, sizeof (local4));
12215 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
12218 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12219 mp->encap_vrf_id = ntohl (encap_vrf_id);
12220 mp->decap_vrf_id = ntohl (decap_vrf_id);
12221 mp->protocol = protocol;
12222 mp->vni = ntohl (vni);
12223 mp->is_add = is_add;
12224 mp->is_ipv6 = ipv6_set;
12231 static void vl_api_vxlan_gpe_tunnel_details_t_handler
12232 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12234 vat_main_t *vam = &vat_main;
12235 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
12236 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
12238 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
12239 ntohl (mp->sw_if_index),
12240 format_ip46_address, &local, IP46_TYPE_ANY,
12241 format_ip46_address, &remote, IP46_TYPE_ANY,
12242 ntohl (mp->vni), mp->protocol,
12243 ntohl (mp->mcast_sw_if_index),
12244 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
12248 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
12249 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12251 vat_main_t *vam = &vat_main;
12252 vat_json_node_t *node = NULL;
12253 struct in_addr ip4;
12254 struct in6_addr ip6;
12256 if (VAT_JSON_ARRAY != vam->json_tree.type)
12258 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12259 vat_json_init_array (&vam->json_tree);
12261 node = vat_json_array_add (&vam->json_tree);
12263 vat_json_init_object (node);
12264 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12267 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
12268 vat_json_object_add_ip6 (node, "local", ip6);
12269 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
12270 vat_json_object_add_ip6 (node, "remote", ip6);
12274 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
12275 vat_json_object_add_ip4 (node, "local", ip4);
12276 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
12277 vat_json_object_add_ip4 (node, "remote", ip4);
12279 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12280 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
12281 vat_json_object_add_uint (node, "mcast_sw_if_index",
12282 ntohl (mp->mcast_sw_if_index));
12283 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12284 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
12285 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12289 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
12291 unformat_input_t *i = vam->input;
12292 vl_api_vxlan_gpe_tunnel_dump_t *mp;
12293 vl_api_control_ping_t *mp_ping;
12295 u8 sw_if_index_set = 0;
12298 /* Parse args required to build the message */
12299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12301 if (unformat (i, "sw_if_index %d", &sw_if_index))
12302 sw_if_index_set = 1;
12307 if (sw_if_index_set == 0)
12312 if (!vam->json_output)
12314 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
12315 "sw_if_index", "local", "remote", "vni",
12316 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
12319 /* Get list of vxlan-tunnel interfaces */
12320 M (VXLAN_GPE_TUNNEL_DUMP, mp);
12322 mp->sw_if_index = htonl (sw_if_index);
12326 /* Use a control ping for synchronization */
12327 M (CONTROL_PING, mp_ping);
12336 format_l2_fib_mac_address (u8 * s, va_list * args)
12338 u8 *a = va_arg (*args, u8 *);
12340 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
12341 a[2], a[3], a[4], a[5], a[6], a[7]);
12344 static void vl_api_l2_fib_table_details_t_handler
12345 (vl_api_l2_fib_table_details_t * mp)
12347 vat_main_t *vam = &vat_main;
12349 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
12351 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
12352 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
12356 static void vl_api_l2_fib_table_details_t_handler_json
12357 (vl_api_l2_fib_table_details_t * mp)
12359 vat_main_t *vam = &vat_main;
12360 vat_json_node_t *node = NULL;
12362 if (VAT_JSON_ARRAY != vam->json_tree.type)
12364 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12365 vat_json_init_array (&vam->json_tree);
12367 node = vat_json_array_add (&vam->json_tree);
12369 vat_json_init_object (node);
12370 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
12371 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
12372 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12373 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
12374 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
12375 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
12379 api_l2_fib_table_dump (vat_main_t * vam)
12381 unformat_input_t *i = vam->input;
12382 vl_api_l2_fib_table_dump_t *mp;
12383 vl_api_control_ping_t *mp_ping;
12388 /* Parse args required to build the message */
12389 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12391 if (unformat (i, "bd_id %d", &bd_id))
12397 if (bd_id_set == 0)
12399 errmsg ("missing bridge domain");
12403 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
12405 /* Get list of l2 fib entries */
12406 M (L2_FIB_TABLE_DUMP, mp);
12408 mp->bd_id = ntohl (bd_id);
12411 /* Use a control ping for synchronization */
12412 M (CONTROL_PING, mp_ping);
12421 api_interface_name_renumber (vat_main_t * vam)
12423 unformat_input_t *line_input = vam->input;
12424 vl_api_interface_name_renumber_t *mp;
12425 u32 sw_if_index = ~0;
12426 u32 new_show_dev_instance = ~0;
12429 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12431 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
12434 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12436 else if (unformat (line_input, "new_show_dev_instance %d",
12437 &new_show_dev_instance))
12443 if (sw_if_index == ~0)
12445 errmsg ("missing interface name or sw_if_index");
12449 if (new_show_dev_instance == ~0)
12451 errmsg ("missing new_show_dev_instance");
12455 M (INTERFACE_NAME_RENUMBER, mp);
12457 mp->sw_if_index = ntohl (sw_if_index);
12458 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
12466 api_want_ip4_arp_events (vat_main_t * vam)
12468 unformat_input_t *line_input = vam->input;
12469 vl_api_want_ip4_arp_events_t *mp;
12470 ip4_address_t address;
12471 int address_set = 0;
12472 u32 enable_disable = 1;
12475 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12477 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
12479 else if (unformat (line_input, "del"))
12480 enable_disable = 0;
12485 if (address_set == 0)
12487 errmsg ("missing addresses");
12491 M (WANT_IP4_ARP_EVENTS, mp);
12492 mp->enable_disable = enable_disable;
12493 mp->pid = htonl (getpid ());
12494 mp->address = address.as_u32;
12502 api_want_ip6_nd_events (vat_main_t * vam)
12504 unformat_input_t *line_input = vam->input;
12505 vl_api_want_ip6_nd_events_t *mp;
12506 ip6_address_t address;
12507 int address_set = 0;
12508 u32 enable_disable = 1;
12511 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12513 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
12515 else if (unformat (line_input, "del"))
12516 enable_disable = 0;
12521 if (address_set == 0)
12523 errmsg ("missing addresses");
12527 M (WANT_IP6_ND_EVENTS, mp);
12528 mp->enable_disable = enable_disable;
12529 mp->pid = htonl (getpid ());
12530 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
12538 api_input_acl_set_interface (vat_main_t * vam)
12540 unformat_input_t *i = vam->input;
12541 vl_api_input_acl_set_interface_t *mp;
12543 int sw_if_index_set;
12544 u32 ip4_table_index = ~0;
12545 u32 ip6_table_index = ~0;
12546 u32 l2_table_index = ~0;
12550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12552 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12553 sw_if_index_set = 1;
12554 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12555 sw_if_index_set = 1;
12556 else if (unformat (i, "del"))
12558 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12560 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12562 else if (unformat (i, "l2-table %d", &l2_table_index))
12566 clib_warning ("parse error '%U'", format_unformat_error, i);
12571 if (sw_if_index_set == 0)
12573 errmsg ("missing interface name or sw_if_index");
12577 M (INPUT_ACL_SET_INTERFACE, mp);
12579 mp->sw_if_index = ntohl (sw_if_index);
12580 mp->ip4_table_index = ntohl (ip4_table_index);
12581 mp->ip6_table_index = ntohl (ip6_table_index);
12582 mp->l2_table_index = ntohl (l2_table_index);
12583 mp->is_add = is_add;
12591 api_ip_address_dump (vat_main_t * vam)
12593 unformat_input_t *i = vam->input;
12594 vl_api_ip_address_dump_t *mp;
12595 vl_api_control_ping_t *mp_ping;
12596 u32 sw_if_index = ~0;
12597 u8 sw_if_index_set = 0;
12602 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12604 if (unformat (i, "sw_if_index %d", &sw_if_index))
12605 sw_if_index_set = 1;
12607 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12608 sw_if_index_set = 1;
12609 else if (unformat (i, "ipv4"))
12611 else if (unformat (i, "ipv6"))
12617 if (ipv4_set && ipv6_set)
12619 errmsg ("ipv4 and ipv6 flags cannot be both set");
12623 if ((!ipv4_set) && (!ipv6_set))
12625 errmsg ("no ipv4 nor ipv6 flag set");
12629 if (sw_if_index_set == 0)
12631 errmsg ("missing interface name or sw_if_index");
12635 vam->current_sw_if_index = sw_if_index;
12636 vam->is_ipv6 = ipv6_set;
12638 M (IP_ADDRESS_DUMP, mp);
12639 mp->sw_if_index = ntohl (sw_if_index);
12640 mp->is_ipv6 = ipv6_set;
12643 /* Use a control ping for synchronization */
12644 M (CONTROL_PING, mp_ping);
12652 api_ip_dump (vat_main_t * vam)
12654 vl_api_ip_dump_t *mp;
12655 vl_api_control_ping_t *mp_ping;
12656 unformat_input_t *in = vam->input;
12663 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
12665 if (unformat (in, "ipv4"))
12667 else if (unformat (in, "ipv6"))
12673 if (ipv4_set && ipv6_set)
12675 errmsg ("ipv4 and ipv6 flags cannot be both set");
12679 if ((!ipv4_set) && (!ipv6_set))
12681 errmsg ("no ipv4 nor ipv6 flag set");
12685 is_ipv6 = ipv6_set;
12686 vam->is_ipv6 = is_ipv6;
12688 /* free old data */
12689 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12691 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12693 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12696 mp->is_ipv6 = ipv6_set;
12699 /* Use a control ping for synchronization */
12700 M (CONTROL_PING, mp_ping);
12708 api_ipsec_spd_add_del (vat_main_t * vam)
12710 unformat_input_t *i = vam->input;
12711 vl_api_ipsec_spd_add_del_t *mp;
12716 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12718 if (unformat (i, "spd_id %d", &spd_id))
12720 else if (unformat (i, "del"))
12724 clib_warning ("parse error '%U'", format_unformat_error, i);
12730 errmsg ("spd_id must be set");
12734 M (IPSEC_SPD_ADD_DEL, mp);
12736 mp->spd_id = ntohl (spd_id);
12737 mp->is_add = is_add;
12745 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12747 unformat_input_t *i = vam->input;
12748 vl_api_ipsec_interface_add_del_spd_t *mp;
12750 u8 sw_if_index_set = 0;
12751 u32 spd_id = (u32) ~ 0;
12755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12757 if (unformat (i, "del"))
12759 else if (unformat (i, "spd_id %d", &spd_id))
12762 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12763 sw_if_index_set = 1;
12764 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12765 sw_if_index_set = 1;
12768 clib_warning ("parse error '%U'", format_unformat_error, i);
12774 if (spd_id == (u32) ~ 0)
12776 errmsg ("spd_id must be set");
12780 if (sw_if_index_set == 0)
12782 errmsg ("missing interface name or sw_if_index");
12786 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12788 mp->spd_id = ntohl (spd_id);
12789 mp->sw_if_index = ntohl (sw_if_index);
12790 mp->is_add = is_add;
12798 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12800 unformat_input_t *i = vam->input;
12801 vl_api_ipsec_spd_add_del_entry_t *mp;
12802 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12803 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12805 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12806 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12807 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12808 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12811 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12812 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12813 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12814 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12815 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12816 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12818 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12820 if (unformat (i, "del"))
12822 if (unformat (i, "outbound"))
12824 if (unformat (i, "inbound"))
12826 else if (unformat (i, "spd_id %d", &spd_id))
12828 else if (unformat (i, "sa_id %d", &sa_id))
12830 else if (unformat (i, "priority %d", &priority))
12832 else if (unformat (i, "protocol %d", &protocol))
12834 else if (unformat (i, "lport_start %d", &lport_start))
12836 else if (unformat (i, "lport_stop %d", &lport_stop))
12838 else if (unformat (i, "rport_start %d", &rport_start))
12840 else if (unformat (i, "rport_stop %d", &rport_stop))
12844 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12850 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12857 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12863 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12870 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12876 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12883 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12889 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12895 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12897 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12899 clib_warning ("unsupported action: 'resolve'");
12905 clib_warning ("parse error '%U'", format_unformat_error, i);
12911 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12913 mp->spd_id = ntohl (spd_id);
12914 mp->priority = ntohl (priority);
12915 mp->is_outbound = is_outbound;
12917 mp->is_ipv6 = is_ipv6;
12918 if (is_ipv6 || is_ip_any)
12920 clib_memcpy (mp->remote_address_start, &raddr6_start,
12921 sizeof (ip6_address_t));
12922 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12923 sizeof (ip6_address_t));
12924 clib_memcpy (mp->local_address_start, &laddr6_start,
12925 sizeof (ip6_address_t));
12926 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12927 sizeof (ip6_address_t));
12931 clib_memcpy (mp->remote_address_start, &raddr4_start,
12932 sizeof (ip4_address_t));
12933 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12934 sizeof (ip4_address_t));
12935 clib_memcpy (mp->local_address_start, &laddr4_start,
12936 sizeof (ip4_address_t));
12937 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12938 sizeof (ip4_address_t));
12940 mp->protocol = (u8) protocol;
12941 mp->local_port_start = ntohs ((u16) lport_start);
12942 mp->local_port_stop = ntohs ((u16) lport_stop);
12943 mp->remote_port_start = ntohs ((u16) rport_start);
12944 mp->remote_port_stop = ntohs ((u16) rport_stop);
12945 mp->policy = (u8) policy;
12946 mp->sa_id = ntohl (sa_id);
12947 mp->is_add = is_add;
12948 mp->is_ip_any = is_ip_any;
12955 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12957 unformat_input_t *i = vam->input;
12958 vl_api_ipsec_sad_add_del_entry_t *mp;
12959 u32 sad_id = 0, spi = 0;
12960 u8 *ck = 0, *ik = 0;
12963 u8 protocol = IPSEC_PROTOCOL_AH;
12964 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12965 u32 crypto_alg = 0, integ_alg = 0;
12966 ip4_address_t tun_src4;
12967 ip4_address_t tun_dst4;
12968 ip6_address_t tun_src6;
12969 ip6_address_t tun_dst6;
12972 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12974 if (unformat (i, "del"))
12976 else if (unformat (i, "sad_id %d", &sad_id))
12978 else if (unformat (i, "spi %d", &spi))
12980 else if (unformat (i, "esp"))
12981 protocol = IPSEC_PROTOCOL_ESP;
12982 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12985 is_tunnel_ipv6 = 0;
12987 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12990 is_tunnel_ipv6 = 0;
12992 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12995 is_tunnel_ipv6 = 1;
12997 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
13000 is_tunnel_ipv6 = 1;
13004 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13006 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13007 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13009 clib_warning ("unsupported crypto-alg: '%U'",
13010 format_ipsec_crypto_alg, crypto_alg);
13014 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13018 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13020 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13021 integ_alg >= IPSEC_INTEG_N_ALG)
13023 clib_warning ("unsupported integ-alg: '%U'",
13024 format_ipsec_integ_alg, integ_alg);
13028 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13032 clib_warning ("parse error '%U'", format_unformat_error, i);
13038 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
13040 mp->sad_id = ntohl (sad_id);
13041 mp->is_add = is_add;
13042 mp->protocol = protocol;
13043 mp->spi = ntohl (spi);
13044 mp->is_tunnel = is_tunnel;
13045 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
13046 mp->crypto_algorithm = crypto_alg;
13047 mp->integrity_algorithm = integ_alg;
13048 mp->crypto_key_length = vec_len (ck);
13049 mp->integrity_key_length = vec_len (ik);
13051 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13052 mp->crypto_key_length = sizeof (mp->crypto_key);
13054 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13055 mp->integrity_key_length = sizeof (mp->integrity_key);
13058 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13060 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13064 if (is_tunnel_ipv6)
13066 clib_memcpy (mp->tunnel_src_address, &tun_src6,
13067 sizeof (ip6_address_t));
13068 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
13069 sizeof (ip6_address_t));
13073 clib_memcpy (mp->tunnel_src_address, &tun_src4,
13074 sizeof (ip4_address_t));
13075 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
13076 sizeof (ip4_address_t));
13086 api_ipsec_sa_set_key (vat_main_t * vam)
13088 unformat_input_t *i = vam->input;
13089 vl_api_ipsec_sa_set_key_t *mp;
13091 u8 *ck = 0, *ik = 0;
13094 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13096 if (unformat (i, "sa_id %d", &sa_id))
13098 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13100 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13104 clib_warning ("parse error '%U'", format_unformat_error, i);
13109 M (IPSEC_SA_SET_KEY, mp);
13111 mp->sa_id = ntohl (sa_id);
13112 mp->crypto_key_length = vec_len (ck);
13113 mp->integrity_key_length = vec_len (ik);
13115 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13116 mp->crypto_key_length = sizeof (mp->crypto_key);
13118 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13119 mp->integrity_key_length = sizeof (mp->integrity_key);
13122 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13124 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13132 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
13134 unformat_input_t *i = vam->input;
13135 vl_api_ipsec_tunnel_if_add_del_t *mp;
13136 u32 local_spi = 0, remote_spi = 0;
13137 u32 crypto_alg = 0, integ_alg = 0;
13138 u8 *lck = NULL, *rck = NULL;
13139 u8 *lik = NULL, *rik = NULL;
13140 ip4_address_t local_ip = { {0} };
13141 ip4_address_t remote_ip = { {0} };
13144 u8 anti_replay = 0;
13147 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13149 if (unformat (i, "del"))
13151 else if (unformat (i, "esn"))
13153 else if (unformat (i, "anti_replay"))
13155 else if (unformat (i, "local_spi %d", &local_spi))
13157 else if (unformat (i, "remote_spi %d", &remote_spi))
13159 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
13161 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
13163 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
13166 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
13168 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
13170 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
13174 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13176 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13177 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13179 errmsg ("unsupported crypto-alg: '%U'\n",
13180 format_ipsec_crypto_alg, crypto_alg);
13186 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13188 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13189 integ_alg >= IPSEC_INTEG_N_ALG)
13191 errmsg ("unsupported integ-alg: '%U'\n",
13192 format_ipsec_integ_alg, integ_alg);
13198 errmsg ("parse error '%U'\n", format_unformat_error, i);
13203 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
13205 mp->is_add = is_add;
13207 mp->anti_replay = anti_replay;
13209 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
13210 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
13212 mp->local_spi = htonl (local_spi);
13213 mp->remote_spi = htonl (remote_spi);
13214 mp->crypto_alg = (u8) crypto_alg;
13216 mp->local_crypto_key_len = 0;
13219 mp->local_crypto_key_len = vec_len (lck);
13220 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
13221 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
13222 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
13225 mp->remote_crypto_key_len = 0;
13228 mp->remote_crypto_key_len = vec_len (rck);
13229 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
13230 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
13231 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
13234 mp->integ_alg = (u8) integ_alg;
13236 mp->local_integ_key_len = 0;
13239 mp->local_integ_key_len = vec_len (lik);
13240 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
13241 mp->local_integ_key_len = sizeof (mp->local_integ_key);
13242 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
13245 mp->remote_integ_key_len = 0;
13248 mp->remote_integ_key_len = vec_len (rik);
13249 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
13250 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
13251 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
13260 api_ikev2_profile_add_del (vat_main_t * vam)
13262 unformat_input_t *i = vam->input;
13263 vl_api_ikev2_profile_add_del_t *mp;
13268 const char *valid_chars = "a-zA-Z0-9_";
13270 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13272 if (unformat (i, "del"))
13274 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13275 vec_add1 (name, 0);
13278 errmsg ("parse error '%U'", format_unformat_error, i);
13283 if (!vec_len (name))
13285 errmsg ("profile name must be specified");
13289 if (vec_len (name) > 64)
13291 errmsg ("profile name too long");
13295 M (IKEV2_PROFILE_ADD_DEL, mp);
13297 clib_memcpy (mp->name, name, vec_len (name));
13298 mp->is_add = is_add;
13307 api_ikev2_profile_set_auth (vat_main_t * vam)
13309 unformat_input_t *i = vam->input;
13310 vl_api_ikev2_profile_set_auth_t *mp;
13313 u32 auth_method = 0;
13317 const char *valid_chars = "a-zA-Z0-9_";
13319 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13321 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13322 vec_add1 (name, 0);
13323 else if (unformat (i, "auth_method %U",
13324 unformat_ikev2_auth_method, &auth_method))
13326 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
13328 else if (unformat (i, "auth_data %v", &data))
13332 errmsg ("parse error '%U'", format_unformat_error, i);
13337 if (!vec_len (name))
13339 errmsg ("profile name must be specified");
13343 if (vec_len (name) > 64)
13345 errmsg ("profile name too long");
13349 if (!vec_len (data))
13351 errmsg ("auth_data must be specified");
13357 errmsg ("auth_method must be specified");
13361 M (IKEV2_PROFILE_SET_AUTH, mp);
13363 mp->is_hex = is_hex;
13364 mp->auth_method = (u8) auth_method;
13365 mp->data_len = vec_len (data);
13366 clib_memcpy (mp->name, name, vec_len (name));
13367 clib_memcpy (mp->data, data, vec_len (data));
13377 api_ikev2_profile_set_id (vat_main_t * vam)
13379 unformat_input_t *i = vam->input;
13380 vl_api_ikev2_profile_set_id_t *mp;
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, "id_type %U", unformat_ikev2_id_type, &id_type))
13396 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
13398 data = vec_new (u8, 4);
13399 clib_memcpy (data, ip4.as_u8, 4);
13401 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
13403 else if (unformat (i, "id_data %v", &data))
13405 else if (unformat (i, "local"))
13407 else if (unformat (i, "remote"))
13411 errmsg ("parse error '%U'", format_unformat_error, i);
13416 if (!vec_len (name))
13418 errmsg ("profile name must be specified");
13422 if (vec_len (name) > 64)
13424 errmsg ("profile name too long");
13428 if (!vec_len (data))
13430 errmsg ("id_data must be specified");
13436 errmsg ("id_type must be specified");
13440 M (IKEV2_PROFILE_SET_ID, mp);
13442 mp->is_local = is_local;
13443 mp->id_type = (u8) id_type;
13444 mp->data_len = vec_len (data);
13445 clib_memcpy (mp->name, name, vec_len (name));
13446 clib_memcpy (mp->data, data, vec_len (data));
13456 api_ikev2_profile_set_ts (vat_main_t * vam)
13458 unformat_input_t *i = vam->input;
13459 vl_api_ikev2_profile_set_ts_t *mp;
13462 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
13463 ip4_address_t start_addr, end_addr;
13465 const char *valid_chars = "a-zA-Z0-9_";
13468 start_addr.as_u32 = 0;
13469 end_addr.as_u32 = (u32) ~ 0;
13471 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13473 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13474 vec_add1 (name, 0);
13475 else if (unformat (i, "protocol %d", &proto))
13477 else if (unformat (i, "start_port %d", &start_port))
13479 else if (unformat (i, "end_port %d", &end_port))
13482 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
13484 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
13486 else if (unformat (i, "local"))
13488 else if (unformat (i, "remote"))
13492 errmsg ("parse error '%U'", format_unformat_error, i);
13497 if (!vec_len (name))
13499 errmsg ("profile name must be specified");
13503 if (vec_len (name) > 64)
13505 errmsg ("profile name too long");
13509 M (IKEV2_PROFILE_SET_TS, mp);
13511 mp->is_local = is_local;
13512 mp->proto = (u8) proto;
13513 mp->start_port = (u16) start_port;
13514 mp->end_port = (u16) end_port;
13515 mp->start_addr = start_addr.as_u32;
13516 mp->end_addr = end_addr.as_u32;
13517 clib_memcpy (mp->name, name, vec_len (name));
13526 api_ikev2_set_local_key (vat_main_t * vam)
13528 unformat_input_t *i = vam->input;
13529 vl_api_ikev2_set_local_key_t *mp;
13533 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13535 if (unformat (i, "file %v", &file))
13536 vec_add1 (file, 0);
13539 errmsg ("parse error '%U'", format_unformat_error, i);
13544 if (!vec_len (file))
13546 errmsg ("RSA key file must be specified");
13550 if (vec_len (file) > 256)
13552 errmsg ("file name too long");
13556 M (IKEV2_SET_LOCAL_KEY, mp);
13558 clib_memcpy (mp->key_file, file, vec_len (file));
13567 api_ikev2_set_responder (vat_main_t * vam)
13569 unformat_input_t *i = vam->input;
13570 vl_api_ikev2_set_responder_t *mp;
13573 u32 sw_if_index = ~0;
13574 ip4_address_t address;
13576 const char *valid_chars = "a-zA-Z0-9_";
13578 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13581 (i, "%U interface %d address %U", unformat_token, valid_chars,
13582 &name, &sw_if_index, unformat_ip4_address, &address))
13583 vec_add1 (name, 0);
13586 errmsg ("parse error '%U'", format_unformat_error, i);
13591 if (!vec_len (name))
13593 errmsg ("profile name must be specified");
13597 if (vec_len (name) > 64)
13599 errmsg ("profile name too long");
13603 M (IKEV2_SET_RESPONDER, mp);
13605 clib_memcpy (mp->name, name, vec_len (name));
13608 mp->sw_if_index = sw_if_index;
13609 clib_memcpy (mp->address, &address, sizeof (address));
13617 api_ikev2_set_ike_transforms (vat_main_t * vam)
13619 unformat_input_t *i = vam->input;
13620 vl_api_ikev2_set_ike_transforms_t *mp;
13623 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13625 const char *valid_chars = "a-zA-Z0-9_";
13627 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13629 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13630 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13631 vec_add1 (name, 0);
13634 errmsg ("parse error '%U'", format_unformat_error, i);
13639 if (!vec_len (name))
13641 errmsg ("profile name must be specified");
13645 if (vec_len (name) > 64)
13647 errmsg ("profile name too long");
13651 M (IKEV2_SET_IKE_TRANSFORMS, mp);
13653 clib_memcpy (mp->name, name, vec_len (name));
13655 mp->crypto_alg = crypto_alg;
13656 mp->crypto_key_size = crypto_key_size;
13657 mp->integ_alg = integ_alg;
13658 mp->dh_group = dh_group;
13667 api_ikev2_set_esp_transforms (vat_main_t * vam)
13669 unformat_input_t *i = vam->input;
13670 vl_api_ikev2_set_esp_transforms_t *mp;
13673 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13675 const char *valid_chars = "a-zA-Z0-9_";
13677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13679 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13680 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13681 vec_add1 (name, 0);
13684 errmsg ("parse error '%U'", format_unformat_error, i);
13689 if (!vec_len (name))
13691 errmsg ("profile name must be specified");
13695 if (vec_len (name) > 64)
13697 errmsg ("profile name too long");
13701 M (IKEV2_SET_ESP_TRANSFORMS, mp);
13703 clib_memcpy (mp->name, name, vec_len (name));
13705 mp->crypto_alg = crypto_alg;
13706 mp->crypto_key_size = crypto_key_size;
13707 mp->integ_alg = integ_alg;
13708 mp->dh_group = dh_group;
13716 api_ikev2_set_sa_lifetime (vat_main_t * vam)
13718 unformat_input_t *i = vam->input;
13719 vl_api_ikev2_set_sa_lifetime_t *mp;
13722 u64 lifetime, lifetime_maxdata;
13723 u32 lifetime_jitter, handover;
13725 const char *valid_chars = "a-zA-Z0-9_";
13727 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13729 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
13730 &lifetime, &lifetime_jitter, &handover,
13731 &lifetime_maxdata))
13732 vec_add1 (name, 0);
13735 errmsg ("parse error '%U'", format_unformat_error, i);
13740 if (!vec_len (name))
13742 errmsg ("profile name must be specified");
13746 if (vec_len (name) > 64)
13748 errmsg ("profile name too long");
13752 M (IKEV2_SET_SA_LIFETIME, mp);
13754 clib_memcpy (mp->name, name, vec_len (name));
13756 mp->lifetime = lifetime;
13757 mp->lifetime_jitter = lifetime_jitter;
13758 mp->handover = handover;
13759 mp->lifetime_maxdata = lifetime_maxdata;
13767 api_ikev2_initiate_sa_init (vat_main_t * vam)
13769 unformat_input_t *i = vam->input;
13770 vl_api_ikev2_initiate_sa_init_t *mp;
13774 const char *valid_chars = "a-zA-Z0-9_";
13776 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13778 if (unformat (i, "%U", unformat_token, valid_chars, &name))
13779 vec_add1 (name, 0);
13782 errmsg ("parse error '%U'", format_unformat_error, i);
13787 if (!vec_len (name))
13789 errmsg ("profile name must be specified");
13793 if (vec_len (name) > 64)
13795 errmsg ("profile name too long");
13799 M (IKEV2_INITIATE_SA_INIT, mp);
13801 clib_memcpy (mp->name, name, vec_len (name));
13810 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
13812 unformat_input_t *i = vam->input;
13813 vl_api_ikev2_initiate_del_ike_sa_t *mp;
13818 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13820 if (unformat (i, "%lx", &ispi))
13824 errmsg ("parse error '%U'", format_unformat_error, i);
13829 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
13839 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13841 unformat_input_t *i = vam->input;
13842 vl_api_ikev2_initiate_del_child_sa_t *mp;
13847 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13849 if (unformat (i, "%x", &ispi))
13853 errmsg ("parse error '%U'", format_unformat_error, i);
13858 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13868 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13870 unformat_input_t *i = vam->input;
13871 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13876 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13878 if (unformat (i, "%x", &ispi))
13882 errmsg ("parse error '%U'", format_unformat_error, i);
13887 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
13900 api_map_add_domain (vat_main_t * vam)
13902 unformat_input_t *i = vam->input;
13903 vl_api_map_add_domain_t *mp;
13905 ip4_address_t ip4_prefix;
13906 ip6_address_t ip6_prefix;
13907 ip6_address_t ip6_src;
13908 u32 num_m_args = 0;
13909 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
13910 0, psid_length = 0;
13911 u8 is_translation = 0;
13913 u32 ip6_src_len = 128;
13916 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13918 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
13919 &ip4_prefix, &ip4_prefix_len))
13921 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
13922 &ip6_prefix, &ip6_prefix_len))
13926 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
13929 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
13931 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
13933 else if (unformat (i, "psid-offset %d", &psid_offset))
13935 else if (unformat (i, "psid-len %d", &psid_length))
13937 else if (unformat (i, "mtu %d", &mtu))
13939 else if (unformat (i, "map-t"))
13940 is_translation = 1;
13943 clib_warning ("parse error '%U'", format_unformat_error, i);
13948 if (num_m_args < 3)
13950 errmsg ("mandatory argument(s) missing");
13954 /* Construct the API message */
13955 M (MAP_ADD_DOMAIN, mp);
13957 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
13958 mp->ip4_prefix_len = ip4_prefix_len;
13960 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
13961 mp->ip6_prefix_len = ip6_prefix_len;
13963 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
13964 mp->ip6_src_prefix_len = ip6_src_len;
13966 mp->ea_bits_len = ea_bits_len;
13967 mp->psid_offset = psid_offset;
13968 mp->psid_length = psid_length;
13969 mp->is_translation = is_translation;
13970 mp->mtu = htons (mtu);
13975 /* Wait for a reply, return good/bad news */
13981 api_map_del_domain (vat_main_t * vam)
13983 unformat_input_t *i = vam->input;
13984 vl_api_map_del_domain_t *mp;
13986 u32 num_m_args = 0;
13990 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13992 if (unformat (i, "index %d", &index))
13996 clib_warning ("parse error '%U'", format_unformat_error, i);
14001 if (num_m_args != 1)
14003 errmsg ("mandatory argument(s) missing");
14007 /* Construct the API message */
14008 M (MAP_DEL_DOMAIN, mp);
14010 mp->index = ntohl (index);
14015 /* Wait for a reply, return good/bad news */
14021 api_map_add_del_rule (vat_main_t * vam)
14023 unformat_input_t *i = vam->input;
14024 vl_api_map_add_del_rule_t *mp;
14026 ip6_address_t ip6_dst;
14027 u32 num_m_args = 0, index, psid = 0;
14030 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14032 if (unformat (i, "index %d", &index))
14034 else if (unformat (i, "psid %d", &psid))
14036 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
14038 else if (unformat (i, "del"))
14044 clib_warning ("parse error '%U'", format_unformat_error, i);
14049 /* Construct the API message */
14050 M (MAP_ADD_DEL_RULE, mp);
14052 mp->index = ntohl (index);
14053 mp->is_add = is_add;
14054 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
14055 mp->psid = ntohs (psid);
14060 /* Wait for a reply, return good/bad news */
14066 api_map_domain_dump (vat_main_t * vam)
14068 vl_api_map_domain_dump_t *mp;
14069 vl_api_control_ping_t *mp_ping;
14072 /* Construct the API message */
14073 M (MAP_DOMAIN_DUMP, mp);
14078 /* Use a control ping for synchronization */
14079 M (CONTROL_PING, mp_ping);
14087 api_map_rule_dump (vat_main_t * vam)
14089 unformat_input_t *i = vam->input;
14090 vl_api_map_rule_dump_t *mp;
14091 vl_api_control_ping_t *mp_ping;
14092 u32 domain_index = ~0;
14095 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14097 if (unformat (i, "index %u", &domain_index))
14103 if (domain_index == ~0)
14105 clib_warning ("parse error: domain index expected");
14109 /* Construct the API message */
14110 M (MAP_RULE_DUMP, mp);
14112 mp->domain_index = htonl (domain_index);
14117 /* Use a control ping for synchronization */
14118 M (CONTROL_PING, mp_ping);
14125 static void vl_api_map_add_domain_reply_t_handler
14126 (vl_api_map_add_domain_reply_t * mp)
14128 vat_main_t *vam = &vat_main;
14129 i32 retval = ntohl (mp->retval);
14131 if (vam->async_mode)
14133 vam->async_errors += (retval < 0);
14137 vam->retval = retval;
14138 vam->result_ready = 1;
14142 static void vl_api_map_add_domain_reply_t_handler_json
14143 (vl_api_map_add_domain_reply_t * mp)
14145 vat_main_t *vam = &vat_main;
14146 vat_json_node_t node;
14148 vat_json_init_object (&node);
14149 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
14150 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
14152 vat_json_print (vam->ofp, &node);
14153 vat_json_free (&node);
14155 vam->retval = ntohl (mp->retval);
14156 vam->result_ready = 1;
14160 api_get_first_msg_id (vat_main_t * vam)
14162 vl_api_get_first_msg_id_t *mp;
14163 unformat_input_t *i = vam->input;
14168 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14170 if (unformat (i, "client %s", &name))
14178 errmsg ("missing client name");
14181 vec_add1 (name, 0);
14183 if (vec_len (name) > 63)
14185 errmsg ("client name too long");
14189 M (GET_FIRST_MSG_ID, mp);
14190 clib_memcpy (mp->name, name, vec_len (name));
14197 api_cop_interface_enable_disable (vat_main_t * vam)
14199 unformat_input_t *line_input = vam->input;
14200 vl_api_cop_interface_enable_disable_t *mp;
14201 u32 sw_if_index = ~0;
14202 u8 enable_disable = 1;
14205 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14207 if (unformat (line_input, "disable"))
14208 enable_disable = 0;
14209 if (unformat (line_input, "enable"))
14210 enable_disable = 1;
14211 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14212 vam, &sw_if_index))
14214 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14220 if (sw_if_index == ~0)
14222 errmsg ("missing interface name or sw_if_index");
14226 /* Construct the API message */
14227 M (COP_INTERFACE_ENABLE_DISABLE, mp);
14228 mp->sw_if_index = ntohl (sw_if_index);
14229 mp->enable_disable = enable_disable;
14233 /* Wait for the reply */
14239 api_cop_whitelist_enable_disable (vat_main_t * vam)
14241 unformat_input_t *line_input = vam->input;
14242 vl_api_cop_whitelist_enable_disable_t *mp;
14243 u32 sw_if_index = ~0;
14244 u8 ip4 = 0, ip6 = 0, default_cop = 0;
14248 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14250 if (unformat (line_input, "ip4"))
14252 else if (unformat (line_input, "ip6"))
14254 else if (unformat (line_input, "default"))
14256 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14257 vam, &sw_if_index))
14259 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14261 else if (unformat (line_input, "fib-id %d", &fib_id))
14267 if (sw_if_index == ~0)
14269 errmsg ("missing interface name or sw_if_index");
14273 /* Construct the API message */
14274 M (COP_WHITELIST_ENABLE_DISABLE, mp);
14275 mp->sw_if_index = ntohl (sw_if_index);
14276 mp->fib_id = ntohl (fib_id);
14279 mp->default_cop = default_cop;
14283 /* Wait for the reply */
14289 api_get_node_graph (vat_main_t * vam)
14291 vl_api_get_node_graph_t *mp;
14294 M (GET_NODE_GRAPH, mp);
14298 /* Wait for the reply */
14304 /** Used for parsing LISP eids */
14305 typedef CLIB_PACKED(struct{
14306 u8 addr[16]; /**< eid address */
14307 u32 len; /**< prefix length if IP */
14308 u8 type; /**< type of eid */
14313 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14315 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14317 memset (a, 0, sizeof (a[0]));
14319 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
14321 a->type = 0; /* ipv4 type */
14323 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
14325 a->type = 1; /* ipv6 type */
14327 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
14329 a->type = 2; /* mac type */
14331 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
14333 a->type = 3; /* NSH type */
14334 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
14335 nsh->spi = clib_host_to_net_u32 (nsh->spi);
14342 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
14351 lisp_eid_size_vat (u8 type)
14368 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
14370 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
14374 api_one_add_del_locator_set (vat_main_t * vam)
14376 unformat_input_t *input = vam->input;
14377 vl_api_one_add_del_locator_set_t *mp;
14379 u8 *locator_set_name = NULL;
14380 u8 locator_set_name_set = 0;
14381 vl_api_local_locator_t locator, *locators = 0;
14382 u32 sw_if_index, priority, weight;
14386 /* Parse args required to build the message */
14387 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14389 if (unformat (input, "del"))
14393 else if (unformat (input, "locator-set %s", &locator_set_name))
14395 locator_set_name_set = 1;
14397 else if (unformat (input, "sw_if_index %u p %u w %u",
14398 &sw_if_index, &priority, &weight))
14400 locator.sw_if_index = htonl (sw_if_index);
14401 locator.priority = priority;
14402 locator.weight = weight;
14403 vec_add1 (locators, locator);
14407 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14408 &sw_if_index, &priority, &weight))
14410 locator.sw_if_index = htonl (sw_if_index);
14411 locator.priority = priority;
14412 locator.weight = weight;
14413 vec_add1 (locators, locator);
14419 if (locator_set_name_set == 0)
14421 errmsg ("missing locator-set name");
14422 vec_free (locators);
14426 if (vec_len (locator_set_name) > 64)
14428 errmsg ("locator-set name too long");
14429 vec_free (locator_set_name);
14430 vec_free (locators);
14433 vec_add1 (locator_set_name, 0);
14435 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14437 /* Construct the API message */
14438 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14440 mp->is_add = is_add;
14441 clib_memcpy (mp->locator_set_name, locator_set_name,
14442 vec_len (locator_set_name));
14443 vec_free (locator_set_name);
14445 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14447 clib_memcpy (mp->locators, locators, data_len);
14448 vec_free (locators);
14453 /* Wait for a reply... */
14458 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14461 api_one_add_del_locator (vat_main_t * vam)
14463 unformat_input_t *input = vam->input;
14464 vl_api_one_add_del_locator_t *mp;
14465 u32 tmp_if_index = ~0;
14466 u32 sw_if_index = ~0;
14467 u8 sw_if_index_set = 0;
14468 u8 sw_if_index_if_name_set = 0;
14470 u8 priority_set = 0;
14474 u8 *locator_set_name = NULL;
14475 u8 locator_set_name_set = 0;
14478 /* Parse args required to build the message */
14479 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14481 if (unformat (input, "del"))
14485 else if (unformat (input, "locator-set %s", &locator_set_name))
14487 locator_set_name_set = 1;
14489 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14492 sw_if_index_if_name_set = 1;
14493 sw_if_index = tmp_if_index;
14495 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14497 sw_if_index_set = 1;
14498 sw_if_index = tmp_if_index;
14500 else if (unformat (input, "p %d", &priority))
14504 else if (unformat (input, "w %d", &weight))
14512 if (locator_set_name_set == 0)
14514 errmsg ("missing locator-set name");
14518 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14520 errmsg ("missing sw_if_index");
14521 vec_free (locator_set_name);
14525 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14527 errmsg ("cannot use both params interface name and sw_if_index");
14528 vec_free (locator_set_name);
14532 if (priority_set == 0)
14534 errmsg ("missing locator-set priority");
14535 vec_free (locator_set_name);
14539 if (weight_set == 0)
14541 errmsg ("missing locator-set weight");
14542 vec_free (locator_set_name);
14546 if (vec_len (locator_set_name) > 64)
14548 errmsg ("locator-set name too long");
14549 vec_free (locator_set_name);
14552 vec_add1 (locator_set_name, 0);
14554 /* Construct the API message */
14555 M (ONE_ADD_DEL_LOCATOR, mp);
14557 mp->is_add = is_add;
14558 mp->sw_if_index = ntohl (sw_if_index);
14559 mp->priority = priority;
14560 mp->weight = weight;
14561 clib_memcpy (mp->locator_set_name, locator_set_name,
14562 vec_len (locator_set_name));
14563 vec_free (locator_set_name);
14568 /* Wait for a reply... */
14573 #define api_lisp_add_del_locator api_one_add_del_locator
14576 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14578 u32 *key_id = va_arg (*args, u32 *);
14581 if (unformat (input, "%s", &s))
14583 if (!strcmp ((char *) s, "sha1"))
14584 key_id[0] = HMAC_SHA_1_96;
14585 else if (!strcmp ((char *) s, "sha256"))
14586 key_id[0] = HMAC_SHA_256_128;
14589 clib_warning ("invalid key_id: '%s'", s);
14590 key_id[0] = HMAC_NO_KEY;
14601 api_one_add_del_local_eid (vat_main_t * vam)
14603 unformat_input_t *input = vam->input;
14604 vl_api_one_add_del_local_eid_t *mp;
14607 lisp_eid_vat_t _eid, *eid = &_eid;
14608 u8 *locator_set_name = 0;
14609 u8 locator_set_name_set = 0;
14615 /* Parse args required to build the message */
14616 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14618 if (unformat (input, "del"))
14622 else if (unformat (input, "vni %d", &vni))
14626 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14630 else if (unformat (input, "locator-set %s", &locator_set_name))
14632 locator_set_name_set = 1;
14634 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14636 else if (unformat (input, "secret-key %_%v%_", &key))
14642 if (locator_set_name_set == 0)
14644 errmsg ("missing locator-set name");
14650 errmsg ("EID address not set!");
14651 vec_free (locator_set_name);
14655 if (key && (0 == key_id))
14657 errmsg ("invalid key_id!");
14661 if (vec_len (key) > 64)
14663 errmsg ("key too long");
14668 if (vec_len (locator_set_name) > 64)
14670 errmsg ("locator-set name too long");
14671 vec_free (locator_set_name);
14674 vec_add1 (locator_set_name, 0);
14676 /* Construct the API message */
14677 M (ONE_ADD_DEL_LOCAL_EID, mp);
14679 mp->is_add = is_add;
14680 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14681 mp->eid_type = eid->type;
14682 mp->prefix_len = eid->len;
14683 mp->vni = clib_host_to_net_u32 (vni);
14684 mp->key_id = clib_host_to_net_u16 (key_id);
14685 clib_memcpy (mp->locator_set_name, locator_set_name,
14686 vec_len (locator_set_name));
14687 clib_memcpy (mp->key, key, vec_len (key));
14689 vec_free (locator_set_name);
14695 /* Wait for a reply... */
14700 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14703 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14705 u32 dp_table = 0, vni = 0;;
14706 unformat_input_t *input = vam->input;
14707 vl_api_gpe_add_del_fwd_entry_t *mp;
14709 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14710 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14711 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14712 u32 action = ~0, w;
14713 ip4_address_t rmt_rloc4, lcl_rloc4;
14714 ip6_address_t rmt_rloc6, lcl_rloc6;
14715 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14718 memset (&rloc, 0, sizeof (rloc));
14720 /* Parse args required to build the message */
14721 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14723 if (unformat (input, "del"))
14725 else if (unformat (input, "add"))
14727 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14731 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14735 else if (unformat (input, "vrf %d", &dp_table))
14737 else if (unformat (input, "bd %d", &dp_table))
14739 else if (unformat (input, "vni %d", &vni))
14741 else if (unformat (input, "w %d", &w))
14745 errmsg ("No RLOC configured for setting priority/weight!");
14748 curr_rloc->weight = w;
14750 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14751 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14755 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
14757 vec_add1 (lcl_locs, rloc);
14759 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
14760 vec_add1 (rmt_locs, rloc);
14761 /* weight saved in rmt loc */
14762 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14764 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14765 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14768 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
14770 vec_add1 (lcl_locs, rloc);
14772 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
14773 vec_add1 (rmt_locs, rloc);
14774 /* weight saved in rmt loc */
14775 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14777 else if (unformat (input, "action %d", &action))
14783 clib_warning ("parse error '%U'", format_unformat_error, input);
14790 errmsg ("remote eid addresses not set");
14794 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14796 errmsg ("eid types don't match");
14800 if (0 == rmt_locs && (u32) ~ 0 == action)
14802 errmsg ("action not set for negative mapping");
14806 /* Construct the API message */
14807 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14808 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14810 mp->is_add = is_add;
14811 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14812 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14813 mp->eid_type = rmt_eid->type;
14814 mp->dp_table = clib_host_to_net_u32 (dp_table);
14815 mp->vni = clib_host_to_net_u32 (vni);
14816 mp->rmt_len = rmt_eid->len;
14817 mp->lcl_len = lcl_eid->len;
14818 mp->action = action;
14820 if (0 != rmt_locs && 0 != lcl_locs)
14822 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14823 clib_memcpy (mp->locs, lcl_locs,
14824 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14826 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14827 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14828 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14830 vec_free (lcl_locs);
14831 vec_free (rmt_locs);
14836 /* Wait for a reply... */
14842 api_one_add_del_map_server (vat_main_t * vam)
14844 unformat_input_t *input = vam->input;
14845 vl_api_one_add_del_map_server_t *mp;
14849 ip4_address_t ipv4;
14850 ip6_address_t ipv6;
14853 /* Parse args required to build the message */
14854 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14856 if (unformat (input, "del"))
14860 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14864 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14872 if (ipv4_set && ipv6_set)
14874 errmsg ("both eid v4 and v6 addresses set");
14878 if (!ipv4_set && !ipv6_set)
14880 errmsg ("eid addresses not set");
14884 /* Construct the API message */
14885 M (ONE_ADD_DEL_MAP_SERVER, mp);
14887 mp->is_add = is_add;
14891 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14896 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14902 /* Wait for a reply... */
14907 #define api_lisp_add_del_map_server api_one_add_del_map_server
14910 api_one_add_del_map_resolver (vat_main_t * vam)
14912 unformat_input_t *input = vam->input;
14913 vl_api_one_add_del_map_resolver_t *mp;
14917 ip4_address_t ipv4;
14918 ip6_address_t ipv6;
14921 /* Parse args required to build the message */
14922 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14924 if (unformat (input, "del"))
14928 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14932 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14940 if (ipv4_set && ipv6_set)
14942 errmsg ("both eid v4 and v6 addresses set");
14946 if (!ipv4_set && !ipv6_set)
14948 errmsg ("eid addresses not set");
14952 /* Construct the API message */
14953 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14955 mp->is_add = is_add;
14959 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14964 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14970 /* Wait for a reply... */
14975 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14978 api_lisp_gpe_enable_disable (vat_main_t * vam)
14980 unformat_input_t *input = vam->input;
14981 vl_api_gpe_enable_disable_t *mp;
14986 /* Parse args required to build the message */
14987 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14989 if (unformat (input, "enable"))
14994 else if (unformat (input, "disable"))
15005 errmsg ("Value not set");
15009 /* Construct the API message */
15010 M (GPE_ENABLE_DISABLE, mp);
15017 /* Wait for a reply... */
15023 api_one_rloc_probe_enable_disable (vat_main_t * vam)
15025 unformat_input_t *input = vam->input;
15026 vl_api_one_rloc_probe_enable_disable_t *mp;
15031 /* Parse args required to build the message */
15032 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15034 if (unformat (input, "enable"))
15039 else if (unformat (input, "disable"))
15047 errmsg ("Value not set");
15051 /* Construct the API message */
15052 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15054 mp->is_enabled = is_en;
15059 /* Wait for a reply... */
15064 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15067 api_one_map_register_enable_disable (vat_main_t * vam)
15069 unformat_input_t *input = vam->input;
15070 vl_api_one_map_register_enable_disable_t *mp;
15075 /* Parse args required to build the message */
15076 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15078 if (unformat (input, "enable"))
15083 else if (unformat (input, "disable"))
15091 errmsg ("Value not set");
15095 /* Construct the API message */
15096 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15098 mp->is_enabled = is_en;
15103 /* Wait for a reply... */
15108 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15111 api_one_enable_disable (vat_main_t * vam)
15113 unformat_input_t *input = vam->input;
15114 vl_api_one_enable_disable_t *mp;
15119 /* Parse args required to build the message */
15120 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15122 if (unformat (input, "enable"))
15127 else if (unformat (input, "disable"))
15137 errmsg ("Value not set");
15141 /* Construct the API message */
15142 M (ONE_ENABLE_DISABLE, mp);
15149 /* Wait for a reply... */
15154 #define api_lisp_enable_disable api_one_enable_disable
15157 api_show_one_map_register_state (vat_main_t * vam)
15159 vl_api_show_one_map_register_state_t *mp;
15162 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
15167 /* wait for reply */
15172 #define api_show_lisp_map_register_state api_show_one_map_register_state
15175 api_show_one_rloc_probe_state (vat_main_t * vam)
15177 vl_api_show_one_rloc_probe_state_t *mp;
15180 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
15185 /* wait for reply */
15190 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
15193 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15195 vl_api_one_add_del_l2_arp_entry_t *mp;
15196 unformat_input_t *input = vam->input;
15201 u8 mac[6] = { 0, };
15202 u32 ip4 = 0, bd = ~0;
15205 /* Parse args required to build the message */
15206 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15208 if (unformat (input, "del"))
15210 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15212 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15214 else if (unformat (input, "bd %d", &bd))
15218 errmsg ("parse error '%U'", format_unformat_error, input);
15223 if (!bd_set || !ip_set || (!mac_set && is_add))
15225 errmsg ("Missing BD, IP or MAC!");
15229 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15230 mp->is_add = is_add;
15231 clib_memcpy (mp->mac, mac, 6);
15232 mp->bd = clib_host_to_net_u32 (bd);
15238 /* wait for reply */
15244 api_one_l2_arp_bd_get (vat_main_t * vam)
15246 vl_api_one_l2_arp_bd_get_t *mp;
15249 M (ONE_L2_ARP_BD_GET, mp);
15254 /* wait for reply */
15260 api_one_l2_arp_entries_get (vat_main_t * vam)
15262 vl_api_one_l2_arp_entries_get_t *mp;
15263 unformat_input_t *input = vam->input;
15268 /* Parse args required to build the message */
15269 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15271 if (unformat (input, "bd %d", &bd))
15275 errmsg ("parse error '%U'", format_unformat_error, input);
15282 errmsg ("Expected bridge domain!");
15286 M (ONE_L2_ARP_ENTRIES_GET, mp);
15287 mp->bd = clib_host_to_net_u32 (bd);
15292 /* wait for reply */
15298 api_one_stats_enable_disable (vat_main_t * vam)
15300 vl_api_one_stats_enable_disable_t *mp;
15301 unformat_input_t *input = vam->input;
15306 /* Parse args required to build the message */
15307 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15309 if (unformat (input, "enable"))
15314 else if (unformat (input, "disable"))
15324 errmsg ("Value not set");
15328 M (ONE_STATS_ENABLE_DISABLE, mp);
15334 /* wait for reply */
15340 api_show_one_stats_enable_disable (vat_main_t * vam)
15342 vl_api_show_one_stats_enable_disable_t *mp;
15345 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
15350 /* wait for reply */
15356 api_show_one_map_request_mode (vat_main_t * vam)
15358 vl_api_show_one_map_request_mode_t *mp;
15361 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
15366 /* wait for reply */
15371 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
15374 api_one_map_request_mode (vat_main_t * vam)
15376 unformat_input_t *input = vam->input;
15377 vl_api_one_map_request_mode_t *mp;
15381 /* Parse args required to build the message */
15382 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15384 if (unformat (input, "dst-only"))
15386 else if (unformat (input, "src-dst"))
15390 errmsg ("parse error '%U'", format_unformat_error, input);
15395 M (ONE_MAP_REQUEST_MODE, mp);
15402 /* wait for reply */
15407 #define api_lisp_map_request_mode api_one_map_request_mode
15410 * Enable/disable ONE proxy ITR.
15412 * @param vam vpp API test context
15413 * @return return code
15416 api_one_pitr_set_locator_set (vat_main_t * vam)
15418 u8 ls_name_set = 0;
15419 unformat_input_t *input = vam->input;
15420 vl_api_one_pitr_set_locator_set_t *mp;
15425 /* Parse args required to build the message */
15426 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15428 if (unformat (input, "del"))
15430 else if (unformat (input, "locator-set %s", &ls_name))
15434 errmsg ("parse error '%U'", format_unformat_error, input);
15441 errmsg ("locator-set name not set!");
15445 M (ONE_PITR_SET_LOCATOR_SET, mp);
15447 mp->is_add = is_add;
15448 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15449 vec_free (ls_name);
15454 /* wait for reply */
15459 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
15462 api_one_nsh_set_locator_set (vat_main_t * vam)
15464 u8 ls_name_set = 0;
15465 unformat_input_t *input = vam->input;
15466 vl_api_one_nsh_set_locator_set_t *mp;
15471 /* Parse args required to build the message */
15472 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15474 if (unformat (input, "del"))
15476 else if (unformat (input, "ls %s", &ls_name))
15480 errmsg ("parse error '%U'", format_unformat_error, input);
15485 if (!ls_name_set && is_add)
15487 errmsg ("locator-set name not set!");
15491 M (ONE_NSH_SET_LOCATOR_SET, mp);
15493 mp->is_add = is_add;
15494 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15495 vec_free (ls_name);
15500 /* wait for reply */
15506 api_show_one_pitr (vat_main_t * vam)
15508 vl_api_show_one_pitr_t *mp;
15511 if (!vam->json_output)
15513 print (vam->ofp, "%=20s", "lisp status:");
15516 M (SHOW_ONE_PITR, mp);
15520 /* Wait for a reply... */
15525 #define api_show_lisp_pitr api_show_one_pitr
15528 api_one_use_petr (vat_main_t * vam)
15530 unformat_input_t *input = vam->input;
15531 vl_api_one_use_petr_t *mp;
15536 memset (&ip, 0, sizeof (ip));
15538 /* Parse args required to build the message */
15539 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15541 if (unformat (input, "disable"))
15544 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
15547 ip_addr_version (&ip) = IP4;
15550 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
15553 ip_addr_version (&ip) = IP6;
15557 errmsg ("parse error '%U'", format_unformat_error, input);
15562 M (ONE_USE_PETR, mp);
15564 mp->is_add = is_add;
15567 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
15569 clib_memcpy (mp->address, &ip, 4);
15571 clib_memcpy (mp->address, &ip, 16);
15577 /* wait for reply */
15582 #define api_lisp_use_petr api_one_use_petr
15585 api_show_one_nsh_mapping (vat_main_t * vam)
15587 vl_api_show_one_use_petr_t *mp;
15590 if (!vam->json_output)
15592 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
15595 M (SHOW_ONE_NSH_MAPPING, mp);
15599 /* Wait for a reply... */
15605 api_show_one_use_petr (vat_main_t * vam)
15607 vl_api_show_one_use_petr_t *mp;
15610 if (!vam->json_output)
15612 print (vam->ofp, "%=20s", "Proxy-ETR status:");
15615 M (SHOW_ONE_USE_PETR, mp);
15619 /* Wait for a reply... */
15624 #define api_show_lisp_use_petr api_show_one_use_petr
15627 * Add/delete mapping between vni and vrf
15630 api_one_eid_table_add_del_map (vat_main_t * vam)
15632 unformat_input_t *input = vam->input;
15633 vl_api_one_eid_table_add_del_map_t *mp;
15634 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15635 u32 vni, vrf, bd_index;
15638 /* Parse args required to build the message */
15639 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15641 if (unformat (input, "del"))
15643 else if (unformat (input, "vrf %d", &vrf))
15645 else if (unformat (input, "bd_index %d", &bd_index))
15647 else if (unformat (input, "vni %d", &vni))
15653 if (!vni_set || (!vrf_set && !bd_index_set))
15655 errmsg ("missing arguments!");
15659 if (vrf_set && bd_index_set)
15661 errmsg ("error: both vrf and bd entered!");
15665 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15667 mp->is_add = is_add;
15668 mp->vni = htonl (vni);
15669 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15670 mp->is_l2 = bd_index_set;
15675 /* wait for reply */
15680 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15683 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15685 u32 *action = va_arg (*args, u32 *);
15688 if (unformat (input, "%s", &s))
15690 if (!strcmp ((char *) s, "no-action"))
15692 else if (!strcmp ((char *) s, "natively-forward"))
15694 else if (!strcmp ((char *) s, "send-map-request"))
15696 else if (!strcmp ((char *) s, "drop"))
15700 clib_warning ("invalid action: '%s'", s);
15712 * Add/del remote mapping to/from ONE control plane
15714 * @param vam vpp API test context
15715 * @return return code
15718 api_one_add_del_remote_mapping (vat_main_t * vam)
15720 unformat_input_t *input = vam->input;
15721 vl_api_one_add_del_remote_mapping_t *mp;
15723 lisp_eid_vat_t _eid, *eid = &_eid;
15724 lisp_eid_vat_t _seid, *seid = &_seid;
15725 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15726 u32 action = ~0, p, w, data_len;
15727 ip4_address_t rloc4;
15728 ip6_address_t rloc6;
15729 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15732 memset (&rloc, 0, sizeof (rloc));
15734 /* Parse args required to build the message */
15735 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15737 if (unformat (input, "del-all"))
15741 else if (unformat (input, "del"))
15745 else if (unformat (input, "add"))
15749 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15753 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15757 else if (unformat (input, "vni %d", &vni))
15761 else if (unformat (input, "p %d w %d", &p, &w))
15765 errmsg ("No RLOC configured for setting priority/weight!");
15768 curr_rloc->priority = p;
15769 curr_rloc->weight = w;
15771 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15774 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
15775 vec_add1 (rlocs, rloc);
15776 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15778 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15781 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
15782 vec_add1 (rlocs, rloc);
15783 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15785 else if (unformat (input, "action %U",
15786 unformat_negative_mapping_action, &action))
15792 clib_warning ("parse error '%U'", format_unformat_error, input);
15799 errmsg ("missing params!");
15803 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15805 errmsg ("no action set for negative map-reply!");
15809 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15811 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15812 mp->is_add = is_add;
15813 mp->vni = htonl (vni);
15814 mp->action = (u8) action;
15815 mp->is_src_dst = seid_set;
15816 mp->eid_len = eid->len;
15817 mp->seid_len = seid->len;
15818 mp->del_all = del_all;
15819 mp->eid_type = eid->type;
15820 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15821 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
15823 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15824 clib_memcpy (mp->rlocs, rlocs, data_len);
15830 /* Wait for a reply... */
15835 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15838 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15839 * forwarding entries in data-plane accordingly.
15841 * @param vam vpp API test context
15842 * @return return code
15845 api_one_add_del_adjacency (vat_main_t * vam)
15847 unformat_input_t *input = vam->input;
15848 vl_api_one_add_del_adjacency_t *mp;
15850 ip4_address_t leid4, reid4;
15851 ip6_address_t leid6, reid6;
15852 u8 reid_mac[6] = { 0 };
15853 u8 leid_mac[6] = { 0 };
15854 u8 reid_type, leid_type;
15855 u32 leid_len = 0, reid_len = 0, len;
15859 leid_type = reid_type = (u8) ~ 0;
15861 /* Parse args required to build the message */
15862 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15864 if (unformat (input, "del"))
15868 else if (unformat (input, "add"))
15872 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
15875 reid_type = 0; /* ipv4 */
15878 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
15881 reid_type = 1; /* ipv6 */
15884 else if (unformat (input, "reid %U", unformat_ethernet_address,
15887 reid_type = 2; /* mac */
15889 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
15892 leid_type = 0; /* ipv4 */
15895 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
15898 leid_type = 1; /* ipv6 */
15901 else if (unformat (input, "leid %U", unformat_ethernet_address,
15904 leid_type = 2; /* mac */
15906 else if (unformat (input, "vni %d", &vni))
15912 errmsg ("parse error '%U'", format_unformat_error, input);
15917 if ((u8) ~ 0 == reid_type)
15919 errmsg ("missing params!");
15923 if (leid_type != reid_type)
15925 errmsg ("remote and local EIDs are of different types!");
15929 M (ONE_ADD_DEL_ADJACENCY, mp);
15930 mp->is_add = is_add;
15931 mp->vni = htonl (vni);
15932 mp->leid_len = leid_len;
15933 mp->reid_len = reid_len;
15934 mp->eid_type = reid_type;
15936 switch (mp->eid_type)
15939 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
15940 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
15943 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
15944 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
15947 clib_memcpy (mp->leid, leid_mac, 6);
15948 clib_memcpy (mp->reid, reid_mac, 6);
15951 errmsg ("unknown EID type %d!", mp->eid_type);
15958 /* Wait for a reply... */
15963 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
15966 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
15968 u32 *mode = va_arg (*args, u32 *);
15970 if (unformat (input, "lisp"))
15972 else if (unformat (input, "vxlan"))
15981 api_gpe_get_encap_mode (vat_main_t * vam)
15983 vl_api_gpe_get_encap_mode_t *mp;
15986 /* Construct the API message */
15987 M (GPE_GET_ENCAP_MODE, mp);
15992 /* Wait for a reply... */
15998 api_gpe_set_encap_mode (vat_main_t * vam)
16000 unformat_input_t *input = vam->input;
16001 vl_api_gpe_set_encap_mode_t *mp;
16005 /* Parse args required to build the message */
16006 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16008 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
16014 /* Construct the API message */
16015 M (GPE_SET_ENCAP_MODE, mp);
16022 /* Wait for a reply... */
16028 api_lisp_gpe_add_del_iface (vat_main_t * vam)
16030 unformat_input_t *input = vam->input;
16031 vl_api_gpe_add_del_iface_t *mp;
16032 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
16033 u32 dp_table = 0, vni = 0;
16036 /* Parse args required to build the message */
16037 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16039 if (unformat (input, "up"))
16044 else if (unformat (input, "down"))
16049 else if (unformat (input, "table_id %d", &dp_table))
16053 else if (unformat (input, "bd_id %d", &dp_table))
16058 else if (unformat (input, "vni %d", &vni))
16066 if (action_set == 0)
16068 errmsg ("Action not set");
16071 if (dp_table_set == 0 || vni_set == 0)
16073 errmsg ("vni and dp_table must be set");
16077 /* Construct the API message */
16078 M (GPE_ADD_DEL_IFACE, mp);
16080 mp->is_add = is_add;
16081 mp->dp_table = clib_host_to_net_u32 (dp_table);
16083 mp->vni = clib_host_to_net_u32 (vni);
16088 /* Wait for a reply... */
16094 api_one_map_register_set_ttl (vat_main_t * vam)
16096 unformat_input_t *input = vam->input;
16097 vl_api_one_map_register_set_ttl_t *mp;
16102 /* Parse args required to build the message */
16103 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16105 if (unformat (input, "%u", &ttl))
16109 clib_warning ("parse error '%U'", format_unformat_error, input);
16116 errmsg ("TTL value missing!");
16120 M (ONE_MAP_REGISTER_SET_TTL, mp);
16121 mp->ttl = clib_host_to_net_u32 (ttl);
16126 /* Wait for a reply... */
16132 api_show_one_map_register_ttl (vat_main_t * vam)
16134 vl_api_show_one_map_register_ttl_t *mp;
16137 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
16142 /* Wait for a reply... */
16148 * Add/del map request itr rlocs from ONE control plane and updates
16150 * @param vam vpp API test context
16151 * @return return code
16154 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
16156 unformat_input_t *input = vam->input;
16157 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
16158 u8 *locator_set_name = 0;
16159 u8 locator_set_name_set = 0;
16163 /* Parse args required to build the message */
16164 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16166 if (unformat (input, "del"))
16170 else if (unformat (input, "%_%v%_", &locator_set_name))
16172 locator_set_name_set = 1;
16176 clib_warning ("parse error '%U'", format_unformat_error, input);
16181 if (is_add && !locator_set_name_set)
16183 errmsg ("itr-rloc is not set!");
16187 if (is_add && vec_len (locator_set_name) > 64)
16189 errmsg ("itr-rloc locator-set name too long");
16190 vec_free (locator_set_name);
16194 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
16195 mp->is_add = is_add;
16198 clib_memcpy (mp->locator_set_name, locator_set_name,
16199 vec_len (locator_set_name));
16203 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
16205 vec_free (locator_set_name);
16210 /* Wait for a reply... */
16215 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
16218 api_one_locator_dump (vat_main_t * vam)
16220 unformat_input_t *input = vam->input;
16221 vl_api_one_locator_dump_t *mp;
16222 vl_api_control_ping_t *mp_ping;
16223 u8 is_index_set = 0, is_name_set = 0;
16228 /* Parse args required to build the message */
16229 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16231 if (unformat (input, "ls_name %_%v%_", &ls_name))
16235 else if (unformat (input, "ls_index %d", &ls_index))
16241 errmsg ("parse error '%U'", format_unformat_error, input);
16246 if (!is_index_set && !is_name_set)
16248 errmsg ("error: expected one of index or name!");
16252 if (is_index_set && is_name_set)
16254 errmsg ("error: only one param expected!");
16258 if (vec_len (ls_name) > 62)
16260 errmsg ("error: locator set name too long!");
16264 if (!vam->json_output)
16266 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
16269 M (ONE_LOCATOR_DUMP, mp);
16270 mp->is_index_set = is_index_set;
16273 mp->ls_index = clib_host_to_net_u32 (ls_index);
16276 vec_add1 (ls_name, 0);
16277 strncpy ((char *) mp->ls_name, (char *) ls_name,
16278 sizeof (mp->ls_name) - 1);
16284 /* Use a control ping for synchronization */
16285 M (CONTROL_PING, mp_ping);
16288 /* Wait for a reply... */
16293 #define api_lisp_locator_dump api_one_locator_dump
16296 api_one_locator_set_dump (vat_main_t * vam)
16298 vl_api_one_locator_set_dump_t *mp;
16299 vl_api_control_ping_t *mp_ping;
16300 unformat_input_t *input = vam->input;
16304 /* Parse args required to build the message */
16305 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16307 if (unformat (input, "local"))
16311 else if (unformat (input, "remote"))
16317 errmsg ("parse error '%U'", format_unformat_error, input);
16322 if (!vam->json_output)
16324 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
16327 M (ONE_LOCATOR_SET_DUMP, mp);
16329 mp->filter = filter;
16334 /* Use a control ping for synchronization */
16335 M (CONTROL_PING, mp_ping);
16338 /* Wait for a reply... */
16343 #define api_lisp_locator_set_dump api_one_locator_set_dump
16346 api_one_eid_table_map_dump (vat_main_t * vam)
16350 unformat_input_t *input = vam->input;
16351 vl_api_one_eid_table_map_dump_t *mp;
16352 vl_api_control_ping_t *mp_ping;
16355 /* Parse args required to build the message */
16356 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16358 if (unformat (input, "l2"))
16363 else if (unformat (input, "l3"))
16370 errmsg ("parse error '%U'", format_unformat_error, input);
16377 errmsg ("expected one of 'l2' or 'l3' parameter!");
16381 if (!vam->json_output)
16383 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
16386 M (ONE_EID_TABLE_MAP_DUMP, mp);
16392 /* Use a control ping for synchronization */
16393 M (CONTROL_PING, mp_ping);
16396 /* Wait for a reply... */
16401 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
16404 api_one_eid_table_vni_dump (vat_main_t * vam)
16406 vl_api_one_eid_table_vni_dump_t *mp;
16407 vl_api_control_ping_t *mp_ping;
16410 if (!vam->json_output)
16412 print (vam->ofp, "VNI");
16415 M (ONE_EID_TABLE_VNI_DUMP, mp);
16420 /* Use a control ping for synchronization */
16421 M (CONTROL_PING, mp_ping);
16424 /* Wait for a reply... */
16429 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
16432 api_one_eid_table_dump (vat_main_t * vam)
16434 unformat_input_t *i = vam->input;
16435 vl_api_one_eid_table_dump_t *mp;
16436 vl_api_control_ping_t *mp_ping;
16437 struct in_addr ip4;
16438 struct in6_addr ip6;
16440 u8 eid_type = ~0, eid_set = 0;
16441 u32 prefix_length = ~0, t, vni = 0;
16444 lisp_nsh_api_t nsh;
16446 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16448 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
16454 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
16460 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
16465 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
16470 else if (unformat (i, "vni %d", &t))
16474 else if (unformat (i, "local"))
16478 else if (unformat (i, "remote"))
16484 errmsg ("parse error '%U'", format_unformat_error, i);
16489 if (!vam->json_output)
16491 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
16492 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
16495 M (ONE_EID_TABLE_DUMP, mp);
16497 mp->filter = filter;
16501 mp->vni = htonl (vni);
16502 mp->eid_type = eid_type;
16506 mp->prefix_length = prefix_length;
16507 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
16510 mp->prefix_length = prefix_length;
16511 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
16514 clib_memcpy (mp->eid, mac, sizeof (mac));
16517 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
16520 errmsg ("unknown EID type %d!", eid_type);
16528 /* Use a control ping for synchronization */
16529 M (CONTROL_PING, mp_ping);
16532 /* Wait for a reply... */
16537 #define api_lisp_eid_table_dump api_one_eid_table_dump
16540 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
16542 unformat_input_t *i = vam->input;
16543 vl_api_gpe_fwd_entries_get_t *mp;
16548 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16550 if (unformat (i, "vni %d", &vni))
16556 errmsg ("parse error '%U'", format_unformat_error, i);
16563 errmsg ("vni not set!");
16567 if (!vam->json_output)
16569 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
16573 M (GPE_FWD_ENTRIES_GET, mp);
16574 mp->vni = clib_host_to_net_u32 (vni);
16579 /* Wait for a reply... */
16584 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
16585 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
16586 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
16587 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
16588 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
16589 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
16590 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
16591 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
16594 api_one_adjacencies_get (vat_main_t * vam)
16596 unformat_input_t *i = vam->input;
16597 vl_api_one_adjacencies_get_t *mp;
16602 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16604 if (unformat (i, "vni %d", &vni))
16610 errmsg ("parse error '%U'", format_unformat_error, i);
16617 errmsg ("vni not set!");
16621 if (!vam->json_output)
16623 print (vam->ofp, "%s %40s", "leid", "reid");
16626 M (ONE_ADJACENCIES_GET, mp);
16627 mp->vni = clib_host_to_net_u32 (vni);
16632 /* Wait for a reply... */
16637 #define api_lisp_adjacencies_get api_one_adjacencies_get
16640 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
16642 unformat_input_t *i = vam->input;
16643 vl_api_gpe_native_fwd_rpaths_get_t *mp;
16645 u8 ip_family_set = 0, is_ip4 = 1;
16647 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16649 if (unformat (i, "ip4"))
16654 else if (unformat (i, "ip6"))
16661 errmsg ("parse error '%U'", format_unformat_error, i);
16666 if (!ip_family_set)
16668 errmsg ("ip family not set!");
16672 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
16673 mp->is_ip4 = is_ip4;
16678 /* Wait for a reply... */
16684 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
16686 vl_api_gpe_fwd_entry_vnis_get_t *mp;
16689 if (!vam->json_output)
16691 print (vam->ofp, "VNIs");
16694 M (GPE_FWD_ENTRY_VNIS_GET, mp);
16699 /* Wait for a reply... */
16705 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
16707 unformat_input_t *i = vam->input;
16708 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
16710 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
16711 struct in_addr ip4;
16712 struct in6_addr ip6;
16713 u32 table_id = 0, nh_sw_if_index = ~0;
16715 memset (&ip4, 0, sizeof (ip4));
16716 memset (&ip6, 0, sizeof (ip6));
16718 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16720 if (unformat (i, "del"))
16722 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
16723 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16728 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
16729 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16734 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
16738 nh_sw_if_index = ~0;
16740 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
16744 nh_sw_if_index = ~0;
16746 else if (unformat (i, "table %d", &table_id))
16750 errmsg ("parse error '%U'", format_unformat_error, i);
16757 errmsg ("nh addr not set!");
16761 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
16762 mp->is_add = is_add;
16763 mp->table_id = clib_host_to_net_u32 (table_id);
16764 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
16765 mp->is_ip4 = is_ip4;
16767 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
16769 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
16774 /* Wait for a reply... */
16780 api_one_map_server_dump (vat_main_t * vam)
16782 vl_api_one_map_server_dump_t *mp;
16783 vl_api_control_ping_t *mp_ping;
16786 if (!vam->json_output)
16788 print (vam->ofp, "%=20s", "Map server");
16791 M (ONE_MAP_SERVER_DUMP, mp);
16795 /* Use a control ping for synchronization */
16796 M (CONTROL_PING, mp_ping);
16799 /* Wait for a reply... */
16804 #define api_lisp_map_server_dump api_one_map_server_dump
16807 api_one_map_resolver_dump (vat_main_t * vam)
16809 vl_api_one_map_resolver_dump_t *mp;
16810 vl_api_control_ping_t *mp_ping;
16813 if (!vam->json_output)
16815 print (vam->ofp, "%=20s", "Map resolver");
16818 M (ONE_MAP_RESOLVER_DUMP, mp);
16822 /* Use a control ping for synchronization */
16823 M (CONTROL_PING, mp_ping);
16826 /* Wait for a reply... */
16831 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
16834 api_one_stats_flush (vat_main_t * vam)
16836 vl_api_one_stats_flush_t *mp;
16839 M (ONE_STATS_FLUSH, mp);
16846 api_one_stats_dump (vat_main_t * vam)
16848 vl_api_one_stats_dump_t *mp;
16849 vl_api_control_ping_t *mp_ping;
16852 M (ONE_STATS_DUMP, mp);
16856 /* Use a control ping for synchronization */
16857 M (CONTROL_PING, mp_ping);
16860 /* Wait for a reply... */
16866 api_show_one_status (vat_main_t * vam)
16868 vl_api_show_one_status_t *mp;
16871 if (!vam->json_output)
16873 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
16876 M (SHOW_ONE_STATUS, mp);
16879 /* Wait for a reply... */
16884 #define api_show_lisp_status api_show_one_status
16887 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
16889 vl_api_gpe_fwd_entry_path_dump_t *mp;
16890 vl_api_control_ping_t *mp_ping;
16891 unformat_input_t *i = vam->input;
16892 u32 fwd_entry_index = ~0;
16895 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16897 if (unformat (i, "index %d", &fwd_entry_index))
16903 if (~0 == fwd_entry_index)
16905 errmsg ("no index specified!");
16909 if (!vam->json_output)
16911 print (vam->ofp, "first line");
16914 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
16918 /* Use a control ping for synchronization */
16919 M (CONTROL_PING, mp_ping);
16922 /* Wait for a reply... */
16928 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
16930 vl_api_one_get_map_request_itr_rlocs_t *mp;
16933 if (!vam->json_output)
16935 print (vam->ofp, "%=20s", "itr-rlocs:");
16938 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
16941 /* Wait for a reply... */
16946 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
16949 api_af_packet_create (vat_main_t * vam)
16951 unformat_input_t *i = vam->input;
16952 vl_api_af_packet_create_t *mp;
16953 u8 *host_if_name = 0;
16955 u8 random_hw_addr = 1;
16958 memset (hw_addr, 0, sizeof (hw_addr));
16960 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16962 if (unformat (i, "name %s", &host_if_name))
16963 vec_add1 (host_if_name, 0);
16964 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16965 random_hw_addr = 0;
16970 if (!vec_len (host_if_name))
16972 errmsg ("host-interface name must be specified");
16976 if (vec_len (host_if_name) > 64)
16978 errmsg ("host-interface name too long");
16982 M (AF_PACKET_CREATE, mp);
16984 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16985 clib_memcpy (mp->hw_addr, hw_addr, 6);
16986 mp->use_random_hw_addr = random_hw_addr;
16987 vec_free (host_if_name);
16995 fprintf (vam->ofp ? vam->ofp : stderr,
16996 " new sw_if_index = %d\n", vam->sw_if_index);
17003 api_af_packet_delete (vat_main_t * vam)
17005 unformat_input_t *i = vam->input;
17006 vl_api_af_packet_delete_t *mp;
17007 u8 *host_if_name = 0;
17010 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17012 if (unformat (i, "name %s", &host_if_name))
17013 vec_add1 (host_if_name, 0);
17018 if (!vec_len (host_if_name))
17020 errmsg ("host-interface name must be specified");
17024 if (vec_len (host_if_name) > 64)
17026 errmsg ("host-interface name too long");
17030 M (AF_PACKET_DELETE, mp);
17032 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17033 vec_free (host_if_name);
17041 api_policer_add_del (vat_main_t * vam)
17043 unformat_input_t *i = vam->input;
17044 vl_api_policer_add_del_t *mp;
17054 u8 color_aware = 0;
17055 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
17058 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
17059 conform_action.dscp = 0;
17060 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
17061 exceed_action.dscp = 0;
17062 violate_action.action_type = SSE2_QOS_ACTION_DROP;
17063 violate_action.dscp = 0;
17065 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17067 if (unformat (i, "del"))
17069 else if (unformat (i, "name %s", &name))
17070 vec_add1 (name, 0);
17071 else if (unformat (i, "cir %u", &cir))
17073 else if (unformat (i, "eir %u", &eir))
17075 else if (unformat (i, "cb %u", &cb))
17077 else if (unformat (i, "eb %u", &eb))
17079 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
17082 else if (unformat (i, "round_type %U", unformat_policer_round_type,
17085 else if (unformat (i, "type %U", unformat_policer_type, &type))
17087 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
17090 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
17093 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
17096 else if (unformat (i, "color-aware"))
17102 if (!vec_len (name))
17104 errmsg ("policer name must be specified");
17108 if (vec_len (name) > 64)
17110 errmsg ("policer name too long");
17114 M (POLICER_ADD_DEL, mp);
17116 clib_memcpy (mp->name, name, vec_len (name));
17118 mp->is_add = is_add;
17123 mp->rate_type = rate_type;
17124 mp->round_type = round_type;
17126 mp->conform_action_type = conform_action.action_type;
17127 mp->conform_dscp = conform_action.dscp;
17128 mp->exceed_action_type = exceed_action.action_type;
17129 mp->exceed_dscp = exceed_action.dscp;
17130 mp->violate_action_type = violate_action.action_type;
17131 mp->violate_dscp = violate_action.dscp;
17132 mp->color_aware = color_aware;
17140 api_policer_dump (vat_main_t * vam)
17142 unformat_input_t *i = vam->input;
17143 vl_api_policer_dump_t *mp;
17144 vl_api_control_ping_t *mp_ping;
17145 u8 *match_name = 0;
17146 u8 match_name_valid = 0;
17149 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17151 if (unformat (i, "name %s", &match_name))
17153 vec_add1 (match_name, 0);
17154 match_name_valid = 1;
17160 M (POLICER_DUMP, mp);
17161 mp->match_name_valid = match_name_valid;
17162 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
17163 vec_free (match_name);
17167 /* Use a control ping for synchronization */
17168 M (CONTROL_PING, mp_ping);
17171 /* Wait for a reply... */
17177 api_policer_classify_set_interface (vat_main_t * vam)
17179 unformat_input_t *i = vam->input;
17180 vl_api_policer_classify_set_interface_t *mp;
17182 int sw_if_index_set;
17183 u32 ip4_table_index = ~0;
17184 u32 ip6_table_index = ~0;
17185 u32 l2_table_index = ~0;
17189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17191 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17192 sw_if_index_set = 1;
17193 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17194 sw_if_index_set = 1;
17195 else if (unformat (i, "del"))
17197 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17199 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17201 else if (unformat (i, "l2-table %d", &l2_table_index))
17205 clib_warning ("parse error '%U'", format_unformat_error, i);
17210 if (sw_if_index_set == 0)
17212 errmsg ("missing interface name or sw_if_index");
17216 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
17218 mp->sw_if_index = ntohl (sw_if_index);
17219 mp->ip4_table_index = ntohl (ip4_table_index);
17220 mp->ip6_table_index = ntohl (ip6_table_index);
17221 mp->l2_table_index = ntohl (l2_table_index);
17222 mp->is_add = is_add;
17230 api_policer_classify_dump (vat_main_t * vam)
17232 unformat_input_t *i = vam->input;
17233 vl_api_policer_classify_dump_t *mp;
17234 vl_api_control_ping_t *mp_ping;
17235 u8 type = POLICER_CLASSIFY_N_TABLES;
17238 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
17242 errmsg ("classify table type must be specified");
17246 if (!vam->json_output)
17248 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17251 M (POLICER_CLASSIFY_DUMP, mp);
17256 /* Use a control ping for synchronization */
17257 M (CONTROL_PING, mp_ping);
17260 /* Wait for a reply... */
17266 api_netmap_create (vat_main_t * vam)
17268 unformat_input_t *i = vam->input;
17269 vl_api_netmap_create_t *mp;
17272 u8 random_hw_addr = 1;
17277 memset (hw_addr, 0, sizeof (hw_addr));
17279 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17281 if (unformat (i, "name %s", &if_name))
17282 vec_add1 (if_name, 0);
17283 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17284 random_hw_addr = 0;
17285 else if (unformat (i, "pipe"))
17287 else if (unformat (i, "master"))
17289 else if (unformat (i, "slave"))
17295 if (!vec_len (if_name))
17297 errmsg ("interface name must be specified");
17301 if (vec_len (if_name) > 64)
17303 errmsg ("interface name too long");
17307 M (NETMAP_CREATE, mp);
17309 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
17310 clib_memcpy (mp->hw_addr, hw_addr, 6);
17311 mp->use_random_hw_addr = random_hw_addr;
17312 mp->is_pipe = is_pipe;
17313 mp->is_master = is_master;
17314 vec_free (if_name);
17322 api_netmap_delete (vat_main_t * vam)
17324 unformat_input_t *i = vam->input;
17325 vl_api_netmap_delete_t *mp;
17329 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17331 if (unformat (i, "name %s", &if_name))
17332 vec_add1 (if_name, 0);
17337 if (!vec_len (if_name))
17339 errmsg ("interface name must be specified");
17343 if (vec_len (if_name) > 64)
17345 errmsg ("interface name too long");
17349 M (NETMAP_DELETE, mp);
17351 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
17352 vec_free (if_name);
17360 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
17362 if (fp->afi == IP46_TYPE_IP6)
17364 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17365 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17366 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17367 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17368 format_ip6_address, fp->next_hop);
17369 else if (fp->afi == IP46_TYPE_IP4)
17371 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17372 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17373 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17374 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17375 format_ip4_address, fp->next_hop);
17379 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
17380 vl_api_fib_path2_t * fp)
17382 struct in_addr ip4;
17383 struct in6_addr ip6;
17385 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17386 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17387 vat_json_object_add_uint (node, "is_local", fp->is_local);
17388 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17389 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17390 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17391 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17392 if (fp->afi == IP46_TYPE_IP4)
17394 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17395 vat_json_object_add_ip4 (node, "next_hop", ip4);
17397 else if (fp->afi == IP46_TYPE_IP6)
17399 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17400 vat_json_object_add_ip6 (node, "next_hop", ip6);
17405 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
17407 vat_main_t *vam = &vat_main;
17408 int count = ntohl (mp->mt_count);
17409 vl_api_fib_path2_t *fp;
17412 print (vam->ofp, "[%d]: sw_if_index %d via:",
17413 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
17415 for (i = 0; i < count; i++)
17417 vl_api_mpls_fib_path_print (vam, fp);
17421 print (vam->ofp, "");
17424 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
17425 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
17428 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
17430 vat_main_t *vam = &vat_main;
17431 vat_json_node_t *node = NULL;
17432 int count = ntohl (mp->mt_count);
17433 vl_api_fib_path2_t *fp;
17436 if (VAT_JSON_ARRAY != vam->json_tree.type)
17438 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17439 vat_json_init_array (&vam->json_tree);
17441 node = vat_json_array_add (&vam->json_tree);
17443 vat_json_init_object (node);
17444 vat_json_object_add_uint (node, "tunnel_index",
17445 ntohl (mp->mt_tunnel_index));
17446 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
17448 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
17451 for (i = 0; i < count; i++)
17453 vl_api_mpls_fib_path_json_print (node, fp);
17459 api_mpls_tunnel_dump (vat_main_t * vam)
17461 vl_api_mpls_tunnel_dump_t *mp;
17462 vl_api_control_ping_t *mp_ping;
17466 /* Parse args required to build the message */
17467 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
17469 if (!unformat (vam->input, "tunnel_index %d", &index))
17476 print (vam->ofp, " tunnel_index %d", index);
17478 M (MPLS_TUNNEL_DUMP, mp);
17479 mp->tunnel_index = htonl (index);
17482 /* Use a control ping for synchronization */
17483 M (CONTROL_PING, mp_ping);
17490 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
17491 #define vl_api_mpls_fib_details_t_print vl_noop_handler
17495 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
17497 vat_main_t *vam = &vat_main;
17498 int count = ntohl (mp->count);
17499 vl_api_fib_path2_t *fp;
17503 "table-id %d, label %u, ess_bit %u",
17504 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
17506 for (i = 0; i < count; i++)
17508 vl_api_mpls_fib_path_print (vam, fp);
17513 static void vl_api_mpls_fib_details_t_handler_json
17514 (vl_api_mpls_fib_details_t * mp)
17516 vat_main_t *vam = &vat_main;
17517 int count = ntohl (mp->count);
17518 vat_json_node_t *node = NULL;
17519 vl_api_fib_path2_t *fp;
17522 if (VAT_JSON_ARRAY != vam->json_tree.type)
17524 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17525 vat_json_init_array (&vam->json_tree);
17527 node = vat_json_array_add (&vam->json_tree);
17529 vat_json_init_object (node);
17530 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17531 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
17532 vat_json_object_add_uint (node, "label", ntohl (mp->label));
17533 vat_json_object_add_uint (node, "path_count", count);
17535 for (i = 0; i < count; i++)
17537 vl_api_mpls_fib_path_json_print (node, fp);
17543 api_mpls_fib_dump (vat_main_t * vam)
17545 vl_api_mpls_fib_dump_t *mp;
17546 vl_api_control_ping_t *mp_ping;
17549 M (MPLS_FIB_DUMP, mp);
17552 /* Use a control ping for synchronization */
17553 M (CONTROL_PING, mp_ping);
17560 #define vl_api_ip_fib_details_t_endian vl_noop_handler
17561 #define vl_api_ip_fib_details_t_print vl_noop_handler
17564 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
17566 vat_main_t *vam = &vat_main;
17567 int count = ntohl (mp->count);
17568 vl_api_fib_path_t *fp;
17572 "table-id %d, prefix %U/%d",
17573 ntohl (mp->table_id), format_ip4_address, mp->address,
17574 mp->address_length);
17576 for (i = 0; i < count; i++)
17578 if (fp->afi == IP46_TYPE_IP6)
17580 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17581 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17582 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17583 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17584 format_ip6_address, fp->next_hop);
17585 else if (fp->afi == IP46_TYPE_IP4)
17587 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17588 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17589 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17590 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17591 format_ip4_address, fp->next_hop);
17596 static void vl_api_ip_fib_details_t_handler_json
17597 (vl_api_ip_fib_details_t * mp)
17599 vat_main_t *vam = &vat_main;
17600 int count = ntohl (mp->count);
17601 vat_json_node_t *node = NULL;
17602 struct in_addr ip4;
17603 struct in6_addr ip6;
17604 vl_api_fib_path_t *fp;
17607 if (VAT_JSON_ARRAY != vam->json_tree.type)
17609 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17610 vat_json_init_array (&vam->json_tree);
17612 node = vat_json_array_add (&vam->json_tree);
17614 vat_json_init_object (node);
17615 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17616 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
17617 vat_json_object_add_ip4 (node, "prefix", ip4);
17618 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17619 vat_json_object_add_uint (node, "path_count", count);
17621 for (i = 0; i < count; i++)
17623 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17624 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17625 vat_json_object_add_uint (node, "is_local", fp->is_local);
17626 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17627 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17628 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17629 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17630 if (fp->afi == IP46_TYPE_IP4)
17632 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17633 vat_json_object_add_ip4 (node, "next_hop", ip4);
17635 else if (fp->afi == IP46_TYPE_IP6)
17637 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17638 vat_json_object_add_ip6 (node, "next_hop", ip6);
17644 api_ip_fib_dump (vat_main_t * vam)
17646 vl_api_ip_fib_dump_t *mp;
17647 vl_api_control_ping_t *mp_ping;
17650 M (IP_FIB_DUMP, mp);
17653 /* Use a control ping for synchronization */
17654 M (CONTROL_PING, mp_ping);
17662 api_ip_mfib_dump (vat_main_t * vam)
17664 vl_api_ip_mfib_dump_t *mp;
17665 vl_api_control_ping_t *mp_ping;
17668 M (IP_MFIB_DUMP, mp);
17671 /* Use a control ping for synchronization */
17672 M (CONTROL_PING, mp_ping);
17679 static void vl_api_ip_neighbor_details_t_handler
17680 (vl_api_ip_neighbor_details_t * mp)
17682 vat_main_t *vam = &vat_main;
17684 print (vam->ofp, "%c %U %U",
17685 (mp->is_static) ? 'S' : 'D',
17686 format_ethernet_address, &mp->mac_address,
17687 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
17691 static void vl_api_ip_neighbor_details_t_handler_json
17692 (vl_api_ip_neighbor_details_t * mp)
17695 vat_main_t *vam = &vat_main;
17696 vat_json_node_t *node;
17697 struct in_addr ip4;
17698 struct in6_addr ip6;
17700 if (VAT_JSON_ARRAY != vam->json_tree.type)
17702 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17703 vat_json_init_array (&vam->json_tree);
17705 node = vat_json_array_add (&vam->json_tree);
17707 vat_json_init_object (node);
17708 vat_json_object_add_string_copy (node, "flag",
17709 (mp->is_static) ? (u8 *) "static" : (u8 *)
17712 vat_json_object_add_string_copy (node, "link_layer",
17713 format (0, "%U", format_ethernet_address,
17714 &mp->mac_address));
17718 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
17719 vat_json_object_add_ip6 (node, "ip_address", ip6);
17723 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
17724 vat_json_object_add_ip4 (node, "ip_address", ip4);
17729 api_ip_neighbor_dump (vat_main_t * vam)
17731 unformat_input_t *i = vam->input;
17732 vl_api_ip_neighbor_dump_t *mp;
17733 vl_api_control_ping_t *mp_ping;
17735 u32 sw_if_index = ~0;
17738 /* Parse args required to build the message */
17739 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17741 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17743 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17745 else if (unformat (i, "ip6"))
17751 if (sw_if_index == ~0)
17753 errmsg ("missing interface name or sw_if_index");
17757 M (IP_NEIGHBOR_DUMP, mp);
17758 mp->is_ipv6 = (u8) is_ipv6;
17759 mp->sw_if_index = ntohl (sw_if_index);
17762 /* Use a control ping for synchronization */
17763 M (CONTROL_PING, mp_ping);
17770 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
17771 #define vl_api_ip6_fib_details_t_print vl_noop_handler
17774 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
17776 vat_main_t *vam = &vat_main;
17777 int count = ntohl (mp->count);
17778 vl_api_fib_path_t *fp;
17782 "table-id %d, prefix %U/%d",
17783 ntohl (mp->table_id), format_ip6_address, mp->address,
17784 mp->address_length);
17786 for (i = 0; i < count; i++)
17788 if (fp->afi == IP46_TYPE_IP6)
17790 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17791 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17792 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17793 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17794 format_ip6_address, fp->next_hop);
17795 else if (fp->afi == IP46_TYPE_IP4)
17797 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17798 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17799 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17800 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17801 format_ip4_address, fp->next_hop);
17806 static void vl_api_ip6_fib_details_t_handler_json
17807 (vl_api_ip6_fib_details_t * mp)
17809 vat_main_t *vam = &vat_main;
17810 int count = ntohl (mp->count);
17811 vat_json_node_t *node = NULL;
17812 struct in_addr ip4;
17813 struct in6_addr ip6;
17814 vl_api_fib_path_t *fp;
17817 if (VAT_JSON_ARRAY != vam->json_tree.type)
17819 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17820 vat_json_init_array (&vam->json_tree);
17822 node = vat_json_array_add (&vam->json_tree);
17824 vat_json_init_object (node);
17825 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17826 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
17827 vat_json_object_add_ip6 (node, "prefix", ip6);
17828 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17829 vat_json_object_add_uint (node, "path_count", count);
17831 for (i = 0; i < count; i++)
17833 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17834 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17835 vat_json_object_add_uint (node, "is_local", fp->is_local);
17836 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17837 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17838 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17839 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17840 if (fp->afi == IP46_TYPE_IP4)
17842 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17843 vat_json_object_add_ip4 (node, "next_hop", ip4);
17845 else if (fp->afi == IP46_TYPE_IP6)
17847 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17848 vat_json_object_add_ip6 (node, "next_hop", ip6);
17854 api_ip6_fib_dump (vat_main_t * vam)
17856 vl_api_ip6_fib_dump_t *mp;
17857 vl_api_control_ping_t *mp_ping;
17860 M (IP6_FIB_DUMP, mp);
17863 /* Use a control ping for synchronization */
17864 M (CONTROL_PING, mp_ping);
17872 api_ip6_mfib_dump (vat_main_t * vam)
17874 vl_api_ip6_mfib_dump_t *mp;
17875 vl_api_control_ping_t *mp_ping;
17878 M (IP6_MFIB_DUMP, mp);
17881 /* Use a control ping for synchronization */
17882 M (CONTROL_PING, mp_ping);
17890 api_classify_table_ids (vat_main_t * vam)
17892 vl_api_classify_table_ids_t *mp;
17895 /* Construct the API message */
17896 M (CLASSIFY_TABLE_IDS, mp);
17905 api_classify_table_by_interface (vat_main_t * vam)
17907 unformat_input_t *input = vam->input;
17908 vl_api_classify_table_by_interface_t *mp;
17910 u32 sw_if_index = ~0;
17912 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17914 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17916 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17921 if (sw_if_index == ~0)
17923 errmsg ("missing interface name or sw_if_index");
17927 /* Construct the API message */
17928 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
17930 mp->sw_if_index = ntohl (sw_if_index);
17938 api_classify_table_info (vat_main_t * vam)
17940 unformat_input_t *input = vam->input;
17941 vl_api_classify_table_info_t *mp;
17945 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17947 if (unformat (input, "table_id %d", &table_id))
17952 if (table_id == ~0)
17954 errmsg ("missing table id");
17958 /* Construct the API message */
17959 M (CLASSIFY_TABLE_INFO, mp);
17961 mp->table_id = ntohl (table_id);
17969 api_classify_session_dump (vat_main_t * vam)
17971 unformat_input_t *input = vam->input;
17972 vl_api_classify_session_dump_t *mp;
17973 vl_api_control_ping_t *mp_ping;
17977 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17979 if (unformat (input, "table_id %d", &table_id))
17984 if (table_id == ~0)
17986 errmsg ("missing table id");
17990 /* Construct the API message */
17991 M (CLASSIFY_SESSION_DUMP, mp);
17993 mp->table_id = ntohl (table_id);
17996 /* Use a control ping for synchronization */
17997 M (CONTROL_PING, mp_ping);
18005 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
18007 vat_main_t *vam = &vat_main;
18009 print (vam->ofp, "collector_address %U, collector_port %d, "
18010 "src_address %U, vrf_id %d, path_mtu %u, "
18011 "template_interval %u, udp_checksum %d",
18012 format_ip4_address, mp->collector_address,
18013 ntohs (mp->collector_port),
18014 format_ip4_address, mp->src_address,
18015 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
18016 ntohl (mp->template_interval), mp->udp_checksum);
18019 vam->result_ready = 1;
18023 vl_api_ipfix_exporter_details_t_handler_json
18024 (vl_api_ipfix_exporter_details_t * mp)
18026 vat_main_t *vam = &vat_main;
18027 vat_json_node_t node;
18028 struct in_addr collector_address;
18029 struct in_addr src_address;
18031 vat_json_init_object (&node);
18032 clib_memcpy (&collector_address, &mp->collector_address,
18033 sizeof (collector_address));
18034 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
18035 vat_json_object_add_uint (&node, "collector_port",
18036 ntohs (mp->collector_port));
18037 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
18038 vat_json_object_add_ip4 (&node, "src_address", src_address);
18039 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
18040 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
18041 vat_json_object_add_uint (&node, "template_interval",
18042 ntohl (mp->template_interval));
18043 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
18045 vat_json_print (vam->ofp, &node);
18046 vat_json_free (&node);
18048 vam->result_ready = 1;
18052 api_ipfix_exporter_dump (vat_main_t * vam)
18054 vl_api_ipfix_exporter_dump_t *mp;
18057 /* Construct the API message */
18058 M (IPFIX_EXPORTER_DUMP, mp);
18067 api_ipfix_classify_stream_dump (vat_main_t * vam)
18069 vl_api_ipfix_classify_stream_dump_t *mp;
18072 /* Construct the API message */
18073 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
18084 vl_api_ipfix_classify_stream_details_t_handler
18085 (vl_api_ipfix_classify_stream_details_t * mp)
18087 vat_main_t *vam = &vat_main;
18088 print (vam->ofp, "domain_id %d, src_port %d",
18089 ntohl (mp->domain_id), ntohs (mp->src_port));
18091 vam->result_ready = 1;
18095 vl_api_ipfix_classify_stream_details_t_handler_json
18096 (vl_api_ipfix_classify_stream_details_t * mp)
18098 vat_main_t *vam = &vat_main;
18099 vat_json_node_t node;
18101 vat_json_init_object (&node);
18102 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
18103 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
18105 vat_json_print (vam->ofp, &node);
18106 vat_json_free (&node);
18108 vam->result_ready = 1;
18112 api_ipfix_classify_table_dump (vat_main_t * vam)
18114 vl_api_ipfix_classify_table_dump_t *mp;
18115 vl_api_control_ping_t *mp_ping;
18118 if (!vam->json_output)
18120 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
18121 "transport_protocol");
18124 /* Construct the API message */
18125 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
18130 /* Use a control ping for synchronization */
18131 M (CONTROL_PING, mp_ping);
18139 vl_api_ipfix_classify_table_details_t_handler
18140 (vl_api_ipfix_classify_table_details_t * mp)
18142 vat_main_t *vam = &vat_main;
18143 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
18144 mp->transport_protocol);
18148 vl_api_ipfix_classify_table_details_t_handler_json
18149 (vl_api_ipfix_classify_table_details_t * mp)
18151 vat_json_node_t *node = NULL;
18152 vat_main_t *vam = &vat_main;
18154 if (VAT_JSON_ARRAY != vam->json_tree.type)
18156 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18157 vat_json_init_array (&vam->json_tree);
18160 node = vat_json_array_add (&vam->json_tree);
18161 vat_json_init_object (node);
18163 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
18164 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
18165 vat_json_object_add_uint (node, "transport_protocol",
18166 mp->transport_protocol);
18170 api_sw_interface_span_enable_disable (vat_main_t * vam)
18172 unformat_input_t *i = vam->input;
18173 vl_api_sw_interface_span_enable_disable_t *mp;
18174 u32 src_sw_if_index = ~0;
18175 u32 dst_sw_if_index = ~0;
18180 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18183 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
18185 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
18189 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
18191 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
18193 else if (unformat (i, "disable"))
18195 else if (unformat (i, "rx"))
18197 else if (unformat (i, "tx"))
18199 else if (unformat (i, "both"))
18201 else if (unformat (i, "l2"))
18207 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
18209 mp->sw_if_index_from = htonl (src_sw_if_index);
18210 mp->sw_if_index_to = htonl (dst_sw_if_index);
18220 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
18223 vat_main_t *vam = &vat_main;
18224 u8 *sw_if_from_name = 0;
18225 u8 *sw_if_to_name = 0;
18226 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18227 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18228 char *states[] = { "none", "rx", "tx", "both" };
18232 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18234 if ((u32) p->value[0] == sw_if_index_from)
18236 sw_if_from_name = (u8 *)(p->key);
18240 if ((u32) p->value[0] == sw_if_index_to)
18242 sw_if_to_name = (u8 *)(p->key);
18243 if (sw_if_from_name)
18248 print (vam->ofp, "%20s => %20s (%s)",
18249 sw_if_from_name, sw_if_to_name, states[mp->state]);
18253 vl_api_sw_interface_span_details_t_handler_json
18254 (vl_api_sw_interface_span_details_t * mp)
18256 vat_main_t *vam = &vat_main;
18257 vat_json_node_t *node = NULL;
18258 u8 *sw_if_from_name = 0;
18259 u8 *sw_if_to_name = 0;
18260 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18261 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18265 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18267 if ((u32) p->value[0] == sw_if_index_from)
18269 sw_if_from_name = (u8 *)(p->key);
18273 if ((u32) p->value[0] == sw_if_index_to)
18275 sw_if_to_name = (u8 *)(p->key);
18276 if (sw_if_from_name)
18282 if (VAT_JSON_ARRAY != vam->json_tree.type)
18284 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18285 vat_json_init_array (&vam->json_tree);
18287 node = vat_json_array_add (&vam->json_tree);
18289 vat_json_init_object (node);
18290 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
18291 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
18292 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
18293 if (0 != sw_if_to_name)
18295 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
18297 vat_json_object_add_uint (node, "state", mp->state);
18301 api_sw_interface_span_dump (vat_main_t * vam)
18303 unformat_input_t *input = vam->input;
18304 vl_api_sw_interface_span_dump_t *mp;
18305 vl_api_control_ping_t *mp_ping;
18309 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18311 if (unformat (input, "l2"))
18317 M (SW_INTERFACE_SPAN_DUMP, mp);
18321 /* Use a control ping for synchronization */
18322 M (CONTROL_PING, mp_ping);
18330 api_pg_create_interface (vat_main_t * vam)
18332 unformat_input_t *input = vam->input;
18333 vl_api_pg_create_interface_t *mp;
18337 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18339 if (unformat (input, "if_id %d", &if_id))
18346 errmsg ("missing pg interface index");
18350 /* Construct the API message */
18351 M (PG_CREATE_INTERFACE, mp);
18353 mp->interface_id = ntohl (if_id);
18361 api_pg_capture (vat_main_t * vam)
18363 unformat_input_t *input = vam->input;
18364 vl_api_pg_capture_t *mp;
18369 u8 pcap_file_set = 0;
18372 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18374 if (unformat (input, "if_id %d", &if_id))
18376 else if (unformat (input, "pcap %s", &pcap_file))
18378 else if (unformat (input, "count %d", &count))
18380 else if (unformat (input, "disable"))
18387 errmsg ("missing pg interface index");
18390 if (pcap_file_set > 0)
18392 if (vec_len (pcap_file) > 255)
18394 errmsg ("pcap file name is too long");
18399 u32 name_len = vec_len (pcap_file);
18400 /* Construct the API message */
18401 M (PG_CAPTURE, mp);
18403 mp->interface_id = ntohl (if_id);
18404 mp->is_enabled = enable;
18405 mp->count = ntohl (count);
18406 mp->pcap_name_length = ntohl (name_len);
18407 if (pcap_file_set != 0)
18409 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
18411 vec_free (pcap_file);
18419 api_pg_enable_disable (vat_main_t * vam)
18421 unformat_input_t *input = vam->input;
18422 vl_api_pg_enable_disable_t *mp;
18425 u8 stream_name_set = 0;
18426 u8 *stream_name = 0;
18428 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18430 if (unformat (input, "stream %s", &stream_name))
18431 stream_name_set = 1;
18432 else if (unformat (input, "disable"))
18438 if (stream_name_set > 0)
18440 if (vec_len (stream_name) > 255)
18442 errmsg ("stream name too long");
18447 u32 name_len = vec_len (stream_name);
18448 /* Construct the API message */
18449 M (PG_ENABLE_DISABLE, mp);
18451 mp->is_enabled = enable;
18452 if (stream_name_set != 0)
18454 mp->stream_name_length = ntohl (name_len);
18455 clib_memcpy (mp->stream_name, stream_name, name_len);
18457 vec_free (stream_name);
18465 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
18467 unformat_input_t *input = vam->input;
18468 vl_api_ip_source_and_port_range_check_add_del_t *mp;
18470 u16 *low_ports = 0;
18471 u16 *high_ports = 0;
18474 ip4_address_t ip4_addr;
18475 ip6_address_t ip6_addr;
18484 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18486 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
18492 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
18497 else if (unformat (input, "vrf %d", &vrf_id))
18499 else if (unformat (input, "del"))
18501 else if (unformat (input, "port %d", &tmp))
18503 if (tmp == 0 || tmp > 65535)
18505 errmsg ("port %d out of range", tmp);
18509 this_hi = this_low + 1;
18510 vec_add1 (low_ports, this_low);
18511 vec_add1 (high_ports, this_hi);
18513 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
18515 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
18517 errmsg ("incorrect range parameters");
18521 /* Note: in debug CLI +1 is added to high before
18522 passing to real fn that does "the work"
18523 (ip_source_and_port_range_check_add_del).
18524 This fn is a wrapper around the binary API fn a
18525 control plane will call, which expects this increment
18526 to have occurred. Hence letting the binary API control
18527 plane fn do the increment for consistency between VAT
18528 and other control planes.
18531 vec_add1 (low_ports, this_low);
18532 vec_add1 (high_ports, this_hi);
18538 if (prefix_set == 0)
18540 errmsg ("<address>/<mask> not specified");
18546 errmsg ("VRF ID required, not specified");
18553 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18557 if (vec_len (low_ports) == 0)
18559 errmsg ("At least one port or port range required");
18563 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
18565 mp->is_add = is_add;
18570 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
18575 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
18578 mp->mask_length = length;
18579 mp->number_of_ranges = vec_len (low_ports);
18581 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
18582 vec_free (low_ports);
18584 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
18585 vec_free (high_ports);
18587 mp->vrf_id = ntohl (vrf_id);
18595 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
18597 unformat_input_t *input = vam->input;
18598 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
18599 u32 sw_if_index = ~0;
18601 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
18602 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
18606 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18608 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18610 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18612 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
18614 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
18616 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
18618 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
18620 else if (unformat (input, "del"))
18626 if (sw_if_index == ~0)
18628 errmsg ("Interface required but not specified");
18634 errmsg ("VRF ID required but not specified");
18638 if (tcp_out_vrf_id == 0
18639 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
18642 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18646 /* Construct the API message */
18647 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
18649 mp->sw_if_index = ntohl (sw_if_index);
18650 mp->is_add = is_add;
18651 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
18652 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
18653 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
18654 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
18659 /* Wait for a reply... */
18665 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
18667 unformat_input_t *i = vam->input;
18668 vl_api_ipsec_gre_add_del_tunnel_t *mp;
18669 u32 local_sa_id = 0;
18670 u32 remote_sa_id = 0;
18671 ip4_address_t src_address;
18672 ip4_address_t dst_address;
18676 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18678 if (unformat (i, "local_sa %d", &local_sa_id))
18680 else if (unformat (i, "remote_sa %d", &remote_sa_id))
18682 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
18684 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
18686 else if (unformat (i, "del"))
18690 clib_warning ("parse error '%U'", format_unformat_error, i);
18695 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
18697 mp->local_sa_id = ntohl (local_sa_id);
18698 mp->remote_sa_id = ntohl (remote_sa_id);
18699 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
18700 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
18701 mp->is_add = is_add;
18709 api_punt (vat_main_t * vam)
18711 unformat_input_t *i = vam->input;
18719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18721 if (unformat (i, "ip %d", &ipv))
18723 else if (unformat (i, "protocol %d", &protocol))
18725 else if (unformat (i, "port %d", &port))
18727 else if (unformat (i, "del"))
18731 clib_warning ("parse error '%U'", format_unformat_error, i);
18738 mp->is_add = (u8) is_add;
18739 mp->ipv = (u8) ipv;
18740 mp->l4_protocol = (u8) protocol;
18741 mp->l4_port = htons ((u16) port);
18748 static void vl_api_ipsec_gre_tunnel_details_t_handler
18749 (vl_api_ipsec_gre_tunnel_details_t * mp)
18751 vat_main_t *vam = &vat_main;
18753 print (vam->ofp, "%11d%15U%15U%14d%14d",
18754 ntohl (mp->sw_if_index),
18755 format_ip4_address, &mp->src_address,
18756 format_ip4_address, &mp->dst_address,
18757 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
18760 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
18761 (vl_api_ipsec_gre_tunnel_details_t * mp)
18763 vat_main_t *vam = &vat_main;
18764 vat_json_node_t *node = NULL;
18765 struct in_addr ip4;
18767 if (VAT_JSON_ARRAY != vam->json_tree.type)
18769 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18770 vat_json_init_array (&vam->json_tree);
18772 node = vat_json_array_add (&vam->json_tree);
18774 vat_json_init_object (node);
18775 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18776 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
18777 vat_json_object_add_ip4 (node, "src_address", ip4);
18778 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
18779 vat_json_object_add_ip4 (node, "dst_address", ip4);
18780 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
18781 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
18785 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
18787 unformat_input_t *i = vam->input;
18788 vl_api_ipsec_gre_tunnel_dump_t *mp;
18789 vl_api_control_ping_t *mp_ping;
18791 u8 sw_if_index_set = 0;
18794 /* Parse args required to build the message */
18795 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18797 if (unformat (i, "sw_if_index %d", &sw_if_index))
18798 sw_if_index_set = 1;
18803 if (sw_if_index_set == 0)
18808 if (!vam->json_output)
18810 print (vam->ofp, "%11s%15s%15s%14s%14s",
18811 "sw_if_index", "src_address", "dst_address",
18812 "local_sa_id", "remote_sa_id");
18815 /* Get list of gre-tunnel interfaces */
18816 M (IPSEC_GRE_TUNNEL_DUMP, mp);
18818 mp->sw_if_index = htonl (sw_if_index);
18822 /* Use a control ping for synchronization */
18823 M (CONTROL_PING, mp_ping);
18831 api_delete_subif (vat_main_t * vam)
18833 unformat_input_t *i = vam->input;
18834 vl_api_delete_subif_t *mp;
18835 u32 sw_if_index = ~0;
18838 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18840 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18842 if (unformat (i, "sw_if_index %d", &sw_if_index))
18848 if (sw_if_index == ~0)
18850 errmsg ("missing sw_if_index");
18854 /* Construct the API message */
18855 M (DELETE_SUBIF, mp);
18856 mp->sw_if_index = ntohl (sw_if_index);
18863 #define foreach_pbb_vtr_op \
18864 _("disable", L2_VTR_DISABLED) \
18865 _("pop", L2_VTR_POP_2) \
18866 _("push", L2_VTR_PUSH_2)
18869 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
18871 unformat_input_t *i = vam->input;
18872 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
18873 u32 sw_if_index = ~0, vtr_op = ~0;
18874 u16 outer_tag = ~0;
18875 u8 dmac[6], smac[6];
18876 u8 dmac_set = 0, smac_set = 0;
18882 /* Shut up coverity */
18883 memset (dmac, 0, sizeof (dmac));
18884 memset (smac, 0, sizeof (smac));
18886 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18888 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18890 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18892 else if (unformat (i, "vtr_op %d", &vtr_op))
18894 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
18897 else if (unformat (i, "translate_pbb_stag"))
18899 if (unformat (i, "%d", &tmp))
18901 vtr_op = L2_VTR_TRANSLATE_2_1;
18907 ("translate_pbb_stag operation requires outer tag definition");
18911 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
18913 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
18915 else if (unformat (i, "sid %d", &sid))
18917 else if (unformat (i, "vlanid %d", &tmp))
18921 clib_warning ("parse error '%U'", format_unformat_error, i);
18926 if ((sw_if_index == ~0) || (vtr_op == ~0))
18928 errmsg ("missing sw_if_index or vtr operation");
18931 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
18932 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
18935 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
18939 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
18940 mp->sw_if_index = ntohl (sw_if_index);
18941 mp->vtr_op = ntohl (vtr_op);
18942 mp->outer_tag = ntohs (outer_tag);
18943 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
18944 clib_memcpy (mp->b_smac, smac, sizeof (smac));
18945 mp->b_vlanid = ntohs (vlanid);
18946 mp->i_sid = ntohl (sid);
18954 api_flow_classify_set_interface (vat_main_t * vam)
18956 unformat_input_t *i = vam->input;
18957 vl_api_flow_classify_set_interface_t *mp;
18959 int sw_if_index_set;
18960 u32 ip4_table_index = ~0;
18961 u32 ip6_table_index = ~0;
18965 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18967 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18968 sw_if_index_set = 1;
18969 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18970 sw_if_index_set = 1;
18971 else if (unformat (i, "del"))
18973 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18975 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18979 clib_warning ("parse error '%U'", format_unformat_error, i);
18984 if (sw_if_index_set == 0)
18986 errmsg ("missing interface name or sw_if_index");
18990 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
18992 mp->sw_if_index = ntohl (sw_if_index);
18993 mp->ip4_table_index = ntohl (ip4_table_index);
18994 mp->ip6_table_index = ntohl (ip6_table_index);
18995 mp->is_add = is_add;
19003 api_flow_classify_dump (vat_main_t * vam)
19005 unformat_input_t *i = vam->input;
19006 vl_api_flow_classify_dump_t *mp;
19007 vl_api_control_ping_t *mp_ping;
19008 u8 type = FLOW_CLASSIFY_N_TABLES;
19011 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
19015 errmsg ("classify table type must be specified");
19019 if (!vam->json_output)
19021 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19024 M (FLOW_CLASSIFY_DUMP, mp);
19029 /* Use a control ping for synchronization */
19030 M (CONTROL_PING, mp_ping);
19033 /* Wait for a reply... */
19039 api_feature_enable_disable (vat_main_t * vam)
19041 unformat_input_t *i = vam->input;
19042 vl_api_feature_enable_disable_t *mp;
19044 u8 *feature_name = 0;
19045 u32 sw_if_index = ~0;
19049 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19051 if (unformat (i, "arc_name %s", &arc_name))
19053 else if (unformat (i, "feature_name %s", &feature_name))
19056 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19058 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19060 else if (unformat (i, "disable"))
19068 errmsg ("missing arc name");
19071 if (vec_len (arc_name) > 63)
19073 errmsg ("arc name too long");
19076 if (feature_name == 0)
19078 errmsg ("missing feature name");
19081 if (vec_len (feature_name) > 63)
19083 errmsg ("feature name too long");
19086 if (sw_if_index == ~0)
19088 errmsg ("missing interface name or sw_if_index");
19092 /* Construct the API message */
19093 M (FEATURE_ENABLE_DISABLE, mp);
19094 mp->sw_if_index = ntohl (sw_if_index);
19095 mp->enable = enable;
19096 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
19097 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
19098 vec_free (arc_name);
19099 vec_free (feature_name);
19107 api_sw_interface_tag_add_del (vat_main_t * vam)
19109 unformat_input_t *i = vam->input;
19110 vl_api_sw_interface_tag_add_del_t *mp;
19111 u32 sw_if_index = ~0;
19116 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19118 if (unformat (i, "tag %s", &tag))
19120 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19122 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19124 else if (unformat (i, "del"))
19130 if (sw_if_index == ~0)
19132 errmsg ("missing interface name or sw_if_index");
19136 if (enable && (tag == 0))
19138 errmsg ("no tag specified");
19142 /* Construct the API message */
19143 M (SW_INTERFACE_TAG_ADD_DEL, mp);
19144 mp->sw_if_index = ntohl (sw_if_index);
19145 mp->is_add = enable;
19147 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
19155 static void vl_api_l2_xconnect_details_t_handler
19156 (vl_api_l2_xconnect_details_t * mp)
19158 vat_main_t *vam = &vat_main;
19160 print (vam->ofp, "%15d%15d",
19161 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
19164 static void vl_api_l2_xconnect_details_t_handler_json
19165 (vl_api_l2_xconnect_details_t * mp)
19167 vat_main_t *vam = &vat_main;
19168 vat_json_node_t *node = NULL;
19170 if (VAT_JSON_ARRAY != vam->json_tree.type)
19172 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19173 vat_json_init_array (&vam->json_tree);
19175 node = vat_json_array_add (&vam->json_tree);
19177 vat_json_init_object (node);
19178 vat_json_object_add_uint (node, "rx_sw_if_index",
19179 ntohl (mp->rx_sw_if_index));
19180 vat_json_object_add_uint (node, "tx_sw_if_index",
19181 ntohl (mp->tx_sw_if_index));
19185 api_l2_xconnect_dump (vat_main_t * vam)
19187 vl_api_l2_xconnect_dump_t *mp;
19188 vl_api_control_ping_t *mp_ping;
19191 if (!vam->json_output)
19193 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
19196 M (L2_XCONNECT_DUMP, mp);
19200 /* Use a control ping for synchronization */
19201 M (CONTROL_PING, mp_ping);
19209 api_sw_interface_set_mtu (vat_main_t * vam)
19211 unformat_input_t *i = vam->input;
19212 vl_api_sw_interface_set_mtu_t *mp;
19213 u32 sw_if_index = ~0;
19217 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19219 if (unformat (i, "mtu %d", &mtu))
19221 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19223 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19229 if (sw_if_index == ~0)
19231 errmsg ("missing interface name or sw_if_index");
19237 errmsg ("no mtu specified");
19241 /* Construct the API message */
19242 M (SW_INTERFACE_SET_MTU, mp);
19243 mp->sw_if_index = ntohl (sw_if_index);
19244 mp->mtu = ntohs ((u16) mtu);
19252 api_p2p_ethernet_add (vat_main_t * vam)
19254 unformat_input_t *i = vam->input;
19255 vl_api_p2p_ethernet_add_t *mp;
19256 u32 parent_if_index = ~0;
19262 memset (remote_mac, 0, sizeof (remote_mac));
19263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19265 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19267 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19271 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19273 else if (unformat (i, "sub_id %d", &sub_id))
19277 clib_warning ("parse error '%U'", format_unformat_error, i);
19282 if (parent_if_index == ~0)
19284 errmsg ("missing interface name or sw_if_index");
19289 errmsg ("missing remote mac address");
19294 errmsg ("missing sub-interface id");
19298 M (P2P_ETHERNET_ADD, mp);
19299 mp->parent_if_index = ntohl (parent_if_index);
19300 mp->subif_id = ntohl (sub_id);
19301 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19309 api_p2p_ethernet_del (vat_main_t * vam)
19311 unformat_input_t *i = vam->input;
19312 vl_api_p2p_ethernet_del_t *mp;
19313 u32 parent_if_index = ~0;
19318 memset (remote_mac, 0, sizeof (remote_mac));
19319 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19321 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19323 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19327 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19331 clib_warning ("parse error '%U'", format_unformat_error, i);
19336 if (parent_if_index == ~0)
19338 errmsg ("missing interface name or sw_if_index");
19343 errmsg ("missing remote mac address");
19347 M (P2P_ETHERNET_DEL, mp);
19348 mp->parent_if_index = ntohl (parent_if_index);
19349 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19357 api_lldp_config (vat_main_t * vam)
19359 unformat_input_t *i = vam->input;
19360 vl_api_lldp_config_t *mp;
19362 int tx_interval = 0;
19363 u8 *sys_name = NULL;
19366 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19368 if (unformat (i, "system-name %s", &sys_name))
19370 else if (unformat (i, "tx-hold %d", &tx_hold))
19372 else if (unformat (i, "tx-interval %d", &tx_interval))
19376 clib_warning ("parse error '%U'", format_unformat_error, i);
19381 vec_add1 (sys_name, 0);
19383 M (LLDP_CONFIG, mp);
19384 mp->tx_hold = htonl (tx_hold);
19385 mp->tx_interval = htonl (tx_interval);
19386 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
19387 vec_free (sys_name);
19395 api_sw_interface_set_lldp (vat_main_t * vam)
19397 unformat_input_t *i = vam->input;
19398 vl_api_sw_interface_set_lldp_t *mp;
19399 u32 sw_if_index = ~0;
19401 u8 *port_desc = NULL;
19404 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19406 if (unformat (i, "disable"))
19409 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19411 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19413 else if (unformat (i, "port-desc %s", &port_desc))
19419 if (sw_if_index == ~0)
19421 errmsg ("missing interface name or sw_if_index");
19425 /* Construct the API message */
19426 vec_add1 (port_desc, 0);
19427 M (SW_INTERFACE_SET_LLDP, mp);
19428 mp->sw_if_index = ntohl (sw_if_index);
19429 mp->enable = enable;
19430 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
19431 vec_free (port_desc);
19439 q_or_quit (vat_main_t * vam)
19441 #if VPP_API_TEST_BUILTIN == 0
19442 longjmp (vam->jump_buf, 1);
19444 return 0; /* not so much */
19448 q (vat_main_t * vam)
19450 return q_or_quit (vam);
19454 quit (vat_main_t * vam)
19456 return q_or_quit (vam);
19460 comment (vat_main_t * vam)
19466 cmd_cmp (void *a1, void *a2)
19471 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
19475 help (vat_main_t * vam)
19480 unformat_input_t *i = vam->input;
19483 if (unformat (i, "%s", &name))
19487 vec_add1 (name, 0);
19489 hs = hash_get_mem (vam->help_by_name, name);
19491 print (vam->ofp, "usage: %s %s", name, hs[0]);
19493 print (vam->ofp, "No such msg / command '%s'", name);
19498 print (vam->ofp, "Help is available for the following:");
19501 hash_foreach_pair (p, vam->function_by_name,
19503 vec_add1 (cmds, (u8 *)(p->key));
19507 vec_sort_with_function (cmds, cmd_cmp);
19509 for (j = 0; j < vec_len (cmds); j++)
19510 print (vam->ofp, "%s", cmds[j]);
19517 set (vat_main_t * vam)
19519 u8 *name = 0, *value = 0;
19520 unformat_input_t *i = vam->input;
19522 if (unformat (i, "%s", &name))
19524 /* The input buffer is a vector, not a string. */
19525 value = vec_dup (i->buffer);
19526 vec_delete (value, i->index, 0);
19527 /* Almost certainly has a trailing newline */
19528 if (value[vec_len (value) - 1] == '\n')
19529 value[vec_len (value) - 1] = 0;
19530 /* Make sure it's a proper string, one way or the other */
19531 vec_add1 (value, 0);
19532 (void) clib_macro_set_value (&vam->macro_main,
19533 (char *) name, (char *) value);
19536 errmsg ("usage: set <name> <value>");
19544 unset (vat_main_t * vam)
19548 if (unformat (vam->input, "%s", &name))
19549 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
19550 errmsg ("unset: %s wasn't set", name);
19563 macro_sort_cmp (void *a1, void *a2)
19565 macro_sort_t *s1 = a1;
19566 macro_sort_t *s2 = a2;
19568 return strcmp ((char *) (s1->name), (char *) (s2->name));
19572 dump_macro_table (vat_main_t * vam)
19574 macro_sort_t *sort_me = 0, *sm;
19579 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
19581 vec_add2 (sort_me, sm, 1);
19582 sm->name = (u8 *)(p->key);
19583 sm->value = (u8 *) (p->value[0]);
19587 vec_sort_with_function (sort_me, macro_sort_cmp);
19589 if (vec_len (sort_me))
19590 print (vam->ofp, "%-15s%s", "Name", "Value");
19592 print (vam->ofp, "The macro table is empty...");
19594 for (i = 0; i < vec_len (sort_me); i++)
19595 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
19600 dump_node_table (vat_main_t * vam)
19603 vlib_node_t *node, *next_node;
19605 if (vec_len (vam->graph_nodes) == 0)
19607 print (vam->ofp, "Node table empty, issue get_node_graph...");
19611 for (i = 0; i < vec_len (vam->graph_nodes); i++)
19613 node = vam->graph_nodes[i];
19614 print (vam->ofp, "[%d] %s", i, node->name);
19615 for (j = 0; j < vec_len (node->next_nodes); j++)
19617 if (node->next_nodes[j] != ~0)
19619 next_node = vam->graph_nodes[node->next_nodes[j]];
19620 print (vam->ofp, " [%d] %s", j, next_node->name);
19628 value_sort_cmp (void *a1, void *a2)
19630 name_sort_t *n1 = a1;
19631 name_sort_t *n2 = a2;
19633 if (n1->value < n2->value)
19635 if (n1->value > n2->value)
19642 dump_msg_api_table (vat_main_t * vam)
19644 api_main_t *am = &api_main;
19645 name_sort_t *nses = 0, *ns;
19650 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
19652 vec_add2 (nses, ns, 1);
19653 ns->name = (u8 *)(hp->key);
19654 ns->value = (u32) hp->value[0];
19658 vec_sort_with_function (nses, value_sort_cmp);
19660 for (i = 0; i < vec_len (nses); i++)
19661 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
19667 get_msg_id (vat_main_t * vam)
19672 if (unformat (vam->input, "%s", &name_and_crc))
19674 message_index = vl_api_get_msg_index (name_and_crc);
19675 if (message_index == ~0)
19677 print (vam->ofp, " '%s' not found", name_and_crc);
19680 print (vam->ofp, " '%s' has message index %d",
19681 name_and_crc, message_index);
19684 errmsg ("name_and_crc required...");
19689 search_node_table (vat_main_t * vam)
19691 unformat_input_t *line_input = vam->input;
19694 vlib_node_t *node, *next_node;
19697 if (vam->graph_node_index_by_name == 0)
19699 print (vam->ofp, "Node table empty, issue get_node_graph...");
19703 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
19705 if (unformat (line_input, "%s", &node_to_find))
19707 vec_add1 (node_to_find, 0);
19708 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
19711 print (vam->ofp, "%s not found...", node_to_find);
19714 node = vam->graph_nodes[p[0]];
19715 print (vam->ofp, "[%d] %s", p[0], node->name);
19716 for (j = 0; j < vec_len (node->next_nodes); j++)
19718 if (node->next_nodes[j] != ~0)
19720 next_node = vam->graph_nodes[node->next_nodes[j]];
19721 print (vam->ofp, " [%d] %s", j, next_node->name);
19728 clib_warning ("parse error '%U'", format_unformat_error,
19734 vec_free (node_to_find);
19743 script (vat_main_t * vam)
19745 #if (VPP_API_TEST_BUILTIN==0)
19747 char *save_current_file;
19748 unformat_input_t save_input;
19749 jmp_buf save_jump_buf;
19750 u32 save_line_number;
19752 FILE *new_fp, *save_ifp;
19754 if (unformat (vam->input, "%s", &s))
19756 new_fp = fopen ((char *) s, "r");
19759 errmsg ("Couldn't open script file %s", s);
19766 errmsg ("Missing script name");
19770 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
19771 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
19772 save_ifp = vam->ifp;
19773 save_line_number = vam->input_line_number;
19774 save_current_file = (char *) vam->current_file;
19776 vam->input_line_number = 0;
19778 vam->current_file = s;
19781 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
19782 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
19783 vam->ifp = save_ifp;
19784 vam->input_line_number = save_line_number;
19785 vam->current_file = (u8 *) save_current_file;
19790 clib_warning ("use the exec command...");
19796 echo (vat_main_t * vam)
19798 print (vam->ofp, "%v", vam->input->buffer);
19802 /* List of API message constructors, CLI names map to api_xxx */
19803 #define foreach_vpe_api_msg \
19804 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
19805 _(sw_interface_dump,"") \
19806 _(sw_interface_set_flags, \
19807 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
19808 _(sw_interface_add_del_address, \
19809 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
19810 _(sw_interface_set_table, \
19811 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
19812 _(sw_interface_set_mpls_enable, \
19813 "<intfc> | sw_if_index [disable | dis]") \
19814 _(sw_interface_set_vpath, \
19815 "<intfc> | sw_if_index <id> enable | disable") \
19816 _(sw_interface_set_vxlan_bypass, \
19817 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
19818 _(sw_interface_set_l2_xconnect, \
19819 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
19820 "enable | disable") \
19821 _(sw_interface_set_l2_bridge, \
19822 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
19823 "[shg <split-horizon-group>] [bvi]\n" \
19824 "enable | disable") \
19825 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
19826 _(bridge_domain_add_del, \
19827 "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") \
19828 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
19830 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
19831 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
19832 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
19834 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
19836 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
19838 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
19840 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
19842 "<vpp-if-name> | sw_if_index <id>") \
19843 _(sw_interface_tap_dump, "") \
19844 _(ip_add_del_route, \
19845 "<addr>/<mask> via <addr> [table-id <n>]\n" \
19846 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
19847 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
19848 "[multipath] [count <n>]") \
19849 _(ip_mroute_add_del, \
19850 "<src> <grp>/<mask> [table-id <n>]\n" \
19851 "[<intfc> | sw_if_index <id>] [local] [del]") \
19852 _(mpls_route_add_del, \
19853 "<label> <eos> via <addr> [table-id <n>]\n" \
19854 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
19855 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
19856 "[multipath] [count <n>]") \
19857 _(mpls_ip_bind_unbind, \
19858 "<label> <addr/len>") \
19859 _(mpls_tunnel_add_del, \
19860 " via <addr> [table-id <n>]\n" \
19861 "sw_if_index <id>] [l2] [del]") \
19862 _(proxy_arp_add_del, \
19863 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
19864 _(proxy_arp_intfc_enable_disable, \
19865 "<intfc> | sw_if_index <id> enable | disable") \
19866 _(sw_interface_set_unnumbered, \
19867 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
19868 _(ip_neighbor_add_del, \
19869 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
19870 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
19871 _(reset_vrf, "vrf <id> [ipv6]") \
19872 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
19873 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
19874 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
19875 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
19876 "[outer_vlan_id_any][inner_vlan_id_any]") \
19877 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
19878 _(reset_fib, "vrf <n> [ipv6]") \
19879 _(dhcp_proxy_config, \
19880 "svr <v46-address> src <v46-address>\n" \
19881 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
19882 _(dhcp_proxy_set_vss, \
19883 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
19884 _(dhcp_proxy_dump, "ip6") \
19885 _(dhcp_client_config, \
19886 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
19887 _(set_ip_flow_hash, \
19888 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
19889 _(sw_interface_ip6_enable_disable, \
19890 "<intfc> | sw_if_index <id> enable | disable") \
19891 _(sw_interface_ip6_set_link_local_address, \
19892 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
19893 _(ip6nd_proxy_add_del, \
19894 "<intfc> | sw_if_index <id> <ip6-address>") \
19895 _(ip6nd_proxy_dump, "") \
19896 _(sw_interface_ip6nd_ra_prefix, \
19897 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
19898 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
19899 "[nolink] [isno]") \
19900 _(sw_interface_ip6nd_ra_config, \
19901 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
19902 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
19903 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
19904 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
19905 _(l2_patch_add_del, \
19906 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
19907 "enable | disable") \
19908 _(sr_localsid_add_del, \
19909 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
19910 "fib-table <num> (end.psp) sw_if_index <num>") \
19911 _(classify_add_del_table, \
19912 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
19913 " [del] [del-chain] mask <mask-value>\n" \
19914 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
19915 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
19916 _(classify_add_del_session, \
19917 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
19918 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
19919 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
19920 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
19921 _(classify_set_interface_ip_table, \
19922 "<intfc> | sw_if_index <nn> table <nn>") \
19923 _(classify_set_interface_l2_tables, \
19924 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19925 " [other-table <nn>]") \
19926 _(get_node_index, "node <node-name") \
19927 _(add_node_next, "node <node-name> next <next-node-name>") \
19928 _(l2tpv3_create_tunnel, \
19929 "client_address <ip6-addr> our_address <ip6-addr>\n" \
19930 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
19931 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
19932 _(l2tpv3_set_tunnel_cookies, \
19933 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
19934 "[new_remote_cookie <nn>]\n") \
19935 _(l2tpv3_interface_enable_disable, \
19936 "<intfc> | sw_if_index <nn> enable | disable") \
19937 _(l2tpv3_set_lookup_key, \
19938 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
19939 _(sw_if_l2tpv3_tunnel_dump, "") \
19940 _(vxlan_add_del_tunnel, \
19941 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
19942 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
19943 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
19944 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19945 _(gre_add_del_tunnel, \
19946 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
19947 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19948 _(l2_fib_clear_table, "") \
19949 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
19950 _(l2_interface_vlan_tag_rewrite, \
19951 "<intfc> | sw_if_index <nn> \n" \
19952 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
19953 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
19954 _(create_vhost_user_if, \
19955 "socket <filename> [server] [renumber <dev_instance>] " \
19956 "[mac <mac_address>]") \
19957 _(modify_vhost_user_if, \
19958 "<intfc> | sw_if_index <nn> socket <filename>\n" \
19959 "[server] [renumber <dev_instance>]") \
19960 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
19961 _(sw_interface_vhost_user_dump, "") \
19962 _(show_version, "") \
19963 _(vxlan_gpe_add_del_tunnel, \
19964 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
19965 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
19966 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
19967 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
19968 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19969 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
19970 _(interface_name_renumber, \
19971 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
19972 _(input_acl_set_interface, \
19973 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19974 " [l2-table <nn>] [del]") \
19975 _(want_ip4_arp_events, "address <ip4-address> [del]") \
19976 _(want_ip6_nd_events, "address <ip6-address> [del]") \
19977 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
19978 _(ip_dump, "ipv4 | ipv6") \
19979 _(ipsec_spd_add_del, "spd_id <n> [del]") \
19980 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
19982 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
19983 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
19984 " integ_alg <alg> integ_key <hex>") \
19985 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
19986 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
19987 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
19988 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
19989 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
19990 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
19991 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
19992 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
19993 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
19994 _(ikev2_profile_add_del, "name <profile_name> [del]") \
19995 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
19996 "(auth_data 0x<data> | auth_data <data>)") \
19997 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
19998 "(id_data 0x<data> | id_data <data>) (local|remote)") \
19999 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
20000 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
20001 "(local|remote)") \
20002 _(ikev2_set_local_key, "file <absolute_file_path>") \
20003 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
20004 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
20005 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
20006 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
20007 _(ikev2_initiate_sa_init, "<profile_name>") \
20008 _(ikev2_initiate_del_ike_sa, "<ispi>") \
20009 _(ikev2_initiate_del_child_sa, "<ispi>") \
20010 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
20011 _(delete_loopback,"sw_if_index <nn>") \
20012 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
20013 _(map_add_domain, \
20014 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
20015 "ip6-src <ip6addr> " \
20016 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
20017 _(map_del_domain, "index <n>") \
20018 _(map_add_del_rule, \
20019 "index <n> psid <n> dst <ip6addr> [del]") \
20020 _(map_domain_dump, "") \
20021 _(map_rule_dump, "index <map-domain>") \
20022 _(want_interface_events, "enable|disable") \
20023 _(want_stats,"enable|disable") \
20024 _(get_first_msg_id, "client <name>") \
20025 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
20026 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
20027 "fib-id <nn> [ip4][ip6][default]") \
20028 _(get_node_graph, " ") \
20029 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
20030 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
20031 _(ioam_disable, "") \
20032 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
20033 " sw_if_index <sw_if_index> p <priority> " \
20034 "w <weight>] [del]") \
20035 _(one_add_del_locator, "locator-set <locator_name> " \
20036 "iface <intf> | sw_if_index <sw_if_index> " \
20037 "p <priority> w <weight> [del]") \
20038 _(one_add_del_local_eid,"vni <vni> eid " \
20039 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20040 "locator-set <locator_name> [del]" \
20041 "[key-id sha1|sha256 secret-key <secret-key>]")\
20042 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
20043 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
20044 _(one_enable_disable, "enable|disable") \
20045 _(one_map_register_enable_disable, "enable|disable") \
20046 _(one_rloc_probe_enable_disable, "enable|disable") \
20047 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20049 "rloc <locator> p <prio> " \
20050 "w <weight> [rloc <loc> ... ] " \
20051 "action <action> [del-all]") \
20052 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20054 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20055 _(one_use_petr, "ip-address> | disable") \
20056 _(one_map_request_mode, "src-dst|dst-only") \
20057 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20058 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20059 _(one_locator_set_dump, "[local | remote]") \
20060 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
20061 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20062 "[local] | [remote]") \
20063 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
20064 _(one_l2_arp_bd_get, "") \
20065 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
20066 _(one_stats_enable_disable, "enable|disalbe") \
20067 _(show_one_stats_enable_disable, "") \
20068 _(one_eid_table_vni_dump, "") \
20069 _(one_eid_table_map_dump, "l2|l3") \
20070 _(one_map_resolver_dump, "") \
20071 _(one_map_server_dump, "") \
20072 _(one_adjacencies_get, "vni <vni>") \
20073 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
20074 _(show_one_rloc_probe_state, "") \
20075 _(show_one_map_register_state, "") \
20076 _(show_one_status, "") \
20077 _(one_stats_dump, "") \
20078 _(one_stats_flush, "") \
20079 _(one_get_map_request_itr_rlocs, "") \
20080 _(one_map_register_set_ttl, "<ttl>") \
20081 _(show_one_nsh_mapping, "") \
20082 _(show_one_pitr, "") \
20083 _(show_one_use_petr, "") \
20084 _(show_one_map_request_mode, "") \
20085 _(show_one_map_register_ttl, "") \
20086 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
20087 " sw_if_index <sw_if_index> p <priority> " \
20088 "w <weight>] [del]") \
20089 _(lisp_add_del_locator, "locator-set <locator_name> " \
20090 "iface <intf> | sw_if_index <sw_if_index> " \
20091 "p <priority> w <weight> [del]") \
20092 _(lisp_add_del_local_eid,"vni <vni> eid " \
20093 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20094 "locator-set <locator_name> [del]" \
20095 "[key-id sha1|sha256 secret-key <secret-key>]") \
20096 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
20097 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
20098 _(lisp_enable_disable, "enable|disable") \
20099 _(lisp_map_register_enable_disable, "enable|disable") \
20100 _(lisp_rloc_probe_enable_disable, "enable|disable") \
20101 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20103 "rloc <locator> p <prio> " \
20104 "w <weight> [rloc <loc> ... ] " \
20105 "action <action> [del-all]") \
20106 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20108 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20109 _(lisp_use_petr, "<ip-address> | disable") \
20110 _(lisp_map_request_mode, "src-dst|dst-only") \
20111 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20112 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20113 _(lisp_locator_set_dump, "[local | remote]") \
20114 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
20115 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20116 "[local] | [remote]") \
20117 _(lisp_eid_table_vni_dump, "") \
20118 _(lisp_eid_table_map_dump, "l2|l3") \
20119 _(lisp_map_resolver_dump, "") \
20120 _(lisp_map_server_dump, "") \
20121 _(lisp_adjacencies_get, "vni <vni>") \
20122 _(gpe_fwd_entry_vnis_get, "") \
20123 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
20124 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
20125 "[table <table-id>]") \
20126 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
20127 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
20128 _(gpe_set_encap_mode, "lisp|vxlan") \
20129 _(gpe_get_encap_mode, "") \
20130 _(lisp_gpe_add_del_iface, "up|down") \
20131 _(lisp_gpe_enable_disable, "enable|disable") \
20132 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
20133 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
20134 _(show_lisp_rloc_probe_state, "") \
20135 _(show_lisp_map_register_state, "") \
20136 _(show_lisp_status, "") \
20137 _(lisp_get_map_request_itr_rlocs, "") \
20138 _(show_lisp_pitr, "") \
20139 _(show_lisp_use_petr, "") \
20140 _(show_lisp_map_request_mode, "") \
20141 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
20142 _(af_packet_delete, "name <host interface name>") \
20143 _(policer_add_del, "name <policer name> <params> [del]") \
20144 _(policer_dump, "[name <policer name>]") \
20145 _(policer_classify_set_interface, \
20146 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20147 " [l2-table <nn>] [del]") \
20148 _(policer_classify_dump, "type [ip4|ip6|l2]") \
20149 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
20150 "[master|slave]") \
20151 _(netmap_delete, "name <interface name>") \
20152 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
20153 _(mpls_fib_dump, "") \
20154 _(classify_table_ids, "") \
20155 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
20156 _(classify_table_info, "table_id <nn>") \
20157 _(classify_session_dump, "table_id <nn>") \
20158 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
20159 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
20160 "[template_interval <nn>] [udp_checksum]") \
20161 _(ipfix_exporter_dump, "") \
20162 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
20163 _(ipfix_classify_stream_dump, "") \
20164 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
20165 _(ipfix_classify_table_dump, "") \
20166 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
20167 _(sw_interface_span_dump, "[l2]") \
20168 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
20169 _(pg_create_interface, "if_id <nn>") \
20170 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
20171 _(pg_enable_disable, "[stream <id>] disable") \
20172 _(ip_source_and_port_range_check_add_del, \
20173 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
20174 _(ip_source_and_port_range_check_interface_add_del, \
20175 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
20176 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
20177 _(ipsec_gre_add_del_tunnel, \
20178 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
20179 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
20180 _(delete_subif,"<intfc> | sw_if_index <nn>") \
20181 _(l2_interface_pbb_tag_rewrite, \
20182 "<intfc> | sw_if_index <nn> \n" \
20183 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
20184 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
20185 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
20186 _(flow_classify_set_interface, \
20187 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
20188 _(flow_classify_dump, "type [ip4|ip6]") \
20189 _(ip_fib_dump, "") \
20190 _(ip_mfib_dump, "") \
20191 _(ip6_fib_dump, "") \
20192 _(ip6_mfib_dump, "") \
20193 _(feature_enable_disable, "arc_name <arc_name> " \
20194 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
20195 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
20197 _(l2_xconnect_dump, "") \
20198 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
20199 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
20200 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
20201 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
20202 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
20203 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
20204 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>] [disable]")
20206 /* List of command functions, CLI names map directly to functions */
20207 #define foreach_cli_function \
20208 _(comment, "usage: comment <ignore-rest-of-line>") \
20209 _(dump_interface_table, "usage: dump_interface_table") \
20210 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
20211 _(dump_ipv4_table, "usage: dump_ipv4_table") \
20212 _(dump_ipv6_table, "usage: dump_ipv6_table") \
20213 _(dump_stats_table, "usage: dump_stats_table") \
20214 _(dump_macro_table, "usage: dump_macro_table ") \
20215 _(dump_node_table, "usage: dump_node_table") \
20216 _(dump_msg_api_table, "usage: dump_msg_api_table") \
20217 _(get_msg_id, "usage: get_msg_id name_and_crc") \
20218 _(echo, "usage: echo <message>") \
20219 _(exec, "usage: exec <vpe-debug-CLI-command>") \
20220 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
20221 _(help, "usage: help") \
20222 _(q, "usage: quit") \
20223 _(quit, "usage: quit") \
20224 _(search_node_table, "usage: search_node_table <name>...") \
20225 _(set, "usage: set <variable-name> <value>") \
20226 _(script, "usage: script <file-name>") \
20227 _(unset, "usage: unset <variable-name>")
20229 static void vl_api_##n##_t_handler_uni \
20230 (vl_api_##n##_t * mp) \
20232 vat_main_t * vam = &vat_main; \
20233 if (vam->json_output) { \
20234 vl_api_##n##_t_handler_json(mp); \
20236 vl_api_##n##_t_handler(mp); \
20239 foreach_vpe_api_reply_msg;
20240 #if VPP_API_TEST_BUILTIN == 0
20241 foreach_standalone_reply_msg;
20246 vat_api_hookup (vat_main_t * vam)
20249 vl_msg_api_set_handlers(VL_API_##N, #n, \
20250 vl_api_##n##_t_handler_uni, \
20252 vl_api_##n##_t_endian, \
20253 vl_api_##n##_t_print, \
20254 sizeof(vl_api_##n##_t), 1);
20255 foreach_vpe_api_reply_msg;
20256 #if VPP_API_TEST_BUILTIN == 0
20257 foreach_standalone_reply_msg;
20261 #if (VPP_API_TEST_BUILTIN==0)
20262 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
20264 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
20266 vam->function_by_name = hash_create_string (0, sizeof (uword));
20268 vam->help_by_name = hash_create_string (0, sizeof (uword));
20271 /* API messages we can send */
20272 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
20273 foreach_vpe_api_msg;
20277 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
20278 foreach_vpe_api_msg;
20281 /* CLI functions */
20282 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
20283 foreach_cli_function;
20287 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
20288 foreach_cli_function;
20292 #if VPP_API_TEST_BUILTIN
20293 static clib_error_t *
20294 vat_api_hookup_shim (vlib_main_t * vm)
20296 vat_api_hookup (&vat_main);
20300 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
20304 * fd.io coding-style-patch-verification: ON
20307 * eval: (c-set-style "gnu")