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_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3856 vat_main_t *vam = &vat_main;
3857 i32 retval = ntohl (mp->retval);
3861 print (vam->ofp, "%-20s%-16s",
3862 mp->status ? "enabled" : "disabled",
3863 mp->status ? (char *) mp->locator_set_name : "");
3866 vam->retval = retval;
3867 vam->result_ready = 1;
3871 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3873 vat_main_t *vam = &vat_main;
3874 vat_json_node_t node;
3877 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3878 vec_add1 (status, 0);
3880 vat_json_init_object (&node);
3881 vat_json_object_add_string_copy (&node, "status", status);
3884 vat_json_object_add_string_copy (&node, "locator_set",
3885 mp->locator_set_name);
3890 vat_json_print (vam->ofp, &node);
3891 vat_json_free (&node);
3893 vam->retval = ntohl (mp->retval);
3894 vam->result_ready = 1;
3898 format_policer_type (u8 * s, va_list * va)
3900 u32 i = va_arg (*va, u32);
3902 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3903 s = format (s, "1r2c");
3904 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3905 s = format (s, "1r3c");
3906 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3907 s = format (s, "2r3c-2698");
3908 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3909 s = format (s, "2r3c-4115");
3910 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3911 s = format (s, "2r3c-mef5cf1");
3913 s = format (s, "ILLEGAL");
3918 format_policer_rate_type (u8 * s, va_list * va)
3920 u32 i = va_arg (*va, u32);
3922 if (i == SSE2_QOS_RATE_KBPS)
3923 s = format (s, "kbps");
3924 else if (i == SSE2_QOS_RATE_PPS)
3925 s = format (s, "pps");
3927 s = format (s, "ILLEGAL");
3932 format_policer_round_type (u8 * s, va_list * va)
3934 u32 i = va_arg (*va, u32);
3936 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3937 s = format (s, "closest");
3938 else if (i == SSE2_QOS_ROUND_TO_UP)
3939 s = format (s, "up");
3940 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3941 s = format (s, "down");
3943 s = format (s, "ILLEGAL");
3948 format_policer_action_type (u8 * s, va_list * va)
3950 u32 i = va_arg (*va, u32);
3952 if (i == SSE2_QOS_ACTION_DROP)
3953 s = format (s, "drop");
3954 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3955 s = format (s, "transmit");
3956 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3957 s = format (s, "mark-and-transmit");
3959 s = format (s, "ILLEGAL");
3964 format_dscp (u8 * s, va_list * va)
3966 u32 i = va_arg (*va, u32);
3971 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3975 return format (s, "ILLEGAL");
3977 s = format (s, "%s", t);
3982 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3984 vat_main_t *vam = &vat_main;
3985 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3987 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3988 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3990 conform_dscp_str = format (0, "");
3992 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3993 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3995 exceed_dscp_str = format (0, "");
3997 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3998 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4000 violate_dscp_str = format (0, "");
4002 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4003 "rate type %U, round type %U, %s rate, %s color-aware, "
4004 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4005 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4006 "conform action %U%s, exceed action %U%s, violate action %U%s",
4008 format_policer_type, mp->type,
4011 clib_net_to_host_u64 (mp->cb),
4012 clib_net_to_host_u64 (mp->eb),
4013 format_policer_rate_type, mp->rate_type,
4014 format_policer_round_type, mp->round_type,
4015 mp->single_rate ? "single" : "dual",
4016 mp->color_aware ? "is" : "not",
4017 ntohl (mp->cir_tokens_per_period),
4018 ntohl (mp->pir_tokens_per_period),
4020 ntohl (mp->current_limit),
4021 ntohl (mp->current_bucket),
4022 ntohl (mp->extended_limit),
4023 ntohl (mp->extended_bucket),
4024 clib_net_to_host_u64 (mp->last_update_time),
4025 format_policer_action_type, mp->conform_action_type,
4027 format_policer_action_type, mp->exceed_action_type,
4029 format_policer_action_type, mp->violate_action_type,
4032 vec_free (conform_dscp_str);
4033 vec_free (exceed_dscp_str);
4034 vec_free (violate_dscp_str);
4037 static void vl_api_policer_details_t_handler_json
4038 (vl_api_policer_details_t * mp)
4040 vat_main_t *vam = &vat_main;
4041 vat_json_node_t *node;
4042 u8 *rate_type_str, *round_type_str, *type_str;
4043 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4045 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4047 format (0, "%U", format_policer_round_type, mp->round_type);
4048 type_str = format (0, "%U", format_policer_type, mp->type);
4049 conform_action_str = format (0, "%U", format_policer_action_type,
4050 mp->conform_action_type);
4051 exceed_action_str = format (0, "%U", format_policer_action_type,
4052 mp->exceed_action_type);
4053 violate_action_str = format (0, "%U", format_policer_action_type,
4054 mp->violate_action_type);
4056 if (VAT_JSON_ARRAY != vam->json_tree.type)
4058 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4059 vat_json_init_array (&vam->json_tree);
4061 node = vat_json_array_add (&vam->json_tree);
4063 vat_json_init_object (node);
4064 vat_json_object_add_string_copy (node, "name", mp->name);
4065 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4066 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4067 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4068 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4069 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4070 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4071 vat_json_object_add_string_copy (node, "type", type_str);
4072 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4073 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4074 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4075 vat_json_object_add_uint (node, "cir_tokens_per_period",
4076 ntohl (mp->cir_tokens_per_period));
4077 vat_json_object_add_uint (node, "eir_tokens_per_period",
4078 ntohl (mp->pir_tokens_per_period));
4079 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4080 vat_json_object_add_uint (node, "current_bucket",
4081 ntohl (mp->current_bucket));
4082 vat_json_object_add_uint (node, "extended_limit",
4083 ntohl (mp->extended_limit));
4084 vat_json_object_add_uint (node, "extended_bucket",
4085 ntohl (mp->extended_bucket));
4086 vat_json_object_add_uint (node, "last_update_time",
4087 ntohl (mp->last_update_time));
4088 vat_json_object_add_string_copy (node, "conform_action",
4089 conform_action_str);
4090 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4092 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4093 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4094 vec_free (dscp_str);
4096 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4097 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4099 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4100 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4101 vec_free (dscp_str);
4103 vat_json_object_add_string_copy (node, "violate_action",
4104 violate_action_str);
4105 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4107 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4108 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4109 vec_free (dscp_str);
4112 vec_free (rate_type_str);
4113 vec_free (round_type_str);
4114 vec_free (type_str);
4115 vec_free (conform_action_str);
4116 vec_free (exceed_action_str);
4117 vec_free (violate_action_str);
4121 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4124 vat_main_t *vam = &vat_main;
4125 int i, count = ntohl (mp->count);
4128 print (vam->ofp, "classify table ids (%d) : ", count);
4129 for (i = 0; i < count; i++)
4131 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4132 print (vam->ofp, (i < count - 1) ? "," : "");
4134 vam->retval = ntohl (mp->retval);
4135 vam->result_ready = 1;
4139 vl_api_classify_table_ids_reply_t_handler_json
4140 (vl_api_classify_table_ids_reply_t * mp)
4142 vat_main_t *vam = &vat_main;
4143 int i, count = ntohl (mp->count);
4147 vat_json_node_t node;
4149 vat_json_init_object (&node);
4150 for (i = 0; i < count; i++)
4152 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4154 vat_json_print (vam->ofp, &node);
4155 vat_json_free (&node);
4157 vam->retval = ntohl (mp->retval);
4158 vam->result_ready = 1;
4162 vl_api_classify_table_by_interface_reply_t_handler
4163 (vl_api_classify_table_by_interface_reply_t * mp)
4165 vat_main_t *vam = &vat_main;
4168 table_id = ntohl (mp->l2_table_id);
4170 print (vam->ofp, "l2 table id : %d", table_id);
4172 print (vam->ofp, "l2 table id : No input ACL tables configured");
4173 table_id = ntohl (mp->ip4_table_id);
4175 print (vam->ofp, "ip4 table id : %d", table_id);
4177 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4178 table_id = ntohl (mp->ip6_table_id);
4180 print (vam->ofp, "ip6 table id : %d", table_id);
4182 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4183 vam->retval = ntohl (mp->retval);
4184 vam->result_ready = 1;
4188 vl_api_classify_table_by_interface_reply_t_handler_json
4189 (vl_api_classify_table_by_interface_reply_t * mp)
4191 vat_main_t *vam = &vat_main;
4192 vat_json_node_t node;
4194 vat_json_init_object (&node);
4196 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4197 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4198 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4200 vat_json_print (vam->ofp, &node);
4201 vat_json_free (&node);
4203 vam->retval = ntohl (mp->retval);
4204 vam->result_ready = 1;
4207 static void vl_api_policer_add_del_reply_t_handler
4208 (vl_api_policer_add_del_reply_t * mp)
4210 vat_main_t *vam = &vat_main;
4211 i32 retval = ntohl (mp->retval);
4212 if (vam->async_mode)
4214 vam->async_errors += (retval < 0);
4218 vam->retval = retval;
4219 vam->result_ready = 1;
4220 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4222 * Note: this is just barely thread-safe, depends on
4223 * the main thread spinning waiting for an answer...
4225 errmsg ("policer index %d", ntohl (mp->policer_index));
4229 static void vl_api_policer_add_del_reply_t_handler_json
4230 (vl_api_policer_add_del_reply_t * mp)
4232 vat_main_t *vam = &vat_main;
4233 vat_json_node_t node;
4235 vat_json_init_object (&node);
4236 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4237 vat_json_object_add_uint (&node, "policer_index",
4238 ntohl (mp->policer_index));
4240 vat_json_print (vam->ofp, &node);
4241 vat_json_free (&node);
4243 vam->retval = ntohl (mp->retval);
4244 vam->result_ready = 1;
4247 /* Format hex dump. */
4249 format_hex_bytes (u8 * s, va_list * va)
4251 u8 *bytes = va_arg (*va, u8 *);
4252 int n_bytes = va_arg (*va, int);
4255 /* Print short or long form depending on byte count. */
4256 uword short_form = n_bytes <= 32;
4257 uword indent = format_get_indent (s);
4262 for (i = 0; i < n_bytes; i++)
4264 if (!short_form && (i % 32) == 0)
4265 s = format (s, "%08x: ", i);
4266 s = format (s, "%02x", bytes[i]);
4267 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4268 s = format (s, "\n%U", format_white_space, indent);
4275 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4278 vat_main_t *vam = &vat_main;
4279 i32 retval = ntohl (mp->retval);
4282 print (vam->ofp, "classify table info :");
4283 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4284 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4285 ntohl (mp->miss_next_index));
4286 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4287 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4288 ntohl (mp->match_n_vectors));
4289 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4290 ntohl (mp->mask_length));
4292 vam->retval = retval;
4293 vam->result_ready = 1;
4297 vl_api_classify_table_info_reply_t_handler_json
4298 (vl_api_classify_table_info_reply_t * mp)
4300 vat_main_t *vam = &vat_main;
4301 vat_json_node_t node;
4303 i32 retval = ntohl (mp->retval);
4306 vat_json_init_object (&node);
4308 vat_json_object_add_int (&node, "sessions",
4309 ntohl (mp->active_sessions));
4310 vat_json_object_add_int (&node, "nexttbl",
4311 ntohl (mp->next_table_index));
4312 vat_json_object_add_int (&node, "nextnode",
4313 ntohl (mp->miss_next_index));
4314 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4315 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4316 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4317 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4318 ntohl (mp->mask_length), 0);
4319 vat_json_object_add_string_copy (&node, "mask", s);
4321 vat_json_print (vam->ofp, &node);
4322 vat_json_free (&node);
4324 vam->retval = ntohl (mp->retval);
4325 vam->result_ready = 1;
4329 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4332 vat_main_t *vam = &vat_main;
4334 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4335 ntohl (mp->hit_next_index), ntohl (mp->advance),
4336 ntohl (mp->opaque_index));
4337 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4338 ntohl (mp->match_length));
4342 vl_api_classify_session_details_t_handler_json
4343 (vl_api_classify_session_details_t * mp)
4345 vat_main_t *vam = &vat_main;
4346 vat_json_node_t *node = NULL;
4348 if (VAT_JSON_ARRAY != vam->json_tree.type)
4350 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4351 vat_json_init_array (&vam->json_tree);
4353 node = vat_json_array_add (&vam->json_tree);
4355 vat_json_init_object (node);
4356 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4357 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4358 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4360 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4362 vat_json_object_add_string_copy (node, "match", s);
4365 static void vl_api_pg_create_interface_reply_t_handler
4366 (vl_api_pg_create_interface_reply_t * mp)
4368 vat_main_t *vam = &vat_main;
4370 vam->retval = ntohl (mp->retval);
4371 vam->result_ready = 1;
4374 static void vl_api_pg_create_interface_reply_t_handler_json
4375 (vl_api_pg_create_interface_reply_t * mp)
4377 vat_main_t *vam = &vat_main;
4378 vat_json_node_t node;
4380 i32 retval = ntohl (mp->retval);
4383 vat_json_init_object (&node);
4385 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4387 vat_json_print (vam->ofp, &node);
4388 vat_json_free (&node);
4390 vam->retval = ntohl (mp->retval);
4391 vam->result_ready = 1;
4394 static void vl_api_policer_classify_details_t_handler
4395 (vl_api_policer_classify_details_t * mp)
4397 vat_main_t *vam = &vat_main;
4399 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4400 ntohl (mp->table_index));
4403 static void vl_api_policer_classify_details_t_handler_json
4404 (vl_api_policer_classify_details_t * mp)
4406 vat_main_t *vam = &vat_main;
4407 vat_json_node_t *node;
4409 if (VAT_JSON_ARRAY != vam->json_tree.type)
4411 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4412 vat_json_init_array (&vam->json_tree);
4414 node = vat_json_array_add (&vam->json_tree);
4416 vat_json_init_object (node);
4417 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4418 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4421 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4422 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4424 vat_main_t *vam = &vat_main;
4425 i32 retval = ntohl (mp->retval);
4426 if (vam->async_mode)
4428 vam->async_errors += (retval < 0);
4432 vam->retval = retval;
4433 vam->sw_if_index = ntohl (mp->sw_if_index);
4434 vam->result_ready = 1;
4438 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4439 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4441 vat_main_t *vam = &vat_main;
4442 vat_json_node_t node;
4444 vat_json_init_object (&node);
4445 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4446 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4448 vat_json_print (vam->ofp, &node);
4449 vat_json_free (&node);
4451 vam->retval = ntohl (mp->retval);
4452 vam->result_ready = 1;
4455 static void vl_api_flow_classify_details_t_handler
4456 (vl_api_flow_classify_details_t * mp)
4458 vat_main_t *vam = &vat_main;
4460 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4461 ntohl (mp->table_index));
4464 static void vl_api_flow_classify_details_t_handler_json
4465 (vl_api_flow_classify_details_t * mp)
4467 vat_main_t *vam = &vat_main;
4468 vat_json_node_t *node;
4470 if (VAT_JSON_ARRAY != vam->json_tree.type)
4472 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4473 vat_json_init_array (&vam->json_tree);
4475 node = vat_json_array_add (&vam->json_tree);
4477 vat_json_init_object (node);
4478 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4479 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4482 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
4483 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
4484 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
4485 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
4486 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4487 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4488 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4489 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4490 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4491 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4492 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4493 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4494 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4495 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4496 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
4497 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
4498 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
4499 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
4502 * Generate boilerplate reply handlers, which
4503 * dig the return value out of the xxx_reply_t API message,
4504 * stick it into vam->retval, and set vam->result_ready
4506 * Could also do this by pointing N message decode slots at
4507 * a single function, but that could break in subtle ways.
4510 #define foreach_standard_reply_retval_handler \
4511 _(sw_interface_set_flags_reply) \
4512 _(sw_interface_add_del_address_reply) \
4513 _(sw_interface_set_table_reply) \
4514 _(sw_interface_set_mpls_enable_reply) \
4515 _(sw_interface_set_vpath_reply) \
4516 _(sw_interface_set_vxlan_bypass_reply) \
4517 _(sw_interface_set_vxlan_gpe_bypass_reply) \
4518 _(sw_interface_set_l2_bridge_reply) \
4519 _(bridge_domain_add_del_reply) \
4520 _(sw_interface_set_l2_xconnect_reply) \
4521 _(l2fib_add_del_reply) \
4522 _(l2fib_flush_int_reply) \
4523 _(l2fib_flush_bd_reply) \
4524 _(ip_add_del_route_reply) \
4525 _(ip_mroute_add_del_reply) \
4526 _(mpls_route_add_del_reply) \
4527 _(mpls_ip_bind_unbind_reply) \
4528 _(proxy_arp_add_del_reply) \
4529 _(proxy_arp_intfc_enable_disable_reply) \
4530 _(sw_interface_set_unnumbered_reply) \
4531 _(ip_neighbor_add_del_reply) \
4532 _(reset_vrf_reply) \
4533 _(oam_add_del_reply) \
4534 _(reset_fib_reply) \
4535 _(dhcp_proxy_config_reply) \
4536 _(dhcp_proxy_set_vss_reply) \
4537 _(dhcp_client_config_reply) \
4538 _(set_ip_flow_hash_reply) \
4539 _(sw_interface_ip6_enable_disable_reply) \
4540 _(sw_interface_ip6_set_link_local_address_reply) \
4541 _(ip6nd_proxy_add_del_reply) \
4542 _(sw_interface_ip6nd_ra_prefix_reply) \
4543 _(sw_interface_ip6nd_ra_config_reply) \
4544 _(set_arp_neighbor_limit_reply) \
4545 _(l2_patch_add_del_reply) \
4546 _(sr_policy_add_reply) \
4547 _(sr_policy_mod_reply) \
4548 _(sr_policy_del_reply) \
4549 _(sr_localsid_add_del_reply) \
4550 _(sr_steering_add_del_reply) \
4551 _(classify_add_del_session_reply) \
4552 _(classify_set_interface_ip_table_reply) \
4553 _(classify_set_interface_l2_tables_reply) \
4554 _(l2tpv3_set_tunnel_cookies_reply) \
4555 _(l2tpv3_interface_enable_disable_reply) \
4556 _(l2tpv3_set_lookup_key_reply) \
4557 _(l2_fib_clear_table_reply) \
4558 _(l2_interface_efp_filter_reply) \
4559 _(l2_interface_vlan_tag_rewrite_reply) \
4560 _(modify_vhost_user_if_reply) \
4561 _(delete_vhost_user_if_reply) \
4562 _(want_ip4_arp_events_reply) \
4563 _(want_ip6_nd_events_reply) \
4564 _(input_acl_set_interface_reply) \
4565 _(ipsec_spd_add_del_reply) \
4566 _(ipsec_interface_add_del_spd_reply) \
4567 _(ipsec_spd_add_del_entry_reply) \
4568 _(ipsec_sad_add_del_entry_reply) \
4569 _(ipsec_sa_set_key_reply) \
4570 _(ipsec_tunnel_if_add_del_reply) \
4571 _(ikev2_profile_add_del_reply) \
4572 _(ikev2_profile_set_auth_reply) \
4573 _(ikev2_profile_set_id_reply) \
4574 _(ikev2_profile_set_ts_reply) \
4575 _(ikev2_set_local_key_reply) \
4576 _(ikev2_set_responder_reply) \
4577 _(ikev2_set_ike_transforms_reply) \
4578 _(ikev2_set_esp_transforms_reply) \
4579 _(ikev2_set_sa_lifetime_reply) \
4580 _(ikev2_initiate_sa_init_reply) \
4581 _(ikev2_initiate_del_ike_sa_reply) \
4582 _(ikev2_initiate_del_child_sa_reply) \
4583 _(ikev2_initiate_rekey_child_sa_reply) \
4584 _(delete_loopback_reply) \
4585 _(bd_ip_mac_add_del_reply) \
4586 _(map_del_domain_reply) \
4587 _(map_add_del_rule_reply) \
4588 _(want_interface_events_reply) \
4589 _(want_stats_reply) \
4590 _(cop_interface_enable_disable_reply) \
4591 _(cop_whitelist_enable_disable_reply) \
4592 _(sw_interface_clear_stats_reply) \
4593 _(ioam_enable_reply) \
4594 _(ioam_disable_reply) \
4595 _(one_add_del_locator_reply) \
4596 _(one_add_del_local_eid_reply) \
4597 _(one_add_del_remote_mapping_reply) \
4598 _(one_add_del_adjacency_reply) \
4599 _(one_add_del_map_resolver_reply) \
4600 _(one_add_del_map_server_reply) \
4601 _(one_enable_disable_reply) \
4602 _(one_rloc_probe_enable_disable_reply) \
4603 _(one_map_register_enable_disable_reply) \
4604 _(one_pitr_set_locator_set_reply) \
4605 _(one_map_request_mode_reply) \
4606 _(one_add_del_map_request_itr_rlocs_reply) \
4607 _(one_eid_table_add_del_map_reply) \
4608 _(one_use_petr_reply) \
4609 _(one_stats_enable_disable_reply) \
4610 _(one_add_del_l2_arp_entry_reply) \
4611 _(one_stats_flush_reply) \
4612 _(gpe_enable_disable_reply) \
4613 _(gpe_set_encap_mode_reply) \
4614 _(gpe_add_del_iface_reply) \
4615 _(gpe_add_del_native_fwd_rpath_reply) \
4616 _(af_packet_delete_reply) \
4617 _(policer_classify_set_interface_reply) \
4618 _(netmap_create_reply) \
4619 _(netmap_delete_reply) \
4620 _(set_ipfix_exporter_reply) \
4621 _(set_ipfix_classify_stream_reply) \
4622 _(ipfix_classify_table_add_del_reply) \
4623 _(flow_classify_set_interface_reply) \
4624 _(sw_interface_span_enable_disable_reply) \
4625 _(pg_capture_reply) \
4626 _(pg_enable_disable_reply) \
4627 _(ip_source_and_port_range_check_add_del_reply) \
4628 _(ip_source_and_port_range_check_interface_add_del_reply)\
4629 _(delete_subif_reply) \
4630 _(l2_interface_pbb_tag_rewrite_reply) \
4632 _(feature_enable_disable_reply) \
4633 _(sw_interface_tag_add_del_reply) \
4634 _(sw_interface_set_mtu_reply) \
4635 _(p2p_ethernet_add_reply) \
4636 _(p2p_ethernet_del_reply)
4639 static void vl_api_##n##_t_handler \
4640 (vl_api_##n##_t * mp) \
4642 vat_main_t * vam = &vat_main; \
4643 i32 retval = ntohl(mp->retval); \
4644 if (vam->async_mode) { \
4645 vam->async_errors += (retval < 0); \
4647 vam->retval = retval; \
4648 vam->result_ready = 1; \
4651 foreach_standard_reply_retval_handler;
4655 static void vl_api_##n##_t_handler_json \
4656 (vl_api_##n##_t * mp) \
4658 vat_main_t * vam = &vat_main; \
4659 vat_json_node_t node; \
4660 vat_json_init_object(&node); \
4661 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4662 vat_json_print(vam->ofp, &node); \
4663 vam->retval = ntohl(mp->retval); \
4664 vam->result_ready = 1; \
4666 foreach_standard_reply_retval_handler;
4670 * Table of message reply handlers, must include boilerplate handlers
4674 #define foreach_vpe_api_reply_msg \
4675 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4676 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4677 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4678 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4679 _(CONTROL_PING_REPLY, control_ping_reply) \
4680 _(CLI_REPLY, cli_reply) \
4681 _(CLI_INBAND_REPLY, cli_inband_reply) \
4682 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4683 sw_interface_add_del_address_reply) \
4684 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4685 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4686 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4687 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4688 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
4689 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4690 sw_interface_set_l2_xconnect_reply) \
4691 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4692 sw_interface_set_l2_bridge_reply) \
4693 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4694 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4695 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
4696 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4697 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
4698 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
4699 _(L2_FLAGS_REPLY, l2_flags_reply) \
4700 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4701 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4702 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4703 _(TAP_DELETE_REPLY, tap_delete_reply) \
4704 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4705 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4706 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4707 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4708 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4709 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4710 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4711 proxy_arp_intfc_enable_disable_reply) \
4712 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4713 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4714 sw_interface_set_unnumbered_reply) \
4715 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4716 _(RESET_VRF_REPLY, reset_vrf_reply) \
4717 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4718 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4719 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4720 _(RESET_FIB_REPLY, reset_fib_reply) \
4721 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4722 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4723 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4724 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4725 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4726 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4727 sw_interface_ip6_enable_disable_reply) \
4728 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4729 sw_interface_ip6_set_link_local_address_reply) \
4730 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
4731 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
4732 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4733 sw_interface_ip6nd_ra_prefix_reply) \
4734 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4735 sw_interface_ip6nd_ra_config_reply) \
4736 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4737 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4738 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4739 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4740 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4741 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4742 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4743 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4744 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4745 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4746 classify_set_interface_ip_table_reply) \
4747 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4748 classify_set_interface_l2_tables_reply) \
4749 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4750 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4751 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4752 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4753 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4754 l2tpv3_interface_enable_disable_reply) \
4755 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4756 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4757 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4758 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4759 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4760 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4761 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4762 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4763 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4764 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4765 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4766 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4767 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4768 _(SHOW_VERSION_REPLY, show_version_reply) \
4769 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
4770 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4771 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4772 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4773 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4774 _(IP4_ARP_EVENT, ip4_arp_event) \
4775 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4776 _(IP6_ND_EVENT, ip6_nd_event) \
4777 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4778 _(IP_ADDRESS_DETAILS, ip_address_details) \
4779 _(IP_DETAILS, ip_details) \
4780 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4781 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4782 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4783 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4784 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4785 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
4786 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4787 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4788 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4789 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4790 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4791 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4792 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4793 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4794 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4795 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4796 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4797 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4798 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4799 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4800 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4801 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4802 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4803 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4804 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4805 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4806 _(MAP_RULE_DETAILS, map_rule_details) \
4807 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4808 _(WANT_STATS_REPLY, want_stats_reply) \
4809 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4810 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4811 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4812 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4813 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4814 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4815 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4816 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4817 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4818 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4819 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4820 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4821 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4822 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4823 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4824 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4825 one_map_register_enable_disable_reply) \
4826 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4827 one_rloc_probe_enable_disable_reply) \
4828 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4829 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
4830 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4831 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4832 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4833 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4834 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4835 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4836 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4837 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4838 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4839 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4840 _(ONE_STATS_DETAILS, one_stats_details) \
4841 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
4842 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
4843 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
4844 show_one_stats_enable_disable_reply) \
4845 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
4846 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
4847 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
4848 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4849 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4850 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4851 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4852 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4853 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
4854 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4855 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
4856 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
4857 gpe_add_del_native_fwd_rpath_reply) \
4858 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4859 gpe_fwd_entry_path_details) \
4860 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4861 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4862 one_add_del_map_request_itr_rlocs_reply) \
4863 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4864 one_get_map_request_itr_rlocs_reply) \
4865 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
4866 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4867 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
4868 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4869 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4870 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4871 show_one_map_register_state_reply) \
4872 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4873 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4874 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4875 _(POLICER_DETAILS, policer_details) \
4876 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4877 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4878 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4879 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4880 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4881 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4882 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4883 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4884 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4885 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4886 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4887 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4888 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4889 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4890 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4891 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4892 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4893 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4894 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4895 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4896 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4897 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4898 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4899 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4900 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4901 ip_source_and_port_range_check_add_del_reply) \
4902 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4903 ip_source_and_port_range_check_interface_add_del_reply) \
4904 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4905 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4906 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4907 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4908 _(PUNT_REPLY, punt_reply) \
4909 _(IP_FIB_DETAILS, ip_fib_details) \
4910 _(IP6_FIB_DETAILS, ip6_fib_details) \
4911 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4912 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4913 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4914 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4915 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4916 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
4917 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
4918 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply)
4920 #define foreach_standalone_reply_msg \
4921 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4922 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
4923 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
4924 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4925 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4926 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4927 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
4936 #define STR_VTR_OP_CASE(op) \
4937 case L2_VTR_ ## op: \
4941 str_vtr_op (u32 vtr_op)
4945 STR_VTR_OP_CASE (DISABLED);
4946 STR_VTR_OP_CASE (PUSH_1);
4947 STR_VTR_OP_CASE (PUSH_2);
4948 STR_VTR_OP_CASE (POP_1);
4949 STR_VTR_OP_CASE (POP_2);
4950 STR_VTR_OP_CASE (TRANSLATE_1_1);
4951 STR_VTR_OP_CASE (TRANSLATE_1_2);
4952 STR_VTR_OP_CASE (TRANSLATE_2_1);
4953 STR_VTR_OP_CASE (TRANSLATE_2_2);
4960 dump_sub_interface_table (vat_main_t * vam)
4962 const sw_interface_subif_t *sub = NULL;
4964 if (vam->json_output)
4967 ("JSON output supported only for VPE API calls and dump_stats_table");
4972 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4973 "Interface", "sw_if_index",
4974 "sub id", "dot1ad", "tags", "outer id",
4975 "inner id", "exact", "default", "outer any", "inner any");
4977 vec_foreach (sub, vam->sw_if_subif_table)
4980 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4981 sub->interface_name,
4983 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4984 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4985 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4986 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4987 if (sub->vtr_op != L2_VTR_DISABLED)
4990 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4991 "tag1: %d tag2: %d ]",
4992 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4993 sub->vtr_tag1, sub->vtr_tag2);
5001 name_sort_cmp (void *a1, void *a2)
5003 name_sort_t *n1 = a1;
5004 name_sort_t *n2 = a2;
5006 return strcmp ((char *) n1->name, (char *) n2->name);
5010 dump_interface_table (vat_main_t * vam)
5013 name_sort_t *nses = 0, *ns;
5015 if (vam->json_output)
5018 ("JSON output supported only for VPE API calls and dump_stats_table");
5023 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5025 vec_add2 (nses, ns, 1);
5026 ns->name = (u8 *)(p->key);
5027 ns->value = (u32) p->value[0];
5031 vec_sort_with_function (nses, name_sort_cmp);
5033 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5034 vec_foreach (ns, nses)
5036 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5043 dump_ip_table (vat_main_t * vam, int is_ipv6)
5045 const ip_details_t *det = NULL;
5046 const ip_address_details_t *address = NULL;
5049 print (vam->ofp, "%-12s", "sw_if_index");
5051 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5058 print (vam->ofp, "%-12d", i);
5059 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5064 vec_foreach (address, det->addr)
5068 is_ipv6 ? format_ip6_address : format_ip4_address,
5069 address->ip, address->prefix_length);
5077 dump_ipv4_table (vat_main_t * vam)
5079 if (vam->json_output)
5082 ("JSON output supported only for VPE API calls and dump_stats_table");
5086 return dump_ip_table (vam, 0);
5090 dump_ipv6_table (vat_main_t * vam)
5092 if (vam->json_output)
5095 ("JSON output supported only for VPE API calls and dump_stats_table");
5099 return dump_ip_table (vam, 1);
5103 counter_type_to_str (u8 counter_type, u8 is_combined)
5107 switch (counter_type)
5109 case VNET_INTERFACE_COUNTER_DROP:
5111 case VNET_INTERFACE_COUNTER_PUNT:
5113 case VNET_INTERFACE_COUNTER_IP4:
5115 case VNET_INTERFACE_COUNTER_IP6:
5117 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5119 case VNET_INTERFACE_COUNTER_RX_MISS:
5121 case VNET_INTERFACE_COUNTER_RX_ERROR:
5123 case VNET_INTERFACE_COUNTER_TX_ERROR:
5126 return "INVALID-COUNTER-TYPE";
5131 switch (counter_type)
5133 case VNET_INTERFACE_COUNTER_RX:
5135 case VNET_INTERFACE_COUNTER_TX:
5138 return "INVALID-COUNTER-TYPE";
5144 dump_stats_table (vat_main_t * vam)
5146 vat_json_node_t node;
5147 vat_json_node_t *msg_array;
5148 vat_json_node_t *msg;
5149 vat_json_node_t *counter_array;
5150 vat_json_node_t *counter;
5151 interface_counter_t c;
5153 ip4_fib_counter_t *c4;
5154 ip6_fib_counter_t *c6;
5155 ip4_nbr_counter_t *n4;
5156 ip6_nbr_counter_t *n6;
5159 if (!vam->json_output)
5161 clib_warning ("dump_stats_table supported only in JSON format");
5165 vat_json_init_object (&node);
5167 /* interface counters */
5168 msg_array = vat_json_object_add (&node, "interface_counters");
5169 vat_json_init_array (msg_array);
5170 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5172 msg = vat_json_array_add (msg_array);
5173 vat_json_init_object (msg);
5174 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5175 (u8 *) counter_type_to_str (i, 0));
5176 vat_json_object_add_int (msg, "is_combined", 0);
5177 counter_array = vat_json_object_add (msg, "data");
5178 vat_json_init_array (counter_array);
5179 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5181 packets = vam->simple_interface_counters[i][j];
5182 vat_json_array_add_uint (counter_array, packets);
5185 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5187 msg = vat_json_array_add (msg_array);
5188 vat_json_init_object (msg);
5189 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5190 (u8 *) counter_type_to_str (i, 1));
5191 vat_json_object_add_int (msg, "is_combined", 1);
5192 counter_array = vat_json_object_add (msg, "data");
5193 vat_json_init_array (counter_array);
5194 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5196 c = vam->combined_interface_counters[i][j];
5197 counter = vat_json_array_add (counter_array);
5198 vat_json_init_object (counter);
5199 vat_json_object_add_uint (counter, "packets", c.packets);
5200 vat_json_object_add_uint (counter, "bytes", c.bytes);
5204 /* ip4 fib counters */
5205 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5206 vat_json_init_array (msg_array);
5207 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5209 msg = vat_json_array_add (msg_array);
5210 vat_json_init_object (msg);
5211 vat_json_object_add_uint (msg, "vrf_id",
5212 vam->ip4_fib_counters_vrf_id_by_index[i]);
5213 counter_array = vat_json_object_add (msg, "c");
5214 vat_json_init_array (counter_array);
5215 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5217 counter = vat_json_array_add (counter_array);
5218 vat_json_init_object (counter);
5219 c4 = &vam->ip4_fib_counters[i][j];
5220 vat_json_object_add_ip4 (counter, "address", c4->address);
5221 vat_json_object_add_uint (counter, "address_length",
5222 c4->address_length);
5223 vat_json_object_add_uint (counter, "packets", c4->packets);
5224 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5228 /* ip6 fib counters */
5229 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5230 vat_json_init_array (msg_array);
5231 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5233 msg = vat_json_array_add (msg_array);
5234 vat_json_init_object (msg);
5235 vat_json_object_add_uint (msg, "vrf_id",
5236 vam->ip6_fib_counters_vrf_id_by_index[i]);
5237 counter_array = vat_json_object_add (msg, "c");
5238 vat_json_init_array (counter_array);
5239 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5241 counter = vat_json_array_add (counter_array);
5242 vat_json_init_object (counter);
5243 c6 = &vam->ip6_fib_counters[i][j];
5244 vat_json_object_add_ip6 (counter, "address", c6->address);
5245 vat_json_object_add_uint (counter, "address_length",
5246 c6->address_length);
5247 vat_json_object_add_uint (counter, "packets", c6->packets);
5248 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5252 /* ip4 nbr counters */
5253 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5254 vat_json_init_array (msg_array);
5255 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5257 msg = vat_json_array_add (msg_array);
5258 vat_json_init_object (msg);
5259 vat_json_object_add_uint (msg, "sw_if_index", i);
5260 counter_array = vat_json_object_add (msg, "c");
5261 vat_json_init_array (counter_array);
5262 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5264 counter = vat_json_array_add (counter_array);
5265 vat_json_init_object (counter);
5266 n4 = &vam->ip4_nbr_counters[i][j];
5267 vat_json_object_add_ip4 (counter, "address", n4->address);
5268 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5269 vat_json_object_add_uint (counter, "packets", n4->packets);
5270 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5274 /* ip6 nbr counters */
5275 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5276 vat_json_init_array (msg_array);
5277 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5279 msg = vat_json_array_add (msg_array);
5280 vat_json_init_object (msg);
5281 vat_json_object_add_uint (msg, "sw_if_index", i);
5282 counter_array = vat_json_object_add (msg, "c");
5283 vat_json_init_array (counter_array);
5284 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5286 counter = vat_json_array_add (counter_array);
5287 vat_json_init_object (counter);
5288 n6 = &vam->ip6_nbr_counters[i][j];
5289 vat_json_object_add_ip6 (counter, "address", n6->address);
5290 vat_json_object_add_uint (counter, "packets", n6->packets);
5291 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5295 vat_json_print (vam->ofp, &node);
5296 vat_json_free (&node);
5302 exec (vat_main_t * vam)
5304 api_main_t *am = &api_main;
5309 unformat_input_t *i = vam->input;
5311 if (vec_len (i->buffer) == 0)
5314 if (vam->exec_mode == 0 && unformat (i, "mode"))
5319 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5329 * Copy cmd into shared memory.
5330 * In order for the CLI command to work, it
5331 * must be a vector ending in \n, not a C-string ending
5334 pthread_mutex_lock (&am->vlib_rp->mutex);
5335 oldheap = svm_push_data_heap (am->vlib_rp);
5337 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
5338 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
5340 svm_pop_heap (oldheap);
5341 pthread_mutex_unlock (&am->vlib_rp->mutex);
5343 mp->cmd_in_shmem = pointer_to_uword (cmd);
5345 timeout = vat_time_now (vam) + 10.0;
5347 while (vat_time_now (vam) < timeout)
5349 if (vam->result_ready == 1)
5352 if (vam->shmem_result != NULL)
5353 print (vam->ofp, "%s", vam->shmem_result);
5354 pthread_mutex_lock (&am->vlib_rp->mutex);
5355 oldheap = svm_push_data_heap (am->vlib_rp);
5357 free_me = (u8 *) vam->shmem_result;
5360 svm_pop_heap (oldheap);
5361 pthread_mutex_unlock (&am->vlib_rp->mutex);
5369 * Future replacement of exec() that passes CLI buffers directly in
5370 * the API messages instead of an additional shared memory area.
5373 exec_inband (vat_main_t * vam)
5375 vl_api_cli_inband_t *mp;
5376 unformat_input_t *i = vam->input;
5379 if (vec_len (i->buffer) == 0)
5382 if (vam->exec_mode == 0 && unformat (i, "mode"))
5387 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5394 * In order for the CLI command to work, it
5395 * must be a vector ending in \n, not a C-string ending
5398 u32 len = vec_len (vam->input->buffer);
5399 M2 (CLI_INBAND, mp, len);
5400 clib_memcpy (mp->cmd, vam->input->buffer, len);
5401 mp->length = htonl (len);
5404 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
5409 api_create_loopback (vat_main_t * vam)
5411 unformat_input_t *i = vam->input;
5412 vl_api_create_loopback_t *mp;
5413 vl_api_create_loopback_instance_t *mp_lbi;
5416 u8 is_specified = 0;
5417 u32 user_instance = 0;
5420 memset (mac_address, 0, sizeof (mac_address));
5422 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5424 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5426 if (unformat (i, "instance %d", &user_instance))
5434 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5435 mp_lbi->is_specified = is_specified;
5437 mp_lbi->user_instance = htonl (user_instance);
5439 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5444 /* Construct the API message */
5445 M (CREATE_LOOPBACK, mp);
5447 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5456 api_delete_loopback (vat_main_t * vam)
5458 unformat_input_t *i = vam->input;
5459 vl_api_delete_loopback_t *mp;
5460 u32 sw_if_index = ~0;
5463 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5465 if (unformat (i, "sw_if_index %d", &sw_if_index))
5471 if (sw_if_index == ~0)
5473 errmsg ("missing sw_if_index");
5477 /* Construct the API message */
5478 M (DELETE_LOOPBACK, mp);
5479 mp->sw_if_index = ntohl (sw_if_index);
5487 api_want_stats (vat_main_t * vam)
5489 unformat_input_t *i = vam->input;
5490 vl_api_want_stats_t *mp;
5494 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5496 if (unformat (i, "enable"))
5498 else if (unformat (i, "disable"))
5506 errmsg ("missing enable|disable");
5511 mp->enable_disable = enable;
5519 api_want_interface_events (vat_main_t * vam)
5521 unformat_input_t *i = vam->input;
5522 vl_api_want_interface_events_t *mp;
5526 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5528 if (unformat (i, "enable"))
5530 else if (unformat (i, "disable"))
5538 errmsg ("missing enable|disable");
5542 M (WANT_INTERFACE_EVENTS, mp);
5543 mp->enable_disable = enable;
5545 vam->interface_event_display = enable;
5553 /* Note: non-static, called once to set up the initial intfc table */
5555 api_sw_interface_dump (vat_main_t * vam)
5557 vl_api_sw_interface_dump_t *mp;
5558 vl_api_control_ping_t *mp_ping;
5560 name_sort_t *nses = 0, *ns;
5561 sw_interface_subif_t *sub = NULL;
5564 /* Toss the old name table */
5566 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5568 vec_add2 (nses, ns, 1);
5569 ns->name = (u8 *)(p->key);
5570 ns->value = (u32) p->value[0];
5574 hash_free (vam->sw_if_index_by_interface_name);
5576 vec_foreach (ns, nses) vec_free (ns->name);
5580 vec_foreach (sub, vam->sw_if_subif_table)
5582 vec_free (sub->interface_name);
5584 vec_free (vam->sw_if_subif_table);
5586 /* recreate the interface name hash table */
5587 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5589 /* Get list of ethernets */
5590 M (SW_INTERFACE_DUMP, mp);
5591 mp->name_filter_valid = 1;
5592 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
5595 /* and local / loopback interfaces */
5596 M (SW_INTERFACE_DUMP, mp);
5597 mp->name_filter_valid = 1;
5598 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
5601 /* and packet-generator interfaces */
5602 M (SW_INTERFACE_DUMP, mp);
5603 mp->name_filter_valid = 1;
5604 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
5607 /* and vxlan-gpe tunnel interfaces */
5608 M (SW_INTERFACE_DUMP, mp);
5609 mp->name_filter_valid = 1;
5610 strncpy ((char *) mp->name_filter, "vxlan_gpe",
5611 sizeof (mp->name_filter) - 1);
5614 /* and vxlan tunnel interfaces */
5615 M (SW_INTERFACE_DUMP, mp);
5616 mp->name_filter_valid = 1;
5617 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
5620 /* and host (af_packet) interfaces */
5621 M (SW_INTERFACE_DUMP, mp);
5622 mp->name_filter_valid = 1;
5623 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
5626 /* and l2tpv3 tunnel interfaces */
5627 M (SW_INTERFACE_DUMP, mp);
5628 mp->name_filter_valid = 1;
5629 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
5630 sizeof (mp->name_filter) - 1);
5633 /* and GRE tunnel interfaces */
5634 M (SW_INTERFACE_DUMP, mp);
5635 mp->name_filter_valid = 1;
5636 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
5639 /* and LISP-GPE interfaces */
5640 M (SW_INTERFACE_DUMP, mp);
5641 mp->name_filter_valid = 1;
5642 strncpy ((char *) mp->name_filter, "lisp_gpe",
5643 sizeof (mp->name_filter) - 1);
5646 /* and IPSEC tunnel interfaces */
5647 M (SW_INTERFACE_DUMP, mp);
5648 mp->name_filter_valid = 1;
5649 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
5652 /* Use a control ping for synchronization */
5653 M (CONTROL_PING, mp_ping);
5661 api_sw_interface_set_flags (vat_main_t * vam)
5663 unformat_input_t *i = vam->input;
5664 vl_api_sw_interface_set_flags_t *mp;
5666 u8 sw_if_index_set = 0;
5667 u8 admin_up = 0, link_up = 0;
5670 /* Parse args required to build the message */
5671 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5673 if (unformat (i, "admin-up"))
5675 else if (unformat (i, "admin-down"))
5677 else if (unformat (i, "link-up"))
5679 else if (unformat (i, "link-down"))
5682 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5683 sw_if_index_set = 1;
5684 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5685 sw_if_index_set = 1;
5690 if (sw_if_index_set == 0)
5692 errmsg ("missing interface name or sw_if_index");
5696 /* Construct the API message */
5697 M (SW_INTERFACE_SET_FLAGS, mp);
5698 mp->sw_if_index = ntohl (sw_if_index);
5699 mp->admin_up_down = admin_up;
5700 mp->link_up_down = link_up;
5705 /* Wait for a reply, return the good/bad news... */
5711 api_sw_interface_clear_stats (vat_main_t * vam)
5713 unformat_input_t *i = vam->input;
5714 vl_api_sw_interface_clear_stats_t *mp;
5716 u8 sw_if_index_set = 0;
5719 /* Parse args required to build the message */
5720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5722 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5723 sw_if_index_set = 1;
5724 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5725 sw_if_index_set = 1;
5730 /* Construct the API message */
5731 M (SW_INTERFACE_CLEAR_STATS, mp);
5733 if (sw_if_index_set == 1)
5734 mp->sw_if_index = ntohl (sw_if_index);
5736 mp->sw_if_index = ~0;
5741 /* Wait for a reply, return the good/bad news... */
5747 api_sw_interface_add_del_address (vat_main_t * vam)
5749 unformat_input_t *i = vam->input;
5750 vl_api_sw_interface_add_del_address_t *mp;
5752 u8 sw_if_index_set = 0;
5753 u8 is_add = 1, del_all = 0;
5754 u32 address_length = 0;
5755 u8 v4_address_set = 0;
5756 u8 v6_address_set = 0;
5757 ip4_address_t v4address;
5758 ip6_address_t v6address;
5761 /* Parse args required to build the message */
5762 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5764 if (unformat (i, "del-all"))
5766 else if (unformat (i, "del"))
5769 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5770 sw_if_index_set = 1;
5771 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5772 sw_if_index_set = 1;
5773 else if (unformat (i, "%U/%d",
5774 unformat_ip4_address, &v4address, &address_length))
5776 else if (unformat (i, "%U/%d",
5777 unformat_ip6_address, &v6address, &address_length))
5783 if (sw_if_index_set == 0)
5785 errmsg ("missing interface name or sw_if_index");
5788 if (v4_address_set && v6_address_set)
5790 errmsg ("both v4 and v6 addresses set");
5793 if (!v4_address_set && !v6_address_set && !del_all)
5795 errmsg ("no addresses set");
5799 /* Construct the API message */
5800 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5802 mp->sw_if_index = ntohl (sw_if_index);
5803 mp->is_add = is_add;
5804 mp->del_all = del_all;
5808 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5812 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5814 mp->address_length = address_length;
5819 /* Wait for a reply, return good/bad news */
5825 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5827 unformat_input_t *i = vam->input;
5828 vl_api_sw_interface_set_mpls_enable_t *mp;
5830 u8 sw_if_index_set = 0;
5834 /* Parse args required to build the message */
5835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5837 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5838 sw_if_index_set = 1;
5839 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5840 sw_if_index_set = 1;
5841 else if (unformat (i, "disable"))
5843 else if (unformat (i, "dis"))
5849 if (sw_if_index_set == 0)
5851 errmsg ("missing interface name or sw_if_index");
5855 /* Construct the API message */
5856 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5858 mp->sw_if_index = ntohl (sw_if_index);
5859 mp->enable = enable;
5864 /* Wait for a reply... */
5870 api_sw_interface_set_table (vat_main_t * vam)
5872 unformat_input_t *i = vam->input;
5873 vl_api_sw_interface_set_table_t *mp;
5874 u32 sw_if_index, vrf_id = 0;
5875 u8 sw_if_index_set = 0;
5879 /* Parse args required to build the message */
5880 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5882 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5883 sw_if_index_set = 1;
5884 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5885 sw_if_index_set = 1;
5886 else if (unformat (i, "vrf %d", &vrf_id))
5888 else if (unformat (i, "ipv6"))
5894 if (sw_if_index_set == 0)
5896 errmsg ("missing interface name or sw_if_index");
5900 /* Construct the API message */
5901 M (SW_INTERFACE_SET_TABLE, mp);
5903 mp->sw_if_index = ntohl (sw_if_index);
5904 mp->is_ipv6 = is_ipv6;
5905 mp->vrf_id = ntohl (vrf_id);
5910 /* Wait for a reply... */
5915 static void vl_api_sw_interface_get_table_reply_t_handler
5916 (vl_api_sw_interface_get_table_reply_t * mp)
5918 vat_main_t *vam = &vat_main;
5920 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5922 vam->retval = ntohl (mp->retval);
5923 vam->result_ready = 1;
5927 static void vl_api_sw_interface_get_table_reply_t_handler_json
5928 (vl_api_sw_interface_get_table_reply_t * mp)
5930 vat_main_t *vam = &vat_main;
5931 vat_json_node_t node;
5933 vat_json_init_object (&node);
5934 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5935 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5937 vat_json_print (vam->ofp, &node);
5938 vat_json_free (&node);
5940 vam->retval = ntohl (mp->retval);
5941 vam->result_ready = 1;
5945 api_sw_interface_get_table (vat_main_t * vam)
5947 unformat_input_t *i = vam->input;
5948 vl_api_sw_interface_get_table_t *mp;
5950 u8 sw_if_index_set = 0;
5954 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5956 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5957 sw_if_index_set = 1;
5958 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5959 sw_if_index_set = 1;
5960 else if (unformat (i, "ipv6"))
5966 if (sw_if_index_set == 0)
5968 errmsg ("missing interface name or sw_if_index");
5972 M (SW_INTERFACE_GET_TABLE, mp);
5973 mp->sw_if_index = htonl (sw_if_index);
5974 mp->is_ipv6 = is_ipv6;
5982 api_sw_interface_set_vpath (vat_main_t * vam)
5984 unformat_input_t *i = vam->input;
5985 vl_api_sw_interface_set_vpath_t *mp;
5986 u32 sw_if_index = 0;
5987 u8 sw_if_index_set = 0;
5991 /* Parse args required to build the message */
5992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5994 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5995 sw_if_index_set = 1;
5996 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5997 sw_if_index_set = 1;
5998 else if (unformat (i, "enable"))
6000 else if (unformat (i, "disable"))
6006 if (sw_if_index_set == 0)
6008 errmsg ("missing interface name or sw_if_index");
6012 /* Construct the API message */
6013 M (SW_INTERFACE_SET_VPATH, mp);
6015 mp->sw_if_index = ntohl (sw_if_index);
6016 mp->enable = is_enable;
6021 /* Wait for a reply... */
6027 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6029 unformat_input_t *i = vam->input;
6030 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6031 u32 sw_if_index = 0;
6032 u8 sw_if_index_set = 0;
6037 /* Parse args required to build the message */
6038 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6040 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6041 sw_if_index_set = 1;
6042 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6043 sw_if_index_set = 1;
6044 else if (unformat (i, "enable"))
6046 else if (unformat (i, "disable"))
6048 else if (unformat (i, "ip4"))
6050 else if (unformat (i, "ip6"))
6056 if (sw_if_index_set == 0)
6058 errmsg ("missing interface name or sw_if_index");
6062 /* Construct the API message */
6063 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6065 mp->sw_if_index = ntohl (sw_if_index);
6066 mp->enable = is_enable;
6067 mp->is_ipv6 = is_ipv6;
6072 /* Wait for a reply... */
6079 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6081 unformat_input_t *i = vam->input;
6082 vl_api_sw_interface_set_l2_xconnect_t *mp;
6084 u8 rx_sw_if_index_set = 0;
6086 u8 tx_sw_if_index_set = 0;
6090 /* Parse args required to build the message */
6091 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6093 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6094 rx_sw_if_index_set = 1;
6095 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6096 tx_sw_if_index_set = 1;
6097 else if (unformat (i, "rx"))
6099 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6101 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6103 rx_sw_if_index_set = 1;
6108 else if (unformat (i, "tx"))
6110 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6112 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6114 tx_sw_if_index_set = 1;
6119 else if (unformat (i, "enable"))
6121 else if (unformat (i, "disable"))
6127 if (rx_sw_if_index_set == 0)
6129 errmsg ("missing rx interface name or rx_sw_if_index");
6133 if (enable && (tx_sw_if_index_set == 0))
6135 errmsg ("missing tx interface name or tx_sw_if_index");
6139 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6141 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6142 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6143 mp->enable = enable;
6151 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6153 unformat_input_t *i = vam->input;
6154 vl_api_sw_interface_set_l2_bridge_t *mp;
6156 u8 rx_sw_if_index_set = 0;
6164 /* Parse args required to build the message */
6165 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6167 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6168 rx_sw_if_index_set = 1;
6169 else if (unformat (i, "bd_id %d", &bd_id))
6173 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6174 rx_sw_if_index_set = 1;
6175 else if (unformat (i, "shg %d", &shg))
6177 else if (unformat (i, "bvi"))
6179 else if (unformat (i, "enable"))
6181 else if (unformat (i, "disable"))
6187 if (rx_sw_if_index_set == 0)
6189 errmsg ("missing rx interface name or sw_if_index");
6193 if (enable && (bd_id_set == 0))
6195 errmsg ("missing bridge domain");
6199 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6201 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6202 mp->bd_id = ntohl (bd_id);
6205 mp->enable = enable;
6213 api_bridge_domain_dump (vat_main_t * vam)
6215 unformat_input_t *i = vam->input;
6216 vl_api_bridge_domain_dump_t *mp;
6217 vl_api_control_ping_t *mp_ping;
6221 /* Parse args required to build the message */
6222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6224 if (unformat (i, "bd_id %d", &bd_id))
6230 M (BRIDGE_DOMAIN_DUMP, mp);
6231 mp->bd_id = ntohl (bd_id);
6234 /* Use a control ping for synchronization */
6235 M (CONTROL_PING, mp_ping);
6243 api_bridge_domain_add_del (vat_main_t * vam)
6245 unformat_input_t *i = vam->input;
6246 vl_api_bridge_domain_add_del_t *mp;
6249 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6253 /* Parse args required to build the message */
6254 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6256 if (unformat (i, "bd_id %d", &bd_id))
6258 else if (unformat (i, "flood %d", &flood))
6260 else if (unformat (i, "uu-flood %d", &uu_flood))
6262 else if (unformat (i, "forward %d", &forward))
6264 else if (unformat (i, "learn %d", &learn))
6266 else if (unformat (i, "arp-term %d", &arp_term))
6268 else if (unformat (i, "mac-age %d", &mac_age))
6270 else if (unformat (i, "del"))
6273 flood = uu_flood = forward = learn = 0;
6281 errmsg ("missing bridge domain");
6287 errmsg ("mac age must be less than 256 ");
6291 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6293 mp->bd_id = ntohl (bd_id);
6295 mp->uu_flood = uu_flood;
6296 mp->forward = forward;
6298 mp->arp_term = arp_term;
6299 mp->is_add = is_add;
6300 mp->mac_age = (u8) mac_age;
6308 api_l2fib_flush_bd (vat_main_t * vam)
6310 unformat_input_t *i = vam->input;
6311 vl_api_l2fib_flush_bd_t *mp;
6315 /* Parse args required to build the message */
6316 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6318 if (unformat (i, "bd_id %d", &bd_id));
6325 errmsg ("missing bridge domain");
6329 M (L2FIB_FLUSH_BD, mp);
6331 mp->bd_id = htonl (bd_id);
6339 api_l2fib_flush_int (vat_main_t * vam)
6341 unformat_input_t *i = vam->input;
6342 vl_api_l2fib_flush_int_t *mp;
6343 u32 sw_if_index = ~0;
6346 /* Parse args required to build the message */
6347 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6349 if (unformat (i, "sw_if_index %d", &sw_if_index));
6351 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6356 if (sw_if_index == ~0)
6358 errmsg ("missing interface name or sw_if_index");
6362 M (L2FIB_FLUSH_INT, mp);
6364 mp->sw_if_index = ntohl (sw_if_index);
6372 api_l2fib_add_del (vat_main_t * vam)
6374 unformat_input_t *i = vam->input;
6375 vl_api_l2fib_add_del_t *mp;
6381 u32 sw_if_index = ~0;
6382 u8 sw_if_index_set = 0;
6391 /* Parse args required to build the message */
6392 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6394 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6396 else if (unformat (i, "bd_id %d", &bd_id))
6398 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6399 sw_if_index_set = 1;
6400 else if (unformat (i, "sw_if"))
6402 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6405 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6406 sw_if_index_set = 1;
6411 else if (unformat (i, "static"))
6413 else if (unformat (i, "filter"))
6418 else if (unformat (i, "bvi"))
6423 else if (unformat (i, "del"))
6425 else if (unformat (i, "count %d", &count))
6433 errmsg ("missing mac address");
6439 errmsg ("missing bridge domain");
6443 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6445 errmsg ("missing interface name or sw_if_index");
6451 /* Turn on async mode */
6452 vam->async_mode = 1;
6453 vam->async_errors = 0;
6454 before = vat_time_now (vam);
6457 for (j = 0; j < count; j++)
6459 M (L2FIB_ADD_DEL, mp);
6462 mp->bd_id = ntohl (bd_id);
6463 mp->is_add = is_add;
6467 mp->sw_if_index = ntohl (sw_if_index);
6468 mp->static_mac = static_mac;
6469 mp->filter_mac = filter_mac;
6470 mp->bvi_mac = bvi_mac;
6472 increment_mac_address (&mac);
6479 vl_api_control_ping_t *mp_ping;
6482 /* Shut off async mode */
6483 vam->async_mode = 0;
6485 M (CONTROL_PING, mp_ping);
6488 timeout = vat_time_now (vam) + 1.0;
6489 while (vat_time_now (vam) < timeout)
6490 if (vam->result_ready == 1)
6495 if (vam->retval == -99)
6498 if (vam->async_errors > 0)
6500 errmsg ("%d asynchronous errors", vam->async_errors);
6503 vam->async_errors = 0;
6504 after = vat_time_now (vam);
6506 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6507 count, after - before, count / (after - before));
6513 /* Wait for a reply... */
6517 /* Return the good/bad news */
6518 return (vam->retval);
6522 api_bridge_domain_set_mac_age (vat_main_t * vam)
6524 unformat_input_t *i = vam->input;
6525 vl_api_bridge_domain_set_mac_age_t *mp;
6530 /* Parse args required to build the message */
6531 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6533 if (unformat (i, "bd_id %d", &bd_id));
6534 else if (unformat (i, "mac-age %d", &mac_age));
6541 errmsg ("missing bridge domain");
6547 errmsg ("mac age must be less than 256 ");
6551 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6553 mp->bd_id = htonl (bd_id);
6554 mp->mac_age = (u8) mac_age;
6562 api_l2_flags (vat_main_t * vam)
6564 unformat_input_t *i = vam->input;
6565 vl_api_l2_flags_t *mp;
6567 u32 feature_bitmap = 0;
6568 u8 sw_if_index_set = 0;
6571 /* Parse args required to build the message */
6572 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6574 if (unformat (i, "sw_if_index %d", &sw_if_index))
6575 sw_if_index_set = 1;
6576 else if (unformat (i, "sw_if"))
6578 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6581 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6582 sw_if_index_set = 1;
6587 else if (unformat (i, "learn"))
6588 feature_bitmap |= L2INPUT_FEAT_LEARN;
6589 else if (unformat (i, "forward"))
6590 feature_bitmap |= L2INPUT_FEAT_FWD;
6591 else if (unformat (i, "flood"))
6592 feature_bitmap |= L2INPUT_FEAT_FLOOD;
6593 else if (unformat (i, "uu-flood"))
6594 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
6599 if (sw_if_index_set == 0)
6601 errmsg ("missing interface name or sw_if_index");
6607 mp->sw_if_index = ntohl (sw_if_index);
6608 mp->feature_bitmap = ntohl (feature_bitmap);
6616 api_bridge_flags (vat_main_t * vam)
6618 unformat_input_t *i = vam->input;
6619 vl_api_bridge_flags_t *mp;
6626 /* Parse args required to build the message */
6627 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6629 if (unformat (i, "bd_id %d", &bd_id))
6631 else if (unformat (i, "learn"))
6633 else if (unformat (i, "forward"))
6635 else if (unformat (i, "flood"))
6637 else if (unformat (i, "uu-flood"))
6638 flags |= L2_UU_FLOOD;
6639 else if (unformat (i, "arp-term"))
6640 flags |= L2_ARP_TERM;
6641 else if (unformat (i, "off"))
6643 else if (unformat (i, "disable"))
6651 errmsg ("missing bridge domain");
6655 M (BRIDGE_FLAGS, mp);
6657 mp->bd_id = ntohl (bd_id);
6658 mp->feature_bitmap = ntohl (flags);
6659 mp->is_set = is_set;
6667 api_bd_ip_mac_add_del (vat_main_t * vam)
6669 unformat_input_t *i = vam->input;
6670 vl_api_bd_ip_mac_add_del_t *mp;
6677 ip4_address_t v4addr;
6678 ip6_address_t v6addr;
6683 /* Parse args required to build the message */
6684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6686 if (unformat (i, "bd_id %d", &bd_id))
6690 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6694 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6699 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6703 else if (unformat (i, "del"))
6711 errmsg ("missing bridge domain");
6714 else if (ip_set == 0)
6716 errmsg ("missing IP address");
6719 else if (mac_set == 0)
6721 errmsg ("missing MAC address");
6725 M (BD_IP_MAC_ADD_DEL, mp);
6727 mp->bd_id = ntohl (bd_id);
6728 mp->is_ipv6 = is_ipv6;
6729 mp->is_add = is_add;
6731 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6733 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6734 clib_memcpy (mp->mac_address, macaddr, 6);
6741 api_tap_connect (vat_main_t * vam)
6743 unformat_input_t *i = vam->input;
6744 vl_api_tap_connect_t *mp;
6750 ip4_address_t ip4_address;
6752 int ip4_address_set = 0;
6753 ip6_address_t ip6_address;
6755 int ip6_address_set = 0;
6758 memset (mac_address, 0, sizeof (mac_address));
6760 /* Parse args required to build the message */
6761 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6763 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6767 else if (unformat (i, "random-mac"))
6769 else if (unformat (i, "tapname %s", &tap_name))
6771 else if (unformat (i, "tag %s", &tag))
6773 else if (unformat (i, "address %U/%d",
6774 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6775 ip4_address_set = 1;
6776 else if (unformat (i, "address %U/%d",
6777 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6778 ip6_address_set = 1;
6785 errmsg ("missing tap name");
6788 if (vec_len (tap_name) > 63)
6790 errmsg ("tap name too long");
6793 vec_add1 (tap_name, 0);
6795 if (vec_len (tag) > 63)
6797 errmsg ("tag too long");
6801 /* Construct the API message */
6802 M (TAP_CONNECT, mp);
6804 mp->use_random_mac = random_mac;
6805 clib_memcpy (mp->mac_address, mac_address, 6);
6806 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6808 clib_memcpy (mp->tag, tag, vec_len (tag));
6810 if (ip4_address_set)
6812 mp->ip4_address_set = 1;
6813 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6814 mp->ip4_mask_width = ip4_mask_width;
6816 if (ip6_address_set)
6818 mp->ip6_address_set = 1;
6819 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6820 mp->ip6_mask_width = ip6_mask_width;
6823 vec_free (tap_name);
6829 /* Wait for a reply... */
6835 api_tap_modify (vat_main_t * vam)
6837 unformat_input_t *i = vam->input;
6838 vl_api_tap_modify_t *mp;
6843 u32 sw_if_index = ~0;
6844 u8 sw_if_index_set = 0;
6847 memset (mac_address, 0, sizeof (mac_address));
6849 /* Parse args required to build the message */
6850 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6852 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6853 sw_if_index_set = 1;
6854 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6855 sw_if_index_set = 1;
6856 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6860 else if (unformat (i, "random-mac"))
6862 else if (unformat (i, "tapname %s", &tap_name))
6868 if (sw_if_index_set == 0)
6870 errmsg ("missing vpp interface name");
6875 errmsg ("missing tap name");
6878 if (vec_len (tap_name) > 63)
6880 errmsg ("tap name too long");
6882 vec_add1 (tap_name, 0);
6884 /* Construct the API message */
6887 mp->use_random_mac = random_mac;
6888 mp->sw_if_index = ntohl (sw_if_index);
6889 clib_memcpy (mp->mac_address, mac_address, 6);
6890 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6891 vec_free (tap_name);
6896 /* Wait for a reply... */
6902 api_tap_delete (vat_main_t * vam)
6904 unformat_input_t *i = vam->input;
6905 vl_api_tap_delete_t *mp;
6906 u32 sw_if_index = ~0;
6907 u8 sw_if_index_set = 0;
6910 /* Parse args required to build the message */
6911 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6913 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6914 sw_if_index_set = 1;
6915 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6916 sw_if_index_set = 1;
6921 if (sw_if_index_set == 0)
6923 errmsg ("missing vpp interface name");
6927 /* Construct the API message */
6930 mp->sw_if_index = ntohl (sw_if_index);
6935 /* Wait for a reply... */
6941 api_ip_add_del_route (vat_main_t * vam)
6943 unformat_input_t *i = vam->input;
6944 vl_api_ip_add_del_route_t *mp;
6945 u32 sw_if_index = ~0, vrf_id = 0;
6947 u8 is_local = 0, is_drop = 0;
6948 u8 is_unreach = 0, is_prohibit = 0;
6949 u8 create_vrf_if_needed = 0;
6951 u32 next_hop_weight = 1;
6953 u8 is_multipath = 0;
6955 u8 address_length_set = 0;
6956 u32 next_hop_table_id = 0;
6957 u32 resolve_attempts = 0;
6958 u32 dst_address_length = 0;
6959 u8 next_hop_set = 0;
6960 ip4_address_t v4_dst_address, v4_next_hop_address;
6961 ip6_address_t v6_dst_address, v6_next_hop_address;
6965 u32 random_add_del = 0;
6966 u32 *random_vector = 0;
6968 u32 random_seed = 0xdeaddabe;
6969 u32 classify_table_index = ~0;
6971 u8 resolve_host = 0, resolve_attached = 0;
6972 mpls_label_t *next_hop_out_label_stack = NULL;
6973 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6974 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6976 /* Parse args required to build the message */
6977 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6979 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6981 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6983 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6988 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6993 else if (unformat (i, "/%d", &dst_address_length))
6995 address_length_set = 1;
6998 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6999 &v4_next_hop_address))
7003 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7004 &v6_next_hop_address))
7008 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7010 else if (unformat (i, "weight %d", &next_hop_weight))
7012 else if (unformat (i, "drop"))
7016 else if (unformat (i, "null-send-unreach"))
7020 else if (unformat (i, "null-send-prohibit"))
7024 else if (unformat (i, "local"))
7028 else if (unformat (i, "classify %d", &classify_table_index))
7032 else if (unformat (i, "del"))
7034 else if (unformat (i, "add"))
7036 else if (unformat (i, "not-last"))
7038 else if (unformat (i, "resolve-via-host"))
7040 else if (unformat (i, "resolve-via-attached"))
7041 resolve_attached = 1;
7042 else if (unformat (i, "multipath"))
7044 else if (unformat (i, "vrf %d", &vrf_id))
7046 else if (unformat (i, "create-vrf"))
7047 create_vrf_if_needed = 1;
7048 else if (unformat (i, "count %d", &count))
7050 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7052 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7054 else if (unformat (i, "out-label %d", &next_hop_out_label))
7055 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7056 else if (unformat (i, "via-label %d", &next_hop_via_label))
7058 else if (unformat (i, "random"))
7060 else if (unformat (i, "seed %d", &random_seed))
7064 clib_warning ("parse error '%U'", format_unformat_error, i);
7069 if (!next_hop_set && !is_drop && !is_local &&
7070 !is_classify && !is_unreach && !is_prohibit &&
7071 MPLS_LABEL_INVALID == next_hop_via_label)
7074 ("next hop / local / drop / unreach / prohibit / classify not set");
7078 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7080 errmsg ("next hop and next-hop via label set");
7083 if (address_set == 0)
7085 errmsg ("missing addresses");
7089 if (address_length_set == 0)
7091 errmsg ("missing address length");
7095 /* Generate a pile of unique, random routes */
7098 u32 this_random_address;
7099 random_hash = hash_create (count, sizeof (uword));
7101 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7102 for (j = 0; j <= count; j++)
7106 this_random_address = random_u32 (&random_seed);
7107 this_random_address =
7108 clib_host_to_net_u32 (this_random_address);
7110 while (hash_get (random_hash, this_random_address));
7111 vec_add1 (random_vector, this_random_address);
7112 hash_set (random_hash, this_random_address, 1);
7114 hash_free (random_hash);
7115 v4_dst_address.as_u32 = random_vector[0];
7120 /* Turn on async mode */
7121 vam->async_mode = 1;
7122 vam->async_errors = 0;
7123 before = vat_time_now (vam);
7126 for (j = 0; j < count; j++)
7128 /* Construct the API message */
7129 M2 (IP_ADD_DEL_ROUTE, mp,
7130 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7132 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7133 mp->table_id = ntohl (vrf_id);
7134 mp->create_vrf_if_needed = create_vrf_if_needed;
7136 mp->is_add = is_add;
7137 mp->is_drop = is_drop;
7138 mp->is_unreach = is_unreach;
7139 mp->is_prohibit = is_prohibit;
7140 mp->is_ipv6 = is_ipv6;
7141 mp->is_local = is_local;
7142 mp->is_classify = is_classify;
7143 mp->is_multipath = is_multipath;
7144 mp->is_resolve_host = resolve_host;
7145 mp->is_resolve_attached = resolve_attached;
7146 mp->not_last = not_last;
7147 mp->next_hop_weight = next_hop_weight;
7148 mp->dst_address_length = dst_address_length;
7149 mp->next_hop_table_id = ntohl (next_hop_table_id);
7150 mp->classify_table_index = ntohl (classify_table_index);
7151 mp->next_hop_via_label = ntohl (next_hop_via_label);
7152 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7153 if (0 != mp->next_hop_n_out_labels)
7155 memcpy (mp->next_hop_out_label_stack,
7156 next_hop_out_label_stack,
7157 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7158 vec_free (next_hop_out_label_stack);
7163 clib_memcpy (mp->dst_address, &v6_dst_address,
7164 sizeof (v6_dst_address));
7166 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
7167 sizeof (v6_next_hop_address));
7168 increment_v6_address (&v6_dst_address);
7172 clib_memcpy (mp->dst_address, &v4_dst_address,
7173 sizeof (v4_dst_address));
7175 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
7176 sizeof (v4_next_hop_address));
7178 v4_dst_address.as_u32 = random_vector[j + 1];
7180 increment_v4_address (&v4_dst_address);
7184 /* If we receive SIGTERM, stop now... */
7189 /* When testing multiple add/del ops, use a control-ping to sync */
7192 vl_api_control_ping_t *mp_ping;
7196 /* Shut off async mode */
7197 vam->async_mode = 0;
7199 M (CONTROL_PING, mp_ping);
7202 timeout = vat_time_now (vam) + 1.0;
7203 while (vat_time_now (vam) < timeout)
7204 if (vam->result_ready == 1)
7209 if (vam->retval == -99)
7212 if (vam->async_errors > 0)
7214 errmsg ("%d asynchronous errors", vam->async_errors);
7217 vam->async_errors = 0;
7218 after = vat_time_now (vam);
7220 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7224 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7225 count, after - before, count / (after - before));
7231 /* Wait for a reply... */
7236 /* Return the good/bad news */
7237 return (vam->retval);
7241 api_ip_mroute_add_del (vat_main_t * vam)
7243 unformat_input_t *i = vam->input;
7244 vl_api_ip_mroute_add_del_t *mp;
7245 u32 sw_if_index = ~0, vrf_id = 0;
7248 u8 create_vrf_if_needed = 0;
7251 u32 grp_address_length = 0;
7252 ip4_address_t v4_grp_address, v4_src_address;
7253 ip6_address_t v6_grp_address, v6_src_address;
7254 mfib_itf_flags_t iflags = 0;
7255 mfib_entry_flags_t eflags = 0;
7258 /* Parse args required to build the message */
7259 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7261 if (unformat (i, "sw_if_index %d", &sw_if_index))
7263 else if (unformat (i, "%U %U",
7264 unformat_ip4_address, &v4_src_address,
7265 unformat_ip4_address, &v4_grp_address))
7267 grp_address_length = 64;
7271 else if (unformat (i, "%U %U",
7272 unformat_ip6_address, &v6_src_address,
7273 unformat_ip6_address, &v6_grp_address))
7275 grp_address_length = 256;
7279 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7281 memset (&v4_src_address, 0, sizeof (v4_src_address));
7282 grp_address_length = 32;
7286 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7288 memset (&v6_src_address, 0, sizeof (v6_src_address));
7289 grp_address_length = 128;
7293 else if (unformat (i, "/%d", &grp_address_length))
7295 else if (unformat (i, "local"))
7299 else if (unformat (i, "del"))
7301 else if (unformat (i, "add"))
7303 else if (unformat (i, "vrf %d", &vrf_id))
7305 else if (unformat (i, "create-vrf"))
7306 create_vrf_if_needed = 1;
7307 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7309 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7313 clib_warning ("parse error '%U'", format_unformat_error, i);
7318 if (address_set == 0)
7320 errmsg ("missing addresses\n");
7324 /* Construct the API message */
7325 M (IP_MROUTE_ADD_DEL, mp);
7327 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7328 mp->table_id = ntohl (vrf_id);
7329 mp->create_vrf_if_needed = create_vrf_if_needed;
7331 mp->is_add = is_add;
7332 mp->is_ipv6 = is_ipv6;
7333 mp->is_local = is_local;
7334 mp->itf_flags = ntohl (iflags);
7335 mp->entry_flags = ntohl (eflags);
7336 mp->grp_address_length = grp_address_length;
7337 mp->grp_address_length = ntohs (mp->grp_address_length);
7341 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7342 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7346 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7347 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7353 /* Wait for a reply... */
7359 api_mpls_route_add_del (vat_main_t * vam)
7361 unformat_input_t *i = vam->input;
7362 vl_api_mpls_route_add_del_t *mp;
7363 u32 sw_if_index = ~0, table_id = 0;
7364 u8 create_table_if_needed = 0;
7366 u32 next_hop_weight = 1;
7367 u8 is_multipath = 0;
7368 u32 next_hop_table_id = 0;
7369 u8 next_hop_set = 0;
7370 ip4_address_t v4_next_hop_address = {
7373 ip6_address_t v6_next_hop_address = { {0} };
7377 u32 classify_table_index = ~0;
7379 u8 resolve_host = 0, resolve_attached = 0;
7380 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7381 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7382 mpls_label_t *next_hop_out_label_stack = NULL;
7383 mpls_label_t local_label = MPLS_LABEL_INVALID;
7385 u8 next_hop_proto_is_ip4 = 1;
7387 /* Parse args required to build the message */
7388 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7390 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7392 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7394 else if (unformat (i, "%d", &local_label))
7396 else if (unformat (i, "eos"))
7398 else if (unformat (i, "non-eos"))
7400 else if (unformat (i, "via %U", unformat_ip4_address,
7401 &v4_next_hop_address))
7404 next_hop_proto_is_ip4 = 1;
7406 else if (unformat (i, "via %U", unformat_ip6_address,
7407 &v6_next_hop_address))
7410 next_hop_proto_is_ip4 = 0;
7412 else if (unformat (i, "weight %d", &next_hop_weight))
7414 else if (unformat (i, "create-table"))
7415 create_table_if_needed = 1;
7416 else if (unformat (i, "classify %d", &classify_table_index))
7420 else if (unformat (i, "del"))
7422 else if (unformat (i, "add"))
7424 else if (unformat (i, "resolve-via-host"))
7426 else if (unformat (i, "resolve-via-attached"))
7427 resolve_attached = 1;
7428 else if (unformat (i, "multipath"))
7430 else if (unformat (i, "count %d", &count))
7432 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
7435 next_hop_proto_is_ip4 = 1;
7437 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
7440 next_hop_proto_is_ip4 = 0;
7442 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7444 else if (unformat (i, "via-label %d", &next_hop_via_label))
7446 else if (unformat (i, "out-label %d", &next_hop_out_label))
7447 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7450 clib_warning ("parse error '%U'", format_unformat_error, i);
7455 if (!next_hop_set && !is_classify)
7457 errmsg ("next hop / classify not set");
7461 if (MPLS_LABEL_INVALID == local_label)
7463 errmsg ("missing label");
7469 /* Turn on async mode */
7470 vam->async_mode = 1;
7471 vam->async_errors = 0;
7472 before = vat_time_now (vam);
7475 for (j = 0; j < count; j++)
7477 /* Construct the API message */
7478 M2 (MPLS_ROUTE_ADD_DEL, mp,
7479 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7481 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
7482 mp->mr_table_id = ntohl (table_id);
7483 mp->mr_create_table_if_needed = create_table_if_needed;
7485 mp->mr_is_add = is_add;
7486 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7487 mp->mr_is_classify = is_classify;
7488 mp->mr_is_multipath = is_multipath;
7489 mp->mr_is_resolve_host = resolve_host;
7490 mp->mr_is_resolve_attached = resolve_attached;
7491 mp->mr_next_hop_weight = next_hop_weight;
7492 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
7493 mp->mr_classify_table_index = ntohl (classify_table_index);
7494 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
7495 mp->mr_label = ntohl (local_label);
7496 mp->mr_eos = is_eos;
7498 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7499 if (0 != mp->mr_next_hop_n_out_labels)
7501 memcpy (mp->mr_next_hop_out_label_stack,
7502 next_hop_out_label_stack,
7503 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7504 vec_free (next_hop_out_label_stack);
7509 if (next_hop_proto_is_ip4)
7511 clib_memcpy (mp->mr_next_hop,
7512 &v4_next_hop_address,
7513 sizeof (v4_next_hop_address));
7517 clib_memcpy (mp->mr_next_hop,
7518 &v6_next_hop_address,
7519 sizeof (v6_next_hop_address));
7526 /* If we receive SIGTERM, stop now... */
7531 /* When testing multiple add/del ops, use a control-ping to sync */
7534 vl_api_control_ping_t *mp_ping;
7538 /* Shut off async mode */
7539 vam->async_mode = 0;
7541 M (CONTROL_PING, mp_ping);
7544 timeout = vat_time_now (vam) + 1.0;
7545 while (vat_time_now (vam) < timeout)
7546 if (vam->result_ready == 1)
7551 if (vam->retval == -99)
7554 if (vam->async_errors > 0)
7556 errmsg ("%d asynchronous errors", vam->async_errors);
7559 vam->async_errors = 0;
7560 after = vat_time_now (vam);
7562 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7566 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7567 count, after - before, count / (after - before));
7573 /* Wait for a reply... */
7578 /* Return the good/bad news */
7579 return (vam->retval);
7583 api_mpls_ip_bind_unbind (vat_main_t * vam)
7585 unformat_input_t *i = vam->input;
7586 vl_api_mpls_ip_bind_unbind_t *mp;
7587 u32 ip_table_id = 0;
7588 u8 create_table_if_needed = 0;
7591 ip4_address_t v4_address;
7592 ip6_address_t v6_address;
7595 mpls_label_t local_label = MPLS_LABEL_INVALID;
7598 /* Parse args required to build the message */
7599 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7601 if (unformat (i, "%U/%d", unformat_ip4_address,
7602 &v4_address, &address_length))
7607 else if (unformat (i, "%U/%d", unformat_ip6_address,
7608 &v6_address, &address_length))
7613 else if (unformat (i, "%d", &local_label))
7615 else if (unformat (i, "create-table"))
7616 create_table_if_needed = 1;
7617 else if (unformat (i, "table-id %d", &ip_table_id))
7619 else if (unformat (i, "unbind"))
7621 else if (unformat (i, "bind"))
7625 clib_warning ("parse error '%U'", format_unformat_error, i);
7632 errmsg ("IP addres not set");
7636 if (MPLS_LABEL_INVALID == local_label)
7638 errmsg ("missing label");
7642 /* Construct the API message */
7643 M (MPLS_IP_BIND_UNBIND, mp);
7645 mp->mb_create_table_if_needed = create_table_if_needed;
7646 mp->mb_is_bind = is_bind;
7647 mp->mb_is_ip4 = is_ip4;
7648 mp->mb_ip_table_id = ntohl (ip_table_id);
7649 mp->mb_mpls_table_id = 0;
7650 mp->mb_label = ntohl (local_label);
7651 mp->mb_address_length = address_length;
7654 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7656 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7661 /* Wait for a reply... */
7667 api_proxy_arp_add_del (vat_main_t * vam)
7669 unformat_input_t *i = vam->input;
7670 vl_api_proxy_arp_add_del_t *mp;
7673 ip4_address_t lo, hi;
7677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7679 if (unformat (i, "vrf %d", &vrf_id))
7681 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7682 unformat_ip4_address, &hi))
7684 else if (unformat (i, "del"))
7688 clib_warning ("parse error '%U'", format_unformat_error, i);
7695 errmsg ("address range not set");
7699 M (PROXY_ARP_ADD_DEL, mp);
7701 mp->vrf_id = ntohl (vrf_id);
7702 mp->is_add = is_add;
7703 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7704 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7712 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7714 unformat_input_t *i = vam->input;
7715 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7718 u8 sw_if_index_set = 0;
7721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7723 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7724 sw_if_index_set = 1;
7725 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7726 sw_if_index_set = 1;
7727 else if (unformat (i, "enable"))
7729 else if (unformat (i, "disable"))
7733 clib_warning ("parse error '%U'", format_unformat_error, i);
7738 if (sw_if_index_set == 0)
7740 errmsg ("missing interface name or sw_if_index");
7744 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7746 mp->sw_if_index = ntohl (sw_if_index);
7747 mp->enable_disable = enable;
7755 api_mpls_tunnel_add_del (vat_main_t * vam)
7757 unformat_input_t *i = vam->input;
7758 vl_api_mpls_tunnel_add_del_t *mp;
7762 u32 sw_if_index = ~0;
7763 u32 next_hop_sw_if_index = ~0;
7764 u32 next_hop_proto_is_ip4 = 1;
7766 u32 next_hop_table_id = 0;
7767 ip4_address_t v4_next_hop_address = {
7770 ip6_address_t v6_next_hop_address = { {0} };
7771 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7774 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7776 if (unformat (i, "add"))
7778 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7780 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7782 else if (unformat (i, "via %U",
7783 unformat_ip4_address, &v4_next_hop_address))
7785 next_hop_proto_is_ip4 = 1;
7787 else if (unformat (i, "via %U",
7788 unformat_ip6_address, &v6_next_hop_address))
7790 next_hop_proto_is_ip4 = 0;
7792 else if (unformat (i, "l2-only"))
7794 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7796 else if (unformat (i, "out-label %d", &next_hop_out_label))
7797 vec_add1 (labels, ntohl (next_hop_out_label));
7800 clib_warning ("parse error '%U'", format_unformat_error, i);
7805 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7807 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7808 mp->mt_sw_if_index = ntohl (sw_if_index);
7809 mp->mt_is_add = is_add;
7810 mp->mt_l2_only = l2_only;
7811 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7812 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7814 mp->mt_next_hop_n_out_labels = vec_len (labels);
7816 if (0 != mp->mt_next_hop_n_out_labels)
7818 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7819 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7823 if (next_hop_proto_is_ip4)
7825 clib_memcpy (mp->mt_next_hop,
7826 &v4_next_hop_address, sizeof (v4_next_hop_address));
7830 clib_memcpy (mp->mt_next_hop,
7831 &v6_next_hop_address, sizeof (v6_next_hop_address));
7840 api_sw_interface_set_unnumbered (vat_main_t * vam)
7842 unformat_input_t *i = vam->input;
7843 vl_api_sw_interface_set_unnumbered_t *mp;
7845 u32 unnum_sw_index = ~0;
7847 u8 sw_if_index_set = 0;
7850 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7852 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7853 sw_if_index_set = 1;
7854 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7855 sw_if_index_set = 1;
7856 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7858 else if (unformat (i, "del"))
7862 clib_warning ("parse error '%U'", format_unformat_error, i);
7867 if (sw_if_index_set == 0)
7869 errmsg ("missing interface name or sw_if_index");
7873 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7875 mp->sw_if_index = ntohl (sw_if_index);
7876 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7877 mp->is_add = is_add;
7885 api_ip_neighbor_add_del (vat_main_t * vam)
7887 unformat_input_t *i = vam->input;
7888 vl_api_ip_neighbor_add_del_t *mp;
7890 u8 sw_if_index_set = 0;
7893 u8 is_no_fib_entry = 0;
7896 u8 v4_address_set = 0;
7897 u8 v6_address_set = 0;
7898 ip4_address_t v4address;
7899 ip6_address_t v6address;
7902 memset (mac_address, 0, sizeof (mac_address));
7904 /* Parse args required to build the message */
7905 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7907 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7911 else if (unformat (i, "del"))
7914 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7915 sw_if_index_set = 1;
7916 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7917 sw_if_index_set = 1;
7918 else if (unformat (i, "is_static"))
7920 else if (unformat (i, "no-fib-entry"))
7921 is_no_fib_entry = 1;
7922 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7924 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7928 clib_warning ("parse error '%U'", format_unformat_error, i);
7933 if (sw_if_index_set == 0)
7935 errmsg ("missing interface name or sw_if_index");
7938 if (v4_address_set && v6_address_set)
7940 errmsg ("both v4 and v6 addresses set");
7943 if (!v4_address_set && !v6_address_set)
7945 errmsg ("no address set");
7949 /* Construct the API message */
7950 M (IP_NEIGHBOR_ADD_DEL, mp);
7952 mp->sw_if_index = ntohl (sw_if_index);
7953 mp->is_add = is_add;
7954 mp->is_static = is_static;
7955 mp->is_no_adj_fib = is_no_fib_entry;
7957 clib_memcpy (mp->mac_address, mac_address, 6);
7961 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7965 /* mp->is_ipv6 = 0; via memset in M macro above */
7966 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7972 /* Wait for a reply, return good/bad news */
7978 api_reset_vrf (vat_main_t * vam)
7980 unformat_input_t *i = vam->input;
7981 vl_api_reset_vrf_t *mp;
7987 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7989 if (unformat (i, "vrf %d", &vrf_id))
7991 else if (unformat (i, "ipv6"))
7995 clib_warning ("parse error '%U'", format_unformat_error, i);
8000 if (vrf_id_set == 0)
8002 errmsg ("missing vrf id");
8008 mp->vrf_id = ntohl (vrf_id);
8009 mp->is_ipv6 = is_ipv6;
8017 api_create_vlan_subif (vat_main_t * vam)
8019 unformat_input_t *i = vam->input;
8020 vl_api_create_vlan_subif_t *mp;
8022 u8 sw_if_index_set = 0;
8027 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8029 if (unformat (i, "sw_if_index %d", &sw_if_index))
8030 sw_if_index_set = 1;
8032 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8033 sw_if_index_set = 1;
8034 else if (unformat (i, "vlan %d", &vlan_id))
8038 clib_warning ("parse error '%U'", format_unformat_error, i);
8043 if (sw_if_index_set == 0)
8045 errmsg ("missing interface name or sw_if_index");
8049 if (vlan_id_set == 0)
8051 errmsg ("missing vlan_id");
8054 M (CREATE_VLAN_SUBIF, mp);
8056 mp->sw_if_index = ntohl (sw_if_index);
8057 mp->vlan_id = ntohl (vlan_id);
8064 #define foreach_create_subif_bit \
8071 _(outer_vlan_id_any) \
8072 _(inner_vlan_id_any)
8075 api_create_subif (vat_main_t * vam)
8077 unformat_input_t *i = vam->input;
8078 vl_api_create_subif_t *mp;
8080 u8 sw_if_index_set = 0;
8087 u32 exact_match = 0;
8088 u32 default_sub = 0;
8089 u32 outer_vlan_id_any = 0;
8090 u32 inner_vlan_id_any = 0;
8092 u16 outer_vlan_id = 0;
8093 u16 inner_vlan_id = 0;
8096 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8098 if (unformat (i, "sw_if_index %d", &sw_if_index))
8099 sw_if_index_set = 1;
8101 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8102 sw_if_index_set = 1;
8103 else if (unformat (i, "sub_id %d", &sub_id))
8105 else if (unformat (i, "outer_vlan_id %d", &tmp))
8106 outer_vlan_id = tmp;
8107 else if (unformat (i, "inner_vlan_id %d", &tmp))
8108 inner_vlan_id = tmp;
8110 #define _(a) else if (unformat (i, #a)) a = 1 ;
8111 foreach_create_subif_bit
8115 clib_warning ("parse error '%U'", format_unformat_error, i);
8120 if (sw_if_index_set == 0)
8122 errmsg ("missing interface name or sw_if_index");
8126 if (sub_id_set == 0)
8128 errmsg ("missing sub_id");
8131 M (CREATE_SUBIF, mp);
8133 mp->sw_if_index = ntohl (sw_if_index);
8134 mp->sub_id = ntohl (sub_id);
8136 #define _(a) mp->a = a;
8137 foreach_create_subif_bit;
8140 mp->outer_vlan_id = ntohs (outer_vlan_id);
8141 mp->inner_vlan_id = ntohs (inner_vlan_id);
8149 api_oam_add_del (vat_main_t * vam)
8151 unformat_input_t *i = vam->input;
8152 vl_api_oam_add_del_t *mp;
8155 ip4_address_t src, dst;
8160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8162 if (unformat (i, "vrf %d", &vrf_id))
8164 else if (unformat (i, "src %U", unformat_ip4_address, &src))
8166 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
8168 else if (unformat (i, "del"))
8172 clib_warning ("parse error '%U'", format_unformat_error, i);
8179 errmsg ("missing src addr");
8185 errmsg ("missing dst addr");
8189 M (OAM_ADD_DEL, mp);
8191 mp->vrf_id = ntohl (vrf_id);
8192 mp->is_add = is_add;
8193 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
8194 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8202 api_reset_fib (vat_main_t * vam)
8204 unformat_input_t *i = vam->input;
8205 vl_api_reset_fib_t *mp;
8211 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8213 if (unformat (i, "vrf %d", &vrf_id))
8215 else if (unformat (i, "ipv6"))
8219 clib_warning ("parse error '%U'", format_unformat_error, i);
8224 if (vrf_id_set == 0)
8226 errmsg ("missing vrf id");
8232 mp->vrf_id = ntohl (vrf_id);
8233 mp->is_ipv6 = is_ipv6;
8241 api_dhcp_proxy_config (vat_main_t * vam)
8243 unformat_input_t *i = vam->input;
8244 vl_api_dhcp_proxy_config_t *mp;
8246 u32 server_vrf_id = 0;
8248 u8 v4_address_set = 0;
8249 u8 v6_address_set = 0;
8250 ip4_address_t v4address;
8251 ip6_address_t v6address;
8252 u8 v4_src_address_set = 0;
8253 u8 v6_src_address_set = 0;
8254 ip4_address_t v4srcaddress;
8255 ip6_address_t v6srcaddress;
8258 /* Parse args required to build the message */
8259 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8261 if (unformat (i, "del"))
8263 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8265 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8267 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8269 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8271 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8272 v4_src_address_set = 1;
8273 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8274 v6_src_address_set = 1;
8279 if (v4_address_set && v6_address_set)
8281 errmsg ("both v4 and v6 server addresses set");
8284 if (!v4_address_set && !v6_address_set)
8286 errmsg ("no server addresses set");
8290 if (v4_src_address_set && v6_src_address_set)
8292 errmsg ("both v4 and v6 src addresses set");
8295 if (!v4_src_address_set && !v6_src_address_set)
8297 errmsg ("no src addresses set");
8301 if (!(v4_src_address_set && v4_address_set) &&
8302 !(v6_src_address_set && v6_address_set))
8304 errmsg ("no matching server and src addresses set");
8308 /* Construct the API message */
8309 M (DHCP_PROXY_CONFIG, mp);
8311 mp->is_add = is_add;
8312 mp->rx_vrf_id = ntohl (rx_vrf_id);
8313 mp->server_vrf_id = ntohl (server_vrf_id);
8317 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
8318 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
8322 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
8323 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
8329 /* Wait for a reply, return good/bad news */
8334 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
8335 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
8338 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
8340 vat_main_t *vam = &vat_main;
8341 u32 i, count = mp->count;
8342 vl_api_dhcp_server_t *s;
8346 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8347 ntohl (mp->rx_vrf_id),
8348 format_ip6_address, mp->dhcp_src_address,
8349 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8352 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8353 ntohl (mp->rx_vrf_id),
8354 format_ip4_address, mp->dhcp_src_address,
8355 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8357 for (i = 0; i < count; i++)
8359 s = &mp->servers[i];
8363 " Server Table-ID %d, Server Address %U",
8364 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
8367 " Server Table-ID %d, Server Address %U",
8368 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
8372 static void vl_api_dhcp_proxy_details_t_handler_json
8373 (vl_api_dhcp_proxy_details_t * mp)
8375 vat_main_t *vam = &vat_main;
8376 vat_json_node_t *node = NULL;
8377 u32 i, count = mp->count;
8379 struct in6_addr ip6;
8380 vl_api_dhcp_server_t *s;
8382 if (VAT_JSON_ARRAY != vam->json_tree.type)
8384 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8385 vat_json_init_array (&vam->json_tree);
8387 node = vat_json_array_add (&vam->json_tree);
8389 vat_json_init_object (node);
8390 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
8391 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
8392 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
8396 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
8397 vat_json_object_add_ip6 (node, "src_address", ip6);
8401 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
8402 vat_json_object_add_ip4 (node, "src_address", ip4);
8405 for (i = 0; i < count; i++)
8407 s = &mp->servers[i];
8409 vat_json_object_add_uint (node, "server-table-id",
8410 ntohl (s->server_vrf_id));
8414 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
8415 vat_json_object_add_ip4 (node, "src_address", ip4);
8419 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
8420 vat_json_object_add_ip6 (node, "server_address", ip6);
8426 api_dhcp_proxy_dump (vat_main_t * vam)
8428 unformat_input_t *i = vam->input;
8429 vl_api_control_ping_t *mp_ping;
8430 vl_api_dhcp_proxy_dump_t *mp;
8434 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8436 if (unformat (i, "ipv6"))
8440 clib_warning ("parse error '%U'", format_unformat_error, i);
8445 M (DHCP_PROXY_DUMP, mp);
8447 mp->is_ip6 = is_ipv6;
8450 /* Use a control ping for synchronization */
8451 M (CONTROL_PING, mp_ping);
8459 api_dhcp_proxy_set_vss (vat_main_t * vam)
8461 unformat_input_t *i = vam->input;
8462 vl_api_dhcp_proxy_set_vss_t *mp;
8473 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8475 if (unformat (i, "tbl_id %d", &tbl_id))
8477 if (unformat (i, "fib_id %d", &fib_id))
8479 if (unformat (i, "oui %d", &oui))
8481 else if (unformat (i, "ipv6"))
8483 else if (unformat (i, "del"))
8487 clib_warning ("parse error '%U'", format_unformat_error, i);
8492 if (tbl_id_set == 0)
8494 errmsg ("missing tbl id");
8498 if (fib_id_set == 0)
8500 errmsg ("missing fib id");
8505 errmsg ("missing oui");
8509 M (DHCP_PROXY_SET_VSS, mp);
8510 mp->tbl_id = ntohl (tbl_id);
8511 mp->fib_id = ntohl (fib_id);
8512 mp->oui = ntohl (oui);
8513 mp->is_ipv6 = is_ipv6;
8514 mp->is_add = is_add;
8522 api_dhcp_client_config (vat_main_t * vam)
8524 unformat_input_t *i = vam->input;
8525 vl_api_dhcp_client_config_t *mp;
8527 u8 sw_if_index_set = 0;
8530 u8 disable_event = 0;
8533 /* Parse args required to build the message */
8534 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8536 if (unformat (i, "del"))
8539 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8540 sw_if_index_set = 1;
8541 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8542 sw_if_index_set = 1;
8543 else if (unformat (i, "hostname %s", &hostname))
8545 else if (unformat (i, "disable_event"))
8551 if (sw_if_index_set == 0)
8553 errmsg ("missing interface name or sw_if_index");
8557 if (vec_len (hostname) > 63)
8559 errmsg ("hostname too long");
8561 vec_add1 (hostname, 0);
8563 /* Construct the API message */
8564 M (DHCP_CLIENT_CONFIG, mp);
8566 mp->sw_if_index = htonl (sw_if_index);
8567 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
8568 vec_free (hostname);
8569 mp->is_add = is_add;
8570 mp->want_dhcp_event = disable_event ? 0 : 1;
8571 mp->pid = htonl (getpid ());
8576 /* Wait for a reply, return good/bad news */
8582 api_set_ip_flow_hash (vat_main_t * vam)
8584 unformat_input_t *i = vam->input;
8585 vl_api_set_ip_flow_hash_t *mp;
8597 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8599 if (unformat (i, "vrf %d", &vrf_id))
8601 else if (unformat (i, "ipv6"))
8603 else if (unformat (i, "src"))
8605 else if (unformat (i, "dst"))
8607 else if (unformat (i, "sport"))
8609 else if (unformat (i, "dport"))
8611 else if (unformat (i, "proto"))
8613 else if (unformat (i, "reverse"))
8618 clib_warning ("parse error '%U'", format_unformat_error, i);
8623 if (vrf_id_set == 0)
8625 errmsg ("missing vrf id");
8629 M (SET_IP_FLOW_HASH, mp);
8635 mp->reverse = reverse;
8636 mp->vrf_id = ntohl (vrf_id);
8637 mp->is_ipv6 = is_ipv6;
8645 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8647 unformat_input_t *i = vam->input;
8648 vl_api_sw_interface_ip6_enable_disable_t *mp;
8650 u8 sw_if_index_set = 0;
8654 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8656 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8657 sw_if_index_set = 1;
8658 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8659 sw_if_index_set = 1;
8660 else if (unformat (i, "enable"))
8662 else if (unformat (i, "disable"))
8666 clib_warning ("parse error '%U'", format_unformat_error, i);
8671 if (sw_if_index_set == 0)
8673 errmsg ("missing interface name or sw_if_index");
8677 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8679 mp->sw_if_index = ntohl (sw_if_index);
8680 mp->enable = enable;
8688 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8690 unformat_input_t *i = vam->input;
8691 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8693 u8 sw_if_index_set = 0;
8694 u8 v6_address_set = 0;
8695 ip6_address_t v6address;
8698 /* Parse args required to build the message */
8699 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8701 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8702 sw_if_index_set = 1;
8703 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8704 sw_if_index_set = 1;
8705 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8711 if (sw_if_index_set == 0)
8713 errmsg ("missing interface name or sw_if_index");
8716 if (!v6_address_set)
8718 errmsg ("no address set");
8722 /* Construct the API message */
8723 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8725 mp->sw_if_index = ntohl (sw_if_index);
8726 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8731 /* Wait for a reply, return good/bad news */
8737 api_ip6nd_proxy_add_del (vat_main_t * vam)
8739 unformat_input_t *i = vam->input;
8740 vl_api_ip6nd_proxy_add_del_t *mp;
8741 u32 sw_if_index = ~0;
8742 u8 v6_address_set = 0;
8743 ip6_address_t v6address;
8747 /* Parse args required to build the message */
8748 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8750 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8752 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8754 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8756 if (unformat (i, "del"))
8760 clib_warning ("parse error '%U'", format_unformat_error, i);
8765 if (sw_if_index == ~0)
8767 errmsg ("missing interface name or sw_if_index");
8770 if (!v6_address_set)
8772 errmsg ("no address set");
8776 /* Construct the API message */
8777 M (IP6ND_PROXY_ADD_DEL, mp);
8779 mp->is_del = is_del;
8780 mp->sw_if_index = ntohl (sw_if_index);
8781 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8786 /* Wait for a reply, return good/bad news */
8792 api_ip6nd_proxy_dump (vat_main_t * vam)
8794 vl_api_ip6nd_proxy_dump_t *mp;
8795 vl_api_control_ping_t *mp_ping;
8798 M (IP6ND_PROXY_DUMP, mp);
8802 /* Use a control ping for synchronization */
8803 M (CONTROL_PING, mp_ping);
8810 static void vl_api_ip6nd_proxy_details_t_handler
8811 (vl_api_ip6nd_proxy_details_t * mp)
8813 vat_main_t *vam = &vat_main;
8815 print (vam->ofp, "host %U sw_if_index %d",
8816 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
8819 static void vl_api_ip6nd_proxy_details_t_handler_json
8820 (vl_api_ip6nd_proxy_details_t * mp)
8822 vat_main_t *vam = &vat_main;
8823 struct in6_addr ip6;
8824 vat_json_node_t *node = NULL;
8826 if (VAT_JSON_ARRAY != vam->json_tree.type)
8828 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8829 vat_json_init_array (&vam->json_tree);
8831 node = vat_json_array_add (&vam->json_tree);
8833 vat_json_init_object (node);
8834 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
8836 clib_memcpy (&ip6, mp->address, sizeof (ip6));
8837 vat_json_object_add_ip6 (node, "host", ip6);
8841 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8843 unformat_input_t *i = vam->input;
8844 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8846 u8 sw_if_index_set = 0;
8847 u32 address_length = 0;
8848 u8 v6_address_set = 0;
8849 ip6_address_t v6address;
8851 u8 no_advertise = 0;
8853 u8 no_autoconfig = 0;
8856 u32 val_lifetime = 0;
8857 u32 pref_lifetime = 0;
8860 /* Parse args required to build the message */
8861 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8863 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8864 sw_if_index_set = 1;
8865 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8866 sw_if_index_set = 1;
8867 else if (unformat (i, "%U/%d",
8868 unformat_ip6_address, &v6address, &address_length))
8870 else if (unformat (i, "val_life %d", &val_lifetime))
8872 else if (unformat (i, "pref_life %d", &pref_lifetime))
8874 else if (unformat (i, "def"))
8876 else if (unformat (i, "noadv"))
8878 else if (unformat (i, "offl"))
8880 else if (unformat (i, "noauto"))
8882 else if (unformat (i, "nolink"))
8884 else if (unformat (i, "isno"))
8888 clib_warning ("parse error '%U'", format_unformat_error, i);
8893 if (sw_if_index_set == 0)
8895 errmsg ("missing interface name or sw_if_index");
8898 if (!v6_address_set)
8900 errmsg ("no address set");
8904 /* Construct the API message */
8905 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8907 mp->sw_if_index = ntohl (sw_if_index);
8908 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8909 mp->address_length = address_length;
8910 mp->use_default = use_default;
8911 mp->no_advertise = no_advertise;
8912 mp->off_link = off_link;
8913 mp->no_autoconfig = no_autoconfig;
8914 mp->no_onlink = no_onlink;
8916 mp->val_lifetime = ntohl (val_lifetime);
8917 mp->pref_lifetime = ntohl (pref_lifetime);
8922 /* Wait for a reply, return good/bad news */
8928 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8930 unformat_input_t *i = vam->input;
8931 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8933 u8 sw_if_index_set = 0;
8938 u8 send_unicast = 0;
8941 u8 default_router = 0;
8942 u32 max_interval = 0;
8943 u32 min_interval = 0;
8945 u32 initial_count = 0;
8946 u32 initial_interval = 0;
8950 /* Parse args required to build the message */
8951 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8953 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8954 sw_if_index_set = 1;
8955 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8956 sw_if_index_set = 1;
8957 else if (unformat (i, "maxint %d", &max_interval))
8959 else if (unformat (i, "minint %d", &min_interval))
8961 else if (unformat (i, "life %d", &lifetime))
8963 else if (unformat (i, "count %d", &initial_count))
8965 else if (unformat (i, "interval %d", &initial_interval))
8967 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8969 else if (unformat (i, "managed"))
8971 else if (unformat (i, "other"))
8973 else if (unformat (i, "ll"))
8975 else if (unformat (i, "send"))
8977 else if (unformat (i, "cease"))
8979 else if (unformat (i, "isno"))
8981 else if (unformat (i, "def"))
8985 clib_warning ("parse error '%U'", format_unformat_error, i);
8990 if (sw_if_index_set == 0)
8992 errmsg ("missing interface name or sw_if_index");
8996 /* Construct the API message */
8997 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8999 mp->sw_if_index = ntohl (sw_if_index);
9000 mp->max_interval = ntohl (max_interval);
9001 mp->min_interval = ntohl (min_interval);
9002 mp->lifetime = ntohl (lifetime);
9003 mp->initial_count = ntohl (initial_count);
9004 mp->initial_interval = ntohl (initial_interval);
9005 mp->suppress = suppress;
9006 mp->managed = managed;
9008 mp->ll_option = ll_option;
9009 mp->send_unicast = send_unicast;
9012 mp->default_router = default_router;
9017 /* Wait for a reply, return good/bad news */
9023 api_set_arp_neighbor_limit (vat_main_t * vam)
9025 unformat_input_t *i = vam->input;
9026 vl_api_set_arp_neighbor_limit_t *mp;
9032 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9034 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9036 else if (unformat (i, "ipv6"))
9040 clib_warning ("parse error '%U'", format_unformat_error, i);
9047 errmsg ("missing limit value");
9051 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9053 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9054 mp->is_ipv6 = is_ipv6;
9062 api_l2_patch_add_del (vat_main_t * vam)
9064 unformat_input_t *i = vam->input;
9065 vl_api_l2_patch_add_del_t *mp;
9067 u8 rx_sw_if_index_set = 0;
9069 u8 tx_sw_if_index_set = 0;
9073 /* Parse args required to build the message */
9074 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9076 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9077 rx_sw_if_index_set = 1;
9078 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9079 tx_sw_if_index_set = 1;
9080 else if (unformat (i, "rx"))
9082 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9084 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9086 rx_sw_if_index_set = 1;
9091 else if (unformat (i, "tx"))
9093 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9095 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9097 tx_sw_if_index_set = 1;
9102 else if (unformat (i, "del"))
9108 if (rx_sw_if_index_set == 0)
9110 errmsg ("missing rx interface name or rx_sw_if_index");
9114 if (tx_sw_if_index_set == 0)
9116 errmsg ("missing tx interface name or tx_sw_if_index");
9120 M (L2_PATCH_ADD_DEL, mp);
9122 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9123 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9124 mp->is_add = is_add;
9132 u8 localsid_addr[16];
9141 api_sr_localsid_add_del (vat_main_t * vam)
9143 unformat_input_t *i = vam->input;
9144 vl_api_sr_localsid_add_del_t *mp;
9147 ip6_address_t localsid;
9151 u32 fib_table = ~(u32) 0;
9152 ip6_address_t next_hop;
9154 bool nexthop_set = 0;
9158 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9160 if (unformat (i, "del"))
9162 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9163 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
9165 else if (unformat (i, "behavior %u", &behavior));
9166 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9167 else if (unformat (i, "fib-table %u", &fib_table));
9168 else if (unformat (i, "end.psp %u", &behavior));
9173 M (SR_LOCALSID_ADD_DEL, mp);
9175 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
9177 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
9178 mp->behavior = behavior;
9179 mp->sw_if_index = ntohl (sw_if_index);
9180 mp->fib_table = ntohl (fib_table);
9181 mp->end_psp = end_psp;
9182 mp->is_del = is_del;
9190 api_ioam_enable (vat_main_t * vam)
9192 unformat_input_t *input = vam->input;
9193 vl_api_ioam_enable_t *mp;
9195 int has_trace_option = 0;
9196 int has_pot_option = 0;
9197 int has_seqno_option = 0;
9198 int has_analyse_option = 0;
9201 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9203 if (unformat (input, "trace"))
9204 has_trace_option = 1;
9205 else if (unformat (input, "pot"))
9207 else if (unformat (input, "seqno"))
9208 has_seqno_option = 1;
9209 else if (unformat (input, "analyse"))
9210 has_analyse_option = 1;
9214 M (IOAM_ENABLE, mp);
9215 mp->id = htons (id);
9216 mp->seqno = has_seqno_option;
9217 mp->analyse = has_analyse_option;
9218 mp->pot_enable = has_pot_option;
9219 mp->trace_enable = has_trace_option;
9228 api_ioam_disable (vat_main_t * vam)
9230 vl_api_ioam_disable_t *mp;
9233 M (IOAM_DISABLE, mp);
9239 #define foreach_tcp_proto_field \
9243 #define foreach_udp_proto_field \
9247 #define foreach_ip4_proto_field \
9259 u16 src_port, dst_port;
9262 #if VPP_API_TEST_BUILTIN == 0
9264 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9266 u8 **maskp = va_arg (*args, u8 **);
9268 u8 found_something = 0;
9271 #define _(a) u8 a=0;
9272 foreach_tcp_proto_field;
9275 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9278 #define _(a) else if (unformat (input, #a)) a=1;
9279 foreach_tcp_proto_field
9285 #define _(a) found_something += a;
9286 foreach_tcp_proto_field;
9289 if (found_something == 0)
9292 vec_validate (mask, sizeof (*tcp) - 1);
9294 tcp = (tcp_header_t *) mask;
9296 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9297 foreach_tcp_proto_field;
9305 unformat_udp_mask (unformat_input_t * input, va_list * args)
9307 u8 **maskp = va_arg (*args, u8 **);
9309 u8 found_something = 0;
9312 #define _(a) u8 a=0;
9313 foreach_udp_proto_field;
9316 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9319 #define _(a) else if (unformat (input, #a)) a=1;
9320 foreach_udp_proto_field
9326 #define _(a) found_something += a;
9327 foreach_udp_proto_field;
9330 if (found_something == 0)
9333 vec_validate (mask, sizeof (*udp) - 1);
9335 udp = (udp_header_t *) mask;
9337 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
9338 foreach_udp_proto_field;
9346 unformat_l4_mask (unformat_input_t * input, va_list * args)
9348 u8 **maskp = va_arg (*args, u8 **);
9349 u16 src_port = 0, dst_port = 0;
9350 tcpudp_header_t *tcpudp;
9352 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9354 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9356 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9358 else if (unformat (input, "src_port"))
9360 else if (unformat (input, "dst_port"))
9366 if (!src_port && !dst_port)
9370 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9372 tcpudp = (tcpudp_header_t *) mask;
9373 tcpudp->src_port = src_port;
9374 tcpudp->dst_port = dst_port;
9382 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9384 u8 **maskp = va_arg (*args, u8 **);
9386 u8 found_something = 0;
9389 #define _(a) u8 a=0;
9390 foreach_ip4_proto_field;
9396 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9398 if (unformat (input, "version"))
9400 else if (unformat (input, "hdr_length"))
9402 else if (unformat (input, "src"))
9404 else if (unformat (input, "dst"))
9406 else if (unformat (input, "proto"))
9409 #define _(a) else if (unformat (input, #a)) a=1;
9410 foreach_ip4_proto_field
9416 #define _(a) found_something += a;
9417 foreach_ip4_proto_field;
9420 if (found_something == 0)
9423 vec_validate (mask, sizeof (*ip) - 1);
9425 ip = (ip4_header_t *) mask;
9427 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9428 foreach_ip4_proto_field;
9431 ip->ip_version_and_header_length = 0;
9434 ip->ip_version_and_header_length |= 0xF0;
9437 ip->ip_version_and_header_length |= 0x0F;
9443 #define foreach_ip6_proto_field \
9451 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9453 u8 **maskp = va_arg (*args, u8 **);
9455 u8 found_something = 0;
9457 u32 ip_version_traffic_class_and_flow_label;
9459 #define _(a) u8 a=0;
9460 foreach_ip6_proto_field;
9463 u8 traffic_class = 0;
9466 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9468 if (unformat (input, "version"))
9470 else if (unformat (input, "traffic-class"))
9472 else if (unformat (input, "flow-label"))
9474 else if (unformat (input, "src"))
9476 else if (unformat (input, "dst"))
9478 else if (unformat (input, "proto"))
9481 #define _(a) else if (unformat (input, #a)) a=1;
9482 foreach_ip6_proto_field
9488 #define _(a) found_something += a;
9489 foreach_ip6_proto_field;
9492 if (found_something == 0)
9495 vec_validate (mask, sizeof (*ip) - 1);
9497 ip = (ip6_header_t *) mask;
9499 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9500 foreach_ip6_proto_field;
9503 ip_version_traffic_class_and_flow_label = 0;
9506 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9509 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9512 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9514 ip->ip_version_traffic_class_and_flow_label =
9515 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9522 unformat_l3_mask (unformat_input_t * input, va_list * args)
9524 u8 **maskp = va_arg (*args, u8 **);
9526 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9528 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9530 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9539 unformat_l2_mask (unformat_input_t * input, va_list * args)
9541 u8 **maskp = va_arg (*args, u8 **);
9556 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9558 if (unformat (input, "src"))
9560 else if (unformat (input, "dst"))
9562 else if (unformat (input, "proto"))
9564 else if (unformat (input, "tag1"))
9566 else if (unformat (input, "tag2"))
9568 else if (unformat (input, "ignore-tag1"))
9570 else if (unformat (input, "ignore-tag2"))
9572 else if (unformat (input, "cos1"))
9574 else if (unformat (input, "cos2"))
9576 else if (unformat (input, "dot1q"))
9578 else if (unformat (input, "dot1ad"))
9583 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9584 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9587 if (tag1 || ignore_tag1 || cos1 || dot1q)
9589 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9592 vec_validate (mask, len - 1);
9595 memset (mask, 0xff, 6);
9598 memset (mask + 6, 0xff, 6);
9602 /* inner vlan tag */
9611 mask[21] = mask[20] = 0xff;
9632 mask[16] = mask[17] = 0xff;
9642 mask[12] = mask[13] = 0xff;
9649 unformat_classify_mask (unformat_input_t * input, va_list * args)
9651 u8 **maskp = va_arg (*args, u8 **);
9652 u32 *skipp = va_arg (*args, u32 *);
9653 u32 *matchp = va_arg (*args, u32 *);
9661 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9663 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9665 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9667 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9669 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9683 if (mask || l2 || l3 || l4)
9687 /* "With a free Ethernet header in every package" */
9689 vec_validate (l2, 13);
9693 vec_append (mask, l3);
9698 vec_append (mask, l4);
9703 /* Scan forward looking for the first significant mask octet */
9704 for (i = 0; i < vec_len (mask); i++)
9708 /* compute (skip, match) params */
9709 *skipp = i / sizeof (u32x4);
9710 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9712 /* Pad mask to an even multiple of the vector size */
9713 while (vec_len (mask) % sizeof (u32x4))
9716 match = vec_len (mask) / sizeof (u32x4);
9718 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9720 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9721 if (*tmp || *(tmp + 1))
9726 clib_warning ("BUG: match 0");
9728 _vec_len (mask) = match * sizeof (u32x4);
9738 #endif /* VPP_API_TEST_BUILTIN */
9740 #define foreach_l2_next \
9742 _(ethernet, ETHERNET_INPUT) \
9747 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9749 u32 *miss_next_indexp = va_arg (*args, u32 *);
9754 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9758 if (unformat (input, "%d", &tmp))
9767 *miss_next_indexp = next_index;
9771 #define foreach_ip_next \
9777 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9779 u32 *miss_next_indexp = va_arg (*args, u32 *);
9784 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9788 if (unformat (input, "%d", &tmp))
9797 *miss_next_indexp = next_index;
9801 #define foreach_acl_next \
9805 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9807 u32 *miss_next_indexp = va_arg (*args, u32 *);
9812 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9816 if (unformat (input, "permit"))
9821 else if (unformat (input, "%d", &tmp))
9830 *miss_next_indexp = next_index;
9835 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9837 u32 *r = va_arg (*args, u32 *);
9839 if (unformat (input, "conform-color"))
9840 *r = POLICE_CONFORM;
9841 else if (unformat (input, "exceed-color"))
9850 api_classify_add_del_table (vat_main_t * vam)
9852 unformat_input_t *i = vam->input;
9853 vl_api_classify_add_del_table_t *mp;
9860 u32 table_index = ~0;
9861 u32 next_table_index = ~0;
9862 u32 miss_next_index = ~0;
9863 u32 memory_size = 32 << 20;
9865 u32 current_data_flag = 0;
9866 int current_data_offset = 0;
9869 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9871 if (unformat (i, "del"))
9873 else if (unformat (i, "del-chain"))
9878 else if (unformat (i, "buckets %d", &nbuckets))
9880 else if (unformat (i, "memory_size %d", &memory_size))
9882 else if (unformat (i, "skip %d", &skip))
9884 else if (unformat (i, "match %d", &match))
9886 else if (unformat (i, "table %d", &table_index))
9888 else if (unformat (i, "mask %U", unformat_classify_mask,
9889 &mask, &skip, &match))
9891 else if (unformat (i, "next-table %d", &next_table_index))
9893 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9896 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9899 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9902 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9904 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9910 if (is_add && mask == 0)
9912 errmsg ("Mask required");
9916 if (is_add && skip == ~0)
9918 errmsg ("skip count required");
9922 if (is_add && match == ~0)
9924 errmsg ("match count required");
9928 if (!is_add && table_index == ~0)
9930 errmsg ("table index required for delete");
9934 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9936 mp->is_add = is_add;
9937 mp->del_chain = del_chain;
9938 mp->table_index = ntohl (table_index);
9939 mp->nbuckets = ntohl (nbuckets);
9940 mp->memory_size = ntohl (memory_size);
9941 mp->skip_n_vectors = ntohl (skip);
9942 mp->match_n_vectors = ntohl (match);
9943 mp->next_table_index = ntohl (next_table_index);
9944 mp->miss_next_index = ntohl (miss_next_index);
9945 mp->current_data_flag = ntohl (current_data_flag);
9946 mp->current_data_offset = ntohl (current_data_offset);
9947 clib_memcpy (mp->mask, mask, vec_len (mask));
9956 #if VPP_API_TEST_BUILTIN == 0
9958 unformat_l4_match (unformat_input_t * input, va_list * args)
9960 u8 **matchp = va_arg (*args, u8 **);
9962 u8 *proto_header = 0;
9968 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9970 if (unformat (input, "src_port %d", &src_port))
9972 else if (unformat (input, "dst_port %d", &dst_port))
9978 h.src_port = clib_host_to_net_u16 (src_port);
9979 h.dst_port = clib_host_to_net_u16 (dst_port);
9980 vec_validate (proto_header, sizeof (h) - 1);
9981 memcpy (proto_header, &h, sizeof (h));
9983 *matchp = proto_header;
9989 unformat_ip4_match (unformat_input_t * input, va_list * args)
9991 u8 **matchp = va_arg (*args, u8 **);
9998 int src = 0, dst = 0;
9999 ip4_address_t src_val, dst_val;
10006 int fragment_id = 0;
10007 u32 fragment_id_val;
10013 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10015 if (unformat (input, "version %d", &version_val))
10017 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10019 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10021 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10023 else if (unformat (input, "proto %d", &proto_val))
10025 else if (unformat (input, "tos %d", &tos_val))
10027 else if (unformat (input, "length %d", &length_val))
10029 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10031 else if (unformat (input, "ttl %d", &ttl_val))
10033 else if (unformat (input, "checksum %d", &checksum_val))
10039 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10040 + ttl + checksum == 0)
10044 * Aligned because we use the real comparison functions
10046 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10048 ip = (ip4_header_t *) match;
10050 /* These are realistically matched in practice */
10052 ip->src_address.as_u32 = src_val.as_u32;
10055 ip->dst_address.as_u32 = dst_val.as_u32;
10058 ip->protocol = proto_val;
10061 /* These are not, but they're included for completeness */
10063 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10066 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10072 ip->length = clib_host_to_net_u16 (length_val);
10078 ip->checksum = clib_host_to_net_u16 (checksum_val);
10085 unformat_ip6_match (unformat_input_t * input, va_list * args)
10087 u8 **matchp = va_arg (*args, u8 **);
10092 u8 traffic_class = 0;
10093 u32 traffic_class_val = 0;
10096 int src = 0, dst = 0;
10097 ip6_address_t src_val, dst_val;
10100 int payload_length = 0;
10101 u32 payload_length_val;
10104 u32 ip_version_traffic_class_and_flow_label;
10106 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10108 if (unformat (input, "version %d", &version_val))
10110 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10112 else if (unformat (input, "flow_label %d", &flow_label_val))
10114 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10116 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10118 else if (unformat (input, "proto %d", &proto_val))
10120 else if (unformat (input, "payload_length %d", &payload_length_val))
10121 payload_length = 1;
10122 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10128 if (version + traffic_class + flow_label + src + dst + proto +
10129 payload_length + hop_limit == 0)
10133 * Aligned because we use the real comparison functions
10135 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10137 ip = (ip6_header_t *) match;
10140 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10143 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10146 ip->protocol = proto_val;
10148 ip_version_traffic_class_and_flow_label = 0;
10151 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10154 ip_version_traffic_class_and_flow_label |=
10155 (traffic_class_val & 0xFF) << 20;
10158 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10160 ip->ip_version_traffic_class_and_flow_label =
10161 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10163 if (payload_length)
10164 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10167 ip->hop_limit = hop_limit_val;
10174 unformat_l3_match (unformat_input_t * input, va_list * args)
10176 u8 **matchp = va_arg (*args, u8 **);
10178 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10180 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10182 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10191 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10193 u8 *tagp = va_arg (*args, u8 *);
10196 if (unformat (input, "%d", &tag))
10198 tagp[0] = (tag >> 8) & 0x0F;
10199 tagp[1] = tag & 0xFF;
10207 unformat_l2_match (unformat_input_t * input, va_list * args)
10209 u8 **matchp = va_arg (*args, u8 **);
10222 u8 ignore_tag1 = 0;
10223 u8 ignore_tag2 = 0;
10229 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10231 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10234 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10236 else if (unformat (input, "proto %U",
10237 unformat_ethernet_type_host_byte_order, &proto_val))
10239 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10241 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10243 else if (unformat (input, "ignore-tag1"))
10245 else if (unformat (input, "ignore-tag2"))
10247 else if (unformat (input, "cos1 %d", &cos1_val))
10249 else if (unformat (input, "cos2 %d", &cos2_val))
10254 if ((src + dst + proto + tag1 + tag2 +
10255 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10258 if (tag1 || ignore_tag1 || cos1)
10260 if (tag2 || ignore_tag2 || cos2)
10263 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10266 clib_memcpy (match, dst_val, 6);
10269 clib_memcpy (match + 6, src_val, 6);
10273 /* inner vlan tag */
10274 match[19] = tag2_val[1];
10275 match[18] = tag2_val[0];
10277 match[18] |= (cos2_val & 0x7) << 5;
10280 match[21] = proto_val & 0xff;
10281 match[20] = proto_val >> 8;
10285 match[15] = tag1_val[1];
10286 match[14] = tag1_val[0];
10289 match[14] |= (cos1_val & 0x7) << 5;
10295 match[15] = tag1_val[1];
10296 match[14] = tag1_val[0];
10299 match[17] = proto_val & 0xff;
10300 match[16] = proto_val >> 8;
10303 match[14] |= (cos1_val & 0x7) << 5;
10309 match[18] |= (cos2_val & 0x7) << 5;
10311 match[14] |= (cos1_val & 0x7) << 5;
10314 match[13] = proto_val & 0xff;
10315 match[12] = proto_val >> 8;
10324 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10326 u8 **matchp = va_arg (*args, u8 **);
10327 u32 skip_n_vectors = va_arg (*args, u32);
10328 u32 match_n_vectors = va_arg (*args, u32);
10335 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10337 if (unformat (input, "hex %U", unformat_hex_string, &match))
10339 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10341 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10343 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10357 if (match || l2 || l3 || l4)
10359 if (l2 || l3 || l4)
10361 /* "Win a free Ethernet header in every packet" */
10363 vec_validate_aligned (l2, 13, sizeof (u32x4));
10367 vec_append_aligned (match, l3, sizeof (u32x4));
10372 vec_append_aligned (match, l4, sizeof (u32x4));
10377 /* Make sure the vector is big enough even if key is all 0's */
10378 vec_validate_aligned
10379 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10382 /* Set size, include skipped vectors */
10383 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10394 api_classify_add_del_session (vat_main_t * vam)
10396 unformat_input_t *i = vam->input;
10397 vl_api_classify_add_del_session_t *mp;
10399 u32 table_index = ~0;
10400 u32 hit_next_index = ~0;
10401 u32 opaque_index = ~0;
10404 u32 skip_n_vectors = 0;
10405 u32 match_n_vectors = 0;
10411 * Warning: you have to supply skip_n and match_n
10412 * because the API client cant simply look at the classify
10416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10418 if (unformat (i, "del"))
10420 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10423 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10426 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10429 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10431 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10433 else if (unformat (i, "opaque-index %d", &opaque_index))
10435 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10437 else if (unformat (i, "match_n %d", &match_n_vectors))
10439 else if (unformat (i, "match %U", api_unformat_classify_match,
10440 &match, skip_n_vectors, match_n_vectors))
10442 else if (unformat (i, "advance %d", &advance))
10444 else if (unformat (i, "table-index %d", &table_index))
10446 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10448 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10450 else if (unformat (i, "action %d", &action))
10452 else if (unformat (i, "metadata %d", &metadata))
10458 if (table_index == ~0)
10460 errmsg ("Table index required");
10464 if (is_add && match == 0)
10466 errmsg ("Match value required");
10470 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10472 mp->is_add = is_add;
10473 mp->table_index = ntohl (table_index);
10474 mp->hit_next_index = ntohl (hit_next_index);
10475 mp->opaque_index = ntohl (opaque_index);
10476 mp->advance = ntohl (advance);
10477 mp->action = action;
10478 mp->metadata = ntohl (metadata);
10479 clib_memcpy (mp->match, match, vec_len (match));
10488 api_classify_set_interface_ip_table (vat_main_t * vam)
10490 unformat_input_t *i = vam->input;
10491 vl_api_classify_set_interface_ip_table_t *mp;
10493 int sw_if_index_set;
10494 u32 table_index = ~0;
10498 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10500 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10501 sw_if_index_set = 1;
10502 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10503 sw_if_index_set = 1;
10504 else if (unformat (i, "table %d", &table_index))
10508 clib_warning ("parse error '%U'", format_unformat_error, i);
10513 if (sw_if_index_set == 0)
10515 errmsg ("missing interface name or sw_if_index");
10520 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10522 mp->sw_if_index = ntohl (sw_if_index);
10523 mp->table_index = ntohl (table_index);
10524 mp->is_ipv6 = is_ipv6;
10532 api_classify_set_interface_l2_tables (vat_main_t * vam)
10534 unformat_input_t *i = vam->input;
10535 vl_api_classify_set_interface_l2_tables_t *mp;
10537 int sw_if_index_set;
10538 u32 ip4_table_index = ~0;
10539 u32 ip6_table_index = ~0;
10540 u32 other_table_index = ~0;
10544 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10546 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10547 sw_if_index_set = 1;
10548 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10549 sw_if_index_set = 1;
10550 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10552 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10554 else if (unformat (i, "other-table %d", &other_table_index))
10556 else if (unformat (i, "is-input %d", &is_input))
10560 clib_warning ("parse error '%U'", format_unformat_error, i);
10565 if (sw_if_index_set == 0)
10567 errmsg ("missing interface name or sw_if_index");
10572 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10574 mp->sw_if_index = ntohl (sw_if_index);
10575 mp->ip4_table_index = ntohl (ip4_table_index);
10576 mp->ip6_table_index = ntohl (ip6_table_index);
10577 mp->other_table_index = ntohl (other_table_index);
10578 mp->is_input = (u8) is_input;
10586 api_set_ipfix_exporter (vat_main_t * vam)
10588 unformat_input_t *i = vam->input;
10589 vl_api_set_ipfix_exporter_t *mp;
10590 ip4_address_t collector_address;
10591 u8 collector_address_set = 0;
10592 u32 collector_port = ~0;
10593 ip4_address_t src_address;
10594 u8 src_address_set = 0;
10597 u32 template_interval = ~0;
10598 u8 udp_checksum = 0;
10601 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10603 if (unformat (i, "collector_address %U", unformat_ip4_address,
10604 &collector_address))
10605 collector_address_set = 1;
10606 else if (unformat (i, "collector_port %d", &collector_port))
10608 else if (unformat (i, "src_address %U", unformat_ip4_address,
10610 src_address_set = 1;
10611 else if (unformat (i, "vrf_id %d", &vrf_id))
10613 else if (unformat (i, "path_mtu %d", &path_mtu))
10615 else if (unformat (i, "template_interval %d", &template_interval))
10617 else if (unformat (i, "udp_checksum"))
10623 if (collector_address_set == 0)
10625 errmsg ("collector_address required");
10629 if (src_address_set == 0)
10631 errmsg ("src_address required");
10635 M (SET_IPFIX_EXPORTER, mp);
10637 memcpy (mp->collector_address, collector_address.data,
10638 sizeof (collector_address.data));
10639 mp->collector_port = htons ((u16) collector_port);
10640 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10641 mp->vrf_id = htonl (vrf_id);
10642 mp->path_mtu = htonl (path_mtu);
10643 mp->template_interval = htonl (template_interval);
10644 mp->udp_checksum = udp_checksum;
10652 api_set_ipfix_classify_stream (vat_main_t * vam)
10654 unformat_input_t *i = vam->input;
10655 vl_api_set_ipfix_classify_stream_t *mp;
10657 u32 src_port = UDP_DST_PORT_ipfix;
10660 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10662 if (unformat (i, "domain %d", &domain_id))
10664 else if (unformat (i, "src_port %d", &src_port))
10668 errmsg ("unknown input `%U'", format_unformat_error, i);
10673 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10675 mp->domain_id = htonl (domain_id);
10676 mp->src_port = htons ((u16) src_port);
10684 api_ipfix_classify_table_add_del (vat_main_t * vam)
10686 unformat_input_t *i = vam->input;
10687 vl_api_ipfix_classify_table_add_del_t *mp;
10689 u32 classify_table_index = ~0;
10691 u8 transport_protocol = 255;
10694 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10696 if (unformat (i, "add"))
10698 else if (unformat (i, "del"))
10700 else if (unformat (i, "table %d", &classify_table_index))
10702 else if (unformat (i, "ip4"))
10704 else if (unformat (i, "ip6"))
10706 else if (unformat (i, "tcp"))
10707 transport_protocol = 6;
10708 else if (unformat (i, "udp"))
10709 transport_protocol = 17;
10712 errmsg ("unknown input `%U'", format_unformat_error, i);
10719 errmsg ("expecting: add|del");
10722 if (classify_table_index == ~0)
10724 errmsg ("classifier table not specified");
10727 if (ip_version == 0)
10729 errmsg ("IP version not specified");
10733 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10735 mp->is_add = is_add;
10736 mp->table_id = htonl (classify_table_index);
10737 mp->ip_version = ip_version;
10738 mp->transport_protocol = transport_protocol;
10746 api_get_node_index (vat_main_t * vam)
10748 unformat_input_t *i = vam->input;
10749 vl_api_get_node_index_t *mp;
10753 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10755 if (unformat (i, "node %s", &name))
10762 errmsg ("node name required");
10765 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10767 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10771 M (GET_NODE_INDEX, mp);
10772 clib_memcpy (mp->node_name, name, vec_len (name));
10781 api_get_next_index (vat_main_t * vam)
10783 unformat_input_t *i = vam->input;
10784 vl_api_get_next_index_t *mp;
10785 u8 *node_name = 0, *next_node_name = 0;
10788 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10790 if (unformat (i, "node-name %s", &node_name))
10792 else if (unformat (i, "next-node-name %s", &next_node_name))
10796 if (node_name == 0)
10798 errmsg ("node name required");
10801 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10803 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10807 if (next_node_name == 0)
10809 errmsg ("next node name required");
10812 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10814 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10818 M (GET_NEXT_INDEX, mp);
10819 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10820 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10821 vec_free (node_name);
10822 vec_free (next_node_name);
10830 api_add_node_next (vat_main_t * vam)
10832 unformat_input_t *i = vam->input;
10833 vl_api_add_node_next_t *mp;
10838 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10840 if (unformat (i, "node %s", &name))
10842 else if (unformat (i, "next %s", &next))
10849 errmsg ("node name required");
10852 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10854 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10859 errmsg ("next node required");
10862 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10864 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10868 M (ADD_NODE_NEXT, mp);
10869 clib_memcpy (mp->node_name, name, vec_len (name));
10870 clib_memcpy (mp->next_name, next, vec_len (next));
10880 api_l2tpv3_create_tunnel (vat_main_t * vam)
10882 unformat_input_t *i = vam->input;
10883 ip6_address_t client_address, our_address;
10884 int client_address_set = 0;
10885 int our_address_set = 0;
10886 u32 local_session_id = 0;
10887 u32 remote_session_id = 0;
10888 u64 local_cookie = 0;
10889 u64 remote_cookie = 0;
10890 u8 l2_sublayer_present = 0;
10891 vl_api_l2tpv3_create_tunnel_t *mp;
10894 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10896 if (unformat (i, "client_address %U", unformat_ip6_address,
10898 client_address_set = 1;
10899 else if (unformat (i, "our_address %U", unformat_ip6_address,
10901 our_address_set = 1;
10902 else if (unformat (i, "local_session_id %d", &local_session_id))
10904 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10906 else if (unformat (i, "local_cookie %lld", &local_cookie))
10908 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10910 else if (unformat (i, "l2-sublayer-present"))
10911 l2_sublayer_present = 1;
10916 if (client_address_set == 0)
10918 errmsg ("client_address required");
10922 if (our_address_set == 0)
10924 errmsg ("our_address required");
10928 M (L2TPV3_CREATE_TUNNEL, mp);
10930 clib_memcpy (mp->client_address, client_address.as_u8,
10931 sizeof (mp->client_address));
10933 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10935 mp->local_session_id = ntohl (local_session_id);
10936 mp->remote_session_id = ntohl (remote_session_id);
10937 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10938 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10939 mp->l2_sublayer_present = l2_sublayer_present;
10948 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10950 unformat_input_t *i = vam->input;
10952 u8 sw_if_index_set = 0;
10953 u64 new_local_cookie = 0;
10954 u64 new_remote_cookie = 0;
10955 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10960 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10961 sw_if_index_set = 1;
10962 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10963 sw_if_index_set = 1;
10964 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10966 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10972 if (sw_if_index_set == 0)
10974 errmsg ("missing interface name or sw_if_index");
10978 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10980 mp->sw_if_index = ntohl (sw_if_index);
10981 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10982 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10990 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10992 unformat_input_t *i = vam->input;
10993 vl_api_l2tpv3_interface_enable_disable_t *mp;
10995 u8 sw_if_index_set = 0;
10996 u8 enable_disable = 1;
10999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11001 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11002 sw_if_index_set = 1;
11003 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11004 sw_if_index_set = 1;
11005 else if (unformat (i, "enable"))
11006 enable_disable = 1;
11007 else if (unformat (i, "disable"))
11008 enable_disable = 0;
11013 if (sw_if_index_set == 0)
11015 errmsg ("missing interface name or sw_if_index");
11019 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11021 mp->sw_if_index = ntohl (sw_if_index);
11022 mp->enable_disable = enable_disable;
11030 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11032 unformat_input_t *i = vam->input;
11033 vl_api_l2tpv3_set_lookup_key_t *mp;
11037 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11039 if (unformat (i, "lookup_v6_src"))
11040 key = L2T_LOOKUP_SRC_ADDRESS;
11041 else if (unformat (i, "lookup_v6_dst"))
11042 key = L2T_LOOKUP_DST_ADDRESS;
11043 else if (unformat (i, "lookup_session_id"))
11044 key = L2T_LOOKUP_SESSION_ID;
11049 if (key == (u8) ~ 0)
11051 errmsg ("l2tp session lookup key unset");
11055 M (L2TPV3_SET_LOOKUP_KEY, mp);
11064 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11065 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11067 vat_main_t *vam = &vat_main;
11069 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11070 format_ip6_address, mp->our_address,
11071 format_ip6_address, mp->client_address,
11072 clib_net_to_host_u32 (mp->sw_if_index));
11075 " local cookies %016llx %016llx remote cookie %016llx",
11076 clib_net_to_host_u64 (mp->local_cookie[0]),
11077 clib_net_to_host_u64 (mp->local_cookie[1]),
11078 clib_net_to_host_u64 (mp->remote_cookie));
11080 print (vam->ofp, " local session-id %d remote session-id %d",
11081 clib_net_to_host_u32 (mp->local_session_id),
11082 clib_net_to_host_u32 (mp->remote_session_id));
11084 print (vam->ofp, " l2 specific sublayer %s\n",
11085 mp->l2_sublayer_present ? "preset" : "absent");
11089 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11090 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11092 vat_main_t *vam = &vat_main;
11093 vat_json_node_t *node = NULL;
11094 struct in6_addr addr;
11096 if (VAT_JSON_ARRAY != vam->json_tree.type)
11098 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11099 vat_json_init_array (&vam->json_tree);
11101 node = vat_json_array_add (&vam->json_tree);
11103 vat_json_init_object (node);
11105 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11106 vat_json_object_add_ip6 (node, "our_address", addr);
11107 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11108 vat_json_object_add_ip6 (node, "client_address", addr);
11110 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11111 vat_json_init_array (lc);
11112 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11113 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11114 vat_json_object_add_uint (node, "remote_cookie",
11115 clib_net_to_host_u64 (mp->remote_cookie));
11117 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11118 vat_json_object_add_uint (node, "local_session_id",
11119 clib_net_to_host_u32 (mp->local_session_id));
11120 vat_json_object_add_uint (node, "remote_session_id",
11121 clib_net_to_host_u32 (mp->remote_session_id));
11122 vat_json_object_add_string_copy (node, "l2_sublayer",
11123 mp->l2_sublayer_present ? (u8 *) "present"
11124 : (u8 *) "absent");
11128 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11130 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11131 vl_api_control_ping_t *mp_ping;
11134 /* Get list of l2tpv3-tunnel interfaces */
11135 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11138 /* Use a control ping for synchronization */
11139 M (CONTROL_PING, mp_ping);
11147 static void vl_api_sw_interface_tap_details_t_handler
11148 (vl_api_sw_interface_tap_details_t * mp)
11150 vat_main_t *vam = &vat_main;
11152 print (vam->ofp, "%-16s %d",
11153 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
11156 static void vl_api_sw_interface_tap_details_t_handler_json
11157 (vl_api_sw_interface_tap_details_t * mp)
11159 vat_main_t *vam = &vat_main;
11160 vat_json_node_t *node = NULL;
11162 if (VAT_JSON_ARRAY != vam->json_tree.type)
11164 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11165 vat_json_init_array (&vam->json_tree);
11167 node = vat_json_array_add (&vam->json_tree);
11169 vat_json_init_object (node);
11170 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11171 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11175 api_sw_interface_tap_dump (vat_main_t * vam)
11177 vl_api_sw_interface_tap_dump_t *mp;
11178 vl_api_control_ping_t *mp_ping;
11181 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
11182 /* Get list of tap interfaces */
11183 M (SW_INTERFACE_TAP_DUMP, mp);
11186 /* Use a control ping for synchronization */
11187 M (CONTROL_PING, mp_ping);
11194 static uword unformat_vxlan_decap_next
11195 (unformat_input_t * input, va_list * args)
11197 u32 *result = va_arg (*args, u32 *);
11200 if (unformat (input, "l2"))
11201 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11202 else if (unformat (input, "%d", &tmp))
11210 api_vxlan_add_del_tunnel (vat_main_t * vam)
11212 unformat_input_t *line_input = vam->input;
11213 vl_api_vxlan_add_del_tunnel_t *mp;
11214 ip46_address_t src, dst;
11216 u8 ipv4_set = 0, ipv6_set = 0;
11220 u32 mcast_sw_if_index = ~0;
11221 u32 encap_vrf_id = 0;
11222 u32 decap_next_index = ~0;
11226 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11227 memset (&src, 0, sizeof src);
11228 memset (&dst, 0, sizeof dst);
11230 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11232 if (unformat (line_input, "del"))
11235 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11241 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11247 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11253 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11258 else if (unformat (line_input, "group %U %U",
11259 unformat_ip4_address, &dst.ip4,
11260 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11262 grp_set = dst_set = 1;
11265 else if (unformat (line_input, "group %U",
11266 unformat_ip4_address, &dst.ip4))
11268 grp_set = dst_set = 1;
11271 else if (unformat (line_input, "group %U %U",
11272 unformat_ip6_address, &dst.ip6,
11273 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11275 grp_set = dst_set = 1;
11278 else if (unformat (line_input, "group %U",
11279 unformat_ip6_address, &dst.ip6))
11281 grp_set = dst_set = 1;
11285 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11287 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11289 else if (unformat (line_input, "decap-next %U",
11290 unformat_vxlan_decap_next, &decap_next_index))
11292 else if (unformat (line_input, "vni %d", &vni))
11296 errmsg ("parse error '%U'", format_unformat_error, line_input);
11303 errmsg ("tunnel src address not specified");
11308 errmsg ("tunnel dst address not specified");
11312 if (grp_set && !ip46_address_is_multicast (&dst))
11314 errmsg ("tunnel group address not multicast");
11317 if (grp_set && mcast_sw_if_index == ~0)
11319 errmsg ("tunnel nonexistent multicast device");
11322 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11324 errmsg ("tunnel dst address must be unicast");
11329 if (ipv4_set && ipv6_set)
11331 errmsg ("both IPv4 and IPv6 addresses specified");
11335 if ((vni == 0) || (vni >> 24))
11337 errmsg ("vni not specified or out of range");
11341 M (VXLAN_ADD_DEL_TUNNEL, mp);
11345 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
11346 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
11350 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
11351 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
11353 mp->encap_vrf_id = ntohl (encap_vrf_id);
11354 mp->decap_next_index = ntohl (decap_next_index);
11355 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11356 mp->vni = ntohl (vni);
11357 mp->is_add = is_add;
11358 mp->is_ipv6 = ipv6_set;
11365 static void vl_api_vxlan_tunnel_details_t_handler
11366 (vl_api_vxlan_tunnel_details_t * mp)
11368 vat_main_t *vam = &vat_main;
11369 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
11370 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
11372 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
11373 ntohl (mp->sw_if_index),
11374 format_ip46_address, &src, IP46_TYPE_ANY,
11375 format_ip46_address, &dst, IP46_TYPE_ANY,
11376 ntohl (mp->encap_vrf_id),
11377 ntohl (mp->decap_next_index), ntohl (mp->vni),
11378 ntohl (mp->mcast_sw_if_index));
11381 static void vl_api_vxlan_tunnel_details_t_handler_json
11382 (vl_api_vxlan_tunnel_details_t * mp)
11384 vat_main_t *vam = &vat_main;
11385 vat_json_node_t *node = NULL;
11387 if (VAT_JSON_ARRAY != vam->json_tree.type)
11389 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11390 vat_json_init_array (&vam->json_tree);
11392 node = vat_json_array_add (&vam->json_tree);
11394 vat_json_init_object (node);
11395 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11398 struct in6_addr ip6;
11400 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
11401 vat_json_object_add_ip6 (node, "src_address", ip6);
11402 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
11403 vat_json_object_add_ip6 (node, "dst_address", ip6);
11407 struct in_addr ip4;
11409 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
11410 vat_json_object_add_ip4 (node, "src_address", ip4);
11411 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
11412 vat_json_object_add_ip4 (node, "dst_address", ip4);
11414 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11415 vat_json_object_add_uint (node, "decap_next_index",
11416 ntohl (mp->decap_next_index));
11417 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11418 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11419 vat_json_object_add_uint (node, "mcast_sw_if_index",
11420 ntohl (mp->mcast_sw_if_index));
11424 api_vxlan_tunnel_dump (vat_main_t * vam)
11426 unformat_input_t *i = vam->input;
11427 vl_api_vxlan_tunnel_dump_t *mp;
11428 vl_api_control_ping_t *mp_ping;
11430 u8 sw_if_index_set = 0;
11433 /* Parse args required to build the message */
11434 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11436 if (unformat (i, "sw_if_index %d", &sw_if_index))
11437 sw_if_index_set = 1;
11442 if (sw_if_index_set == 0)
11447 if (!vam->json_output)
11449 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
11450 "sw_if_index", "src_address", "dst_address",
11451 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11454 /* Get list of vxlan-tunnel interfaces */
11455 M (VXLAN_TUNNEL_DUMP, mp);
11457 mp->sw_if_index = htonl (sw_if_index);
11461 /* Use a control ping for synchronization */
11462 M (CONTROL_PING, mp_ping);
11470 api_gre_add_del_tunnel (vat_main_t * vam)
11472 unformat_input_t *line_input = vam->input;
11473 vl_api_gre_add_del_tunnel_t *mp;
11474 ip4_address_t src4, dst4;
11475 ip6_address_t src6, dst6;
11482 u32 outer_fib_id = 0;
11485 memset (&src4, 0, sizeof src4);
11486 memset (&dst4, 0, sizeof dst4);
11487 memset (&src6, 0, sizeof src6);
11488 memset (&dst6, 0, sizeof dst6);
11490 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11492 if (unformat (line_input, "del"))
11494 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
11499 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
11504 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
11509 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
11514 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
11516 else if (unformat (line_input, "teb"))
11520 errmsg ("parse error '%U'", format_unformat_error, line_input);
11527 errmsg ("tunnel src address not specified");
11532 errmsg ("tunnel dst address not specified");
11535 if (ipv4_set && ipv6_set)
11537 errmsg ("both IPv4 and IPv6 addresses specified");
11542 M (GRE_ADD_DEL_TUNNEL, mp);
11546 clib_memcpy (&mp->src_address, &src4, 4);
11547 clib_memcpy (&mp->dst_address, &dst4, 4);
11551 clib_memcpy (&mp->src_address, &src6, 16);
11552 clib_memcpy (&mp->dst_address, &dst6, 16);
11554 mp->outer_fib_id = ntohl (outer_fib_id);
11555 mp->is_add = is_add;
11557 mp->is_ipv6 = ipv6_set;
11564 static void vl_api_gre_tunnel_details_t_handler
11565 (vl_api_gre_tunnel_details_t * mp)
11567 vat_main_t *vam = &vat_main;
11568 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
11569 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
11571 print (vam->ofp, "%11d%24U%24U%6d%14d",
11572 ntohl (mp->sw_if_index),
11573 format_ip46_address, &src, IP46_TYPE_ANY,
11574 format_ip46_address, &dst, IP46_TYPE_ANY,
11575 mp->teb, ntohl (mp->outer_fib_id));
11578 static void vl_api_gre_tunnel_details_t_handler_json
11579 (vl_api_gre_tunnel_details_t * mp)
11581 vat_main_t *vam = &vat_main;
11582 vat_json_node_t *node = NULL;
11583 struct in_addr ip4;
11584 struct in6_addr ip6;
11586 if (VAT_JSON_ARRAY != vam->json_tree.type)
11588 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11589 vat_json_init_array (&vam->json_tree);
11591 node = vat_json_array_add (&vam->json_tree);
11593 vat_json_init_object (node);
11594 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11597 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11598 vat_json_object_add_ip4 (node, "src_address", ip4);
11599 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11600 vat_json_object_add_ip4 (node, "dst_address", ip4);
11604 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
11605 vat_json_object_add_ip6 (node, "src_address", ip6);
11606 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
11607 vat_json_object_add_ip6 (node, "dst_address", ip6);
11609 vat_json_object_add_uint (node, "teb", mp->teb);
11610 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11611 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
11615 api_gre_tunnel_dump (vat_main_t * vam)
11617 unformat_input_t *i = vam->input;
11618 vl_api_gre_tunnel_dump_t *mp;
11619 vl_api_control_ping_t *mp_ping;
11621 u8 sw_if_index_set = 0;
11624 /* Parse args required to build the message */
11625 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11627 if (unformat (i, "sw_if_index %d", &sw_if_index))
11628 sw_if_index_set = 1;
11633 if (sw_if_index_set == 0)
11638 if (!vam->json_output)
11640 print (vam->ofp, "%11s%24s%24s%6s%14s",
11641 "sw_if_index", "src_address", "dst_address", "teb",
11645 /* Get list of gre-tunnel interfaces */
11646 M (GRE_TUNNEL_DUMP, mp);
11648 mp->sw_if_index = htonl (sw_if_index);
11652 /* Use a control ping for synchronization */
11653 M (CONTROL_PING, mp_ping);
11661 api_l2_fib_clear_table (vat_main_t * vam)
11663 // unformat_input_t * i = vam->input;
11664 vl_api_l2_fib_clear_table_t *mp;
11667 M (L2_FIB_CLEAR_TABLE, mp);
11675 api_l2_interface_efp_filter (vat_main_t * vam)
11677 unformat_input_t *i = vam->input;
11678 vl_api_l2_interface_efp_filter_t *mp;
11681 u8 sw_if_index_set = 0;
11684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11686 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11687 sw_if_index_set = 1;
11688 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11689 sw_if_index_set = 1;
11690 else if (unformat (i, "enable"))
11692 else if (unformat (i, "disable"))
11696 clib_warning ("parse error '%U'", format_unformat_error, i);
11701 if (sw_if_index_set == 0)
11703 errmsg ("missing sw_if_index");
11707 M (L2_INTERFACE_EFP_FILTER, mp);
11709 mp->sw_if_index = ntohl (sw_if_index);
11710 mp->enable_disable = enable;
11717 #define foreach_vtr_op \
11718 _("disable", L2_VTR_DISABLED) \
11719 _("push-1", L2_VTR_PUSH_1) \
11720 _("push-2", L2_VTR_PUSH_2) \
11721 _("pop-1", L2_VTR_POP_1) \
11722 _("pop-2", L2_VTR_POP_2) \
11723 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11724 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11725 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11726 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11729 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11731 unformat_input_t *i = vam->input;
11732 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11734 u8 sw_if_index_set = 0;
11737 u32 push_dot1q = 1;
11742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11744 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11745 sw_if_index_set = 1;
11746 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11747 sw_if_index_set = 1;
11748 else if (unformat (i, "vtr_op %d", &vtr_op))
11750 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11753 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11755 else if (unformat (i, "tag1 %d", &tag1))
11757 else if (unformat (i, "tag2 %d", &tag2))
11761 clib_warning ("parse error '%U'", format_unformat_error, i);
11766 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11768 errmsg ("missing vtr operation or sw_if_index");
11772 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11773 mp->sw_if_index = ntohl (sw_if_index);
11774 mp->vtr_op = ntohl (vtr_op);
11775 mp->push_dot1q = ntohl (push_dot1q);
11776 mp->tag1 = ntohl (tag1);
11777 mp->tag2 = ntohl (tag2);
11785 api_create_vhost_user_if (vat_main_t * vam)
11787 unformat_input_t *i = vam->input;
11788 vl_api_create_vhost_user_if_t *mp;
11791 u8 file_name_set = 0;
11792 u32 custom_dev_instance = ~0;
11794 u8 use_custom_mac = 0;
11798 /* Shut up coverity */
11799 memset (hwaddr, 0, sizeof (hwaddr));
11801 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11803 if (unformat (i, "socket %s", &file_name))
11807 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11809 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11810 use_custom_mac = 1;
11811 else if (unformat (i, "server"))
11813 else if (unformat (i, "tag %s", &tag))
11819 if (file_name_set == 0)
11821 errmsg ("missing socket file name");
11825 if (vec_len (file_name) > 255)
11827 errmsg ("socket file name too long");
11830 vec_add1 (file_name, 0);
11832 M (CREATE_VHOST_USER_IF, mp);
11834 mp->is_server = is_server;
11835 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11836 vec_free (file_name);
11837 if (custom_dev_instance != ~0)
11840 mp->custom_dev_instance = ntohl (custom_dev_instance);
11842 mp->use_custom_mac = use_custom_mac;
11843 clib_memcpy (mp->mac_address, hwaddr, 6);
11845 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11854 api_modify_vhost_user_if (vat_main_t * vam)
11856 unformat_input_t *i = vam->input;
11857 vl_api_modify_vhost_user_if_t *mp;
11860 u8 file_name_set = 0;
11861 u32 custom_dev_instance = ~0;
11862 u8 sw_if_index_set = 0;
11863 u32 sw_if_index = (u32) ~ 0;
11866 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11868 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11869 sw_if_index_set = 1;
11870 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11871 sw_if_index_set = 1;
11872 else if (unformat (i, "socket %s", &file_name))
11876 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11878 else if (unformat (i, "server"))
11884 if (sw_if_index_set == 0)
11886 errmsg ("missing sw_if_index or interface name");
11890 if (file_name_set == 0)
11892 errmsg ("missing socket file name");
11896 if (vec_len (file_name) > 255)
11898 errmsg ("socket file name too long");
11901 vec_add1 (file_name, 0);
11903 M (MODIFY_VHOST_USER_IF, mp);
11905 mp->sw_if_index = ntohl (sw_if_index);
11906 mp->is_server = is_server;
11907 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11908 vec_free (file_name);
11909 if (custom_dev_instance != ~0)
11912 mp->custom_dev_instance = ntohl (custom_dev_instance);
11921 api_delete_vhost_user_if (vat_main_t * vam)
11923 unformat_input_t *i = vam->input;
11924 vl_api_delete_vhost_user_if_t *mp;
11925 u32 sw_if_index = ~0;
11926 u8 sw_if_index_set = 0;
11929 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11931 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11932 sw_if_index_set = 1;
11933 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11934 sw_if_index_set = 1;
11939 if (sw_if_index_set == 0)
11941 errmsg ("missing sw_if_index or interface name");
11946 M (DELETE_VHOST_USER_IF, mp);
11948 mp->sw_if_index = ntohl (sw_if_index);
11955 static void vl_api_sw_interface_vhost_user_details_t_handler
11956 (vl_api_sw_interface_vhost_user_details_t * mp)
11958 vat_main_t *vam = &vat_main;
11960 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11961 (char *) mp->interface_name,
11962 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11963 clib_net_to_host_u64 (mp->features), mp->is_server,
11964 ntohl (mp->num_regions), (char *) mp->sock_filename);
11965 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11968 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11969 (vl_api_sw_interface_vhost_user_details_t * mp)
11971 vat_main_t *vam = &vat_main;
11972 vat_json_node_t *node = NULL;
11974 if (VAT_JSON_ARRAY != vam->json_tree.type)
11976 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11977 vat_json_init_array (&vam->json_tree);
11979 node = vat_json_array_add (&vam->json_tree);
11981 vat_json_init_object (node);
11982 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11983 vat_json_object_add_string_copy (node, "interface_name",
11984 mp->interface_name);
11985 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11986 ntohl (mp->virtio_net_hdr_sz));
11987 vat_json_object_add_uint (node, "features",
11988 clib_net_to_host_u64 (mp->features));
11989 vat_json_object_add_uint (node, "is_server", mp->is_server);
11990 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11991 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11992 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11996 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11998 vl_api_sw_interface_vhost_user_dump_t *mp;
11999 vl_api_control_ping_t *mp_ping;
12002 "Interface name idx hdr_sz features server regions filename");
12004 /* Get list of vhost-user interfaces */
12005 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12008 /* Use a control ping for synchronization */
12009 M (CONTROL_PING, mp_ping);
12017 api_show_version (vat_main_t * vam)
12019 vl_api_show_version_t *mp;
12022 M (SHOW_VERSION, mp);
12031 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12033 unformat_input_t *line_input = vam->input;
12034 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12035 ip4_address_t local4, remote4;
12036 ip6_address_t local6, remote6;
12038 u8 ipv4_set = 0, ipv6_set = 0;
12042 u32 mcast_sw_if_index = ~0;
12043 u32 encap_vrf_id = 0;
12044 u32 decap_vrf_id = 0;
12050 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12051 memset (&local4, 0, sizeof local4);
12052 memset (&remote4, 0, sizeof remote4);
12053 memset (&local6, 0, sizeof local6);
12054 memset (&remote6, 0, sizeof remote6);
12056 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12058 if (unformat (line_input, "del"))
12060 else if (unformat (line_input, "local %U",
12061 unformat_ip4_address, &local4))
12066 else if (unformat (line_input, "remote %U",
12067 unformat_ip4_address, &remote4))
12072 else if (unformat (line_input, "local %U",
12073 unformat_ip6_address, &local6))
12078 else if (unformat (line_input, "remote %U",
12079 unformat_ip6_address, &remote6))
12084 else if (unformat (line_input, "group %U %U",
12085 unformat_ip4_address, &remote4,
12086 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12088 grp_set = remote_set = 1;
12091 else if (unformat (line_input, "group %U",
12092 unformat_ip4_address, &remote4))
12094 grp_set = remote_set = 1;
12097 else if (unformat (line_input, "group %U %U",
12098 unformat_ip6_address, &remote6,
12099 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12101 grp_set = remote_set = 1;
12104 else if (unformat (line_input, "group %U",
12105 unformat_ip6_address, &remote6))
12107 grp_set = remote_set = 1;
12111 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12113 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12115 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
12117 else if (unformat (line_input, "vni %d", &vni))
12119 else if (unformat (line_input, "next-ip4"))
12121 else if (unformat (line_input, "next-ip6"))
12123 else if (unformat (line_input, "next-ethernet"))
12125 else if (unformat (line_input, "next-nsh"))
12129 errmsg ("parse error '%U'", format_unformat_error, line_input);
12134 if (local_set == 0)
12136 errmsg ("tunnel local address not specified");
12139 if (remote_set == 0)
12141 errmsg ("tunnel remote address not specified");
12144 if (grp_set && mcast_sw_if_index == ~0)
12146 errmsg ("tunnel nonexistent multicast device");
12149 if (ipv4_set && ipv6_set)
12151 errmsg ("both IPv4 and IPv6 addresses specified");
12157 errmsg ("vni not specified");
12161 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
12166 clib_memcpy (&mp->local, &local6, sizeof (local6));
12167 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
12171 clib_memcpy (&mp->local, &local4, sizeof (local4));
12172 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
12175 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12176 mp->encap_vrf_id = ntohl (encap_vrf_id);
12177 mp->decap_vrf_id = ntohl (decap_vrf_id);
12178 mp->protocol = protocol;
12179 mp->vni = ntohl (vni);
12180 mp->is_add = is_add;
12181 mp->is_ipv6 = ipv6_set;
12188 static void vl_api_vxlan_gpe_tunnel_details_t_handler
12189 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12191 vat_main_t *vam = &vat_main;
12192 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
12193 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
12195 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
12196 ntohl (mp->sw_if_index),
12197 format_ip46_address, &local, IP46_TYPE_ANY,
12198 format_ip46_address, &remote, IP46_TYPE_ANY,
12199 ntohl (mp->vni), mp->protocol,
12200 ntohl (mp->mcast_sw_if_index),
12201 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
12205 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
12206 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12208 vat_main_t *vam = &vat_main;
12209 vat_json_node_t *node = NULL;
12210 struct in_addr ip4;
12211 struct in6_addr ip6;
12213 if (VAT_JSON_ARRAY != vam->json_tree.type)
12215 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12216 vat_json_init_array (&vam->json_tree);
12218 node = vat_json_array_add (&vam->json_tree);
12220 vat_json_init_object (node);
12221 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12224 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
12225 vat_json_object_add_ip6 (node, "local", ip6);
12226 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
12227 vat_json_object_add_ip6 (node, "remote", ip6);
12231 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
12232 vat_json_object_add_ip4 (node, "local", ip4);
12233 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
12234 vat_json_object_add_ip4 (node, "remote", ip4);
12236 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12237 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
12238 vat_json_object_add_uint (node, "mcast_sw_if_index",
12239 ntohl (mp->mcast_sw_if_index));
12240 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12241 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
12242 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12246 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
12248 unformat_input_t *i = vam->input;
12249 vl_api_vxlan_gpe_tunnel_dump_t *mp;
12250 vl_api_control_ping_t *mp_ping;
12252 u8 sw_if_index_set = 0;
12255 /* Parse args required to build the message */
12256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12258 if (unformat (i, "sw_if_index %d", &sw_if_index))
12259 sw_if_index_set = 1;
12264 if (sw_if_index_set == 0)
12269 if (!vam->json_output)
12271 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
12272 "sw_if_index", "local", "remote", "vni",
12273 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
12276 /* Get list of vxlan-tunnel interfaces */
12277 M (VXLAN_GPE_TUNNEL_DUMP, mp);
12279 mp->sw_if_index = htonl (sw_if_index);
12283 /* Use a control ping for synchronization */
12284 M (CONTROL_PING, mp_ping);
12293 format_l2_fib_mac_address (u8 * s, va_list * args)
12295 u8 *a = va_arg (*args, u8 *);
12297 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
12298 a[2], a[3], a[4], a[5], a[6], a[7]);
12301 static void vl_api_l2_fib_table_details_t_handler
12302 (vl_api_l2_fib_table_details_t * mp)
12304 vat_main_t *vam = &vat_main;
12306 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
12308 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
12309 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
12313 static void vl_api_l2_fib_table_details_t_handler_json
12314 (vl_api_l2_fib_table_details_t * mp)
12316 vat_main_t *vam = &vat_main;
12317 vat_json_node_t *node = NULL;
12319 if (VAT_JSON_ARRAY != vam->json_tree.type)
12321 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12322 vat_json_init_array (&vam->json_tree);
12324 node = vat_json_array_add (&vam->json_tree);
12326 vat_json_init_object (node);
12327 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
12328 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
12329 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12330 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
12331 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
12332 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
12336 api_l2_fib_table_dump (vat_main_t * vam)
12338 unformat_input_t *i = vam->input;
12339 vl_api_l2_fib_table_dump_t *mp;
12340 vl_api_control_ping_t *mp_ping;
12345 /* Parse args required to build the message */
12346 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12348 if (unformat (i, "bd_id %d", &bd_id))
12354 if (bd_id_set == 0)
12356 errmsg ("missing bridge domain");
12360 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
12362 /* Get list of l2 fib entries */
12363 M (L2_FIB_TABLE_DUMP, mp);
12365 mp->bd_id = ntohl (bd_id);
12368 /* Use a control ping for synchronization */
12369 M (CONTROL_PING, mp_ping);
12378 api_interface_name_renumber (vat_main_t * vam)
12380 unformat_input_t *line_input = vam->input;
12381 vl_api_interface_name_renumber_t *mp;
12382 u32 sw_if_index = ~0;
12383 u32 new_show_dev_instance = ~0;
12386 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12388 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
12391 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12393 else if (unformat (line_input, "new_show_dev_instance %d",
12394 &new_show_dev_instance))
12400 if (sw_if_index == ~0)
12402 errmsg ("missing interface name or sw_if_index");
12406 if (new_show_dev_instance == ~0)
12408 errmsg ("missing new_show_dev_instance");
12412 M (INTERFACE_NAME_RENUMBER, mp);
12414 mp->sw_if_index = ntohl (sw_if_index);
12415 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
12423 api_want_ip4_arp_events (vat_main_t * vam)
12425 unformat_input_t *line_input = vam->input;
12426 vl_api_want_ip4_arp_events_t *mp;
12427 ip4_address_t address;
12428 int address_set = 0;
12429 u32 enable_disable = 1;
12432 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12434 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
12436 else if (unformat (line_input, "del"))
12437 enable_disable = 0;
12442 if (address_set == 0)
12444 errmsg ("missing addresses");
12448 M (WANT_IP4_ARP_EVENTS, mp);
12449 mp->enable_disable = enable_disable;
12450 mp->pid = htonl (getpid ());
12451 mp->address = address.as_u32;
12459 api_want_ip6_nd_events (vat_main_t * vam)
12461 unformat_input_t *line_input = vam->input;
12462 vl_api_want_ip6_nd_events_t *mp;
12463 ip6_address_t address;
12464 int address_set = 0;
12465 u32 enable_disable = 1;
12468 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12470 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
12472 else if (unformat (line_input, "del"))
12473 enable_disable = 0;
12478 if (address_set == 0)
12480 errmsg ("missing addresses");
12484 M (WANT_IP6_ND_EVENTS, mp);
12485 mp->enable_disable = enable_disable;
12486 mp->pid = htonl (getpid ());
12487 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
12495 api_input_acl_set_interface (vat_main_t * vam)
12497 unformat_input_t *i = vam->input;
12498 vl_api_input_acl_set_interface_t *mp;
12500 int sw_if_index_set;
12501 u32 ip4_table_index = ~0;
12502 u32 ip6_table_index = ~0;
12503 u32 l2_table_index = ~0;
12507 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12509 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12510 sw_if_index_set = 1;
12511 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12512 sw_if_index_set = 1;
12513 else if (unformat (i, "del"))
12515 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12517 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12519 else if (unformat (i, "l2-table %d", &l2_table_index))
12523 clib_warning ("parse error '%U'", format_unformat_error, i);
12528 if (sw_if_index_set == 0)
12530 errmsg ("missing interface name or sw_if_index");
12534 M (INPUT_ACL_SET_INTERFACE, mp);
12536 mp->sw_if_index = ntohl (sw_if_index);
12537 mp->ip4_table_index = ntohl (ip4_table_index);
12538 mp->ip6_table_index = ntohl (ip6_table_index);
12539 mp->l2_table_index = ntohl (l2_table_index);
12540 mp->is_add = is_add;
12548 api_ip_address_dump (vat_main_t * vam)
12550 unformat_input_t *i = vam->input;
12551 vl_api_ip_address_dump_t *mp;
12552 vl_api_control_ping_t *mp_ping;
12553 u32 sw_if_index = ~0;
12554 u8 sw_if_index_set = 0;
12559 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12561 if (unformat (i, "sw_if_index %d", &sw_if_index))
12562 sw_if_index_set = 1;
12564 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12565 sw_if_index_set = 1;
12566 else if (unformat (i, "ipv4"))
12568 else if (unformat (i, "ipv6"))
12574 if (ipv4_set && ipv6_set)
12576 errmsg ("ipv4 and ipv6 flags cannot be both set");
12580 if ((!ipv4_set) && (!ipv6_set))
12582 errmsg ("no ipv4 nor ipv6 flag set");
12586 if (sw_if_index_set == 0)
12588 errmsg ("missing interface name or sw_if_index");
12592 vam->current_sw_if_index = sw_if_index;
12593 vam->is_ipv6 = ipv6_set;
12595 M (IP_ADDRESS_DUMP, mp);
12596 mp->sw_if_index = ntohl (sw_if_index);
12597 mp->is_ipv6 = ipv6_set;
12600 /* Use a control ping for synchronization */
12601 M (CONTROL_PING, mp_ping);
12609 api_ip_dump (vat_main_t * vam)
12611 vl_api_ip_dump_t *mp;
12612 vl_api_control_ping_t *mp_ping;
12613 unformat_input_t *in = vam->input;
12620 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
12622 if (unformat (in, "ipv4"))
12624 else if (unformat (in, "ipv6"))
12630 if (ipv4_set && ipv6_set)
12632 errmsg ("ipv4 and ipv6 flags cannot be both set");
12636 if ((!ipv4_set) && (!ipv6_set))
12638 errmsg ("no ipv4 nor ipv6 flag set");
12642 is_ipv6 = ipv6_set;
12643 vam->is_ipv6 = is_ipv6;
12645 /* free old data */
12646 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12648 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12650 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12653 mp->is_ipv6 = ipv6_set;
12656 /* Use a control ping for synchronization */
12657 M (CONTROL_PING, mp_ping);
12665 api_ipsec_spd_add_del (vat_main_t * vam)
12667 unformat_input_t *i = vam->input;
12668 vl_api_ipsec_spd_add_del_t *mp;
12673 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12675 if (unformat (i, "spd_id %d", &spd_id))
12677 else if (unformat (i, "del"))
12681 clib_warning ("parse error '%U'", format_unformat_error, i);
12687 errmsg ("spd_id must be set");
12691 M (IPSEC_SPD_ADD_DEL, mp);
12693 mp->spd_id = ntohl (spd_id);
12694 mp->is_add = is_add;
12702 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12704 unformat_input_t *i = vam->input;
12705 vl_api_ipsec_interface_add_del_spd_t *mp;
12707 u8 sw_if_index_set = 0;
12708 u32 spd_id = (u32) ~ 0;
12712 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12714 if (unformat (i, "del"))
12716 else if (unformat (i, "spd_id %d", &spd_id))
12719 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12720 sw_if_index_set = 1;
12721 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12722 sw_if_index_set = 1;
12725 clib_warning ("parse error '%U'", format_unformat_error, i);
12731 if (spd_id == (u32) ~ 0)
12733 errmsg ("spd_id must be set");
12737 if (sw_if_index_set == 0)
12739 errmsg ("missing interface name or sw_if_index");
12743 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12745 mp->spd_id = ntohl (spd_id);
12746 mp->sw_if_index = ntohl (sw_if_index);
12747 mp->is_add = is_add;
12755 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12757 unformat_input_t *i = vam->input;
12758 vl_api_ipsec_spd_add_del_entry_t *mp;
12759 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12760 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12762 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12763 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12764 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12765 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12768 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12769 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12770 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12771 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12772 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12773 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12775 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12777 if (unformat (i, "del"))
12779 if (unformat (i, "outbound"))
12781 if (unformat (i, "inbound"))
12783 else if (unformat (i, "spd_id %d", &spd_id))
12785 else if (unformat (i, "sa_id %d", &sa_id))
12787 else if (unformat (i, "priority %d", &priority))
12789 else if (unformat (i, "protocol %d", &protocol))
12791 else if (unformat (i, "lport_start %d", &lport_start))
12793 else if (unformat (i, "lport_stop %d", &lport_stop))
12795 else if (unformat (i, "rport_start %d", &rport_start))
12797 else if (unformat (i, "rport_stop %d", &rport_stop))
12801 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12807 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12814 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12820 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12827 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12833 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12840 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12846 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12852 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12854 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12856 clib_warning ("unsupported action: 'resolve'");
12862 clib_warning ("parse error '%U'", format_unformat_error, i);
12868 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12870 mp->spd_id = ntohl (spd_id);
12871 mp->priority = ntohl (priority);
12872 mp->is_outbound = is_outbound;
12874 mp->is_ipv6 = is_ipv6;
12875 if (is_ipv6 || is_ip_any)
12877 clib_memcpy (mp->remote_address_start, &raddr6_start,
12878 sizeof (ip6_address_t));
12879 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12880 sizeof (ip6_address_t));
12881 clib_memcpy (mp->local_address_start, &laddr6_start,
12882 sizeof (ip6_address_t));
12883 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12884 sizeof (ip6_address_t));
12888 clib_memcpy (mp->remote_address_start, &raddr4_start,
12889 sizeof (ip4_address_t));
12890 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12891 sizeof (ip4_address_t));
12892 clib_memcpy (mp->local_address_start, &laddr4_start,
12893 sizeof (ip4_address_t));
12894 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12895 sizeof (ip4_address_t));
12897 mp->protocol = (u8) protocol;
12898 mp->local_port_start = ntohs ((u16) lport_start);
12899 mp->local_port_stop = ntohs ((u16) lport_stop);
12900 mp->remote_port_start = ntohs ((u16) rport_start);
12901 mp->remote_port_stop = ntohs ((u16) rport_stop);
12902 mp->policy = (u8) policy;
12903 mp->sa_id = ntohl (sa_id);
12904 mp->is_add = is_add;
12905 mp->is_ip_any = is_ip_any;
12912 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12914 unformat_input_t *i = vam->input;
12915 vl_api_ipsec_sad_add_del_entry_t *mp;
12916 u32 sad_id = 0, spi = 0;
12917 u8 *ck = 0, *ik = 0;
12920 u8 protocol = IPSEC_PROTOCOL_AH;
12921 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12922 u32 crypto_alg = 0, integ_alg = 0;
12923 ip4_address_t tun_src4;
12924 ip4_address_t tun_dst4;
12925 ip6_address_t tun_src6;
12926 ip6_address_t tun_dst6;
12929 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12931 if (unformat (i, "del"))
12933 else if (unformat (i, "sad_id %d", &sad_id))
12935 else if (unformat (i, "spi %d", &spi))
12937 else if (unformat (i, "esp"))
12938 protocol = IPSEC_PROTOCOL_ESP;
12939 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12942 is_tunnel_ipv6 = 0;
12944 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12947 is_tunnel_ipv6 = 0;
12949 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12952 is_tunnel_ipv6 = 1;
12954 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12957 is_tunnel_ipv6 = 1;
12961 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12963 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12964 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12966 clib_warning ("unsupported crypto-alg: '%U'",
12967 format_ipsec_crypto_alg, crypto_alg);
12971 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12975 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12977 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12978 integ_alg >= IPSEC_INTEG_N_ALG)
12980 clib_warning ("unsupported integ-alg: '%U'",
12981 format_ipsec_integ_alg, integ_alg);
12985 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12989 clib_warning ("parse error '%U'", format_unformat_error, i);
12995 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12997 mp->sad_id = ntohl (sad_id);
12998 mp->is_add = is_add;
12999 mp->protocol = protocol;
13000 mp->spi = ntohl (spi);
13001 mp->is_tunnel = is_tunnel;
13002 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
13003 mp->crypto_algorithm = crypto_alg;
13004 mp->integrity_algorithm = integ_alg;
13005 mp->crypto_key_length = vec_len (ck);
13006 mp->integrity_key_length = vec_len (ik);
13008 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13009 mp->crypto_key_length = sizeof (mp->crypto_key);
13011 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13012 mp->integrity_key_length = sizeof (mp->integrity_key);
13015 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13017 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13021 if (is_tunnel_ipv6)
13023 clib_memcpy (mp->tunnel_src_address, &tun_src6,
13024 sizeof (ip6_address_t));
13025 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
13026 sizeof (ip6_address_t));
13030 clib_memcpy (mp->tunnel_src_address, &tun_src4,
13031 sizeof (ip4_address_t));
13032 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
13033 sizeof (ip4_address_t));
13043 api_ipsec_sa_set_key (vat_main_t * vam)
13045 unformat_input_t *i = vam->input;
13046 vl_api_ipsec_sa_set_key_t *mp;
13048 u8 *ck = 0, *ik = 0;
13051 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13053 if (unformat (i, "sa_id %d", &sa_id))
13055 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13057 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13061 clib_warning ("parse error '%U'", format_unformat_error, i);
13066 M (IPSEC_SA_SET_KEY, mp);
13068 mp->sa_id = ntohl (sa_id);
13069 mp->crypto_key_length = vec_len (ck);
13070 mp->integrity_key_length = vec_len (ik);
13072 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13073 mp->crypto_key_length = sizeof (mp->crypto_key);
13075 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13076 mp->integrity_key_length = sizeof (mp->integrity_key);
13079 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13081 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13089 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
13091 unformat_input_t *i = vam->input;
13092 vl_api_ipsec_tunnel_if_add_del_t *mp;
13093 u32 local_spi = 0, remote_spi = 0;
13094 u32 crypto_alg = 0, integ_alg = 0;
13095 u8 *lck = NULL, *rck = NULL;
13096 u8 *lik = NULL, *rik = NULL;
13097 ip4_address_t local_ip = { {0} };
13098 ip4_address_t remote_ip = { {0} };
13101 u8 anti_replay = 0;
13104 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13106 if (unformat (i, "del"))
13108 else if (unformat (i, "esn"))
13110 else if (unformat (i, "anti_replay"))
13112 else if (unformat (i, "local_spi %d", &local_spi))
13114 else if (unformat (i, "remote_spi %d", &remote_spi))
13116 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
13118 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
13120 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
13123 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
13125 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
13127 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
13131 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13133 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13134 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13136 errmsg ("unsupported crypto-alg: '%U'\n",
13137 format_ipsec_crypto_alg, crypto_alg);
13143 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13145 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13146 integ_alg >= IPSEC_INTEG_N_ALG)
13148 errmsg ("unsupported integ-alg: '%U'\n",
13149 format_ipsec_integ_alg, integ_alg);
13155 errmsg ("parse error '%U'\n", format_unformat_error, i);
13160 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
13162 mp->is_add = is_add;
13164 mp->anti_replay = anti_replay;
13166 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
13167 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
13169 mp->local_spi = htonl (local_spi);
13170 mp->remote_spi = htonl (remote_spi);
13171 mp->crypto_alg = (u8) crypto_alg;
13173 mp->local_crypto_key_len = 0;
13176 mp->local_crypto_key_len = vec_len (lck);
13177 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
13178 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
13179 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
13182 mp->remote_crypto_key_len = 0;
13185 mp->remote_crypto_key_len = vec_len (rck);
13186 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
13187 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
13188 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
13191 mp->integ_alg = (u8) integ_alg;
13193 mp->local_integ_key_len = 0;
13196 mp->local_integ_key_len = vec_len (lik);
13197 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
13198 mp->local_integ_key_len = sizeof (mp->local_integ_key);
13199 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
13202 mp->remote_integ_key_len = 0;
13205 mp->remote_integ_key_len = vec_len (rik);
13206 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
13207 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
13208 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
13217 api_ikev2_profile_add_del (vat_main_t * vam)
13219 unformat_input_t *i = vam->input;
13220 vl_api_ikev2_profile_add_del_t *mp;
13225 const char *valid_chars = "a-zA-Z0-9_";
13227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13229 if (unformat (i, "del"))
13231 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13232 vec_add1 (name, 0);
13235 errmsg ("parse error '%U'", format_unformat_error, i);
13240 if (!vec_len (name))
13242 errmsg ("profile name must be specified");
13246 if (vec_len (name) > 64)
13248 errmsg ("profile name too long");
13252 M (IKEV2_PROFILE_ADD_DEL, mp);
13254 clib_memcpy (mp->name, name, vec_len (name));
13255 mp->is_add = is_add;
13264 api_ikev2_profile_set_auth (vat_main_t * vam)
13266 unformat_input_t *i = vam->input;
13267 vl_api_ikev2_profile_set_auth_t *mp;
13270 u32 auth_method = 0;
13274 const char *valid_chars = "a-zA-Z0-9_";
13276 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13278 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13279 vec_add1 (name, 0);
13280 else if (unformat (i, "auth_method %U",
13281 unformat_ikev2_auth_method, &auth_method))
13283 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
13285 else if (unformat (i, "auth_data %v", &data))
13289 errmsg ("parse error '%U'", format_unformat_error, i);
13294 if (!vec_len (name))
13296 errmsg ("profile name must be specified");
13300 if (vec_len (name) > 64)
13302 errmsg ("profile name too long");
13306 if (!vec_len (data))
13308 errmsg ("auth_data must be specified");
13314 errmsg ("auth_method must be specified");
13318 M (IKEV2_PROFILE_SET_AUTH, mp);
13320 mp->is_hex = is_hex;
13321 mp->auth_method = (u8) auth_method;
13322 mp->data_len = vec_len (data);
13323 clib_memcpy (mp->name, name, vec_len (name));
13324 clib_memcpy (mp->data, data, vec_len (data));
13334 api_ikev2_profile_set_id (vat_main_t * vam)
13336 unformat_input_t *i = vam->input;
13337 vl_api_ikev2_profile_set_id_t *mp;
13345 const char *valid_chars = "a-zA-Z0-9_";
13347 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13349 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13350 vec_add1 (name, 0);
13351 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
13353 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
13355 data = vec_new (u8, 4);
13356 clib_memcpy (data, ip4.as_u8, 4);
13358 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
13360 else if (unformat (i, "id_data %v", &data))
13362 else if (unformat (i, "local"))
13364 else if (unformat (i, "remote"))
13368 errmsg ("parse error '%U'", format_unformat_error, i);
13373 if (!vec_len (name))
13375 errmsg ("profile name must be specified");
13379 if (vec_len (name) > 64)
13381 errmsg ("profile name too long");
13385 if (!vec_len (data))
13387 errmsg ("id_data must be specified");
13393 errmsg ("id_type must be specified");
13397 M (IKEV2_PROFILE_SET_ID, mp);
13399 mp->is_local = is_local;
13400 mp->id_type = (u8) id_type;
13401 mp->data_len = vec_len (data);
13402 clib_memcpy (mp->name, name, vec_len (name));
13403 clib_memcpy (mp->data, data, vec_len (data));
13413 api_ikev2_profile_set_ts (vat_main_t * vam)
13415 unformat_input_t *i = vam->input;
13416 vl_api_ikev2_profile_set_ts_t *mp;
13419 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
13420 ip4_address_t start_addr, end_addr;
13422 const char *valid_chars = "a-zA-Z0-9_";
13425 start_addr.as_u32 = 0;
13426 end_addr.as_u32 = (u32) ~ 0;
13428 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13430 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13431 vec_add1 (name, 0);
13432 else if (unformat (i, "protocol %d", &proto))
13434 else if (unformat (i, "start_port %d", &start_port))
13436 else if (unformat (i, "end_port %d", &end_port))
13439 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
13441 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
13443 else if (unformat (i, "local"))
13445 else if (unformat (i, "remote"))
13449 errmsg ("parse error '%U'", format_unformat_error, i);
13454 if (!vec_len (name))
13456 errmsg ("profile name must be specified");
13460 if (vec_len (name) > 64)
13462 errmsg ("profile name too long");
13466 M (IKEV2_PROFILE_SET_TS, mp);
13468 mp->is_local = is_local;
13469 mp->proto = (u8) proto;
13470 mp->start_port = (u16) start_port;
13471 mp->end_port = (u16) end_port;
13472 mp->start_addr = start_addr.as_u32;
13473 mp->end_addr = end_addr.as_u32;
13474 clib_memcpy (mp->name, name, vec_len (name));
13483 api_ikev2_set_local_key (vat_main_t * vam)
13485 unformat_input_t *i = vam->input;
13486 vl_api_ikev2_set_local_key_t *mp;
13490 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13492 if (unformat (i, "file %v", &file))
13493 vec_add1 (file, 0);
13496 errmsg ("parse error '%U'", format_unformat_error, i);
13501 if (!vec_len (file))
13503 errmsg ("RSA key file must be specified");
13507 if (vec_len (file) > 256)
13509 errmsg ("file name too long");
13513 M (IKEV2_SET_LOCAL_KEY, mp);
13515 clib_memcpy (mp->key_file, file, vec_len (file));
13524 api_ikev2_set_responder (vat_main_t * vam)
13526 unformat_input_t *i = vam->input;
13527 vl_api_ikev2_set_responder_t *mp;
13530 u32 sw_if_index = ~0;
13531 ip4_address_t address;
13533 const char *valid_chars = "a-zA-Z0-9_";
13535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13538 (i, "%U interface %d address %U", unformat_token, valid_chars,
13539 &name, &sw_if_index, unformat_ip4_address, &address))
13540 vec_add1 (name, 0);
13543 errmsg ("parse error '%U'", format_unformat_error, i);
13548 if (!vec_len (name))
13550 errmsg ("profile name must be specified");
13554 if (vec_len (name) > 64)
13556 errmsg ("profile name too long");
13560 M (IKEV2_SET_RESPONDER, mp);
13562 clib_memcpy (mp->name, name, vec_len (name));
13565 mp->sw_if_index = sw_if_index;
13566 clib_memcpy (mp->address, &address, sizeof (address));
13574 api_ikev2_set_ike_transforms (vat_main_t * vam)
13576 unformat_input_t *i = vam->input;
13577 vl_api_ikev2_set_ike_transforms_t *mp;
13580 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13582 const char *valid_chars = "a-zA-Z0-9_";
13584 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13586 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13587 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13588 vec_add1 (name, 0);
13591 errmsg ("parse error '%U'", format_unformat_error, i);
13596 if (!vec_len (name))
13598 errmsg ("profile name must be specified");
13602 if (vec_len (name) > 64)
13604 errmsg ("profile name too long");
13608 M (IKEV2_SET_IKE_TRANSFORMS, mp);
13610 clib_memcpy (mp->name, name, vec_len (name));
13612 mp->crypto_alg = crypto_alg;
13613 mp->crypto_key_size = crypto_key_size;
13614 mp->integ_alg = integ_alg;
13615 mp->dh_group = dh_group;
13624 api_ikev2_set_esp_transforms (vat_main_t * vam)
13626 unformat_input_t *i = vam->input;
13627 vl_api_ikev2_set_esp_transforms_t *mp;
13630 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13632 const char *valid_chars = "a-zA-Z0-9_";
13634 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13636 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13637 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13638 vec_add1 (name, 0);
13641 errmsg ("parse error '%U'", format_unformat_error, i);
13646 if (!vec_len (name))
13648 errmsg ("profile name must be specified");
13652 if (vec_len (name) > 64)
13654 errmsg ("profile name too long");
13658 M (IKEV2_SET_ESP_TRANSFORMS, mp);
13660 clib_memcpy (mp->name, name, vec_len (name));
13662 mp->crypto_alg = crypto_alg;
13663 mp->crypto_key_size = crypto_key_size;
13664 mp->integ_alg = integ_alg;
13665 mp->dh_group = dh_group;
13673 api_ikev2_set_sa_lifetime (vat_main_t * vam)
13675 unformat_input_t *i = vam->input;
13676 vl_api_ikev2_set_sa_lifetime_t *mp;
13679 u64 lifetime, lifetime_maxdata;
13680 u32 lifetime_jitter, handover;
13682 const char *valid_chars = "a-zA-Z0-9_";
13684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13686 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
13687 &lifetime, &lifetime_jitter, &handover,
13688 &lifetime_maxdata))
13689 vec_add1 (name, 0);
13692 errmsg ("parse error '%U'", format_unformat_error, i);
13697 if (!vec_len (name))
13699 errmsg ("profile name must be specified");
13703 if (vec_len (name) > 64)
13705 errmsg ("profile name too long");
13709 M (IKEV2_SET_SA_LIFETIME, mp);
13711 clib_memcpy (mp->name, name, vec_len (name));
13713 mp->lifetime = lifetime;
13714 mp->lifetime_jitter = lifetime_jitter;
13715 mp->handover = handover;
13716 mp->lifetime_maxdata = lifetime_maxdata;
13724 api_ikev2_initiate_sa_init (vat_main_t * vam)
13726 unformat_input_t *i = vam->input;
13727 vl_api_ikev2_initiate_sa_init_t *mp;
13731 const char *valid_chars = "a-zA-Z0-9_";
13733 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13735 if (unformat (i, "%U", unformat_token, valid_chars, &name))
13736 vec_add1 (name, 0);
13739 errmsg ("parse error '%U'", format_unformat_error, i);
13744 if (!vec_len (name))
13746 errmsg ("profile name must be specified");
13750 if (vec_len (name) > 64)
13752 errmsg ("profile name too long");
13756 M (IKEV2_INITIATE_SA_INIT, mp);
13758 clib_memcpy (mp->name, name, vec_len (name));
13767 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
13769 unformat_input_t *i = vam->input;
13770 vl_api_ikev2_initiate_del_ike_sa_t *mp;
13775 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13777 if (unformat (i, "%lx", &ispi))
13781 errmsg ("parse error '%U'", format_unformat_error, i);
13786 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
13796 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13798 unformat_input_t *i = vam->input;
13799 vl_api_ikev2_initiate_del_child_sa_t *mp;
13804 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13806 if (unformat (i, "%x", &ispi))
13810 errmsg ("parse error '%U'", format_unformat_error, i);
13815 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13825 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13827 unformat_input_t *i = vam->input;
13828 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13833 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13835 if (unformat (i, "%x", &ispi))
13839 errmsg ("parse error '%U'", format_unformat_error, i);
13844 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
13857 api_map_add_domain (vat_main_t * vam)
13859 unformat_input_t *i = vam->input;
13860 vl_api_map_add_domain_t *mp;
13862 ip4_address_t ip4_prefix;
13863 ip6_address_t ip6_prefix;
13864 ip6_address_t ip6_src;
13865 u32 num_m_args = 0;
13866 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
13867 0, psid_length = 0;
13868 u8 is_translation = 0;
13870 u32 ip6_src_len = 128;
13873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13875 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
13876 &ip4_prefix, &ip4_prefix_len))
13878 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
13879 &ip6_prefix, &ip6_prefix_len))
13883 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
13886 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
13888 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
13890 else if (unformat (i, "psid-offset %d", &psid_offset))
13892 else if (unformat (i, "psid-len %d", &psid_length))
13894 else if (unformat (i, "mtu %d", &mtu))
13896 else if (unformat (i, "map-t"))
13897 is_translation = 1;
13900 clib_warning ("parse error '%U'", format_unformat_error, i);
13905 if (num_m_args < 3)
13907 errmsg ("mandatory argument(s) missing");
13911 /* Construct the API message */
13912 M (MAP_ADD_DOMAIN, mp);
13914 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
13915 mp->ip4_prefix_len = ip4_prefix_len;
13917 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
13918 mp->ip6_prefix_len = ip6_prefix_len;
13920 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
13921 mp->ip6_src_prefix_len = ip6_src_len;
13923 mp->ea_bits_len = ea_bits_len;
13924 mp->psid_offset = psid_offset;
13925 mp->psid_length = psid_length;
13926 mp->is_translation = is_translation;
13927 mp->mtu = htons (mtu);
13932 /* Wait for a reply, return good/bad news */
13938 api_map_del_domain (vat_main_t * vam)
13940 unformat_input_t *i = vam->input;
13941 vl_api_map_del_domain_t *mp;
13943 u32 num_m_args = 0;
13947 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13949 if (unformat (i, "index %d", &index))
13953 clib_warning ("parse error '%U'", format_unformat_error, i);
13958 if (num_m_args != 1)
13960 errmsg ("mandatory argument(s) missing");
13964 /* Construct the API message */
13965 M (MAP_DEL_DOMAIN, mp);
13967 mp->index = ntohl (index);
13972 /* Wait for a reply, return good/bad news */
13978 api_map_add_del_rule (vat_main_t * vam)
13980 unformat_input_t *i = vam->input;
13981 vl_api_map_add_del_rule_t *mp;
13983 ip6_address_t ip6_dst;
13984 u32 num_m_args = 0, index, psid = 0;
13987 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13989 if (unformat (i, "index %d", &index))
13991 else if (unformat (i, "psid %d", &psid))
13993 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13995 else if (unformat (i, "del"))
14001 clib_warning ("parse error '%U'", format_unformat_error, i);
14006 /* Construct the API message */
14007 M (MAP_ADD_DEL_RULE, mp);
14009 mp->index = ntohl (index);
14010 mp->is_add = is_add;
14011 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
14012 mp->psid = ntohs (psid);
14017 /* Wait for a reply, return good/bad news */
14023 api_map_domain_dump (vat_main_t * vam)
14025 vl_api_map_domain_dump_t *mp;
14026 vl_api_control_ping_t *mp_ping;
14029 /* Construct the API message */
14030 M (MAP_DOMAIN_DUMP, mp);
14035 /* Use a control ping for synchronization */
14036 M (CONTROL_PING, mp_ping);
14044 api_map_rule_dump (vat_main_t * vam)
14046 unformat_input_t *i = vam->input;
14047 vl_api_map_rule_dump_t *mp;
14048 vl_api_control_ping_t *mp_ping;
14049 u32 domain_index = ~0;
14052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14054 if (unformat (i, "index %u", &domain_index))
14060 if (domain_index == ~0)
14062 clib_warning ("parse error: domain index expected");
14066 /* Construct the API message */
14067 M (MAP_RULE_DUMP, mp);
14069 mp->domain_index = htonl (domain_index);
14074 /* Use a control ping for synchronization */
14075 M (CONTROL_PING, mp_ping);
14082 static void vl_api_map_add_domain_reply_t_handler
14083 (vl_api_map_add_domain_reply_t * mp)
14085 vat_main_t *vam = &vat_main;
14086 i32 retval = ntohl (mp->retval);
14088 if (vam->async_mode)
14090 vam->async_errors += (retval < 0);
14094 vam->retval = retval;
14095 vam->result_ready = 1;
14099 static void vl_api_map_add_domain_reply_t_handler_json
14100 (vl_api_map_add_domain_reply_t * mp)
14102 vat_main_t *vam = &vat_main;
14103 vat_json_node_t node;
14105 vat_json_init_object (&node);
14106 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
14107 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
14109 vat_json_print (vam->ofp, &node);
14110 vat_json_free (&node);
14112 vam->retval = ntohl (mp->retval);
14113 vam->result_ready = 1;
14117 api_get_first_msg_id (vat_main_t * vam)
14119 vl_api_get_first_msg_id_t *mp;
14120 unformat_input_t *i = vam->input;
14125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14127 if (unformat (i, "client %s", &name))
14135 errmsg ("missing client name");
14138 vec_add1 (name, 0);
14140 if (vec_len (name) > 63)
14142 errmsg ("client name too long");
14146 M (GET_FIRST_MSG_ID, mp);
14147 clib_memcpy (mp->name, name, vec_len (name));
14154 api_cop_interface_enable_disable (vat_main_t * vam)
14156 unformat_input_t *line_input = vam->input;
14157 vl_api_cop_interface_enable_disable_t *mp;
14158 u32 sw_if_index = ~0;
14159 u8 enable_disable = 1;
14162 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14164 if (unformat (line_input, "disable"))
14165 enable_disable = 0;
14166 if (unformat (line_input, "enable"))
14167 enable_disable = 1;
14168 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14169 vam, &sw_if_index))
14171 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14177 if (sw_if_index == ~0)
14179 errmsg ("missing interface name or sw_if_index");
14183 /* Construct the API message */
14184 M (COP_INTERFACE_ENABLE_DISABLE, mp);
14185 mp->sw_if_index = ntohl (sw_if_index);
14186 mp->enable_disable = enable_disable;
14190 /* Wait for the reply */
14196 api_cop_whitelist_enable_disable (vat_main_t * vam)
14198 unformat_input_t *line_input = vam->input;
14199 vl_api_cop_whitelist_enable_disable_t *mp;
14200 u32 sw_if_index = ~0;
14201 u8 ip4 = 0, ip6 = 0, default_cop = 0;
14205 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14207 if (unformat (line_input, "ip4"))
14209 else if (unformat (line_input, "ip6"))
14211 else if (unformat (line_input, "default"))
14213 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14214 vam, &sw_if_index))
14216 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14218 else if (unformat (line_input, "fib-id %d", &fib_id))
14224 if (sw_if_index == ~0)
14226 errmsg ("missing interface name or sw_if_index");
14230 /* Construct the API message */
14231 M (COP_WHITELIST_ENABLE_DISABLE, mp);
14232 mp->sw_if_index = ntohl (sw_if_index);
14233 mp->fib_id = ntohl (fib_id);
14236 mp->default_cop = default_cop;
14240 /* Wait for the reply */
14246 api_get_node_graph (vat_main_t * vam)
14248 vl_api_get_node_graph_t *mp;
14251 M (GET_NODE_GRAPH, mp);
14255 /* Wait for the reply */
14261 /** Used for parsing LISP eids */
14262 typedef CLIB_PACKED(struct{
14263 u8 addr[16]; /**< eid address */
14264 u32 len; /**< prefix length if IP */
14265 u8 type; /**< type of eid */
14270 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14272 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14274 memset (a, 0, sizeof (a[0]));
14276 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
14278 a->type = 0; /* ipv4 type */
14280 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
14282 a->type = 1; /* ipv6 type */
14284 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
14286 a->type = 2; /* mac type */
14288 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
14290 a->type = 3; /* NSH type */
14291 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
14292 nsh->spi = clib_host_to_net_u32 (nsh->spi);
14299 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
14308 lisp_eid_size_vat (u8 type)
14325 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
14327 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
14331 api_one_add_del_locator_set (vat_main_t * vam)
14333 unformat_input_t *input = vam->input;
14334 vl_api_one_add_del_locator_set_t *mp;
14336 u8 *locator_set_name = NULL;
14337 u8 locator_set_name_set = 0;
14338 vl_api_local_locator_t locator, *locators = 0;
14339 u32 sw_if_index, priority, weight;
14343 /* Parse args required to build the message */
14344 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14346 if (unformat (input, "del"))
14350 else if (unformat (input, "locator-set %s", &locator_set_name))
14352 locator_set_name_set = 1;
14354 else if (unformat (input, "sw_if_index %u p %u w %u",
14355 &sw_if_index, &priority, &weight))
14357 locator.sw_if_index = htonl (sw_if_index);
14358 locator.priority = priority;
14359 locator.weight = weight;
14360 vec_add1 (locators, locator);
14364 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14365 &sw_if_index, &priority, &weight))
14367 locator.sw_if_index = htonl (sw_if_index);
14368 locator.priority = priority;
14369 locator.weight = weight;
14370 vec_add1 (locators, locator);
14376 if (locator_set_name_set == 0)
14378 errmsg ("missing locator-set name");
14379 vec_free (locators);
14383 if (vec_len (locator_set_name) > 64)
14385 errmsg ("locator-set name too long");
14386 vec_free (locator_set_name);
14387 vec_free (locators);
14390 vec_add1 (locator_set_name, 0);
14392 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14394 /* Construct the API message */
14395 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14397 mp->is_add = is_add;
14398 clib_memcpy (mp->locator_set_name, locator_set_name,
14399 vec_len (locator_set_name));
14400 vec_free (locator_set_name);
14402 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14404 clib_memcpy (mp->locators, locators, data_len);
14405 vec_free (locators);
14410 /* Wait for a reply... */
14415 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14418 api_one_add_del_locator (vat_main_t * vam)
14420 unformat_input_t *input = vam->input;
14421 vl_api_one_add_del_locator_t *mp;
14422 u32 tmp_if_index = ~0;
14423 u32 sw_if_index = ~0;
14424 u8 sw_if_index_set = 0;
14425 u8 sw_if_index_if_name_set = 0;
14427 u8 priority_set = 0;
14431 u8 *locator_set_name = NULL;
14432 u8 locator_set_name_set = 0;
14435 /* Parse args required to build the message */
14436 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14438 if (unformat (input, "del"))
14442 else if (unformat (input, "locator-set %s", &locator_set_name))
14444 locator_set_name_set = 1;
14446 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14449 sw_if_index_if_name_set = 1;
14450 sw_if_index = tmp_if_index;
14452 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14454 sw_if_index_set = 1;
14455 sw_if_index = tmp_if_index;
14457 else if (unformat (input, "p %d", &priority))
14461 else if (unformat (input, "w %d", &weight))
14469 if (locator_set_name_set == 0)
14471 errmsg ("missing locator-set name");
14475 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14477 errmsg ("missing sw_if_index");
14478 vec_free (locator_set_name);
14482 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14484 errmsg ("cannot use both params interface name and sw_if_index");
14485 vec_free (locator_set_name);
14489 if (priority_set == 0)
14491 errmsg ("missing locator-set priority");
14492 vec_free (locator_set_name);
14496 if (weight_set == 0)
14498 errmsg ("missing locator-set weight");
14499 vec_free (locator_set_name);
14503 if (vec_len (locator_set_name) > 64)
14505 errmsg ("locator-set name too long");
14506 vec_free (locator_set_name);
14509 vec_add1 (locator_set_name, 0);
14511 /* Construct the API message */
14512 M (ONE_ADD_DEL_LOCATOR, mp);
14514 mp->is_add = is_add;
14515 mp->sw_if_index = ntohl (sw_if_index);
14516 mp->priority = priority;
14517 mp->weight = weight;
14518 clib_memcpy (mp->locator_set_name, locator_set_name,
14519 vec_len (locator_set_name));
14520 vec_free (locator_set_name);
14525 /* Wait for a reply... */
14530 #define api_lisp_add_del_locator api_one_add_del_locator
14533 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14535 u32 *key_id = va_arg (*args, u32 *);
14538 if (unformat (input, "%s", &s))
14540 if (!strcmp ((char *) s, "sha1"))
14541 key_id[0] = HMAC_SHA_1_96;
14542 else if (!strcmp ((char *) s, "sha256"))
14543 key_id[0] = HMAC_SHA_256_128;
14546 clib_warning ("invalid key_id: '%s'", s);
14547 key_id[0] = HMAC_NO_KEY;
14558 api_one_add_del_local_eid (vat_main_t * vam)
14560 unformat_input_t *input = vam->input;
14561 vl_api_one_add_del_local_eid_t *mp;
14564 lisp_eid_vat_t _eid, *eid = &_eid;
14565 u8 *locator_set_name = 0;
14566 u8 locator_set_name_set = 0;
14572 /* Parse args required to build the message */
14573 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14575 if (unformat (input, "del"))
14579 else if (unformat (input, "vni %d", &vni))
14583 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14587 else if (unformat (input, "locator-set %s", &locator_set_name))
14589 locator_set_name_set = 1;
14591 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14593 else if (unformat (input, "secret-key %_%v%_", &key))
14599 if (locator_set_name_set == 0)
14601 errmsg ("missing locator-set name");
14607 errmsg ("EID address not set!");
14608 vec_free (locator_set_name);
14612 if (key && (0 == key_id))
14614 errmsg ("invalid key_id!");
14618 if (vec_len (key) > 64)
14620 errmsg ("key too long");
14625 if (vec_len (locator_set_name) > 64)
14627 errmsg ("locator-set name too long");
14628 vec_free (locator_set_name);
14631 vec_add1 (locator_set_name, 0);
14633 /* Construct the API message */
14634 M (ONE_ADD_DEL_LOCAL_EID, mp);
14636 mp->is_add = is_add;
14637 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14638 mp->eid_type = eid->type;
14639 mp->prefix_len = eid->len;
14640 mp->vni = clib_host_to_net_u32 (vni);
14641 mp->key_id = clib_host_to_net_u16 (key_id);
14642 clib_memcpy (mp->locator_set_name, locator_set_name,
14643 vec_len (locator_set_name));
14644 clib_memcpy (mp->key, key, vec_len (key));
14646 vec_free (locator_set_name);
14652 /* Wait for a reply... */
14657 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14660 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14662 u32 dp_table = 0, vni = 0;;
14663 unformat_input_t *input = vam->input;
14664 vl_api_gpe_add_del_fwd_entry_t *mp;
14666 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14667 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14668 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14669 u32 action = ~0, w;
14670 ip4_address_t rmt_rloc4, lcl_rloc4;
14671 ip6_address_t rmt_rloc6, lcl_rloc6;
14672 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14675 memset (&rloc, 0, sizeof (rloc));
14677 /* Parse args required to build the message */
14678 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14680 if (unformat (input, "del"))
14682 else if (unformat (input, "add"))
14684 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14688 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14692 else if (unformat (input, "vrf %d", &dp_table))
14694 else if (unformat (input, "bd %d", &dp_table))
14696 else if (unformat (input, "vni %d", &vni))
14698 else if (unformat (input, "w %d", &w))
14702 errmsg ("No RLOC configured for setting priority/weight!");
14705 curr_rloc->weight = w;
14707 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14708 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14712 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
14714 vec_add1 (lcl_locs, rloc);
14716 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
14717 vec_add1 (rmt_locs, rloc);
14718 /* weight saved in rmt loc */
14719 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14721 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14722 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14725 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
14727 vec_add1 (lcl_locs, rloc);
14729 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
14730 vec_add1 (rmt_locs, rloc);
14731 /* weight saved in rmt loc */
14732 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14734 else if (unformat (input, "action %d", &action))
14740 clib_warning ("parse error '%U'", format_unformat_error, input);
14747 errmsg ("remote eid addresses not set");
14751 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14753 errmsg ("eid types don't match");
14757 if (0 == rmt_locs && (u32) ~ 0 == action)
14759 errmsg ("action not set for negative mapping");
14763 /* Construct the API message */
14764 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14765 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14767 mp->is_add = is_add;
14768 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14769 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14770 mp->eid_type = rmt_eid->type;
14771 mp->dp_table = clib_host_to_net_u32 (dp_table);
14772 mp->vni = clib_host_to_net_u32 (vni);
14773 mp->rmt_len = rmt_eid->len;
14774 mp->lcl_len = lcl_eid->len;
14775 mp->action = action;
14777 if (0 != rmt_locs && 0 != lcl_locs)
14779 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14780 clib_memcpy (mp->locs, lcl_locs,
14781 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14783 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14784 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14785 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14787 vec_free (lcl_locs);
14788 vec_free (rmt_locs);
14793 /* Wait for a reply... */
14799 api_one_add_del_map_server (vat_main_t * vam)
14801 unformat_input_t *input = vam->input;
14802 vl_api_one_add_del_map_server_t *mp;
14806 ip4_address_t ipv4;
14807 ip6_address_t ipv6;
14810 /* Parse args required to build the message */
14811 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14813 if (unformat (input, "del"))
14817 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14821 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14829 if (ipv4_set && ipv6_set)
14831 errmsg ("both eid v4 and v6 addresses set");
14835 if (!ipv4_set && !ipv6_set)
14837 errmsg ("eid addresses not set");
14841 /* Construct the API message */
14842 M (ONE_ADD_DEL_MAP_SERVER, mp);
14844 mp->is_add = is_add;
14848 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14853 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14859 /* Wait for a reply... */
14864 #define api_lisp_add_del_map_server api_one_add_del_map_server
14867 api_one_add_del_map_resolver (vat_main_t * vam)
14869 unformat_input_t *input = vam->input;
14870 vl_api_one_add_del_map_resolver_t *mp;
14874 ip4_address_t ipv4;
14875 ip6_address_t ipv6;
14878 /* Parse args required to build the message */
14879 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14881 if (unformat (input, "del"))
14885 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14889 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14897 if (ipv4_set && ipv6_set)
14899 errmsg ("both eid v4 and v6 addresses set");
14903 if (!ipv4_set && !ipv6_set)
14905 errmsg ("eid addresses not set");
14909 /* Construct the API message */
14910 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14912 mp->is_add = is_add;
14916 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14921 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14927 /* Wait for a reply... */
14932 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14935 api_lisp_gpe_enable_disable (vat_main_t * vam)
14937 unformat_input_t *input = vam->input;
14938 vl_api_gpe_enable_disable_t *mp;
14943 /* Parse args required to build the message */
14944 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14946 if (unformat (input, "enable"))
14951 else if (unformat (input, "disable"))
14962 errmsg ("Value not set");
14966 /* Construct the API message */
14967 M (GPE_ENABLE_DISABLE, mp);
14974 /* Wait for a reply... */
14980 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14982 unformat_input_t *input = vam->input;
14983 vl_api_one_rloc_probe_enable_disable_t *mp;
14988 /* Parse args required to build the message */
14989 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14991 if (unformat (input, "enable"))
14996 else if (unformat (input, "disable"))
15004 errmsg ("Value not set");
15008 /* Construct the API message */
15009 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15011 mp->is_enabled = is_en;
15016 /* Wait for a reply... */
15021 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15024 api_one_map_register_enable_disable (vat_main_t * vam)
15026 unformat_input_t *input = vam->input;
15027 vl_api_one_map_register_enable_disable_t *mp;
15032 /* Parse args required to build the message */
15033 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15035 if (unformat (input, "enable"))
15040 else if (unformat (input, "disable"))
15048 errmsg ("Value not set");
15052 /* Construct the API message */
15053 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15055 mp->is_enabled = is_en;
15060 /* Wait for a reply... */
15065 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15068 api_one_enable_disable (vat_main_t * vam)
15070 unformat_input_t *input = vam->input;
15071 vl_api_one_enable_disable_t *mp;
15076 /* Parse args required to build the message */
15077 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15079 if (unformat (input, "enable"))
15084 else if (unformat (input, "disable"))
15094 errmsg ("Value not set");
15098 /* Construct the API message */
15099 M (ONE_ENABLE_DISABLE, mp);
15106 /* Wait for a reply... */
15111 #define api_lisp_enable_disable api_one_enable_disable
15114 api_show_one_map_register_state (vat_main_t * vam)
15116 vl_api_show_one_map_register_state_t *mp;
15119 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
15124 /* wait for reply */
15129 #define api_show_lisp_map_register_state api_show_one_map_register_state
15132 api_show_one_rloc_probe_state (vat_main_t * vam)
15134 vl_api_show_one_rloc_probe_state_t *mp;
15137 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
15142 /* wait for reply */
15147 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
15150 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15152 vl_api_one_add_del_l2_arp_entry_t *mp;
15153 unformat_input_t *input = vam->input;
15158 u8 mac[6] = { 0, };
15159 u32 ip4 = 0, bd = ~0;
15162 /* Parse args required to build the message */
15163 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15165 if (unformat (input, "del"))
15167 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15169 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15171 else if (unformat (input, "bd %d", &bd))
15175 errmsg ("parse error '%U'", format_unformat_error, input);
15180 if (!bd_set || !ip_set || (!mac_set && is_add))
15182 errmsg ("Missing BD, IP or MAC!");
15186 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15187 mp->is_add = is_add;
15188 clib_memcpy (mp->mac, mac, 6);
15189 mp->bd = clib_host_to_net_u32 (bd);
15195 /* wait for reply */
15201 api_one_l2_arp_bd_get (vat_main_t * vam)
15203 vl_api_one_l2_arp_bd_get_t *mp;
15206 M (ONE_L2_ARP_BD_GET, mp);
15211 /* wait for reply */
15217 api_one_l2_arp_entries_get (vat_main_t * vam)
15219 vl_api_one_l2_arp_entries_get_t *mp;
15220 unformat_input_t *input = vam->input;
15225 /* Parse args required to build the message */
15226 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15228 if (unformat (input, "bd %d", &bd))
15232 errmsg ("parse error '%U'", format_unformat_error, input);
15239 errmsg ("Expected bridge domain!");
15243 M (ONE_L2_ARP_ENTRIES_GET, mp);
15244 mp->bd = clib_host_to_net_u32 (bd);
15249 /* wait for reply */
15255 api_one_stats_enable_disable (vat_main_t * vam)
15257 vl_api_one_stats_enable_disable_t *mp;
15258 unformat_input_t *input = vam->input;
15263 /* Parse args required to build the message */
15264 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15266 if (unformat (input, "enable"))
15271 else if (unformat (input, "disable"))
15281 errmsg ("Value not set");
15285 M (ONE_STATS_ENABLE_DISABLE, mp);
15291 /* wait for reply */
15297 api_show_one_stats_enable_disable (vat_main_t * vam)
15299 vl_api_show_one_stats_enable_disable_t *mp;
15302 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
15307 /* wait for reply */
15313 api_show_one_map_request_mode (vat_main_t * vam)
15315 vl_api_show_one_map_request_mode_t *mp;
15318 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
15323 /* wait for reply */
15328 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
15331 api_one_map_request_mode (vat_main_t * vam)
15333 unformat_input_t *input = vam->input;
15334 vl_api_one_map_request_mode_t *mp;
15338 /* Parse args required to build the message */
15339 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15341 if (unformat (input, "dst-only"))
15343 else if (unformat (input, "src-dst"))
15347 errmsg ("parse error '%U'", format_unformat_error, input);
15352 M (ONE_MAP_REQUEST_MODE, mp);
15359 /* wait for reply */
15364 #define api_lisp_map_request_mode api_one_map_request_mode
15367 * Enable/disable ONE proxy ITR.
15369 * @param vam vpp API test context
15370 * @return return code
15373 api_one_pitr_set_locator_set (vat_main_t * vam)
15375 u8 ls_name_set = 0;
15376 unformat_input_t *input = vam->input;
15377 vl_api_one_pitr_set_locator_set_t *mp;
15382 /* Parse args required to build the message */
15383 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15385 if (unformat (input, "del"))
15387 else if (unformat (input, "locator-set %s", &ls_name))
15391 errmsg ("parse error '%U'", format_unformat_error, input);
15398 errmsg ("locator-set name not set!");
15402 M (ONE_PITR_SET_LOCATOR_SET, mp);
15404 mp->is_add = is_add;
15405 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15406 vec_free (ls_name);
15411 /* wait for reply */
15416 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
15419 api_one_nsh_set_locator_set (vat_main_t * vam)
15421 u8 ls_name_set = 0;
15422 unformat_input_t *input = vam->input;
15423 vl_api_one_nsh_set_locator_set_t *mp;
15428 /* Parse args required to build the message */
15429 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15431 if (unformat (input, "del"))
15433 else if (unformat (input, "ls %s", &ls_name))
15437 errmsg ("parse error '%U'", format_unformat_error, input);
15442 if (!ls_name_set && is_add)
15444 errmsg ("locator-set name not set!");
15448 M (ONE_NSH_SET_LOCATOR_SET, mp);
15450 mp->is_add = is_add;
15451 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15452 vec_free (ls_name);
15457 /* wait for reply */
15463 api_show_one_pitr (vat_main_t * vam)
15465 vl_api_show_one_pitr_t *mp;
15468 if (!vam->json_output)
15470 print (vam->ofp, "%=20s", "lisp status:");
15473 M (SHOW_ONE_PITR, mp);
15477 /* Wait for a reply... */
15482 #define api_show_lisp_pitr api_show_one_pitr
15485 api_one_use_petr (vat_main_t * vam)
15487 unformat_input_t *input = vam->input;
15488 vl_api_one_use_petr_t *mp;
15493 memset (&ip, 0, sizeof (ip));
15495 /* Parse args required to build the message */
15496 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15498 if (unformat (input, "disable"))
15501 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
15504 ip_addr_version (&ip) = IP4;
15507 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
15510 ip_addr_version (&ip) = IP6;
15514 errmsg ("parse error '%U'", format_unformat_error, input);
15519 M (ONE_USE_PETR, mp);
15521 mp->is_add = is_add;
15524 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
15526 clib_memcpy (mp->address, &ip, 4);
15528 clib_memcpy (mp->address, &ip, 16);
15534 /* wait for reply */
15539 #define api_lisp_use_petr api_one_use_petr
15542 api_show_one_nsh_mapping (vat_main_t * vam)
15544 vl_api_show_one_use_petr_t *mp;
15547 if (!vam->json_output)
15549 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
15552 M (SHOW_ONE_NSH_MAPPING, mp);
15556 /* Wait for a reply... */
15562 api_show_one_use_petr (vat_main_t * vam)
15564 vl_api_show_one_use_petr_t *mp;
15567 if (!vam->json_output)
15569 print (vam->ofp, "%=20s", "Proxy-ETR status:");
15572 M (SHOW_ONE_USE_PETR, mp);
15576 /* Wait for a reply... */
15581 #define api_show_lisp_use_petr api_show_one_use_petr
15584 * Add/delete mapping between vni and vrf
15587 api_one_eid_table_add_del_map (vat_main_t * vam)
15589 unformat_input_t *input = vam->input;
15590 vl_api_one_eid_table_add_del_map_t *mp;
15591 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15592 u32 vni, vrf, bd_index;
15595 /* Parse args required to build the message */
15596 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15598 if (unformat (input, "del"))
15600 else if (unformat (input, "vrf %d", &vrf))
15602 else if (unformat (input, "bd_index %d", &bd_index))
15604 else if (unformat (input, "vni %d", &vni))
15610 if (!vni_set || (!vrf_set && !bd_index_set))
15612 errmsg ("missing arguments!");
15616 if (vrf_set && bd_index_set)
15618 errmsg ("error: both vrf and bd entered!");
15622 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15624 mp->is_add = is_add;
15625 mp->vni = htonl (vni);
15626 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15627 mp->is_l2 = bd_index_set;
15632 /* wait for reply */
15637 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15640 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15642 u32 *action = va_arg (*args, u32 *);
15645 if (unformat (input, "%s", &s))
15647 if (!strcmp ((char *) s, "no-action"))
15649 else if (!strcmp ((char *) s, "natively-forward"))
15651 else if (!strcmp ((char *) s, "send-map-request"))
15653 else if (!strcmp ((char *) s, "drop"))
15657 clib_warning ("invalid action: '%s'", s);
15669 * Add/del remote mapping to/from ONE control plane
15671 * @param vam vpp API test context
15672 * @return return code
15675 api_one_add_del_remote_mapping (vat_main_t * vam)
15677 unformat_input_t *input = vam->input;
15678 vl_api_one_add_del_remote_mapping_t *mp;
15680 lisp_eid_vat_t _eid, *eid = &_eid;
15681 lisp_eid_vat_t _seid, *seid = &_seid;
15682 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15683 u32 action = ~0, p, w, data_len;
15684 ip4_address_t rloc4;
15685 ip6_address_t rloc6;
15686 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15689 memset (&rloc, 0, sizeof (rloc));
15691 /* Parse args required to build the message */
15692 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15694 if (unformat (input, "del-all"))
15698 else if (unformat (input, "del"))
15702 else if (unformat (input, "add"))
15706 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15710 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15714 else if (unformat (input, "vni %d", &vni))
15718 else if (unformat (input, "p %d w %d", &p, &w))
15722 errmsg ("No RLOC configured for setting priority/weight!");
15725 curr_rloc->priority = p;
15726 curr_rloc->weight = w;
15728 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15731 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
15732 vec_add1 (rlocs, rloc);
15733 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15735 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15738 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
15739 vec_add1 (rlocs, rloc);
15740 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15742 else if (unformat (input, "action %U",
15743 unformat_negative_mapping_action, &action))
15749 clib_warning ("parse error '%U'", format_unformat_error, input);
15756 errmsg ("missing params!");
15760 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15762 errmsg ("no action set for negative map-reply!");
15766 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15768 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15769 mp->is_add = is_add;
15770 mp->vni = htonl (vni);
15771 mp->action = (u8) action;
15772 mp->is_src_dst = seid_set;
15773 mp->eid_len = eid->len;
15774 mp->seid_len = seid->len;
15775 mp->del_all = del_all;
15776 mp->eid_type = eid->type;
15777 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15778 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
15780 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15781 clib_memcpy (mp->rlocs, rlocs, data_len);
15787 /* Wait for a reply... */
15792 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15795 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15796 * forwarding entries in data-plane accordingly.
15798 * @param vam vpp API test context
15799 * @return return code
15802 api_one_add_del_adjacency (vat_main_t * vam)
15804 unformat_input_t *input = vam->input;
15805 vl_api_one_add_del_adjacency_t *mp;
15807 ip4_address_t leid4, reid4;
15808 ip6_address_t leid6, reid6;
15809 u8 reid_mac[6] = { 0 };
15810 u8 leid_mac[6] = { 0 };
15811 u8 reid_type, leid_type;
15812 u32 leid_len = 0, reid_len = 0, len;
15816 leid_type = reid_type = (u8) ~ 0;
15818 /* Parse args required to build the message */
15819 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15821 if (unformat (input, "del"))
15825 else if (unformat (input, "add"))
15829 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
15832 reid_type = 0; /* ipv4 */
15835 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
15838 reid_type = 1; /* ipv6 */
15841 else if (unformat (input, "reid %U", unformat_ethernet_address,
15844 reid_type = 2; /* mac */
15846 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
15849 leid_type = 0; /* ipv4 */
15852 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
15855 leid_type = 1; /* ipv6 */
15858 else if (unformat (input, "leid %U", unformat_ethernet_address,
15861 leid_type = 2; /* mac */
15863 else if (unformat (input, "vni %d", &vni))
15869 errmsg ("parse error '%U'", format_unformat_error, input);
15874 if ((u8) ~ 0 == reid_type)
15876 errmsg ("missing params!");
15880 if (leid_type != reid_type)
15882 errmsg ("remote and local EIDs are of different types!");
15886 M (ONE_ADD_DEL_ADJACENCY, mp);
15887 mp->is_add = is_add;
15888 mp->vni = htonl (vni);
15889 mp->leid_len = leid_len;
15890 mp->reid_len = reid_len;
15891 mp->eid_type = reid_type;
15893 switch (mp->eid_type)
15896 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
15897 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
15900 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
15901 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
15904 clib_memcpy (mp->leid, leid_mac, 6);
15905 clib_memcpy (mp->reid, reid_mac, 6);
15908 errmsg ("unknown EID type %d!", mp->eid_type);
15915 /* Wait for a reply... */
15920 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
15923 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
15925 u32 *mode = va_arg (*args, u32 *);
15927 if (unformat (input, "lisp"))
15929 else if (unformat (input, "vxlan"))
15938 api_gpe_get_encap_mode (vat_main_t * vam)
15940 vl_api_gpe_get_encap_mode_t *mp;
15943 /* Construct the API message */
15944 M (GPE_GET_ENCAP_MODE, mp);
15949 /* Wait for a reply... */
15955 api_gpe_set_encap_mode (vat_main_t * vam)
15957 unformat_input_t *input = vam->input;
15958 vl_api_gpe_set_encap_mode_t *mp;
15962 /* Parse args required to build the message */
15963 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15965 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
15971 /* Construct the API message */
15972 M (GPE_SET_ENCAP_MODE, mp);
15979 /* Wait for a reply... */
15985 api_lisp_gpe_add_del_iface (vat_main_t * vam)
15987 unformat_input_t *input = vam->input;
15988 vl_api_gpe_add_del_iface_t *mp;
15989 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
15990 u32 dp_table = 0, vni = 0;
15993 /* Parse args required to build the message */
15994 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15996 if (unformat (input, "up"))
16001 else if (unformat (input, "down"))
16006 else if (unformat (input, "table_id %d", &dp_table))
16010 else if (unformat (input, "bd_id %d", &dp_table))
16015 else if (unformat (input, "vni %d", &vni))
16023 if (action_set == 0)
16025 errmsg ("Action not set");
16028 if (dp_table_set == 0 || vni_set == 0)
16030 errmsg ("vni and dp_table must be set");
16034 /* Construct the API message */
16035 M (GPE_ADD_DEL_IFACE, mp);
16037 mp->is_add = is_add;
16038 mp->dp_table = clib_host_to_net_u32 (dp_table);
16040 mp->vni = clib_host_to_net_u32 (vni);
16045 /* Wait for a reply... */
16051 * Add/del map request itr rlocs from ONE control plane and updates
16053 * @param vam vpp API test context
16054 * @return return code
16057 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
16059 unformat_input_t *input = vam->input;
16060 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
16061 u8 *locator_set_name = 0;
16062 u8 locator_set_name_set = 0;
16066 /* Parse args required to build the message */
16067 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16069 if (unformat (input, "del"))
16073 else if (unformat (input, "%_%v%_", &locator_set_name))
16075 locator_set_name_set = 1;
16079 clib_warning ("parse error '%U'", format_unformat_error, input);
16084 if (is_add && !locator_set_name_set)
16086 errmsg ("itr-rloc is not set!");
16090 if (is_add && vec_len (locator_set_name) > 64)
16092 errmsg ("itr-rloc locator-set name too long");
16093 vec_free (locator_set_name);
16097 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
16098 mp->is_add = is_add;
16101 clib_memcpy (mp->locator_set_name, locator_set_name,
16102 vec_len (locator_set_name));
16106 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
16108 vec_free (locator_set_name);
16113 /* Wait for a reply... */
16118 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
16121 api_one_locator_dump (vat_main_t * vam)
16123 unformat_input_t *input = vam->input;
16124 vl_api_one_locator_dump_t *mp;
16125 vl_api_control_ping_t *mp_ping;
16126 u8 is_index_set = 0, is_name_set = 0;
16131 /* Parse args required to build the message */
16132 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16134 if (unformat (input, "ls_name %_%v%_", &ls_name))
16138 else if (unformat (input, "ls_index %d", &ls_index))
16144 errmsg ("parse error '%U'", format_unformat_error, input);
16149 if (!is_index_set && !is_name_set)
16151 errmsg ("error: expected one of index or name!");
16155 if (is_index_set && is_name_set)
16157 errmsg ("error: only one param expected!");
16161 if (vec_len (ls_name) > 62)
16163 errmsg ("error: locator set name too long!");
16167 if (!vam->json_output)
16169 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
16172 M (ONE_LOCATOR_DUMP, mp);
16173 mp->is_index_set = is_index_set;
16176 mp->ls_index = clib_host_to_net_u32 (ls_index);
16179 vec_add1 (ls_name, 0);
16180 strncpy ((char *) mp->ls_name, (char *) ls_name,
16181 sizeof (mp->ls_name) - 1);
16187 /* Use a control ping for synchronization */
16188 M (CONTROL_PING, mp_ping);
16191 /* Wait for a reply... */
16196 #define api_lisp_locator_dump api_one_locator_dump
16199 api_one_locator_set_dump (vat_main_t * vam)
16201 vl_api_one_locator_set_dump_t *mp;
16202 vl_api_control_ping_t *mp_ping;
16203 unformat_input_t *input = vam->input;
16207 /* Parse args required to build the message */
16208 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16210 if (unformat (input, "local"))
16214 else if (unformat (input, "remote"))
16220 errmsg ("parse error '%U'", format_unformat_error, input);
16225 if (!vam->json_output)
16227 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
16230 M (ONE_LOCATOR_SET_DUMP, mp);
16232 mp->filter = filter;
16237 /* Use a control ping for synchronization */
16238 M (CONTROL_PING, mp_ping);
16241 /* Wait for a reply... */
16246 #define api_lisp_locator_set_dump api_one_locator_set_dump
16249 api_one_eid_table_map_dump (vat_main_t * vam)
16253 unformat_input_t *input = vam->input;
16254 vl_api_one_eid_table_map_dump_t *mp;
16255 vl_api_control_ping_t *mp_ping;
16258 /* Parse args required to build the message */
16259 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16261 if (unformat (input, "l2"))
16266 else if (unformat (input, "l3"))
16273 errmsg ("parse error '%U'", format_unformat_error, input);
16280 errmsg ("expected one of 'l2' or 'l3' parameter!");
16284 if (!vam->json_output)
16286 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
16289 M (ONE_EID_TABLE_MAP_DUMP, mp);
16295 /* Use a control ping for synchronization */
16296 M (CONTROL_PING, mp_ping);
16299 /* Wait for a reply... */
16304 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
16307 api_one_eid_table_vni_dump (vat_main_t * vam)
16309 vl_api_one_eid_table_vni_dump_t *mp;
16310 vl_api_control_ping_t *mp_ping;
16313 if (!vam->json_output)
16315 print (vam->ofp, "VNI");
16318 M (ONE_EID_TABLE_VNI_DUMP, mp);
16323 /* Use a control ping for synchronization */
16324 M (CONTROL_PING, mp_ping);
16327 /* Wait for a reply... */
16332 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
16335 api_one_eid_table_dump (vat_main_t * vam)
16337 unformat_input_t *i = vam->input;
16338 vl_api_one_eid_table_dump_t *mp;
16339 vl_api_control_ping_t *mp_ping;
16340 struct in_addr ip4;
16341 struct in6_addr ip6;
16343 u8 eid_type = ~0, eid_set = 0;
16344 u32 prefix_length = ~0, t, vni = 0;
16347 lisp_nsh_api_t nsh;
16349 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16351 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
16357 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
16363 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
16368 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
16373 else if (unformat (i, "vni %d", &t))
16377 else if (unformat (i, "local"))
16381 else if (unformat (i, "remote"))
16387 errmsg ("parse error '%U'", format_unformat_error, i);
16392 if (!vam->json_output)
16394 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
16395 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
16398 M (ONE_EID_TABLE_DUMP, mp);
16400 mp->filter = filter;
16404 mp->vni = htonl (vni);
16405 mp->eid_type = eid_type;
16409 mp->prefix_length = prefix_length;
16410 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
16413 mp->prefix_length = prefix_length;
16414 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
16417 clib_memcpy (mp->eid, mac, sizeof (mac));
16420 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
16423 errmsg ("unknown EID type %d!", eid_type);
16431 /* Use a control ping for synchronization */
16432 M (CONTROL_PING, mp_ping);
16435 /* Wait for a reply... */
16440 #define api_lisp_eid_table_dump api_one_eid_table_dump
16443 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
16445 unformat_input_t *i = vam->input;
16446 vl_api_gpe_fwd_entries_get_t *mp;
16451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16453 if (unformat (i, "vni %d", &vni))
16459 errmsg ("parse error '%U'", format_unformat_error, i);
16466 errmsg ("vni not set!");
16470 if (!vam->json_output)
16472 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
16476 M (GPE_FWD_ENTRIES_GET, mp);
16477 mp->vni = clib_host_to_net_u32 (vni);
16482 /* Wait for a reply... */
16487 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
16488 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
16489 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
16490 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
16491 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
16492 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
16493 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
16494 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
16497 api_one_adjacencies_get (vat_main_t * vam)
16499 unformat_input_t *i = vam->input;
16500 vl_api_one_adjacencies_get_t *mp;
16505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16507 if (unformat (i, "vni %d", &vni))
16513 errmsg ("parse error '%U'", format_unformat_error, i);
16520 errmsg ("vni not set!");
16524 if (!vam->json_output)
16526 print (vam->ofp, "%s %40s", "leid", "reid");
16529 M (ONE_ADJACENCIES_GET, mp);
16530 mp->vni = clib_host_to_net_u32 (vni);
16535 /* Wait for a reply... */
16540 #define api_lisp_adjacencies_get api_one_adjacencies_get
16543 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
16545 unformat_input_t *i = vam->input;
16546 vl_api_gpe_native_fwd_rpaths_get_t *mp;
16548 u8 ip_family_set = 0, is_ip4 = 1;
16550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16552 if (unformat (i, "ip4"))
16557 else if (unformat (i, "ip6"))
16564 errmsg ("parse error '%U'", format_unformat_error, i);
16569 if (!ip_family_set)
16571 errmsg ("ip family not set!");
16575 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
16576 mp->is_ip4 = is_ip4;
16581 /* Wait for a reply... */
16587 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
16589 vl_api_gpe_fwd_entry_vnis_get_t *mp;
16592 if (!vam->json_output)
16594 print (vam->ofp, "VNIs");
16597 M (GPE_FWD_ENTRY_VNIS_GET, mp);
16602 /* Wait for a reply... */
16608 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
16610 unformat_input_t *i = vam->input;
16611 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
16613 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
16614 struct in_addr ip4;
16615 struct in6_addr ip6;
16616 u32 table_id = 0, nh_sw_if_index = ~0;
16618 memset (&ip4, 0, sizeof (ip4));
16619 memset (&ip6, 0, sizeof (ip6));
16621 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16623 if (unformat (i, "del"))
16625 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
16626 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16631 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
16632 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16637 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
16641 nh_sw_if_index = ~0;
16643 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
16647 nh_sw_if_index = ~0;
16649 else if (unformat (i, "table %d", &table_id))
16653 errmsg ("parse error '%U'", format_unformat_error, i);
16660 errmsg ("nh addr not set!");
16664 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
16665 mp->is_add = is_add;
16666 mp->table_id = clib_host_to_net_u32 (table_id);
16667 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
16668 mp->is_ip4 = is_ip4;
16670 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
16672 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
16677 /* Wait for a reply... */
16683 api_one_map_server_dump (vat_main_t * vam)
16685 vl_api_one_map_server_dump_t *mp;
16686 vl_api_control_ping_t *mp_ping;
16689 if (!vam->json_output)
16691 print (vam->ofp, "%=20s", "Map server");
16694 M (ONE_MAP_SERVER_DUMP, mp);
16698 /* Use a control ping for synchronization */
16699 M (CONTROL_PING, mp_ping);
16702 /* Wait for a reply... */
16707 #define api_lisp_map_server_dump api_one_map_server_dump
16710 api_one_map_resolver_dump (vat_main_t * vam)
16712 vl_api_one_map_resolver_dump_t *mp;
16713 vl_api_control_ping_t *mp_ping;
16716 if (!vam->json_output)
16718 print (vam->ofp, "%=20s", "Map resolver");
16721 M (ONE_MAP_RESOLVER_DUMP, mp);
16725 /* Use a control ping for synchronization */
16726 M (CONTROL_PING, mp_ping);
16729 /* Wait for a reply... */
16734 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
16737 api_one_stats_flush (vat_main_t * vam)
16739 vl_api_one_stats_flush_t *mp;
16742 M (ONE_STATS_FLUSH, mp);
16749 api_one_stats_dump (vat_main_t * vam)
16751 vl_api_one_stats_dump_t *mp;
16752 vl_api_control_ping_t *mp_ping;
16755 M (ONE_STATS_DUMP, mp);
16759 /* Use a control ping for synchronization */
16760 M (CONTROL_PING, mp_ping);
16763 /* Wait for a reply... */
16769 api_show_one_status (vat_main_t * vam)
16771 vl_api_show_one_status_t *mp;
16774 if (!vam->json_output)
16776 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
16779 M (SHOW_ONE_STATUS, mp);
16782 /* Wait for a reply... */
16787 #define api_show_lisp_status api_show_one_status
16790 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
16792 vl_api_gpe_fwd_entry_path_dump_t *mp;
16793 vl_api_control_ping_t *mp_ping;
16794 unformat_input_t *i = vam->input;
16795 u32 fwd_entry_index = ~0;
16798 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16800 if (unformat (i, "index %d", &fwd_entry_index))
16806 if (~0 == fwd_entry_index)
16808 errmsg ("no index specified!");
16812 if (!vam->json_output)
16814 print (vam->ofp, "first line");
16817 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
16821 /* Use a control ping for synchronization */
16822 M (CONTROL_PING, mp_ping);
16825 /* Wait for a reply... */
16831 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
16833 vl_api_one_get_map_request_itr_rlocs_t *mp;
16836 if (!vam->json_output)
16838 print (vam->ofp, "%=20s", "itr-rlocs:");
16841 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
16844 /* Wait for a reply... */
16849 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
16852 api_af_packet_create (vat_main_t * vam)
16854 unformat_input_t *i = vam->input;
16855 vl_api_af_packet_create_t *mp;
16856 u8 *host_if_name = 0;
16858 u8 random_hw_addr = 1;
16861 memset (hw_addr, 0, sizeof (hw_addr));
16863 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16865 if (unformat (i, "name %s", &host_if_name))
16866 vec_add1 (host_if_name, 0);
16867 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16868 random_hw_addr = 0;
16873 if (!vec_len (host_if_name))
16875 errmsg ("host-interface name must be specified");
16879 if (vec_len (host_if_name) > 64)
16881 errmsg ("host-interface name too long");
16885 M (AF_PACKET_CREATE, mp);
16887 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16888 clib_memcpy (mp->hw_addr, hw_addr, 6);
16889 mp->use_random_hw_addr = random_hw_addr;
16890 vec_free (host_if_name);
16898 fprintf (vam->ofp ? vam->ofp : stderr,
16899 " new sw_if_index = %d\n", vam->sw_if_index);
16906 api_af_packet_delete (vat_main_t * vam)
16908 unformat_input_t *i = vam->input;
16909 vl_api_af_packet_delete_t *mp;
16910 u8 *host_if_name = 0;
16913 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16915 if (unformat (i, "name %s", &host_if_name))
16916 vec_add1 (host_if_name, 0);
16921 if (!vec_len (host_if_name))
16923 errmsg ("host-interface name must be specified");
16927 if (vec_len (host_if_name) > 64)
16929 errmsg ("host-interface name too long");
16933 M (AF_PACKET_DELETE, mp);
16935 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16936 vec_free (host_if_name);
16944 api_policer_add_del (vat_main_t * vam)
16946 unformat_input_t *i = vam->input;
16947 vl_api_policer_add_del_t *mp;
16957 u8 color_aware = 0;
16958 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
16961 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
16962 conform_action.dscp = 0;
16963 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
16964 exceed_action.dscp = 0;
16965 violate_action.action_type = SSE2_QOS_ACTION_DROP;
16966 violate_action.dscp = 0;
16968 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16970 if (unformat (i, "del"))
16972 else if (unformat (i, "name %s", &name))
16973 vec_add1 (name, 0);
16974 else if (unformat (i, "cir %u", &cir))
16976 else if (unformat (i, "eir %u", &eir))
16978 else if (unformat (i, "cb %u", &cb))
16980 else if (unformat (i, "eb %u", &eb))
16982 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
16985 else if (unformat (i, "round_type %U", unformat_policer_round_type,
16988 else if (unformat (i, "type %U", unformat_policer_type, &type))
16990 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
16993 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
16996 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
16999 else if (unformat (i, "color-aware"))
17005 if (!vec_len (name))
17007 errmsg ("policer name must be specified");
17011 if (vec_len (name) > 64)
17013 errmsg ("policer name too long");
17017 M (POLICER_ADD_DEL, mp);
17019 clib_memcpy (mp->name, name, vec_len (name));
17021 mp->is_add = is_add;
17026 mp->rate_type = rate_type;
17027 mp->round_type = round_type;
17029 mp->conform_action_type = conform_action.action_type;
17030 mp->conform_dscp = conform_action.dscp;
17031 mp->exceed_action_type = exceed_action.action_type;
17032 mp->exceed_dscp = exceed_action.dscp;
17033 mp->violate_action_type = violate_action.action_type;
17034 mp->violate_dscp = violate_action.dscp;
17035 mp->color_aware = color_aware;
17043 api_policer_dump (vat_main_t * vam)
17045 unformat_input_t *i = vam->input;
17046 vl_api_policer_dump_t *mp;
17047 vl_api_control_ping_t *mp_ping;
17048 u8 *match_name = 0;
17049 u8 match_name_valid = 0;
17052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17054 if (unformat (i, "name %s", &match_name))
17056 vec_add1 (match_name, 0);
17057 match_name_valid = 1;
17063 M (POLICER_DUMP, mp);
17064 mp->match_name_valid = match_name_valid;
17065 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
17066 vec_free (match_name);
17070 /* Use a control ping for synchronization */
17071 M (CONTROL_PING, mp_ping);
17074 /* Wait for a reply... */
17080 api_policer_classify_set_interface (vat_main_t * vam)
17082 unformat_input_t *i = vam->input;
17083 vl_api_policer_classify_set_interface_t *mp;
17085 int sw_if_index_set;
17086 u32 ip4_table_index = ~0;
17087 u32 ip6_table_index = ~0;
17088 u32 l2_table_index = ~0;
17092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17094 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17095 sw_if_index_set = 1;
17096 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17097 sw_if_index_set = 1;
17098 else if (unformat (i, "del"))
17100 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17102 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17104 else if (unformat (i, "l2-table %d", &l2_table_index))
17108 clib_warning ("parse error '%U'", format_unformat_error, i);
17113 if (sw_if_index_set == 0)
17115 errmsg ("missing interface name or sw_if_index");
17119 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
17121 mp->sw_if_index = ntohl (sw_if_index);
17122 mp->ip4_table_index = ntohl (ip4_table_index);
17123 mp->ip6_table_index = ntohl (ip6_table_index);
17124 mp->l2_table_index = ntohl (l2_table_index);
17125 mp->is_add = is_add;
17133 api_policer_classify_dump (vat_main_t * vam)
17135 unformat_input_t *i = vam->input;
17136 vl_api_policer_classify_dump_t *mp;
17137 vl_api_control_ping_t *mp_ping;
17138 u8 type = POLICER_CLASSIFY_N_TABLES;
17141 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
17145 errmsg ("classify table type must be specified");
17149 if (!vam->json_output)
17151 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17154 M (POLICER_CLASSIFY_DUMP, mp);
17159 /* Use a control ping for synchronization */
17160 M (CONTROL_PING, mp_ping);
17163 /* Wait for a reply... */
17169 api_netmap_create (vat_main_t * vam)
17171 unformat_input_t *i = vam->input;
17172 vl_api_netmap_create_t *mp;
17175 u8 random_hw_addr = 1;
17180 memset (hw_addr, 0, sizeof (hw_addr));
17182 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17184 if (unformat (i, "name %s", &if_name))
17185 vec_add1 (if_name, 0);
17186 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17187 random_hw_addr = 0;
17188 else if (unformat (i, "pipe"))
17190 else if (unformat (i, "master"))
17192 else if (unformat (i, "slave"))
17198 if (!vec_len (if_name))
17200 errmsg ("interface name must be specified");
17204 if (vec_len (if_name) > 64)
17206 errmsg ("interface name too long");
17210 M (NETMAP_CREATE, mp);
17212 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
17213 clib_memcpy (mp->hw_addr, hw_addr, 6);
17214 mp->use_random_hw_addr = random_hw_addr;
17215 mp->is_pipe = is_pipe;
17216 mp->is_master = is_master;
17217 vec_free (if_name);
17225 api_netmap_delete (vat_main_t * vam)
17227 unformat_input_t *i = vam->input;
17228 vl_api_netmap_delete_t *mp;
17232 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17234 if (unformat (i, "name %s", &if_name))
17235 vec_add1 (if_name, 0);
17240 if (!vec_len (if_name))
17242 errmsg ("interface name must be specified");
17246 if (vec_len (if_name) > 64)
17248 errmsg ("interface name too long");
17252 M (NETMAP_DELETE, mp);
17254 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
17255 vec_free (if_name);
17263 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
17265 if (fp->afi == IP46_TYPE_IP6)
17267 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17268 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17269 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17270 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17271 format_ip6_address, fp->next_hop);
17272 else if (fp->afi == IP46_TYPE_IP4)
17274 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17275 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17276 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17277 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17278 format_ip4_address, fp->next_hop);
17282 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
17283 vl_api_fib_path2_t * fp)
17285 struct in_addr ip4;
17286 struct in6_addr ip6;
17288 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17289 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17290 vat_json_object_add_uint (node, "is_local", fp->is_local);
17291 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17292 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17293 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17294 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17295 if (fp->afi == IP46_TYPE_IP4)
17297 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17298 vat_json_object_add_ip4 (node, "next_hop", ip4);
17300 else if (fp->afi == IP46_TYPE_IP6)
17302 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17303 vat_json_object_add_ip6 (node, "next_hop", ip6);
17308 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
17310 vat_main_t *vam = &vat_main;
17311 int count = ntohl (mp->mt_count);
17312 vl_api_fib_path2_t *fp;
17315 print (vam->ofp, "[%d]: sw_if_index %d via:",
17316 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
17318 for (i = 0; i < count; i++)
17320 vl_api_mpls_fib_path_print (vam, fp);
17324 print (vam->ofp, "");
17327 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
17328 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
17331 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
17333 vat_main_t *vam = &vat_main;
17334 vat_json_node_t *node = NULL;
17335 int count = ntohl (mp->mt_count);
17336 vl_api_fib_path2_t *fp;
17339 if (VAT_JSON_ARRAY != vam->json_tree.type)
17341 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17342 vat_json_init_array (&vam->json_tree);
17344 node = vat_json_array_add (&vam->json_tree);
17346 vat_json_init_object (node);
17347 vat_json_object_add_uint (node, "tunnel_index",
17348 ntohl (mp->mt_tunnel_index));
17349 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
17351 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
17354 for (i = 0; i < count; i++)
17356 vl_api_mpls_fib_path_json_print (node, fp);
17362 api_mpls_tunnel_dump (vat_main_t * vam)
17364 vl_api_mpls_tunnel_dump_t *mp;
17365 vl_api_control_ping_t *mp_ping;
17369 /* Parse args required to build the message */
17370 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
17372 if (!unformat (vam->input, "tunnel_index %d", &index))
17379 print (vam->ofp, " tunnel_index %d", index);
17381 M (MPLS_TUNNEL_DUMP, mp);
17382 mp->tunnel_index = htonl (index);
17385 /* Use a control ping for synchronization */
17386 M (CONTROL_PING, mp_ping);
17393 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
17394 #define vl_api_mpls_fib_details_t_print vl_noop_handler
17398 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
17400 vat_main_t *vam = &vat_main;
17401 int count = ntohl (mp->count);
17402 vl_api_fib_path2_t *fp;
17406 "table-id %d, label %u, ess_bit %u",
17407 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
17409 for (i = 0; i < count; i++)
17411 vl_api_mpls_fib_path_print (vam, fp);
17416 static void vl_api_mpls_fib_details_t_handler_json
17417 (vl_api_mpls_fib_details_t * mp)
17419 vat_main_t *vam = &vat_main;
17420 int count = ntohl (mp->count);
17421 vat_json_node_t *node = NULL;
17422 vl_api_fib_path2_t *fp;
17425 if (VAT_JSON_ARRAY != vam->json_tree.type)
17427 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17428 vat_json_init_array (&vam->json_tree);
17430 node = vat_json_array_add (&vam->json_tree);
17432 vat_json_init_object (node);
17433 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17434 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
17435 vat_json_object_add_uint (node, "label", ntohl (mp->label));
17436 vat_json_object_add_uint (node, "path_count", count);
17438 for (i = 0; i < count; i++)
17440 vl_api_mpls_fib_path_json_print (node, fp);
17446 api_mpls_fib_dump (vat_main_t * vam)
17448 vl_api_mpls_fib_dump_t *mp;
17449 vl_api_control_ping_t *mp_ping;
17452 M (MPLS_FIB_DUMP, mp);
17455 /* Use a control ping for synchronization */
17456 M (CONTROL_PING, mp_ping);
17463 #define vl_api_ip_fib_details_t_endian vl_noop_handler
17464 #define vl_api_ip_fib_details_t_print vl_noop_handler
17467 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
17469 vat_main_t *vam = &vat_main;
17470 int count = ntohl (mp->count);
17471 vl_api_fib_path_t *fp;
17475 "table-id %d, prefix %U/%d",
17476 ntohl (mp->table_id), format_ip4_address, mp->address,
17477 mp->address_length);
17479 for (i = 0; i < count; i++)
17481 if (fp->afi == IP46_TYPE_IP6)
17483 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17484 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17485 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17486 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17487 format_ip6_address, fp->next_hop);
17488 else if (fp->afi == IP46_TYPE_IP4)
17490 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17491 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17492 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17493 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17494 format_ip4_address, fp->next_hop);
17499 static void vl_api_ip_fib_details_t_handler_json
17500 (vl_api_ip_fib_details_t * mp)
17502 vat_main_t *vam = &vat_main;
17503 int count = ntohl (mp->count);
17504 vat_json_node_t *node = NULL;
17505 struct in_addr ip4;
17506 struct in6_addr ip6;
17507 vl_api_fib_path_t *fp;
17510 if (VAT_JSON_ARRAY != vam->json_tree.type)
17512 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17513 vat_json_init_array (&vam->json_tree);
17515 node = vat_json_array_add (&vam->json_tree);
17517 vat_json_init_object (node);
17518 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17519 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
17520 vat_json_object_add_ip4 (node, "prefix", ip4);
17521 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17522 vat_json_object_add_uint (node, "path_count", count);
17524 for (i = 0; i < count; i++)
17526 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17527 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17528 vat_json_object_add_uint (node, "is_local", fp->is_local);
17529 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17530 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17531 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17532 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17533 if (fp->afi == IP46_TYPE_IP4)
17535 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17536 vat_json_object_add_ip4 (node, "next_hop", ip4);
17538 else if (fp->afi == IP46_TYPE_IP6)
17540 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17541 vat_json_object_add_ip6 (node, "next_hop", ip6);
17547 api_ip_fib_dump (vat_main_t * vam)
17549 vl_api_ip_fib_dump_t *mp;
17550 vl_api_control_ping_t *mp_ping;
17553 M (IP_FIB_DUMP, mp);
17556 /* Use a control ping for synchronization */
17557 M (CONTROL_PING, mp_ping);
17565 api_ip_mfib_dump (vat_main_t * vam)
17567 vl_api_ip_mfib_dump_t *mp;
17568 vl_api_control_ping_t *mp_ping;
17571 M (IP_MFIB_DUMP, mp);
17574 /* Use a control ping for synchronization */
17575 M (CONTROL_PING, mp_ping);
17582 static void vl_api_ip_neighbor_details_t_handler
17583 (vl_api_ip_neighbor_details_t * mp)
17585 vat_main_t *vam = &vat_main;
17587 print (vam->ofp, "%c %U %U",
17588 (mp->is_static) ? 'S' : 'D',
17589 format_ethernet_address, &mp->mac_address,
17590 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
17594 static void vl_api_ip_neighbor_details_t_handler_json
17595 (vl_api_ip_neighbor_details_t * mp)
17598 vat_main_t *vam = &vat_main;
17599 vat_json_node_t *node;
17600 struct in_addr ip4;
17601 struct in6_addr ip6;
17603 if (VAT_JSON_ARRAY != vam->json_tree.type)
17605 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17606 vat_json_init_array (&vam->json_tree);
17608 node = vat_json_array_add (&vam->json_tree);
17610 vat_json_init_object (node);
17611 vat_json_object_add_string_copy (node, "flag",
17612 (mp->is_static) ? (u8 *) "static" : (u8 *)
17615 vat_json_object_add_string_copy (node, "link_layer",
17616 format (0, "%U", format_ethernet_address,
17617 &mp->mac_address));
17621 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
17622 vat_json_object_add_ip6 (node, "ip_address", ip6);
17626 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
17627 vat_json_object_add_ip4 (node, "ip_address", ip4);
17632 api_ip_neighbor_dump (vat_main_t * vam)
17634 unformat_input_t *i = vam->input;
17635 vl_api_ip_neighbor_dump_t *mp;
17636 vl_api_control_ping_t *mp_ping;
17638 u32 sw_if_index = ~0;
17641 /* Parse args required to build the message */
17642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17644 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17646 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17648 else if (unformat (i, "ip6"))
17654 if (sw_if_index == ~0)
17656 errmsg ("missing interface name or sw_if_index");
17660 M (IP_NEIGHBOR_DUMP, mp);
17661 mp->is_ipv6 = (u8) is_ipv6;
17662 mp->sw_if_index = ntohl (sw_if_index);
17665 /* Use a control ping for synchronization */
17666 M (CONTROL_PING, mp_ping);
17673 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
17674 #define vl_api_ip6_fib_details_t_print vl_noop_handler
17677 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
17679 vat_main_t *vam = &vat_main;
17680 int count = ntohl (mp->count);
17681 vl_api_fib_path_t *fp;
17685 "table-id %d, prefix %U/%d",
17686 ntohl (mp->table_id), format_ip6_address, mp->address,
17687 mp->address_length);
17689 for (i = 0; i < count; i++)
17691 if (fp->afi == IP46_TYPE_IP6)
17693 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17694 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17695 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17696 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17697 format_ip6_address, fp->next_hop);
17698 else if (fp->afi == IP46_TYPE_IP4)
17700 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17701 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17702 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17703 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17704 format_ip4_address, fp->next_hop);
17709 static void vl_api_ip6_fib_details_t_handler_json
17710 (vl_api_ip6_fib_details_t * mp)
17712 vat_main_t *vam = &vat_main;
17713 int count = ntohl (mp->count);
17714 vat_json_node_t *node = NULL;
17715 struct in_addr ip4;
17716 struct in6_addr ip6;
17717 vl_api_fib_path_t *fp;
17720 if (VAT_JSON_ARRAY != vam->json_tree.type)
17722 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17723 vat_json_init_array (&vam->json_tree);
17725 node = vat_json_array_add (&vam->json_tree);
17727 vat_json_init_object (node);
17728 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17729 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
17730 vat_json_object_add_ip6 (node, "prefix", ip6);
17731 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17732 vat_json_object_add_uint (node, "path_count", count);
17734 for (i = 0; i < count; i++)
17736 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17737 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17738 vat_json_object_add_uint (node, "is_local", fp->is_local);
17739 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17740 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17741 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17742 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17743 if (fp->afi == IP46_TYPE_IP4)
17745 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17746 vat_json_object_add_ip4 (node, "next_hop", ip4);
17748 else if (fp->afi == IP46_TYPE_IP6)
17750 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17751 vat_json_object_add_ip6 (node, "next_hop", ip6);
17757 api_ip6_fib_dump (vat_main_t * vam)
17759 vl_api_ip6_fib_dump_t *mp;
17760 vl_api_control_ping_t *mp_ping;
17763 M (IP6_FIB_DUMP, mp);
17766 /* Use a control ping for synchronization */
17767 M (CONTROL_PING, mp_ping);
17775 api_ip6_mfib_dump (vat_main_t * vam)
17777 vl_api_ip6_mfib_dump_t *mp;
17778 vl_api_control_ping_t *mp_ping;
17781 M (IP6_MFIB_DUMP, mp);
17784 /* Use a control ping for synchronization */
17785 M (CONTROL_PING, mp_ping);
17793 api_classify_table_ids (vat_main_t * vam)
17795 vl_api_classify_table_ids_t *mp;
17798 /* Construct the API message */
17799 M (CLASSIFY_TABLE_IDS, mp);
17808 api_classify_table_by_interface (vat_main_t * vam)
17810 unformat_input_t *input = vam->input;
17811 vl_api_classify_table_by_interface_t *mp;
17813 u32 sw_if_index = ~0;
17815 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17817 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17819 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17824 if (sw_if_index == ~0)
17826 errmsg ("missing interface name or sw_if_index");
17830 /* Construct the API message */
17831 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
17833 mp->sw_if_index = ntohl (sw_if_index);
17841 api_classify_table_info (vat_main_t * vam)
17843 unformat_input_t *input = vam->input;
17844 vl_api_classify_table_info_t *mp;
17848 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17850 if (unformat (input, "table_id %d", &table_id))
17855 if (table_id == ~0)
17857 errmsg ("missing table id");
17861 /* Construct the API message */
17862 M (CLASSIFY_TABLE_INFO, mp);
17864 mp->table_id = ntohl (table_id);
17872 api_classify_session_dump (vat_main_t * vam)
17874 unformat_input_t *input = vam->input;
17875 vl_api_classify_session_dump_t *mp;
17876 vl_api_control_ping_t *mp_ping;
17880 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17882 if (unformat (input, "table_id %d", &table_id))
17887 if (table_id == ~0)
17889 errmsg ("missing table id");
17893 /* Construct the API message */
17894 M (CLASSIFY_SESSION_DUMP, mp);
17896 mp->table_id = ntohl (table_id);
17899 /* Use a control ping for synchronization */
17900 M (CONTROL_PING, mp_ping);
17908 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
17910 vat_main_t *vam = &vat_main;
17912 print (vam->ofp, "collector_address %U, collector_port %d, "
17913 "src_address %U, vrf_id %d, path_mtu %u, "
17914 "template_interval %u, udp_checksum %d",
17915 format_ip4_address, mp->collector_address,
17916 ntohs (mp->collector_port),
17917 format_ip4_address, mp->src_address,
17918 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
17919 ntohl (mp->template_interval), mp->udp_checksum);
17922 vam->result_ready = 1;
17926 vl_api_ipfix_exporter_details_t_handler_json
17927 (vl_api_ipfix_exporter_details_t * mp)
17929 vat_main_t *vam = &vat_main;
17930 vat_json_node_t node;
17931 struct in_addr collector_address;
17932 struct in_addr src_address;
17934 vat_json_init_object (&node);
17935 clib_memcpy (&collector_address, &mp->collector_address,
17936 sizeof (collector_address));
17937 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
17938 vat_json_object_add_uint (&node, "collector_port",
17939 ntohs (mp->collector_port));
17940 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
17941 vat_json_object_add_ip4 (&node, "src_address", src_address);
17942 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
17943 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
17944 vat_json_object_add_uint (&node, "template_interval",
17945 ntohl (mp->template_interval));
17946 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
17948 vat_json_print (vam->ofp, &node);
17949 vat_json_free (&node);
17951 vam->result_ready = 1;
17955 api_ipfix_exporter_dump (vat_main_t * vam)
17957 vl_api_ipfix_exporter_dump_t *mp;
17960 /* Construct the API message */
17961 M (IPFIX_EXPORTER_DUMP, mp);
17970 api_ipfix_classify_stream_dump (vat_main_t * vam)
17972 vl_api_ipfix_classify_stream_dump_t *mp;
17975 /* Construct the API message */
17976 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
17987 vl_api_ipfix_classify_stream_details_t_handler
17988 (vl_api_ipfix_classify_stream_details_t * mp)
17990 vat_main_t *vam = &vat_main;
17991 print (vam->ofp, "domain_id %d, src_port %d",
17992 ntohl (mp->domain_id), ntohs (mp->src_port));
17994 vam->result_ready = 1;
17998 vl_api_ipfix_classify_stream_details_t_handler_json
17999 (vl_api_ipfix_classify_stream_details_t * mp)
18001 vat_main_t *vam = &vat_main;
18002 vat_json_node_t node;
18004 vat_json_init_object (&node);
18005 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
18006 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
18008 vat_json_print (vam->ofp, &node);
18009 vat_json_free (&node);
18011 vam->result_ready = 1;
18015 api_ipfix_classify_table_dump (vat_main_t * vam)
18017 vl_api_ipfix_classify_table_dump_t *mp;
18018 vl_api_control_ping_t *mp_ping;
18021 if (!vam->json_output)
18023 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
18024 "transport_protocol");
18027 /* Construct the API message */
18028 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
18033 /* Use a control ping for synchronization */
18034 M (CONTROL_PING, mp_ping);
18042 vl_api_ipfix_classify_table_details_t_handler
18043 (vl_api_ipfix_classify_table_details_t * mp)
18045 vat_main_t *vam = &vat_main;
18046 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
18047 mp->transport_protocol);
18051 vl_api_ipfix_classify_table_details_t_handler_json
18052 (vl_api_ipfix_classify_table_details_t * mp)
18054 vat_json_node_t *node = NULL;
18055 vat_main_t *vam = &vat_main;
18057 if (VAT_JSON_ARRAY != vam->json_tree.type)
18059 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18060 vat_json_init_array (&vam->json_tree);
18063 node = vat_json_array_add (&vam->json_tree);
18064 vat_json_init_object (node);
18066 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
18067 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
18068 vat_json_object_add_uint (node, "transport_protocol",
18069 mp->transport_protocol);
18073 api_sw_interface_span_enable_disable (vat_main_t * vam)
18075 unformat_input_t *i = vam->input;
18076 vl_api_sw_interface_span_enable_disable_t *mp;
18077 u32 src_sw_if_index = ~0;
18078 u32 dst_sw_if_index = ~0;
18082 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18085 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
18087 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
18091 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
18093 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
18095 else if (unformat (i, "disable"))
18097 else if (unformat (i, "rx"))
18099 else if (unformat (i, "tx"))
18101 else if (unformat (i, "both"))
18107 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
18109 mp->sw_if_index_from = htonl (src_sw_if_index);
18110 mp->sw_if_index_to = htonl (dst_sw_if_index);
18119 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
18122 vat_main_t *vam = &vat_main;
18123 u8 *sw_if_from_name = 0;
18124 u8 *sw_if_to_name = 0;
18125 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18126 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18127 char *states[] = { "none", "rx", "tx", "both" };
18131 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18133 if ((u32) p->value[0] == sw_if_index_from)
18135 sw_if_from_name = (u8 *)(p->key);
18139 if ((u32) p->value[0] == sw_if_index_to)
18141 sw_if_to_name = (u8 *)(p->key);
18142 if (sw_if_from_name)
18147 print (vam->ofp, "%20s => %20s (%s)",
18148 sw_if_from_name, sw_if_to_name, states[mp->state]);
18152 vl_api_sw_interface_span_details_t_handler_json
18153 (vl_api_sw_interface_span_details_t * mp)
18155 vat_main_t *vam = &vat_main;
18156 vat_json_node_t *node = NULL;
18157 u8 *sw_if_from_name = 0;
18158 u8 *sw_if_to_name = 0;
18159 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18160 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18164 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18166 if ((u32) p->value[0] == sw_if_index_from)
18168 sw_if_from_name = (u8 *)(p->key);
18172 if ((u32) p->value[0] == sw_if_index_to)
18174 sw_if_to_name = (u8 *)(p->key);
18175 if (sw_if_from_name)
18181 if (VAT_JSON_ARRAY != vam->json_tree.type)
18183 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18184 vat_json_init_array (&vam->json_tree);
18186 node = vat_json_array_add (&vam->json_tree);
18188 vat_json_init_object (node);
18189 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
18190 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
18191 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
18192 if (0 != sw_if_to_name)
18194 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
18196 vat_json_object_add_uint (node, "state", mp->state);
18200 api_sw_interface_span_dump (vat_main_t * vam)
18202 vl_api_sw_interface_span_dump_t *mp;
18203 vl_api_control_ping_t *mp_ping;
18206 M (SW_INTERFACE_SPAN_DUMP, mp);
18209 /* Use a control ping for synchronization */
18210 M (CONTROL_PING, mp_ping);
18218 api_pg_create_interface (vat_main_t * vam)
18220 unformat_input_t *input = vam->input;
18221 vl_api_pg_create_interface_t *mp;
18225 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18227 if (unformat (input, "if_id %d", &if_id))
18234 errmsg ("missing pg interface index");
18238 /* Construct the API message */
18239 M (PG_CREATE_INTERFACE, mp);
18241 mp->interface_id = ntohl (if_id);
18249 api_pg_capture (vat_main_t * vam)
18251 unformat_input_t *input = vam->input;
18252 vl_api_pg_capture_t *mp;
18257 u8 pcap_file_set = 0;
18260 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18262 if (unformat (input, "if_id %d", &if_id))
18264 else if (unformat (input, "pcap %s", &pcap_file))
18266 else if (unformat (input, "count %d", &count))
18268 else if (unformat (input, "disable"))
18275 errmsg ("missing pg interface index");
18278 if (pcap_file_set > 0)
18280 if (vec_len (pcap_file) > 255)
18282 errmsg ("pcap file name is too long");
18287 u32 name_len = vec_len (pcap_file);
18288 /* Construct the API message */
18289 M (PG_CAPTURE, mp);
18291 mp->interface_id = ntohl (if_id);
18292 mp->is_enabled = enable;
18293 mp->count = ntohl (count);
18294 mp->pcap_name_length = ntohl (name_len);
18295 if (pcap_file_set != 0)
18297 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
18299 vec_free (pcap_file);
18307 api_pg_enable_disable (vat_main_t * vam)
18309 unformat_input_t *input = vam->input;
18310 vl_api_pg_enable_disable_t *mp;
18313 u8 stream_name_set = 0;
18314 u8 *stream_name = 0;
18316 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18318 if (unformat (input, "stream %s", &stream_name))
18319 stream_name_set = 1;
18320 else if (unformat (input, "disable"))
18326 if (stream_name_set > 0)
18328 if (vec_len (stream_name) > 255)
18330 errmsg ("stream name too long");
18335 u32 name_len = vec_len (stream_name);
18336 /* Construct the API message */
18337 M (PG_ENABLE_DISABLE, mp);
18339 mp->is_enabled = enable;
18340 if (stream_name_set != 0)
18342 mp->stream_name_length = ntohl (name_len);
18343 clib_memcpy (mp->stream_name, stream_name, name_len);
18345 vec_free (stream_name);
18353 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
18355 unformat_input_t *input = vam->input;
18356 vl_api_ip_source_and_port_range_check_add_del_t *mp;
18358 u16 *low_ports = 0;
18359 u16 *high_ports = 0;
18362 ip4_address_t ip4_addr;
18363 ip6_address_t ip6_addr;
18372 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18374 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
18380 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
18385 else if (unformat (input, "vrf %d", &vrf_id))
18387 else if (unformat (input, "del"))
18389 else if (unformat (input, "port %d", &tmp))
18391 if (tmp == 0 || tmp > 65535)
18393 errmsg ("port %d out of range", tmp);
18397 this_hi = this_low + 1;
18398 vec_add1 (low_ports, this_low);
18399 vec_add1 (high_ports, this_hi);
18401 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
18403 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
18405 errmsg ("incorrect range parameters");
18409 /* Note: in debug CLI +1 is added to high before
18410 passing to real fn that does "the work"
18411 (ip_source_and_port_range_check_add_del).
18412 This fn is a wrapper around the binary API fn a
18413 control plane will call, which expects this increment
18414 to have occurred. Hence letting the binary API control
18415 plane fn do the increment for consistency between VAT
18416 and other control planes.
18419 vec_add1 (low_ports, this_low);
18420 vec_add1 (high_ports, this_hi);
18426 if (prefix_set == 0)
18428 errmsg ("<address>/<mask> not specified");
18434 errmsg ("VRF ID required, not specified");
18441 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18445 if (vec_len (low_ports) == 0)
18447 errmsg ("At least one port or port range required");
18451 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
18453 mp->is_add = is_add;
18458 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
18463 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
18466 mp->mask_length = length;
18467 mp->number_of_ranges = vec_len (low_ports);
18469 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
18470 vec_free (low_ports);
18472 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
18473 vec_free (high_ports);
18475 mp->vrf_id = ntohl (vrf_id);
18483 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
18485 unformat_input_t *input = vam->input;
18486 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
18487 u32 sw_if_index = ~0;
18489 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
18490 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
18494 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18496 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18498 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18500 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
18502 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
18504 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
18506 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
18508 else if (unformat (input, "del"))
18514 if (sw_if_index == ~0)
18516 errmsg ("Interface required but not specified");
18522 errmsg ("VRF ID required but not specified");
18526 if (tcp_out_vrf_id == 0
18527 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
18530 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18534 /* Construct the API message */
18535 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
18537 mp->sw_if_index = ntohl (sw_if_index);
18538 mp->is_add = is_add;
18539 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
18540 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
18541 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
18542 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
18547 /* Wait for a reply... */
18553 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
18555 unformat_input_t *i = vam->input;
18556 vl_api_ipsec_gre_add_del_tunnel_t *mp;
18557 u32 local_sa_id = 0;
18558 u32 remote_sa_id = 0;
18559 ip4_address_t src_address;
18560 ip4_address_t dst_address;
18564 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18566 if (unformat (i, "local_sa %d", &local_sa_id))
18568 else if (unformat (i, "remote_sa %d", &remote_sa_id))
18570 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
18572 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
18574 else if (unformat (i, "del"))
18578 clib_warning ("parse error '%U'", format_unformat_error, i);
18583 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
18585 mp->local_sa_id = ntohl (local_sa_id);
18586 mp->remote_sa_id = ntohl (remote_sa_id);
18587 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
18588 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
18589 mp->is_add = is_add;
18597 api_punt (vat_main_t * vam)
18599 unformat_input_t *i = vam->input;
18607 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18609 if (unformat (i, "ip %d", &ipv))
18611 else if (unformat (i, "protocol %d", &protocol))
18613 else if (unformat (i, "port %d", &port))
18615 else if (unformat (i, "del"))
18619 clib_warning ("parse error '%U'", format_unformat_error, i);
18626 mp->is_add = (u8) is_add;
18627 mp->ipv = (u8) ipv;
18628 mp->l4_protocol = (u8) protocol;
18629 mp->l4_port = htons ((u16) port);
18636 static void vl_api_ipsec_gre_tunnel_details_t_handler
18637 (vl_api_ipsec_gre_tunnel_details_t * mp)
18639 vat_main_t *vam = &vat_main;
18641 print (vam->ofp, "%11d%15U%15U%14d%14d",
18642 ntohl (mp->sw_if_index),
18643 format_ip4_address, &mp->src_address,
18644 format_ip4_address, &mp->dst_address,
18645 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
18648 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
18649 (vl_api_ipsec_gre_tunnel_details_t * mp)
18651 vat_main_t *vam = &vat_main;
18652 vat_json_node_t *node = NULL;
18653 struct in_addr ip4;
18655 if (VAT_JSON_ARRAY != vam->json_tree.type)
18657 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18658 vat_json_init_array (&vam->json_tree);
18660 node = vat_json_array_add (&vam->json_tree);
18662 vat_json_init_object (node);
18663 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18664 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
18665 vat_json_object_add_ip4 (node, "src_address", ip4);
18666 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
18667 vat_json_object_add_ip4 (node, "dst_address", ip4);
18668 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
18669 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
18673 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
18675 unformat_input_t *i = vam->input;
18676 vl_api_ipsec_gre_tunnel_dump_t *mp;
18677 vl_api_control_ping_t *mp_ping;
18679 u8 sw_if_index_set = 0;
18682 /* Parse args required to build the message */
18683 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18685 if (unformat (i, "sw_if_index %d", &sw_if_index))
18686 sw_if_index_set = 1;
18691 if (sw_if_index_set == 0)
18696 if (!vam->json_output)
18698 print (vam->ofp, "%11s%15s%15s%14s%14s",
18699 "sw_if_index", "src_address", "dst_address",
18700 "local_sa_id", "remote_sa_id");
18703 /* Get list of gre-tunnel interfaces */
18704 M (IPSEC_GRE_TUNNEL_DUMP, mp);
18706 mp->sw_if_index = htonl (sw_if_index);
18710 /* Use a control ping for synchronization */
18711 M (CONTROL_PING, mp_ping);
18719 api_delete_subif (vat_main_t * vam)
18721 unformat_input_t *i = vam->input;
18722 vl_api_delete_subif_t *mp;
18723 u32 sw_if_index = ~0;
18726 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18728 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18730 if (unformat (i, "sw_if_index %d", &sw_if_index))
18736 if (sw_if_index == ~0)
18738 errmsg ("missing sw_if_index");
18742 /* Construct the API message */
18743 M (DELETE_SUBIF, mp);
18744 mp->sw_if_index = ntohl (sw_if_index);
18751 #define foreach_pbb_vtr_op \
18752 _("disable", L2_VTR_DISABLED) \
18753 _("pop", L2_VTR_POP_2) \
18754 _("push", L2_VTR_PUSH_2)
18757 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
18759 unformat_input_t *i = vam->input;
18760 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
18761 u32 sw_if_index = ~0, vtr_op = ~0;
18762 u16 outer_tag = ~0;
18763 u8 dmac[6], smac[6];
18764 u8 dmac_set = 0, smac_set = 0;
18770 /* Shut up coverity */
18771 memset (dmac, 0, sizeof (dmac));
18772 memset (smac, 0, sizeof (smac));
18774 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18776 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18778 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18780 else if (unformat (i, "vtr_op %d", &vtr_op))
18782 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
18785 else if (unformat (i, "translate_pbb_stag"))
18787 if (unformat (i, "%d", &tmp))
18789 vtr_op = L2_VTR_TRANSLATE_2_1;
18795 ("translate_pbb_stag operation requires outer tag definition");
18799 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
18801 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
18803 else if (unformat (i, "sid %d", &sid))
18805 else if (unformat (i, "vlanid %d", &tmp))
18809 clib_warning ("parse error '%U'", format_unformat_error, i);
18814 if ((sw_if_index == ~0) || (vtr_op == ~0))
18816 errmsg ("missing sw_if_index or vtr operation");
18819 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
18820 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
18823 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
18827 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
18828 mp->sw_if_index = ntohl (sw_if_index);
18829 mp->vtr_op = ntohl (vtr_op);
18830 mp->outer_tag = ntohs (outer_tag);
18831 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
18832 clib_memcpy (mp->b_smac, smac, sizeof (smac));
18833 mp->b_vlanid = ntohs (vlanid);
18834 mp->i_sid = ntohl (sid);
18842 api_flow_classify_set_interface (vat_main_t * vam)
18844 unformat_input_t *i = vam->input;
18845 vl_api_flow_classify_set_interface_t *mp;
18847 int sw_if_index_set;
18848 u32 ip4_table_index = ~0;
18849 u32 ip6_table_index = ~0;
18853 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18855 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18856 sw_if_index_set = 1;
18857 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18858 sw_if_index_set = 1;
18859 else if (unformat (i, "del"))
18861 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18863 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18867 clib_warning ("parse error '%U'", format_unformat_error, i);
18872 if (sw_if_index_set == 0)
18874 errmsg ("missing interface name or sw_if_index");
18878 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
18880 mp->sw_if_index = ntohl (sw_if_index);
18881 mp->ip4_table_index = ntohl (ip4_table_index);
18882 mp->ip6_table_index = ntohl (ip6_table_index);
18883 mp->is_add = is_add;
18891 api_flow_classify_dump (vat_main_t * vam)
18893 unformat_input_t *i = vam->input;
18894 vl_api_flow_classify_dump_t *mp;
18895 vl_api_control_ping_t *mp_ping;
18896 u8 type = FLOW_CLASSIFY_N_TABLES;
18899 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
18903 errmsg ("classify table type must be specified");
18907 if (!vam->json_output)
18909 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18912 M (FLOW_CLASSIFY_DUMP, mp);
18917 /* Use a control ping for synchronization */
18918 M (CONTROL_PING, mp_ping);
18921 /* Wait for a reply... */
18927 api_feature_enable_disable (vat_main_t * vam)
18929 unformat_input_t *i = vam->input;
18930 vl_api_feature_enable_disable_t *mp;
18932 u8 *feature_name = 0;
18933 u32 sw_if_index = ~0;
18937 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18939 if (unformat (i, "arc_name %s", &arc_name))
18941 else if (unformat (i, "feature_name %s", &feature_name))
18944 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18946 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18948 else if (unformat (i, "disable"))
18956 errmsg ("missing arc name");
18959 if (vec_len (arc_name) > 63)
18961 errmsg ("arc name too long");
18964 if (feature_name == 0)
18966 errmsg ("missing feature name");
18969 if (vec_len (feature_name) > 63)
18971 errmsg ("feature name too long");
18974 if (sw_if_index == ~0)
18976 errmsg ("missing interface name or sw_if_index");
18980 /* Construct the API message */
18981 M (FEATURE_ENABLE_DISABLE, mp);
18982 mp->sw_if_index = ntohl (sw_if_index);
18983 mp->enable = enable;
18984 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
18985 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
18986 vec_free (arc_name);
18987 vec_free (feature_name);
18995 api_sw_interface_tag_add_del (vat_main_t * vam)
18997 unformat_input_t *i = vam->input;
18998 vl_api_sw_interface_tag_add_del_t *mp;
18999 u32 sw_if_index = ~0;
19004 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19006 if (unformat (i, "tag %s", &tag))
19008 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19010 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19012 else if (unformat (i, "del"))
19018 if (sw_if_index == ~0)
19020 errmsg ("missing interface name or sw_if_index");
19024 if (enable && (tag == 0))
19026 errmsg ("no tag specified");
19030 /* Construct the API message */
19031 M (SW_INTERFACE_TAG_ADD_DEL, mp);
19032 mp->sw_if_index = ntohl (sw_if_index);
19033 mp->is_add = enable;
19035 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
19043 static void vl_api_l2_xconnect_details_t_handler
19044 (vl_api_l2_xconnect_details_t * mp)
19046 vat_main_t *vam = &vat_main;
19048 print (vam->ofp, "%15d%15d",
19049 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
19052 static void vl_api_l2_xconnect_details_t_handler_json
19053 (vl_api_l2_xconnect_details_t * mp)
19055 vat_main_t *vam = &vat_main;
19056 vat_json_node_t *node = NULL;
19058 if (VAT_JSON_ARRAY != vam->json_tree.type)
19060 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19061 vat_json_init_array (&vam->json_tree);
19063 node = vat_json_array_add (&vam->json_tree);
19065 vat_json_init_object (node);
19066 vat_json_object_add_uint (node, "rx_sw_if_index",
19067 ntohl (mp->rx_sw_if_index));
19068 vat_json_object_add_uint (node, "tx_sw_if_index",
19069 ntohl (mp->tx_sw_if_index));
19073 api_l2_xconnect_dump (vat_main_t * vam)
19075 vl_api_l2_xconnect_dump_t *mp;
19076 vl_api_control_ping_t *mp_ping;
19079 if (!vam->json_output)
19081 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
19084 M (L2_XCONNECT_DUMP, mp);
19088 /* Use a control ping for synchronization */
19089 M (CONTROL_PING, mp_ping);
19097 api_sw_interface_set_mtu (vat_main_t * vam)
19099 unformat_input_t *i = vam->input;
19100 vl_api_sw_interface_set_mtu_t *mp;
19101 u32 sw_if_index = ~0;
19105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19107 if (unformat (i, "mtu %d", &mtu))
19109 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19111 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19117 if (sw_if_index == ~0)
19119 errmsg ("missing interface name or sw_if_index");
19125 errmsg ("no mtu specified");
19129 /* Construct the API message */
19130 M (SW_INTERFACE_SET_MTU, mp);
19131 mp->sw_if_index = ntohl (sw_if_index);
19132 mp->mtu = ntohs ((u16) mtu);
19140 api_p2p_ethernet_add (vat_main_t * vam)
19142 unformat_input_t *i = vam->input;
19143 vl_api_p2p_ethernet_add_t *mp;
19144 u32 parent_if_index = ~0;
19149 memset (remote_mac, 0, sizeof (remote_mac));
19150 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19152 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19154 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19158 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19162 clib_warning ("parse error '%U'", format_unformat_error, i);
19167 if (parent_if_index == ~0)
19169 errmsg ("missing interface name or sw_if_index");
19174 errmsg ("missing remote mac address");
19178 M (P2P_ETHERNET_ADD, mp);
19179 mp->parent_if_index = ntohl (parent_if_index);
19180 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19188 api_p2p_ethernet_del (vat_main_t * vam)
19190 unformat_input_t *i = vam->input;
19191 vl_api_p2p_ethernet_del_t *mp;
19192 u32 parent_if_index = ~0;
19197 memset (remote_mac, 0, sizeof (remote_mac));
19198 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19200 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19202 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19206 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19210 clib_warning ("parse error '%U'", format_unformat_error, i);
19215 if (parent_if_index == ~0)
19217 errmsg ("missing interface name or sw_if_index");
19222 errmsg ("missing remote mac address");
19226 M (P2P_ETHERNET_DEL, mp);
19227 mp->parent_if_index = ntohl (parent_if_index);
19228 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19236 q_or_quit (vat_main_t * vam)
19238 #if VPP_API_TEST_BUILTIN == 0
19239 longjmp (vam->jump_buf, 1);
19241 return 0; /* not so much */
19245 q (vat_main_t * vam)
19247 return q_or_quit (vam);
19251 quit (vat_main_t * vam)
19253 return q_or_quit (vam);
19257 comment (vat_main_t * vam)
19263 cmd_cmp (void *a1, void *a2)
19268 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
19272 help (vat_main_t * vam)
19277 unformat_input_t *i = vam->input;
19280 if (unformat (i, "%s", &name))
19284 vec_add1 (name, 0);
19286 hs = hash_get_mem (vam->help_by_name, name);
19288 print (vam->ofp, "usage: %s %s", name, hs[0]);
19290 print (vam->ofp, "No such msg / command '%s'", name);
19295 print (vam->ofp, "Help is available for the following:");
19298 hash_foreach_pair (p, vam->function_by_name,
19300 vec_add1 (cmds, (u8 *)(p->key));
19304 vec_sort_with_function (cmds, cmd_cmp);
19306 for (j = 0; j < vec_len (cmds); j++)
19307 print (vam->ofp, "%s", cmds[j]);
19314 set (vat_main_t * vam)
19316 u8 *name = 0, *value = 0;
19317 unformat_input_t *i = vam->input;
19319 if (unformat (i, "%s", &name))
19321 /* The input buffer is a vector, not a string. */
19322 value = vec_dup (i->buffer);
19323 vec_delete (value, i->index, 0);
19324 /* Almost certainly has a trailing newline */
19325 if (value[vec_len (value) - 1] == '\n')
19326 value[vec_len (value) - 1] = 0;
19327 /* Make sure it's a proper string, one way or the other */
19328 vec_add1 (value, 0);
19329 (void) clib_macro_set_value (&vam->macro_main,
19330 (char *) name, (char *) value);
19333 errmsg ("usage: set <name> <value>");
19341 unset (vat_main_t * vam)
19345 if (unformat (vam->input, "%s", &name))
19346 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
19347 errmsg ("unset: %s wasn't set", name);
19360 macro_sort_cmp (void *a1, void *a2)
19362 macro_sort_t *s1 = a1;
19363 macro_sort_t *s2 = a2;
19365 return strcmp ((char *) (s1->name), (char *) (s2->name));
19369 dump_macro_table (vat_main_t * vam)
19371 macro_sort_t *sort_me = 0, *sm;
19376 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
19378 vec_add2 (sort_me, sm, 1);
19379 sm->name = (u8 *)(p->key);
19380 sm->value = (u8 *) (p->value[0]);
19384 vec_sort_with_function (sort_me, macro_sort_cmp);
19386 if (vec_len (sort_me))
19387 print (vam->ofp, "%-15s%s", "Name", "Value");
19389 print (vam->ofp, "The macro table is empty...");
19391 for (i = 0; i < vec_len (sort_me); i++)
19392 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
19397 dump_node_table (vat_main_t * vam)
19400 vlib_node_t *node, *next_node;
19402 if (vec_len (vam->graph_nodes) == 0)
19404 print (vam->ofp, "Node table empty, issue get_node_graph...");
19408 for (i = 0; i < vec_len (vam->graph_nodes); i++)
19410 node = vam->graph_nodes[i];
19411 print (vam->ofp, "[%d] %s", i, node->name);
19412 for (j = 0; j < vec_len (node->next_nodes); j++)
19414 if (node->next_nodes[j] != ~0)
19416 next_node = vam->graph_nodes[node->next_nodes[j]];
19417 print (vam->ofp, " [%d] %s", j, next_node->name);
19425 value_sort_cmp (void *a1, void *a2)
19427 name_sort_t *n1 = a1;
19428 name_sort_t *n2 = a2;
19430 if (n1->value < n2->value)
19432 if (n1->value > n2->value)
19439 dump_msg_api_table (vat_main_t * vam)
19441 api_main_t *am = &api_main;
19442 name_sort_t *nses = 0, *ns;
19447 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
19449 vec_add2 (nses, ns, 1);
19450 ns->name = (u8 *)(hp->key);
19451 ns->value = (u32) hp->value[0];
19455 vec_sort_with_function (nses, value_sort_cmp);
19457 for (i = 0; i < vec_len (nses); i++)
19458 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
19464 get_msg_id (vat_main_t * vam)
19469 if (unformat (vam->input, "%s", &name_and_crc))
19471 message_index = vl_api_get_msg_index (name_and_crc);
19472 if (message_index == ~0)
19474 print (vam->ofp, " '%s' not found", name_and_crc);
19477 print (vam->ofp, " '%s' has message index %d",
19478 name_and_crc, message_index);
19481 errmsg ("name_and_crc required...");
19486 search_node_table (vat_main_t * vam)
19488 unformat_input_t *line_input = vam->input;
19491 vlib_node_t *node, *next_node;
19494 if (vam->graph_node_index_by_name == 0)
19496 print (vam->ofp, "Node table empty, issue get_node_graph...");
19500 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
19502 if (unformat (line_input, "%s", &node_to_find))
19504 vec_add1 (node_to_find, 0);
19505 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
19508 print (vam->ofp, "%s not found...", node_to_find);
19511 node = vam->graph_nodes[p[0]];
19512 print (vam->ofp, "[%d] %s", p[0], node->name);
19513 for (j = 0; j < vec_len (node->next_nodes); j++)
19515 if (node->next_nodes[j] != ~0)
19517 next_node = vam->graph_nodes[node->next_nodes[j]];
19518 print (vam->ofp, " [%d] %s", j, next_node->name);
19525 clib_warning ("parse error '%U'", format_unformat_error,
19531 vec_free (node_to_find);
19540 script (vat_main_t * vam)
19542 #if (VPP_API_TEST_BUILTIN==0)
19544 char *save_current_file;
19545 unformat_input_t save_input;
19546 jmp_buf save_jump_buf;
19547 u32 save_line_number;
19549 FILE *new_fp, *save_ifp;
19551 if (unformat (vam->input, "%s", &s))
19553 new_fp = fopen ((char *) s, "r");
19556 errmsg ("Couldn't open script file %s", s);
19563 errmsg ("Missing script name");
19567 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
19568 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
19569 save_ifp = vam->ifp;
19570 save_line_number = vam->input_line_number;
19571 save_current_file = (char *) vam->current_file;
19573 vam->input_line_number = 0;
19575 vam->current_file = s;
19578 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
19579 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
19580 vam->ifp = save_ifp;
19581 vam->input_line_number = save_line_number;
19582 vam->current_file = (u8 *) save_current_file;
19587 clib_warning ("use the exec command...");
19593 echo (vat_main_t * vam)
19595 print (vam->ofp, "%v", vam->input->buffer);
19599 /* List of API message constructors, CLI names map to api_xxx */
19600 #define foreach_vpe_api_msg \
19601 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
19602 _(sw_interface_dump,"") \
19603 _(sw_interface_set_flags, \
19604 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
19605 _(sw_interface_add_del_address, \
19606 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
19607 _(sw_interface_set_table, \
19608 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
19609 _(sw_interface_set_mpls_enable, \
19610 "<intfc> | sw_if_index [disable | dis]") \
19611 _(sw_interface_set_vpath, \
19612 "<intfc> | sw_if_index <id> enable | disable") \
19613 _(sw_interface_set_vxlan_bypass, \
19614 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
19615 _(sw_interface_set_l2_xconnect, \
19616 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
19617 "enable | disable") \
19618 _(sw_interface_set_l2_bridge, \
19619 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
19620 "[shg <split-horizon-group>] [bvi]\n" \
19621 "enable | disable") \
19622 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
19623 _(bridge_domain_add_del, \
19624 "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") \
19625 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
19627 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
19628 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
19629 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
19631 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
19633 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
19635 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
19637 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
19639 "<vpp-if-name> | sw_if_index <id>") \
19640 _(sw_interface_tap_dump, "") \
19641 _(ip_add_del_route, \
19642 "<addr>/<mask> via <addr> [table-id <n>]\n" \
19643 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
19644 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
19645 "[multipath] [count <n>]") \
19646 _(ip_mroute_add_del, \
19647 "<src> <grp>/<mask> [table-id <n>]\n" \
19648 "[<intfc> | sw_if_index <id>] [local] [del]") \
19649 _(mpls_route_add_del, \
19650 "<label> <eos> via <addr> [table-id <n>]\n" \
19651 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
19652 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
19653 "[multipath] [count <n>]") \
19654 _(mpls_ip_bind_unbind, \
19655 "<label> <addr/len>") \
19656 _(mpls_tunnel_add_del, \
19657 " via <addr> [table-id <n>]\n" \
19658 "sw_if_index <id>] [l2] [del]") \
19659 _(proxy_arp_add_del, \
19660 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
19661 _(proxy_arp_intfc_enable_disable, \
19662 "<intfc> | sw_if_index <id> enable | disable") \
19663 _(sw_interface_set_unnumbered, \
19664 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
19665 _(ip_neighbor_add_del, \
19666 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
19667 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
19668 _(reset_vrf, "vrf <id> [ipv6]") \
19669 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
19670 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
19671 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
19672 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
19673 "[outer_vlan_id_any][inner_vlan_id_any]") \
19674 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
19675 _(reset_fib, "vrf <n> [ipv6]") \
19676 _(dhcp_proxy_config, \
19677 "svr <v46-address> src <v46-address>\n" \
19678 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
19679 _(dhcp_proxy_set_vss, \
19680 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
19681 _(dhcp_proxy_dump, "ip6") \
19682 _(dhcp_client_config, \
19683 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
19684 _(set_ip_flow_hash, \
19685 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
19686 _(sw_interface_ip6_enable_disable, \
19687 "<intfc> | sw_if_index <id> enable | disable") \
19688 _(sw_interface_ip6_set_link_local_address, \
19689 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
19690 _(ip6nd_proxy_add_del, \
19691 "<intfc> | sw_if_index <id> <ip6-address>") \
19692 _(ip6nd_proxy_dump, "") \
19693 _(sw_interface_ip6nd_ra_prefix, \
19694 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
19695 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
19696 "[nolink] [isno]") \
19697 _(sw_interface_ip6nd_ra_config, \
19698 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
19699 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
19700 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
19701 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
19702 _(l2_patch_add_del, \
19703 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
19704 "enable | disable") \
19705 _(sr_localsid_add_del, \
19706 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
19707 "fib-table <num> (end.psp) sw_if_index <num>") \
19708 _(classify_add_del_table, \
19709 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
19710 " [del] [del-chain] mask <mask-value>\n" \
19711 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
19712 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
19713 _(classify_add_del_session, \
19714 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
19715 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
19716 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
19717 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
19718 _(classify_set_interface_ip_table, \
19719 "<intfc> | sw_if_index <nn> table <nn>") \
19720 _(classify_set_interface_l2_tables, \
19721 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19722 " [other-table <nn>]") \
19723 _(get_node_index, "node <node-name") \
19724 _(add_node_next, "node <node-name> next <next-node-name>") \
19725 _(l2tpv3_create_tunnel, \
19726 "client_address <ip6-addr> our_address <ip6-addr>\n" \
19727 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
19728 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
19729 _(l2tpv3_set_tunnel_cookies, \
19730 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
19731 "[new_remote_cookie <nn>]\n") \
19732 _(l2tpv3_interface_enable_disable, \
19733 "<intfc> | sw_if_index <nn> enable | disable") \
19734 _(l2tpv3_set_lookup_key, \
19735 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
19736 _(sw_if_l2tpv3_tunnel_dump, "") \
19737 _(vxlan_add_del_tunnel, \
19738 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
19739 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
19740 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
19741 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19742 _(gre_add_del_tunnel, \
19743 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
19744 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19745 _(l2_fib_clear_table, "") \
19746 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
19747 _(l2_interface_vlan_tag_rewrite, \
19748 "<intfc> | sw_if_index <nn> \n" \
19749 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
19750 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
19751 _(create_vhost_user_if, \
19752 "socket <filename> [server] [renumber <dev_instance>] " \
19753 "[mac <mac_address>]") \
19754 _(modify_vhost_user_if, \
19755 "<intfc> | sw_if_index <nn> socket <filename>\n" \
19756 "[server] [renumber <dev_instance>]") \
19757 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
19758 _(sw_interface_vhost_user_dump, "") \
19759 _(show_version, "") \
19760 _(vxlan_gpe_add_del_tunnel, \
19761 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
19762 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
19763 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
19764 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
19765 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19766 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
19767 _(interface_name_renumber, \
19768 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
19769 _(input_acl_set_interface, \
19770 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19771 " [l2-table <nn>] [del]") \
19772 _(want_ip4_arp_events, "address <ip4-address> [del]") \
19773 _(want_ip6_nd_events, "address <ip6-address> [del]") \
19774 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
19775 _(ip_dump, "ipv4 | ipv6") \
19776 _(ipsec_spd_add_del, "spd_id <n> [del]") \
19777 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
19779 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
19780 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
19781 " integ_alg <alg> integ_key <hex>") \
19782 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
19783 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
19784 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
19785 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
19786 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
19787 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
19788 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
19789 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
19790 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
19791 _(ikev2_profile_add_del, "name <profile_name> [del]") \
19792 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
19793 "(auth_data 0x<data> | auth_data <data>)") \
19794 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
19795 "(id_data 0x<data> | id_data <data>) (local|remote)") \
19796 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
19797 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
19798 "(local|remote)") \
19799 _(ikev2_set_local_key, "file <absolute_file_path>") \
19800 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
19801 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
19802 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
19803 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
19804 _(ikev2_initiate_sa_init, "<profile_name>") \
19805 _(ikev2_initiate_del_ike_sa, "<ispi>") \
19806 _(ikev2_initiate_del_child_sa, "<ispi>") \
19807 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
19808 _(delete_loopback,"sw_if_index <nn>") \
19809 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
19810 _(map_add_domain, \
19811 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
19812 "ip6-src <ip6addr> " \
19813 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
19814 _(map_del_domain, "index <n>") \
19815 _(map_add_del_rule, \
19816 "index <n> psid <n> dst <ip6addr> [del]") \
19817 _(map_domain_dump, "") \
19818 _(map_rule_dump, "index <map-domain>") \
19819 _(want_interface_events, "enable|disable") \
19820 _(want_stats,"enable|disable") \
19821 _(get_first_msg_id, "client <name>") \
19822 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
19823 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
19824 "fib-id <nn> [ip4][ip6][default]") \
19825 _(get_node_graph, " ") \
19826 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
19827 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
19828 _(ioam_disable, "") \
19829 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
19830 " sw_if_index <sw_if_index> p <priority> " \
19831 "w <weight>] [del]") \
19832 _(one_add_del_locator, "locator-set <locator_name> " \
19833 "iface <intf> | sw_if_index <sw_if_index> " \
19834 "p <priority> w <weight> [del]") \
19835 _(one_add_del_local_eid,"vni <vni> eid " \
19836 "<ipv4|ipv6>/<prefix> | <L2 address> " \
19837 "locator-set <locator_name> [del]" \
19838 "[key-id sha1|sha256 secret-key <secret-key>]")\
19839 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
19840 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
19841 _(one_enable_disable, "enable|disable") \
19842 _(one_map_register_enable_disable, "enable|disable") \
19843 _(one_rloc_probe_enable_disable, "enable|disable") \
19844 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
19846 "rloc <locator> p <prio> " \
19847 "w <weight> [rloc <loc> ... ] " \
19848 "action <action> [del-all]") \
19849 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
19851 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
19852 _(one_use_petr, "ip-address> | disable") \
19853 _(one_map_request_mode, "src-dst|dst-only") \
19854 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
19855 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
19856 _(one_locator_set_dump, "[local | remote]") \
19857 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
19858 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
19859 "[local] | [remote]") \
19860 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
19861 _(one_l2_arp_bd_get, "") \
19862 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
19863 _(one_stats_enable_disable, "enable|disalbe") \
19864 _(show_one_stats_enable_disable, "") \
19865 _(one_eid_table_vni_dump, "") \
19866 _(one_eid_table_map_dump, "l2|l3") \
19867 _(one_map_resolver_dump, "") \
19868 _(one_map_server_dump, "") \
19869 _(one_adjacencies_get, "vni <vni>") \
19870 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
19871 _(show_one_rloc_probe_state, "") \
19872 _(show_one_map_register_state, "") \
19873 _(show_one_status, "") \
19874 _(one_stats_dump, "") \
19875 _(one_stats_flush, "") \
19876 _(one_get_map_request_itr_rlocs, "") \
19877 _(show_one_nsh_mapping, "") \
19878 _(show_one_pitr, "") \
19879 _(show_one_use_petr, "") \
19880 _(show_one_map_request_mode, "") \
19881 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
19882 " sw_if_index <sw_if_index> p <priority> " \
19883 "w <weight>] [del]") \
19884 _(lisp_add_del_locator, "locator-set <locator_name> " \
19885 "iface <intf> | sw_if_index <sw_if_index> " \
19886 "p <priority> w <weight> [del]") \
19887 _(lisp_add_del_local_eid,"vni <vni> eid " \
19888 "<ipv4|ipv6>/<prefix> | <L2 address> " \
19889 "locator-set <locator_name> [del]" \
19890 "[key-id sha1|sha256 secret-key <secret-key>]") \
19891 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
19892 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
19893 _(lisp_enable_disable, "enable|disable") \
19894 _(lisp_map_register_enable_disable, "enable|disable") \
19895 _(lisp_rloc_probe_enable_disable, "enable|disable") \
19896 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
19898 "rloc <locator> p <prio> " \
19899 "w <weight> [rloc <loc> ... ] " \
19900 "action <action> [del-all]") \
19901 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
19903 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
19904 _(lisp_use_petr, "<ip-address> | disable") \
19905 _(lisp_map_request_mode, "src-dst|dst-only") \
19906 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
19907 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
19908 _(lisp_locator_set_dump, "[local | remote]") \
19909 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
19910 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
19911 "[local] | [remote]") \
19912 _(lisp_eid_table_vni_dump, "") \
19913 _(lisp_eid_table_map_dump, "l2|l3") \
19914 _(lisp_map_resolver_dump, "") \
19915 _(lisp_map_server_dump, "") \
19916 _(lisp_adjacencies_get, "vni <vni>") \
19917 _(gpe_fwd_entry_vnis_get, "") \
19918 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
19919 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
19920 "[table <table-id>]") \
19921 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
19922 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
19923 _(gpe_set_encap_mode, "lisp|vxlan") \
19924 _(gpe_get_encap_mode, "") \
19925 _(lisp_gpe_add_del_iface, "up|down") \
19926 _(lisp_gpe_enable_disable, "enable|disable") \
19927 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
19928 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
19929 _(show_lisp_rloc_probe_state, "") \
19930 _(show_lisp_map_register_state, "") \
19931 _(show_lisp_status, "") \
19932 _(lisp_get_map_request_itr_rlocs, "") \
19933 _(show_lisp_pitr, "") \
19934 _(show_lisp_use_petr, "") \
19935 _(show_lisp_map_request_mode, "") \
19936 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
19937 _(af_packet_delete, "name <host interface name>") \
19938 _(policer_add_del, "name <policer name> <params> [del]") \
19939 _(policer_dump, "[name <policer name>]") \
19940 _(policer_classify_set_interface, \
19941 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19942 " [l2-table <nn>] [del]") \
19943 _(policer_classify_dump, "type [ip4|ip6|l2]") \
19944 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
19945 "[master|slave]") \
19946 _(netmap_delete, "name <interface name>") \
19947 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
19948 _(mpls_fib_dump, "") \
19949 _(classify_table_ids, "") \
19950 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
19951 _(classify_table_info, "table_id <nn>") \
19952 _(classify_session_dump, "table_id <nn>") \
19953 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
19954 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
19955 "[template_interval <nn>] [udp_checksum]") \
19956 _(ipfix_exporter_dump, "") \
19957 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
19958 _(ipfix_classify_stream_dump, "") \
19959 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
19960 _(ipfix_classify_table_dump, "") \
19961 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
19962 _(sw_interface_span_dump, "") \
19963 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
19964 _(pg_create_interface, "if_id <nn>") \
19965 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
19966 _(pg_enable_disable, "[stream <id>] disable") \
19967 _(ip_source_and_port_range_check_add_del, \
19968 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
19969 _(ip_source_and_port_range_check_interface_add_del, \
19970 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
19971 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
19972 _(ipsec_gre_add_del_tunnel, \
19973 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
19974 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
19975 _(delete_subif,"<intfc> | sw_if_index <nn>") \
19976 _(l2_interface_pbb_tag_rewrite, \
19977 "<intfc> | sw_if_index <nn> \n" \
19978 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
19979 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
19980 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
19981 _(flow_classify_set_interface, \
19982 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
19983 _(flow_classify_dump, "type [ip4|ip6]") \
19984 _(ip_fib_dump, "") \
19985 _(ip_mfib_dump, "") \
19986 _(ip6_fib_dump, "") \
19987 _(ip6_mfib_dump, "") \
19988 _(feature_enable_disable, "arc_name <arc_name> " \
19989 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
19990 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
19992 _(l2_xconnect_dump, "") \
19993 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
19994 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
19995 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
19996 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
19997 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>")
19999 /* List of command functions, CLI names map directly to functions */
20000 #define foreach_cli_function \
20001 _(comment, "usage: comment <ignore-rest-of-line>") \
20002 _(dump_interface_table, "usage: dump_interface_table") \
20003 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
20004 _(dump_ipv4_table, "usage: dump_ipv4_table") \
20005 _(dump_ipv6_table, "usage: dump_ipv6_table") \
20006 _(dump_stats_table, "usage: dump_stats_table") \
20007 _(dump_macro_table, "usage: dump_macro_table ") \
20008 _(dump_node_table, "usage: dump_node_table") \
20009 _(dump_msg_api_table, "usage: dump_msg_api_table") \
20010 _(get_msg_id, "usage: get_msg_id name_and_crc") \
20011 _(echo, "usage: echo <message>") \
20012 _(exec, "usage: exec <vpe-debug-CLI-command>") \
20013 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
20014 _(help, "usage: help") \
20015 _(q, "usage: quit") \
20016 _(quit, "usage: quit") \
20017 _(search_node_table, "usage: search_node_table <name>...") \
20018 _(set, "usage: set <variable-name> <value>") \
20019 _(script, "usage: script <file-name>") \
20020 _(unset, "usage: unset <variable-name>")
20023 static void vl_api_##n##_t_handler_uni \
20024 (vl_api_##n##_t * mp) \
20026 vat_main_t * vam = &vat_main; \
20027 if (vam->json_output) { \
20028 vl_api_##n##_t_handler_json(mp); \
20030 vl_api_##n##_t_handler(mp); \
20033 foreach_vpe_api_reply_msg;
20034 #if VPP_API_TEST_BUILTIN == 0
20035 foreach_standalone_reply_msg;
20040 vat_api_hookup (vat_main_t * vam)
20043 vl_msg_api_set_handlers(VL_API_##N, #n, \
20044 vl_api_##n##_t_handler_uni, \
20046 vl_api_##n##_t_endian, \
20047 vl_api_##n##_t_print, \
20048 sizeof(vl_api_##n##_t), 1);
20049 foreach_vpe_api_reply_msg;
20050 #if VPP_API_TEST_BUILTIN == 0
20051 foreach_standalone_reply_msg;
20055 #if (VPP_API_TEST_BUILTIN==0)
20056 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
20058 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
20060 vam->function_by_name = hash_create_string (0, sizeof (uword));
20062 vam->help_by_name = hash_create_string (0, sizeof (uword));
20065 /* API messages we can send */
20066 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
20067 foreach_vpe_api_msg;
20071 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
20072 foreach_vpe_api_msg;
20075 /* CLI functions */
20076 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
20077 foreach_cli_function;
20081 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
20082 foreach_cli_function;
20086 #if VPP_API_TEST_BUILTIN
20087 static clib_error_t *
20088 vat_api_hookup_shim (vlib_main_t * vm)
20090 vat_api_hookup (&vat_main);
20094 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
20098 * fd.io coding-style-patch-verification: ON
20101 * eval: (c-set-style "gnu")