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 = (u8 *) mp->reply_in_shmem;
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 = (u8 *) (mp->reply_in_shmem);
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: address %U new mac %U sw_if_index %d",
1259 mp->mac_ip ? "mac/ip binding" : "address resolution",
1260 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: address %U new mac %U sw_if_index %d",
1275 mp->mac_ip ? "mac/ip binding" : "address resolution",
1276 format_ip6_address, mp->address,
1277 format_ethernet_address, mp->new_mac, sw_if_index);
1281 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1283 /* JSON output not supported */
1287 * Special-case: build the bridge domain table, maintain
1288 * the next bd id vbl.
1290 static void vl_api_bridge_domain_details_t_handler
1291 (vl_api_bridge_domain_details_t * mp)
1293 vat_main_t *vam = &vat_main;
1294 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1296 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1297 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1299 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1300 ntohl (mp->bd_id), mp->learn, mp->forward,
1301 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1304 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG", "Interface Name");
1307 static void vl_api_bridge_domain_details_t_handler_json
1308 (vl_api_bridge_domain_details_t * mp)
1310 vat_main_t *vam = &vat_main;
1311 vat_json_node_t *node, *array = NULL;
1313 if (VAT_JSON_ARRAY != vam->json_tree.type)
1315 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1316 vat_json_init_array (&vam->json_tree);
1318 node = vat_json_array_add (&vam->json_tree);
1320 vat_json_init_object (node);
1321 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1322 vat_json_object_add_uint (node, "flood", mp->flood);
1323 vat_json_object_add_uint (node, "forward", mp->forward);
1324 vat_json_object_add_uint (node, "learn", mp->learn);
1325 vat_json_object_add_uint (node, "bvi_sw_if_index",
1326 ntohl (mp->bvi_sw_if_index));
1327 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1328 array = vat_json_object_add (node, "sw_if");
1329 vat_json_init_array (array);
1333 * Special-case: build the bridge domain sw if table.
1335 static void vl_api_bridge_domain_sw_if_details_t_handler
1336 (vl_api_bridge_domain_sw_if_details_t * mp)
1338 vat_main_t *vam = &vat_main;
1343 sw_if_index = ntohl (mp->sw_if_index);
1345 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1347 if ((u32) p->value[0] == sw_if_index)
1349 sw_if_name = (u8 *)(p->key);
1355 print (vam->ofp, "%7d %3d %s", sw_if_index,
1356 mp->shg, sw_if_name ? (char *) sw_if_name :
1357 "sw_if_index not found!");
1360 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1361 (vl_api_bridge_domain_sw_if_details_t * mp)
1363 vat_main_t *vam = &vat_main;
1364 vat_json_node_t *node = NULL;
1365 uword last_index = 0;
1367 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1368 ASSERT (vec_len (vam->json_tree.array) >= 1);
1369 last_index = vec_len (vam->json_tree.array) - 1;
1370 node = &vam->json_tree.array[last_index];
1371 node = vat_json_object_get_element (node, "sw_if");
1372 ASSERT (NULL != node);
1373 node = vat_json_array_add (node);
1375 vat_json_init_object (node);
1376 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1377 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1378 vat_json_object_add_uint (node, "shg", mp->shg);
1381 static void vl_api_control_ping_reply_t_handler
1382 (vl_api_control_ping_reply_t * mp)
1384 vat_main_t *vam = &vat_main;
1385 i32 retval = ntohl (mp->retval);
1386 if (vam->async_mode)
1388 vam->async_errors += (retval < 0);
1392 vam->retval = retval;
1393 vam->result_ready = 1;
1397 static void vl_api_control_ping_reply_t_handler_json
1398 (vl_api_control_ping_reply_t * mp)
1400 vat_main_t *vam = &vat_main;
1401 i32 retval = ntohl (mp->retval);
1403 if (VAT_JSON_NONE != vam->json_tree.type)
1405 vat_json_print (vam->ofp, &vam->json_tree);
1406 vat_json_free (&vam->json_tree);
1407 vam->json_tree.type = VAT_JSON_NONE;
1412 vat_json_init_array (&vam->json_tree);
1413 vat_json_print (vam->ofp, &vam->json_tree);
1414 vam->json_tree.type = VAT_JSON_NONE;
1417 vam->retval = retval;
1418 vam->result_ready = 1;
1422 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1424 vat_main_t *vam = &vat_main;
1425 i32 retval = ntohl (mp->retval);
1426 if (vam->async_mode)
1428 vam->async_errors += (retval < 0);
1432 vam->retval = retval;
1433 vam->result_ready = 1;
1437 static void vl_api_l2_flags_reply_t_handler_json
1438 (vl_api_l2_flags_reply_t * mp)
1440 vat_main_t *vam = &vat_main;
1441 vat_json_node_t node;
1443 vat_json_init_object (&node);
1444 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1445 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1446 ntohl (mp->resulting_feature_bitmap));
1448 vat_json_print (vam->ofp, &node);
1449 vat_json_free (&node);
1451 vam->retval = ntohl (mp->retval);
1452 vam->result_ready = 1;
1455 static void vl_api_bridge_flags_reply_t_handler
1456 (vl_api_bridge_flags_reply_t * mp)
1458 vat_main_t *vam = &vat_main;
1459 i32 retval = ntohl (mp->retval);
1460 if (vam->async_mode)
1462 vam->async_errors += (retval < 0);
1466 vam->retval = retval;
1467 vam->result_ready = 1;
1471 static void vl_api_bridge_flags_reply_t_handler_json
1472 (vl_api_bridge_flags_reply_t * mp)
1474 vat_main_t *vam = &vat_main;
1475 vat_json_node_t node;
1477 vat_json_init_object (&node);
1478 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1479 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1480 ntohl (mp->resulting_feature_bitmap));
1482 vat_json_print (vam->ofp, &node);
1483 vat_json_free (&node);
1485 vam->retval = ntohl (mp->retval);
1486 vam->result_ready = 1;
1489 static void vl_api_tap_connect_reply_t_handler
1490 (vl_api_tap_connect_reply_t * mp)
1492 vat_main_t *vam = &vat_main;
1493 i32 retval = ntohl (mp->retval);
1494 if (vam->async_mode)
1496 vam->async_errors += (retval < 0);
1500 vam->retval = retval;
1501 vam->sw_if_index = ntohl (mp->sw_if_index);
1502 vam->result_ready = 1;
1507 static void vl_api_tap_connect_reply_t_handler_json
1508 (vl_api_tap_connect_reply_t * mp)
1510 vat_main_t *vam = &vat_main;
1511 vat_json_node_t node;
1513 vat_json_init_object (&node);
1514 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1515 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1517 vat_json_print (vam->ofp, &node);
1518 vat_json_free (&node);
1520 vam->retval = ntohl (mp->retval);
1521 vam->result_ready = 1;
1526 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1528 vat_main_t *vam = &vat_main;
1529 i32 retval = ntohl (mp->retval);
1530 if (vam->async_mode)
1532 vam->async_errors += (retval < 0);
1536 vam->retval = retval;
1537 vam->sw_if_index = ntohl (mp->sw_if_index);
1538 vam->result_ready = 1;
1542 static void vl_api_tap_modify_reply_t_handler_json
1543 (vl_api_tap_modify_reply_t * mp)
1545 vat_main_t *vam = &vat_main;
1546 vat_json_node_t node;
1548 vat_json_init_object (&node);
1549 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1550 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1552 vat_json_print (vam->ofp, &node);
1553 vat_json_free (&node);
1555 vam->retval = ntohl (mp->retval);
1556 vam->result_ready = 1;
1560 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1562 vat_main_t *vam = &vat_main;
1563 i32 retval = ntohl (mp->retval);
1564 if (vam->async_mode)
1566 vam->async_errors += (retval < 0);
1570 vam->retval = retval;
1571 vam->result_ready = 1;
1575 static void vl_api_tap_delete_reply_t_handler_json
1576 (vl_api_tap_delete_reply_t * mp)
1578 vat_main_t *vam = &vat_main;
1579 vat_json_node_t node;
1581 vat_json_init_object (&node);
1582 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1584 vat_json_print (vam->ofp, &node);
1585 vat_json_free (&node);
1587 vam->retval = ntohl (mp->retval);
1588 vam->result_ready = 1;
1591 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1592 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1594 vat_main_t *vam = &vat_main;
1595 i32 retval = ntohl (mp->retval);
1596 if (vam->async_mode)
1598 vam->async_errors += (retval < 0);
1602 vam->retval = retval;
1603 vam->result_ready = 1;
1607 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1608 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1610 vat_main_t *vam = &vat_main;
1611 vat_json_node_t node;
1613 vat_json_init_object (&node);
1614 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1615 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1616 ntohl (mp->sw_if_index));
1618 vat_json_print (vam->ofp, &node);
1619 vat_json_free (&node);
1621 vam->retval = ntohl (mp->retval);
1622 vam->result_ready = 1;
1625 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1626 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1628 vat_main_t *vam = &vat_main;
1629 i32 retval = ntohl (mp->retval);
1630 if (vam->async_mode)
1632 vam->async_errors += (retval < 0);
1636 vam->retval = retval;
1637 vam->sw_if_index = ntohl (mp->sw_if_index);
1638 vam->result_ready = 1;
1642 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1643 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1645 vat_main_t *vam = &vat_main;
1646 vat_json_node_t node;
1648 vat_json_init_object (&node);
1649 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1650 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1652 vat_json_print (vam->ofp, &node);
1653 vat_json_free (&node);
1655 vam->retval = ntohl (mp->retval);
1656 vam->result_ready = 1;
1660 static void vl_api_one_add_del_locator_set_reply_t_handler
1661 (vl_api_one_add_del_locator_set_reply_t * mp)
1663 vat_main_t *vam = &vat_main;
1664 i32 retval = ntohl (mp->retval);
1665 if (vam->async_mode)
1667 vam->async_errors += (retval < 0);
1671 vam->retval = retval;
1672 vam->result_ready = 1;
1676 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1677 (vl_api_one_add_del_locator_set_reply_t * mp)
1679 vat_main_t *vam = &vat_main;
1680 vat_json_node_t node;
1682 vat_json_init_object (&node);
1683 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1684 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1686 vat_json_print (vam->ofp, &node);
1687 vat_json_free (&node);
1689 vam->retval = ntohl (mp->retval);
1690 vam->result_ready = 1;
1693 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1694 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1696 vat_main_t *vam = &vat_main;
1697 i32 retval = ntohl (mp->retval);
1698 if (vam->async_mode)
1700 vam->async_errors += (retval < 0);
1704 vam->retval = retval;
1705 vam->sw_if_index = ntohl (mp->sw_if_index);
1706 vam->result_ready = 1;
1710 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1711 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1713 vat_main_t *vam = &vat_main;
1714 vat_json_node_t node;
1716 vat_json_init_object (&node);
1717 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1718 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1720 vat_json_print (vam->ofp, &node);
1721 vat_json_free (&node);
1723 vam->retval = ntohl (mp->retval);
1724 vam->result_ready = 1;
1727 static void vl_api_gre_add_del_tunnel_reply_t_handler
1728 (vl_api_gre_add_del_tunnel_reply_t * mp)
1730 vat_main_t *vam = &vat_main;
1731 i32 retval = ntohl (mp->retval);
1732 if (vam->async_mode)
1734 vam->async_errors += (retval < 0);
1738 vam->retval = retval;
1739 vam->sw_if_index = ntohl (mp->sw_if_index);
1740 vam->result_ready = 1;
1744 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1745 (vl_api_gre_add_del_tunnel_reply_t * mp)
1747 vat_main_t *vam = &vat_main;
1748 vat_json_node_t node;
1750 vat_json_init_object (&node);
1751 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1752 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1754 vat_json_print (vam->ofp, &node);
1755 vat_json_free (&node);
1757 vam->retval = ntohl (mp->retval);
1758 vam->result_ready = 1;
1761 static void vl_api_create_vhost_user_if_reply_t_handler
1762 (vl_api_create_vhost_user_if_reply_t * mp)
1764 vat_main_t *vam = &vat_main;
1765 i32 retval = ntohl (mp->retval);
1766 if (vam->async_mode)
1768 vam->async_errors += (retval < 0);
1772 vam->retval = retval;
1773 vam->sw_if_index = ntohl (mp->sw_if_index);
1774 vam->result_ready = 1;
1778 static void vl_api_create_vhost_user_if_reply_t_handler_json
1779 (vl_api_create_vhost_user_if_reply_t * mp)
1781 vat_main_t *vam = &vat_main;
1782 vat_json_node_t node;
1784 vat_json_init_object (&node);
1785 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1786 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1788 vat_json_print (vam->ofp, &node);
1789 vat_json_free (&node);
1791 vam->retval = ntohl (mp->retval);
1792 vam->result_ready = 1;
1795 static void vl_api_ip_address_details_t_handler
1796 (vl_api_ip_address_details_t * mp)
1798 vat_main_t *vam = &vat_main;
1799 static ip_address_details_t empty_ip_address_details = { {0} };
1800 ip_address_details_t *address = NULL;
1801 ip_details_t *current_ip_details = NULL;
1802 ip_details_t *details = NULL;
1804 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1806 if (!details || vam->current_sw_if_index >= vec_len (details)
1807 || !details[vam->current_sw_if_index].present)
1809 errmsg ("ip address details arrived but not stored");
1810 errmsg ("ip_dump should be called first");
1814 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1816 #define addresses (current_ip_details->addr)
1818 vec_validate_init_empty (addresses, vec_len (addresses),
1819 empty_ip_address_details);
1821 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1823 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1824 address->prefix_length = mp->prefix_length;
1828 static void vl_api_ip_address_details_t_handler_json
1829 (vl_api_ip_address_details_t * mp)
1831 vat_main_t *vam = &vat_main;
1832 vat_json_node_t *node = NULL;
1833 struct in6_addr ip6;
1836 if (VAT_JSON_ARRAY != vam->json_tree.type)
1838 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1839 vat_json_init_array (&vam->json_tree);
1841 node = vat_json_array_add (&vam->json_tree);
1843 vat_json_init_object (node);
1846 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1847 vat_json_object_add_ip6 (node, "ip", ip6);
1851 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1852 vat_json_object_add_ip4 (node, "ip", ip4);
1854 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1858 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1860 vat_main_t *vam = &vat_main;
1861 static ip_details_t empty_ip_details = { 0 };
1862 ip_details_t *ip = NULL;
1863 u32 sw_if_index = ~0;
1865 sw_if_index = ntohl (mp->sw_if_index);
1867 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1868 sw_if_index, empty_ip_details);
1870 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1877 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1879 vat_main_t *vam = &vat_main;
1881 if (VAT_JSON_ARRAY != vam->json_tree.type)
1883 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1884 vat_json_init_array (&vam->json_tree);
1886 vat_json_array_add_uint (&vam->json_tree,
1887 clib_net_to_host_u32 (mp->sw_if_index));
1890 static void vl_api_map_domain_details_t_handler_json
1891 (vl_api_map_domain_details_t * mp)
1893 vat_json_node_t *node = NULL;
1894 vat_main_t *vam = &vat_main;
1895 struct in6_addr ip6;
1898 if (VAT_JSON_ARRAY != vam->json_tree.type)
1900 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1901 vat_json_init_array (&vam->json_tree);
1904 node = vat_json_array_add (&vam->json_tree);
1905 vat_json_init_object (node);
1907 vat_json_object_add_uint (node, "domain_index",
1908 clib_net_to_host_u32 (mp->domain_index));
1909 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1910 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1911 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1912 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1913 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1914 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1915 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1916 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1917 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1918 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1919 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1920 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1921 vat_json_object_add_uint (node, "flags", mp->flags);
1922 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1923 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1926 static void vl_api_map_domain_details_t_handler
1927 (vl_api_map_domain_details_t * mp)
1929 vat_main_t *vam = &vat_main;
1931 if (mp->is_translation)
1934 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
1935 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1936 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1937 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1938 clib_net_to_host_u32 (mp->domain_index));
1943 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
1944 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1945 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1946 format_ip6_address, mp->ip6_src,
1947 clib_net_to_host_u32 (mp->domain_index));
1949 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
1950 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1951 mp->is_translation ? "map-t" : "");
1954 static void vl_api_map_rule_details_t_handler_json
1955 (vl_api_map_rule_details_t * mp)
1957 struct in6_addr ip6;
1958 vat_json_node_t *node = NULL;
1959 vat_main_t *vam = &vat_main;
1961 if (VAT_JSON_ARRAY != vam->json_tree.type)
1963 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1964 vat_json_init_array (&vam->json_tree);
1967 node = vat_json_array_add (&vam->json_tree);
1968 vat_json_init_object (node);
1970 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1971 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1972 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1976 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1978 vat_main_t *vam = &vat_main;
1979 print (vam->ofp, " %d (psid) %U (ip6-dst)",
1980 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1984 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1986 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1987 "router_addr %U host_mac %U",
1988 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1989 format_ip4_address, &mp->host_address,
1990 format_ip4_address, &mp->router_address,
1991 format_ethernet_address, mp->host_mac);
1994 static void vl_api_dhcp_compl_event_t_handler_json
1995 (vl_api_dhcp_compl_event_t * mp)
1997 /* JSON output not supported */
2001 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2004 vat_main_t *vam = &vat_main;
2005 static u64 default_counter = 0;
2007 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2009 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2010 sw_if_index, default_counter);
2011 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2015 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2016 interface_counter_t counter)
2018 vat_main_t *vam = &vat_main;
2019 static interface_counter_t default_counter = { 0, };
2021 vec_validate_init_empty (vam->combined_interface_counters,
2022 vnet_counter_type, NULL);
2023 vec_validate_init_empty (vam->combined_interface_counters
2024 [vnet_counter_type], sw_if_index, default_counter);
2025 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2028 static void vl_api_vnet_interface_counters_t_handler
2029 (vl_api_vnet_interface_counters_t * mp)
2034 static void vl_api_vnet_interface_counters_t_handler_json
2035 (vl_api_vnet_interface_counters_t * mp)
2037 interface_counter_t counter;
2042 u32 first_sw_if_index;
2045 count = ntohl (mp->count);
2046 first_sw_if_index = ntohl (mp->first_sw_if_index);
2048 if (!mp->is_combined)
2050 v_packets = (u64 *) & mp->data;
2051 for (i = 0; i < count; i++)
2054 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2055 set_simple_interface_counter (mp->vnet_counter_type,
2056 first_sw_if_index + i, packets);
2062 v = (vlib_counter_t *) & mp->data;
2063 for (i = 0; i < count; i++)
2066 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2068 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2069 set_combined_interface_counter (mp->vnet_counter_type,
2070 first_sw_if_index + i, counter);
2077 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2079 vat_main_t *vam = &vat_main;
2082 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2084 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2093 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2095 vat_main_t *vam = &vat_main;
2098 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2100 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2108 static void vl_api_vnet_ip4_fib_counters_t_handler
2109 (vl_api_vnet_ip4_fib_counters_t * mp)
2114 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2115 (vl_api_vnet_ip4_fib_counters_t * mp)
2117 vat_main_t *vam = &vat_main;
2118 vl_api_ip4_fib_counter_t *v;
2119 ip4_fib_counter_t *counter;
2126 vrf_id = ntohl (mp->vrf_id);
2127 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2128 if (~0 == vrf_index)
2130 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2131 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2132 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2133 vec_validate (vam->ip4_fib_counters, vrf_index);
2134 vam->ip4_fib_counters[vrf_index] = NULL;
2137 vec_free (vam->ip4_fib_counters[vrf_index]);
2138 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2139 count = ntohl (mp->count);
2140 for (i = 0; i < count; i++)
2142 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2143 counter = &vam->ip4_fib_counters[vrf_index][i];
2144 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2145 counter->address = ip4;
2146 counter->address_length = v->address_length;
2147 counter->packets = clib_net_to_host_u64 (v->packets);
2148 counter->bytes = clib_net_to_host_u64 (v->bytes);
2153 static void vl_api_vnet_ip4_nbr_counters_t_handler
2154 (vl_api_vnet_ip4_nbr_counters_t * mp)
2159 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2160 (vl_api_vnet_ip4_nbr_counters_t * mp)
2162 vat_main_t *vam = &vat_main;
2163 vl_api_ip4_nbr_counter_t *v;
2164 ip4_nbr_counter_t *counter;
2169 sw_if_index = ntohl (mp->sw_if_index);
2170 count = ntohl (mp->count);
2171 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2174 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2176 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2177 for (i = 0; i < count; i++)
2179 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2180 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2181 counter->address.s_addr = v->address;
2182 counter->packets = clib_net_to_host_u64 (v->packets);
2183 counter->bytes = clib_net_to_host_u64 (v->bytes);
2184 counter->linkt = v->link_type;
2189 static void vl_api_vnet_ip6_fib_counters_t_handler
2190 (vl_api_vnet_ip6_fib_counters_t * mp)
2195 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2196 (vl_api_vnet_ip6_fib_counters_t * mp)
2198 vat_main_t *vam = &vat_main;
2199 vl_api_ip6_fib_counter_t *v;
2200 ip6_fib_counter_t *counter;
2201 struct in6_addr ip6;
2207 vrf_id = ntohl (mp->vrf_id);
2208 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2209 if (~0 == vrf_index)
2211 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2212 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2213 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2214 vec_validate (vam->ip6_fib_counters, vrf_index);
2215 vam->ip6_fib_counters[vrf_index] = NULL;
2218 vec_free (vam->ip6_fib_counters[vrf_index]);
2219 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2220 count = ntohl (mp->count);
2221 for (i = 0; i < count; i++)
2223 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2224 counter = &vam->ip6_fib_counters[vrf_index][i];
2225 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2226 counter->address = ip6;
2227 counter->address_length = v->address_length;
2228 counter->packets = clib_net_to_host_u64 (v->packets);
2229 counter->bytes = clib_net_to_host_u64 (v->bytes);
2234 static void vl_api_vnet_ip6_nbr_counters_t_handler
2235 (vl_api_vnet_ip6_nbr_counters_t * mp)
2240 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2241 (vl_api_vnet_ip6_nbr_counters_t * mp)
2243 vat_main_t *vam = &vat_main;
2244 vl_api_ip6_nbr_counter_t *v;
2245 ip6_nbr_counter_t *counter;
2246 struct in6_addr ip6;
2251 sw_if_index = ntohl (mp->sw_if_index);
2252 count = ntohl (mp->count);
2253 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2256 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2258 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2259 for (i = 0; i < count; i++)
2261 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2262 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2263 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2264 counter->address = ip6;
2265 counter->packets = clib_net_to_host_u64 (v->packets);
2266 counter->bytes = clib_net_to_host_u64 (v->bytes);
2271 static void vl_api_get_first_msg_id_reply_t_handler
2272 (vl_api_get_first_msg_id_reply_t * mp)
2274 vat_main_t *vam = &vat_main;
2275 i32 retval = ntohl (mp->retval);
2277 if (vam->async_mode)
2279 vam->async_errors += (retval < 0);
2283 vam->retval = retval;
2284 vam->result_ready = 1;
2288 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2292 static void vl_api_get_first_msg_id_reply_t_handler_json
2293 (vl_api_get_first_msg_id_reply_t * mp)
2295 vat_main_t *vam = &vat_main;
2296 vat_json_node_t node;
2298 vat_json_init_object (&node);
2299 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2300 vat_json_object_add_uint (&node, "first_msg_id",
2301 (uint) ntohs (mp->first_msg_id));
2303 vat_json_print (vam->ofp, &node);
2304 vat_json_free (&node);
2306 vam->retval = ntohl (mp->retval);
2307 vam->result_ready = 1;
2310 static void vl_api_get_node_graph_reply_t_handler
2311 (vl_api_get_node_graph_reply_t * mp)
2313 vat_main_t *vam = &vat_main;
2314 api_main_t *am = &api_main;
2315 i32 retval = ntohl (mp->retval);
2316 u8 *pvt_copy, *reply;
2321 if (vam->async_mode)
2323 vam->async_errors += (retval < 0);
2327 vam->retval = retval;
2328 vam->result_ready = 1;
2331 /* "Should never happen..." */
2335 reply = (u8 *) (mp->reply_in_shmem);
2336 pvt_copy = vec_dup (reply);
2338 /* Toss the shared-memory original... */
2339 pthread_mutex_lock (&am->vlib_rp->mutex);
2340 oldheap = svm_push_data_heap (am->vlib_rp);
2344 svm_pop_heap (oldheap);
2345 pthread_mutex_unlock (&am->vlib_rp->mutex);
2347 if (vam->graph_nodes)
2349 hash_free (vam->graph_node_index_by_name);
2351 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2353 node = vam->graph_nodes[i];
2354 vec_free (node->name);
2355 vec_free (node->next_nodes);
2358 vec_free (vam->graph_nodes);
2361 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2362 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2363 vec_free (pvt_copy);
2365 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2367 node = vam->graph_nodes[i];
2368 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2372 static void vl_api_get_node_graph_reply_t_handler_json
2373 (vl_api_get_node_graph_reply_t * mp)
2375 vat_main_t *vam = &vat_main;
2376 api_main_t *am = &api_main;
2378 vat_json_node_t node;
2381 /* $$$$ make this real? */
2382 vat_json_init_object (&node);
2383 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2384 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2386 reply = (u8 *) (mp->reply_in_shmem);
2388 /* Toss the shared-memory original... */
2389 pthread_mutex_lock (&am->vlib_rp->mutex);
2390 oldheap = svm_push_data_heap (am->vlib_rp);
2394 svm_pop_heap (oldheap);
2395 pthread_mutex_unlock (&am->vlib_rp->mutex);
2397 vat_json_print (vam->ofp, &node);
2398 vat_json_free (&node);
2400 vam->retval = ntohl (mp->retval);
2401 vam->result_ready = 1;
2405 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2407 vat_main_t *vam = &vat_main;
2412 s = format (s, "%=16d%=16d%=16d",
2413 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2417 s = format (s, "%=16U%=16d%=16d",
2418 mp->is_ipv6 ? format_ip6_address :
2420 mp->ip_address, mp->priority, mp->weight);
2423 print (vam->ofp, "%v", s);
2428 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2430 vat_main_t *vam = &vat_main;
2431 vat_json_node_t *node = NULL;
2432 struct in6_addr ip6;
2435 if (VAT_JSON_ARRAY != vam->json_tree.type)
2437 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2438 vat_json_init_array (&vam->json_tree);
2440 node = vat_json_array_add (&vam->json_tree);
2441 vat_json_init_object (node);
2443 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2444 vat_json_object_add_uint (node, "priority", mp->priority);
2445 vat_json_object_add_uint (node, "weight", mp->weight);
2448 vat_json_object_add_uint (node, "sw_if_index",
2449 clib_net_to_host_u32 (mp->sw_if_index));
2454 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2455 vat_json_object_add_ip6 (node, "address", ip6);
2459 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2460 vat_json_object_add_ip4 (node, "address", ip4);
2466 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2469 vat_main_t *vam = &vat_main;
2472 ls_name = format (0, "%s", mp->ls_name);
2474 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2480 vl_api_one_locator_set_details_t_handler_json
2481 (vl_api_one_locator_set_details_t * mp)
2483 vat_main_t *vam = &vat_main;
2484 vat_json_node_t *node = 0;
2487 ls_name = format (0, "%s", mp->ls_name);
2488 vec_add1 (ls_name, 0);
2490 if (VAT_JSON_ARRAY != vam->json_tree.type)
2492 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2493 vat_json_init_array (&vam->json_tree);
2495 node = vat_json_array_add (&vam->json_tree);
2497 vat_json_init_object (node);
2498 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2499 vat_json_object_add_uint (node, "ls_index",
2500 clib_net_to_host_u32 (mp->ls_index));
2505 format_lisp_flat_eid (u8 * s, va_list * args)
2507 u32 type = va_arg (*args, u32);
2508 u8 *eid = va_arg (*args, u8 *);
2509 u32 eid_len = va_arg (*args, u32);
2514 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2516 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2518 return format (s, "%U", format_ethernet_address, eid);
2524 format_lisp_eid_vat (u8 * s, va_list * args)
2526 u32 type = va_arg (*args, u32);
2527 u8 *eid = va_arg (*args, u8 *);
2528 u32 eid_len = va_arg (*args, u32);
2529 u8 *seid = va_arg (*args, u8 *);
2530 u32 seid_len = va_arg (*args, u32);
2531 u32 is_src_dst = va_arg (*args, u32);
2534 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2536 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2542 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2544 vat_main_t *vam = &vat_main;
2545 u8 *s = 0, *eid = 0;
2547 if (~0 == mp->locator_set_index)
2548 s = format (0, "action: %d", mp->action);
2550 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2552 eid = format (0, "%U", format_lisp_eid_vat,
2556 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2559 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2560 clib_net_to_host_u32 (mp->vni),
2562 mp->is_local ? "local" : "remote",
2563 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2564 clib_net_to_host_u16 (mp->key_id), mp->key);
2571 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2574 vat_main_t *vam = &vat_main;
2575 vat_json_node_t *node = 0;
2578 if (VAT_JSON_ARRAY != vam->json_tree.type)
2580 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2581 vat_json_init_array (&vam->json_tree);
2583 node = vat_json_array_add (&vam->json_tree);
2585 vat_json_init_object (node);
2586 if (~0 == mp->locator_set_index)
2587 vat_json_object_add_uint (node, "action", mp->action);
2589 vat_json_object_add_uint (node, "locator_set_index",
2590 clib_net_to_host_u32 (mp->locator_set_index));
2592 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2593 eid = format (0, "%U", format_lisp_eid_vat,
2597 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2599 vat_json_object_add_string_copy (node, "eid", eid);
2600 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2601 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2602 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2606 vat_json_object_add_uint (node, "key_id",
2607 clib_net_to_host_u16 (mp->key_id));
2608 vat_json_object_add_string_copy (node, "key", mp->key);
2614 vl_api_one_eid_table_map_details_t_handler
2615 (vl_api_one_eid_table_map_details_t * mp)
2617 vat_main_t *vam = &vat_main;
2619 u8 *line = format (0, "%=10d%=10d",
2620 clib_net_to_host_u32 (mp->vni),
2621 clib_net_to_host_u32 (mp->dp_table));
2622 print (vam->ofp, "%v", line);
2627 vl_api_one_eid_table_map_details_t_handler_json
2628 (vl_api_one_eid_table_map_details_t * mp)
2630 vat_main_t *vam = &vat_main;
2631 vat_json_node_t *node = NULL;
2633 if (VAT_JSON_ARRAY != vam->json_tree.type)
2635 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2636 vat_json_init_array (&vam->json_tree);
2638 node = vat_json_array_add (&vam->json_tree);
2639 vat_json_init_object (node);
2640 vat_json_object_add_uint (node, "dp_table",
2641 clib_net_to_host_u32 (mp->dp_table));
2642 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2646 vl_api_one_eid_table_vni_details_t_handler
2647 (vl_api_one_eid_table_vni_details_t * mp)
2649 vat_main_t *vam = &vat_main;
2651 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2652 print (vam->ofp, "%v", line);
2657 vl_api_one_eid_table_vni_details_t_handler_json
2658 (vl_api_one_eid_table_vni_details_t * mp)
2660 vat_main_t *vam = &vat_main;
2661 vat_json_node_t *node = NULL;
2663 if (VAT_JSON_ARRAY != vam->json_tree.type)
2665 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2666 vat_json_init_array (&vam->json_tree);
2668 node = vat_json_array_add (&vam->json_tree);
2669 vat_json_init_object (node);
2670 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2674 vl_api_show_one_map_register_state_reply_t_handler
2675 (vl_api_show_one_map_register_state_reply_t * mp)
2677 vat_main_t *vam = &vat_main;
2678 int retval = clib_net_to_host_u32 (mp->retval);
2680 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2682 vam->retval = retval;
2683 vam->result_ready = 1;
2687 vl_api_show_one_map_register_state_reply_t_handler_json
2688 (vl_api_show_one_map_register_state_reply_t * mp)
2690 vat_main_t *vam = &vat_main;
2691 vat_json_node_t _node, *node = &_node;
2692 int retval = clib_net_to_host_u32 (mp->retval);
2694 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2696 vat_json_init_object (node);
2697 vat_json_object_add_string_copy (node, "state", s);
2699 vat_json_print (vam->ofp, node);
2700 vat_json_free (node);
2702 vam->retval = retval;
2703 vam->result_ready = 1;
2708 vl_api_show_one_rloc_probe_state_reply_t_handler
2709 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2711 vat_main_t *vam = &vat_main;
2712 int retval = clib_net_to_host_u32 (mp->retval);
2717 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2719 vam->retval = retval;
2720 vam->result_ready = 1;
2724 vl_api_show_one_rloc_probe_state_reply_t_handler_json
2725 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2727 vat_main_t *vam = &vat_main;
2728 vat_json_node_t _node, *node = &_node;
2729 int retval = clib_net_to_host_u32 (mp->retval);
2731 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2732 vat_json_init_object (node);
2733 vat_json_object_add_string_copy (node, "state", s);
2735 vat_json_print (vam->ofp, node);
2736 vat_json_free (node);
2738 vam->retval = retval;
2739 vam->result_ready = 1;
2744 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
2746 e->dp_table = clib_net_to_host_u32 (e->dp_table);
2747 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
2751 gpe_fwd_entries_get_reply_t_net_to_host
2752 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2756 mp->count = clib_net_to_host_u32 (mp->count);
2757 for (i = 0; i < mp->count; i++)
2759 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
2764 format_gpe_encap_mode (u8 * s, va_list * args)
2766 u32 mode = va_arg (*args, u32);
2771 return format (s, "lisp");
2773 return format (s, "vxlan");
2779 vl_api_gpe_get_encap_mode_reply_t_handler
2780 (vl_api_gpe_get_encap_mode_reply_t * mp)
2782 vat_main_t *vam = &vat_main;
2784 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
2785 vam->retval = ntohl (mp->retval);
2786 vam->result_ready = 1;
2790 vl_api_gpe_get_encap_mode_reply_t_handler_json
2791 (vl_api_gpe_get_encap_mode_reply_t * mp)
2793 vat_main_t *vam = &vat_main;
2794 vat_json_node_t node;
2796 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
2797 vec_add1 (encap_mode, 0);
2799 vat_json_init_object (&node);
2800 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
2802 vec_free (encap_mode);
2803 vat_json_print (vam->ofp, &node);
2804 vat_json_free (&node);
2806 vam->retval = ntohl (mp->retval);
2807 vam->result_ready = 1;
2811 vl_api_gpe_fwd_entry_path_details_t_handler
2812 (vl_api_gpe_fwd_entry_path_details_t * mp)
2814 vat_main_t *vam = &vat_main;
2815 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2817 if (mp->lcl_loc.is_ip4)
2818 format_ip_address_fcn = format_ip4_address;
2820 format_ip_address_fcn = format_ip6_address;
2822 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
2823 format_ip_address_fcn, &mp->lcl_loc,
2824 format_ip_address_fcn, &mp->rmt_loc);
2828 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
2830 struct in6_addr ip6;
2835 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
2836 vat_json_object_add_ip4 (n, "address", ip4);
2840 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
2841 vat_json_object_add_ip6 (n, "address", ip6);
2843 vat_json_object_add_uint (n, "weight", loc->weight);
2847 vl_api_gpe_fwd_entry_path_details_t_handler_json
2848 (vl_api_gpe_fwd_entry_path_details_t * mp)
2850 vat_main_t *vam = &vat_main;
2851 vat_json_node_t *node = NULL;
2852 vat_json_node_t *loc_node;
2854 if (VAT_JSON_ARRAY != vam->json_tree.type)
2856 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2857 vat_json_init_array (&vam->json_tree);
2859 node = vat_json_array_add (&vam->json_tree);
2860 vat_json_init_object (node);
2862 loc_node = vat_json_object_add (node, "local_locator");
2863 vat_json_init_object (loc_node);
2864 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
2866 loc_node = vat_json_object_add (node, "remote_locator");
2867 vat_json_init_object (loc_node);
2868 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
2872 vl_api_gpe_fwd_entries_get_reply_t_handler
2873 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2875 vat_main_t *vam = &vat_main;
2877 int retval = clib_net_to_host_u32 (mp->retval);
2878 vl_api_gpe_fwd_entry_t *e;
2883 gpe_fwd_entries_get_reply_t_net_to_host (mp);
2885 for (i = 0; i < mp->count; i++)
2887 e = &mp->entries[i];
2888 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
2889 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
2890 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
2894 vam->retval = retval;
2895 vam->result_ready = 1;
2899 vl_api_gpe_fwd_entries_get_reply_t_handler_json
2900 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2903 vat_main_t *vam = &vat_main;
2904 vat_json_node_t *e = 0, root;
2906 int retval = clib_net_to_host_u32 (mp->retval);
2907 vl_api_gpe_fwd_entry_t *fwd;
2912 gpe_fwd_entries_get_reply_t_net_to_host (mp);
2913 vat_json_init_array (&root);
2915 for (i = 0; i < mp->count; i++)
2917 e = vat_json_array_add (&root);
2918 fwd = &mp->entries[i];
2920 vat_json_init_object (e);
2921 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
2922 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
2924 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
2925 fwd->leid_prefix_len);
2927 vat_json_object_add_string_copy (e, "leid", s);
2930 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
2931 fwd->reid_prefix_len);
2933 vat_json_object_add_string_copy (e, "reid", s);
2937 vat_json_print (vam->ofp, &root);
2938 vat_json_free (&root);
2941 vam->retval = retval;
2942 vam->result_ready = 1;
2946 vl_api_one_adjacencies_get_reply_t_handler
2947 (vl_api_one_adjacencies_get_reply_t * mp)
2949 vat_main_t *vam = &vat_main;
2951 int retval = clib_net_to_host_u32 (mp->retval);
2952 vl_api_one_adjacency_t *a;
2957 n = clib_net_to_host_u32 (mp->count);
2959 for (i = 0; i < n; i++)
2961 a = &mp->adjacencies[i];
2962 print (vam->ofp, "%U %40U",
2963 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2964 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
2968 vam->retval = retval;
2969 vam->result_ready = 1;
2973 vl_api_one_adjacencies_get_reply_t_handler_json
2974 (vl_api_one_adjacencies_get_reply_t * mp)
2977 vat_main_t *vam = &vat_main;
2978 vat_json_node_t *e = 0, root;
2980 int retval = clib_net_to_host_u32 (mp->retval);
2981 vl_api_one_adjacency_t *a;
2986 n = clib_net_to_host_u32 (mp->count);
2987 vat_json_init_array (&root);
2989 for (i = 0; i < n; i++)
2991 e = vat_json_array_add (&root);
2992 a = &mp->adjacencies[i];
2994 vat_json_init_object (e);
2995 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
2996 a->leid_prefix_len);
2998 vat_json_object_add_string_copy (e, "leid", s);
3001 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3002 a->reid_prefix_len);
3004 vat_json_object_add_string_copy (e, "reid", s);
3008 vat_json_print (vam->ofp, &root);
3009 vat_json_free (&root);
3012 vam->retval = retval;
3013 vam->result_ready = 1;
3017 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3019 vat_main_t *vam = &vat_main;
3021 print (vam->ofp, "%=20U",
3022 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3027 vl_api_one_map_server_details_t_handler_json
3028 (vl_api_one_map_server_details_t * mp)
3030 vat_main_t *vam = &vat_main;
3031 vat_json_node_t *node = NULL;
3032 struct in6_addr ip6;
3035 if (VAT_JSON_ARRAY != vam->json_tree.type)
3037 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3038 vat_json_init_array (&vam->json_tree);
3040 node = vat_json_array_add (&vam->json_tree);
3042 vat_json_init_object (node);
3045 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3046 vat_json_object_add_ip6 (node, "map-server", ip6);
3050 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3051 vat_json_object_add_ip4 (node, "map-server", ip4);
3056 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3059 vat_main_t *vam = &vat_main;
3061 print (vam->ofp, "%=20U",
3062 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3067 vl_api_one_map_resolver_details_t_handler_json
3068 (vl_api_one_map_resolver_details_t * mp)
3070 vat_main_t *vam = &vat_main;
3071 vat_json_node_t *node = NULL;
3072 struct in6_addr ip6;
3075 if (VAT_JSON_ARRAY != vam->json_tree.type)
3077 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3078 vat_json_init_array (&vam->json_tree);
3080 node = vat_json_array_add (&vam->json_tree);
3082 vat_json_init_object (node);
3085 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3086 vat_json_object_add_ip6 (node, "map resolver", ip6);
3090 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3091 vat_json_object_add_ip4 (node, "map resolver", ip4);
3096 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3098 vat_main_t *vam = &vat_main;
3099 i32 retval = ntohl (mp->retval);
3103 print (vam->ofp, "feature: %s\ngpe: %s",
3104 mp->feature_status ? "enabled" : "disabled",
3105 mp->gpe_status ? "enabled" : "disabled");
3108 vam->retval = retval;
3109 vam->result_ready = 1;
3113 vl_api_show_one_status_reply_t_handler_json
3114 (vl_api_show_one_status_reply_t * mp)
3116 vat_main_t *vam = &vat_main;
3117 vat_json_node_t node;
3118 u8 *gpe_status = NULL;
3119 u8 *feature_status = NULL;
3121 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3122 feature_status = format (0, "%s",
3123 mp->feature_status ? "enabled" : "disabled");
3124 vec_add1 (gpe_status, 0);
3125 vec_add1 (feature_status, 0);
3127 vat_json_init_object (&node);
3128 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3129 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3131 vec_free (gpe_status);
3132 vec_free (feature_status);
3134 vat_json_print (vam->ofp, &node);
3135 vat_json_free (&node);
3137 vam->retval = ntohl (mp->retval);
3138 vam->result_ready = 1;
3142 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3143 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3145 vat_main_t *vam = &vat_main;
3146 i32 retval = ntohl (mp->retval);
3150 print (vam->ofp, "%=20s", mp->locator_set_name);
3153 vam->retval = retval;
3154 vam->result_ready = 1;
3158 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3159 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3161 vat_main_t *vam = &vat_main;
3162 vat_json_node_t *node = NULL;
3164 if (VAT_JSON_ARRAY != vam->json_tree.type)
3166 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3167 vat_json_init_array (&vam->json_tree);
3169 node = vat_json_array_add (&vam->json_tree);
3171 vat_json_init_object (node);
3172 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3174 vat_json_print (vam->ofp, node);
3175 vat_json_free (node);
3177 vam->retval = ntohl (mp->retval);
3178 vam->result_ready = 1;
3182 format_lisp_map_request_mode (u8 * s, va_list * args)
3184 u32 mode = va_arg (*args, u32);
3189 return format (0, "dst-only");
3191 return format (0, "src-dst");
3197 vl_api_show_one_map_request_mode_reply_t_handler
3198 (vl_api_show_one_map_request_mode_reply_t * mp)
3200 vat_main_t *vam = &vat_main;
3201 i32 retval = ntohl (mp->retval);
3205 u32 mode = mp->mode;
3206 print (vam->ofp, "map_request_mode: %U",
3207 format_lisp_map_request_mode, mode);
3210 vam->retval = retval;
3211 vam->result_ready = 1;
3215 vl_api_show_one_map_request_mode_reply_t_handler_json
3216 (vl_api_show_one_map_request_mode_reply_t * mp)
3218 vat_main_t *vam = &vat_main;
3219 vat_json_node_t node;
3224 s = format (0, "%U", format_lisp_map_request_mode, mode);
3227 vat_json_init_object (&node);
3228 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3229 vat_json_print (vam->ofp, &node);
3230 vat_json_free (&node);
3233 vam->retval = ntohl (mp->retval);
3234 vam->result_ready = 1;
3238 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3240 vat_main_t *vam = &vat_main;
3241 i32 retval = ntohl (mp->retval);
3245 print (vam->ofp, "%-20s%-16s",
3246 mp->status ? "enabled" : "disabled",
3247 mp->status ? (char *) mp->locator_set_name : "");
3250 vam->retval = retval;
3251 vam->result_ready = 1;
3255 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3257 vat_main_t *vam = &vat_main;
3258 vat_json_node_t node;
3261 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3262 vec_add1 (status, 0);
3264 vat_json_init_object (&node);
3265 vat_json_object_add_string_copy (&node, "status", status);
3268 vat_json_object_add_string_copy (&node, "locator_set",
3269 mp->locator_set_name);
3274 vat_json_print (vam->ofp, &node);
3275 vat_json_free (&node);
3277 vam->retval = ntohl (mp->retval);
3278 vam->result_ready = 1;
3282 format_policer_type (u8 * s, va_list * va)
3284 u32 i = va_arg (*va, u32);
3286 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3287 s = format (s, "1r2c");
3288 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3289 s = format (s, "1r3c");
3290 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3291 s = format (s, "2r3c-2698");
3292 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3293 s = format (s, "2r3c-4115");
3294 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3295 s = format (s, "2r3c-mef5cf1");
3297 s = format (s, "ILLEGAL");
3302 format_policer_rate_type (u8 * s, va_list * va)
3304 u32 i = va_arg (*va, u32);
3306 if (i == SSE2_QOS_RATE_KBPS)
3307 s = format (s, "kbps");
3308 else if (i == SSE2_QOS_RATE_PPS)
3309 s = format (s, "pps");
3311 s = format (s, "ILLEGAL");
3316 format_policer_round_type (u8 * s, va_list * va)
3318 u32 i = va_arg (*va, u32);
3320 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3321 s = format (s, "closest");
3322 else if (i == SSE2_QOS_ROUND_TO_UP)
3323 s = format (s, "up");
3324 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3325 s = format (s, "down");
3327 s = format (s, "ILLEGAL");
3332 format_policer_action_type (u8 * s, va_list * va)
3334 u32 i = va_arg (*va, u32);
3336 if (i == SSE2_QOS_ACTION_DROP)
3337 s = format (s, "drop");
3338 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3339 s = format (s, "transmit");
3340 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3341 s = format (s, "mark-and-transmit");
3343 s = format (s, "ILLEGAL");
3348 format_dscp (u8 * s, va_list * va)
3350 u32 i = va_arg (*va, u32);
3355 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3359 return format (s, "ILLEGAL");
3361 s = format (s, "%s", t);
3366 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3368 vat_main_t *vam = &vat_main;
3369 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3371 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3372 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3374 conform_dscp_str = format (0, "");
3376 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3377 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3379 exceed_dscp_str = format (0, "");
3381 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3382 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3384 violate_dscp_str = format (0, "");
3386 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3387 "rate type %U, round type %U, %s rate, %s color-aware, "
3388 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3389 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3390 "conform action %U%s, exceed action %U%s, violate action %U%s",
3392 format_policer_type, mp->type,
3395 clib_net_to_host_u64 (mp->cb),
3396 clib_net_to_host_u64 (mp->eb),
3397 format_policer_rate_type, mp->rate_type,
3398 format_policer_round_type, mp->round_type,
3399 mp->single_rate ? "single" : "dual",
3400 mp->color_aware ? "is" : "not",
3401 ntohl (mp->cir_tokens_per_period),
3402 ntohl (mp->pir_tokens_per_period),
3404 ntohl (mp->current_limit),
3405 ntohl (mp->current_bucket),
3406 ntohl (mp->extended_limit),
3407 ntohl (mp->extended_bucket),
3408 clib_net_to_host_u64 (mp->last_update_time),
3409 format_policer_action_type, mp->conform_action_type,
3411 format_policer_action_type, mp->exceed_action_type,
3413 format_policer_action_type, mp->violate_action_type,
3416 vec_free (conform_dscp_str);
3417 vec_free (exceed_dscp_str);
3418 vec_free (violate_dscp_str);
3421 static void vl_api_policer_details_t_handler_json
3422 (vl_api_policer_details_t * mp)
3424 vat_main_t *vam = &vat_main;
3425 vat_json_node_t *node;
3426 u8 *rate_type_str, *round_type_str, *type_str;
3427 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3429 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3431 format (0, "%U", format_policer_round_type, mp->round_type);
3432 type_str = format (0, "%U", format_policer_type, mp->type);
3433 conform_action_str = format (0, "%U", format_policer_action_type,
3434 mp->conform_action_type);
3435 exceed_action_str = format (0, "%U", format_policer_action_type,
3436 mp->exceed_action_type);
3437 violate_action_str = format (0, "%U", format_policer_action_type,
3438 mp->violate_action_type);
3440 if (VAT_JSON_ARRAY != vam->json_tree.type)
3442 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3443 vat_json_init_array (&vam->json_tree);
3445 node = vat_json_array_add (&vam->json_tree);
3447 vat_json_init_object (node);
3448 vat_json_object_add_string_copy (node, "name", mp->name);
3449 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3450 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3451 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3452 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3453 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3454 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3455 vat_json_object_add_string_copy (node, "type", type_str);
3456 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3457 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3458 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3459 vat_json_object_add_uint (node, "cir_tokens_per_period",
3460 ntohl (mp->cir_tokens_per_period));
3461 vat_json_object_add_uint (node, "eir_tokens_per_period",
3462 ntohl (mp->pir_tokens_per_period));
3463 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3464 vat_json_object_add_uint (node, "current_bucket",
3465 ntohl (mp->current_bucket));
3466 vat_json_object_add_uint (node, "extended_limit",
3467 ntohl (mp->extended_limit));
3468 vat_json_object_add_uint (node, "extended_bucket",
3469 ntohl (mp->extended_bucket));
3470 vat_json_object_add_uint (node, "last_update_time",
3471 ntohl (mp->last_update_time));
3472 vat_json_object_add_string_copy (node, "conform_action",
3473 conform_action_str);
3474 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3476 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3477 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3478 vec_free (dscp_str);
3480 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3481 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3483 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3484 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3485 vec_free (dscp_str);
3487 vat_json_object_add_string_copy (node, "violate_action",
3488 violate_action_str);
3489 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3491 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3492 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3493 vec_free (dscp_str);
3496 vec_free (rate_type_str);
3497 vec_free (round_type_str);
3498 vec_free (type_str);
3499 vec_free (conform_action_str);
3500 vec_free (exceed_action_str);
3501 vec_free (violate_action_str);
3505 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3508 vat_main_t *vam = &vat_main;
3509 int i, count = ntohl (mp->count);
3512 print (vam->ofp, "classify table ids (%d) : ", count);
3513 for (i = 0; i < count; i++)
3515 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3516 print (vam->ofp, (i < count - 1) ? "," : "");
3518 vam->retval = ntohl (mp->retval);
3519 vam->result_ready = 1;
3523 vl_api_classify_table_ids_reply_t_handler_json
3524 (vl_api_classify_table_ids_reply_t * mp)
3526 vat_main_t *vam = &vat_main;
3527 int i, count = ntohl (mp->count);
3531 vat_json_node_t node;
3533 vat_json_init_object (&node);
3534 for (i = 0; i < count; i++)
3536 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3538 vat_json_print (vam->ofp, &node);
3539 vat_json_free (&node);
3541 vam->retval = ntohl (mp->retval);
3542 vam->result_ready = 1;
3546 vl_api_classify_table_by_interface_reply_t_handler
3547 (vl_api_classify_table_by_interface_reply_t * mp)
3549 vat_main_t *vam = &vat_main;
3552 table_id = ntohl (mp->l2_table_id);
3554 print (vam->ofp, "l2 table id : %d", table_id);
3556 print (vam->ofp, "l2 table id : No input ACL tables configured");
3557 table_id = ntohl (mp->ip4_table_id);
3559 print (vam->ofp, "ip4 table id : %d", table_id);
3561 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3562 table_id = ntohl (mp->ip6_table_id);
3564 print (vam->ofp, "ip6 table id : %d", table_id);
3566 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3567 vam->retval = ntohl (mp->retval);
3568 vam->result_ready = 1;
3572 vl_api_classify_table_by_interface_reply_t_handler_json
3573 (vl_api_classify_table_by_interface_reply_t * mp)
3575 vat_main_t *vam = &vat_main;
3576 vat_json_node_t node;
3578 vat_json_init_object (&node);
3580 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3581 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3582 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3584 vat_json_print (vam->ofp, &node);
3585 vat_json_free (&node);
3587 vam->retval = ntohl (mp->retval);
3588 vam->result_ready = 1;
3591 static void vl_api_policer_add_del_reply_t_handler
3592 (vl_api_policer_add_del_reply_t * mp)
3594 vat_main_t *vam = &vat_main;
3595 i32 retval = ntohl (mp->retval);
3596 if (vam->async_mode)
3598 vam->async_errors += (retval < 0);
3602 vam->retval = retval;
3603 vam->result_ready = 1;
3604 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3606 * Note: this is just barely thread-safe, depends on
3607 * the main thread spinning waiting for an answer...
3609 errmsg ("policer index %d", ntohl (mp->policer_index));
3613 static void vl_api_policer_add_del_reply_t_handler_json
3614 (vl_api_policer_add_del_reply_t * mp)
3616 vat_main_t *vam = &vat_main;
3617 vat_json_node_t node;
3619 vat_json_init_object (&node);
3620 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3621 vat_json_object_add_uint (&node, "policer_index",
3622 ntohl (mp->policer_index));
3624 vat_json_print (vam->ofp, &node);
3625 vat_json_free (&node);
3627 vam->retval = ntohl (mp->retval);
3628 vam->result_ready = 1;
3631 /* Format hex dump. */
3633 format_hex_bytes (u8 * s, va_list * va)
3635 u8 *bytes = va_arg (*va, u8 *);
3636 int n_bytes = va_arg (*va, int);
3639 /* Print short or long form depending on byte count. */
3640 uword short_form = n_bytes <= 32;
3641 uword indent = format_get_indent (s);
3646 for (i = 0; i < n_bytes; i++)
3648 if (!short_form && (i % 32) == 0)
3649 s = format (s, "%08x: ", i);
3650 s = format (s, "%02x", bytes[i]);
3651 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3652 s = format (s, "\n%U", format_white_space, indent);
3659 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3662 vat_main_t *vam = &vat_main;
3663 i32 retval = ntohl (mp->retval);
3666 print (vam->ofp, "classify table info :");
3667 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3668 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3669 ntohl (mp->miss_next_index));
3670 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3671 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3672 ntohl (mp->match_n_vectors));
3673 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3674 ntohl (mp->mask_length));
3676 vam->retval = retval;
3677 vam->result_ready = 1;
3681 vl_api_classify_table_info_reply_t_handler_json
3682 (vl_api_classify_table_info_reply_t * mp)
3684 vat_main_t *vam = &vat_main;
3685 vat_json_node_t node;
3687 i32 retval = ntohl (mp->retval);
3690 vat_json_init_object (&node);
3692 vat_json_object_add_int (&node, "sessions",
3693 ntohl (mp->active_sessions));
3694 vat_json_object_add_int (&node, "nexttbl",
3695 ntohl (mp->next_table_index));
3696 vat_json_object_add_int (&node, "nextnode",
3697 ntohl (mp->miss_next_index));
3698 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3699 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3700 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3701 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3702 ntohl (mp->mask_length), 0);
3703 vat_json_object_add_string_copy (&node, "mask", s);
3705 vat_json_print (vam->ofp, &node);
3706 vat_json_free (&node);
3708 vam->retval = ntohl (mp->retval);
3709 vam->result_ready = 1;
3713 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3716 vat_main_t *vam = &vat_main;
3718 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3719 ntohl (mp->hit_next_index), ntohl (mp->advance),
3720 ntohl (mp->opaque_index));
3721 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3722 ntohl (mp->match_length));
3726 vl_api_classify_session_details_t_handler_json
3727 (vl_api_classify_session_details_t * mp)
3729 vat_main_t *vam = &vat_main;
3730 vat_json_node_t *node = NULL;
3732 if (VAT_JSON_ARRAY != vam->json_tree.type)
3734 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3735 vat_json_init_array (&vam->json_tree);
3737 node = vat_json_array_add (&vam->json_tree);
3739 vat_json_init_object (node);
3740 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3741 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3742 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3744 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3746 vat_json_object_add_string_copy (node, "match", s);
3749 static void vl_api_pg_create_interface_reply_t_handler
3750 (vl_api_pg_create_interface_reply_t * mp)
3752 vat_main_t *vam = &vat_main;
3754 vam->retval = ntohl (mp->retval);
3755 vam->result_ready = 1;
3758 static void vl_api_pg_create_interface_reply_t_handler_json
3759 (vl_api_pg_create_interface_reply_t * mp)
3761 vat_main_t *vam = &vat_main;
3762 vat_json_node_t node;
3764 i32 retval = ntohl (mp->retval);
3767 vat_json_init_object (&node);
3769 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3771 vat_json_print (vam->ofp, &node);
3772 vat_json_free (&node);
3774 vam->retval = ntohl (mp->retval);
3775 vam->result_ready = 1;
3778 static void vl_api_policer_classify_details_t_handler
3779 (vl_api_policer_classify_details_t * mp)
3781 vat_main_t *vam = &vat_main;
3783 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3784 ntohl (mp->table_index));
3787 static void vl_api_policer_classify_details_t_handler_json
3788 (vl_api_policer_classify_details_t * mp)
3790 vat_main_t *vam = &vat_main;
3791 vat_json_node_t *node;
3793 if (VAT_JSON_ARRAY != vam->json_tree.type)
3795 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3796 vat_json_init_array (&vam->json_tree);
3798 node = vat_json_array_add (&vam->json_tree);
3800 vat_json_init_object (node);
3801 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3802 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3805 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3806 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3808 vat_main_t *vam = &vat_main;
3809 i32 retval = ntohl (mp->retval);
3810 if (vam->async_mode)
3812 vam->async_errors += (retval < 0);
3816 vam->retval = retval;
3817 vam->sw_if_index = ntohl (mp->sw_if_index);
3818 vam->result_ready = 1;
3822 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3823 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3825 vat_main_t *vam = &vat_main;
3826 vat_json_node_t node;
3828 vat_json_init_object (&node);
3829 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3830 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3832 vat_json_print (vam->ofp, &node);
3833 vat_json_free (&node);
3835 vam->retval = ntohl (mp->retval);
3836 vam->result_ready = 1;
3839 static void vl_api_flow_classify_details_t_handler
3840 (vl_api_flow_classify_details_t * mp)
3842 vat_main_t *vam = &vat_main;
3844 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3845 ntohl (mp->table_index));
3848 static void vl_api_flow_classify_details_t_handler_json
3849 (vl_api_flow_classify_details_t * mp)
3851 vat_main_t *vam = &vat_main;
3852 vat_json_node_t *node;
3854 if (VAT_JSON_ARRAY != vam->json_tree.type)
3856 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3857 vat_json_init_array (&vam->json_tree);
3859 node = vat_json_array_add (&vam->json_tree);
3861 vat_json_init_object (node);
3862 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3863 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3868 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3869 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3870 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3871 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3872 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
3873 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
3874 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
3875 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
3876 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
3877 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
3880 * Generate boilerplate reply handlers, which
3881 * dig the return value out of the xxx_reply_t API message,
3882 * stick it into vam->retval, and set vam->result_ready
3884 * Could also do this by pointing N message decode slots at
3885 * a single function, but that could break in subtle ways.
3888 #define foreach_standard_reply_retval_handler \
3889 _(sw_interface_set_flags_reply) \
3890 _(sw_interface_add_del_address_reply) \
3891 _(sw_interface_set_table_reply) \
3892 _(sw_interface_set_mpls_enable_reply) \
3893 _(sw_interface_set_vpath_reply) \
3894 _(sw_interface_set_vxlan_bypass_reply) \
3895 _(sw_interface_set_l2_bridge_reply) \
3896 _(bridge_domain_add_del_reply) \
3897 _(sw_interface_set_l2_xconnect_reply) \
3898 _(l2fib_add_del_reply) \
3899 _(ip_add_del_route_reply) \
3900 _(ip_mroute_add_del_reply) \
3901 _(mpls_route_add_del_reply) \
3902 _(mpls_ip_bind_unbind_reply) \
3903 _(proxy_arp_add_del_reply) \
3904 _(proxy_arp_intfc_enable_disable_reply) \
3905 _(sw_interface_set_unnumbered_reply) \
3906 _(ip_neighbor_add_del_reply) \
3907 _(reset_vrf_reply) \
3908 _(oam_add_del_reply) \
3909 _(reset_fib_reply) \
3910 _(dhcp_proxy_config_reply) \
3911 _(dhcp_proxy_set_vss_reply) \
3912 _(dhcp_client_config_reply) \
3913 _(set_ip_flow_hash_reply) \
3914 _(sw_interface_ip6_enable_disable_reply) \
3915 _(sw_interface_ip6_set_link_local_address_reply) \
3916 _(ip6nd_proxy_add_del_reply) \
3917 _(sw_interface_ip6nd_ra_prefix_reply) \
3918 _(sw_interface_ip6nd_ra_config_reply) \
3919 _(set_arp_neighbor_limit_reply) \
3920 _(l2_patch_add_del_reply) \
3921 _(sr_policy_add_reply) \
3922 _(sr_policy_mod_reply) \
3923 _(sr_policy_del_reply) \
3924 _(sr_localsid_add_del_reply) \
3925 _(sr_steering_add_del_reply) \
3926 _(classify_add_del_session_reply) \
3927 _(classify_set_interface_ip_table_reply) \
3928 _(classify_set_interface_l2_tables_reply) \
3929 _(l2tpv3_set_tunnel_cookies_reply) \
3930 _(l2tpv3_interface_enable_disable_reply) \
3931 _(l2tpv3_set_lookup_key_reply) \
3932 _(l2_fib_clear_table_reply) \
3933 _(l2_interface_efp_filter_reply) \
3934 _(l2_interface_vlan_tag_rewrite_reply) \
3935 _(modify_vhost_user_if_reply) \
3936 _(delete_vhost_user_if_reply) \
3937 _(want_ip4_arp_events_reply) \
3938 _(want_ip6_nd_events_reply) \
3939 _(input_acl_set_interface_reply) \
3940 _(ipsec_spd_add_del_reply) \
3941 _(ipsec_interface_add_del_spd_reply) \
3942 _(ipsec_spd_add_del_entry_reply) \
3943 _(ipsec_sad_add_del_entry_reply) \
3944 _(ipsec_sa_set_key_reply) \
3945 _(ikev2_profile_add_del_reply) \
3946 _(ikev2_profile_set_auth_reply) \
3947 _(ikev2_profile_set_id_reply) \
3948 _(ikev2_profile_set_ts_reply) \
3949 _(ikev2_set_local_key_reply) \
3950 _(ikev2_set_responder_reply) \
3951 _(ikev2_set_ike_transforms_reply) \
3952 _(ikev2_set_esp_transforms_reply) \
3953 _(ikev2_set_sa_lifetime_reply) \
3954 _(ikev2_initiate_sa_init_reply) \
3955 _(ikev2_initiate_del_ike_sa_reply) \
3956 _(ikev2_initiate_del_child_sa_reply) \
3957 _(ikev2_initiate_rekey_child_sa_reply) \
3958 _(delete_loopback_reply) \
3959 _(bd_ip_mac_add_del_reply) \
3960 _(map_del_domain_reply) \
3961 _(map_add_del_rule_reply) \
3962 _(want_interface_events_reply) \
3963 _(want_stats_reply) \
3964 _(cop_interface_enable_disable_reply) \
3965 _(cop_whitelist_enable_disable_reply) \
3966 _(sw_interface_clear_stats_reply) \
3967 _(ioam_enable_reply) \
3968 _(ioam_disable_reply) \
3969 _(one_add_del_locator_reply) \
3970 _(one_add_del_local_eid_reply) \
3971 _(one_add_del_remote_mapping_reply) \
3972 _(one_add_del_adjacency_reply) \
3973 _(one_add_del_map_resolver_reply) \
3974 _(one_add_del_map_server_reply) \
3975 _(one_enable_disable_reply) \
3976 _(one_rloc_probe_enable_disable_reply) \
3977 _(one_map_register_enable_disable_reply) \
3978 _(one_pitr_set_locator_set_reply) \
3979 _(one_map_request_mode_reply) \
3980 _(one_add_del_map_request_itr_rlocs_reply) \
3981 _(one_eid_table_add_del_map_reply) \
3982 _(gpe_add_del_fwd_entry_reply) \
3983 _(gpe_enable_disable_reply) \
3984 _(gpe_set_encap_mode_reply) \
3985 _(gpe_add_del_iface_reply) \
3986 _(vxlan_gpe_add_del_tunnel_reply) \
3987 _(af_packet_delete_reply) \
3988 _(policer_classify_set_interface_reply) \
3989 _(netmap_create_reply) \
3990 _(netmap_delete_reply) \
3991 _(set_ipfix_exporter_reply) \
3992 _(set_ipfix_classify_stream_reply) \
3993 _(ipfix_classify_table_add_del_reply) \
3994 _(flow_classify_set_interface_reply) \
3995 _(sw_interface_span_enable_disable_reply) \
3996 _(pg_capture_reply) \
3997 _(pg_enable_disable_reply) \
3998 _(ip_source_and_port_range_check_add_del_reply) \
3999 _(ip_source_and_port_range_check_interface_add_del_reply)\
4000 _(delete_subif_reply) \
4001 _(l2_interface_pbb_tag_rewrite_reply) \
4003 _(feature_enable_disable_reply) \
4004 _(sw_interface_tag_add_del_reply) \
4005 _(sw_interface_set_mtu_reply)
4008 static void vl_api_##n##_t_handler \
4009 (vl_api_##n##_t * mp) \
4011 vat_main_t * vam = &vat_main; \
4012 i32 retval = ntohl(mp->retval); \
4013 if (vam->async_mode) { \
4014 vam->async_errors += (retval < 0); \
4016 vam->retval = retval; \
4017 vam->result_ready = 1; \
4020 foreach_standard_reply_retval_handler;
4024 static void vl_api_##n##_t_handler_json \
4025 (vl_api_##n##_t * mp) \
4027 vat_main_t * vam = &vat_main; \
4028 vat_json_node_t node; \
4029 vat_json_init_object(&node); \
4030 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4031 vat_json_print(vam->ofp, &node); \
4032 vam->retval = ntohl(mp->retval); \
4033 vam->result_ready = 1; \
4035 foreach_standard_reply_retval_handler;
4039 * Table of message reply handlers, must include boilerplate handlers
4043 #define foreach_vpe_api_reply_msg \
4044 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4045 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4046 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4047 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4048 _(CONTROL_PING_REPLY, control_ping_reply) \
4049 _(CLI_REPLY, cli_reply) \
4050 _(CLI_INBAND_REPLY, cli_inband_reply) \
4051 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4052 sw_interface_add_del_address_reply) \
4053 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4054 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4055 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4056 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4057 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4058 sw_interface_set_l2_xconnect_reply) \
4059 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4060 sw_interface_set_l2_bridge_reply) \
4061 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4062 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4063 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
4064 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4065 _(L2_FLAGS_REPLY, l2_flags_reply) \
4066 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4067 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4068 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4069 _(TAP_DELETE_REPLY, tap_delete_reply) \
4070 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4071 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4072 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4073 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4074 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4075 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4076 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4077 proxy_arp_intfc_enable_disable_reply) \
4078 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4079 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4080 sw_interface_set_unnumbered_reply) \
4081 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4082 _(RESET_VRF_REPLY, reset_vrf_reply) \
4083 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4084 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4085 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4086 _(RESET_FIB_REPLY, reset_fib_reply) \
4087 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4088 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4089 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4090 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4091 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4092 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4093 sw_interface_ip6_enable_disable_reply) \
4094 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4095 sw_interface_ip6_set_link_local_address_reply) \
4096 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
4097 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
4098 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4099 sw_interface_ip6nd_ra_prefix_reply) \
4100 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4101 sw_interface_ip6nd_ra_config_reply) \
4102 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4103 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4104 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4105 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4106 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4107 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4108 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4109 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4110 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4111 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4112 classify_set_interface_ip_table_reply) \
4113 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4114 classify_set_interface_l2_tables_reply) \
4115 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4116 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4117 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4118 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4119 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4120 l2tpv3_interface_enable_disable_reply) \
4121 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4122 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4123 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4124 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4125 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4126 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4127 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4128 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4129 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4130 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4131 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4132 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4133 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4134 _(SHOW_VERSION_REPLY, show_version_reply) \
4135 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
4136 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4137 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4138 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4139 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4140 _(IP4_ARP_EVENT, ip4_arp_event) \
4141 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4142 _(IP6_ND_EVENT, ip6_nd_event) \
4143 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4144 _(IP_ADDRESS_DETAILS, ip_address_details) \
4145 _(IP_DETAILS, ip_details) \
4146 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4147 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4148 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4149 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4150 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4151 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4152 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4153 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4154 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4155 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4156 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4157 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4158 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4159 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4160 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4161 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4162 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4163 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4164 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4165 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4166 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4167 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4168 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4169 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4170 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4171 _(MAP_RULE_DETAILS, map_rule_details) \
4172 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4173 _(WANT_STATS_REPLY, want_stats_reply) \
4174 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4175 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4176 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4177 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4178 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4179 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4180 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4181 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4182 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4183 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4184 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4185 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4186 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4187 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4188 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4189 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4190 one_map_register_enable_disable_reply) \
4191 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4192 one_rloc_probe_enable_disable_reply) \
4193 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4194 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4195 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4196 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4197 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4198 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4199 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4200 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4201 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4202 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4203 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4204 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4205 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4206 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4207 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4208 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4209 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4210 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4211 gpe_fwd_entry_path_details) \
4212 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4213 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4214 one_add_del_map_request_itr_rlocs_reply) \
4215 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4216 one_get_map_request_itr_rlocs_reply) \
4217 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4218 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4219 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4220 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4221 show_one_map_register_state_reply) \
4222 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4223 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4224 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4225 _(POLICER_DETAILS, policer_details) \
4226 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4227 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4228 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4229 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4230 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4231 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4232 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4233 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4234 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4235 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4236 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4237 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4238 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4239 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4240 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4241 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4242 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4243 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4244 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4245 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4246 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4247 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4248 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4249 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4250 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4251 ip_source_and_port_range_check_add_del_reply) \
4252 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4253 ip_source_and_port_range_check_interface_add_del_reply) \
4254 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4255 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4256 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4257 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4258 _(PUNT_REPLY, punt_reply) \
4259 _(IP_FIB_DETAILS, ip_fib_details) \
4260 _(IP6_FIB_DETAILS, ip6_fib_details) \
4261 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4262 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4263 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4264 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4265 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4266 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4268 #define foreach_standalone_reply_msg \
4269 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4270 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
4271 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4272 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4273 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4274 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
4283 #define STR_VTR_OP_CASE(op) \
4284 case L2_VTR_ ## op: \
4288 str_vtr_op (u32 vtr_op)
4292 STR_VTR_OP_CASE (DISABLED);
4293 STR_VTR_OP_CASE (PUSH_1);
4294 STR_VTR_OP_CASE (PUSH_2);
4295 STR_VTR_OP_CASE (POP_1);
4296 STR_VTR_OP_CASE (POP_2);
4297 STR_VTR_OP_CASE (TRANSLATE_1_1);
4298 STR_VTR_OP_CASE (TRANSLATE_1_2);
4299 STR_VTR_OP_CASE (TRANSLATE_2_1);
4300 STR_VTR_OP_CASE (TRANSLATE_2_2);
4307 dump_sub_interface_table (vat_main_t * vam)
4309 const sw_interface_subif_t *sub = NULL;
4311 if (vam->json_output)
4314 ("JSON output supported only for VPE API calls and dump_stats_table");
4319 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4320 "Interface", "sw_if_index",
4321 "sub id", "dot1ad", "tags", "outer id",
4322 "inner id", "exact", "default", "outer any", "inner any");
4324 vec_foreach (sub, vam->sw_if_subif_table)
4327 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4328 sub->interface_name,
4330 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4331 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4332 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4333 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4334 if (sub->vtr_op != L2_VTR_DISABLED)
4337 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4338 "tag1: %d tag2: %d ]",
4339 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4340 sub->vtr_tag1, sub->vtr_tag2);
4348 name_sort_cmp (void *a1, void *a2)
4350 name_sort_t *n1 = a1;
4351 name_sort_t *n2 = a2;
4353 return strcmp ((char *) n1->name, (char *) n2->name);
4357 dump_interface_table (vat_main_t * vam)
4360 name_sort_t *nses = 0, *ns;
4362 if (vam->json_output)
4365 ("JSON output supported only for VPE API calls and dump_stats_table");
4370 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4372 vec_add2 (nses, ns, 1);
4373 ns->name = (u8 *)(p->key);
4374 ns->value = (u32) p->value[0];
4378 vec_sort_with_function (nses, name_sort_cmp);
4380 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4381 vec_foreach (ns, nses)
4383 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4390 dump_ip_table (vat_main_t * vam, int is_ipv6)
4392 const ip_details_t *det = NULL;
4393 const ip_address_details_t *address = NULL;
4396 print (vam->ofp, "%-12s", "sw_if_index");
4398 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4405 print (vam->ofp, "%-12d", i);
4406 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4411 vec_foreach (address, det->addr)
4415 is_ipv6 ? format_ip6_address : format_ip4_address,
4416 address->ip, address->prefix_length);
4424 dump_ipv4_table (vat_main_t * vam)
4426 if (vam->json_output)
4429 ("JSON output supported only for VPE API calls and dump_stats_table");
4433 return dump_ip_table (vam, 0);
4437 dump_ipv6_table (vat_main_t * vam)
4439 if (vam->json_output)
4442 ("JSON output supported only for VPE API calls and dump_stats_table");
4446 return dump_ip_table (vam, 1);
4450 counter_type_to_str (u8 counter_type, u8 is_combined)
4454 switch (counter_type)
4456 case VNET_INTERFACE_COUNTER_DROP:
4458 case VNET_INTERFACE_COUNTER_PUNT:
4460 case VNET_INTERFACE_COUNTER_IP4:
4462 case VNET_INTERFACE_COUNTER_IP6:
4464 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4466 case VNET_INTERFACE_COUNTER_RX_MISS:
4468 case VNET_INTERFACE_COUNTER_RX_ERROR:
4470 case VNET_INTERFACE_COUNTER_TX_ERROR:
4473 return "INVALID-COUNTER-TYPE";
4478 switch (counter_type)
4480 case VNET_INTERFACE_COUNTER_RX:
4482 case VNET_INTERFACE_COUNTER_TX:
4485 return "INVALID-COUNTER-TYPE";
4491 dump_stats_table (vat_main_t * vam)
4493 vat_json_node_t node;
4494 vat_json_node_t *msg_array;
4495 vat_json_node_t *msg;
4496 vat_json_node_t *counter_array;
4497 vat_json_node_t *counter;
4498 interface_counter_t c;
4500 ip4_fib_counter_t *c4;
4501 ip6_fib_counter_t *c6;
4502 ip4_nbr_counter_t *n4;
4503 ip6_nbr_counter_t *n6;
4506 if (!vam->json_output)
4508 clib_warning ("dump_stats_table supported only in JSON format");
4512 vat_json_init_object (&node);
4514 /* interface counters */
4515 msg_array = vat_json_object_add (&node, "interface_counters");
4516 vat_json_init_array (msg_array);
4517 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4519 msg = vat_json_array_add (msg_array);
4520 vat_json_init_object (msg);
4521 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4522 (u8 *) counter_type_to_str (i, 0));
4523 vat_json_object_add_int (msg, "is_combined", 0);
4524 counter_array = vat_json_object_add (msg, "data");
4525 vat_json_init_array (counter_array);
4526 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4528 packets = vam->simple_interface_counters[i][j];
4529 vat_json_array_add_uint (counter_array, packets);
4532 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4534 msg = vat_json_array_add (msg_array);
4535 vat_json_init_object (msg);
4536 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4537 (u8 *) counter_type_to_str (i, 1));
4538 vat_json_object_add_int (msg, "is_combined", 1);
4539 counter_array = vat_json_object_add (msg, "data");
4540 vat_json_init_array (counter_array);
4541 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4543 c = vam->combined_interface_counters[i][j];
4544 counter = vat_json_array_add (counter_array);
4545 vat_json_init_object (counter);
4546 vat_json_object_add_uint (counter, "packets", c.packets);
4547 vat_json_object_add_uint (counter, "bytes", c.bytes);
4551 /* ip4 fib counters */
4552 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4553 vat_json_init_array (msg_array);
4554 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4556 msg = vat_json_array_add (msg_array);
4557 vat_json_init_object (msg);
4558 vat_json_object_add_uint (msg, "vrf_id",
4559 vam->ip4_fib_counters_vrf_id_by_index[i]);
4560 counter_array = vat_json_object_add (msg, "c");
4561 vat_json_init_array (counter_array);
4562 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4564 counter = vat_json_array_add (counter_array);
4565 vat_json_init_object (counter);
4566 c4 = &vam->ip4_fib_counters[i][j];
4567 vat_json_object_add_ip4 (counter, "address", c4->address);
4568 vat_json_object_add_uint (counter, "address_length",
4569 c4->address_length);
4570 vat_json_object_add_uint (counter, "packets", c4->packets);
4571 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4575 /* ip6 fib counters */
4576 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4577 vat_json_init_array (msg_array);
4578 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4580 msg = vat_json_array_add (msg_array);
4581 vat_json_init_object (msg);
4582 vat_json_object_add_uint (msg, "vrf_id",
4583 vam->ip6_fib_counters_vrf_id_by_index[i]);
4584 counter_array = vat_json_object_add (msg, "c");
4585 vat_json_init_array (counter_array);
4586 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4588 counter = vat_json_array_add (counter_array);
4589 vat_json_init_object (counter);
4590 c6 = &vam->ip6_fib_counters[i][j];
4591 vat_json_object_add_ip6 (counter, "address", c6->address);
4592 vat_json_object_add_uint (counter, "address_length",
4593 c6->address_length);
4594 vat_json_object_add_uint (counter, "packets", c6->packets);
4595 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4599 /* ip4 nbr counters */
4600 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4601 vat_json_init_array (msg_array);
4602 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4604 msg = vat_json_array_add (msg_array);
4605 vat_json_init_object (msg);
4606 vat_json_object_add_uint (msg, "sw_if_index", i);
4607 counter_array = vat_json_object_add (msg, "c");
4608 vat_json_init_array (counter_array);
4609 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4611 counter = vat_json_array_add (counter_array);
4612 vat_json_init_object (counter);
4613 n4 = &vam->ip4_nbr_counters[i][j];
4614 vat_json_object_add_ip4 (counter, "address", n4->address);
4615 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4616 vat_json_object_add_uint (counter, "packets", n4->packets);
4617 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4621 /* ip6 nbr counters */
4622 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4623 vat_json_init_array (msg_array);
4624 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4626 msg = vat_json_array_add (msg_array);
4627 vat_json_init_object (msg);
4628 vat_json_object_add_uint (msg, "sw_if_index", i);
4629 counter_array = vat_json_object_add (msg, "c");
4630 vat_json_init_array (counter_array);
4631 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4633 counter = vat_json_array_add (counter_array);
4634 vat_json_init_object (counter);
4635 n6 = &vam->ip6_nbr_counters[i][j];
4636 vat_json_object_add_ip6 (counter, "address", n6->address);
4637 vat_json_object_add_uint (counter, "packets", n6->packets);
4638 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4642 vat_json_print (vam->ofp, &node);
4643 vat_json_free (&node);
4649 exec (vat_main_t * vam)
4651 api_main_t *am = &api_main;
4652 vl_api_cli_request_t *mp;
4656 unformat_input_t *i = vam->input;
4658 if (vec_len (i->buffer) == 0)
4661 if (vam->exec_mode == 0 && unformat (i, "mode"))
4666 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4673 M (CLI_REQUEST, mp);
4676 * Copy cmd into shared memory.
4677 * In order for the CLI command to work, it
4678 * must be a vector ending in \n, not a C-string ending
4681 pthread_mutex_lock (&am->vlib_rp->mutex);
4682 oldheap = svm_push_data_heap (am->vlib_rp);
4684 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4685 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4687 svm_pop_heap (oldheap);
4688 pthread_mutex_unlock (&am->vlib_rp->mutex);
4690 mp->cmd_in_shmem = (u64) cmd;
4692 timeout = vat_time_now (vam) + 10.0;
4694 while (vat_time_now (vam) < timeout)
4696 if (vam->result_ready == 1)
4699 if (vam->shmem_result != NULL)
4700 print (vam->ofp, "%s", vam->shmem_result);
4701 pthread_mutex_lock (&am->vlib_rp->mutex);
4702 oldheap = svm_push_data_heap (am->vlib_rp);
4704 free_me = (u8 *) vam->shmem_result;
4707 svm_pop_heap (oldheap);
4708 pthread_mutex_unlock (&am->vlib_rp->mutex);
4716 * Future replacement of exec() that passes CLI buffers directly in
4717 * the API messages instead of an additional shared memory area.
4720 exec_inband (vat_main_t * vam)
4722 vl_api_cli_inband_t *mp;
4723 unformat_input_t *i = vam->input;
4726 if (vec_len (i->buffer) == 0)
4729 if (vam->exec_mode == 0 && unformat (i, "mode"))
4734 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4741 * In order for the CLI command to work, it
4742 * must be a vector ending in \n, not a C-string ending
4745 u32 len = vec_len (vam->input->buffer);
4746 M2 (CLI_INBAND, mp, len);
4747 clib_memcpy (mp->cmd, vam->input->buffer, len);
4748 mp->length = htonl (len);
4751 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
4756 api_create_loopback (vat_main_t * vam)
4758 unformat_input_t *i = vam->input;
4759 vl_api_create_loopback_t *mp;
4760 vl_api_create_loopback_instance_t *mp_lbi;
4763 u8 is_specified = 0;
4764 u32 user_instance = 0;
4767 memset (mac_address, 0, sizeof (mac_address));
4769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4771 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4773 if (unformat (i, "instance %d", &user_instance))
4781 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
4782 mp_lbi->is_specified = is_specified;
4784 mp_lbi->user_instance = htonl (user_instance);
4786 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
4791 /* Construct the API message */
4792 M (CREATE_LOOPBACK, mp);
4794 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4803 api_delete_loopback (vat_main_t * vam)
4805 unformat_input_t *i = vam->input;
4806 vl_api_delete_loopback_t *mp;
4807 u32 sw_if_index = ~0;
4810 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4812 if (unformat (i, "sw_if_index %d", &sw_if_index))
4818 if (sw_if_index == ~0)
4820 errmsg ("missing sw_if_index");
4824 /* Construct the API message */
4825 M (DELETE_LOOPBACK, mp);
4826 mp->sw_if_index = ntohl (sw_if_index);
4834 api_want_stats (vat_main_t * vam)
4836 unformat_input_t *i = vam->input;
4837 vl_api_want_stats_t *mp;
4841 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4843 if (unformat (i, "enable"))
4845 else if (unformat (i, "disable"))
4853 errmsg ("missing enable|disable");
4858 mp->enable_disable = enable;
4866 api_want_interface_events (vat_main_t * vam)
4868 unformat_input_t *i = vam->input;
4869 vl_api_want_interface_events_t *mp;
4873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4875 if (unformat (i, "enable"))
4877 else if (unformat (i, "disable"))
4885 errmsg ("missing enable|disable");
4889 M (WANT_INTERFACE_EVENTS, mp);
4890 mp->enable_disable = enable;
4892 vam->interface_event_display = enable;
4900 /* Note: non-static, called once to set up the initial intfc table */
4902 api_sw_interface_dump (vat_main_t * vam)
4904 vl_api_sw_interface_dump_t *mp;
4905 vl_api_control_ping_t *mp_ping;
4907 name_sort_t *nses = 0, *ns;
4908 sw_interface_subif_t *sub = NULL;
4911 /* Toss the old name table */
4913 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4915 vec_add2 (nses, ns, 1);
4916 ns->name = (u8 *)(p->key);
4917 ns->value = (u32) p->value[0];
4921 hash_free (vam->sw_if_index_by_interface_name);
4923 vec_foreach (ns, nses) vec_free (ns->name);
4927 vec_foreach (sub, vam->sw_if_subif_table)
4929 vec_free (sub->interface_name);
4931 vec_free (vam->sw_if_subif_table);
4933 /* recreate the interface name hash table */
4934 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4936 /* Get list of ethernets */
4937 M (SW_INTERFACE_DUMP, mp);
4938 mp->name_filter_valid = 1;
4939 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4942 /* and local / loopback interfaces */
4943 M (SW_INTERFACE_DUMP, mp);
4944 mp->name_filter_valid = 1;
4945 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4948 /* and packet-generator interfaces */
4949 M (SW_INTERFACE_DUMP, mp);
4950 mp->name_filter_valid = 1;
4951 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4954 /* and vxlan-gpe tunnel interfaces */
4955 M (SW_INTERFACE_DUMP, mp);
4956 mp->name_filter_valid = 1;
4957 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4958 sizeof (mp->name_filter) - 1);
4961 /* and vxlan tunnel interfaces */
4962 M (SW_INTERFACE_DUMP, mp);
4963 mp->name_filter_valid = 1;
4964 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4967 /* and host (af_packet) interfaces */
4968 M (SW_INTERFACE_DUMP, mp);
4969 mp->name_filter_valid = 1;
4970 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4973 /* and l2tpv3 tunnel interfaces */
4974 M (SW_INTERFACE_DUMP, mp);
4975 mp->name_filter_valid = 1;
4976 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4977 sizeof (mp->name_filter) - 1);
4980 /* and GRE tunnel interfaces */
4981 M (SW_INTERFACE_DUMP, mp);
4982 mp->name_filter_valid = 1;
4983 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4986 /* and LISP-GPE interfaces */
4987 M (SW_INTERFACE_DUMP, mp);
4988 mp->name_filter_valid = 1;
4989 strncpy ((char *) mp->name_filter, "lisp_gpe",
4990 sizeof (mp->name_filter) - 1);
4993 /* and IPSEC tunnel interfaces */
4994 M (SW_INTERFACE_DUMP, mp);
4995 mp->name_filter_valid = 1;
4996 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4999 /* Use a control ping for synchronization */
5000 M (CONTROL_PING, mp_ping);
5008 api_sw_interface_set_flags (vat_main_t * vam)
5010 unformat_input_t *i = vam->input;
5011 vl_api_sw_interface_set_flags_t *mp;
5013 u8 sw_if_index_set = 0;
5014 u8 admin_up = 0, link_up = 0;
5017 /* Parse args required to build the message */
5018 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5020 if (unformat (i, "admin-up"))
5022 else if (unformat (i, "admin-down"))
5024 else if (unformat (i, "link-up"))
5026 else if (unformat (i, "link-down"))
5029 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5030 sw_if_index_set = 1;
5031 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5032 sw_if_index_set = 1;
5037 if (sw_if_index_set == 0)
5039 errmsg ("missing interface name or sw_if_index");
5043 /* Construct the API message */
5044 M (SW_INTERFACE_SET_FLAGS, mp);
5045 mp->sw_if_index = ntohl (sw_if_index);
5046 mp->admin_up_down = admin_up;
5047 mp->link_up_down = link_up;
5052 /* Wait for a reply, return the good/bad news... */
5058 api_sw_interface_clear_stats (vat_main_t * vam)
5060 unformat_input_t *i = vam->input;
5061 vl_api_sw_interface_clear_stats_t *mp;
5063 u8 sw_if_index_set = 0;
5066 /* Parse args required to build the message */
5067 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5069 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5070 sw_if_index_set = 1;
5071 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5072 sw_if_index_set = 1;
5077 /* Construct the API message */
5078 M (SW_INTERFACE_CLEAR_STATS, mp);
5080 if (sw_if_index_set == 1)
5081 mp->sw_if_index = ntohl (sw_if_index);
5083 mp->sw_if_index = ~0;
5088 /* Wait for a reply, return the good/bad news... */
5094 api_sw_interface_add_del_address (vat_main_t * vam)
5096 unformat_input_t *i = vam->input;
5097 vl_api_sw_interface_add_del_address_t *mp;
5099 u8 sw_if_index_set = 0;
5100 u8 is_add = 1, del_all = 0;
5101 u32 address_length = 0;
5102 u8 v4_address_set = 0;
5103 u8 v6_address_set = 0;
5104 ip4_address_t v4address;
5105 ip6_address_t v6address;
5108 /* Parse args required to build the message */
5109 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5111 if (unformat (i, "del-all"))
5113 else if (unformat (i, "del"))
5116 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5117 sw_if_index_set = 1;
5118 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5119 sw_if_index_set = 1;
5120 else if (unformat (i, "%U/%d",
5121 unformat_ip4_address, &v4address, &address_length))
5123 else if (unformat (i, "%U/%d",
5124 unformat_ip6_address, &v6address, &address_length))
5130 if (sw_if_index_set == 0)
5132 errmsg ("missing interface name or sw_if_index");
5135 if (v4_address_set && v6_address_set)
5137 errmsg ("both v4 and v6 addresses set");
5140 if (!v4_address_set && !v6_address_set && !del_all)
5142 errmsg ("no addresses set");
5146 /* Construct the API message */
5147 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5149 mp->sw_if_index = ntohl (sw_if_index);
5150 mp->is_add = is_add;
5151 mp->del_all = del_all;
5155 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5159 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5161 mp->address_length = address_length;
5166 /* Wait for a reply, return good/bad news */
5172 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5174 unformat_input_t *i = vam->input;
5175 vl_api_sw_interface_set_mpls_enable_t *mp;
5177 u8 sw_if_index_set = 0;
5181 /* Parse args required to build the message */
5182 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5184 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5185 sw_if_index_set = 1;
5186 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5187 sw_if_index_set = 1;
5188 else if (unformat (i, "disable"))
5190 else if (unformat (i, "dis"))
5196 if (sw_if_index_set == 0)
5198 errmsg ("missing interface name or sw_if_index");
5202 /* Construct the API message */
5203 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5205 mp->sw_if_index = ntohl (sw_if_index);
5206 mp->enable = enable;
5211 /* Wait for a reply... */
5217 api_sw_interface_set_table (vat_main_t * vam)
5219 unformat_input_t *i = vam->input;
5220 vl_api_sw_interface_set_table_t *mp;
5221 u32 sw_if_index, vrf_id = 0;
5222 u8 sw_if_index_set = 0;
5226 /* Parse args required to build the message */
5227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5229 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5230 sw_if_index_set = 1;
5231 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5232 sw_if_index_set = 1;
5233 else if (unformat (i, "vrf %d", &vrf_id))
5235 else if (unformat (i, "ipv6"))
5241 if (sw_if_index_set == 0)
5243 errmsg ("missing interface name or sw_if_index");
5247 /* Construct the API message */
5248 M (SW_INTERFACE_SET_TABLE, mp);
5250 mp->sw_if_index = ntohl (sw_if_index);
5251 mp->is_ipv6 = is_ipv6;
5252 mp->vrf_id = ntohl (vrf_id);
5257 /* Wait for a reply... */
5262 static void vl_api_sw_interface_get_table_reply_t_handler
5263 (vl_api_sw_interface_get_table_reply_t * mp)
5265 vat_main_t *vam = &vat_main;
5267 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5269 vam->retval = ntohl (mp->retval);
5270 vam->result_ready = 1;
5274 static void vl_api_sw_interface_get_table_reply_t_handler_json
5275 (vl_api_sw_interface_get_table_reply_t * mp)
5277 vat_main_t *vam = &vat_main;
5278 vat_json_node_t node;
5280 vat_json_init_object (&node);
5281 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5282 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5284 vat_json_print (vam->ofp, &node);
5285 vat_json_free (&node);
5287 vam->retval = ntohl (mp->retval);
5288 vam->result_ready = 1;
5292 api_sw_interface_get_table (vat_main_t * vam)
5294 unformat_input_t *i = vam->input;
5295 vl_api_sw_interface_get_table_t *mp;
5297 u8 sw_if_index_set = 0;
5301 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5303 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5304 sw_if_index_set = 1;
5305 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5306 sw_if_index_set = 1;
5307 else if (unformat (i, "ipv6"))
5313 if (sw_if_index_set == 0)
5315 errmsg ("missing interface name or sw_if_index");
5319 M (SW_INTERFACE_GET_TABLE, mp);
5320 mp->sw_if_index = htonl (sw_if_index);
5321 mp->is_ipv6 = is_ipv6;
5329 api_sw_interface_set_vpath (vat_main_t * vam)
5331 unformat_input_t *i = vam->input;
5332 vl_api_sw_interface_set_vpath_t *mp;
5333 u32 sw_if_index = 0;
5334 u8 sw_if_index_set = 0;
5338 /* Parse args required to build the message */
5339 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5341 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5342 sw_if_index_set = 1;
5343 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5344 sw_if_index_set = 1;
5345 else if (unformat (i, "enable"))
5347 else if (unformat (i, "disable"))
5353 if (sw_if_index_set == 0)
5355 errmsg ("missing interface name or sw_if_index");
5359 /* Construct the API message */
5360 M (SW_INTERFACE_SET_VPATH, mp);
5362 mp->sw_if_index = ntohl (sw_if_index);
5363 mp->enable = is_enable;
5368 /* Wait for a reply... */
5374 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5376 unformat_input_t *i = vam->input;
5377 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5378 u32 sw_if_index = 0;
5379 u8 sw_if_index_set = 0;
5384 /* Parse args required to build the message */
5385 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5387 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5388 sw_if_index_set = 1;
5389 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5390 sw_if_index_set = 1;
5391 else if (unformat (i, "enable"))
5393 else if (unformat (i, "disable"))
5395 else if (unformat (i, "ip4"))
5397 else if (unformat (i, "ip6"))
5403 if (sw_if_index_set == 0)
5405 errmsg ("missing interface name or sw_if_index");
5409 /* Construct the API message */
5410 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5412 mp->sw_if_index = ntohl (sw_if_index);
5413 mp->enable = is_enable;
5414 mp->is_ipv6 = is_ipv6;
5419 /* Wait for a reply... */
5425 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5427 unformat_input_t *i = vam->input;
5428 vl_api_sw_interface_set_l2_xconnect_t *mp;
5430 u8 rx_sw_if_index_set = 0;
5432 u8 tx_sw_if_index_set = 0;
5436 /* Parse args required to build the message */
5437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5439 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5440 rx_sw_if_index_set = 1;
5441 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5442 tx_sw_if_index_set = 1;
5443 else if (unformat (i, "rx"))
5445 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5447 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5449 rx_sw_if_index_set = 1;
5454 else if (unformat (i, "tx"))
5456 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5458 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5460 tx_sw_if_index_set = 1;
5465 else if (unformat (i, "enable"))
5467 else if (unformat (i, "disable"))
5473 if (rx_sw_if_index_set == 0)
5475 errmsg ("missing rx interface name or rx_sw_if_index");
5479 if (enable && (tx_sw_if_index_set == 0))
5481 errmsg ("missing tx interface name or tx_sw_if_index");
5485 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5487 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5488 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5489 mp->enable = enable;
5497 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5499 unformat_input_t *i = vam->input;
5500 vl_api_sw_interface_set_l2_bridge_t *mp;
5502 u8 rx_sw_if_index_set = 0;
5510 /* Parse args required to build the message */
5511 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5513 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5514 rx_sw_if_index_set = 1;
5515 else if (unformat (i, "bd_id %d", &bd_id))
5519 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5520 rx_sw_if_index_set = 1;
5521 else if (unformat (i, "shg %d", &shg))
5523 else if (unformat (i, "bvi"))
5525 else if (unformat (i, "enable"))
5527 else if (unformat (i, "disable"))
5533 if (rx_sw_if_index_set == 0)
5535 errmsg ("missing rx interface name or sw_if_index");
5539 if (enable && (bd_id_set == 0))
5541 errmsg ("missing bridge domain");
5545 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
5547 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5548 mp->bd_id = ntohl (bd_id);
5551 mp->enable = enable;
5559 api_bridge_domain_dump (vat_main_t * vam)
5561 unformat_input_t *i = vam->input;
5562 vl_api_bridge_domain_dump_t *mp;
5563 vl_api_control_ping_t *mp_ping;
5567 /* Parse args required to build the message */
5568 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5570 if (unformat (i, "bd_id %d", &bd_id))
5576 M (BRIDGE_DOMAIN_DUMP, mp);
5577 mp->bd_id = ntohl (bd_id);
5580 /* Use a control ping for synchronization */
5581 M (CONTROL_PING, mp_ping);
5589 api_bridge_domain_add_del (vat_main_t * vam)
5591 unformat_input_t *i = vam->input;
5592 vl_api_bridge_domain_add_del_t *mp;
5595 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5599 /* Parse args required to build the message */
5600 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5602 if (unformat (i, "bd_id %d", &bd_id))
5604 else if (unformat (i, "flood %d", &flood))
5606 else if (unformat (i, "uu-flood %d", &uu_flood))
5608 else if (unformat (i, "forward %d", &forward))
5610 else if (unformat (i, "learn %d", &learn))
5612 else if (unformat (i, "arp-term %d", &arp_term))
5614 else if (unformat (i, "mac-age %d", &mac_age))
5616 else if (unformat (i, "del"))
5619 flood = uu_flood = forward = learn = 0;
5627 errmsg ("missing bridge domain");
5633 errmsg ("mac age must be less than 256 ");
5637 M (BRIDGE_DOMAIN_ADD_DEL, mp);
5639 mp->bd_id = ntohl (bd_id);
5641 mp->uu_flood = uu_flood;
5642 mp->forward = forward;
5644 mp->arp_term = arp_term;
5645 mp->is_add = is_add;
5646 mp->mac_age = (u8) mac_age;
5654 api_l2fib_add_del (vat_main_t * vam)
5656 unformat_input_t *i = vam->input;
5657 vl_api_l2fib_add_del_t *mp;
5663 u32 sw_if_index = ~0;
5664 u8 sw_if_index_set = 0;
5673 /* Parse args required to build the message */
5674 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5676 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5678 else if (unformat (i, "bd_id %d", &bd_id))
5680 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5681 sw_if_index_set = 1;
5682 else if (unformat (i, "sw_if"))
5684 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5687 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5688 sw_if_index_set = 1;
5693 else if (unformat (i, "static"))
5695 else if (unformat (i, "filter"))
5700 else if (unformat (i, "bvi"))
5705 else if (unformat (i, "del"))
5707 else if (unformat (i, "count %d", &count))
5715 errmsg ("missing mac address");
5721 errmsg ("missing bridge domain");
5725 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5727 errmsg ("missing interface name or sw_if_index");
5733 /* Turn on async mode */
5734 vam->async_mode = 1;
5735 vam->async_errors = 0;
5736 before = vat_time_now (vam);
5739 for (j = 0; j < count; j++)
5741 M (L2FIB_ADD_DEL, mp);
5744 mp->bd_id = ntohl (bd_id);
5745 mp->is_add = is_add;
5749 mp->sw_if_index = ntohl (sw_if_index);
5750 mp->static_mac = static_mac;
5751 mp->filter_mac = filter_mac;
5752 mp->bvi_mac = bvi_mac;
5754 increment_mac_address (&mac);
5761 vl_api_control_ping_t *mp_ping;
5764 /* Shut off async mode */
5765 vam->async_mode = 0;
5767 M (CONTROL_PING, mp_ping);
5770 timeout = vat_time_now (vam) + 1.0;
5771 while (vat_time_now (vam) < timeout)
5772 if (vam->result_ready == 1)
5777 if (vam->retval == -99)
5780 if (vam->async_errors > 0)
5782 errmsg ("%d asynchronous errors", vam->async_errors);
5785 vam->async_errors = 0;
5786 after = vat_time_now (vam);
5788 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
5789 count, after - before, count / (after - before));
5795 /* Wait for a reply... */
5799 /* Return the good/bad news */
5800 return (vam->retval);
5804 api_l2_flags (vat_main_t * vam)
5806 unformat_input_t *i = vam->input;
5807 vl_api_l2_flags_t *mp;
5809 u32 feature_bitmap = 0;
5810 u8 sw_if_index_set = 0;
5813 /* Parse args required to build the message */
5814 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5816 if (unformat (i, "sw_if_index %d", &sw_if_index))
5817 sw_if_index_set = 1;
5818 else if (unformat (i, "sw_if"))
5820 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5823 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5824 sw_if_index_set = 1;
5829 else if (unformat (i, "learn"))
5830 feature_bitmap |= L2INPUT_FEAT_LEARN;
5831 else if (unformat (i, "forward"))
5832 feature_bitmap |= L2INPUT_FEAT_FWD;
5833 else if (unformat (i, "flood"))
5834 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5835 else if (unformat (i, "uu-flood"))
5836 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5841 if (sw_if_index_set == 0)
5843 errmsg ("missing interface name or sw_if_index");
5849 mp->sw_if_index = ntohl (sw_if_index);
5850 mp->feature_bitmap = ntohl (feature_bitmap);
5858 api_bridge_flags (vat_main_t * vam)
5860 unformat_input_t *i = vam->input;
5861 vl_api_bridge_flags_t *mp;
5868 /* Parse args required to build the message */
5869 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5871 if (unformat (i, "bd_id %d", &bd_id))
5873 else if (unformat (i, "learn"))
5875 else if (unformat (i, "forward"))
5877 else if (unformat (i, "flood"))
5879 else if (unformat (i, "uu-flood"))
5880 flags |= L2_UU_FLOOD;
5881 else if (unformat (i, "arp-term"))
5882 flags |= L2_ARP_TERM;
5883 else if (unformat (i, "off"))
5885 else if (unformat (i, "disable"))
5893 errmsg ("missing bridge domain");
5897 M (BRIDGE_FLAGS, mp);
5899 mp->bd_id = ntohl (bd_id);
5900 mp->feature_bitmap = ntohl (flags);
5901 mp->is_set = is_set;
5909 api_bd_ip_mac_add_del (vat_main_t * vam)
5911 unformat_input_t *i = vam->input;
5912 vl_api_bd_ip_mac_add_del_t *mp;
5919 ip4_address_t v4addr;
5920 ip6_address_t v6addr;
5925 /* Parse args required to build the message */
5926 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5928 if (unformat (i, "bd_id %d", &bd_id))
5932 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5936 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5941 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5945 else if (unformat (i, "del"))
5953 errmsg ("missing bridge domain");
5956 else if (ip_set == 0)
5958 errmsg ("missing IP address");
5961 else if (mac_set == 0)
5963 errmsg ("missing MAC address");
5967 M (BD_IP_MAC_ADD_DEL, mp);
5969 mp->bd_id = ntohl (bd_id);
5970 mp->is_ipv6 = is_ipv6;
5971 mp->is_add = is_add;
5973 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5975 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5976 clib_memcpy (mp->mac_address, macaddr, 6);
5983 api_tap_connect (vat_main_t * vam)
5985 unformat_input_t *i = vam->input;
5986 vl_api_tap_connect_t *mp;
5992 ip4_address_t ip4_address;
5994 int ip4_address_set = 0;
5995 ip6_address_t ip6_address;
5997 int ip6_address_set = 0;
6000 memset (mac_address, 0, sizeof (mac_address));
6002 /* Parse args required to build the message */
6003 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6005 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6009 else if (unformat (i, "random-mac"))
6011 else if (unformat (i, "tapname %s", &tap_name))
6013 else if (unformat (i, "tag %s", &tag))
6015 else if (unformat (i, "address %U/%d",
6016 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6017 ip4_address_set = 1;
6018 else if (unformat (i, "address %U/%d",
6019 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6020 ip6_address_set = 1;
6027 errmsg ("missing tap name");
6030 if (vec_len (tap_name) > 63)
6032 errmsg ("tap name too long");
6035 vec_add1 (tap_name, 0);
6037 if (vec_len (tag) > 63)
6039 errmsg ("tag too long");
6043 /* Construct the API message */
6044 M (TAP_CONNECT, mp);
6046 mp->use_random_mac = random_mac;
6047 clib_memcpy (mp->mac_address, mac_address, 6);
6048 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6050 clib_memcpy (mp->tag, tag, vec_len (tag));
6052 if (ip4_address_set)
6054 mp->ip4_address_set = 1;
6055 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6056 mp->ip4_mask_width = ip4_mask_width;
6058 if (ip6_address_set)
6060 mp->ip6_address_set = 1;
6061 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6062 mp->ip6_mask_width = ip6_mask_width;
6065 vec_free (tap_name);
6071 /* Wait for a reply... */
6077 api_tap_modify (vat_main_t * vam)
6079 unformat_input_t *i = vam->input;
6080 vl_api_tap_modify_t *mp;
6085 u32 sw_if_index = ~0;
6086 u8 sw_if_index_set = 0;
6089 memset (mac_address, 0, sizeof (mac_address));
6091 /* Parse args required to build the message */
6092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6094 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6095 sw_if_index_set = 1;
6096 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6097 sw_if_index_set = 1;
6098 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6102 else if (unformat (i, "random-mac"))
6104 else if (unformat (i, "tapname %s", &tap_name))
6110 if (sw_if_index_set == 0)
6112 errmsg ("missing vpp interface name");
6117 errmsg ("missing tap name");
6120 if (vec_len (tap_name) > 63)
6122 errmsg ("tap name too long");
6124 vec_add1 (tap_name, 0);
6126 /* Construct the API message */
6129 mp->use_random_mac = random_mac;
6130 mp->sw_if_index = ntohl (sw_if_index);
6131 clib_memcpy (mp->mac_address, mac_address, 6);
6132 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6133 vec_free (tap_name);
6138 /* Wait for a reply... */
6144 api_tap_delete (vat_main_t * vam)
6146 unformat_input_t *i = vam->input;
6147 vl_api_tap_delete_t *mp;
6148 u32 sw_if_index = ~0;
6149 u8 sw_if_index_set = 0;
6152 /* Parse args required to build the message */
6153 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6155 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6156 sw_if_index_set = 1;
6157 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6158 sw_if_index_set = 1;
6163 if (sw_if_index_set == 0)
6165 errmsg ("missing vpp interface name");
6169 /* Construct the API message */
6172 mp->sw_if_index = ntohl (sw_if_index);
6177 /* Wait for a reply... */
6183 api_ip_add_del_route (vat_main_t * vam)
6185 unformat_input_t *i = vam->input;
6186 vl_api_ip_add_del_route_t *mp;
6187 u32 sw_if_index = ~0, vrf_id = 0;
6189 u8 is_local = 0, is_drop = 0;
6190 u8 is_unreach = 0, is_prohibit = 0;
6191 u8 create_vrf_if_needed = 0;
6193 u32 next_hop_weight = 1;
6195 u8 is_multipath = 0;
6197 u8 address_length_set = 0;
6198 u32 next_hop_table_id = 0;
6199 u32 resolve_attempts = 0;
6200 u32 dst_address_length = 0;
6201 u8 next_hop_set = 0;
6202 ip4_address_t v4_dst_address, v4_next_hop_address;
6203 ip6_address_t v6_dst_address, v6_next_hop_address;
6207 u32 random_add_del = 0;
6208 u32 *random_vector = 0;
6210 u32 random_seed = 0xdeaddabe;
6211 u32 classify_table_index = ~0;
6213 u8 resolve_host = 0, resolve_attached = 0;
6214 mpls_label_t *next_hop_out_label_stack = NULL;
6215 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6216 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6218 /* Parse args required to build the message */
6219 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6221 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6223 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6225 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6230 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6235 else if (unformat (i, "/%d", &dst_address_length))
6237 address_length_set = 1;
6240 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6241 &v4_next_hop_address))
6245 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6246 &v6_next_hop_address))
6250 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6252 else if (unformat (i, "weight %d", &next_hop_weight))
6254 else if (unformat (i, "drop"))
6258 else if (unformat (i, "null-send-unreach"))
6262 else if (unformat (i, "null-send-prohibit"))
6266 else if (unformat (i, "local"))
6270 else if (unformat (i, "classify %d", &classify_table_index))
6274 else if (unformat (i, "del"))
6276 else if (unformat (i, "add"))
6278 else if (unformat (i, "not-last"))
6280 else if (unformat (i, "resolve-via-host"))
6282 else if (unformat (i, "resolve-via-attached"))
6283 resolve_attached = 1;
6284 else if (unformat (i, "multipath"))
6286 else if (unformat (i, "vrf %d", &vrf_id))
6288 else if (unformat (i, "create-vrf"))
6289 create_vrf_if_needed = 1;
6290 else if (unformat (i, "count %d", &count))
6292 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6294 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6296 else if (unformat (i, "out-label %d", &next_hop_out_label))
6297 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6298 else if (unformat (i, "via-label %d", &next_hop_via_label))
6300 else if (unformat (i, "random"))
6302 else if (unformat (i, "seed %d", &random_seed))
6306 clib_warning ("parse error '%U'", format_unformat_error, i);
6311 if (!next_hop_set && !is_drop && !is_local &&
6312 !is_classify && !is_unreach && !is_prohibit &&
6313 MPLS_LABEL_INVALID == next_hop_via_label)
6316 ("next hop / local / drop / unreach / prohibit / classify not set");
6320 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6322 errmsg ("next hop and next-hop via label set");
6325 if (address_set == 0)
6327 errmsg ("missing addresses");
6331 if (address_length_set == 0)
6333 errmsg ("missing address length");
6337 /* Generate a pile of unique, random routes */
6340 u32 this_random_address;
6341 random_hash = hash_create (count, sizeof (uword));
6343 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6344 for (j = 0; j <= count; j++)
6348 this_random_address = random_u32 (&random_seed);
6349 this_random_address =
6350 clib_host_to_net_u32 (this_random_address);
6352 while (hash_get (random_hash, this_random_address));
6353 vec_add1 (random_vector, this_random_address);
6354 hash_set (random_hash, this_random_address, 1);
6356 hash_free (random_hash);
6357 v4_dst_address.as_u32 = random_vector[0];
6362 /* Turn on async mode */
6363 vam->async_mode = 1;
6364 vam->async_errors = 0;
6365 before = vat_time_now (vam);
6368 for (j = 0; j < count; j++)
6370 /* Construct the API message */
6371 M2 (IP_ADD_DEL_ROUTE, mp,
6372 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6374 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6375 mp->table_id = ntohl (vrf_id);
6376 mp->create_vrf_if_needed = create_vrf_if_needed;
6378 mp->is_add = is_add;
6379 mp->is_drop = is_drop;
6380 mp->is_unreach = is_unreach;
6381 mp->is_prohibit = is_prohibit;
6382 mp->is_ipv6 = is_ipv6;
6383 mp->is_local = is_local;
6384 mp->is_classify = is_classify;
6385 mp->is_multipath = is_multipath;
6386 mp->is_resolve_host = resolve_host;
6387 mp->is_resolve_attached = resolve_attached;
6388 mp->not_last = not_last;
6389 mp->next_hop_weight = next_hop_weight;
6390 mp->dst_address_length = dst_address_length;
6391 mp->next_hop_table_id = ntohl (next_hop_table_id);
6392 mp->classify_table_index = ntohl (classify_table_index);
6393 mp->next_hop_via_label = ntohl (next_hop_via_label);
6394 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6395 if (0 != mp->next_hop_n_out_labels)
6397 memcpy (mp->next_hop_out_label_stack,
6398 next_hop_out_label_stack,
6399 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6400 vec_free (next_hop_out_label_stack);
6405 clib_memcpy (mp->dst_address, &v6_dst_address,
6406 sizeof (v6_dst_address));
6408 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6409 sizeof (v6_next_hop_address));
6410 increment_v6_address (&v6_dst_address);
6414 clib_memcpy (mp->dst_address, &v4_dst_address,
6415 sizeof (v4_dst_address));
6417 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6418 sizeof (v4_next_hop_address));
6420 v4_dst_address.as_u32 = random_vector[j + 1];
6422 increment_v4_address (&v4_dst_address);
6426 /* If we receive SIGTERM, stop now... */
6431 /* When testing multiple add/del ops, use a control-ping to sync */
6434 vl_api_control_ping_t *mp_ping;
6438 /* Shut off async mode */
6439 vam->async_mode = 0;
6441 M (CONTROL_PING, mp_ping);
6444 timeout = vat_time_now (vam) + 1.0;
6445 while (vat_time_now (vam) < timeout)
6446 if (vam->result_ready == 1)
6451 if (vam->retval == -99)
6454 if (vam->async_errors > 0)
6456 errmsg ("%d asynchronous errors", vam->async_errors);
6459 vam->async_errors = 0;
6460 after = vat_time_now (vam);
6462 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6466 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6467 count, after - before, count / (after - before));
6473 /* Wait for a reply... */
6478 /* Return the good/bad news */
6479 return (vam->retval);
6483 api_ip_mroute_add_del (vat_main_t * vam)
6485 unformat_input_t *i = vam->input;
6486 vl_api_ip_mroute_add_del_t *mp;
6487 u32 sw_if_index = ~0, vrf_id = 0;
6490 u8 create_vrf_if_needed = 0;
6493 u32 grp_address_length = 0;
6494 ip4_address_t v4_grp_address, v4_src_address;
6495 ip6_address_t v6_grp_address, v6_src_address;
6496 mfib_itf_flags_t iflags = 0;
6497 mfib_entry_flags_t eflags = 0;
6500 /* Parse args required to build the message */
6501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6503 if (unformat (i, "sw_if_index %d", &sw_if_index))
6505 else if (unformat (i, "%U %U",
6506 unformat_ip4_address, &v4_src_address,
6507 unformat_ip4_address, &v4_grp_address))
6509 grp_address_length = 64;
6513 else if (unformat (i, "%U %U",
6514 unformat_ip6_address, &v6_src_address,
6515 unformat_ip6_address, &v6_grp_address))
6517 grp_address_length = 256;
6521 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
6523 memset (&v4_src_address, 0, sizeof (v4_src_address));
6524 grp_address_length = 32;
6528 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
6530 memset (&v6_src_address, 0, sizeof (v6_src_address));
6531 grp_address_length = 128;
6535 else if (unformat (i, "/%d", &grp_address_length))
6537 else if (unformat (i, "local"))
6541 else if (unformat (i, "del"))
6543 else if (unformat (i, "add"))
6545 else if (unformat (i, "vrf %d", &vrf_id))
6547 else if (unformat (i, "create-vrf"))
6548 create_vrf_if_needed = 1;
6549 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
6551 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
6555 clib_warning ("parse error '%U'", format_unformat_error, i);
6560 if (address_set == 0)
6562 errmsg ("missing addresses\n");
6566 /* Construct the API message */
6567 M (IP_MROUTE_ADD_DEL, mp);
6569 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6570 mp->table_id = ntohl (vrf_id);
6571 mp->create_vrf_if_needed = create_vrf_if_needed;
6573 mp->is_add = is_add;
6574 mp->is_ipv6 = is_ipv6;
6575 mp->is_local = is_local;
6576 mp->itf_flags = ntohl (iflags);
6577 mp->entry_flags = ntohl (eflags);
6578 mp->grp_address_length = grp_address_length;
6579 mp->grp_address_length = ntohs (mp->grp_address_length);
6583 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
6584 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
6588 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
6589 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
6595 /* Wait for a reply... */
6601 api_mpls_route_add_del (vat_main_t * vam)
6603 unformat_input_t *i = vam->input;
6604 vl_api_mpls_route_add_del_t *mp;
6605 u32 sw_if_index = ~0, table_id = 0;
6606 u8 create_table_if_needed = 0;
6608 u32 next_hop_weight = 1;
6609 u8 is_multipath = 0;
6610 u32 next_hop_table_id = 0;
6611 u8 next_hop_set = 0;
6612 ip4_address_t v4_next_hop_address = {
6615 ip6_address_t v6_next_hop_address = { {0} };
6619 u32 classify_table_index = ~0;
6621 u8 resolve_host = 0, resolve_attached = 0;
6622 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6623 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6624 mpls_label_t *next_hop_out_label_stack = NULL;
6625 mpls_label_t local_label = MPLS_LABEL_INVALID;
6627 u8 next_hop_proto_is_ip4 = 1;
6629 /* Parse args required to build the message */
6630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6632 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6634 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6636 else if (unformat (i, "%d", &local_label))
6638 else if (unformat (i, "eos"))
6640 else if (unformat (i, "non-eos"))
6642 else if (unformat (i, "via %U", unformat_ip4_address,
6643 &v4_next_hop_address))
6646 next_hop_proto_is_ip4 = 1;
6648 else if (unformat (i, "via %U", unformat_ip6_address,
6649 &v6_next_hop_address))
6652 next_hop_proto_is_ip4 = 0;
6654 else if (unformat (i, "weight %d", &next_hop_weight))
6656 else if (unformat (i, "create-table"))
6657 create_table_if_needed = 1;
6658 else if (unformat (i, "classify %d", &classify_table_index))
6662 else if (unformat (i, "del"))
6664 else if (unformat (i, "add"))
6666 else if (unformat (i, "resolve-via-host"))
6668 else if (unformat (i, "resolve-via-attached"))
6669 resolve_attached = 1;
6670 else if (unformat (i, "multipath"))
6672 else if (unformat (i, "count %d", &count))
6674 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6677 next_hop_proto_is_ip4 = 1;
6679 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6682 next_hop_proto_is_ip4 = 0;
6684 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6686 else if (unformat (i, "via-label %d", &next_hop_via_label))
6688 else if (unformat (i, "out-label %d", &next_hop_out_label))
6689 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6692 clib_warning ("parse error '%U'", format_unformat_error, i);
6697 if (!next_hop_set && !is_classify)
6699 errmsg ("next hop / classify not set");
6703 if (MPLS_LABEL_INVALID == local_label)
6705 errmsg ("missing label");
6711 /* Turn on async mode */
6712 vam->async_mode = 1;
6713 vam->async_errors = 0;
6714 before = vat_time_now (vam);
6717 for (j = 0; j < count; j++)
6719 /* Construct the API message */
6720 M2 (MPLS_ROUTE_ADD_DEL, mp,
6721 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6723 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6724 mp->mr_table_id = ntohl (table_id);
6725 mp->mr_create_table_if_needed = create_table_if_needed;
6727 mp->mr_is_add = is_add;
6728 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6729 mp->mr_is_classify = is_classify;
6730 mp->mr_is_multipath = is_multipath;
6731 mp->mr_is_resolve_host = resolve_host;
6732 mp->mr_is_resolve_attached = resolve_attached;
6733 mp->mr_next_hop_weight = next_hop_weight;
6734 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6735 mp->mr_classify_table_index = ntohl (classify_table_index);
6736 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6737 mp->mr_label = ntohl (local_label);
6738 mp->mr_eos = is_eos;
6740 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6741 if (0 != mp->mr_next_hop_n_out_labels)
6743 memcpy (mp->mr_next_hop_out_label_stack,
6744 next_hop_out_label_stack,
6745 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6746 vec_free (next_hop_out_label_stack);
6751 if (next_hop_proto_is_ip4)
6753 clib_memcpy (mp->mr_next_hop,
6754 &v4_next_hop_address,
6755 sizeof (v4_next_hop_address));
6759 clib_memcpy (mp->mr_next_hop,
6760 &v6_next_hop_address,
6761 sizeof (v6_next_hop_address));
6768 /* If we receive SIGTERM, stop now... */
6773 /* When testing multiple add/del ops, use a control-ping to sync */
6776 vl_api_control_ping_t *mp_ping;
6780 /* Shut off async mode */
6781 vam->async_mode = 0;
6783 M (CONTROL_PING, mp_ping);
6786 timeout = vat_time_now (vam) + 1.0;
6787 while (vat_time_now (vam) < timeout)
6788 if (vam->result_ready == 1)
6793 if (vam->retval == -99)
6796 if (vam->async_errors > 0)
6798 errmsg ("%d asynchronous errors", vam->async_errors);
6801 vam->async_errors = 0;
6802 after = vat_time_now (vam);
6804 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6808 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6809 count, after - before, count / (after - before));
6815 /* Wait for a reply... */
6820 /* Return the good/bad news */
6821 return (vam->retval);
6825 api_mpls_ip_bind_unbind (vat_main_t * vam)
6827 unformat_input_t *i = vam->input;
6828 vl_api_mpls_ip_bind_unbind_t *mp;
6829 u32 ip_table_id = 0;
6830 u8 create_table_if_needed = 0;
6833 ip4_address_t v4_address;
6834 ip6_address_t v6_address;
6837 mpls_label_t local_label = MPLS_LABEL_INVALID;
6840 /* Parse args required to build the message */
6841 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6843 if (unformat (i, "%U/%d", unformat_ip4_address,
6844 &v4_address, &address_length))
6849 else if (unformat (i, "%U/%d", unformat_ip6_address,
6850 &v6_address, &address_length))
6855 else if (unformat (i, "%d", &local_label))
6857 else if (unformat (i, "create-table"))
6858 create_table_if_needed = 1;
6859 else if (unformat (i, "table-id %d", &ip_table_id))
6861 else if (unformat (i, "unbind"))
6863 else if (unformat (i, "bind"))
6867 clib_warning ("parse error '%U'", format_unformat_error, i);
6874 errmsg ("IP addres not set");
6878 if (MPLS_LABEL_INVALID == local_label)
6880 errmsg ("missing label");
6884 /* Construct the API message */
6885 M (MPLS_IP_BIND_UNBIND, mp);
6887 mp->mb_create_table_if_needed = create_table_if_needed;
6888 mp->mb_is_bind = is_bind;
6889 mp->mb_is_ip4 = is_ip4;
6890 mp->mb_ip_table_id = ntohl (ip_table_id);
6891 mp->mb_mpls_table_id = 0;
6892 mp->mb_label = ntohl (local_label);
6893 mp->mb_address_length = address_length;
6896 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
6898 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
6903 /* Wait for a reply... */
6909 api_proxy_arp_add_del (vat_main_t * vam)
6911 unformat_input_t *i = vam->input;
6912 vl_api_proxy_arp_add_del_t *mp;
6915 ip4_address_t lo, hi;
6919 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6921 if (unformat (i, "vrf %d", &vrf_id))
6923 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
6924 unformat_ip4_address, &hi))
6926 else if (unformat (i, "del"))
6930 clib_warning ("parse error '%U'", format_unformat_error, i);
6937 errmsg ("address range not set");
6941 M (PROXY_ARP_ADD_DEL, mp);
6943 mp->vrf_id = ntohl (vrf_id);
6944 mp->is_add = is_add;
6945 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
6946 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
6954 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
6956 unformat_input_t *i = vam->input;
6957 vl_api_proxy_arp_intfc_enable_disable_t *mp;
6960 u8 sw_if_index_set = 0;
6963 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6965 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6966 sw_if_index_set = 1;
6967 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6968 sw_if_index_set = 1;
6969 else if (unformat (i, "enable"))
6971 else if (unformat (i, "disable"))
6975 clib_warning ("parse error '%U'", format_unformat_error, i);
6980 if (sw_if_index_set == 0)
6982 errmsg ("missing interface name or sw_if_index");
6986 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
6988 mp->sw_if_index = ntohl (sw_if_index);
6989 mp->enable_disable = enable;
6997 api_mpls_tunnel_add_del (vat_main_t * vam)
6999 unformat_input_t *i = vam->input;
7000 vl_api_mpls_tunnel_add_del_t *mp;
7004 u32 sw_if_index = ~0;
7005 u32 next_hop_sw_if_index = ~0;
7006 u32 next_hop_proto_is_ip4 = 1;
7008 u32 next_hop_table_id = 0;
7009 ip4_address_t v4_next_hop_address = {
7012 ip6_address_t v6_next_hop_address = { {0} };
7013 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7016 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7018 if (unformat (i, "add"))
7020 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7022 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7024 else if (unformat (i, "via %U",
7025 unformat_ip4_address, &v4_next_hop_address))
7027 next_hop_proto_is_ip4 = 1;
7029 else if (unformat (i, "via %U",
7030 unformat_ip6_address, &v6_next_hop_address))
7032 next_hop_proto_is_ip4 = 0;
7034 else if (unformat (i, "l2-only"))
7036 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7038 else if (unformat (i, "out-label %d", &next_hop_out_label))
7039 vec_add1 (labels, ntohl (next_hop_out_label));
7042 clib_warning ("parse error '%U'", format_unformat_error, i);
7047 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7049 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7050 mp->mt_sw_if_index = ntohl (sw_if_index);
7051 mp->mt_is_add = is_add;
7052 mp->mt_l2_only = l2_only;
7053 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7054 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7056 mp->mt_next_hop_n_out_labels = vec_len (labels);
7058 if (0 != mp->mt_next_hop_n_out_labels)
7060 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7061 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7065 if (next_hop_proto_is_ip4)
7067 clib_memcpy (mp->mt_next_hop,
7068 &v4_next_hop_address, sizeof (v4_next_hop_address));
7072 clib_memcpy (mp->mt_next_hop,
7073 &v6_next_hop_address, sizeof (v6_next_hop_address));
7082 api_sw_interface_set_unnumbered (vat_main_t * vam)
7084 unformat_input_t *i = vam->input;
7085 vl_api_sw_interface_set_unnumbered_t *mp;
7087 u32 unnum_sw_index = ~0;
7089 u8 sw_if_index_set = 0;
7092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7094 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7095 sw_if_index_set = 1;
7096 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7097 sw_if_index_set = 1;
7098 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7100 else if (unformat (i, "del"))
7104 clib_warning ("parse error '%U'", format_unformat_error, i);
7109 if (sw_if_index_set == 0)
7111 errmsg ("missing interface name or sw_if_index");
7115 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7117 mp->sw_if_index = ntohl (sw_if_index);
7118 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7119 mp->is_add = is_add;
7127 api_ip_neighbor_add_del (vat_main_t * vam)
7129 unformat_input_t *i = vam->input;
7130 vl_api_ip_neighbor_add_del_t *mp;
7132 u8 sw_if_index_set = 0;
7137 u8 v4_address_set = 0;
7138 u8 v6_address_set = 0;
7139 ip4_address_t v4address;
7140 ip6_address_t v6address;
7143 memset (mac_address, 0, sizeof (mac_address));
7145 /* Parse args required to build the message */
7146 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7148 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7152 else if (unformat (i, "del"))
7155 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7156 sw_if_index_set = 1;
7157 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7158 sw_if_index_set = 1;
7159 else if (unformat (i, "is_static"))
7161 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7163 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7167 clib_warning ("parse error '%U'", format_unformat_error, i);
7172 if (sw_if_index_set == 0)
7174 errmsg ("missing interface name or sw_if_index");
7177 if (v4_address_set && v6_address_set)
7179 errmsg ("both v4 and v6 addresses set");
7182 if (!v4_address_set && !v6_address_set)
7184 errmsg ("no address set");
7188 /* Construct the API message */
7189 M (IP_NEIGHBOR_ADD_DEL, mp);
7191 mp->sw_if_index = ntohl (sw_if_index);
7192 mp->is_add = is_add;
7193 mp->is_static = is_static;
7195 clib_memcpy (mp->mac_address, mac_address, 6);
7199 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7203 /* mp->is_ipv6 = 0; via memset in M macro above */
7204 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7210 /* Wait for a reply, return good/bad news */
7216 api_reset_vrf (vat_main_t * vam)
7218 unformat_input_t *i = vam->input;
7219 vl_api_reset_vrf_t *mp;
7225 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7227 if (unformat (i, "vrf %d", &vrf_id))
7229 else if (unformat (i, "ipv6"))
7233 clib_warning ("parse error '%U'", format_unformat_error, i);
7238 if (vrf_id_set == 0)
7240 errmsg ("missing vrf id");
7246 mp->vrf_id = ntohl (vrf_id);
7247 mp->is_ipv6 = is_ipv6;
7255 api_create_vlan_subif (vat_main_t * vam)
7257 unformat_input_t *i = vam->input;
7258 vl_api_create_vlan_subif_t *mp;
7260 u8 sw_if_index_set = 0;
7265 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7267 if (unformat (i, "sw_if_index %d", &sw_if_index))
7268 sw_if_index_set = 1;
7270 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7271 sw_if_index_set = 1;
7272 else if (unformat (i, "vlan %d", &vlan_id))
7276 clib_warning ("parse error '%U'", format_unformat_error, i);
7281 if (sw_if_index_set == 0)
7283 errmsg ("missing interface name or sw_if_index");
7287 if (vlan_id_set == 0)
7289 errmsg ("missing vlan_id");
7292 M (CREATE_VLAN_SUBIF, mp);
7294 mp->sw_if_index = ntohl (sw_if_index);
7295 mp->vlan_id = ntohl (vlan_id);
7302 #define foreach_create_subif_bit \
7309 _(outer_vlan_id_any) \
7310 _(inner_vlan_id_any)
7313 api_create_subif (vat_main_t * vam)
7315 unformat_input_t *i = vam->input;
7316 vl_api_create_subif_t *mp;
7318 u8 sw_if_index_set = 0;
7325 u32 exact_match = 0;
7326 u32 default_sub = 0;
7327 u32 outer_vlan_id_any = 0;
7328 u32 inner_vlan_id_any = 0;
7330 u16 outer_vlan_id = 0;
7331 u16 inner_vlan_id = 0;
7334 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7336 if (unformat (i, "sw_if_index %d", &sw_if_index))
7337 sw_if_index_set = 1;
7339 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7340 sw_if_index_set = 1;
7341 else if (unformat (i, "sub_id %d", &sub_id))
7343 else if (unformat (i, "outer_vlan_id %d", &tmp))
7344 outer_vlan_id = tmp;
7345 else if (unformat (i, "inner_vlan_id %d", &tmp))
7346 inner_vlan_id = tmp;
7348 #define _(a) else if (unformat (i, #a)) a = 1 ;
7349 foreach_create_subif_bit
7353 clib_warning ("parse error '%U'", format_unformat_error, i);
7358 if (sw_if_index_set == 0)
7360 errmsg ("missing interface name or sw_if_index");
7364 if (sub_id_set == 0)
7366 errmsg ("missing sub_id");
7369 M (CREATE_SUBIF, mp);
7371 mp->sw_if_index = ntohl (sw_if_index);
7372 mp->sub_id = ntohl (sub_id);
7374 #define _(a) mp->a = a;
7375 foreach_create_subif_bit;
7378 mp->outer_vlan_id = ntohs (outer_vlan_id);
7379 mp->inner_vlan_id = ntohs (inner_vlan_id);
7387 api_oam_add_del (vat_main_t * vam)
7389 unformat_input_t *i = vam->input;
7390 vl_api_oam_add_del_t *mp;
7393 ip4_address_t src, dst;
7398 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7400 if (unformat (i, "vrf %d", &vrf_id))
7402 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7404 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7406 else if (unformat (i, "del"))
7410 clib_warning ("parse error '%U'", format_unformat_error, i);
7417 errmsg ("missing src addr");
7423 errmsg ("missing dst addr");
7427 M (OAM_ADD_DEL, mp);
7429 mp->vrf_id = ntohl (vrf_id);
7430 mp->is_add = is_add;
7431 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7432 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7440 api_reset_fib (vat_main_t * vam)
7442 unformat_input_t *i = vam->input;
7443 vl_api_reset_fib_t *mp;
7449 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7451 if (unformat (i, "vrf %d", &vrf_id))
7453 else if (unformat (i, "ipv6"))
7457 clib_warning ("parse error '%U'", format_unformat_error, i);
7462 if (vrf_id_set == 0)
7464 errmsg ("missing vrf id");
7470 mp->vrf_id = ntohl (vrf_id);
7471 mp->is_ipv6 = is_ipv6;
7479 api_dhcp_proxy_config (vat_main_t * vam)
7481 unformat_input_t *i = vam->input;
7482 vl_api_dhcp_proxy_config_t *mp;
7484 u32 server_vrf_id = 0;
7486 u8 v4_address_set = 0;
7487 u8 v6_address_set = 0;
7488 ip4_address_t v4address;
7489 ip6_address_t v6address;
7490 u8 v4_src_address_set = 0;
7491 u8 v6_src_address_set = 0;
7492 ip4_address_t v4srcaddress;
7493 ip6_address_t v6srcaddress;
7496 /* Parse args required to build the message */
7497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7499 if (unformat (i, "del"))
7501 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7503 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7505 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7507 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7509 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7510 v4_src_address_set = 1;
7511 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7512 v6_src_address_set = 1;
7517 if (v4_address_set && v6_address_set)
7519 errmsg ("both v4 and v6 server addresses set");
7522 if (!v4_address_set && !v6_address_set)
7524 errmsg ("no server addresses set");
7528 if (v4_src_address_set && v6_src_address_set)
7530 errmsg ("both v4 and v6 src addresses set");
7533 if (!v4_src_address_set && !v6_src_address_set)
7535 errmsg ("no src addresses set");
7539 if (!(v4_src_address_set && v4_address_set) &&
7540 !(v6_src_address_set && v6_address_set))
7542 errmsg ("no matching server and src addresses set");
7546 /* Construct the API message */
7547 M (DHCP_PROXY_CONFIG, mp);
7549 mp->is_add = is_add;
7550 mp->rx_vrf_id = ntohl (rx_vrf_id);
7551 mp->server_vrf_id = ntohl (server_vrf_id);
7555 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7556 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7560 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7561 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7567 /* Wait for a reply, return good/bad news */
7572 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
7573 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
7576 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
7578 vat_main_t *vam = &vat_main;
7579 u32 i, count = mp->count;
7580 vl_api_dhcp_server_t *s;
7584 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7585 ntohl (mp->rx_vrf_id),
7586 format_ip6_address, mp->dhcp_src_address,
7587 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7590 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7591 ntohl (mp->rx_vrf_id),
7592 format_ip4_address, mp->dhcp_src_address,
7593 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7595 for (i = 0; i < count; i++)
7597 s = &mp->servers[i];
7601 " Server Table-ID %d, Server Address %U",
7602 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
7605 " Server Table-ID %d, Server Address %U",
7606 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
7610 static void vl_api_dhcp_proxy_details_t_handler_json
7611 (vl_api_dhcp_proxy_details_t * mp)
7613 vat_main_t *vam = &vat_main;
7614 vat_json_node_t *node = NULL;
7615 u32 i, count = mp->count;
7617 struct in6_addr ip6;
7618 vl_api_dhcp_server_t *s;
7620 if (VAT_JSON_ARRAY != vam->json_tree.type)
7622 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7623 vat_json_init_array (&vam->json_tree);
7625 node = vat_json_array_add (&vam->json_tree);
7627 vat_json_init_object (node);
7628 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
7629 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
7630 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
7634 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
7635 vat_json_object_add_ip6 (node, "src_address", ip6);
7639 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
7640 vat_json_object_add_ip4 (node, "src_address", ip4);
7643 for (i = 0; i < count; i++)
7645 s = &mp->servers[i];
7647 vat_json_object_add_uint (node, "server-table-id",
7648 ntohl (s->server_vrf_id));
7652 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
7653 vat_json_object_add_ip4 (node, "src_address", ip4);
7657 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
7658 vat_json_object_add_ip6 (node, "server_address", ip6);
7664 api_dhcp_proxy_dump (vat_main_t * vam)
7666 unformat_input_t *i = vam->input;
7667 vl_api_control_ping_t *mp_ping;
7668 vl_api_dhcp_proxy_dump_t *mp;
7672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7674 if (unformat (i, "ipv6"))
7678 clib_warning ("parse error '%U'", format_unformat_error, i);
7683 M (DHCP_PROXY_DUMP, mp);
7685 mp->is_ip6 = is_ipv6;
7688 /* Use a control ping for synchronization */
7689 M (CONTROL_PING, mp_ping);
7697 api_dhcp_proxy_set_vss (vat_main_t * vam)
7699 unformat_input_t *i = vam->input;
7700 vl_api_dhcp_proxy_set_vss_t *mp;
7711 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7713 if (unformat (i, "tbl_id %d", &tbl_id))
7715 if (unformat (i, "fib_id %d", &fib_id))
7717 if (unformat (i, "oui %d", &oui))
7719 else if (unformat (i, "ipv6"))
7721 else if (unformat (i, "del"))
7725 clib_warning ("parse error '%U'", format_unformat_error, i);
7730 if (tbl_id_set == 0)
7732 errmsg ("missing tbl id");
7736 if (fib_id_set == 0)
7738 errmsg ("missing fib id");
7743 errmsg ("missing oui");
7747 M (DHCP_PROXY_SET_VSS, mp);
7748 mp->tbl_id = ntohl (tbl_id);
7749 mp->fib_id = ntohl (fib_id);
7750 mp->oui = ntohl (oui);
7751 mp->is_ipv6 = is_ipv6;
7752 mp->is_add = is_add;
7760 api_dhcp_client_config (vat_main_t * vam)
7762 unformat_input_t *i = vam->input;
7763 vl_api_dhcp_client_config_t *mp;
7765 u8 sw_if_index_set = 0;
7768 u8 disable_event = 0;
7771 /* Parse args required to build the message */
7772 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7774 if (unformat (i, "del"))
7777 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7778 sw_if_index_set = 1;
7779 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7780 sw_if_index_set = 1;
7781 else if (unformat (i, "hostname %s", &hostname))
7783 else if (unformat (i, "disable_event"))
7789 if (sw_if_index_set == 0)
7791 errmsg ("missing interface name or sw_if_index");
7795 if (vec_len (hostname) > 63)
7797 errmsg ("hostname too long");
7799 vec_add1 (hostname, 0);
7801 /* Construct the API message */
7802 M (DHCP_CLIENT_CONFIG, mp);
7804 mp->sw_if_index = ntohl (sw_if_index);
7805 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7806 vec_free (hostname);
7807 mp->is_add = is_add;
7808 mp->want_dhcp_event = disable_event ? 0 : 1;
7809 mp->pid = getpid ();
7814 /* Wait for a reply, return good/bad news */
7820 api_set_ip_flow_hash (vat_main_t * vam)
7822 unformat_input_t *i = vam->input;
7823 vl_api_set_ip_flow_hash_t *mp;
7835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7837 if (unformat (i, "vrf %d", &vrf_id))
7839 else if (unformat (i, "ipv6"))
7841 else if (unformat (i, "src"))
7843 else if (unformat (i, "dst"))
7845 else if (unformat (i, "sport"))
7847 else if (unformat (i, "dport"))
7849 else if (unformat (i, "proto"))
7851 else if (unformat (i, "reverse"))
7856 clib_warning ("parse error '%U'", format_unformat_error, i);
7861 if (vrf_id_set == 0)
7863 errmsg ("missing vrf id");
7867 M (SET_IP_FLOW_HASH, mp);
7873 mp->reverse = reverse;
7874 mp->vrf_id = ntohl (vrf_id);
7875 mp->is_ipv6 = is_ipv6;
7883 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7885 unformat_input_t *i = vam->input;
7886 vl_api_sw_interface_ip6_enable_disable_t *mp;
7888 u8 sw_if_index_set = 0;
7892 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7894 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7895 sw_if_index_set = 1;
7896 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7897 sw_if_index_set = 1;
7898 else if (unformat (i, "enable"))
7900 else if (unformat (i, "disable"))
7904 clib_warning ("parse error '%U'", format_unformat_error, i);
7909 if (sw_if_index_set == 0)
7911 errmsg ("missing interface name or sw_if_index");
7915 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
7917 mp->sw_if_index = ntohl (sw_if_index);
7918 mp->enable = enable;
7926 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7928 unformat_input_t *i = vam->input;
7929 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7931 u8 sw_if_index_set = 0;
7932 u8 v6_address_set = 0;
7933 ip6_address_t v6address;
7936 /* Parse args required to build the message */
7937 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7939 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7940 sw_if_index_set = 1;
7941 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7942 sw_if_index_set = 1;
7943 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
7949 if (sw_if_index_set == 0)
7951 errmsg ("missing interface name or sw_if_index");
7954 if (!v6_address_set)
7956 errmsg ("no address set");
7960 /* Construct the API message */
7961 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
7963 mp->sw_if_index = ntohl (sw_if_index);
7964 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7969 /* Wait for a reply, return good/bad news */
7975 api_ip6nd_proxy_add_del (vat_main_t * vam)
7977 unformat_input_t *i = vam->input;
7978 vl_api_ip6nd_proxy_add_del_t *mp;
7979 u32 sw_if_index = ~0;
7980 u8 v6_address_set = 0;
7981 ip6_address_t v6address;
7985 /* Parse args required to build the message */
7986 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7988 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7990 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7992 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
7994 if (unformat (i, "del"))
7998 clib_warning ("parse error '%U'", format_unformat_error, i);
8003 if (sw_if_index == ~0)
8005 errmsg ("missing interface name or sw_if_index");
8008 if (!v6_address_set)
8010 errmsg ("no address set");
8014 /* Construct the API message */
8015 M (IP6ND_PROXY_ADD_DEL, mp);
8017 mp->is_del = is_del;
8018 mp->sw_if_index = ntohl (sw_if_index);
8019 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8024 /* Wait for a reply, return good/bad news */
8030 api_ip6nd_proxy_dump (vat_main_t * vam)
8032 vl_api_ip6nd_proxy_dump_t *mp;
8033 vl_api_control_ping_t *mp_ping;
8036 M (IP6ND_PROXY_DUMP, mp);
8040 /* Use a control ping for synchronization */
8041 M (CONTROL_PING, mp_ping);
8048 static void vl_api_ip6nd_proxy_details_t_handler
8049 (vl_api_ip6nd_proxy_details_t * mp)
8051 vat_main_t *vam = &vat_main;
8053 print (vam->ofp, "host %U sw_if_index %d",
8054 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
8057 static void vl_api_ip6nd_proxy_details_t_handler_json
8058 (vl_api_ip6nd_proxy_details_t * mp)
8060 vat_main_t *vam = &vat_main;
8061 struct in6_addr ip6;
8062 vat_json_node_t *node = NULL;
8064 if (VAT_JSON_ARRAY != vam->json_tree.type)
8066 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8067 vat_json_init_array (&vam->json_tree);
8069 node = vat_json_array_add (&vam->json_tree);
8071 vat_json_init_object (node);
8072 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
8074 clib_memcpy (&ip6, mp->address, sizeof (ip6));
8075 vat_json_object_add_ip6 (node, "host", ip6);
8079 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8081 unformat_input_t *i = vam->input;
8082 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8084 u8 sw_if_index_set = 0;
8085 u32 address_length = 0;
8086 u8 v6_address_set = 0;
8087 ip6_address_t v6address;
8089 u8 no_advertise = 0;
8091 u8 no_autoconfig = 0;
8094 u32 val_lifetime = 0;
8095 u32 pref_lifetime = 0;
8098 /* Parse args required to build the message */
8099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
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, "sw_if_index %d", &sw_if_index))
8104 sw_if_index_set = 1;
8105 else if (unformat (i, "%U/%d",
8106 unformat_ip6_address, &v6address, &address_length))
8108 else if (unformat (i, "val_life %d", &val_lifetime))
8110 else if (unformat (i, "pref_life %d", &pref_lifetime))
8112 else if (unformat (i, "def"))
8114 else if (unformat (i, "noadv"))
8116 else if (unformat (i, "offl"))
8118 else if (unformat (i, "noauto"))
8120 else if (unformat (i, "nolink"))
8122 else if (unformat (i, "isno"))
8126 clib_warning ("parse error '%U'", format_unformat_error, i);
8131 if (sw_if_index_set == 0)
8133 errmsg ("missing interface name or sw_if_index");
8136 if (!v6_address_set)
8138 errmsg ("no address set");
8142 /* Construct the API message */
8143 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8145 mp->sw_if_index = ntohl (sw_if_index);
8146 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8147 mp->address_length = address_length;
8148 mp->use_default = use_default;
8149 mp->no_advertise = no_advertise;
8150 mp->off_link = off_link;
8151 mp->no_autoconfig = no_autoconfig;
8152 mp->no_onlink = no_onlink;
8154 mp->val_lifetime = ntohl (val_lifetime);
8155 mp->pref_lifetime = ntohl (pref_lifetime);
8160 /* Wait for a reply, return good/bad news */
8166 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8168 unformat_input_t *i = vam->input;
8169 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8171 u8 sw_if_index_set = 0;
8176 u8 send_unicast = 0;
8179 u8 default_router = 0;
8180 u32 max_interval = 0;
8181 u32 min_interval = 0;
8183 u32 initial_count = 0;
8184 u32 initial_interval = 0;
8188 /* Parse args required to build the message */
8189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8191 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8192 sw_if_index_set = 1;
8193 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8194 sw_if_index_set = 1;
8195 else if (unformat (i, "maxint %d", &max_interval))
8197 else if (unformat (i, "minint %d", &min_interval))
8199 else if (unformat (i, "life %d", &lifetime))
8201 else if (unformat (i, "count %d", &initial_count))
8203 else if (unformat (i, "interval %d", &initial_interval))
8205 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8207 else if (unformat (i, "managed"))
8209 else if (unformat (i, "other"))
8211 else if (unformat (i, "ll"))
8213 else if (unformat (i, "send"))
8215 else if (unformat (i, "cease"))
8217 else if (unformat (i, "isno"))
8219 else if (unformat (i, "def"))
8223 clib_warning ("parse error '%U'", format_unformat_error, i);
8228 if (sw_if_index_set == 0)
8230 errmsg ("missing interface name or sw_if_index");
8234 /* Construct the API message */
8235 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8237 mp->sw_if_index = ntohl (sw_if_index);
8238 mp->max_interval = ntohl (max_interval);
8239 mp->min_interval = ntohl (min_interval);
8240 mp->lifetime = ntohl (lifetime);
8241 mp->initial_count = ntohl (initial_count);
8242 mp->initial_interval = ntohl (initial_interval);
8243 mp->suppress = suppress;
8244 mp->managed = managed;
8246 mp->ll_option = ll_option;
8247 mp->send_unicast = send_unicast;
8250 mp->default_router = default_router;
8255 /* Wait for a reply, return good/bad news */
8261 api_set_arp_neighbor_limit (vat_main_t * vam)
8263 unformat_input_t *i = vam->input;
8264 vl_api_set_arp_neighbor_limit_t *mp;
8270 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8272 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8274 else if (unformat (i, "ipv6"))
8278 clib_warning ("parse error '%U'", format_unformat_error, i);
8285 errmsg ("missing limit value");
8289 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8291 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8292 mp->is_ipv6 = is_ipv6;
8300 api_l2_patch_add_del (vat_main_t * vam)
8302 unformat_input_t *i = vam->input;
8303 vl_api_l2_patch_add_del_t *mp;
8305 u8 rx_sw_if_index_set = 0;
8307 u8 tx_sw_if_index_set = 0;
8311 /* Parse args required to build the message */
8312 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8314 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8315 rx_sw_if_index_set = 1;
8316 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8317 tx_sw_if_index_set = 1;
8318 else if (unformat (i, "rx"))
8320 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8322 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8324 rx_sw_if_index_set = 1;
8329 else if (unformat (i, "tx"))
8331 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8333 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8335 tx_sw_if_index_set = 1;
8340 else if (unformat (i, "del"))
8346 if (rx_sw_if_index_set == 0)
8348 errmsg ("missing rx interface name or rx_sw_if_index");
8352 if (tx_sw_if_index_set == 0)
8354 errmsg ("missing tx interface name or tx_sw_if_index");
8358 M (L2_PATCH_ADD_DEL, mp);
8360 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8361 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8362 mp->is_add = is_add;
8370 u8 localsid_addr[16];
8379 api_sr_localsid_add_del (vat_main_t * vam)
8381 unformat_input_t *i = vam->input;
8382 vl_api_sr_localsid_add_del_t *mp;
8385 ip6_address_t localsid;
8389 u32 fib_table = ~(u32) 0;
8390 ip6_address_t next_hop;
8392 bool nexthop_set = 0;
8396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8398 if (unformat (i, "del"))
8400 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
8401 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
8403 else if (unformat (i, "behavior %u", &behavior));
8404 else if (unformat (i, "sw_if_index %u", &sw_if_index));
8405 else if (unformat (i, "fib-table %u", &fib_table));
8406 else if (unformat (i, "end.psp %u", &behavior));
8411 M (SR_LOCALSID_ADD_DEL, mp);
8413 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
8415 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
8416 mp->behavior = behavior;
8417 mp->sw_if_index = ntohl (sw_if_index);
8418 mp->fib_table = ntohl (fib_table);
8419 mp->end_psp = end_psp;
8420 mp->is_del = is_del;
8428 api_ioam_enable (vat_main_t * vam)
8430 unformat_input_t *input = vam->input;
8431 vl_api_ioam_enable_t *mp;
8433 int has_trace_option = 0;
8434 int has_pot_option = 0;
8435 int has_seqno_option = 0;
8436 int has_analyse_option = 0;
8439 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8441 if (unformat (input, "trace"))
8442 has_trace_option = 1;
8443 else if (unformat (input, "pot"))
8445 else if (unformat (input, "seqno"))
8446 has_seqno_option = 1;
8447 else if (unformat (input, "analyse"))
8448 has_analyse_option = 1;
8452 M (IOAM_ENABLE, mp);
8453 mp->id = htons (id);
8454 mp->seqno = has_seqno_option;
8455 mp->analyse = has_analyse_option;
8456 mp->pot_enable = has_pot_option;
8457 mp->trace_enable = has_trace_option;
8466 api_ioam_disable (vat_main_t * vam)
8468 vl_api_ioam_disable_t *mp;
8471 M (IOAM_DISABLE, mp);
8477 #define foreach_tcp_proto_field \
8481 #define foreach_udp_proto_field \
8485 #define foreach_ip4_proto_field \
8497 u16 src_port, dst_port;
8500 #if VPP_API_TEST_BUILTIN == 0
8502 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8504 u8 **maskp = va_arg (*args, u8 **);
8506 u8 found_something = 0;
8509 #define _(a) u8 a=0;
8510 foreach_tcp_proto_field;
8513 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8516 #define _(a) else if (unformat (input, #a)) a=1;
8517 foreach_tcp_proto_field
8523 #define _(a) found_something += a;
8524 foreach_tcp_proto_field;
8527 if (found_something == 0)
8530 vec_validate (mask, sizeof (*tcp) - 1);
8532 tcp = (tcp_header_t *) mask;
8534 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8535 foreach_tcp_proto_field;
8543 unformat_udp_mask (unformat_input_t * input, va_list * args)
8545 u8 **maskp = va_arg (*args, u8 **);
8547 u8 found_something = 0;
8550 #define _(a) u8 a=0;
8551 foreach_udp_proto_field;
8554 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8557 #define _(a) else if (unformat (input, #a)) a=1;
8558 foreach_udp_proto_field
8564 #define _(a) found_something += a;
8565 foreach_udp_proto_field;
8568 if (found_something == 0)
8571 vec_validate (mask, sizeof (*udp) - 1);
8573 udp = (udp_header_t *) mask;
8575 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8576 foreach_udp_proto_field;
8584 unformat_l4_mask (unformat_input_t * input, va_list * args)
8586 u8 **maskp = va_arg (*args, u8 **);
8587 u16 src_port = 0, dst_port = 0;
8588 tcpudp_header_t *tcpudp;
8590 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8592 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8594 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8596 else if (unformat (input, "src_port"))
8598 else if (unformat (input, "dst_port"))
8604 if (!src_port && !dst_port)
8608 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8610 tcpudp = (tcpudp_header_t *) mask;
8611 tcpudp->src_port = src_port;
8612 tcpudp->dst_port = dst_port;
8620 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8622 u8 **maskp = va_arg (*args, u8 **);
8624 u8 found_something = 0;
8627 #define _(a) u8 a=0;
8628 foreach_ip4_proto_field;
8634 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8636 if (unformat (input, "version"))
8638 else if (unformat (input, "hdr_length"))
8640 else if (unformat (input, "src"))
8642 else if (unformat (input, "dst"))
8644 else if (unformat (input, "proto"))
8647 #define _(a) else if (unformat (input, #a)) a=1;
8648 foreach_ip4_proto_field
8654 #define _(a) found_something += a;
8655 foreach_ip4_proto_field;
8658 if (found_something == 0)
8661 vec_validate (mask, sizeof (*ip) - 1);
8663 ip = (ip4_header_t *) mask;
8665 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8666 foreach_ip4_proto_field;
8669 ip->ip_version_and_header_length = 0;
8672 ip->ip_version_and_header_length |= 0xF0;
8675 ip->ip_version_and_header_length |= 0x0F;
8681 #define foreach_ip6_proto_field \
8689 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8691 u8 **maskp = va_arg (*args, u8 **);
8693 u8 found_something = 0;
8695 u32 ip_version_traffic_class_and_flow_label;
8697 #define _(a) u8 a=0;
8698 foreach_ip6_proto_field;
8701 u8 traffic_class = 0;
8704 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8706 if (unformat (input, "version"))
8708 else if (unformat (input, "traffic-class"))
8710 else if (unformat (input, "flow-label"))
8712 else if (unformat (input, "src"))
8714 else if (unformat (input, "dst"))
8716 else if (unformat (input, "proto"))
8719 #define _(a) else if (unformat (input, #a)) a=1;
8720 foreach_ip6_proto_field
8726 #define _(a) found_something += a;
8727 foreach_ip6_proto_field;
8730 if (found_something == 0)
8733 vec_validate (mask, sizeof (*ip) - 1);
8735 ip = (ip6_header_t *) mask;
8737 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8738 foreach_ip6_proto_field;
8741 ip_version_traffic_class_and_flow_label = 0;
8744 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8747 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8750 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8752 ip->ip_version_traffic_class_and_flow_label =
8753 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8760 unformat_l3_mask (unformat_input_t * input, va_list * args)
8762 u8 **maskp = va_arg (*args, u8 **);
8764 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8766 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8768 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8777 unformat_l2_mask (unformat_input_t * input, va_list * args)
8779 u8 **maskp = va_arg (*args, u8 **);
8794 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8796 if (unformat (input, "src"))
8798 else if (unformat (input, "dst"))
8800 else if (unformat (input, "proto"))
8802 else if (unformat (input, "tag1"))
8804 else if (unformat (input, "tag2"))
8806 else if (unformat (input, "ignore-tag1"))
8808 else if (unformat (input, "ignore-tag2"))
8810 else if (unformat (input, "cos1"))
8812 else if (unformat (input, "cos2"))
8814 else if (unformat (input, "dot1q"))
8816 else if (unformat (input, "dot1ad"))
8821 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8822 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8825 if (tag1 || ignore_tag1 || cos1 || dot1q)
8827 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8830 vec_validate (mask, len - 1);
8833 memset (mask, 0xff, 6);
8836 memset (mask + 6, 0xff, 6);
8840 /* inner vlan tag */
8849 mask[21] = mask[20] = 0xff;
8870 mask[16] = mask[17] = 0xff;
8880 mask[12] = mask[13] = 0xff;
8887 unformat_classify_mask (unformat_input_t * input, va_list * args)
8889 u8 **maskp = va_arg (*args, u8 **);
8890 u32 *skipp = va_arg (*args, u32 *);
8891 u32 *matchp = va_arg (*args, u32 *);
8899 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8901 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8903 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8905 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8907 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
8921 if (mask || l2 || l3 || l4)
8925 /* "With a free Ethernet header in every package" */
8927 vec_validate (l2, 13);
8931 vec_append (mask, l3);
8936 vec_append (mask, l4);
8941 /* Scan forward looking for the first significant mask octet */
8942 for (i = 0; i < vec_len (mask); i++)
8946 /* compute (skip, match) params */
8947 *skipp = i / sizeof (u32x4);
8948 vec_delete (mask, *skipp * sizeof (u32x4), 0);
8950 /* Pad mask to an even multiple of the vector size */
8951 while (vec_len (mask) % sizeof (u32x4))
8954 match = vec_len (mask) / sizeof (u32x4);
8956 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
8958 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
8959 if (*tmp || *(tmp + 1))
8964 clib_warning ("BUG: match 0");
8966 _vec_len (mask) = match * sizeof (u32x4);
8976 #endif /* VPP_API_TEST_BUILTIN */
8978 #define foreach_l2_next \
8980 _(ethernet, ETHERNET_INPUT) \
8985 unformat_l2_next_index (unformat_input_t * input, va_list * args)
8987 u32 *miss_next_indexp = va_arg (*args, u32 *);
8992 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
8996 if (unformat (input, "%d", &tmp))
9005 *miss_next_indexp = next_index;
9009 #define foreach_ip_next \
9015 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9017 u32 *miss_next_indexp = va_arg (*args, u32 *);
9022 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9026 if (unformat (input, "%d", &tmp))
9035 *miss_next_indexp = next_index;
9039 #define foreach_acl_next \
9043 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9045 u32 *miss_next_indexp = va_arg (*args, u32 *);
9050 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9054 if (unformat (input, "permit"))
9059 else if (unformat (input, "%d", &tmp))
9068 *miss_next_indexp = next_index;
9073 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9075 u32 *r = va_arg (*args, u32 *);
9077 if (unformat (input, "conform-color"))
9078 *r = POLICE_CONFORM;
9079 else if (unformat (input, "exceed-color"))
9088 api_classify_add_del_table (vat_main_t * vam)
9090 unformat_input_t *i = vam->input;
9091 vl_api_classify_add_del_table_t *mp;
9098 u32 table_index = ~0;
9099 u32 next_table_index = ~0;
9100 u32 miss_next_index = ~0;
9101 u32 memory_size = 32 << 20;
9103 u32 current_data_flag = 0;
9104 int current_data_offset = 0;
9107 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9109 if (unformat (i, "del"))
9111 else if (unformat (i, "del-chain"))
9116 else if (unformat (i, "buckets %d", &nbuckets))
9118 else if (unformat (i, "memory_size %d", &memory_size))
9120 else if (unformat (i, "skip %d", &skip))
9122 else if (unformat (i, "match %d", &match))
9124 else if (unformat (i, "table %d", &table_index))
9126 else if (unformat (i, "mask %U", unformat_classify_mask,
9127 &mask, &skip, &match))
9129 else if (unformat (i, "next-table %d", &next_table_index))
9131 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9134 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9137 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9140 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9142 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9148 if (is_add && mask == 0)
9150 errmsg ("Mask required");
9154 if (is_add && skip == ~0)
9156 errmsg ("skip count required");
9160 if (is_add && match == ~0)
9162 errmsg ("match count required");
9166 if (!is_add && table_index == ~0)
9168 errmsg ("table index required for delete");
9172 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9174 mp->is_add = is_add;
9175 mp->del_chain = del_chain;
9176 mp->table_index = ntohl (table_index);
9177 mp->nbuckets = ntohl (nbuckets);
9178 mp->memory_size = ntohl (memory_size);
9179 mp->skip_n_vectors = ntohl (skip);
9180 mp->match_n_vectors = ntohl (match);
9181 mp->next_table_index = ntohl (next_table_index);
9182 mp->miss_next_index = ntohl (miss_next_index);
9183 mp->current_data_flag = ntohl (current_data_flag);
9184 mp->current_data_offset = ntohl (current_data_offset);
9185 clib_memcpy (mp->mask, mask, vec_len (mask));
9194 #if VPP_API_TEST_BUILTIN == 0
9196 unformat_l4_match (unformat_input_t * input, va_list * args)
9198 u8 **matchp = va_arg (*args, u8 **);
9200 u8 *proto_header = 0;
9206 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9208 if (unformat (input, "src_port %d", &src_port))
9210 else if (unformat (input, "dst_port %d", &dst_port))
9216 h.src_port = clib_host_to_net_u16 (src_port);
9217 h.dst_port = clib_host_to_net_u16 (dst_port);
9218 vec_validate (proto_header, sizeof (h) - 1);
9219 memcpy (proto_header, &h, sizeof (h));
9221 *matchp = proto_header;
9227 unformat_ip4_match (unformat_input_t * input, va_list * args)
9229 u8 **matchp = va_arg (*args, u8 **);
9236 int src = 0, dst = 0;
9237 ip4_address_t src_val, dst_val;
9244 int fragment_id = 0;
9245 u32 fragment_id_val;
9251 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9253 if (unformat (input, "version %d", &version_val))
9255 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9257 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9259 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9261 else if (unformat (input, "proto %d", &proto_val))
9263 else if (unformat (input, "tos %d", &tos_val))
9265 else if (unformat (input, "length %d", &length_val))
9267 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9269 else if (unformat (input, "ttl %d", &ttl_val))
9271 else if (unformat (input, "checksum %d", &checksum_val))
9277 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9278 + ttl + checksum == 0)
9282 * Aligned because we use the real comparison functions
9284 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9286 ip = (ip4_header_t *) match;
9288 /* These are realistically matched in practice */
9290 ip->src_address.as_u32 = src_val.as_u32;
9293 ip->dst_address.as_u32 = dst_val.as_u32;
9296 ip->protocol = proto_val;
9299 /* These are not, but they're included for completeness */
9301 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9304 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9310 ip->length = clib_host_to_net_u16 (length_val);
9316 ip->checksum = clib_host_to_net_u16 (checksum_val);
9323 unformat_ip6_match (unformat_input_t * input, va_list * args)
9325 u8 **matchp = va_arg (*args, u8 **);
9330 u8 traffic_class = 0;
9331 u32 traffic_class_val = 0;
9334 int src = 0, dst = 0;
9335 ip6_address_t src_val, dst_val;
9338 int payload_length = 0;
9339 u32 payload_length_val;
9342 u32 ip_version_traffic_class_and_flow_label;
9344 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9346 if (unformat (input, "version %d", &version_val))
9348 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9350 else if (unformat (input, "flow_label %d", &flow_label_val))
9352 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9354 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9356 else if (unformat (input, "proto %d", &proto_val))
9358 else if (unformat (input, "payload_length %d", &payload_length_val))
9360 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9366 if (version + traffic_class + flow_label + src + dst + proto +
9367 payload_length + hop_limit == 0)
9371 * Aligned because we use the real comparison functions
9373 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9375 ip = (ip6_header_t *) match;
9378 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9381 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9384 ip->protocol = proto_val;
9386 ip_version_traffic_class_and_flow_label = 0;
9389 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9392 ip_version_traffic_class_and_flow_label |=
9393 (traffic_class_val & 0xFF) << 20;
9396 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9398 ip->ip_version_traffic_class_and_flow_label =
9399 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9402 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9405 ip->hop_limit = hop_limit_val;
9412 unformat_l3_match (unformat_input_t * input, va_list * args)
9414 u8 **matchp = va_arg (*args, u8 **);
9416 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9418 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9420 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9429 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9431 u8 *tagp = va_arg (*args, u8 *);
9434 if (unformat (input, "%d", &tag))
9436 tagp[0] = (tag >> 8) & 0x0F;
9437 tagp[1] = tag & 0xFF;
9445 unformat_l2_match (unformat_input_t * input, va_list * args)
9447 u8 **matchp = va_arg (*args, u8 **);
9467 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9469 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9472 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9474 else if (unformat (input, "proto %U",
9475 unformat_ethernet_type_host_byte_order, &proto_val))
9477 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9479 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9481 else if (unformat (input, "ignore-tag1"))
9483 else if (unformat (input, "ignore-tag2"))
9485 else if (unformat (input, "cos1 %d", &cos1_val))
9487 else if (unformat (input, "cos2 %d", &cos2_val))
9492 if ((src + dst + proto + tag1 + tag2 +
9493 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9496 if (tag1 || ignore_tag1 || cos1)
9498 if (tag2 || ignore_tag2 || cos2)
9501 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9504 clib_memcpy (match, dst_val, 6);
9507 clib_memcpy (match + 6, src_val, 6);
9511 /* inner vlan tag */
9512 match[19] = tag2_val[1];
9513 match[18] = tag2_val[0];
9515 match[18] |= (cos2_val & 0x7) << 5;
9518 match[21] = proto_val & 0xff;
9519 match[20] = proto_val >> 8;
9523 match[15] = tag1_val[1];
9524 match[14] = tag1_val[0];
9527 match[14] |= (cos1_val & 0x7) << 5;
9533 match[15] = tag1_val[1];
9534 match[14] = tag1_val[0];
9537 match[17] = proto_val & 0xff;
9538 match[16] = proto_val >> 8;
9541 match[14] |= (cos1_val & 0x7) << 5;
9547 match[18] |= (cos2_val & 0x7) << 5;
9549 match[14] |= (cos1_val & 0x7) << 5;
9552 match[13] = proto_val & 0xff;
9553 match[12] = proto_val >> 8;
9562 api_unformat_classify_match (unformat_input_t * input, va_list * args)
9564 u8 **matchp = va_arg (*args, u8 **);
9565 u32 skip_n_vectors = va_arg (*args, u32);
9566 u32 match_n_vectors = va_arg (*args, u32);
9573 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9575 if (unformat (input, "hex %U", unformat_hex_string, &match))
9577 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9579 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9581 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9595 if (match || l2 || l3 || l4)
9599 /* "Win a free Ethernet header in every packet" */
9601 vec_validate_aligned (l2, 13, sizeof (u32x4));
9605 vec_append_aligned (match, l3, sizeof (u32x4));
9610 vec_append_aligned (match, l4, sizeof (u32x4));
9615 /* Make sure the vector is big enough even if key is all 0's */
9616 vec_validate_aligned
9617 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9620 /* Set size, include skipped vectors */
9621 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9632 api_classify_add_del_session (vat_main_t * vam)
9634 unformat_input_t *i = vam->input;
9635 vl_api_classify_add_del_session_t *mp;
9637 u32 table_index = ~0;
9638 u32 hit_next_index = ~0;
9639 u32 opaque_index = ~0;
9642 u32 skip_n_vectors = 0;
9643 u32 match_n_vectors = 0;
9649 * Warning: you have to supply skip_n and match_n
9650 * because the API client cant simply look at the classify
9654 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9656 if (unformat (i, "del"))
9658 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
9661 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9664 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
9667 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9669 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9671 else if (unformat (i, "opaque-index %d", &opaque_index))
9673 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9675 else if (unformat (i, "match_n %d", &match_n_vectors))
9677 else if (unformat (i, "match %U", api_unformat_classify_match,
9678 &match, skip_n_vectors, match_n_vectors))
9680 else if (unformat (i, "advance %d", &advance))
9682 else if (unformat (i, "table-index %d", &table_index))
9684 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9686 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9688 else if (unformat (i, "action %d", &action))
9690 else if (unformat (i, "metadata %d", &metadata))
9696 if (table_index == ~0)
9698 errmsg ("Table index required");
9702 if (is_add && match == 0)
9704 errmsg ("Match value required");
9708 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
9710 mp->is_add = is_add;
9711 mp->table_index = ntohl (table_index);
9712 mp->hit_next_index = ntohl (hit_next_index);
9713 mp->opaque_index = ntohl (opaque_index);
9714 mp->advance = ntohl (advance);
9715 mp->action = action;
9716 mp->metadata = ntohl (metadata);
9717 clib_memcpy (mp->match, match, vec_len (match));
9726 api_classify_set_interface_ip_table (vat_main_t * vam)
9728 unformat_input_t *i = vam->input;
9729 vl_api_classify_set_interface_ip_table_t *mp;
9731 int sw_if_index_set;
9732 u32 table_index = ~0;
9736 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9738 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9739 sw_if_index_set = 1;
9740 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9741 sw_if_index_set = 1;
9742 else if (unformat (i, "table %d", &table_index))
9746 clib_warning ("parse error '%U'", format_unformat_error, i);
9751 if (sw_if_index_set == 0)
9753 errmsg ("missing interface name or sw_if_index");
9758 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
9760 mp->sw_if_index = ntohl (sw_if_index);
9761 mp->table_index = ntohl (table_index);
9762 mp->is_ipv6 = is_ipv6;
9770 api_classify_set_interface_l2_tables (vat_main_t * vam)
9772 unformat_input_t *i = vam->input;
9773 vl_api_classify_set_interface_l2_tables_t *mp;
9775 int sw_if_index_set;
9776 u32 ip4_table_index = ~0;
9777 u32 ip6_table_index = ~0;
9778 u32 other_table_index = ~0;
9782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9784 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9785 sw_if_index_set = 1;
9786 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9787 sw_if_index_set = 1;
9788 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9790 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9792 else if (unformat (i, "other-table %d", &other_table_index))
9794 else if (unformat (i, "is-input %d", &is_input))
9798 clib_warning ("parse error '%U'", format_unformat_error, i);
9803 if (sw_if_index_set == 0)
9805 errmsg ("missing interface name or sw_if_index");
9810 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
9812 mp->sw_if_index = ntohl (sw_if_index);
9813 mp->ip4_table_index = ntohl (ip4_table_index);
9814 mp->ip6_table_index = ntohl (ip6_table_index);
9815 mp->other_table_index = ntohl (other_table_index);
9816 mp->is_input = (u8) is_input;
9824 api_set_ipfix_exporter (vat_main_t * vam)
9826 unformat_input_t *i = vam->input;
9827 vl_api_set_ipfix_exporter_t *mp;
9828 ip4_address_t collector_address;
9829 u8 collector_address_set = 0;
9830 u32 collector_port = ~0;
9831 ip4_address_t src_address;
9832 u8 src_address_set = 0;
9835 u32 template_interval = ~0;
9836 u8 udp_checksum = 0;
9839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9841 if (unformat (i, "collector_address %U", unformat_ip4_address,
9842 &collector_address))
9843 collector_address_set = 1;
9844 else if (unformat (i, "collector_port %d", &collector_port))
9846 else if (unformat (i, "src_address %U", unformat_ip4_address,
9848 src_address_set = 1;
9849 else if (unformat (i, "vrf_id %d", &vrf_id))
9851 else if (unformat (i, "path_mtu %d", &path_mtu))
9853 else if (unformat (i, "template_interval %d", &template_interval))
9855 else if (unformat (i, "udp_checksum"))
9861 if (collector_address_set == 0)
9863 errmsg ("collector_address required");
9867 if (src_address_set == 0)
9869 errmsg ("src_address required");
9873 M (SET_IPFIX_EXPORTER, mp);
9875 memcpy (mp->collector_address, collector_address.data,
9876 sizeof (collector_address.data));
9877 mp->collector_port = htons ((u16) collector_port);
9878 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9879 mp->vrf_id = htonl (vrf_id);
9880 mp->path_mtu = htonl (path_mtu);
9881 mp->template_interval = htonl (template_interval);
9882 mp->udp_checksum = udp_checksum;
9890 api_set_ipfix_classify_stream (vat_main_t * vam)
9892 unformat_input_t *i = vam->input;
9893 vl_api_set_ipfix_classify_stream_t *mp;
9895 u32 src_port = UDP_DST_PORT_ipfix;
9898 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9900 if (unformat (i, "domain %d", &domain_id))
9902 else if (unformat (i, "src_port %d", &src_port))
9906 errmsg ("unknown input `%U'", format_unformat_error, i);
9911 M (SET_IPFIX_CLASSIFY_STREAM, mp);
9913 mp->domain_id = htonl (domain_id);
9914 mp->src_port = htons ((u16) src_port);
9922 api_ipfix_classify_table_add_del (vat_main_t * vam)
9924 unformat_input_t *i = vam->input;
9925 vl_api_ipfix_classify_table_add_del_t *mp;
9927 u32 classify_table_index = ~0;
9929 u8 transport_protocol = 255;
9932 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9934 if (unformat (i, "add"))
9936 else if (unformat (i, "del"))
9938 else if (unformat (i, "table %d", &classify_table_index))
9940 else if (unformat (i, "ip4"))
9942 else if (unformat (i, "ip6"))
9944 else if (unformat (i, "tcp"))
9945 transport_protocol = 6;
9946 else if (unformat (i, "udp"))
9947 transport_protocol = 17;
9950 errmsg ("unknown input `%U'", format_unformat_error, i);
9957 errmsg ("expecting: add|del");
9960 if (classify_table_index == ~0)
9962 errmsg ("classifier table not specified");
9965 if (ip_version == 0)
9967 errmsg ("IP version not specified");
9971 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
9973 mp->is_add = is_add;
9974 mp->table_id = htonl (classify_table_index);
9975 mp->ip_version = ip_version;
9976 mp->transport_protocol = transport_protocol;
9984 api_get_node_index (vat_main_t * vam)
9986 unformat_input_t *i = vam->input;
9987 vl_api_get_node_index_t *mp;
9991 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9993 if (unformat (i, "node %s", &name))
10000 errmsg ("node name required");
10003 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10005 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10009 M (GET_NODE_INDEX, mp);
10010 clib_memcpy (mp->node_name, name, vec_len (name));
10019 api_get_next_index (vat_main_t * vam)
10021 unformat_input_t *i = vam->input;
10022 vl_api_get_next_index_t *mp;
10023 u8 *node_name = 0, *next_node_name = 0;
10026 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10028 if (unformat (i, "node-name %s", &node_name))
10030 else if (unformat (i, "next-node-name %s", &next_node_name))
10034 if (node_name == 0)
10036 errmsg ("node name required");
10039 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10041 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10045 if (next_node_name == 0)
10047 errmsg ("next node name required");
10050 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10052 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10056 M (GET_NEXT_INDEX, mp);
10057 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10058 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10059 vec_free (node_name);
10060 vec_free (next_node_name);
10068 api_add_node_next (vat_main_t * vam)
10070 unformat_input_t *i = vam->input;
10071 vl_api_add_node_next_t *mp;
10076 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10078 if (unformat (i, "node %s", &name))
10080 else if (unformat (i, "next %s", &next))
10087 errmsg ("node name required");
10090 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10092 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10097 errmsg ("next node required");
10100 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10102 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10106 M (ADD_NODE_NEXT, mp);
10107 clib_memcpy (mp->node_name, name, vec_len (name));
10108 clib_memcpy (mp->next_name, next, vec_len (next));
10118 api_l2tpv3_create_tunnel (vat_main_t * vam)
10120 unformat_input_t *i = vam->input;
10121 ip6_address_t client_address, our_address;
10122 int client_address_set = 0;
10123 int our_address_set = 0;
10124 u32 local_session_id = 0;
10125 u32 remote_session_id = 0;
10126 u64 local_cookie = 0;
10127 u64 remote_cookie = 0;
10128 u8 l2_sublayer_present = 0;
10129 vl_api_l2tpv3_create_tunnel_t *mp;
10132 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10134 if (unformat (i, "client_address %U", unformat_ip6_address,
10136 client_address_set = 1;
10137 else if (unformat (i, "our_address %U", unformat_ip6_address,
10139 our_address_set = 1;
10140 else if (unformat (i, "local_session_id %d", &local_session_id))
10142 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10144 else if (unformat (i, "local_cookie %lld", &local_cookie))
10146 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10148 else if (unformat (i, "l2-sublayer-present"))
10149 l2_sublayer_present = 1;
10154 if (client_address_set == 0)
10156 errmsg ("client_address required");
10160 if (our_address_set == 0)
10162 errmsg ("our_address required");
10166 M (L2TPV3_CREATE_TUNNEL, mp);
10168 clib_memcpy (mp->client_address, client_address.as_u8,
10169 sizeof (mp->client_address));
10171 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10173 mp->local_session_id = ntohl (local_session_id);
10174 mp->remote_session_id = ntohl (remote_session_id);
10175 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10176 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10177 mp->l2_sublayer_present = l2_sublayer_present;
10186 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10188 unformat_input_t *i = vam->input;
10190 u8 sw_if_index_set = 0;
10191 u64 new_local_cookie = 0;
10192 u64 new_remote_cookie = 0;
10193 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10196 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10198 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10199 sw_if_index_set = 1;
10200 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10201 sw_if_index_set = 1;
10202 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10204 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10210 if (sw_if_index_set == 0)
10212 errmsg ("missing interface name or sw_if_index");
10216 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10218 mp->sw_if_index = ntohl (sw_if_index);
10219 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10220 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10228 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10230 unformat_input_t *i = vam->input;
10231 vl_api_l2tpv3_interface_enable_disable_t *mp;
10233 u8 sw_if_index_set = 0;
10234 u8 enable_disable = 1;
10237 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10239 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10240 sw_if_index_set = 1;
10241 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10242 sw_if_index_set = 1;
10243 else if (unformat (i, "enable"))
10244 enable_disable = 1;
10245 else if (unformat (i, "disable"))
10246 enable_disable = 0;
10251 if (sw_if_index_set == 0)
10253 errmsg ("missing interface name or sw_if_index");
10257 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10259 mp->sw_if_index = ntohl (sw_if_index);
10260 mp->enable_disable = enable_disable;
10268 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10270 unformat_input_t *i = vam->input;
10271 vl_api_l2tpv3_set_lookup_key_t *mp;
10275 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10277 if (unformat (i, "lookup_v6_src"))
10278 key = L2T_LOOKUP_SRC_ADDRESS;
10279 else if (unformat (i, "lookup_v6_dst"))
10280 key = L2T_LOOKUP_DST_ADDRESS;
10281 else if (unformat (i, "lookup_session_id"))
10282 key = L2T_LOOKUP_SESSION_ID;
10287 if (key == (u8) ~ 0)
10289 errmsg ("l2tp session lookup key unset");
10293 M (L2TPV3_SET_LOOKUP_KEY, mp);
10302 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10303 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10305 vat_main_t *vam = &vat_main;
10307 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10308 format_ip6_address, mp->our_address,
10309 format_ip6_address, mp->client_address,
10310 clib_net_to_host_u32 (mp->sw_if_index));
10313 " local cookies %016llx %016llx remote cookie %016llx",
10314 clib_net_to_host_u64 (mp->local_cookie[0]),
10315 clib_net_to_host_u64 (mp->local_cookie[1]),
10316 clib_net_to_host_u64 (mp->remote_cookie));
10318 print (vam->ofp, " local session-id %d remote session-id %d",
10319 clib_net_to_host_u32 (mp->local_session_id),
10320 clib_net_to_host_u32 (mp->remote_session_id));
10322 print (vam->ofp, " l2 specific sublayer %s\n",
10323 mp->l2_sublayer_present ? "preset" : "absent");
10327 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10328 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10330 vat_main_t *vam = &vat_main;
10331 vat_json_node_t *node = NULL;
10332 struct in6_addr addr;
10334 if (VAT_JSON_ARRAY != vam->json_tree.type)
10336 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10337 vat_json_init_array (&vam->json_tree);
10339 node = vat_json_array_add (&vam->json_tree);
10341 vat_json_init_object (node);
10343 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10344 vat_json_object_add_ip6 (node, "our_address", addr);
10345 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10346 vat_json_object_add_ip6 (node, "client_address", addr);
10348 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10349 vat_json_init_array (lc);
10350 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10351 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10352 vat_json_object_add_uint (node, "remote_cookie",
10353 clib_net_to_host_u64 (mp->remote_cookie));
10355 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10356 vat_json_object_add_uint (node, "local_session_id",
10357 clib_net_to_host_u32 (mp->local_session_id));
10358 vat_json_object_add_uint (node, "remote_session_id",
10359 clib_net_to_host_u32 (mp->remote_session_id));
10360 vat_json_object_add_string_copy (node, "l2_sublayer",
10361 mp->l2_sublayer_present ? (u8 *) "present"
10362 : (u8 *) "absent");
10366 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10368 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10369 vl_api_control_ping_t *mp_ping;
10372 /* Get list of l2tpv3-tunnel interfaces */
10373 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10376 /* Use a control ping for synchronization */
10377 M (CONTROL_PING, mp_ping);
10385 static void vl_api_sw_interface_tap_details_t_handler
10386 (vl_api_sw_interface_tap_details_t * mp)
10388 vat_main_t *vam = &vat_main;
10390 print (vam->ofp, "%-16s %d",
10391 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10394 static void vl_api_sw_interface_tap_details_t_handler_json
10395 (vl_api_sw_interface_tap_details_t * mp)
10397 vat_main_t *vam = &vat_main;
10398 vat_json_node_t *node = NULL;
10400 if (VAT_JSON_ARRAY != vam->json_tree.type)
10402 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10403 vat_json_init_array (&vam->json_tree);
10405 node = vat_json_array_add (&vam->json_tree);
10407 vat_json_init_object (node);
10408 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10409 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10413 api_sw_interface_tap_dump (vat_main_t * vam)
10415 vl_api_sw_interface_tap_dump_t *mp;
10416 vl_api_control_ping_t *mp_ping;
10419 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10420 /* Get list of tap interfaces */
10421 M (SW_INTERFACE_TAP_DUMP, mp);
10424 /* Use a control ping for synchronization */
10425 M (CONTROL_PING, mp_ping);
10432 static uword unformat_vxlan_decap_next
10433 (unformat_input_t * input, va_list * args)
10435 u32 *result = va_arg (*args, u32 *);
10438 if (unformat (input, "l2"))
10439 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10440 else if (unformat (input, "%d", &tmp))
10448 api_vxlan_add_del_tunnel (vat_main_t * vam)
10450 unformat_input_t *line_input = vam->input;
10451 vl_api_vxlan_add_del_tunnel_t *mp;
10452 ip46_address_t src, dst;
10454 u8 ipv4_set = 0, ipv6_set = 0;
10458 u32 mcast_sw_if_index = ~0;
10459 u32 encap_vrf_id = 0;
10460 u32 decap_next_index = ~0;
10464 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10465 memset (&src, 0, sizeof src);
10466 memset (&dst, 0, sizeof dst);
10468 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10470 if (unformat (line_input, "del"))
10473 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10479 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10485 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10491 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10496 else if (unformat (line_input, "group %U %U",
10497 unformat_ip4_address, &dst.ip4,
10498 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10500 grp_set = dst_set = 1;
10503 else if (unformat (line_input, "group %U",
10504 unformat_ip4_address, &dst.ip4))
10506 grp_set = dst_set = 1;
10509 else if (unformat (line_input, "group %U %U",
10510 unformat_ip6_address, &dst.ip6,
10511 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10513 grp_set = dst_set = 1;
10516 else if (unformat (line_input, "group %U",
10517 unformat_ip6_address, &dst.ip6))
10519 grp_set = dst_set = 1;
10523 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10525 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10527 else if (unformat (line_input, "decap-next %U",
10528 unformat_vxlan_decap_next, &decap_next_index))
10530 else if (unformat (line_input, "vni %d", &vni))
10534 errmsg ("parse error '%U'", format_unformat_error, line_input);
10541 errmsg ("tunnel src address not specified");
10546 errmsg ("tunnel dst address not specified");
10550 if (grp_set && !ip46_address_is_multicast (&dst))
10552 errmsg ("tunnel group address not multicast");
10555 if (grp_set && mcast_sw_if_index == ~0)
10557 errmsg ("tunnel nonexistent multicast device");
10560 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10562 errmsg ("tunnel dst address must be unicast");
10567 if (ipv4_set && ipv6_set)
10569 errmsg ("both IPv4 and IPv6 addresses specified");
10573 if ((vni == 0) || (vni >> 24))
10575 errmsg ("vni not specified or out of range");
10579 M (VXLAN_ADD_DEL_TUNNEL, mp);
10583 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10584 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10588 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10589 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10591 mp->encap_vrf_id = ntohl (encap_vrf_id);
10592 mp->decap_next_index = ntohl (decap_next_index);
10593 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10594 mp->vni = ntohl (vni);
10595 mp->is_add = is_add;
10596 mp->is_ipv6 = ipv6_set;
10603 static void vl_api_vxlan_tunnel_details_t_handler
10604 (vl_api_vxlan_tunnel_details_t * mp)
10606 vat_main_t *vam = &vat_main;
10607 ip46_address_t src, dst;
10609 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10610 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10612 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10613 ntohl (mp->sw_if_index),
10614 format_ip46_address, &src, IP46_TYPE_ANY,
10615 format_ip46_address, &dst, IP46_TYPE_ANY,
10616 ntohl (mp->encap_vrf_id),
10617 ntohl (mp->decap_next_index), ntohl (mp->vni),
10618 ntohl (mp->mcast_sw_if_index));
10621 static void vl_api_vxlan_tunnel_details_t_handler_json
10622 (vl_api_vxlan_tunnel_details_t * mp)
10624 vat_main_t *vam = &vat_main;
10625 vat_json_node_t *node = NULL;
10627 if (VAT_JSON_ARRAY != vam->json_tree.type)
10629 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10630 vat_json_init_array (&vam->json_tree);
10632 node = vat_json_array_add (&vam->json_tree);
10634 vat_json_init_object (node);
10635 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10638 struct in6_addr ip6;
10640 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10641 vat_json_object_add_ip6 (node, "src_address", ip6);
10642 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10643 vat_json_object_add_ip6 (node, "dst_address", ip6);
10647 struct in_addr ip4;
10649 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10650 vat_json_object_add_ip4 (node, "src_address", ip4);
10651 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10652 vat_json_object_add_ip4 (node, "dst_address", ip4);
10654 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10655 vat_json_object_add_uint (node, "decap_next_index",
10656 ntohl (mp->decap_next_index));
10657 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10658 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10659 vat_json_object_add_uint (node, "mcast_sw_if_index",
10660 ntohl (mp->mcast_sw_if_index));
10664 api_vxlan_tunnel_dump (vat_main_t * vam)
10666 unformat_input_t *i = vam->input;
10667 vl_api_vxlan_tunnel_dump_t *mp;
10668 vl_api_control_ping_t *mp_ping;
10670 u8 sw_if_index_set = 0;
10673 /* Parse args required to build the message */
10674 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10676 if (unformat (i, "sw_if_index %d", &sw_if_index))
10677 sw_if_index_set = 1;
10682 if (sw_if_index_set == 0)
10687 if (!vam->json_output)
10689 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10690 "sw_if_index", "src_address", "dst_address",
10691 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10694 /* Get list of vxlan-tunnel interfaces */
10695 M (VXLAN_TUNNEL_DUMP, mp);
10697 mp->sw_if_index = htonl (sw_if_index);
10701 /* Use a control ping for synchronization */
10702 M (CONTROL_PING, mp_ping);
10710 api_gre_add_del_tunnel (vat_main_t * vam)
10712 unformat_input_t *line_input = vam->input;
10713 vl_api_gre_add_del_tunnel_t *mp;
10714 ip4_address_t src4, dst4;
10719 u32 outer_fib_id = 0;
10722 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10724 if (unformat (line_input, "del"))
10726 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10728 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10730 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10732 else if (unformat (line_input, "teb"))
10736 errmsg ("parse error '%U'", format_unformat_error, line_input);
10743 errmsg ("tunnel src address not specified");
10748 errmsg ("tunnel dst address not specified");
10753 M (GRE_ADD_DEL_TUNNEL, mp);
10755 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10756 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10757 mp->outer_fib_id = ntohl (outer_fib_id);
10758 mp->is_add = is_add;
10766 static void vl_api_gre_tunnel_details_t_handler
10767 (vl_api_gre_tunnel_details_t * mp)
10769 vat_main_t *vam = &vat_main;
10771 print (vam->ofp, "%11d%15U%15U%6d%14d",
10772 ntohl (mp->sw_if_index),
10773 format_ip4_address, &mp->src_address,
10774 format_ip4_address, &mp->dst_address,
10775 mp->teb, ntohl (mp->outer_fib_id));
10778 static void vl_api_gre_tunnel_details_t_handler_json
10779 (vl_api_gre_tunnel_details_t * mp)
10781 vat_main_t *vam = &vat_main;
10782 vat_json_node_t *node = NULL;
10783 struct in_addr ip4;
10785 if (VAT_JSON_ARRAY != vam->json_tree.type)
10787 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10788 vat_json_init_array (&vam->json_tree);
10790 node = vat_json_array_add (&vam->json_tree);
10792 vat_json_init_object (node);
10793 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10794 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10795 vat_json_object_add_ip4 (node, "src_address", ip4);
10796 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10797 vat_json_object_add_ip4 (node, "dst_address", ip4);
10798 vat_json_object_add_uint (node, "teb", mp->teb);
10799 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10803 api_gre_tunnel_dump (vat_main_t * vam)
10805 unformat_input_t *i = vam->input;
10806 vl_api_gre_tunnel_dump_t *mp;
10807 vl_api_control_ping_t *mp_ping;
10809 u8 sw_if_index_set = 0;
10812 /* Parse args required to build the message */
10813 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10815 if (unformat (i, "sw_if_index %d", &sw_if_index))
10816 sw_if_index_set = 1;
10821 if (sw_if_index_set == 0)
10826 if (!vam->json_output)
10828 print (vam->ofp, "%11s%15s%15s%6s%14s",
10829 "sw_if_index", "src_address", "dst_address", "teb",
10833 /* Get list of gre-tunnel interfaces */
10834 M (GRE_TUNNEL_DUMP, mp);
10836 mp->sw_if_index = htonl (sw_if_index);
10840 /* Use a control ping for synchronization */
10841 M (CONTROL_PING, mp_ping);
10849 api_l2_fib_clear_table (vat_main_t * vam)
10851 // unformat_input_t * i = vam->input;
10852 vl_api_l2_fib_clear_table_t *mp;
10855 M (L2_FIB_CLEAR_TABLE, mp);
10863 api_l2_interface_efp_filter (vat_main_t * vam)
10865 unformat_input_t *i = vam->input;
10866 vl_api_l2_interface_efp_filter_t *mp;
10869 u8 sw_if_index_set = 0;
10872 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10874 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10875 sw_if_index_set = 1;
10876 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10877 sw_if_index_set = 1;
10878 else if (unformat (i, "enable"))
10880 else if (unformat (i, "disable"))
10884 clib_warning ("parse error '%U'", format_unformat_error, i);
10889 if (sw_if_index_set == 0)
10891 errmsg ("missing sw_if_index");
10895 M (L2_INTERFACE_EFP_FILTER, mp);
10897 mp->sw_if_index = ntohl (sw_if_index);
10898 mp->enable_disable = enable;
10905 #define foreach_vtr_op \
10906 _("disable", L2_VTR_DISABLED) \
10907 _("push-1", L2_VTR_PUSH_1) \
10908 _("push-2", L2_VTR_PUSH_2) \
10909 _("pop-1", L2_VTR_POP_1) \
10910 _("pop-2", L2_VTR_POP_2) \
10911 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10912 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10913 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10914 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10917 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10919 unformat_input_t *i = vam->input;
10920 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10922 u8 sw_if_index_set = 0;
10925 u32 push_dot1q = 1;
10930 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10932 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10933 sw_if_index_set = 1;
10934 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10935 sw_if_index_set = 1;
10936 else if (unformat (i, "vtr_op %d", &vtr_op))
10938 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
10941 else if (unformat (i, "push_dot1q %d", &push_dot1q))
10943 else if (unformat (i, "tag1 %d", &tag1))
10945 else if (unformat (i, "tag2 %d", &tag2))
10949 clib_warning ("parse error '%U'", format_unformat_error, i);
10954 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
10956 errmsg ("missing vtr operation or sw_if_index");
10960 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
10961 mp->sw_if_index = ntohl (sw_if_index);
10962 mp->vtr_op = ntohl (vtr_op);
10963 mp->push_dot1q = ntohl (push_dot1q);
10964 mp->tag1 = ntohl (tag1);
10965 mp->tag2 = ntohl (tag2);
10973 api_create_vhost_user_if (vat_main_t * vam)
10975 unformat_input_t *i = vam->input;
10976 vl_api_create_vhost_user_if_t *mp;
10979 u8 file_name_set = 0;
10980 u32 custom_dev_instance = ~0;
10982 u8 use_custom_mac = 0;
10986 /* Shut up coverity */
10987 memset (hwaddr, 0, sizeof (hwaddr));
10989 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10991 if (unformat (i, "socket %s", &file_name))
10995 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10997 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
10998 use_custom_mac = 1;
10999 else if (unformat (i, "server"))
11001 else if (unformat (i, "tag %s", &tag))
11007 if (file_name_set == 0)
11009 errmsg ("missing socket file name");
11013 if (vec_len (file_name) > 255)
11015 errmsg ("socket file name too long");
11018 vec_add1 (file_name, 0);
11020 M (CREATE_VHOST_USER_IF, mp);
11022 mp->is_server = is_server;
11023 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11024 vec_free (file_name);
11025 if (custom_dev_instance != ~0)
11028 mp->custom_dev_instance = ntohl (custom_dev_instance);
11030 mp->use_custom_mac = use_custom_mac;
11031 clib_memcpy (mp->mac_address, hwaddr, 6);
11033 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11042 api_modify_vhost_user_if (vat_main_t * vam)
11044 unformat_input_t *i = vam->input;
11045 vl_api_modify_vhost_user_if_t *mp;
11048 u8 file_name_set = 0;
11049 u32 custom_dev_instance = ~0;
11050 u8 sw_if_index_set = 0;
11051 u32 sw_if_index = (u32) ~ 0;
11054 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11056 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11057 sw_if_index_set = 1;
11058 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11059 sw_if_index_set = 1;
11060 else if (unformat (i, "socket %s", &file_name))
11064 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11066 else if (unformat (i, "server"))
11072 if (sw_if_index_set == 0)
11074 errmsg ("missing sw_if_index or interface name");
11078 if (file_name_set == 0)
11080 errmsg ("missing socket file name");
11084 if (vec_len (file_name) > 255)
11086 errmsg ("socket file name too long");
11089 vec_add1 (file_name, 0);
11091 M (MODIFY_VHOST_USER_IF, mp);
11093 mp->sw_if_index = ntohl (sw_if_index);
11094 mp->is_server = is_server;
11095 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11096 vec_free (file_name);
11097 if (custom_dev_instance != ~0)
11100 mp->custom_dev_instance = ntohl (custom_dev_instance);
11109 api_delete_vhost_user_if (vat_main_t * vam)
11111 unformat_input_t *i = vam->input;
11112 vl_api_delete_vhost_user_if_t *mp;
11113 u32 sw_if_index = ~0;
11114 u8 sw_if_index_set = 0;
11117 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11119 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11120 sw_if_index_set = 1;
11121 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11122 sw_if_index_set = 1;
11127 if (sw_if_index_set == 0)
11129 errmsg ("missing sw_if_index or interface name");
11134 M (DELETE_VHOST_USER_IF, mp);
11136 mp->sw_if_index = ntohl (sw_if_index);
11143 static void vl_api_sw_interface_vhost_user_details_t_handler
11144 (vl_api_sw_interface_vhost_user_details_t * mp)
11146 vat_main_t *vam = &vat_main;
11148 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11149 (char *) mp->interface_name,
11150 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11151 clib_net_to_host_u64 (mp->features), mp->is_server,
11152 ntohl (mp->num_regions), (char *) mp->sock_filename);
11153 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11156 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11157 (vl_api_sw_interface_vhost_user_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, "interface_name",
11172 mp->interface_name);
11173 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11174 ntohl (mp->virtio_net_hdr_sz));
11175 vat_json_object_add_uint (node, "features",
11176 clib_net_to_host_u64 (mp->features));
11177 vat_json_object_add_uint (node, "is_server", mp->is_server);
11178 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11179 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11180 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11184 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11186 vl_api_sw_interface_vhost_user_dump_t *mp;
11187 vl_api_control_ping_t *mp_ping;
11190 "Interface name idx hdr_sz features server regions filename");
11192 /* Get list of vhost-user interfaces */
11193 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11196 /* Use a control ping for synchronization */
11197 M (CONTROL_PING, mp_ping);
11205 api_show_version (vat_main_t * vam)
11207 vl_api_show_version_t *mp;
11210 M (SHOW_VERSION, mp);
11219 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11221 unformat_input_t *line_input = vam->input;
11222 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11223 ip4_address_t local4, remote4;
11224 ip6_address_t local6, remote6;
11226 u8 ipv4_set = 0, ipv6_set = 0;
11229 u32 encap_vrf_id = 0;
11230 u32 decap_vrf_id = 0;
11236 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11238 if (unformat (line_input, "del"))
11240 else if (unformat (line_input, "local %U",
11241 unformat_ip4_address, &local4))
11246 else if (unformat (line_input, "remote %U",
11247 unformat_ip4_address, &remote4))
11252 else if (unformat (line_input, "local %U",
11253 unformat_ip6_address, &local6))
11258 else if (unformat (line_input, "remote %U",
11259 unformat_ip6_address, &remote6))
11264 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11266 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11268 else if (unformat (line_input, "vni %d", &vni))
11270 else if (unformat (line_input, "next-ip4"))
11272 else if (unformat (line_input, "next-ip6"))
11274 else if (unformat (line_input, "next-ethernet"))
11276 else if (unformat (line_input, "next-nsh"))
11280 errmsg ("parse error '%U'", format_unformat_error, line_input);
11285 if (local_set == 0)
11287 errmsg ("tunnel local address not specified");
11290 if (remote_set == 0)
11292 errmsg ("tunnel remote address not specified");
11295 if (ipv4_set && ipv6_set)
11297 errmsg ("both IPv4 and IPv6 addresses specified");
11303 errmsg ("vni not specified");
11307 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11312 clib_memcpy (&mp->local, &local6, sizeof (local6));
11313 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11317 clib_memcpy (&mp->local, &local4, sizeof (local4));
11318 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11321 mp->encap_vrf_id = ntohl (encap_vrf_id);
11322 mp->decap_vrf_id = ntohl (decap_vrf_id);
11323 mp->protocol = protocol;
11324 mp->vni = ntohl (vni);
11325 mp->is_add = is_add;
11326 mp->is_ipv6 = ipv6_set;
11333 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11334 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11336 vat_main_t *vam = &vat_main;
11338 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11339 ntohl (mp->sw_if_index),
11340 format_ip46_address, &(mp->local[0]),
11341 format_ip46_address, &(mp->remote[0]),
11343 ntohl (mp->protocol),
11344 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11347 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11348 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11350 vat_main_t *vam = &vat_main;
11351 vat_json_node_t *node = NULL;
11352 struct in_addr ip4;
11353 struct in6_addr ip6;
11355 if (VAT_JSON_ARRAY != vam->json_tree.type)
11357 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11358 vat_json_init_array (&vam->json_tree);
11360 node = vat_json_array_add (&vam->json_tree);
11362 vat_json_init_object (node);
11363 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11366 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11367 vat_json_object_add_ip6 (node, "local", ip6);
11368 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11369 vat_json_object_add_ip6 (node, "remote", ip6);
11373 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11374 vat_json_object_add_ip4 (node, "local", ip4);
11375 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11376 vat_json_object_add_ip4 (node, "remote", ip4);
11378 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11379 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11380 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11381 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11382 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11386 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11388 unformat_input_t *i = vam->input;
11389 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11390 vl_api_control_ping_t *mp_ping;
11392 u8 sw_if_index_set = 0;
11395 /* Parse args required to build the message */
11396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11398 if (unformat (i, "sw_if_index %d", &sw_if_index))
11399 sw_if_index_set = 1;
11404 if (sw_if_index_set == 0)
11409 if (!vam->json_output)
11411 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11412 "sw_if_index", "local", "remote", "vni",
11413 "protocol", "encap_vrf_id", "decap_vrf_id");
11416 /* Get list of vxlan-tunnel interfaces */
11417 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11419 mp->sw_if_index = htonl (sw_if_index);
11423 /* Use a control ping for synchronization */
11424 M (CONTROL_PING, mp_ping);
11432 format_l2_fib_mac_address (u8 * s, va_list * args)
11434 u8 *a = va_arg (*args, u8 *);
11436 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11437 a[2], a[3], a[4], a[5], a[6], a[7]);
11440 static void vl_api_l2_fib_table_entry_t_handler
11441 (vl_api_l2_fib_table_entry_t * mp)
11443 vat_main_t *vam = &vat_main;
11445 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11447 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11448 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11452 static void vl_api_l2_fib_table_entry_t_handler_json
11453 (vl_api_l2_fib_table_entry_t * mp)
11455 vat_main_t *vam = &vat_main;
11456 vat_json_node_t *node = NULL;
11458 if (VAT_JSON_ARRAY != vam->json_tree.type)
11460 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11461 vat_json_init_array (&vam->json_tree);
11463 node = vat_json_array_add (&vam->json_tree);
11465 vat_json_init_object (node);
11466 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11467 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11468 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11469 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11470 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11471 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11475 api_l2_fib_table_dump (vat_main_t * vam)
11477 unformat_input_t *i = vam->input;
11478 vl_api_l2_fib_table_dump_t *mp;
11479 vl_api_control_ping_t *mp_ping;
11484 /* Parse args required to build the message */
11485 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11487 if (unformat (i, "bd_id %d", &bd_id))
11493 if (bd_id_set == 0)
11495 errmsg ("missing bridge domain");
11499 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11501 /* Get list of l2 fib entries */
11502 M (L2_FIB_TABLE_DUMP, mp);
11504 mp->bd_id = ntohl (bd_id);
11507 /* Use a control ping for synchronization */
11508 M (CONTROL_PING, mp_ping);
11517 api_interface_name_renumber (vat_main_t * vam)
11519 unformat_input_t *line_input = vam->input;
11520 vl_api_interface_name_renumber_t *mp;
11521 u32 sw_if_index = ~0;
11522 u32 new_show_dev_instance = ~0;
11525 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11527 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11530 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11532 else if (unformat (line_input, "new_show_dev_instance %d",
11533 &new_show_dev_instance))
11539 if (sw_if_index == ~0)
11541 errmsg ("missing interface name or sw_if_index");
11545 if (new_show_dev_instance == ~0)
11547 errmsg ("missing new_show_dev_instance");
11551 M (INTERFACE_NAME_RENUMBER, mp);
11553 mp->sw_if_index = ntohl (sw_if_index);
11554 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11562 api_want_ip4_arp_events (vat_main_t * vam)
11564 unformat_input_t *line_input = vam->input;
11565 vl_api_want_ip4_arp_events_t *mp;
11566 ip4_address_t address;
11567 int address_set = 0;
11568 u32 enable_disable = 1;
11571 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11573 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11575 else if (unformat (line_input, "del"))
11576 enable_disable = 0;
11581 if (address_set == 0)
11583 errmsg ("missing addresses");
11587 M (WANT_IP4_ARP_EVENTS, mp);
11588 mp->enable_disable = enable_disable;
11589 mp->pid = getpid ();
11590 mp->address = address.as_u32;
11598 api_want_ip6_nd_events (vat_main_t * vam)
11600 unformat_input_t *line_input = vam->input;
11601 vl_api_want_ip6_nd_events_t *mp;
11602 ip6_address_t address;
11603 int address_set = 0;
11604 u32 enable_disable = 1;
11607 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11609 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11611 else if (unformat (line_input, "del"))
11612 enable_disable = 0;
11617 if (address_set == 0)
11619 errmsg ("missing addresses");
11623 M (WANT_IP6_ND_EVENTS, mp);
11624 mp->enable_disable = enable_disable;
11625 mp->pid = getpid ();
11626 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11634 api_input_acl_set_interface (vat_main_t * vam)
11636 unformat_input_t *i = vam->input;
11637 vl_api_input_acl_set_interface_t *mp;
11639 int sw_if_index_set;
11640 u32 ip4_table_index = ~0;
11641 u32 ip6_table_index = ~0;
11642 u32 l2_table_index = ~0;
11646 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11648 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11649 sw_if_index_set = 1;
11650 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11651 sw_if_index_set = 1;
11652 else if (unformat (i, "del"))
11654 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11656 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11658 else if (unformat (i, "l2-table %d", &l2_table_index))
11662 clib_warning ("parse error '%U'", format_unformat_error, i);
11667 if (sw_if_index_set == 0)
11669 errmsg ("missing interface name or sw_if_index");
11673 M (INPUT_ACL_SET_INTERFACE, mp);
11675 mp->sw_if_index = ntohl (sw_if_index);
11676 mp->ip4_table_index = ntohl (ip4_table_index);
11677 mp->ip6_table_index = ntohl (ip6_table_index);
11678 mp->l2_table_index = ntohl (l2_table_index);
11679 mp->is_add = is_add;
11687 api_ip_address_dump (vat_main_t * vam)
11689 unformat_input_t *i = vam->input;
11690 vl_api_ip_address_dump_t *mp;
11691 vl_api_control_ping_t *mp_ping;
11692 u32 sw_if_index = ~0;
11693 u8 sw_if_index_set = 0;
11698 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11700 if (unformat (i, "sw_if_index %d", &sw_if_index))
11701 sw_if_index_set = 1;
11703 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11704 sw_if_index_set = 1;
11705 else if (unformat (i, "ipv4"))
11707 else if (unformat (i, "ipv6"))
11713 if (ipv4_set && ipv6_set)
11715 errmsg ("ipv4 and ipv6 flags cannot be both set");
11719 if ((!ipv4_set) && (!ipv6_set))
11721 errmsg ("no ipv4 nor ipv6 flag set");
11725 if (sw_if_index_set == 0)
11727 errmsg ("missing interface name or sw_if_index");
11731 vam->current_sw_if_index = sw_if_index;
11732 vam->is_ipv6 = ipv6_set;
11734 M (IP_ADDRESS_DUMP, mp);
11735 mp->sw_if_index = ntohl (sw_if_index);
11736 mp->is_ipv6 = ipv6_set;
11739 /* Use a control ping for synchronization */
11740 M (CONTROL_PING, mp_ping);
11748 api_ip_dump (vat_main_t * vam)
11750 vl_api_ip_dump_t *mp;
11751 vl_api_control_ping_t *mp_ping;
11752 unformat_input_t *in = vam->input;
11759 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11761 if (unformat (in, "ipv4"))
11763 else if (unformat (in, "ipv6"))
11769 if (ipv4_set && ipv6_set)
11771 errmsg ("ipv4 and ipv6 flags cannot be both set");
11775 if ((!ipv4_set) && (!ipv6_set))
11777 errmsg ("no ipv4 nor ipv6 flag set");
11781 is_ipv6 = ipv6_set;
11782 vam->is_ipv6 = is_ipv6;
11784 /* free old data */
11785 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11787 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11789 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11792 mp->is_ipv6 = ipv6_set;
11795 /* Use a control ping for synchronization */
11796 M (CONTROL_PING, mp_ping);
11804 api_ipsec_spd_add_del (vat_main_t * vam)
11806 unformat_input_t *i = vam->input;
11807 vl_api_ipsec_spd_add_del_t *mp;
11812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11814 if (unformat (i, "spd_id %d", &spd_id))
11816 else if (unformat (i, "del"))
11820 clib_warning ("parse error '%U'", format_unformat_error, i);
11826 errmsg ("spd_id must be set");
11830 M (IPSEC_SPD_ADD_DEL, mp);
11832 mp->spd_id = ntohl (spd_id);
11833 mp->is_add = is_add;
11841 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11843 unformat_input_t *i = vam->input;
11844 vl_api_ipsec_interface_add_del_spd_t *mp;
11846 u8 sw_if_index_set = 0;
11847 u32 spd_id = (u32) ~ 0;
11851 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11853 if (unformat (i, "del"))
11855 else if (unformat (i, "spd_id %d", &spd_id))
11858 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11859 sw_if_index_set = 1;
11860 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11861 sw_if_index_set = 1;
11864 clib_warning ("parse error '%U'", format_unformat_error, i);
11870 if (spd_id == (u32) ~ 0)
11872 errmsg ("spd_id must be set");
11876 if (sw_if_index_set == 0)
11878 errmsg ("missing interface name or sw_if_index");
11882 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
11884 mp->spd_id = ntohl (spd_id);
11885 mp->sw_if_index = ntohl (sw_if_index);
11886 mp->is_add = is_add;
11894 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11896 unformat_input_t *i = vam->input;
11897 vl_api_ipsec_spd_add_del_entry_t *mp;
11898 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11899 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11901 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11902 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11903 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11904 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11907 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11908 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11909 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11910 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11911 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11912 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11914 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11916 if (unformat (i, "del"))
11918 if (unformat (i, "outbound"))
11920 if (unformat (i, "inbound"))
11922 else if (unformat (i, "spd_id %d", &spd_id))
11924 else if (unformat (i, "sa_id %d", &sa_id))
11926 else if (unformat (i, "priority %d", &priority))
11928 else if (unformat (i, "protocol %d", &protocol))
11930 else if (unformat (i, "lport_start %d", &lport_start))
11932 else if (unformat (i, "lport_stop %d", &lport_stop))
11934 else if (unformat (i, "rport_start %d", &rport_start))
11936 else if (unformat (i, "rport_stop %d", &rport_stop))
11940 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
11946 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
11953 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
11959 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
11966 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
11972 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
11979 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
11985 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
11991 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
11993 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
11995 clib_warning ("unsupported action: 'resolve'");
12001 clib_warning ("parse error '%U'", format_unformat_error, i);
12007 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12009 mp->spd_id = ntohl (spd_id);
12010 mp->priority = ntohl (priority);
12011 mp->is_outbound = is_outbound;
12013 mp->is_ipv6 = is_ipv6;
12014 if (is_ipv6 || is_ip_any)
12016 clib_memcpy (mp->remote_address_start, &raddr6_start,
12017 sizeof (ip6_address_t));
12018 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12019 sizeof (ip6_address_t));
12020 clib_memcpy (mp->local_address_start, &laddr6_start,
12021 sizeof (ip6_address_t));
12022 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12023 sizeof (ip6_address_t));
12027 clib_memcpy (mp->remote_address_start, &raddr4_start,
12028 sizeof (ip4_address_t));
12029 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12030 sizeof (ip4_address_t));
12031 clib_memcpy (mp->local_address_start, &laddr4_start,
12032 sizeof (ip4_address_t));
12033 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12034 sizeof (ip4_address_t));
12036 mp->protocol = (u8) protocol;
12037 mp->local_port_start = ntohs ((u16) lport_start);
12038 mp->local_port_stop = ntohs ((u16) lport_stop);
12039 mp->remote_port_start = ntohs ((u16) rport_start);
12040 mp->remote_port_stop = ntohs ((u16) rport_stop);
12041 mp->policy = (u8) policy;
12042 mp->sa_id = ntohl (sa_id);
12043 mp->is_add = is_add;
12044 mp->is_ip_any = is_ip_any;
12051 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12053 unformat_input_t *i = vam->input;
12054 vl_api_ipsec_sad_add_del_entry_t *mp;
12055 u32 sad_id = 0, spi = 0;
12056 u8 *ck = 0, *ik = 0;
12059 u8 protocol = IPSEC_PROTOCOL_AH;
12060 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12061 u32 crypto_alg = 0, integ_alg = 0;
12062 ip4_address_t tun_src4;
12063 ip4_address_t tun_dst4;
12064 ip6_address_t tun_src6;
12065 ip6_address_t tun_dst6;
12068 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12070 if (unformat (i, "del"))
12072 else if (unformat (i, "sad_id %d", &sad_id))
12074 else if (unformat (i, "spi %d", &spi))
12076 else if (unformat (i, "esp"))
12077 protocol = IPSEC_PROTOCOL_ESP;
12078 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12081 is_tunnel_ipv6 = 0;
12083 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12086 is_tunnel_ipv6 = 0;
12088 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12091 is_tunnel_ipv6 = 1;
12093 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12096 is_tunnel_ipv6 = 1;
12100 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12102 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12103 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12105 clib_warning ("unsupported crypto-alg: '%U'",
12106 format_ipsec_crypto_alg, crypto_alg);
12110 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12114 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12116 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12117 integ_alg >= IPSEC_INTEG_N_ALG)
12119 clib_warning ("unsupported integ-alg: '%U'",
12120 format_ipsec_integ_alg, integ_alg);
12124 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12128 clib_warning ("parse error '%U'", format_unformat_error, i);
12134 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12136 mp->sad_id = ntohl (sad_id);
12137 mp->is_add = is_add;
12138 mp->protocol = protocol;
12139 mp->spi = ntohl (spi);
12140 mp->is_tunnel = is_tunnel;
12141 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12142 mp->crypto_algorithm = crypto_alg;
12143 mp->integrity_algorithm = integ_alg;
12144 mp->crypto_key_length = vec_len (ck);
12145 mp->integrity_key_length = vec_len (ik);
12147 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12148 mp->crypto_key_length = sizeof (mp->crypto_key);
12150 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12151 mp->integrity_key_length = sizeof (mp->integrity_key);
12154 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12156 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12160 if (is_tunnel_ipv6)
12162 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12163 sizeof (ip6_address_t));
12164 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12165 sizeof (ip6_address_t));
12169 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12170 sizeof (ip4_address_t));
12171 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12172 sizeof (ip4_address_t));
12182 api_ipsec_sa_set_key (vat_main_t * vam)
12184 unformat_input_t *i = vam->input;
12185 vl_api_ipsec_sa_set_key_t *mp;
12187 u8 *ck = 0, *ik = 0;
12190 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12192 if (unformat (i, "sa_id %d", &sa_id))
12194 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12196 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12200 clib_warning ("parse error '%U'", format_unformat_error, i);
12205 M (IPSEC_SA_SET_KEY, mp);
12207 mp->sa_id = ntohl (sa_id);
12208 mp->crypto_key_length = vec_len (ck);
12209 mp->integrity_key_length = vec_len (ik);
12211 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12212 mp->crypto_key_length = sizeof (mp->crypto_key);
12214 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12215 mp->integrity_key_length = sizeof (mp->integrity_key);
12218 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12220 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12228 api_ikev2_profile_add_del (vat_main_t * vam)
12230 unformat_input_t *i = vam->input;
12231 vl_api_ikev2_profile_add_del_t *mp;
12236 const char *valid_chars = "a-zA-Z0-9_";
12238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12240 if (unformat (i, "del"))
12242 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12243 vec_add1 (name, 0);
12246 errmsg ("parse error '%U'", format_unformat_error, i);
12251 if (!vec_len (name))
12253 errmsg ("profile name must be specified");
12257 if (vec_len (name) > 64)
12259 errmsg ("profile name too long");
12263 M (IKEV2_PROFILE_ADD_DEL, mp);
12265 clib_memcpy (mp->name, name, vec_len (name));
12266 mp->is_add = is_add;
12275 api_ikev2_profile_set_auth (vat_main_t * vam)
12277 unformat_input_t *i = vam->input;
12278 vl_api_ikev2_profile_set_auth_t *mp;
12281 u32 auth_method = 0;
12285 const char *valid_chars = "a-zA-Z0-9_";
12287 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12289 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12290 vec_add1 (name, 0);
12291 else if (unformat (i, "auth_method %U",
12292 unformat_ikev2_auth_method, &auth_method))
12294 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12296 else if (unformat (i, "auth_data %v", &data))
12300 errmsg ("parse error '%U'", format_unformat_error, i);
12305 if (!vec_len (name))
12307 errmsg ("profile name must be specified");
12311 if (vec_len (name) > 64)
12313 errmsg ("profile name too long");
12317 if (!vec_len (data))
12319 errmsg ("auth_data must be specified");
12325 errmsg ("auth_method must be specified");
12329 M (IKEV2_PROFILE_SET_AUTH, mp);
12331 mp->is_hex = is_hex;
12332 mp->auth_method = (u8) auth_method;
12333 mp->data_len = vec_len (data);
12334 clib_memcpy (mp->name, name, vec_len (name));
12335 clib_memcpy (mp->data, data, vec_len (data));
12345 api_ikev2_profile_set_id (vat_main_t * vam)
12347 unformat_input_t *i = vam->input;
12348 vl_api_ikev2_profile_set_id_t *mp;
12356 const char *valid_chars = "a-zA-Z0-9_";
12358 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12360 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12361 vec_add1 (name, 0);
12362 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12364 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12366 data = vec_new (u8, 4);
12367 clib_memcpy (data, ip4.as_u8, 4);
12369 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12371 else if (unformat (i, "id_data %v", &data))
12373 else if (unformat (i, "local"))
12375 else if (unformat (i, "remote"))
12379 errmsg ("parse error '%U'", format_unformat_error, i);
12384 if (!vec_len (name))
12386 errmsg ("profile name must be specified");
12390 if (vec_len (name) > 64)
12392 errmsg ("profile name too long");
12396 if (!vec_len (data))
12398 errmsg ("id_data must be specified");
12404 errmsg ("id_type must be specified");
12408 M (IKEV2_PROFILE_SET_ID, mp);
12410 mp->is_local = is_local;
12411 mp->id_type = (u8) id_type;
12412 mp->data_len = vec_len (data);
12413 clib_memcpy (mp->name, name, vec_len (name));
12414 clib_memcpy (mp->data, data, vec_len (data));
12424 api_ikev2_profile_set_ts (vat_main_t * vam)
12426 unformat_input_t *i = vam->input;
12427 vl_api_ikev2_profile_set_ts_t *mp;
12430 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12431 ip4_address_t start_addr, end_addr;
12433 const char *valid_chars = "a-zA-Z0-9_";
12436 start_addr.as_u32 = 0;
12437 end_addr.as_u32 = (u32) ~ 0;
12439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12441 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12442 vec_add1 (name, 0);
12443 else if (unformat (i, "protocol %d", &proto))
12445 else if (unformat (i, "start_port %d", &start_port))
12447 else if (unformat (i, "end_port %d", &end_port))
12450 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12452 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12454 else if (unformat (i, "local"))
12456 else if (unformat (i, "remote"))
12460 errmsg ("parse error '%U'", format_unformat_error, i);
12465 if (!vec_len (name))
12467 errmsg ("profile name must be specified");
12471 if (vec_len (name) > 64)
12473 errmsg ("profile name too long");
12477 M (IKEV2_PROFILE_SET_TS, mp);
12479 mp->is_local = is_local;
12480 mp->proto = (u8) proto;
12481 mp->start_port = (u16) start_port;
12482 mp->end_port = (u16) end_port;
12483 mp->start_addr = start_addr.as_u32;
12484 mp->end_addr = end_addr.as_u32;
12485 clib_memcpy (mp->name, name, vec_len (name));
12494 api_ikev2_set_local_key (vat_main_t * vam)
12496 unformat_input_t *i = vam->input;
12497 vl_api_ikev2_set_local_key_t *mp;
12501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12503 if (unformat (i, "file %v", &file))
12504 vec_add1 (file, 0);
12507 errmsg ("parse error '%U'", format_unformat_error, i);
12512 if (!vec_len (file))
12514 errmsg ("RSA key file must be specified");
12518 if (vec_len (file) > 256)
12520 errmsg ("file name too long");
12524 M (IKEV2_SET_LOCAL_KEY, mp);
12526 clib_memcpy (mp->key_file, file, vec_len (file));
12535 api_ikev2_set_responder (vat_main_t * vam)
12537 unformat_input_t *i = vam->input;
12538 vl_api_ikev2_set_responder_t *mp;
12541 u32 sw_if_index = ~0;
12542 ip4_address_t address;
12544 const char *valid_chars = "a-zA-Z0-9_";
12546 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12549 (i, "%U interface %d address %U", unformat_token, valid_chars,
12550 &name, &sw_if_index, unformat_ip4_address, &address))
12551 vec_add1 (name, 0);
12554 errmsg ("parse error '%U'", format_unformat_error, i);
12559 if (!vec_len (name))
12561 errmsg ("profile name must be specified");
12565 if (vec_len (name) > 64)
12567 errmsg ("profile name too long");
12571 M (IKEV2_SET_RESPONDER, mp);
12573 clib_memcpy (mp->name, name, vec_len (name));
12576 mp->sw_if_index = sw_if_index;
12577 clib_memcpy (mp->address, &address, sizeof (address));
12585 api_ikev2_set_ike_transforms (vat_main_t * vam)
12587 unformat_input_t *i = vam->input;
12588 vl_api_ikev2_set_ike_transforms_t *mp;
12591 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12593 const char *valid_chars = "a-zA-Z0-9_";
12595 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12597 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12598 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12599 vec_add1 (name, 0);
12602 errmsg ("parse error '%U'", format_unformat_error, i);
12607 if (!vec_len (name))
12609 errmsg ("profile name must be specified");
12613 if (vec_len (name) > 64)
12615 errmsg ("profile name too long");
12619 M (IKEV2_SET_IKE_TRANSFORMS, mp);
12621 clib_memcpy (mp->name, name, vec_len (name));
12623 mp->crypto_alg = crypto_alg;
12624 mp->crypto_key_size = crypto_key_size;
12625 mp->integ_alg = integ_alg;
12626 mp->dh_group = dh_group;
12635 api_ikev2_set_esp_transforms (vat_main_t * vam)
12637 unformat_input_t *i = vam->input;
12638 vl_api_ikev2_set_esp_transforms_t *mp;
12641 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12643 const char *valid_chars = "a-zA-Z0-9_";
12645 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12647 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12648 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12649 vec_add1 (name, 0);
12652 errmsg ("parse error '%U'", format_unformat_error, i);
12657 if (!vec_len (name))
12659 errmsg ("profile name must be specified");
12663 if (vec_len (name) > 64)
12665 errmsg ("profile name too long");
12669 M (IKEV2_SET_ESP_TRANSFORMS, mp);
12671 clib_memcpy (mp->name, name, vec_len (name));
12673 mp->crypto_alg = crypto_alg;
12674 mp->crypto_key_size = crypto_key_size;
12675 mp->integ_alg = integ_alg;
12676 mp->dh_group = dh_group;
12684 api_ikev2_set_sa_lifetime (vat_main_t * vam)
12686 unformat_input_t *i = vam->input;
12687 vl_api_ikev2_set_sa_lifetime_t *mp;
12690 u64 lifetime, lifetime_maxdata;
12691 u32 lifetime_jitter, handover;
12693 const char *valid_chars = "a-zA-Z0-9_";
12695 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12697 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
12698 &lifetime, &lifetime_jitter, &handover,
12699 &lifetime_maxdata))
12700 vec_add1 (name, 0);
12703 errmsg ("parse error '%U'", format_unformat_error, i);
12708 if (!vec_len (name))
12710 errmsg ("profile name must be specified");
12714 if (vec_len (name) > 64)
12716 errmsg ("profile name too long");
12720 M (IKEV2_SET_SA_LIFETIME, mp);
12722 clib_memcpy (mp->name, name, vec_len (name));
12724 mp->lifetime = lifetime;
12725 mp->lifetime_jitter = lifetime_jitter;
12726 mp->handover = handover;
12727 mp->lifetime_maxdata = lifetime_maxdata;
12735 api_ikev2_initiate_sa_init (vat_main_t * vam)
12737 unformat_input_t *i = vam->input;
12738 vl_api_ikev2_initiate_sa_init_t *mp;
12742 const char *valid_chars = "a-zA-Z0-9_";
12744 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12746 if (unformat (i, "%U", unformat_token, valid_chars, &name))
12747 vec_add1 (name, 0);
12750 errmsg ("parse error '%U'", format_unformat_error, i);
12755 if (!vec_len (name))
12757 errmsg ("profile name must be specified");
12761 if (vec_len (name) > 64)
12763 errmsg ("profile name too long");
12767 M (IKEV2_INITIATE_SA_INIT, mp);
12769 clib_memcpy (mp->name, name, vec_len (name));
12778 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
12780 unformat_input_t *i = vam->input;
12781 vl_api_ikev2_initiate_del_ike_sa_t *mp;
12786 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12788 if (unformat (i, "%lx", &ispi))
12792 errmsg ("parse error '%U'", format_unformat_error, i);
12797 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
12807 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
12809 unformat_input_t *i = vam->input;
12810 vl_api_ikev2_initiate_del_child_sa_t *mp;
12815 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12817 if (unformat (i, "%x", &ispi))
12821 errmsg ("parse error '%U'", format_unformat_error, i);
12826 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
12836 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
12838 unformat_input_t *i = vam->input;
12839 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
12844 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12846 if (unformat (i, "%x", &ispi))
12850 errmsg ("parse error '%U'", format_unformat_error, i);
12855 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
12868 api_map_add_domain (vat_main_t * vam)
12870 unformat_input_t *i = vam->input;
12871 vl_api_map_add_domain_t *mp;
12873 ip4_address_t ip4_prefix;
12874 ip6_address_t ip6_prefix;
12875 ip6_address_t ip6_src;
12876 u32 num_m_args = 0;
12877 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12878 0, psid_length = 0;
12879 u8 is_translation = 0;
12881 u32 ip6_src_len = 128;
12884 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12886 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12887 &ip4_prefix, &ip4_prefix_len))
12889 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12890 &ip6_prefix, &ip6_prefix_len))
12894 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12897 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12899 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12901 else if (unformat (i, "psid-offset %d", &psid_offset))
12903 else if (unformat (i, "psid-len %d", &psid_length))
12905 else if (unformat (i, "mtu %d", &mtu))
12907 else if (unformat (i, "map-t"))
12908 is_translation = 1;
12911 clib_warning ("parse error '%U'", format_unformat_error, i);
12916 if (num_m_args < 3)
12918 errmsg ("mandatory argument(s) missing");
12922 /* Construct the API message */
12923 M (MAP_ADD_DOMAIN, mp);
12925 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12926 mp->ip4_prefix_len = ip4_prefix_len;
12928 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12929 mp->ip6_prefix_len = ip6_prefix_len;
12931 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12932 mp->ip6_src_prefix_len = ip6_src_len;
12934 mp->ea_bits_len = ea_bits_len;
12935 mp->psid_offset = psid_offset;
12936 mp->psid_length = psid_length;
12937 mp->is_translation = is_translation;
12938 mp->mtu = htons (mtu);
12943 /* Wait for a reply, return good/bad news */
12949 api_map_del_domain (vat_main_t * vam)
12951 unformat_input_t *i = vam->input;
12952 vl_api_map_del_domain_t *mp;
12954 u32 num_m_args = 0;
12958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12960 if (unformat (i, "index %d", &index))
12964 clib_warning ("parse error '%U'", format_unformat_error, i);
12969 if (num_m_args != 1)
12971 errmsg ("mandatory argument(s) missing");
12975 /* Construct the API message */
12976 M (MAP_DEL_DOMAIN, mp);
12978 mp->index = ntohl (index);
12983 /* Wait for a reply, return good/bad news */
12989 api_map_add_del_rule (vat_main_t * vam)
12991 unformat_input_t *i = vam->input;
12992 vl_api_map_add_del_rule_t *mp;
12994 ip6_address_t ip6_dst;
12995 u32 num_m_args = 0, index, psid = 0;
12998 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13000 if (unformat (i, "index %d", &index))
13002 else if (unformat (i, "psid %d", &psid))
13004 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13006 else if (unformat (i, "del"))
13012 clib_warning ("parse error '%U'", format_unformat_error, i);
13017 /* Construct the API message */
13018 M (MAP_ADD_DEL_RULE, mp);
13020 mp->index = ntohl (index);
13021 mp->is_add = is_add;
13022 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13023 mp->psid = ntohs (psid);
13028 /* Wait for a reply, return good/bad news */
13034 api_map_domain_dump (vat_main_t * vam)
13036 vl_api_map_domain_dump_t *mp;
13037 vl_api_control_ping_t *mp_ping;
13040 /* Construct the API message */
13041 M (MAP_DOMAIN_DUMP, mp);
13046 /* Use a control ping for synchronization */
13047 M (CONTROL_PING, mp_ping);
13055 api_map_rule_dump (vat_main_t * vam)
13057 unformat_input_t *i = vam->input;
13058 vl_api_map_rule_dump_t *mp;
13059 vl_api_control_ping_t *mp_ping;
13060 u32 domain_index = ~0;
13063 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13065 if (unformat (i, "index %u", &domain_index))
13071 if (domain_index == ~0)
13073 clib_warning ("parse error: domain index expected");
13077 /* Construct the API message */
13078 M (MAP_RULE_DUMP, mp);
13080 mp->domain_index = htonl (domain_index);
13085 /* Use a control ping for synchronization */
13086 M (CONTROL_PING, mp_ping);
13093 static void vl_api_map_add_domain_reply_t_handler
13094 (vl_api_map_add_domain_reply_t * mp)
13096 vat_main_t *vam = &vat_main;
13097 i32 retval = ntohl (mp->retval);
13099 if (vam->async_mode)
13101 vam->async_errors += (retval < 0);
13105 vam->retval = retval;
13106 vam->result_ready = 1;
13110 static void vl_api_map_add_domain_reply_t_handler_json
13111 (vl_api_map_add_domain_reply_t * mp)
13113 vat_main_t *vam = &vat_main;
13114 vat_json_node_t node;
13116 vat_json_init_object (&node);
13117 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13118 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13120 vat_json_print (vam->ofp, &node);
13121 vat_json_free (&node);
13123 vam->retval = ntohl (mp->retval);
13124 vam->result_ready = 1;
13128 api_get_first_msg_id (vat_main_t * vam)
13130 vl_api_get_first_msg_id_t *mp;
13131 unformat_input_t *i = vam->input;
13136 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13138 if (unformat (i, "client %s", &name))
13146 errmsg ("missing client name");
13149 vec_add1 (name, 0);
13151 if (vec_len (name) > 63)
13153 errmsg ("client name too long");
13157 M (GET_FIRST_MSG_ID, mp);
13158 clib_memcpy (mp->name, name, vec_len (name));
13165 api_cop_interface_enable_disable (vat_main_t * vam)
13167 unformat_input_t *line_input = vam->input;
13168 vl_api_cop_interface_enable_disable_t *mp;
13169 u32 sw_if_index = ~0;
13170 u8 enable_disable = 1;
13173 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13175 if (unformat (line_input, "disable"))
13176 enable_disable = 0;
13177 if (unformat (line_input, "enable"))
13178 enable_disable = 1;
13179 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13180 vam, &sw_if_index))
13182 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13188 if (sw_if_index == ~0)
13190 errmsg ("missing interface name or sw_if_index");
13194 /* Construct the API message */
13195 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13196 mp->sw_if_index = ntohl (sw_if_index);
13197 mp->enable_disable = enable_disable;
13201 /* Wait for the reply */
13207 api_cop_whitelist_enable_disable (vat_main_t * vam)
13209 unformat_input_t *line_input = vam->input;
13210 vl_api_cop_whitelist_enable_disable_t *mp;
13211 u32 sw_if_index = ~0;
13212 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13216 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13218 if (unformat (line_input, "ip4"))
13220 else if (unformat (line_input, "ip6"))
13222 else if (unformat (line_input, "default"))
13224 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13225 vam, &sw_if_index))
13227 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13229 else if (unformat (line_input, "fib-id %d", &fib_id))
13235 if (sw_if_index == ~0)
13237 errmsg ("missing interface name or sw_if_index");
13241 /* Construct the API message */
13242 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13243 mp->sw_if_index = ntohl (sw_if_index);
13244 mp->fib_id = ntohl (fib_id);
13247 mp->default_cop = default_cop;
13251 /* Wait for the reply */
13257 api_get_node_graph (vat_main_t * vam)
13259 vl_api_get_node_graph_t *mp;
13262 M (GET_NODE_GRAPH, mp);
13266 /* Wait for the reply */
13272 /** Used for parsing LISP eids */
13273 typedef CLIB_PACKED(struct{
13274 u8 addr[16]; /**< eid address */
13275 u32 len; /**< prefix length if IP */
13276 u8 type; /**< type of eid */
13281 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13283 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13285 memset (a, 0, sizeof (a[0]));
13287 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13289 a->type = 0; /* ipv4 type */
13291 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13293 a->type = 1; /* ipv6 type */
13295 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13297 a->type = 2; /* mac type */
13304 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13313 lisp_eid_size_vat (u8 type)
13328 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13330 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13334 api_one_add_del_locator_set (vat_main_t * vam)
13336 unformat_input_t *input = vam->input;
13337 vl_api_one_add_del_locator_set_t *mp;
13339 u8 *locator_set_name = NULL;
13340 u8 locator_set_name_set = 0;
13341 vl_api_local_locator_t locator, *locators = 0;
13342 u32 sw_if_index, priority, weight;
13346 /* Parse args required to build the message */
13347 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13349 if (unformat (input, "del"))
13353 else if (unformat (input, "locator-set %s", &locator_set_name))
13355 locator_set_name_set = 1;
13357 else if (unformat (input, "sw_if_index %u p %u w %u",
13358 &sw_if_index, &priority, &weight))
13360 locator.sw_if_index = htonl (sw_if_index);
13361 locator.priority = priority;
13362 locator.weight = weight;
13363 vec_add1 (locators, locator);
13367 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13368 &sw_if_index, &priority, &weight))
13370 locator.sw_if_index = htonl (sw_if_index);
13371 locator.priority = priority;
13372 locator.weight = weight;
13373 vec_add1 (locators, locator);
13379 if (locator_set_name_set == 0)
13381 errmsg ("missing locator-set name");
13382 vec_free (locators);
13386 if (vec_len (locator_set_name) > 64)
13388 errmsg ("locator-set name too long");
13389 vec_free (locator_set_name);
13390 vec_free (locators);
13393 vec_add1 (locator_set_name, 0);
13395 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13397 /* Construct the API message */
13398 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
13400 mp->is_add = is_add;
13401 clib_memcpy (mp->locator_set_name, locator_set_name,
13402 vec_len (locator_set_name));
13403 vec_free (locator_set_name);
13405 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13407 clib_memcpy (mp->locators, locators, data_len);
13408 vec_free (locators);
13413 /* Wait for a reply... */
13418 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
13421 api_one_add_del_locator (vat_main_t * vam)
13423 unformat_input_t *input = vam->input;
13424 vl_api_one_add_del_locator_t *mp;
13425 u32 tmp_if_index = ~0;
13426 u32 sw_if_index = ~0;
13427 u8 sw_if_index_set = 0;
13428 u8 sw_if_index_if_name_set = 0;
13430 u8 priority_set = 0;
13434 u8 *locator_set_name = NULL;
13435 u8 locator_set_name_set = 0;
13438 /* Parse args required to build the message */
13439 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13441 if (unformat (input, "del"))
13445 else if (unformat (input, "locator-set %s", &locator_set_name))
13447 locator_set_name_set = 1;
13449 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13452 sw_if_index_if_name_set = 1;
13453 sw_if_index = tmp_if_index;
13455 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13457 sw_if_index_set = 1;
13458 sw_if_index = tmp_if_index;
13460 else if (unformat (input, "p %d", &priority))
13464 else if (unformat (input, "w %d", &weight))
13472 if (locator_set_name_set == 0)
13474 errmsg ("missing locator-set name");
13478 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13480 errmsg ("missing sw_if_index");
13481 vec_free (locator_set_name);
13485 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13487 errmsg ("cannot use both params interface name and sw_if_index");
13488 vec_free (locator_set_name);
13492 if (priority_set == 0)
13494 errmsg ("missing locator-set priority");
13495 vec_free (locator_set_name);
13499 if (weight_set == 0)
13501 errmsg ("missing locator-set weight");
13502 vec_free (locator_set_name);
13506 if (vec_len (locator_set_name) > 64)
13508 errmsg ("locator-set name too long");
13509 vec_free (locator_set_name);
13512 vec_add1 (locator_set_name, 0);
13514 /* Construct the API message */
13515 M (ONE_ADD_DEL_LOCATOR, mp);
13517 mp->is_add = is_add;
13518 mp->sw_if_index = ntohl (sw_if_index);
13519 mp->priority = priority;
13520 mp->weight = weight;
13521 clib_memcpy (mp->locator_set_name, locator_set_name,
13522 vec_len (locator_set_name));
13523 vec_free (locator_set_name);
13528 /* Wait for a reply... */
13533 #define api_lisp_add_del_locator api_one_add_del_locator
13536 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13538 u32 *key_id = va_arg (*args, u32 *);
13541 if (unformat (input, "%s", &s))
13543 if (!strcmp ((char *) s, "sha1"))
13544 key_id[0] = HMAC_SHA_1_96;
13545 else if (!strcmp ((char *) s, "sha256"))
13546 key_id[0] = HMAC_SHA_256_128;
13549 clib_warning ("invalid key_id: '%s'", s);
13550 key_id[0] = HMAC_NO_KEY;
13561 api_one_add_del_local_eid (vat_main_t * vam)
13563 unformat_input_t *input = vam->input;
13564 vl_api_one_add_del_local_eid_t *mp;
13567 lisp_eid_vat_t _eid, *eid = &_eid;
13568 u8 *locator_set_name = 0;
13569 u8 locator_set_name_set = 0;
13575 /* Parse args required to build the message */
13576 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13578 if (unformat (input, "del"))
13582 else if (unformat (input, "vni %d", &vni))
13586 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13590 else if (unformat (input, "locator-set %s", &locator_set_name))
13592 locator_set_name_set = 1;
13594 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13596 else if (unformat (input, "secret-key %_%v%_", &key))
13602 if (locator_set_name_set == 0)
13604 errmsg ("missing locator-set name");
13610 errmsg ("EID address not set!");
13611 vec_free (locator_set_name);
13615 if (key && (0 == key_id))
13617 errmsg ("invalid key_id!");
13621 if (vec_len (key) > 64)
13623 errmsg ("key too long");
13628 if (vec_len (locator_set_name) > 64)
13630 errmsg ("locator-set name too long");
13631 vec_free (locator_set_name);
13634 vec_add1 (locator_set_name, 0);
13636 /* Construct the API message */
13637 M (ONE_ADD_DEL_LOCAL_EID, mp);
13639 mp->is_add = is_add;
13640 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13641 mp->eid_type = eid->type;
13642 mp->prefix_len = eid->len;
13643 mp->vni = clib_host_to_net_u32 (vni);
13644 mp->key_id = clib_host_to_net_u16 (key_id);
13645 clib_memcpy (mp->locator_set_name, locator_set_name,
13646 vec_len (locator_set_name));
13647 clib_memcpy (mp->key, key, vec_len (key));
13649 vec_free (locator_set_name);
13655 /* Wait for a reply... */
13660 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
13663 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13665 u32 dp_table = 0, vni = 0;;
13666 unformat_input_t *input = vam->input;
13667 vl_api_gpe_add_del_fwd_entry_t *mp;
13669 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13670 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13671 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13672 u32 action = ~0, w;
13673 ip4_address_t rmt_rloc4, lcl_rloc4;
13674 ip6_address_t rmt_rloc6, lcl_rloc6;
13675 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13678 memset (&rloc, 0, sizeof (rloc));
13680 /* Parse args required to build the message */
13681 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13683 if (unformat (input, "del"))
13685 else if (unformat (input, "add"))
13687 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13691 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13695 else if (unformat (input, "vrf %d", &dp_table))
13697 else if (unformat (input, "bd %d", &dp_table))
13699 else if (unformat (input, "vni %d", &vni))
13701 else if (unformat (input, "w %d", &w))
13705 errmsg ("No RLOC configured for setting priority/weight!");
13708 curr_rloc->weight = w;
13710 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13711 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13715 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13717 vec_add1 (lcl_locs, rloc);
13719 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13720 vec_add1 (rmt_locs, rloc);
13721 /* weight saved in rmt loc */
13722 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13724 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13725 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13728 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13730 vec_add1 (lcl_locs, rloc);
13732 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13733 vec_add1 (rmt_locs, rloc);
13734 /* weight saved in rmt loc */
13735 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13737 else if (unformat (input, "action %d", &action))
13743 clib_warning ("parse error '%U'", format_unformat_error, input);
13750 errmsg ("remote eid addresses not set");
13754 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13756 errmsg ("eid types don't match");
13760 if (0 == rmt_locs && (u32) ~ 0 == action)
13762 errmsg ("action not set for negative mapping");
13766 /* Construct the API message */
13767 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
13768 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
13770 mp->is_add = is_add;
13771 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13772 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13773 mp->eid_type = rmt_eid->type;
13774 mp->dp_table = clib_host_to_net_u32 (dp_table);
13775 mp->vni = clib_host_to_net_u32 (vni);
13776 mp->rmt_len = rmt_eid->len;
13777 mp->lcl_len = lcl_eid->len;
13778 mp->action = action;
13780 if (0 != rmt_locs && 0 != lcl_locs)
13782 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
13783 clib_memcpy (mp->locs, lcl_locs,
13784 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
13786 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
13787 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
13788 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
13790 vec_free (lcl_locs);
13791 vec_free (rmt_locs);
13796 /* Wait for a reply... */
13802 api_one_add_del_map_server (vat_main_t * vam)
13804 unformat_input_t *input = vam->input;
13805 vl_api_one_add_del_map_server_t *mp;
13809 ip4_address_t ipv4;
13810 ip6_address_t ipv6;
13813 /* Parse args required to build the message */
13814 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13816 if (unformat (input, "del"))
13820 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13824 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13832 if (ipv4_set && ipv6_set)
13834 errmsg ("both eid v4 and v6 addresses set");
13838 if (!ipv4_set && !ipv6_set)
13840 errmsg ("eid addresses not set");
13844 /* Construct the API message */
13845 M (ONE_ADD_DEL_MAP_SERVER, mp);
13847 mp->is_add = is_add;
13851 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13856 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13862 /* Wait for a reply... */
13867 #define api_lisp_add_del_map_server api_one_add_del_map_server
13870 api_one_add_del_map_resolver (vat_main_t * vam)
13872 unformat_input_t *input = vam->input;
13873 vl_api_one_add_del_map_resolver_t *mp;
13877 ip4_address_t ipv4;
13878 ip6_address_t ipv6;
13881 /* Parse args required to build the message */
13882 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13884 if (unformat (input, "del"))
13888 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13892 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13900 if (ipv4_set && ipv6_set)
13902 errmsg ("both eid v4 and v6 addresses set");
13906 if (!ipv4_set && !ipv6_set)
13908 errmsg ("eid addresses not set");
13912 /* Construct the API message */
13913 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
13915 mp->is_add = is_add;
13919 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13924 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13930 /* Wait for a reply... */
13935 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
13938 api_lisp_gpe_enable_disable (vat_main_t * vam)
13940 unformat_input_t *input = vam->input;
13941 vl_api_gpe_enable_disable_t *mp;
13946 /* Parse args required to build the message */
13947 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13949 if (unformat (input, "enable"))
13954 else if (unformat (input, "disable"))
13965 errmsg ("Value not set");
13969 /* Construct the API message */
13970 M (GPE_ENABLE_DISABLE, mp);
13977 /* Wait for a reply... */
13983 api_one_rloc_probe_enable_disable (vat_main_t * vam)
13985 unformat_input_t *input = vam->input;
13986 vl_api_one_rloc_probe_enable_disable_t *mp;
13991 /* Parse args required to build the message */
13992 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13994 if (unformat (input, "enable"))
13999 else if (unformat (input, "disable"))
14007 errmsg ("Value not set");
14011 /* Construct the API message */
14012 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14014 mp->is_enabled = is_en;
14019 /* Wait for a reply... */
14024 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14027 api_one_map_register_enable_disable (vat_main_t * vam)
14029 unformat_input_t *input = vam->input;
14030 vl_api_one_map_register_enable_disable_t *mp;
14035 /* Parse args required to build the message */
14036 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14038 if (unformat (input, "enable"))
14043 else if (unformat (input, "disable"))
14051 errmsg ("Value not set");
14055 /* Construct the API message */
14056 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14058 mp->is_enabled = is_en;
14063 /* Wait for a reply... */
14068 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14071 api_one_enable_disable (vat_main_t * vam)
14073 unformat_input_t *input = vam->input;
14074 vl_api_one_enable_disable_t *mp;
14079 /* Parse args required to build the message */
14080 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14082 if (unformat (input, "enable"))
14087 else if (unformat (input, "disable"))
14097 errmsg ("Value not set");
14101 /* Construct the API message */
14102 M (ONE_ENABLE_DISABLE, mp);
14109 /* Wait for a reply... */
14114 #define api_lisp_enable_disable api_one_enable_disable
14117 api_show_one_map_register_state (vat_main_t * vam)
14119 vl_api_show_one_map_register_state_t *mp;
14122 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14127 /* wait for reply */
14132 #define api_show_lisp_map_register_state api_show_one_map_register_state
14135 api_show_one_rloc_probe_state (vat_main_t * vam)
14137 vl_api_show_one_rloc_probe_state_t *mp;
14140 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14145 /* wait for reply */
14150 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14153 api_show_one_map_request_mode (vat_main_t * vam)
14155 vl_api_show_one_map_request_mode_t *mp;
14158 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
14163 /* wait for reply */
14168 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
14171 api_one_map_request_mode (vat_main_t * vam)
14173 unformat_input_t *input = vam->input;
14174 vl_api_one_map_request_mode_t *mp;
14178 /* Parse args required to build the message */
14179 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14181 if (unformat (input, "dst-only"))
14183 else if (unformat (input, "src-dst"))
14187 errmsg ("parse error '%U'", format_unformat_error, input);
14192 M (ONE_MAP_REQUEST_MODE, mp);
14199 /* wait for reply */
14204 #define api_lisp_map_request_mode api_one_map_request_mode
14207 * Enable/disable ONE proxy ITR.
14209 * @param vam vpp API test context
14210 * @return return code
14213 api_one_pitr_set_locator_set (vat_main_t * vam)
14215 u8 ls_name_set = 0;
14216 unformat_input_t *input = vam->input;
14217 vl_api_one_pitr_set_locator_set_t *mp;
14222 /* Parse args required to build the message */
14223 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14225 if (unformat (input, "del"))
14227 else if (unformat (input, "locator-set %s", &ls_name))
14231 errmsg ("parse error '%U'", format_unformat_error, input);
14238 errmsg ("locator-set name not set!");
14242 M (ONE_PITR_SET_LOCATOR_SET, mp);
14244 mp->is_add = is_add;
14245 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14246 vec_free (ls_name);
14251 /* wait for reply */
14256 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
14259 api_show_one_pitr (vat_main_t * vam)
14261 vl_api_show_one_pitr_t *mp;
14264 if (!vam->json_output)
14266 print (vam->ofp, "%=20s", "lisp status:");
14269 M (SHOW_ONE_PITR, mp);
14273 /* Wait for a reply... */
14278 #define api_show_lisp_pitr api_show_one_pitr
14281 * Add/delete mapping between vni and vrf
14284 api_one_eid_table_add_del_map (vat_main_t * vam)
14286 unformat_input_t *input = vam->input;
14287 vl_api_one_eid_table_add_del_map_t *mp;
14288 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
14289 u32 vni, vrf, bd_index;
14292 /* Parse args required to build the message */
14293 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14295 if (unformat (input, "del"))
14297 else if (unformat (input, "vrf %d", &vrf))
14299 else if (unformat (input, "bd_index %d", &bd_index))
14301 else if (unformat (input, "vni %d", &vni))
14307 if (!vni_set || (!vrf_set && !bd_index_set))
14309 errmsg ("missing arguments!");
14313 if (vrf_set && bd_index_set)
14315 errmsg ("error: both vrf and bd entered!");
14319 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
14321 mp->is_add = is_add;
14322 mp->vni = htonl (vni);
14323 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
14324 mp->is_l2 = bd_index_set;
14329 /* wait for reply */
14334 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
14337 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
14339 u32 *action = va_arg (*args, u32 *);
14342 if (unformat (input, "%s", &s))
14344 if (!strcmp ((char *) s, "no-action"))
14346 else if (!strcmp ((char *) s, "natively-forward"))
14348 else if (!strcmp ((char *) s, "send-map-request"))
14350 else if (!strcmp ((char *) s, "drop"))
14354 clib_warning ("invalid action: '%s'", s);
14366 * Add/del remote mapping to/from ONE control plane
14368 * @param vam vpp API test context
14369 * @return return code
14372 api_one_add_del_remote_mapping (vat_main_t * vam)
14374 unformat_input_t *input = vam->input;
14375 vl_api_one_add_del_remote_mapping_t *mp;
14377 lisp_eid_vat_t _eid, *eid = &_eid;
14378 lisp_eid_vat_t _seid, *seid = &_seid;
14379 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
14380 u32 action = ~0, p, w, data_len;
14381 ip4_address_t rloc4;
14382 ip6_address_t rloc6;
14383 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
14386 memset (&rloc, 0, sizeof (rloc));
14388 /* Parse args required to build the message */
14389 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14391 if (unformat (input, "del-all"))
14395 else if (unformat (input, "del"))
14399 else if (unformat (input, "add"))
14403 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14407 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14411 else if (unformat (input, "vni %d", &vni))
14415 else if (unformat (input, "p %d w %d", &p, &w))
14419 errmsg ("No RLOC configured for setting priority/weight!");
14422 curr_rloc->priority = p;
14423 curr_rloc->weight = w;
14425 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14428 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14429 vec_add1 (rlocs, rloc);
14430 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14432 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14435 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14436 vec_add1 (rlocs, rloc);
14437 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14439 else if (unformat (input, "action %U",
14440 unformat_negative_mapping_action, &action))
14446 clib_warning ("parse error '%U'", format_unformat_error, input);
14453 errmsg ("missing params!");
14457 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14459 errmsg ("no action set for negative map-reply!");
14463 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
14465 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
14466 mp->is_add = is_add;
14467 mp->vni = htonl (vni);
14468 mp->action = (u8) action;
14469 mp->is_src_dst = seid_set;
14470 mp->eid_len = eid->len;
14471 mp->seid_len = seid->len;
14472 mp->del_all = del_all;
14473 mp->eid_type = eid->type;
14474 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14475 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14477 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14478 clib_memcpy (mp->rlocs, rlocs, data_len);
14484 /* Wait for a reply... */
14489 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
14492 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
14493 * forwarding entries in data-plane accordingly.
14495 * @param vam vpp API test context
14496 * @return return code
14499 api_one_add_del_adjacency (vat_main_t * vam)
14501 unformat_input_t *input = vam->input;
14502 vl_api_one_add_del_adjacency_t *mp;
14504 ip4_address_t leid4, reid4;
14505 ip6_address_t leid6, reid6;
14506 u8 reid_mac[6] = { 0 };
14507 u8 leid_mac[6] = { 0 };
14508 u8 reid_type, leid_type;
14509 u32 leid_len = 0, reid_len = 0, len;
14513 leid_type = reid_type = (u8) ~ 0;
14515 /* Parse args required to build the message */
14516 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14518 if (unformat (input, "del"))
14522 else if (unformat (input, "add"))
14526 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14529 reid_type = 0; /* ipv4 */
14532 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14535 reid_type = 1; /* ipv6 */
14538 else if (unformat (input, "reid %U", unformat_ethernet_address,
14541 reid_type = 2; /* mac */
14543 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14546 leid_type = 0; /* ipv4 */
14549 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14552 leid_type = 1; /* ipv6 */
14555 else if (unformat (input, "leid %U", unformat_ethernet_address,
14558 leid_type = 2; /* mac */
14560 else if (unformat (input, "vni %d", &vni))
14566 errmsg ("parse error '%U'", format_unformat_error, input);
14571 if ((u8) ~ 0 == reid_type)
14573 errmsg ("missing params!");
14577 if (leid_type != reid_type)
14579 errmsg ("remote and local EIDs are of different types!");
14583 M (ONE_ADD_DEL_ADJACENCY, mp);
14584 mp->is_add = is_add;
14585 mp->vni = htonl (vni);
14586 mp->leid_len = leid_len;
14587 mp->reid_len = reid_len;
14588 mp->eid_type = reid_type;
14590 switch (mp->eid_type)
14593 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14594 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14597 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14598 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14601 clib_memcpy (mp->leid, leid_mac, 6);
14602 clib_memcpy (mp->reid, reid_mac, 6);
14605 errmsg ("unknown EID type %d!", mp->eid_type);
14612 /* Wait for a reply... */
14617 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
14620 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
14622 u32 *mode = va_arg (*args, u32 *);
14624 if (unformat (input, "lisp"))
14626 else if (unformat (input, "vxlan"))
14635 api_gpe_get_encap_mode (vat_main_t * vam)
14637 vl_api_gpe_get_encap_mode_t *mp;
14640 /* Construct the API message */
14641 M (GPE_GET_ENCAP_MODE, mp);
14646 /* Wait for a reply... */
14652 api_gpe_set_encap_mode (vat_main_t * vam)
14654 unformat_input_t *input = vam->input;
14655 vl_api_gpe_set_encap_mode_t *mp;
14659 /* Parse args required to build the message */
14660 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14662 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
14668 /* Construct the API message */
14669 M (GPE_SET_ENCAP_MODE, mp);
14676 /* Wait for a reply... */
14682 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14684 unformat_input_t *input = vam->input;
14685 vl_api_gpe_add_del_iface_t *mp;
14686 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14687 u32 dp_table = 0, vni = 0;
14690 /* Parse args required to build the message */
14691 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14693 if (unformat (input, "up"))
14698 else if (unformat (input, "down"))
14703 else if (unformat (input, "table_id %d", &dp_table))
14707 else if (unformat (input, "bd_id %d", &dp_table))
14712 else if (unformat (input, "vni %d", &vni))
14720 if (action_set == 0)
14722 errmsg ("Action not set");
14725 if (dp_table_set == 0 || vni_set == 0)
14727 errmsg ("vni and dp_table must be set");
14731 /* Construct the API message */
14732 M (GPE_ADD_DEL_IFACE, mp);
14734 mp->is_add = is_add;
14735 mp->dp_table = dp_table;
14742 /* Wait for a reply... */
14748 * Add/del map request itr rlocs from ONE control plane and updates
14750 * @param vam vpp API test context
14751 * @return return code
14754 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
14756 unformat_input_t *input = vam->input;
14757 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
14758 u8 *locator_set_name = 0;
14759 u8 locator_set_name_set = 0;
14763 /* Parse args required to build the message */
14764 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14766 if (unformat (input, "del"))
14770 else if (unformat (input, "%_%v%_", &locator_set_name))
14772 locator_set_name_set = 1;
14776 clib_warning ("parse error '%U'", format_unformat_error, input);
14781 if (is_add && !locator_set_name_set)
14783 errmsg ("itr-rloc is not set!");
14787 if (is_add && vec_len (locator_set_name) > 64)
14789 errmsg ("itr-rloc locator-set name too long");
14790 vec_free (locator_set_name);
14794 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
14795 mp->is_add = is_add;
14798 clib_memcpy (mp->locator_set_name, locator_set_name,
14799 vec_len (locator_set_name));
14803 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14805 vec_free (locator_set_name);
14810 /* Wait for a reply... */
14815 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
14818 api_one_locator_dump (vat_main_t * vam)
14820 unformat_input_t *input = vam->input;
14821 vl_api_one_locator_dump_t *mp;
14822 vl_api_control_ping_t *mp_ping;
14823 u8 is_index_set = 0, is_name_set = 0;
14828 /* Parse args required to build the message */
14829 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14831 if (unformat (input, "ls_name %_%v%_", &ls_name))
14835 else if (unformat (input, "ls_index %d", &ls_index))
14841 errmsg ("parse error '%U'", format_unformat_error, input);
14846 if (!is_index_set && !is_name_set)
14848 errmsg ("error: expected one of index or name!");
14852 if (is_index_set && is_name_set)
14854 errmsg ("error: only one param expected!");
14858 if (vec_len (ls_name) > 62)
14860 errmsg ("error: locator set name too long!");
14864 if (!vam->json_output)
14866 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
14869 M (ONE_LOCATOR_DUMP, mp);
14870 mp->is_index_set = is_index_set;
14873 mp->ls_index = clib_host_to_net_u32 (ls_index);
14876 vec_add1 (ls_name, 0);
14877 strncpy ((char *) mp->ls_name, (char *) ls_name,
14878 sizeof (mp->ls_name) - 1);
14884 /* Use a control ping for synchronization */
14885 M (CONTROL_PING, mp_ping);
14888 /* Wait for a reply... */
14893 #define api_lisp_locator_dump api_one_locator_dump
14896 api_one_locator_set_dump (vat_main_t * vam)
14898 vl_api_one_locator_set_dump_t *mp;
14899 vl_api_control_ping_t *mp_ping;
14900 unformat_input_t *input = vam->input;
14904 /* Parse args required to build the message */
14905 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14907 if (unformat (input, "local"))
14911 else if (unformat (input, "remote"))
14917 errmsg ("parse error '%U'", format_unformat_error, input);
14922 if (!vam->json_output)
14924 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
14927 M (ONE_LOCATOR_SET_DUMP, mp);
14929 mp->filter = filter;
14934 /* Use a control ping for synchronization */
14935 M (CONTROL_PING, mp_ping);
14938 /* Wait for a reply... */
14943 #define api_lisp_locator_set_dump api_one_locator_set_dump
14946 api_one_eid_table_map_dump (vat_main_t * vam)
14950 unformat_input_t *input = vam->input;
14951 vl_api_one_eid_table_map_dump_t *mp;
14952 vl_api_control_ping_t *mp_ping;
14955 /* Parse args required to build the message */
14956 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14958 if (unformat (input, "l2"))
14963 else if (unformat (input, "l3"))
14970 errmsg ("parse error '%U'", format_unformat_error, input);
14977 errmsg ("expected one of 'l2' or 'l3' parameter!");
14981 if (!vam->json_output)
14983 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
14986 M (ONE_EID_TABLE_MAP_DUMP, mp);
14992 /* Use a control ping for synchronization */
14993 M (CONTROL_PING, mp_ping);
14996 /* Wait for a reply... */
15001 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
15004 api_one_eid_table_vni_dump (vat_main_t * vam)
15006 vl_api_one_eid_table_vni_dump_t *mp;
15007 vl_api_control_ping_t *mp_ping;
15010 if (!vam->json_output)
15012 print (vam->ofp, "VNI");
15015 M (ONE_EID_TABLE_VNI_DUMP, mp);
15020 /* Use a control ping for synchronization */
15021 M (CONTROL_PING, mp_ping);
15024 /* Wait for a reply... */
15029 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
15032 api_one_eid_table_dump (vat_main_t * vam)
15034 unformat_input_t *i = vam->input;
15035 vl_api_one_eid_table_dump_t *mp;
15036 vl_api_control_ping_t *mp_ping;
15037 struct in_addr ip4;
15038 struct in6_addr ip6;
15040 u8 eid_type = ~0, eid_set = 0;
15041 u32 prefix_length = ~0, t, vni = 0;
15045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15047 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
15053 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
15059 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
15064 else if (unformat (i, "vni %d", &t))
15068 else if (unformat (i, "local"))
15072 else if (unformat (i, "remote"))
15078 errmsg ("parse error '%U'", format_unformat_error, i);
15083 if (!vam->json_output)
15085 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
15086 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
15089 M (ONE_EID_TABLE_DUMP, mp);
15091 mp->filter = filter;
15095 mp->vni = htonl (vni);
15096 mp->eid_type = eid_type;
15100 mp->prefix_length = prefix_length;
15101 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
15104 mp->prefix_length = prefix_length;
15105 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
15108 clib_memcpy (mp->eid, mac, sizeof (mac));
15111 errmsg ("unknown EID type %d!", eid_type);
15119 /* Use a control ping for synchronization */
15120 M (CONTROL_PING, mp_ping);
15123 /* Wait for a reply... */
15128 #define api_lisp_eid_table_dump api_one_eid_table_dump
15131 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
15133 unformat_input_t *i = vam->input;
15134 vl_api_gpe_fwd_entries_get_t *mp;
15139 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15141 if (unformat (i, "vni %d", &vni))
15147 errmsg ("parse error '%U'", format_unformat_error, i);
15154 errmsg ("vni not set!");
15158 if (!vam->json_output)
15160 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15164 M (GPE_FWD_ENTRIES_GET, mp);
15165 mp->vni = clib_host_to_net_u32 (vni);
15170 /* Wait for a reply... */
15175 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15176 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15177 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15178 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
15181 api_one_adjacencies_get (vat_main_t * vam)
15183 unformat_input_t *i = vam->input;
15184 vl_api_one_adjacencies_get_t *mp;
15189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15191 if (unformat (i, "vni %d", &vni))
15197 errmsg ("parse error '%U'", format_unformat_error, i);
15204 errmsg ("vni not set!");
15208 if (!vam->json_output)
15210 print (vam->ofp, "%s %40s", "leid", "reid");
15213 M (ONE_ADJACENCIES_GET, mp);
15214 mp->vni = clib_host_to_net_u32 (vni);
15219 /* Wait for a reply... */
15224 #define api_lisp_adjacencies_get api_one_adjacencies_get
15227 api_one_map_server_dump (vat_main_t * vam)
15229 vl_api_one_map_server_dump_t *mp;
15230 vl_api_control_ping_t *mp_ping;
15233 if (!vam->json_output)
15235 print (vam->ofp, "%=20s", "Map server");
15238 M (ONE_MAP_SERVER_DUMP, mp);
15242 /* Use a control ping for synchronization */
15243 M (CONTROL_PING, mp_ping);
15246 /* Wait for a reply... */
15251 #define api_lisp_map_server_dump api_one_map_server_dump
15254 api_one_map_resolver_dump (vat_main_t * vam)
15256 vl_api_one_map_resolver_dump_t *mp;
15257 vl_api_control_ping_t *mp_ping;
15260 if (!vam->json_output)
15262 print (vam->ofp, "%=20s", "Map resolver");
15265 M (ONE_MAP_RESOLVER_DUMP, mp);
15269 /* Use a control ping for synchronization */
15270 M (CONTROL_PING, mp_ping);
15273 /* Wait for a reply... */
15278 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
15281 api_show_one_status (vat_main_t * vam)
15283 vl_api_show_one_status_t *mp;
15286 if (!vam->json_output)
15288 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
15291 M (SHOW_ONE_STATUS, mp);
15294 /* Wait for a reply... */
15299 #define api_show_lisp_status api_show_one_status
15302 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
15304 vl_api_gpe_fwd_entry_path_dump_t *mp;
15305 vl_api_control_ping_t *mp_ping;
15306 unformat_input_t *i = vam->input;
15307 u32 fwd_entry_index = ~0;
15310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15312 if (unformat (i, "index %d", &fwd_entry_index))
15318 if (~0 == fwd_entry_index)
15320 errmsg ("no index specified!");
15324 if (!vam->json_output)
15326 print (vam->ofp, "first line");
15329 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
15333 /* Use a control ping for synchronization */
15334 M (CONTROL_PING, mp_ping);
15337 /* Wait for a reply... */
15343 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
15345 vl_api_one_get_map_request_itr_rlocs_t *mp;
15348 if (!vam->json_output)
15350 print (vam->ofp, "%=20s", "itr-rlocs:");
15353 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
15356 /* Wait for a reply... */
15361 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
15364 api_af_packet_create (vat_main_t * vam)
15366 unformat_input_t *i = vam->input;
15367 vl_api_af_packet_create_t *mp;
15368 u8 *host_if_name = 0;
15370 u8 random_hw_addr = 1;
15373 memset (hw_addr, 0, sizeof (hw_addr));
15375 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15377 if (unformat (i, "name %s", &host_if_name))
15378 vec_add1 (host_if_name, 0);
15379 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15380 random_hw_addr = 0;
15385 if (!vec_len (host_if_name))
15387 errmsg ("host-interface name must be specified");
15391 if (vec_len (host_if_name) > 64)
15393 errmsg ("host-interface name too long");
15397 M (AF_PACKET_CREATE, mp);
15399 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15400 clib_memcpy (mp->hw_addr, hw_addr, 6);
15401 mp->use_random_hw_addr = random_hw_addr;
15402 vec_free (host_if_name);
15410 fprintf (vam->ofp ? vam->ofp : stderr,
15411 " new sw_if_index = %d\n", vam->sw_if_index);
15418 api_af_packet_delete (vat_main_t * vam)
15420 unformat_input_t *i = vam->input;
15421 vl_api_af_packet_delete_t *mp;
15422 u8 *host_if_name = 0;
15425 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15427 if (unformat (i, "name %s", &host_if_name))
15428 vec_add1 (host_if_name, 0);
15433 if (!vec_len (host_if_name))
15435 errmsg ("host-interface name must be specified");
15439 if (vec_len (host_if_name) > 64)
15441 errmsg ("host-interface name too long");
15445 M (AF_PACKET_DELETE, mp);
15447 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15448 vec_free (host_if_name);
15456 api_policer_add_del (vat_main_t * vam)
15458 unformat_input_t *i = vam->input;
15459 vl_api_policer_add_del_t *mp;
15469 u8 color_aware = 0;
15470 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
15473 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
15474 conform_action.dscp = 0;
15475 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
15476 exceed_action.dscp = 0;
15477 violate_action.action_type = SSE2_QOS_ACTION_DROP;
15478 violate_action.dscp = 0;
15480 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15482 if (unformat (i, "del"))
15484 else if (unformat (i, "name %s", &name))
15485 vec_add1 (name, 0);
15486 else if (unformat (i, "cir %u", &cir))
15488 else if (unformat (i, "eir %u", &eir))
15490 else if (unformat (i, "cb %u", &cb))
15492 else if (unformat (i, "eb %u", &eb))
15494 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
15497 else if (unformat (i, "round_type %U", unformat_policer_round_type,
15500 else if (unformat (i, "type %U", unformat_policer_type, &type))
15502 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
15505 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
15508 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
15511 else if (unformat (i, "color-aware"))
15517 if (!vec_len (name))
15519 errmsg ("policer name must be specified");
15523 if (vec_len (name) > 64)
15525 errmsg ("policer name too long");
15529 M (POLICER_ADD_DEL, mp);
15531 clib_memcpy (mp->name, name, vec_len (name));
15533 mp->is_add = is_add;
15538 mp->rate_type = rate_type;
15539 mp->round_type = round_type;
15541 mp->conform_action_type = conform_action.action_type;
15542 mp->conform_dscp = conform_action.dscp;
15543 mp->exceed_action_type = exceed_action.action_type;
15544 mp->exceed_dscp = exceed_action.dscp;
15545 mp->violate_action_type = violate_action.action_type;
15546 mp->violate_dscp = violate_action.dscp;
15547 mp->color_aware = color_aware;
15555 api_policer_dump (vat_main_t * vam)
15557 unformat_input_t *i = vam->input;
15558 vl_api_policer_dump_t *mp;
15559 vl_api_control_ping_t *mp_ping;
15560 u8 *match_name = 0;
15561 u8 match_name_valid = 0;
15564 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15566 if (unformat (i, "name %s", &match_name))
15568 vec_add1 (match_name, 0);
15569 match_name_valid = 1;
15575 M (POLICER_DUMP, mp);
15576 mp->match_name_valid = match_name_valid;
15577 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15578 vec_free (match_name);
15582 /* Use a control ping for synchronization */
15583 M (CONTROL_PING, mp_ping);
15586 /* Wait for a reply... */
15592 api_policer_classify_set_interface (vat_main_t * vam)
15594 unformat_input_t *i = vam->input;
15595 vl_api_policer_classify_set_interface_t *mp;
15597 int sw_if_index_set;
15598 u32 ip4_table_index = ~0;
15599 u32 ip6_table_index = ~0;
15600 u32 l2_table_index = ~0;
15604 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15606 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15607 sw_if_index_set = 1;
15608 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15609 sw_if_index_set = 1;
15610 else if (unformat (i, "del"))
15612 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15614 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15616 else if (unformat (i, "l2-table %d", &l2_table_index))
15620 clib_warning ("parse error '%U'", format_unformat_error, i);
15625 if (sw_if_index_set == 0)
15627 errmsg ("missing interface name or sw_if_index");
15631 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
15633 mp->sw_if_index = ntohl (sw_if_index);
15634 mp->ip4_table_index = ntohl (ip4_table_index);
15635 mp->ip6_table_index = ntohl (ip6_table_index);
15636 mp->l2_table_index = ntohl (l2_table_index);
15637 mp->is_add = is_add;
15645 api_policer_classify_dump (vat_main_t * vam)
15647 unformat_input_t *i = vam->input;
15648 vl_api_policer_classify_dump_t *mp;
15649 vl_api_control_ping_t *mp_ping;
15650 u8 type = POLICER_CLASSIFY_N_TABLES;
15653 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15657 errmsg ("classify table type must be specified");
15661 if (!vam->json_output)
15663 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15666 M (POLICER_CLASSIFY_DUMP, mp);
15671 /* Use a control ping for synchronization */
15672 M (CONTROL_PING, mp_ping);
15675 /* Wait for a reply... */
15681 api_netmap_create (vat_main_t * vam)
15683 unformat_input_t *i = vam->input;
15684 vl_api_netmap_create_t *mp;
15687 u8 random_hw_addr = 1;
15692 memset (hw_addr, 0, sizeof (hw_addr));
15694 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15696 if (unformat (i, "name %s", &if_name))
15697 vec_add1 (if_name, 0);
15698 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15699 random_hw_addr = 0;
15700 else if (unformat (i, "pipe"))
15702 else if (unformat (i, "master"))
15704 else if (unformat (i, "slave"))
15710 if (!vec_len (if_name))
15712 errmsg ("interface name must be specified");
15716 if (vec_len (if_name) > 64)
15718 errmsg ("interface name too long");
15722 M (NETMAP_CREATE, mp);
15724 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15725 clib_memcpy (mp->hw_addr, hw_addr, 6);
15726 mp->use_random_hw_addr = random_hw_addr;
15727 mp->is_pipe = is_pipe;
15728 mp->is_master = is_master;
15729 vec_free (if_name);
15737 api_netmap_delete (vat_main_t * vam)
15739 unformat_input_t *i = vam->input;
15740 vl_api_netmap_delete_t *mp;
15744 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15746 if (unformat (i, "name %s", &if_name))
15747 vec_add1 (if_name, 0);
15752 if (!vec_len (if_name))
15754 errmsg ("interface name must be specified");
15758 if (vec_len (if_name) > 64)
15760 errmsg ("interface name too long");
15764 M (NETMAP_DELETE, mp);
15766 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15767 vec_free (if_name);
15774 static void vl_api_mpls_tunnel_details_t_handler
15775 (vl_api_mpls_tunnel_details_t * mp)
15777 vat_main_t *vam = &vat_main;
15778 i32 len = mp->mt_next_hop_n_labels;
15781 print (vam->ofp, "[%d]: via %U %d labels ",
15783 format_ip4_address, mp->mt_next_hop,
15784 ntohl (mp->mt_next_hop_sw_if_index));
15785 for (i = 0; i < len; i++)
15787 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15789 print (vam->ofp, "");
15792 static void vl_api_mpls_tunnel_details_t_handler_json
15793 (vl_api_mpls_tunnel_details_t * mp)
15795 vat_main_t *vam = &vat_main;
15796 vat_json_node_t *node = NULL;
15797 struct in_addr ip4;
15799 i32 len = mp->mt_next_hop_n_labels;
15801 if (VAT_JSON_ARRAY != vam->json_tree.type)
15803 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15804 vat_json_init_array (&vam->json_tree);
15806 node = vat_json_array_add (&vam->json_tree);
15808 vat_json_init_object (node);
15809 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15810 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15811 vat_json_object_add_ip4 (node, "next_hop", ip4);
15812 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15813 ntohl (mp->mt_next_hop_sw_if_index));
15814 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15815 vat_json_object_add_uint (node, "label_count", len);
15816 for (i = 0; i < len; i++)
15818 vat_json_object_add_uint (node, "label",
15819 ntohl (mp->mt_next_hop_out_labels[i]));
15824 api_mpls_tunnel_dump (vat_main_t * vam)
15826 vl_api_mpls_tunnel_dump_t *mp;
15827 vl_api_control_ping_t *mp_ping;
15831 /* Parse args required to build the message */
15832 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15834 if (!unformat (vam->input, "tunnel_index %d", &index))
15841 print (vam->ofp, " tunnel_index %d", index);
15843 M (MPLS_TUNNEL_DUMP, mp);
15844 mp->tunnel_index = htonl (index);
15847 /* Use a control ping for synchronization */
15848 M (CONTROL_PING, mp_ping);
15855 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
15856 #define vl_api_mpls_fib_details_t_print vl_noop_handler
15859 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
15861 vat_main_t *vam = &vat_main;
15862 int count = ntohl (mp->count);
15863 vl_api_fib_path2_t *fp;
15867 "table-id %d, label %u, ess_bit %u",
15868 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
15870 for (i = 0; i < count; i++)
15872 if (fp->afi == IP46_TYPE_IP6)
15874 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15875 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15876 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15877 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15878 format_ip6_address, fp->next_hop);
15879 else if (fp->afi == IP46_TYPE_IP4)
15881 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15882 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15883 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15884 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15885 format_ip4_address, fp->next_hop);
15890 static void vl_api_mpls_fib_details_t_handler_json
15891 (vl_api_mpls_fib_details_t * mp)
15893 vat_main_t *vam = &vat_main;
15894 int count = ntohl (mp->count);
15895 vat_json_node_t *node = NULL;
15896 struct in_addr ip4;
15897 struct in6_addr ip6;
15898 vl_api_fib_path2_t *fp;
15901 if (VAT_JSON_ARRAY != vam->json_tree.type)
15903 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15904 vat_json_init_array (&vam->json_tree);
15906 node = vat_json_array_add (&vam->json_tree);
15908 vat_json_init_object (node);
15909 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15910 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
15911 vat_json_object_add_uint (node, "label", ntohl (mp->label));
15912 vat_json_object_add_uint (node, "path_count", count);
15914 for (i = 0; i < count; i++)
15916 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15917 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15918 vat_json_object_add_uint (node, "is_local", fp->is_local);
15919 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15920 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15921 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15922 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15923 if (fp->afi == IP46_TYPE_IP4)
15925 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15926 vat_json_object_add_ip4 (node, "next_hop", ip4);
15928 else if (fp->afi == IP46_TYPE_IP6)
15930 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15931 vat_json_object_add_ip6 (node, "next_hop", ip6);
15937 api_mpls_fib_dump (vat_main_t * vam)
15939 vl_api_mpls_fib_dump_t *mp;
15940 vl_api_control_ping_t *mp_ping;
15943 M (MPLS_FIB_DUMP, mp);
15946 /* Use a control ping for synchronization */
15947 M (CONTROL_PING, mp_ping);
15954 #define vl_api_ip_fib_details_t_endian vl_noop_handler
15955 #define vl_api_ip_fib_details_t_print vl_noop_handler
15958 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
15960 vat_main_t *vam = &vat_main;
15961 int count = ntohl (mp->count);
15962 vl_api_fib_path_t *fp;
15966 "table-id %d, prefix %U/%d",
15967 ntohl (mp->table_id), format_ip4_address, mp->address,
15968 mp->address_length);
15970 for (i = 0; i < count; i++)
15972 if (fp->afi == IP46_TYPE_IP6)
15974 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15975 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15976 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15977 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15978 format_ip6_address, fp->next_hop);
15979 else if (fp->afi == IP46_TYPE_IP4)
15981 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15982 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15983 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15984 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15985 format_ip4_address, fp->next_hop);
15990 static void vl_api_ip_fib_details_t_handler_json
15991 (vl_api_ip_fib_details_t * mp)
15993 vat_main_t *vam = &vat_main;
15994 int count = ntohl (mp->count);
15995 vat_json_node_t *node = NULL;
15996 struct in_addr ip4;
15997 struct in6_addr ip6;
15998 vl_api_fib_path_t *fp;
16001 if (VAT_JSON_ARRAY != vam->json_tree.type)
16003 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16004 vat_json_init_array (&vam->json_tree);
16006 node = vat_json_array_add (&vam->json_tree);
16008 vat_json_init_object (node);
16009 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16010 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
16011 vat_json_object_add_ip4 (node, "prefix", ip4);
16012 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16013 vat_json_object_add_uint (node, "path_count", count);
16015 for (i = 0; i < count; i++)
16017 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16018 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16019 vat_json_object_add_uint (node, "is_local", fp->is_local);
16020 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16021 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16022 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16023 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16024 if (fp->afi == IP46_TYPE_IP4)
16026 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16027 vat_json_object_add_ip4 (node, "next_hop", ip4);
16029 else if (fp->afi == IP46_TYPE_IP6)
16031 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16032 vat_json_object_add_ip6 (node, "next_hop", ip6);
16038 api_ip_fib_dump (vat_main_t * vam)
16040 vl_api_ip_fib_dump_t *mp;
16041 vl_api_control_ping_t *mp_ping;
16044 M (IP_FIB_DUMP, mp);
16047 /* Use a control ping for synchronization */
16048 M (CONTROL_PING, mp_ping);
16056 api_ip_mfib_dump (vat_main_t * vam)
16058 vl_api_ip_mfib_dump_t *mp;
16059 vl_api_control_ping_t *mp_ping;
16062 M (IP_MFIB_DUMP, mp);
16065 /* Use a control ping for synchronization */
16066 M (CONTROL_PING, mp_ping);
16073 static void vl_api_ip_neighbor_details_t_handler
16074 (vl_api_ip_neighbor_details_t * mp)
16076 vat_main_t *vam = &vat_main;
16078 print (vam->ofp, "%c %U %U",
16079 (mp->is_static) ? 'S' : 'D',
16080 format_ethernet_address, &mp->mac_address,
16081 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
16085 static void vl_api_ip_neighbor_details_t_handler_json
16086 (vl_api_ip_neighbor_details_t * mp)
16089 vat_main_t *vam = &vat_main;
16090 vat_json_node_t *node;
16091 struct in_addr ip4;
16092 struct in6_addr ip6;
16094 if (VAT_JSON_ARRAY != vam->json_tree.type)
16096 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16097 vat_json_init_array (&vam->json_tree);
16099 node = vat_json_array_add (&vam->json_tree);
16101 vat_json_init_object (node);
16102 vat_json_object_add_string_copy (node, "flag",
16103 (mp->is_static) ? (u8 *) "static" : (u8 *)
16106 vat_json_object_add_string_copy (node, "link_layer",
16107 format (0, "%U", format_ethernet_address,
16108 &mp->mac_address));
16112 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
16113 vat_json_object_add_ip6 (node, "ip_address", ip6);
16117 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
16118 vat_json_object_add_ip4 (node, "ip_address", ip4);
16123 api_ip_neighbor_dump (vat_main_t * vam)
16125 unformat_input_t *i = vam->input;
16126 vl_api_ip_neighbor_dump_t *mp;
16127 vl_api_control_ping_t *mp_ping;
16129 u32 sw_if_index = ~0;
16132 /* Parse args required to build the message */
16133 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16135 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16137 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16139 else if (unformat (i, "ip6"))
16145 if (sw_if_index == ~0)
16147 errmsg ("missing interface name or sw_if_index");
16151 M (IP_NEIGHBOR_DUMP, mp);
16152 mp->is_ipv6 = (u8) is_ipv6;
16153 mp->sw_if_index = ntohl (sw_if_index);
16156 /* Use a control ping for synchronization */
16157 M (CONTROL_PING, mp_ping);
16164 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
16165 #define vl_api_ip6_fib_details_t_print vl_noop_handler
16168 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
16170 vat_main_t *vam = &vat_main;
16171 int count = ntohl (mp->count);
16172 vl_api_fib_path_t *fp;
16176 "table-id %d, prefix %U/%d",
16177 ntohl (mp->table_id), format_ip6_address, mp->address,
16178 mp->address_length);
16180 for (i = 0; i < count; i++)
16182 if (fp->afi == IP46_TYPE_IP6)
16184 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16185 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16186 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16187 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16188 format_ip6_address, fp->next_hop);
16189 else if (fp->afi == IP46_TYPE_IP4)
16191 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16192 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16193 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16194 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16195 format_ip4_address, fp->next_hop);
16200 static void vl_api_ip6_fib_details_t_handler_json
16201 (vl_api_ip6_fib_details_t * mp)
16203 vat_main_t *vam = &vat_main;
16204 int count = ntohl (mp->count);
16205 vat_json_node_t *node = NULL;
16206 struct in_addr ip4;
16207 struct in6_addr ip6;
16208 vl_api_fib_path_t *fp;
16211 if (VAT_JSON_ARRAY != vam->json_tree.type)
16213 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16214 vat_json_init_array (&vam->json_tree);
16216 node = vat_json_array_add (&vam->json_tree);
16218 vat_json_init_object (node);
16219 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16220 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
16221 vat_json_object_add_ip6 (node, "prefix", ip6);
16222 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16223 vat_json_object_add_uint (node, "path_count", count);
16225 for (i = 0; i < count; i++)
16227 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16228 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16229 vat_json_object_add_uint (node, "is_local", fp->is_local);
16230 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16231 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16232 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16233 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16234 if (fp->afi == IP46_TYPE_IP4)
16236 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16237 vat_json_object_add_ip4 (node, "next_hop", ip4);
16239 else if (fp->afi == IP46_TYPE_IP6)
16241 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16242 vat_json_object_add_ip6 (node, "next_hop", ip6);
16248 api_ip6_fib_dump (vat_main_t * vam)
16250 vl_api_ip6_fib_dump_t *mp;
16251 vl_api_control_ping_t *mp_ping;
16254 M (IP6_FIB_DUMP, mp);
16257 /* Use a control ping for synchronization */
16258 M (CONTROL_PING, mp_ping);
16266 api_ip6_mfib_dump (vat_main_t * vam)
16268 vl_api_ip6_mfib_dump_t *mp;
16269 vl_api_control_ping_t *mp_ping;
16272 M (IP6_MFIB_DUMP, mp);
16275 /* Use a control ping for synchronization */
16276 M (CONTROL_PING, mp_ping);
16284 api_classify_table_ids (vat_main_t * vam)
16286 vl_api_classify_table_ids_t *mp;
16289 /* Construct the API message */
16290 M (CLASSIFY_TABLE_IDS, mp);
16299 api_classify_table_by_interface (vat_main_t * vam)
16301 unformat_input_t *input = vam->input;
16302 vl_api_classify_table_by_interface_t *mp;
16304 u32 sw_if_index = ~0;
16306 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16308 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16310 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16315 if (sw_if_index == ~0)
16317 errmsg ("missing interface name or sw_if_index");
16321 /* Construct the API message */
16322 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
16324 mp->sw_if_index = ntohl (sw_if_index);
16332 api_classify_table_info (vat_main_t * vam)
16334 unformat_input_t *input = vam->input;
16335 vl_api_classify_table_info_t *mp;
16339 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16341 if (unformat (input, "table_id %d", &table_id))
16346 if (table_id == ~0)
16348 errmsg ("missing table id");
16352 /* Construct the API message */
16353 M (CLASSIFY_TABLE_INFO, mp);
16355 mp->table_id = ntohl (table_id);
16363 api_classify_session_dump (vat_main_t * vam)
16365 unformat_input_t *input = vam->input;
16366 vl_api_classify_session_dump_t *mp;
16367 vl_api_control_ping_t *mp_ping;
16371 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16373 if (unformat (input, "table_id %d", &table_id))
16378 if (table_id == ~0)
16380 errmsg ("missing table id");
16384 /* Construct the API message */
16385 M (CLASSIFY_SESSION_DUMP, mp);
16387 mp->table_id = ntohl (table_id);
16390 /* Use a control ping for synchronization */
16391 M (CONTROL_PING, mp_ping);
16399 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
16401 vat_main_t *vam = &vat_main;
16403 print (vam->ofp, "collector_address %U, collector_port %d, "
16404 "src_address %U, vrf_id %d, path_mtu %u, "
16405 "template_interval %u, udp_checksum %d",
16406 format_ip4_address, mp->collector_address,
16407 ntohs (mp->collector_port),
16408 format_ip4_address, mp->src_address,
16409 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
16410 ntohl (mp->template_interval), mp->udp_checksum);
16413 vam->result_ready = 1;
16417 vl_api_ipfix_exporter_details_t_handler_json
16418 (vl_api_ipfix_exporter_details_t * mp)
16420 vat_main_t *vam = &vat_main;
16421 vat_json_node_t node;
16422 struct in_addr collector_address;
16423 struct in_addr src_address;
16425 vat_json_init_object (&node);
16426 clib_memcpy (&collector_address, &mp->collector_address,
16427 sizeof (collector_address));
16428 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
16429 vat_json_object_add_uint (&node, "collector_port",
16430 ntohs (mp->collector_port));
16431 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
16432 vat_json_object_add_ip4 (&node, "src_address", src_address);
16433 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
16434 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
16435 vat_json_object_add_uint (&node, "template_interval",
16436 ntohl (mp->template_interval));
16437 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
16439 vat_json_print (vam->ofp, &node);
16440 vat_json_free (&node);
16442 vam->result_ready = 1;
16446 api_ipfix_exporter_dump (vat_main_t * vam)
16448 vl_api_ipfix_exporter_dump_t *mp;
16451 /* Construct the API message */
16452 M (IPFIX_EXPORTER_DUMP, mp);
16461 api_ipfix_classify_stream_dump (vat_main_t * vam)
16463 vl_api_ipfix_classify_stream_dump_t *mp;
16466 /* Construct the API message */
16467 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
16478 vl_api_ipfix_classify_stream_details_t_handler
16479 (vl_api_ipfix_classify_stream_details_t * mp)
16481 vat_main_t *vam = &vat_main;
16482 print (vam->ofp, "domain_id %d, src_port %d",
16483 ntohl (mp->domain_id), ntohs (mp->src_port));
16485 vam->result_ready = 1;
16489 vl_api_ipfix_classify_stream_details_t_handler_json
16490 (vl_api_ipfix_classify_stream_details_t * mp)
16492 vat_main_t *vam = &vat_main;
16493 vat_json_node_t node;
16495 vat_json_init_object (&node);
16496 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
16497 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
16499 vat_json_print (vam->ofp, &node);
16500 vat_json_free (&node);
16502 vam->result_ready = 1;
16506 api_ipfix_classify_table_dump (vat_main_t * vam)
16508 vl_api_ipfix_classify_table_dump_t *mp;
16509 vl_api_control_ping_t *mp_ping;
16512 if (!vam->json_output)
16514 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
16515 "transport_protocol");
16518 /* Construct the API message */
16519 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
16524 /* Use a control ping for synchronization */
16525 M (CONTROL_PING, mp_ping);
16533 vl_api_ipfix_classify_table_details_t_handler
16534 (vl_api_ipfix_classify_table_details_t * mp)
16536 vat_main_t *vam = &vat_main;
16537 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
16538 mp->transport_protocol);
16542 vl_api_ipfix_classify_table_details_t_handler_json
16543 (vl_api_ipfix_classify_table_details_t * mp)
16545 vat_json_node_t *node = NULL;
16546 vat_main_t *vam = &vat_main;
16548 if (VAT_JSON_ARRAY != vam->json_tree.type)
16550 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16551 vat_json_init_array (&vam->json_tree);
16554 node = vat_json_array_add (&vam->json_tree);
16555 vat_json_init_object (node);
16557 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
16558 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
16559 vat_json_object_add_uint (node, "transport_protocol",
16560 mp->transport_protocol);
16564 api_sw_interface_span_enable_disable (vat_main_t * vam)
16566 unformat_input_t *i = vam->input;
16567 vl_api_sw_interface_span_enable_disable_t *mp;
16568 u32 src_sw_if_index = ~0;
16569 u32 dst_sw_if_index = ~0;
16573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16576 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
16578 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
16582 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
16584 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16586 else if (unformat (i, "disable"))
16588 else if (unformat (i, "rx"))
16590 else if (unformat (i, "tx"))
16592 else if (unformat (i, "both"))
16598 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
16600 mp->sw_if_index_from = htonl (src_sw_if_index);
16601 mp->sw_if_index_to = htonl (dst_sw_if_index);
16610 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16613 vat_main_t *vam = &vat_main;
16614 u8 *sw_if_from_name = 0;
16615 u8 *sw_if_to_name = 0;
16616 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16617 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16618 char *states[] = { "none", "rx", "tx", "both" };
16622 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16624 if ((u32) p->value[0] == sw_if_index_from)
16626 sw_if_from_name = (u8 *)(p->key);
16630 if ((u32) p->value[0] == sw_if_index_to)
16632 sw_if_to_name = (u8 *)(p->key);
16633 if (sw_if_from_name)
16638 print (vam->ofp, "%20s => %20s (%s)",
16639 sw_if_from_name, sw_if_to_name, states[mp->state]);
16643 vl_api_sw_interface_span_details_t_handler_json
16644 (vl_api_sw_interface_span_details_t * mp)
16646 vat_main_t *vam = &vat_main;
16647 vat_json_node_t *node = NULL;
16648 u8 *sw_if_from_name = 0;
16649 u8 *sw_if_to_name = 0;
16650 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16651 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16655 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16657 if ((u32) p->value[0] == sw_if_index_from)
16659 sw_if_from_name = (u8 *)(p->key);
16663 if ((u32) p->value[0] == sw_if_index_to)
16665 sw_if_to_name = (u8 *)(p->key);
16666 if (sw_if_from_name)
16672 if (VAT_JSON_ARRAY != vam->json_tree.type)
16674 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16675 vat_json_init_array (&vam->json_tree);
16677 node = vat_json_array_add (&vam->json_tree);
16679 vat_json_init_object (node);
16680 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16681 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16682 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16683 if (0 != sw_if_to_name)
16685 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16687 vat_json_object_add_uint (node, "state", mp->state);
16691 api_sw_interface_span_dump (vat_main_t * vam)
16693 vl_api_sw_interface_span_dump_t *mp;
16694 vl_api_control_ping_t *mp_ping;
16697 M (SW_INTERFACE_SPAN_DUMP, mp);
16700 /* Use a control ping for synchronization */
16701 M (CONTROL_PING, mp_ping);
16709 api_pg_create_interface (vat_main_t * vam)
16711 unformat_input_t *input = vam->input;
16712 vl_api_pg_create_interface_t *mp;
16716 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16718 if (unformat (input, "if_id %d", &if_id))
16725 errmsg ("missing pg interface index");
16729 /* Construct the API message */
16730 M (PG_CREATE_INTERFACE, mp);
16732 mp->interface_id = ntohl (if_id);
16740 api_pg_capture (vat_main_t * vam)
16742 unformat_input_t *input = vam->input;
16743 vl_api_pg_capture_t *mp;
16748 u8 pcap_file_set = 0;
16751 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16753 if (unformat (input, "if_id %d", &if_id))
16755 else if (unformat (input, "pcap %s", &pcap_file))
16757 else if (unformat (input, "count %d", &count))
16759 else if (unformat (input, "disable"))
16766 errmsg ("missing pg interface index");
16769 if (pcap_file_set > 0)
16771 if (vec_len (pcap_file) > 255)
16773 errmsg ("pcap file name is too long");
16778 u32 name_len = vec_len (pcap_file);
16779 /* Construct the API message */
16780 M (PG_CAPTURE, mp);
16782 mp->interface_id = ntohl (if_id);
16783 mp->is_enabled = enable;
16784 mp->count = ntohl (count);
16785 mp->pcap_name_length = ntohl (name_len);
16786 if (pcap_file_set != 0)
16788 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16790 vec_free (pcap_file);
16798 api_pg_enable_disable (vat_main_t * vam)
16800 unformat_input_t *input = vam->input;
16801 vl_api_pg_enable_disable_t *mp;
16804 u8 stream_name_set = 0;
16805 u8 *stream_name = 0;
16807 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16809 if (unformat (input, "stream %s", &stream_name))
16810 stream_name_set = 1;
16811 else if (unformat (input, "disable"))
16817 if (stream_name_set > 0)
16819 if (vec_len (stream_name) > 255)
16821 errmsg ("stream name too long");
16826 u32 name_len = vec_len (stream_name);
16827 /* Construct the API message */
16828 M (PG_ENABLE_DISABLE, mp);
16830 mp->is_enabled = enable;
16831 if (stream_name_set != 0)
16833 mp->stream_name_length = ntohl (name_len);
16834 clib_memcpy (mp->stream_name, stream_name, name_len);
16836 vec_free (stream_name);
16844 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16846 unformat_input_t *input = vam->input;
16847 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16849 u16 *low_ports = 0;
16850 u16 *high_ports = 0;
16853 ip4_address_t ip4_addr;
16854 ip6_address_t ip6_addr;
16863 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16865 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
16871 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
16876 else if (unformat (input, "vrf %d", &vrf_id))
16878 else if (unformat (input, "del"))
16880 else if (unformat (input, "port %d", &tmp))
16882 if (tmp == 0 || tmp > 65535)
16884 errmsg ("port %d out of range", tmp);
16888 this_hi = this_low + 1;
16889 vec_add1 (low_ports, this_low);
16890 vec_add1 (high_ports, this_hi);
16892 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
16894 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
16896 errmsg ("incorrect range parameters");
16900 /* Note: in debug CLI +1 is added to high before
16901 passing to real fn that does "the work"
16902 (ip_source_and_port_range_check_add_del).
16903 This fn is a wrapper around the binary API fn a
16904 control plane will call, which expects this increment
16905 to have occurred. Hence letting the binary API control
16906 plane fn do the increment for consistency between VAT
16907 and other control planes.
16910 vec_add1 (low_ports, this_low);
16911 vec_add1 (high_ports, this_hi);
16917 if (prefix_set == 0)
16919 errmsg ("<address>/<mask> not specified");
16925 errmsg ("VRF ID required, not specified");
16932 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16936 if (vec_len (low_ports) == 0)
16938 errmsg ("At least one port or port range required");
16942 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
16944 mp->is_add = is_add;
16949 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
16954 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
16957 mp->mask_length = length;
16958 mp->number_of_ranges = vec_len (low_ports);
16960 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
16961 vec_free (low_ports);
16963 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
16964 vec_free (high_ports);
16966 mp->vrf_id = ntohl (vrf_id);
16974 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
16976 unformat_input_t *input = vam->input;
16977 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
16978 u32 sw_if_index = ~0;
16980 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
16981 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
16985 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16987 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16989 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16991 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
16993 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
16995 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
16997 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
16999 else if (unformat (input, "del"))
17005 if (sw_if_index == ~0)
17007 errmsg ("Interface required but not specified");
17013 errmsg ("VRF ID required but not specified");
17017 if (tcp_out_vrf_id == 0
17018 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
17021 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17025 /* Construct the API message */
17026 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
17028 mp->sw_if_index = ntohl (sw_if_index);
17029 mp->is_add = is_add;
17030 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
17031 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
17032 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
17033 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
17038 /* Wait for a reply... */
17044 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
17046 unformat_input_t *i = vam->input;
17047 vl_api_ipsec_gre_add_del_tunnel_t *mp;
17048 u32 local_sa_id = 0;
17049 u32 remote_sa_id = 0;
17050 ip4_address_t src_address;
17051 ip4_address_t dst_address;
17055 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17057 if (unformat (i, "local_sa %d", &local_sa_id))
17059 else if (unformat (i, "remote_sa %d", &remote_sa_id))
17061 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
17063 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
17065 else if (unformat (i, "del"))
17069 clib_warning ("parse error '%U'", format_unformat_error, i);
17074 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
17076 mp->local_sa_id = ntohl (local_sa_id);
17077 mp->remote_sa_id = ntohl (remote_sa_id);
17078 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
17079 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
17080 mp->is_add = is_add;
17088 api_punt (vat_main_t * vam)
17090 unformat_input_t *i = vam->input;
17098 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17100 if (unformat (i, "ip %d", &ipv))
17102 else if (unformat (i, "protocol %d", &protocol))
17104 else if (unformat (i, "port %d", &port))
17106 else if (unformat (i, "del"))
17110 clib_warning ("parse error '%U'", format_unformat_error, i);
17117 mp->is_add = (u8) is_add;
17118 mp->ipv = (u8) ipv;
17119 mp->l4_protocol = (u8) protocol;
17120 mp->l4_port = htons ((u16) port);
17127 static void vl_api_ipsec_gre_tunnel_details_t_handler
17128 (vl_api_ipsec_gre_tunnel_details_t * mp)
17130 vat_main_t *vam = &vat_main;
17132 print (vam->ofp, "%11d%15U%15U%14d%14d",
17133 ntohl (mp->sw_if_index),
17134 format_ip4_address, &mp->src_address,
17135 format_ip4_address, &mp->dst_address,
17136 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
17139 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
17140 (vl_api_ipsec_gre_tunnel_details_t * mp)
17142 vat_main_t *vam = &vat_main;
17143 vat_json_node_t *node = NULL;
17144 struct in_addr ip4;
17146 if (VAT_JSON_ARRAY != vam->json_tree.type)
17148 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17149 vat_json_init_array (&vam->json_tree);
17151 node = vat_json_array_add (&vam->json_tree);
17153 vat_json_init_object (node);
17154 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17155 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
17156 vat_json_object_add_ip4 (node, "src_address", ip4);
17157 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
17158 vat_json_object_add_ip4 (node, "dst_address", ip4);
17159 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
17160 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
17164 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
17166 unformat_input_t *i = vam->input;
17167 vl_api_ipsec_gre_tunnel_dump_t *mp;
17168 vl_api_control_ping_t *mp_ping;
17170 u8 sw_if_index_set = 0;
17173 /* Parse args required to build the message */
17174 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17176 if (unformat (i, "sw_if_index %d", &sw_if_index))
17177 sw_if_index_set = 1;
17182 if (sw_if_index_set == 0)
17187 if (!vam->json_output)
17189 print (vam->ofp, "%11s%15s%15s%14s%14s",
17190 "sw_if_index", "src_address", "dst_address",
17191 "local_sa_id", "remote_sa_id");
17194 /* Get list of gre-tunnel interfaces */
17195 M (IPSEC_GRE_TUNNEL_DUMP, mp);
17197 mp->sw_if_index = htonl (sw_if_index);
17201 /* Use a control ping for synchronization */
17202 M (CONTROL_PING, mp_ping);
17210 api_delete_subif (vat_main_t * vam)
17212 unformat_input_t *i = vam->input;
17213 vl_api_delete_subif_t *mp;
17214 u32 sw_if_index = ~0;
17217 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17219 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17221 if (unformat (i, "sw_if_index %d", &sw_if_index))
17227 if (sw_if_index == ~0)
17229 errmsg ("missing sw_if_index");
17233 /* Construct the API message */
17234 M (DELETE_SUBIF, mp);
17235 mp->sw_if_index = ntohl (sw_if_index);
17242 #define foreach_pbb_vtr_op \
17243 _("disable", L2_VTR_DISABLED) \
17244 _("pop", L2_VTR_POP_2) \
17245 _("push", L2_VTR_PUSH_2)
17248 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
17250 unformat_input_t *i = vam->input;
17251 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
17252 u32 sw_if_index = ~0, vtr_op = ~0;
17253 u16 outer_tag = ~0;
17254 u8 dmac[6], smac[6];
17255 u8 dmac_set = 0, smac_set = 0;
17261 /* Shut up coverity */
17262 memset (dmac, 0, sizeof (dmac));
17263 memset (smac, 0, sizeof (smac));
17265 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17267 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17269 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17271 else if (unformat (i, "vtr_op %d", &vtr_op))
17273 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
17276 else if (unformat (i, "translate_pbb_stag"))
17278 if (unformat (i, "%d", &tmp))
17280 vtr_op = L2_VTR_TRANSLATE_2_1;
17286 ("translate_pbb_stag operation requires outer tag definition");
17290 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
17292 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
17294 else if (unformat (i, "sid %d", &sid))
17296 else if (unformat (i, "vlanid %d", &tmp))
17300 clib_warning ("parse error '%U'", format_unformat_error, i);
17305 if ((sw_if_index == ~0) || (vtr_op == ~0))
17307 errmsg ("missing sw_if_index or vtr operation");
17310 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
17311 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
17314 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
17318 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
17319 mp->sw_if_index = ntohl (sw_if_index);
17320 mp->vtr_op = ntohl (vtr_op);
17321 mp->outer_tag = ntohs (outer_tag);
17322 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
17323 clib_memcpy (mp->b_smac, smac, sizeof (smac));
17324 mp->b_vlanid = ntohs (vlanid);
17325 mp->i_sid = ntohl (sid);
17333 api_flow_classify_set_interface (vat_main_t * vam)
17335 unformat_input_t *i = vam->input;
17336 vl_api_flow_classify_set_interface_t *mp;
17338 int sw_if_index_set;
17339 u32 ip4_table_index = ~0;
17340 u32 ip6_table_index = ~0;
17344 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17346 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17347 sw_if_index_set = 1;
17348 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17349 sw_if_index_set = 1;
17350 else if (unformat (i, "del"))
17352 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17354 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17358 clib_warning ("parse error '%U'", format_unformat_error, i);
17363 if (sw_if_index_set == 0)
17365 errmsg ("missing interface name or sw_if_index");
17369 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
17371 mp->sw_if_index = ntohl (sw_if_index);
17372 mp->ip4_table_index = ntohl (ip4_table_index);
17373 mp->ip6_table_index = ntohl (ip6_table_index);
17374 mp->is_add = is_add;
17382 api_flow_classify_dump (vat_main_t * vam)
17384 unformat_input_t *i = vam->input;
17385 vl_api_flow_classify_dump_t *mp;
17386 vl_api_control_ping_t *mp_ping;
17387 u8 type = FLOW_CLASSIFY_N_TABLES;
17390 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
17394 errmsg ("classify table type must be specified");
17398 if (!vam->json_output)
17400 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17403 M (FLOW_CLASSIFY_DUMP, mp);
17408 /* Use a control ping for synchronization */
17409 M (CONTROL_PING, mp_ping);
17412 /* Wait for a reply... */
17418 api_feature_enable_disable (vat_main_t * vam)
17420 unformat_input_t *i = vam->input;
17421 vl_api_feature_enable_disable_t *mp;
17423 u8 *feature_name = 0;
17424 u32 sw_if_index = ~0;
17428 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17430 if (unformat (i, "arc_name %s", &arc_name))
17432 else if (unformat (i, "feature_name %s", &feature_name))
17435 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17437 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17439 else if (unformat (i, "disable"))
17447 errmsg ("missing arc name");
17450 if (vec_len (arc_name) > 63)
17452 errmsg ("arc name too long");
17455 if (feature_name == 0)
17457 errmsg ("missing feature name");
17460 if (vec_len (feature_name) > 63)
17462 errmsg ("feature name too long");
17465 if (sw_if_index == ~0)
17467 errmsg ("missing interface name or sw_if_index");
17471 /* Construct the API message */
17472 M (FEATURE_ENABLE_DISABLE, mp);
17473 mp->sw_if_index = ntohl (sw_if_index);
17474 mp->enable = enable;
17475 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
17476 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
17477 vec_free (arc_name);
17478 vec_free (feature_name);
17486 api_sw_interface_tag_add_del (vat_main_t * vam)
17488 unformat_input_t *i = vam->input;
17489 vl_api_sw_interface_tag_add_del_t *mp;
17490 u32 sw_if_index = ~0;
17495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17497 if (unformat (i, "tag %s", &tag))
17499 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17501 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17503 else if (unformat (i, "del"))
17509 if (sw_if_index == ~0)
17511 errmsg ("missing interface name or sw_if_index");
17515 if (enable && (tag == 0))
17517 errmsg ("no tag specified");
17521 /* Construct the API message */
17522 M (SW_INTERFACE_TAG_ADD_DEL, mp);
17523 mp->sw_if_index = ntohl (sw_if_index);
17524 mp->is_add = enable;
17526 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
17534 static void vl_api_l2_xconnect_details_t_handler
17535 (vl_api_l2_xconnect_details_t * mp)
17537 vat_main_t *vam = &vat_main;
17539 print (vam->ofp, "%15d%15d",
17540 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
17543 static void vl_api_l2_xconnect_details_t_handler_json
17544 (vl_api_l2_xconnect_details_t * mp)
17546 vat_main_t *vam = &vat_main;
17547 vat_json_node_t *node = NULL;
17549 if (VAT_JSON_ARRAY != vam->json_tree.type)
17551 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17552 vat_json_init_array (&vam->json_tree);
17554 node = vat_json_array_add (&vam->json_tree);
17556 vat_json_init_object (node);
17557 vat_json_object_add_uint (node, "rx_sw_if_index",
17558 ntohl (mp->rx_sw_if_index));
17559 vat_json_object_add_uint (node, "tx_sw_if_index",
17560 ntohl (mp->tx_sw_if_index));
17564 api_l2_xconnect_dump (vat_main_t * vam)
17566 vl_api_l2_xconnect_dump_t *mp;
17567 vl_api_control_ping_t *mp_ping;
17570 if (!vam->json_output)
17572 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
17575 M (L2_XCONNECT_DUMP, mp);
17579 /* Use a control ping for synchronization */
17580 M (CONTROL_PING, mp_ping);
17588 api_sw_interface_set_mtu (vat_main_t * vam)
17590 unformat_input_t *i = vam->input;
17591 vl_api_sw_interface_set_mtu_t *mp;
17592 u32 sw_if_index = ~0;
17596 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17598 if (unformat (i, "mtu %d", &mtu))
17600 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17602 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17608 if (sw_if_index == ~0)
17610 errmsg ("missing interface name or sw_if_index");
17616 errmsg ("no mtu specified");
17620 /* Construct the API message */
17621 M (SW_INTERFACE_SET_MTU, mp);
17622 mp->sw_if_index = ntohl (sw_if_index);
17623 mp->mtu = ntohs ((u16) mtu);
17632 q_or_quit (vat_main_t * vam)
17634 #if VPP_API_TEST_BUILTIN == 0
17635 longjmp (vam->jump_buf, 1);
17637 return 0; /* not so much */
17641 q (vat_main_t * vam)
17643 return q_or_quit (vam);
17647 quit (vat_main_t * vam)
17649 return q_or_quit (vam);
17653 comment (vat_main_t * vam)
17659 cmd_cmp (void *a1, void *a2)
17664 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17668 help (vat_main_t * vam)
17673 unformat_input_t *i = vam->input;
17676 if (unformat (i, "%s", &name))
17680 vec_add1 (name, 0);
17682 hs = hash_get_mem (vam->help_by_name, name);
17684 print (vam->ofp, "usage: %s %s", name, hs[0]);
17686 print (vam->ofp, "No such msg / command '%s'", name);
17691 print (vam->ofp, "Help is available for the following:");
17694 hash_foreach_pair (p, vam->function_by_name,
17696 vec_add1 (cmds, (u8 *)(p->key));
17700 vec_sort_with_function (cmds, cmd_cmp);
17702 for (j = 0; j < vec_len (cmds); j++)
17703 print (vam->ofp, "%s", cmds[j]);
17710 set (vat_main_t * vam)
17712 u8 *name = 0, *value = 0;
17713 unformat_input_t *i = vam->input;
17715 if (unformat (i, "%s", &name))
17717 /* The input buffer is a vector, not a string. */
17718 value = vec_dup (i->buffer);
17719 vec_delete (value, i->index, 0);
17720 /* Almost certainly has a trailing newline */
17721 if (value[vec_len (value) - 1] == '\n')
17722 value[vec_len (value) - 1] = 0;
17723 /* Make sure it's a proper string, one way or the other */
17724 vec_add1 (value, 0);
17725 (void) clib_macro_set_value (&vam->macro_main,
17726 (char *) name, (char *) value);
17729 errmsg ("usage: set <name> <value>");
17737 unset (vat_main_t * vam)
17741 if (unformat (vam->input, "%s", &name))
17742 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17743 errmsg ("unset: %s wasn't set", name);
17756 macro_sort_cmp (void *a1, void *a2)
17758 macro_sort_t *s1 = a1;
17759 macro_sort_t *s2 = a2;
17761 return strcmp ((char *) (s1->name), (char *) (s2->name));
17765 dump_macro_table (vat_main_t * vam)
17767 macro_sort_t *sort_me = 0, *sm;
17772 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17774 vec_add2 (sort_me, sm, 1);
17775 sm->name = (u8 *)(p->key);
17776 sm->value = (u8 *) (p->value[0]);
17780 vec_sort_with_function (sort_me, macro_sort_cmp);
17782 if (vec_len (sort_me))
17783 print (vam->ofp, "%-15s%s", "Name", "Value");
17785 print (vam->ofp, "The macro table is empty...");
17787 for (i = 0; i < vec_len (sort_me); i++)
17788 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17793 dump_node_table (vat_main_t * vam)
17796 vlib_node_t *node, *next_node;
17798 if (vec_len (vam->graph_nodes) == 0)
17800 print (vam->ofp, "Node table empty, issue get_node_graph...");
17804 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17806 node = vam->graph_nodes[i];
17807 print (vam->ofp, "[%d] %s", i, node->name);
17808 for (j = 0; j < vec_len (node->next_nodes); j++)
17810 if (node->next_nodes[j] != ~0)
17812 next_node = vam->graph_nodes[node->next_nodes[j]];
17813 print (vam->ofp, " [%d] %s", j, next_node->name);
17821 value_sort_cmp (void *a1, void *a2)
17823 name_sort_t *n1 = a1;
17824 name_sort_t *n2 = a2;
17826 if (n1->value < n2->value)
17828 if (n1->value > n2->value)
17835 dump_msg_api_table (vat_main_t * vam)
17837 api_main_t *am = &api_main;
17838 name_sort_t *nses = 0, *ns;
17843 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17845 vec_add2 (nses, ns, 1);
17846 ns->name = (u8 *)(hp->key);
17847 ns->value = (u32) hp->value[0];
17851 vec_sort_with_function (nses, value_sort_cmp);
17853 for (i = 0; i < vec_len (nses); i++)
17854 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
17860 get_msg_id (vat_main_t * vam)
17865 if (unformat (vam->input, "%s", &name_and_crc))
17867 message_index = vl_api_get_msg_index (name_and_crc);
17868 if (message_index == ~0)
17870 print (vam->ofp, " '%s' not found", name_and_crc);
17873 print (vam->ofp, " '%s' has message index %d",
17874 name_and_crc, message_index);
17877 errmsg ("name_and_crc required...");
17882 search_node_table (vat_main_t * vam)
17884 unformat_input_t *line_input = vam->input;
17887 vlib_node_t *node, *next_node;
17890 if (vam->graph_node_index_by_name == 0)
17892 print (vam->ofp, "Node table empty, issue get_node_graph...");
17896 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
17898 if (unformat (line_input, "%s", &node_to_find))
17900 vec_add1 (node_to_find, 0);
17901 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
17904 print (vam->ofp, "%s not found...", node_to_find);
17907 node = vam->graph_nodes[p[0]];
17908 print (vam->ofp, "[%d] %s", p[0], node->name);
17909 for (j = 0; j < vec_len (node->next_nodes); j++)
17911 if (node->next_nodes[j] != ~0)
17913 next_node = vam->graph_nodes[node->next_nodes[j]];
17914 print (vam->ofp, " [%d] %s", j, next_node->name);
17921 clib_warning ("parse error '%U'", format_unformat_error,
17927 vec_free (node_to_find);
17936 script (vat_main_t * vam)
17938 #if (VPP_API_TEST_BUILTIN==0)
17940 char *save_current_file;
17941 unformat_input_t save_input;
17942 jmp_buf save_jump_buf;
17943 u32 save_line_number;
17945 FILE *new_fp, *save_ifp;
17947 if (unformat (vam->input, "%s", &s))
17949 new_fp = fopen ((char *) s, "r");
17952 errmsg ("Couldn't open script file %s", s);
17959 errmsg ("Missing script name");
17963 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
17964 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
17965 save_ifp = vam->ifp;
17966 save_line_number = vam->input_line_number;
17967 save_current_file = (char *) vam->current_file;
17969 vam->input_line_number = 0;
17971 vam->current_file = s;
17974 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
17975 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
17976 vam->ifp = save_ifp;
17977 vam->input_line_number = save_line_number;
17978 vam->current_file = (u8 *) save_current_file;
17983 clib_warning ("use the exec command...");
17989 echo (vat_main_t * vam)
17991 print (vam->ofp, "%v", vam->input->buffer);
17995 /* List of API message constructors, CLI names map to api_xxx */
17996 #define foreach_vpe_api_msg \
17997 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
17998 _(sw_interface_dump,"") \
17999 _(sw_interface_set_flags, \
18000 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
18001 _(sw_interface_add_del_address, \
18002 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
18003 _(sw_interface_set_table, \
18004 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
18005 _(sw_interface_set_mpls_enable, \
18006 "<intfc> | sw_if_index [disable | dis]") \
18007 _(sw_interface_set_vpath, \
18008 "<intfc> | sw_if_index <id> enable | disable") \
18009 _(sw_interface_set_vxlan_bypass, \
18010 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
18011 _(sw_interface_set_l2_xconnect, \
18012 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18013 "enable | disable") \
18014 _(sw_interface_set_l2_bridge, \
18015 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
18016 "[shg <split-horizon-group>] [bvi]\n" \
18017 "enable | disable") \
18018 _(bridge_domain_add_del, \
18019 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
18020 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
18022 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
18024 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
18026 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
18028 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
18030 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
18032 "<vpp-if-name> | sw_if_index <id>") \
18033 _(sw_interface_tap_dump, "") \
18034 _(ip_add_del_route, \
18035 "<addr>/<mask> via <addr> [table-id <n>]\n" \
18036 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18037 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18038 "[multipath] [count <n>]") \
18039 _(ip_mroute_add_del, \
18040 "<src> <grp>/<mask> [table-id <n>]\n" \
18041 "[<intfc> | sw_if_index <id>] [local] [del]") \
18042 _(mpls_route_add_del, \
18043 "<label> <eos> via <addr> [table-id <n>]\n" \
18044 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18045 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18046 "[multipath] [count <n>]") \
18047 _(mpls_ip_bind_unbind, \
18048 "<label> <addr/len>") \
18049 _(mpls_tunnel_add_del, \
18050 " via <addr> [table-id <n>]\n" \
18051 "sw_if_index <id>] [l2] [del]") \
18052 _(proxy_arp_add_del, \
18053 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
18054 _(proxy_arp_intfc_enable_disable, \
18055 "<intfc> | sw_if_index <id> enable | disable") \
18056 _(sw_interface_set_unnumbered, \
18057 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
18058 _(ip_neighbor_add_del, \
18059 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
18060 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
18061 _(reset_vrf, "vrf <id> [ipv6]") \
18062 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
18063 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
18064 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
18065 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
18066 "[outer_vlan_id_any][inner_vlan_id_any]") \
18067 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
18068 _(reset_fib, "vrf <n> [ipv6]") \
18069 _(dhcp_proxy_config, \
18070 "svr <v46-address> src <v46-address>\n" \
18071 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
18072 _(dhcp_proxy_set_vss, \
18073 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
18074 _(dhcp_proxy_dump, "ip6") \
18075 _(dhcp_client_config, \
18076 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
18077 _(set_ip_flow_hash, \
18078 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
18079 _(sw_interface_ip6_enable_disable, \
18080 "<intfc> | sw_if_index <id> enable | disable") \
18081 _(sw_interface_ip6_set_link_local_address, \
18082 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
18083 _(ip6nd_proxy_add_del, \
18084 "<intfc> | sw_if_index <id> <ip6-address>") \
18085 _(ip6nd_proxy_dump, "") \
18086 _(sw_interface_ip6nd_ra_prefix, \
18087 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
18088 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
18089 "[nolink] [isno]") \
18090 _(sw_interface_ip6nd_ra_config, \
18091 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
18092 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
18093 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
18094 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
18095 _(l2_patch_add_del, \
18096 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18097 "enable | disable") \
18098 _(sr_localsid_add_del, \
18099 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
18100 "fib-table <num> (end.psp) sw_if_index <num>") \
18101 _(classify_add_del_table, \
18102 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
18103 " [del] [del-chain] mask <mask-value>\n" \
18104 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
18105 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
18106 _(classify_add_del_session, \
18107 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
18108 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
18109 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
18110 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
18111 _(classify_set_interface_ip_table, \
18112 "<intfc> | sw_if_index <nn> table <nn>") \
18113 _(classify_set_interface_l2_tables, \
18114 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18115 " [other-table <nn>]") \
18116 _(get_node_index, "node <node-name") \
18117 _(add_node_next, "node <node-name> next <next-node-name>") \
18118 _(l2tpv3_create_tunnel, \
18119 "client_address <ip6-addr> our_address <ip6-addr>\n" \
18120 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
18121 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
18122 _(l2tpv3_set_tunnel_cookies, \
18123 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
18124 "[new_remote_cookie <nn>]\n") \
18125 _(l2tpv3_interface_enable_disable, \
18126 "<intfc> | sw_if_index <nn> enable | disable") \
18127 _(l2tpv3_set_lookup_key, \
18128 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
18129 _(sw_if_l2tpv3_tunnel_dump, "") \
18130 _(vxlan_add_del_tunnel, \
18131 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
18132 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
18133 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
18134 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18135 _(gre_add_del_tunnel, \
18136 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
18137 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18138 _(l2_fib_clear_table, "") \
18139 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
18140 _(l2_interface_vlan_tag_rewrite, \
18141 "<intfc> | sw_if_index <nn> \n" \
18142 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
18143 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
18144 _(create_vhost_user_if, \
18145 "socket <filename> [server] [renumber <dev_instance>] " \
18146 "[mac <mac_address>]") \
18147 _(modify_vhost_user_if, \
18148 "<intfc> | sw_if_index <nn> socket <filename>\n" \
18149 "[server] [renumber <dev_instance>]") \
18150 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
18151 _(sw_interface_vhost_user_dump, "") \
18152 _(show_version, "") \
18153 _(vxlan_gpe_add_del_tunnel, \
18154 "local <addr> remote <addr> vni <nn>\n" \
18155 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
18156 "[next-ethernet] [next-nsh]\n") \
18157 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18158 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
18159 _(interface_name_renumber, \
18160 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
18161 _(input_acl_set_interface, \
18162 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18163 " [l2-table <nn>] [del]") \
18164 _(want_ip4_arp_events, "address <ip4-address> [del]") \
18165 _(want_ip6_nd_events, "address <ip6-address> [del]") \
18166 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
18167 _(ip_dump, "ipv4 | ipv6") \
18168 _(ipsec_spd_add_del, "spd_id <n> [del]") \
18169 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
18171 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
18172 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
18173 " integ_alg <alg> integ_key <hex>") \
18174 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
18175 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
18176 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
18177 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
18178 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
18179 _(ikev2_profile_add_del, "name <profile_name> [del]") \
18180 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
18181 "(auth_data 0x<data> | auth_data <data>)") \
18182 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
18183 "(id_data 0x<data> | id_data <data>) (local|remote)") \
18184 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
18185 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
18186 "(local|remote)") \
18187 _(ikev2_set_local_key, "file <absolute_file_path>") \
18188 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
18189 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18190 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18191 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
18192 _(ikev2_initiate_sa_init, "<profile_name>") \
18193 _(ikev2_initiate_del_ike_sa, "<ispi>") \
18194 _(ikev2_initiate_del_child_sa, "<ispi>") \
18195 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
18196 _(delete_loopback,"sw_if_index <nn>") \
18197 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
18198 _(map_add_domain, \
18199 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
18200 "ip6-src <ip6addr> " \
18201 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
18202 _(map_del_domain, "index <n>") \
18203 _(map_add_del_rule, \
18204 "index <n> psid <n> dst <ip6addr> [del]") \
18205 _(map_domain_dump, "") \
18206 _(map_rule_dump, "index <map-domain>") \
18207 _(want_interface_events, "enable|disable") \
18208 _(want_stats,"enable|disable") \
18209 _(get_first_msg_id, "client <name>") \
18210 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
18211 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
18212 "fib-id <nn> [ip4][ip6][default]") \
18213 _(get_node_graph, " ") \
18214 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
18215 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
18216 _(ioam_disable, "") \
18217 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
18218 " sw_if_index <sw_if_index> p <priority> " \
18219 "w <weight>] [del]") \
18220 _(one_add_del_locator, "locator-set <locator_name> " \
18221 "iface <intf> | sw_if_index <sw_if_index> " \
18222 "p <priority> w <weight> [del]") \
18223 _(one_add_del_local_eid,"vni <vni> eid " \
18224 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18225 "locator-set <locator_name> [del]" \
18226 "[key-id sha1|sha256 secret-key <secret-key>]")\
18227 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
18228 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
18229 _(one_enable_disable, "enable|disable") \
18230 _(one_map_register_enable_disable, "enable|disable") \
18231 _(one_rloc_probe_enable_disable, "enable|disable") \
18232 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18234 "rloc <locator> p <prio> " \
18235 "w <weight> [rloc <loc> ... ] " \
18236 "action <action> [del-all]") \
18237 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18239 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18240 _(one_map_request_mode, "src-dst|dst-only") \
18241 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18242 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18243 _(one_locator_set_dump, "[local | remote]") \
18244 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
18245 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18246 "[local] | [remote]") \
18247 _(one_eid_table_vni_dump, "") \
18248 _(one_eid_table_map_dump, "l2|l3") \
18249 _(one_map_resolver_dump, "") \
18250 _(one_map_server_dump, "") \
18251 _(one_adjacencies_get, "vni <vni>") \
18252 _(show_one_rloc_probe_state, "") \
18253 _(show_one_map_register_state, "") \
18254 _(show_one_status, "") \
18255 _(one_get_map_request_itr_rlocs, "") \
18256 _(show_one_pitr, "") \
18257 _(show_one_map_request_mode, "") \
18258 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
18259 " sw_if_index <sw_if_index> p <priority> " \
18260 "w <weight>] [del]") \
18261 _(lisp_add_del_locator, "locator-set <locator_name> " \
18262 "iface <intf> | sw_if_index <sw_if_index> " \
18263 "p <priority> w <weight> [del]") \
18264 _(lisp_add_del_local_eid,"vni <vni> eid " \
18265 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18266 "locator-set <locator_name> [del]" \
18267 "[key-id sha1|sha256 secret-key <secret-key>]") \
18268 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
18269 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
18270 _(lisp_enable_disable, "enable|disable") \
18271 _(lisp_map_register_enable_disable, "enable|disable") \
18272 _(lisp_rloc_probe_enable_disable, "enable|disable") \
18273 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18275 "rloc <locator> p <prio> " \
18276 "w <weight> [rloc <loc> ... ] " \
18277 "action <action> [del-all]") \
18278 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18280 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18281 _(lisp_map_request_mode, "src-dst|dst-only") \
18282 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18283 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18284 _(lisp_locator_set_dump, "[local | remote]") \
18285 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
18286 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18287 "[local] | [remote]") \
18288 _(lisp_eid_table_vni_dump, "") \
18289 _(lisp_eid_table_map_dump, "l2|l3") \
18290 _(lisp_map_resolver_dump, "") \
18291 _(lisp_map_server_dump, "") \
18292 _(lisp_adjacencies_get, "vni <vni>") \
18293 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
18294 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
18295 _(gpe_set_encap_mode, "lisp|vxlan") \
18296 _(gpe_get_encap_mode, "") \
18297 _(lisp_gpe_add_del_iface, "up|down") \
18298 _(lisp_gpe_enable_disable, "enable|disable") \
18299 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
18300 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
18301 _(show_lisp_rloc_probe_state, "") \
18302 _(show_lisp_map_register_state, "") \
18303 _(show_lisp_status, "") \
18304 _(lisp_get_map_request_itr_rlocs, "") \
18305 _(show_lisp_pitr, "") \
18306 _(show_lisp_map_request_mode, "") \
18307 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
18308 _(af_packet_delete, "name <host interface name>") \
18309 _(policer_add_del, "name <policer name> <params> [del]") \
18310 _(policer_dump, "[name <policer name>]") \
18311 _(policer_classify_set_interface, \
18312 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18313 " [l2-table <nn>] [del]") \
18314 _(policer_classify_dump, "type [ip4|ip6|l2]") \
18315 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
18316 "[master|slave]") \
18317 _(netmap_delete, "name <interface name>") \
18318 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
18319 _(mpls_fib_dump, "") \
18320 _(classify_table_ids, "") \
18321 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
18322 _(classify_table_info, "table_id <nn>") \
18323 _(classify_session_dump, "table_id <nn>") \
18324 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
18325 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
18326 "[template_interval <nn>] [udp_checksum]") \
18327 _(ipfix_exporter_dump, "") \
18328 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
18329 _(ipfix_classify_stream_dump, "") \
18330 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
18331 _(ipfix_classify_table_dump, "") \
18332 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
18333 _(sw_interface_span_dump, "") \
18334 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
18335 _(pg_create_interface, "if_id <nn>") \
18336 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
18337 _(pg_enable_disable, "[stream <id>] disable") \
18338 _(ip_source_and_port_range_check_add_del, \
18339 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
18340 _(ip_source_and_port_range_check_interface_add_del, \
18341 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
18342 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
18343 _(ipsec_gre_add_del_tunnel, \
18344 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
18345 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
18346 _(delete_subif,"<intfc> | sw_if_index <nn>") \
18347 _(l2_interface_pbb_tag_rewrite, \
18348 "<intfc> | sw_if_index <nn> \n" \
18349 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
18350 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
18351 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
18352 _(flow_classify_set_interface, \
18353 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
18354 _(flow_classify_dump, "type [ip4|ip6]") \
18355 _(ip_fib_dump, "") \
18356 _(ip_mfib_dump, "") \
18357 _(ip6_fib_dump, "") \
18358 _(ip6_mfib_dump, "") \
18359 _(feature_enable_disable, "arc_name <arc_name> " \
18360 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
18361 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
18363 _(l2_xconnect_dump, "") \
18364 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
18365 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
18366 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
18368 /* List of command functions, CLI names map directly to functions */
18369 #define foreach_cli_function \
18370 _(comment, "usage: comment <ignore-rest-of-line>") \
18371 _(dump_interface_table, "usage: dump_interface_table") \
18372 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
18373 _(dump_ipv4_table, "usage: dump_ipv4_table") \
18374 _(dump_ipv6_table, "usage: dump_ipv6_table") \
18375 _(dump_stats_table, "usage: dump_stats_table") \
18376 _(dump_macro_table, "usage: dump_macro_table ") \
18377 _(dump_node_table, "usage: dump_node_table") \
18378 _(dump_msg_api_table, "usage: dump_msg_api_table") \
18379 _(get_msg_id, "usage: get_msg_id name_and_crc") \
18380 _(echo, "usage: echo <message>") \
18381 _(exec, "usage: exec <vpe-debug-CLI-command>") \
18382 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
18383 _(help, "usage: help") \
18384 _(q, "usage: quit") \
18385 _(quit, "usage: quit") \
18386 _(search_node_table, "usage: search_node_table <name>...") \
18387 _(set, "usage: set <variable-name> <value>") \
18388 _(script, "usage: script <file-name>") \
18389 _(unset, "usage: unset <variable-name>")
18392 static void vl_api_##n##_t_handler_uni \
18393 (vl_api_##n##_t * mp) \
18395 vat_main_t * vam = &vat_main; \
18396 if (vam->json_output) { \
18397 vl_api_##n##_t_handler_json(mp); \
18399 vl_api_##n##_t_handler(mp); \
18402 foreach_vpe_api_reply_msg;
18403 #if VPP_API_TEST_BUILTIN == 0
18404 foreach_standalone_reply_msg;
18409 vat_api_hookup (vat_main_t * vam)
18412 vl_msg_api_set_handlers(VL_API_##N, #n, \
18413 vl_api_##n##_t_handler_uni, \
18415 vl_api_##n##_t_endian, \
18416 vl_api_##n##_t_print, \
18417 sizeof(vl_api_##n##_t), 1);
18418 foreach_vpe_api_reply_msg;
18419 #if VPP_API_TEST_BUILTIN == 0
18420 foreach_standalone_reply_msg;
18424 #if (VPP_API_TEST_BUILTIN==0)
18425 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
18427 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
18429 vam->function_by_name = hash_create_string (0, sizeof (uword));
18431 vam->help_by_name = hash_create_string (0, sizeof (uword));
18434 /* API messages we can send */
18435 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18436 foreach_vpe_api_msg;
18440 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18441 foreach_vpe_api_msg;
18444 /* CLI functions */
18445 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
18446 foreach_cli_function;
18450 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18451 foreach_cli_function;
18455 #if VPP_API_TEST_BUILTIN
18456 static clib_error_t *
18457 vat_api_hookup_shim (vlib_main_t * vm)
18459 vat_api_hookup (&vat_main);
18463 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
18467 * fd.io coding-style-patch-verification: ON
18470 * eval: (c-set-style "gnu")