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;
7135 u8 is_no_fib_entry = 0;
7138 u8 v4_address_set = 0;
7139 u8 v6_address_set = 0;
7140 ip4_address_t v4address;
7141 ip6_address_t v6address;
7144 memset (mac_address, 0, sizeof (mac_address));
7146 /* Parse args required to build the message */
7147 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7149 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7153 else if (unformat (i, "del"))
7156 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7157 sw_if_index_set = 1;
7158 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7159 sw_if_index_set = 1;
7160 else if (unformat (i, "is_static"))
7162 else if (unformat (i, "no-fib-entry"))
7163 is_no_fib_entry = 1;
7164 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7166 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7170 clib_warning ("parse error '%U'", format_unformat_error, i);
7175 if (sw_if_index_set == 0)
7177 errmsg ("missing interface name or sw_if_index");
7180 if (v4_address_set && v6_address_set)
7182 errmsg ("both v4 and v6 addresses set");
7185 if (!v4_address_set && !v6_address_set)
7187 errmsg ("no address set");
7191 /* Construct the API message */
7192 M (IP_NEIGHBOR_ADD_DEL, mp);
7194 mp->sw_if_index = ntohl (sw_if_index);
7195 mp->is_add = is_add;
7196 mp->is_static = is_static;
7197 mp->is_no_adj_fib = is_no_fib_entry;
7199 clib_memcpy (mp->mac_address, mac_address, 6);
7203 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7207 /* mp->is_ipv6 = 0; via memset in M macro above */
7208 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7214 /* Wait for a reply, return good/bad news */
7220 api_reset_vrf (vat_main_t * vam)
7222 unformat_input_t *i = vam->input;
7223 vl_api_reset_vrf_t *mp;
7229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7231 if (unformat (i, "vrf %d", &vrf_id))
7233 else if (unformat (i, "ipv6"))
7237 clib_warning ("parse error '%U'", format_unformat_error, i);
7242 if (vrf_id_set == 0)
7244 errmsg ("missing vrf id");
7250 mp->vrf_id = ntohl (vrf_id);
7251 mp->is_ipv6 = is_ipv6;
7259 api_create_vlan_subif (vat_main_t * vam)
7261 unformat_input_t *i = vam->input;
7262 vl_api_create_vlan_subif_t *mp;
7264 u8 sw_if_index_set = 0;
7269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7271 if (unformat (i, "sw_if_index %d", &sw_if_index))
7272 sw_if_index_set = 1;
7274 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7275 sw_if_index_set = 1;
7276 else if (unformat (i, "vlan %d", &vlan_id))
7280 clib_warning ("parse error '%U'", format_unformat_error, i);
7285 if (sw_if_index_set == 0)
7287 errmsg ("missing interface name or sw_if_index");
7291 if (vlan_id_set == 0)
7293 errmsg ("missing vlan_id");
7296 M (CREATE_VLAN_SUBIF, mp);
7298 mp->sw_if_index = ntohl (sw_if_index);
7299 mp->vlan_id = ntohl (vlan_id);
7306 #define foreach_create_subif_bit \
7313 _(outer_vlan_id_any) \
7314 _(inner_vlan_id_any)
7317 api_create_subif (vat_main_t * vam)
7319 unformat_input_t *i = vam->input;
7320 vl_api_create_subif_t *mp;
7322 u8 sw_if_index_set = 0;
7329 u32 exact_match = 0;
7330 u32 default_sub = 0;
7331 u32 outer_vlan_id_any = 0;
7332 u32 inner_vlan_id_any = 0;
7334 u16 outer_vlan_id = 0;
7335 u16 inner_vlan_id = 0;
7338 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7340 if (unformat (i, "sw_if_index %d", &sw_if_index))
7341 sw_if_index_set = 1;
7343 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7344 sw_if_index_set = 1;
7345 else if (unformat (i, "sub_id %d", &sub_id))
7347 else if (unformat (i, "outer_vlan_id %d", &tmp))
7348 outer_vlan_id = tmp;
7349 else if (unformat (i, "inner_vlan_id %d", &tmp))
7350 inner_vlan_id = tmp;
7352 #define _(a) else if (unformat (i, #a)) a = 1 ;
7353 foreach_create_subif_bit
7357 clib_warning ("parse error '%U'", format_unformat_error, i);
7362 if (sw_if_index_set == 0)
7364 errmsg ("missing interface name or sw_if_index");
7368 if (sub_id_set == 0)
7370 errmsg ("missing sub_id");
7373 M (CREATE_SUBIF, mp);
7375 mp->sw_if_index = ntohl (sw_if_index);
7376 mp->sub_id = ntohl (sub_id);
7378 #define _(a) mp->a = a;
7379 foreach_create_subif_bit;
7382 mp->outer_vlan_id = ntohs (outer_vlan_id);
7383 mp->inner_vlan_id = ntohs (inner_vlan_id);
7391 api_oam_add_del (vat_main_t * vam)
7393 unformat_input_t *i = vam->input;
7394 vl_api_oam_add_del_t *mp;
7397 ip4_address_t src, dst;
7402 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7404 if (unformat (i, "vrf %d", &vrf_id))
7406 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7408 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7410 else if (unformat (i, "del"))
7414 clib_warning ("parse error '%U'", format_unformat_error, i);
7421 errmsg ("missing src addr");
7427 errmsg ("missing dst addr");
7431 M (OAM_ADD_DEL, mp);
7433 mp->vrf_id = ntohl (vrf_id);
7434 mp->is_add = is_add;
7435 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7436 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7444 api_reset_fib (vat_main_t * vam)
7446 unformat_input_t *i = vam->input;
7447 vl_api_reset_fib_t *mp;
7453 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7455 if (unformat (i, "vrf %d", &vrf_id))
7457 else if (unformat (i, "ipv6"))
7461 clib_warning ("parse error '%U'", format_unformat_error, i);
7466 if (vrf_id_set == 0)
7468 errmsg ("missing vrf id");
7474 mp->vrf_id = ntohl (vrf_id);
7475 mp->is_ipv6 = is_ipv6;
7483 api_dhcp_proxy_config (vat_main_t * vam)
7485 unformat_input_t *i = vam->input;
7486 vl_api_dhcp_proxy_config_t *mp;
7488 u32 server_vrf_id = 0;
7490 u8 v4_address_set = 0;
7491 u8 v6_address_set = 0;
7492 ip4_address_t v4address;
7493 ip6_address_t v6address;
7494 u8 v4_src_address_set = 0;
7495 u8 v6_src_address_set = 0;
7496 ip4_address_t v4srcaddress;
7497 ip6_address_t v6srcaddress;
7500 /* Parse args required to build the message */
7501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7503 if (unformat (i, "del"))
7505 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7507 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7509 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7511 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7513 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7514 v4_src_address_set = 1;
7515 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7516 v6_src_address_set = 1;
7521 if (v4_address_set && v6_address_set)
7523 errmsg ("both v4 and v6 server addresses set");
7526 if (!v4_address_set && !v6_address_set)
7528 errmsg ("no server addresses set");
7532 if (v4_src_address_set && v6_src_address_set)
7534 errmsg ("both v4 and v6 src addresses set");
7537 if (!v4_src_address_set && !v6_src_address_set)
7539 errmsg ("no src addresses set");
7543 if (!(v4_src_address_set && v4_address_set) &&
7544 !(v6_src_address_set && v6_address_set))
7546 errmsg ("no matching server and src addresses set");
7550 /* Construct the API message */
7551 M (DHCP_PROXY_CONFIG, mp);
7553 mp->is_add = is_add;
7554 mp->rx_vrf_id = ntohl (rx_vrf_id);
7555 mp->server_vrf_id = ntohl (server_vrf_id);
7559 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7560 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7564 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7565 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7571 /* Wait for a reply, return good/bad news */
7576 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
7577 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
7580 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
7582 vat_main_t *vam = &vat_main;
7583 u32 i, count = mp->count;
7584 vl_api_dhcp_server_t *s;
7588 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7589 ntohl (mp->rx_vrf_id),
7590 format_ip6_address, mp->dhcp_src_address,
7591 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7594 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7595 ntohl (mp->rx_vrf_id),
7596 format_ip4_address, mp->dhcp_src_address,
7597 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7599 for (i = 0; i < count; i++)
7601 s = &mp->servers[i];
7605 " Server Table-ID %d, Server Address %U",
7606 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
7609 " Server Table-ID %d, Server Address %U",
7610 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
7614 static void vl_api_dhcp_proxy_details_t_handler_json
7615 (vl_api_dhcp_proxy_details_t * mp)
7617 vat_main_t *vam = &vat_main;
7618 vat_json_node_t *node = NULL;
7619 u32 i, count = mp->count;
7621 struct in6_addr ip6;
7622 vl_api_dhcp_server_t *s;
7624 if (VAT_JSON_ARRAY != vam->json_tree.type)
7626 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7627 vat_json_init_array (&vam->json_tree);
7629 node = vat_json_array_add (&vam->json_tree);
7631 vat_json_init_object (node);
7632 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
7633 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
7634 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
7638 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
7639 vat_json_object_add_ip6 (node, "src_address", ip6);
7643 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
7644 vat_json_object_add_ip4 (node, "src_address", ip4);
7647 for (i = 0; i < count; i++)
7649 s = &mp->servers[i];
7651 vat_json_object_add_uint (node, "server-table-id",
7652 ntohl (s->server_vrf_id));
7656 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
7657 vat_json_object_add_ip4 (node, "src_address", ip4);
7661 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
7662 vat_json_object_add_ip6 (node, "server_address", ip6);
7668 api_dhcp_proxy_dump (vat_main_t * vam)
7670 unformat_input_t *i = vam->input;
7671 vl_api_control_ping_t *mp_ping;
7672 vl_api_dhcp_proxy_dump_t *mp;
7676 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7678 if (unformat (i, "ipv6"))
7682 clib_warning ("parse error '%U'", format_unformat_error, i);
7687 M (DHCP_PROXY_DUMP, mp);
7689 mp->is_ip6 = is_ipv6;
7692 /* Use a control ping for synchronization */
7693 M (CONTROL_PING, mp_ping);
7701 api_dhcp_proxy_set_vss (vat_main_t * vam)
7703 unformat_input_t *i = vam->input;
7704 vl_api_dhcp_proxy_set_vss_t *mp;
7715 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7717 if (unformat (i, "tbl_id %d", &tbl_id))
7719 if (unformat (i, "fib_id %d", &fib_id))
7721 if (unformat (i, "oui %d", &oui))
7723 else if (unformat (i, "ipv6"))
7725 else if (unformat (i, "del"))
7729 clib_warning ("parse error '%U'", format_unformat_error, i);
7734 if (tbl_id_set == 0)
7736 errmsg ("missing tbl id");
7740 if (fib_id_set == 0)
7742 errmsg ("missing fib id");
7747 errmsg ("missing oui");
7751 M (DHCP_PROXY_SET_VSS, mp);
7752 mp->tbl_id = ntohl (tbl_id);
7753 mp->fib_id = ntohl (fib_id);
7754 mp->oui = ntohl (oui);
7755 mp->is_ipv6 = is_ipv6;
7756 mp->is_add = is_add;
7764 api_dhcp_client_config (vat_main_t * vam)
7766 unformat_input_t *i = vam->input;
7767 vl_api_dhcp_client_config_t *mp;
7769 u8 sw_if_index_set = 0;
7772 u8 disable_event = 0;
7775 /* Parse args required to build the message */
7776 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7778 if (unformat (i, "del"))
7781 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7782 sw_if_index_set = 1;
7783 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7784 sw_if_index_set = 1;
7785 else if (unformat (i, "hostname %s", &hostname))
7787 else if (unformat (i, "disable_event"))
7793 if (sw_if_index_set == 0)
7795 errmsg ("missing interface name or sw_if_index");
7799 if (vec_len (hostname) > 63)
7801 errmsg ("hostname too long");
7803 vec_add1 (hostname, 0);
7805 /* Construct the API message */
7806 M (DHCP_CLIENT_CONFIG, mp);
7808 mp->sw_if_index = ntohl (sw_if_index);
7809 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7810 vec_free (hostname);
7811 mp->is_add = is_add;
7812 mp->want_dhcp_event = disable_event ? 0 : 1;
7813 mp->pid = getpid ();
7818 /* Wait for a reply, return good/bad news */
7824 api_set_ip_flow_hash (vat_main_t * vam)
7826 unformat_input_t *i = vam->input;
7827 vl_api_set_ip_flow_hash_t *mp;
7839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7841 if (unformat (i, "vrf %d", &vrf_id))
7843 else if (unformat (i, "ipv6"))
7845 else if (unformat (i, "src"))
7847 else if (unformat (i, "dst"))
7849 else if (unformat (i, "sport"))
7851 else if (unformat (i, "dport"))
7853 else if (unformat (i, "proto"))
7855 else if (unformat (i, "reverse"))
7860 clib_warning ("parse error '%U'", format_unformat_error, i);
7865 if (vrf_id_set == 0)
7867 errmsg ("missing vrf id");
7871 M (SET_IP_FLOW_HASH, mp);
7877 mp->reverse = reverse;
7878 mp->vrf_id = ntohl (vrf_id);
7879 mp->is_ipv6 = is_ipv6;
7887 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7889 unformat_input_t *i = vam->input;
7890 vl_api_sw_interface_ip6_enable_disable_t *mp;
7892 u8 sw_if_index_set = 0;
7896 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7898 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7899 sw_if_index_set = 1;
7900 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7901 sw_if_index_set = 1;
7902 else if (unformat (i, "enable"))
7904 else if (unformat (i, "disable"))
7908 clib_warning ("parse error '%U'", format_unformat_error, i);
7913 if (sw_if_index_set == 0)
7915 errmsg ("missing interface name or sw_if_index");
7919 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
7921 mp->sw_if_index = ntohl (sw_if_index);
7922 mp->enable = enable;
7930 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7932 unformat_input_t *i = vam->input;
7933 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7935 u8 sw_if_index_set = 0;
7936 u8 v6_address_set = 0;
7937 ip6_address_t v6address;
7940 /* Parse args required to build the message */
7941 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7943 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7944 sw_if_index_set = 1;
7945 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7946 sw_if_index_set = 1;
7947 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
7953 if (sw_if_index_set == 0)
7955 errmsg ("missing interface name or sw_if_index");
7958 if (!v6_address_set)
7960 errmsg ("no address set");
7964 /* Construct the API message */
7965 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
7967 mp->sw_if_index = ntohl (sw_if_index);
7968 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7973 /* Wait for a reply, return good/bad news */
7979 api_ip6nd_proxy_add_del (vat_main_t * vam)
7981 unformat_input_t *i = vam->input;
7982 vl_api_ip6nd_proxy_add_del_t *mp;
7983 u32 sw_if_index = ~0;
7984 u8 v6_address_set = 0;
7985 ip6_address_t v6address;
7989 /* Parse args required to build the message */
7990 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7992 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7994 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7996 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
7998 if (unformat (i, "del"))
8002 clib_warning ("parse error '%U'", format_unformat_error, i);
8007 if (sw_if_index == ~0)
8009 errmsg ("missing interface name or sw_if_index");
8012 if (!v6_address_set)
8014 errmsg ("no address set");
8018 /* Construct the API message */
8019 M (IP6ND_PROXY_ADD_DEL, mp);
8021 mp->is_del = is_del;
8022 mp->sw_if_index = ntohl (sw_if_index);
8023 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8028 /* Wait for a reply, return good/bad news */
8034 api_ip6nd_proxy_dump (vat_main_t * vam)
8036 vl_api_ip6nd_proxy_dump_t *mp;
8037 vl_api_control_ping_t *mp_ping;
8040 M (IP6ND_PROXY_DUMP, mp);
8044 /* Use a control ping for synchronization */
8045 M (CONTROL_PING, mp_ping);
8052 static void vl_api_ip6nd_proxy_details_t_handler
8053 (vl_api_ip6nd_proxy_details_t * mp)
8055 vat_main_t *vam = &vat_main;
8057 print (vam->ofp, "host %U sw_if_index %d",
8058 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
8061 static void vl_api_ip6nd_proxy_details_t_handler_json
8062 (vl_api_ip6nd_proxy_details_t * mp)
8064 vat_main_t *vam = &vat_main;
8065 struct in6_addr ip6;
8066 vat_json_node_t *node = NULL;
8068 if (VAT_JSON_ARRAY != vam->json_tree.type)
8070 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8071 vat_json_init_array (&vam->json_tree);
8073 node = vat_json_array_add (&vam->json_tree);
8075 vat_json_init_object (node);
8076 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
8078 clib_memcpy (&ip6, mp->address, sizeof (ip6));
8079 vat_json_object_add_ip6 (node, "host", ip6);
8083 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8085 unformat_input_t *i = vam->input;
8086 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8088 u8 sw_if_index_set = 0;
8089 u32 address_length = 0;
8090 u8 v6_address_set = 0;
8091 ip6_address_t v6address;
8093 u8 no_advertise = 0;
8095 u8 no_autoconfig = 0;
8098 u32 val_lifetime = 0;
8099 u32 pref_lifetime = 0;
8102 /* Parse args required to build the message */
8103 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8105 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8106 sw_if_index_set = 1;
8107 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8108 sw_if_index_set = 1;
8109 else if (unformat (i, "%U/%d",
8110 unformat_ip6_address, &v6address, &address_length))
8112 else if (unformat (i, "val_life %d", &val_lifetime))
8114 else if (unformat (i, "pref_life %d", &pref_lifetime))
8116 else if (unformat (i, "def"))
8118 else if (unformat (i, "noadv"))
8120 else if (unformat (i, "offl"))
8122 else if (unformat (i, "noauto"))
8124 else if (unformat (i, "nolink"))
8126 else if (unformat (i, "isno"))
8130 clib_warning ("parse error '%U'", format_unformat_error, i);
8135 if (sw_if_index_set == 0)
8137 errmsg ("missing interface name or sw_if_index");
8140 if (!v6_address_set)
8142 errmsg ("no address set");
8146 /* Construct the API message */
8147 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8149 mp->sw_if_index = ntohl (sw_if_index);
8150 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8151 mp->address_length = address_length;
8152 mp->use_default = use_default;
8153 mp->no_advertise = no_advertise;
8154 mp->off_link = off_link;
8155 mp->no_autoconfig = no_autoconfig;
8156 mp->no_onlink = no_onlink;
8158 mp->val_lifetime = ntohl (val_lifetime);
8159 mp->pref_lifetime = ntohl (pref_lifetime);
8164 /* Wait for a reply, return good/bad news */
8170 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8172 unformat_input_t *i = vam->input;
8173 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8175 u8 sw_if_index_set = 0;
8180 u8 send_unicast = 0;
8183 u8 default_router = 0;
8184 u32 max_interval = 0;
8185 u32 min_interval = 0;
8187 u32 initial_count = 0;
8188 u32 initial_interval = 0;
8192 /* Parse args required to build the message */
8193 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8195 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8196 sw_if_index_set = 1;
8197 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8198 sw_if_index_set = 1;
8199 else if (unformat (i, "maxint %d", &max_interval))
8201 else if (unformat (i, "minint %d", &min_interval))
8203 else if (unformat (i, "life %d", &lifetime))
8205 else if (unformat (i, "count %d", &initial_count))
8207 else if (unformat (i, "interval %d", &initial_interval))
8209 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8211 else if (unformat (i, "managed"))
8213 else if (unformat (i, "other"))
8215 else if (unformat (i, "ll"))
8217 else if (unformat (i, "send"))
8219 else if (unformat (i, "cease"))
8221 else if (unformat (i, "isno"))
8223 else if (unformat (i, "def"))
8227 clib_warning ("parse error '%U'", format_unformat_error, i);
8232 if (sw_if_index_set == 0)
8234 errmsg ("missing interface name or sw_if_index");
8238 /* Construct the API message */
8239 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8241 mp->sw_if_index = ntohl (sw_if_index);
8242 mp->max_interval = ntohl (max_interval);
8243 mp->min_interval = ntohl (min_interval);
8244 mp->lifetime = ntohl (lifetime);
8245 mp->initial_count = ntohl (initial_count);
8246 mp->initial_interval = ntohl (initial_interval);
8247 mp->suppress = suppress;
8248 mp->managed = managed;
8250 mp->ll_option = ll_option;
8251 mp->send_unicast = send_unicast;
8254 mp->default_router = default_router;
8259 /* Wait for a reply, return good/bad news */
8265 api_set_arp_neighbor_limit (vat_main_t * vam)
8267 unformat_input_t *i = vam->input;
8268 vl_api_set_arp_neighbor_limit_t *mp;
8274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8276 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8278 else if (unformat (i, "ipv6"))
8282 clib_warning ("parse error '%U'", format_unformat_error, i);
8289 errmsg ("missing limit value");
8293 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8295 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8296 mp->is_ipv6 = is_ipv6;
8304 api_l2_patch_add_del (vat_main_t * vam)
8306 unformat_input_t *i = vam->input;
8307 vl_api_l2_patch_add_del_t *mp;
8309 u8 rx_sw_if_index_set = 0;
8311 u8 tx_sw_if_index_set = 0;
8315 /* Parse args required to build the message */
8316 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8318 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8319 rx_sw_if_index_set = 1;
8320 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8321 tx_sw_if_index_set = 1;
8322 else if (unformat (i, "rx"))
8324 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8326 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8328 rx_sw_if_index_set = 1;
8333 else if (unformat (i, "tx"))
8335 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8337 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8339 tx_sw_if_index_set = 1;
8344 else if (unformat (i, "del"))
8350 if (rx_sw_if_index_set == 0)
8352 errmsg ("missing rx interface name or rx_sw_if_index");
8356 if (tx_sw_if_index_set == 0)
8358 errmsg ("missing tx interface name or tx_sw_if_index");
8362 M (L2_PATCH_ADD_DEL, mp);
8364 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8365 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8366 mp->is_add = is_add;
8374 u8 localsid_addr[16];
8383 api_sr_localsid_add_del (vat_main_t * vam)
8385 unformat_input_t *i = vam->input;
8386 vl_api_sr_localsid_add_del_t *mp;
8389 ip6_address_t localsid;
8393 u32 fib_table = ~(u32) 0;
8394 ip6_address_t next_hop;
8396 bool nexthop_set = 0;
8400 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8402 if (unformat (i, "del"))
8404 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
8405 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
8407 else if (unformat (i, "behavior %u", &behavior));
8408 else if (unformat (i, "sw_if_index %u", &sw_if_index));
8409 else if (unformat (i, "fib-table %u", &fib_table));
8410 else if (unformat (i, "end.psp %u", &behavior));
8415 M (SR_LOCALSID_ADD_DEL, mp);
8417 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
8419 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
8420 mp->behavior = behavior;
8421 mp->sw_if_index = ntohl (sw_if_index);
8422 mp->fib_table = ntohl (fib_table);
8423 mp->end_psp = end_psp;
8424 mp->is_del = is_del;
8432 api_ioam_enable (vat_main_t * vam)
8434 unformat_input_t *input = vam->input;
8435 vl_api_ioam_enable_t *mp;
8437 int has_trace_option = 0;
8438 int has_pot_option = 0;
8439 int has_seqno_option = 0;
8440 int has_analyse_option = 0;
8443 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8445 if (unformat (input, "trace"))
8446 has_trace_option = 1;
8447 else if (unformat (input, "pot"))
8449 else if (unformat (input, "seqno"))
8450 has_seqno_option = 1;
8451 else if (unformat (input, "analyse"))
8452 has_analyse_option = 1;
8456 M (IOAM_ENABLE, mp);
8457 mp->id = htons (id);
8458 mp->seqno = has_seqno_option;
8459 mp->analyse = has_analyse_option;
8460 mp->pot_enable = has_pot_option;
8461 mp->trace_enable = has_trace_option;
8470 api_ioam_disable (vat_main_t * vam)
8472 vl_api_ioam_disable_t *mp;
8475 M (IOAM_DISABLE, mp);
8481 #define foreach_tcp_proto_field \
8485 #define foreach_udp_proto_field \
8489 #define foreach_ip4_proto_field \
8501 u16 src_port, dst_port;
8504 #if VPP_API_TEST_BUILTIN == 0
8506 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8508 u8 **maskp = va_arg (*args, u8 **);
8510 u8 found_something = 0;
8513 #define _(a) u8 a=0;
8514 foreach_tcp_proto_field;
8517 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8520 #define _(a) else if (unformat (input, #a)) a=1;
8521 foreach_tcp_proto_field
8527 #define _(a) found_something += a;
8528 foreach_tcp_proto_field;
8531 if (found_something == 0)
8534 vec_validate (mask, sizeof (*tcp) - 1);
8536 tcp = (tcp_header_t *) mask;
8538 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8539 foreach_tcp_proto_field;
8547 unformat_udp_mask (unformat_input_t * input, va_list * args)
8549 u8 **maskp = va_arg (*args, u8 **);
8551 u8 found_something = 0;
8554 #define _(a) u8 a=0;
8555 foreach_udp_proto_field;
8558 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8561 #define _(a) else if (unformat (input, #a)) a=1;
8562 foreach_udp_proto_field
8568 #define _(a) found_something += a;
8569 foreach_udp_proto_field;
8572 if (found_something == 0)
8575 vec_validate (mask, sizeof (*udp) - 1);
8577 udp = (udp_header_t *) mask;
8579 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8580 foreach_udp_proto_field;
8588 unformat_l4_mask (unformat_input_t * input, va_list * args)
8590 u8 **maskp = va_arg (*args, u8 **);
8591 u16 src_port = 0, dst_port = 0;
8592 tcpudp_header_t *tcpudp;
8594 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8596 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8598 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8600 else if (unformat (input, "src_port"))
8602 else if (unformat (input, "dst_port"))
8608 if (!src_port && !dst_port)
8612 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8614 tcpudp = (tcpudp_header_t *) mask;
8615 tcpudp->src_port = src_port;
8616 tcpudp->dst_port = dst_port;
8624 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8626 u8 **maskp = va_arg (*args, u8 **);
8628 u8 found_something = 0;
8631 #define _(a) u8 a=0;
8632 foreach_ip4_proto_field;
8638 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8640 if (unformat (input, "version"))
8642 else if (unformat (input, "hdr_length"))
8644 else if (unformat (input, "src"))
8646 else if (unformat (input, "dst"))
8648 else if (unformat (input, "proto"))
8651 #define _(a) else if (unformat (input, #a)) a=1;
8652 foreach_ip4_proto_field
8658 #define _(a) found_something += a;
8659 foreach_ip4_proto_field;
8662 if (found_something == 0)
8665 vec_validate (mask, sizeof (*ip) - 1);
8667 ip = (ip4_header_t *) mask;
8669 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8670 foreach_ip4_proto_field;
8673 ip->ip_version_and_header_length = 0;
8676 ip->ip_version_and_header_length |= 0xF0;
8679 ip->ip_version_and_header_length |= 0x0F;
8685 #define foreach_ip6_proto_field \
8693 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8695 u8 **maskp = va_arg (*args, u8 **);
8697 u8 found_something = 0;
8699 u32 ip_version_traffic_class_and_flow_label;
8701 #define _(a) u8 a=0;
8702 foreach_ip6_proto_field;
8705 u8 traffic_class = 0;
8708 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8710 if (unformat (input, "version"))
8712 else if (unformat (input, "traffic-class"))
8714 else if (unformat (input, "flow-label"))
8716 else if (unformat (input, "src"))
8718 else if (unformat (input, "dst"))
8720 else if (unformat (input, "proto"))
8723 #define _(a) else if (unformat (input, #a)) a=1;
8724 foreach_ip6_proto_field
8730 #define _(a) found_something += a;
8731 foreach_ip6_proto_field;
8734 if (found_something == 0)
8737 vec_validate (mask, sizeof (*ip) - 1);
8739 ip = (ip6_header_t *) mask;
8741 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8742 foreach_ip6_proto_field;
8745 ip_version_traffic_class_and_flow_label = 0;
8748 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8751 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8754 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8756 ip->ip_version_traffic_class_and_flow_label =
8757 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8764 unformat_l3_mask (unformat_input_t * input, va_list * args)
8766 u8 **maskp = va_arg (*args, u8 **);
8768 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8770 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8772 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8781 unformat_l2_mask (unformat_input_t * input, va_list * args)
8783 u8 **maskp = va_arg (*args, u8 **);
8798 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8800 if (unformat (input, "src"))
8802 else if (unformat (input, "dst"))
8804 else if (unformat (input, "proto"))
8806 else if (unformat (input, "tag1"))
8808 else if (unformat (input, "tag2"))
8810 else if (unformat (input, "ignore-tag1"))
8812 else if (unformat (input, "ignore-tag2"))
8814 else if (unformat (input, "cos1"))
8816 else if (unformat (input, "cos2"))
8818 else if (unformat (input, "dot1q"))
8820 else if (unformat (input, "dot1ad"))
8825 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8826 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8829 if (tag1 || ignore_tag1 || cos1 || dot1q)
8831 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8834 vec_validate (mask, len - 1);
8837 memset (mask, 0xff, 6);
8840 memset (mask + 6, 0xff, 6);
8844 /* inner vlan tag */
8853 mask[21] = mask[20] = 0xff;
8874 mask[16] = mask[17] = 0xff;
8884 mask[12] = mask[13] = 0xff;
8891 unformat_classify_mask (unformat_input_t * input, va_list * args)
8893 u8 **maskp = va_arg (*args, u8 **);
8894 u32 *skipp = va_arg (*args, u32 *);
8895 u32 *matchp = va_arg (*args, u32 *);
8903 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8905 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8907 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8909 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8911 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
8925 if (mask || l2 || l3 || l4)
8929 /* "With a free Ethernet header in every package" */
8931 vec_validate (l2, 13);
8935 vec_append (mask, l3);
8940 vec_append (mask, l4);
8945 /* Scan forward looking for the first significant mask octet */
8946 for (i = 0; i < vec_len (mask); i++)
8950 /* compute (skip, match) params */
8951 *skipp = i / sizeof (u32x4);
8952 vec_delete (mask, *skipp * sizeof (u32x4), 0);
8954 /* Pad mask to an even multiple of the vector size */
8955 while (vec_len (mask) % sizeof (u32x4))
8958 match = vec_len (mask) / sizeof (u32x4);
8960 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
8962 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
8963 if (*tmp || *(tmp + 1))
8968 clib_warning ("BUG: match 0");
8970 _vec_len (mask) = match * sizeof (u32x4);
8980 #endif /* VPP_API_TEST_BUILTIN */
8982 #define foreach_l2_next \
8984 _(ethernet, ETHERNET_INPUT) \
8989 unformat_l2_next_index (unformat_input_t * input, va_list * args)
8991 u32 *miss_next_indexp = va_arg (*args, u32 *);
8996 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9000 if (unformat (input, "%d", &tmp))
9009 *miss_next_indexp = next_index;
9013 #define foreach_ip_next \
9019 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9021 u32 *miss_next_indexp = va_arg (*args, u32 *);
9026 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9030 if (unformat (input, "%d", &tmp))
9039 *miss_next_indexp = next_index;
9043 #define foreach_acl_next \
9047 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9049 u32 *miss_next_indexp = va_arg (*args, u32 *);
9054 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9058 if (unformat (input, "permit"))
9063 else if (unformat (input, "%d", &tmp))
9072 *miss_next_indexp = next_index;
9077 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9079 u32 *r = va_arg (*args, u32 *);
9081 if (unformat (input, "conform-color"))
9082 *r = POLICE_CONFORM;
9083 else if (unformat (input, "exceed-color"))
9092 api_classify_add_del_table (vat_main_t * vam)
9094 unformat_input_t *i = vam->input;
9095 vl_api_classify_add_del_table_t *mp;
9102 u32 table_index = ~0;
9103 u32 next_table_index = ~0;
9104 u32 miss_next_index = ~0;
9105 u32 memory_size = 32 << 20;
9107 u32 current_data_flag = 0;
9108 int current_data_offset = 0;
9111 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9113 if (unformat (i, "del"))
9115 else if (unformat (i, "del-chain"))
9120 else if (unformat (i, "buckets %d", &nbuckets))
9122 else if (unformat (i, "memory_size %d", &memory_size))
9124 else if (unformat (i, "skip %d", &skip))
9126 else if (unformat (i, "match %d", &match))
9128 else if (unformat (i, "table %d", &table_index))
9130 else if (unformat (i, "mask %U", unformat_classify_mask,
9131 &mask, &skip, &match))
9133 else if (unformat (i, "next-table %d", &next_table_index))
9135 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9138 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9141 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9144 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9146 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9152 if (is_add && mask == 0)
9154 errmsg ("Mask required");
9158 if (is_add && skip == ~0)
9160 errmsg ("skip count required");
9164 if (is_add && match == ~0)
9166 errmsg ("match count required");
9170 if (!is_add && table_index == ~0)
9172 errmsg ("table index required for delete");
9176 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9178 mp->is_add = is_add;
9179 mp->del_chain = del_chain;
9180 mp->table_index = ntohl (table_index);
9181 mp->nbuckets = ntohl (nbuckets);
9182 mp->memory_size = ntohl (memory_size);
9183 mp->skip_n_vectors = ntohl (skip);
9184 mp->match_n_vectors = ntohl (match);
9185 mp->next_table_index = ntohl (next_table_index);
9186 mp->miss_next_index = ntohl (miss_next_index);
9187 mp->current_data_flag = ntohl (current_data_flag);
9188 mp->current_data_offset = ntohl (current_data_offset);
9189 clib_memcpy (mp->mask, mask, vec_len (mask));
9198 #if VPP_API_TEST_BUILTIN == 0
9200 unformat_l4_match (unformat_input_t * input, va_list * args)
9202 u8 **matchp = va_arg (*args, u8 **);
9204 u8 *proto_header = 0;
9210 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9212 if (unformat (input, "src_port %d", &src_port))
9214 else if (unformat (input, "dst_port %d", &dst_port))
9220 h.src_port = clib_host_to_net_u16 (src_port);
9221 h.dst_port = clib_host_to_net_u16 (dst_port);
9222 vec_validate (proto_header, sizeof (h) - 1);
9223 memcpy (proto_header, &h, sizeof (h));
9225 *matchp = proto_header;
9231 unformat_ip4_match (unformat_input_t * input, va_list * args)
9233 u8 **matchp = va_arg (*args, u8 **);
9240 int src = 0, dst = 0;
9241 ip4_address_t src_val, dst_val;
9248 int fragment_id = 0;
9249 u32 fragment_id_val;
9255 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9257 if (unformat (input, "version %d", &version_val))
9259 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9261 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9263 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9265 else if (unformat (input, "proto %d", &proto_val))
9267 else if (unformat (input, "tos %d", &tos_val))
9269 else if (unformat (input, "length %d", &length_val))
9271 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9273 else if (unformat (input, "ttl %d", &ttl_val))
9275 else if (unformat (input, "checksum %d", &checksum_val))
9281 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9282 + ttl + checksum == 0)
9286 * Aligned because we use the real comparison functions
9288 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9290 ip = (ip4_header_t *) match;
9292 /* These are realistically matched in practice */
9294 ip->src_address.as_u32 = src_val.as_u32;
9297 ip->dst_address.as_u32 = dst_val.as_u32;
9300 ip->protocol = proto_val;
9303 /* These are not, but they're included for completeness */
9305 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9308 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9314 ip->length = clib_host_to_net_u16 (length_val);
9320 ip->checksum = clib_host_to_net_u16 (checksum_val);
9327 unformat_ip6_match (unformat_input_t * input, va_list * args)
9329 u8 **matchp = va_arg (*args, u8 **);
9334 u8 traffic_class = 0;
9335 u32 traffic_class_val = 0;
9338 int src = 0, dst = 0;
9339 ip6_address_t src_val, dst_val;
9342 int payload_length = 0;
9343 u32 payload_length_val;
9346 u32 ip_version_traffic_class_and_flow_label;
9348 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9350 if (unformat (input, "version %d", &version_val))
9352 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9354 else if (unformat (input, "flow_label %d", &flow_label_val))
9356 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9358 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9360 else if (unformat (input, "proto %d", &proto_val))
9362 else if (unformat (input, "payload_length %d", &payload_length_val))
9364 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9370 if (version + traffic_class + flow_label + src + dst + proto +
9371 payload_length + hop_limit == 0)
9375 * Aligned because we use the real comparison functions
9377 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9379 ip = (ip6_header_t *) match;
9382 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9385 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9388 ip->protocol = proto_val;
9390 ip_version_traffic_class_and_flow_label = 0;
9393 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9396 ip_version_traffic_class_and_flow_label |=
9397 (traffic_class_val & 0xFF) << 20;
9400 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9402 ip->ip_version_traffic_class_and_flow_label =
9403 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9406 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9409 ip->hop_limit = hop_limit_val;
9416 unformat_l3_match (unformat_input_t * input, va_list * args)
9418 u8 **matchp = va_arg (*args, u8 **);
9420 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9422 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9424 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9433 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9435 u8 *tagp = va_arg (*args, u8 *);
9438 if (unformat (input, "%d", &tag))
9440 tagp[0] = (tag >> 8) & 0x0F;
9441 tagp[1] = tag & 0xFF;
9449 unformat_l2_match (unformat_input_t * input, va_list * args)
9451 u8 **matchp = va_arg (*args, u8 **);
9471 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9473 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9476 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9478 else if (unformat (input, "proto %U",
9479 unformat_ethernet_type_host_byte_order, &proto_val))
9481 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9483 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9485 else if (unformat (input, "ignore-tag1"))
9487 else if (unformat (input, "ignore-tag2"))
9489 else if (unformat (input, "cos1 %d", &cos1_val))
9491 else if (unformat (input, "cos2 %d", &cos2_val))
9496 if ((src + dst + proto + tag1 + tag2 +
9497 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9500 if (tag1 || ignore_tag1 || cos1)
9502 if (tag2 || ignore_tag2 || cos2)
9505 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9508 clib_memcpy (match, dst_val, 6);
9511 clib_memcpy (match + 6, src_val, 6);
9515 /* inner vlan tag */
9516 match[19] = tag2_val[1];
9517 match[18] = tag2_val[0];
9519 match[18] |= (cos2_val & 0x7) << 5;
9522 match[21] = proto_val & 0xff;
9523 match[20] = proto_val >> 8;
9527 match[15] = tag1_val[1];
9528 match[14] = tag1_val[0];
9531 match[14] |= (cos1_val & 0x7) << 5;
9537 match[15] = tag1_val[1];
9538 match[14] = tag1_val[0];
9541 match[17] = proto_val & 0xff;
9542 match[16] = proto_val >> 8;
9545 match[14] |= (cos1_val & 0x7) << 5;
9551 match[18] |= (cos2_val & 0x7) << 5;
9553 match[14] |= (cos1_val & 0x7) << 5;
9556 match[13] = proto_val & 0xff;
9557 match[12] = proto_val >> 8;
9566 api_unformat_classify_match (unformat_input_t * input, va_list * args)
9568 u8 **matchp = va_arg (*args, u8 **);
9569 u32 skip_n_vectors = va_arg (*args, u32);
9570 u32 match_n_vectors = va_arg (*args, u32);
9577 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9579 if (unformat (input, "hex %U", unformat_hex_string, &match))
9581 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9583 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9585 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9599 if (match || l2 || l3 || l4)
9603 /* "Win a free Ethernet header in every packet" */
9605 vec_validate_aligned (l2, 13, sizeof (u32x4));
9609 vec_append_aligned (match, l3, sizeof (u32x4));
9614 vec_append_aligned (match, l4, sizeof (u32x4));
9619 /* Make sure the vector is big enough even if key is all 0's */
9620 vec_validate_aligned
9621 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9624 /* Set size, include skipped vectors */
9625 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9636 api_classify_add_del_session (vat_main_t * vam)
9638 unformat_input_t *i = vam->input;
9639 vl_api_classify_add_del_session_t *mp;
9641 u32 table_index = ~0;
9642 u32 hit_next_index = ~0;
9643 u32 opaque_index = ~0;
9646 u32 skip_n_vectors = 0;
9647 u32 match_n_vectors = 0;
9653 * Warning: you have to supply skip_n and match_n
9654 * because the API client cant simply look at the classify
9658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9660 if (unformat (i, "del"))
9662 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
9665 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9668 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
9671 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9673 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9675 else if (unformat (i, "opaque-index %d", &opaque_index))
9677 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9679 else if (unformat (i, "match_n %d", &match_n_vectors))
9681 else if (unformat (i, "match %U", api_unformat_classify_match,
9682 &match, skip_n_vectors, match_n_vectors))
9684 else if (unformat (i, "advance %d", &advance))
9686 else if (unformat (i, "table-index %d", &table_index))
9688 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9690 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9692 else if (unformat (i, "action %d", &action))
9694 else if (unformat (i, "metadata %d", &metadata))
9700 if (table_index == ~0)
9702 errmsg ("Table index required");
9706 if (is_add && match == 0)
9708 errmsg ("Match value required");
9712 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
9714 mp->is_add = is_add;
9715 mp->table_index = ntohl (table_index);
9716 mp->hit_next_index = ntohl (hit_next_index);
9717 mp->opaque_index = ntohl (opaque_index);
9718 mp->advance = ntohl (advance);
9719 mp->action = action;
9720 mp->metadata = ntohl (metadata);
9721 clib_memcpy (mp->match, match, vec_len (match));
9730 api_classify_set_interface_ip_table (vat_main_t * vam)
9732 unformat_input_t *i = vam->input;
9733 vl_api_classify_set_interface_ip_table_t *mp;
9735 int sw_if_index_set;
9736 u32 table_index = ~0;
9740 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9742 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9743 sw_if_index_set = 1;
9744 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9745 sw_if_index_set = 1;
9746 else if (unformat (i, "table %d", &table_index))
9750 clib_warning ("parse error '%U'", format_unformat_error, i);
9755 if (sw_if_index_set == 0)
9757 errmsg ("missing interface name or sw_if_index");
9762 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
9764 mp->sw_if_index = ntohl (sw_if_index);
9765 mp->table_index = ntohl (table_index);
9766 mp->is_ipv6 = is_ipv6;
9774 api_classify_set_interface_l2_tables (vat_main_t * vam)
9776 unformat_input_t *i = vam->input;
9777 vl_api_classify_set_interface_l2_tables_t *mp;
9779 int sw_if_index_set;
9780 u32 ip4_table_index = ~0;
9781 u32 ip6_table_index = ~0;
9782 u32 other_table_index = ~0;
9786 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9788 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9789 sw_if_index_set = 1;
9790 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9791 sw_if_index_set = 1;
9792 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9794 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9796 else if (unformat (i, "other-table %d", &other_table_index))
9798 else if (unformat (i, "is-input %d", &is_input))
9802 clib_warning ("parse error '%U'", format_unformat_error, i);
9807 if (sw_if_index_set == 0)
9809 errmsg ("missing interface name or sw_if_index");
9814 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
9816 mp->sw_if_index = ntohl (sw_if_index);
9817 mp->ip4_table_index = ntohl (ip4_table_index);
9818 mp->ip6_table_index = ntohl (ip6_table_index);
9819 mp->other_table_index = ntohl (other_table_index);
9820 mp->is_input = (u8) is_input;
9828 api_set_ipfix_exporter (vat_main_t * vam)
9830 unformat_input_t *i = vam->input;
9831 vl_api_set_ipfix_exporter_t *mp;
9832 ip4_address_t collector_address;
9833 u8 collector_address_set = 0;
9834 u32 collector_port = ~0;
9835 ip4_address_t src_address;
9836 u8 src_address_set = 0;
9839 u32 template_interval = ~0;
9840 u8 udp_checksum = 0;
9843 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9845 if (unformat (i, "collector_address %U", unformat_ip4_address,
9846 &collector_address))
9847 collector_address_set = 1;
9848 else if (unformat (i, "collector_port %d", &collector_port))
9850 else if (unformat (i, "src_address %U", unformat_ip4_address,
9852 src_address_set = 1;
9853 else if (unformat (i, "vrf_id %d", &vrf_id))
9855 else if (unformat (i, "path_mtu %d", &path_mtu))
9857 else if (unformat (i, "template_interval %d", &template_interval))
9859 else if (unformat (i, "udp_checksum"))
9865 if (collector_address_set == 0)
9867 errmsg ("collector_address required");
9871 if (src_address_set == 0)
9873 errmsg ("src_address required");
9877 M (SET_IPFIX_EXPORTER, mp);
9879 memcpy (mp->collector_address, collector_address.data,
9880 sizeof (collector_address.data));
9881 mp->collector_port = htons ((u16) collector_port);
9882 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9883 mp->vrf_id = htonl (vrf_id);
9884 mp->path_mtu = htonl (path_mtu);
9885 mp->template_interval = htonl (template_interval);
9886 mp->udp_checksum = udp_checksum;
9894 api_set_ipfix_classify_stream (vat_main_t * vam)
9896 unformat_input_t *i = vam->input;
9897 vl_api_set_ipfix_classify_stream_t *mp;
9899 u32 src_port = UDP_DST_PORT_ipfix;
9902 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9904 if (unformat (i, "domain %d", &domain_id))
9906 else if (unformat (i, "src_port %d", &src_port))
9910 errmsg ("unknown input `%U'", format_unformat_error, i);
9915 M (SET_IPFIX_CLASSIFY_STREAM, mp);
9917 mp->domain_id = htonl (domain_id);
9918 mp->src_port = htons ((u16) src_port);
9926 api_ipfix_classify_table_add_del (vat_main_t * vam)
9928 unformat_input_t *i = vam->input;
9929 vl_api_ipfix_classify_table_add_del_t *mp;
9931 u32 classify_table_index = ~0;
9933 u8 transport_protocol = 255;
9936 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9938 if (unformat (i, "add"))
9940 else if (unformat (i, "del"))
9942 else if (unformat (i, "table %d", &classify_table_index))
9944 else if (unformat (i, "ip4"))
9946 else if (unformat (i, "ip6"))
9948 else if (unformat (i, "tcp"))
9949 transport_protocol = 6;
9950 else if (unformat (i, "udp"))
9951 transport_protocol = 17;
9954 errmsg ("unknown input `%U'", format_unformat_error, i);
9961 errmsg ("expecting: add|del");
9964 if (classify_table_index == ~0)
9966 errmsg ("classifier table not specified");
9969 if (ip_version == 0)
9971 errmsg ("IP version not specified");
9975 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
9977 mp->is_add = is_add;
9978 mp->table_id = htonl (classify_table_index);
9979 mp->ip_version = ip_version;
9980 mp->transport_protocol = transport_protocol;
9988 api_get_node_index (vat_main_t * vam)
9990 unformat_input_t *i = vam->input;
9991 vl_api_get_node_index_t *mp;
9995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9997 if (unformat (i, "node %s", &name))
10004 errmsg ("node name required");
10007 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10009 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10013 M (GET_NODE_INDEX, mp);
10014 clib_memcpy (mp->node_name, name, vec_len (name));
10023 api_get_next_index (vat_main_t * vam)
10025 unformat_input_t *i = vam->input;
10026 vl_api_get_next_index_t *mp;
10027 u8 *node_name = 0, *next_node_name = 0;
10030 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10032 if (unformat (i, "node-name %s", &node_name))
10034 else if (unformat (i, "next-node-name %s", &next_node_name))
10038 if (node_name == 0)
10040 errmsg ("node name required");
10043 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10045 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10049 if (next_node_name == 0)
10051 errmsg ("next node name required");
10054 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10056 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10060 M (GET_NEXT_INDEX, mp);
10061 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10062 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10063 vec_free (node_name);
10064 vec_free (next_node_name);
10072 api_add_node_next (vat_main_t * vam)
10074 unformat_input_t *i = vam->input;
10075 vl_api_add_node_next_t *mp;
10080 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10082 if (unformat (i, "node %s", &name))
10084 else if (unformat (i, "next %s", &next))
10091 errmsg ("node name required");
10094 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10096 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10101 errmsg ("next node required");
10104 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10106 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10110 M (ADD_NODE_NEXT, mp);
10111 clib_memcpy (mp->node_name, name, vec_len (name));
10112 clib_memcpy (mp->next_name, next, vec_len (next));
10122 api_l2tpv3_create_tunnel (vat_main_t * vam)
10124 unformat_input_t *i = vam->input;
10125 ip6_address_t client_address, our_address;
10126 int client_address_set = 0;
10127 int our_address_set = 0;
10128 u32 local_session_id = 0;
10129 u32 remote_session_id = 0;
10130 u64 local_cookie = 0;
10131 u64 remote_cookie = 0;
10132 u8 l2_sublayer_present = 0;
10133 vl_api_l2tpv3_create_tunnel_t *mp;
10136 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10138 if (unformat (i, "client_address %U", unformat_ip6_address,
10140 client_address_set = 1;
10141 else if (unformat (i, "our_address %U", unformat_ip6_address,
10143 our_address_set = 1;
10144 else if (unformat (i, "local_session_id %d", &local_session_id))
10146 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10148 else if (unformat (i, "local_cookie %lld", &local_cookie))
10150 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10152 else if (unformat (i, "l2-sublayer-present"))
10153 l2_sublayer_present = 1;
10158 if (client_address_set == 0)
10160 errmsg ("client_address required");
10164 if (our_address_set == 0)
10166 errmsg ("our_address required");
10170 M (L2TPV3_CREATE_TUNNEL, mp);
10172 clib_memcpy (mp->client_address, client_address.as_u8,
10173 sizeof (mp->client_address));
10175 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10177 mp->local_session_id = ntohl (local_session_id);
10178 mp->remote_session_id = ntohl (remote_session_id);
10179 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10180 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10181 mp->l2_sublayer_present = l2_sublayer_present;
10190 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10192 unformat_input_t *i = vam->input;
10194 u8 sw_if_index_set = 0;
10195 u64 new_local_cookie = 0;
10196 u64 new_remote_cookie = 0;
10197 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10200 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10202 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10203 sw_if_index_set = 1;
10204 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10205 sw_if_index_set = 1;
10206 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10208 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10214 if (sw_if_index_set == 0)
10216 errmsg ("missing interface name or sw_if_index");
10220 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10222 mp->sw_if_index = ntohl (sw_if_index);
10223 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10224 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10232 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10234 unformat_input_t *i = vam->input;
10235 vl_api_l2tpv3_interface_enable_disable_t *mp;
10237 u8 sw_if_index_set = 0;
10238 u8 enable_disable = 1;
10241 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10243 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10244 sw_if_index_set = 1;
10245 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10246 sw_if_index_set = 1;
10247 else if (unformat (i, "enable"))
10248 enable_disable = 1;
10249 else if (unformat (i, "disable"))
10250 enable_disable = 0;
10255 if (sw_if_index_set == 0)
10257 errmsg ("missing interface name or sw_if_index");
10261 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10263 mp->sw_if_index = ntohl (sw_if_index);
10264 mp->enable_disable = enable_disable;
10272 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10274 unformat_input_t *i = vam->input;
10275 vl_api_l2tpv3_set_lookup_key_t *mp;
10279 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10281 if (unformat (i, "lookup_v6_src"))
10282 key = L2T_LOOKUP_SRC_ADDRESS;
10283 else if (unformat (i, "lookup_v6_dst"))
10284 key = L2T_LOOKUP_DST_ADDRESS;
10285 else if (unformat (i, "lookup_session_id"))
10286 key = L2T_LOOKUP_SESSION_ID;
10291 if (key == (u8) ~ 0)
10293 errmsg ("l2tp session lookup key unset");
10297 M (L2TPV3_SET_LOOKUP_KEY, mp);
10306 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10307 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10309 vat_main_t *vam = &vat_main;
10311 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10312 format_ip6_address, mp->our_address,
10313 format_ip6_address, mp->client_address,
10314 clib_net_to_host_u32 (mp->sw_if_index));
10317 " local cookies %016llx %016llx remote cookie %016llx",
10318 clib_net_to_host_u64 (mp->local_cookie[0]),
10319 clib_net_to_host_u64 (mp->local_cookie[1]),
10320 clib_net_to_host_u64 (mp->remote_cookie));
10322 print (vam->ofp, " local session-id %d remote session-id %d",
10323 clib_net_to_host_u32 (mp->local_session_id),
10324 clib_net_to_host_u32 (mp->remote_session_id));
10326 print (vam->ofp, " l2 specific sublayer %s\n",
10327 mp->l2_sublayer_present ? "preset" : "absent");
10331 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10332 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10334 vat_main_t *vam = &vat_main;
10335 vat_json_node_t *node = NULL;
10336 struct in6_addr addr;
10338 if (VAT_JSON_ARRAY != vam->json_tree.type)
10340 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10341 vat_json_init_array (&vam->json_tree);
10343 node = vat_json_array_add (&vam->json_tree);
10345 vat_json_init_object (node);
10347 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10348 vat_json_object_add_ip6 (node, "our_address", addr);
10349 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10350 vat_json_object_add_ip6 (node, "client_address", addr);
10352 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10353 vat_json_init_array (lc);
10354 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10355 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10356 vat_json_object_add_uint (node, "remote_cookie",
10357 clib_net_to_host_u64 (mp->remote_cookie));
10359 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10360 vat_json_object_add_uint (node, "local_session_id",
10361 clib_net_to_host_u32 (mp->local_session_id));
10362 vat_json_object_add_uint (node, "remote_session_id",
10363 clib_net_to_host_u32 (mp->remote_session_id));
10364 vat_json_object_add_string_copy (node, "l2_sublayer",
10365 mp->l2_sublayer_present ? (u8 *) "present"
10366 : (u8 *) "absent");
10370 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10372 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10373 vl_api_control_ping_t *mp_ping;
10376 /* Get list of l2tpv3-tunnel interfaces */
10377 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10380 /* Use a control ping for synchronization */
10381 M (CONTROL_PING, mp_ping);
10389 static void vl_api_sw_interface_tap_details_t_handler
10390 (vl_api_sw_interface_tap_details_t * mp)
10392 vat_main_t *vam = &vat_main;
10394 print (vam->ofp, "%-16s %d",
10395 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10398 static void vl_api_sw_interface_tap_details_t_handler_json
10399 (vl_api_sw_interface_tap_details_t * mp)
10401 vat_main_t *vam = &vat_main;
10402 vat_json_node_t *node = NULL;
10404 if (VAT_JSON_ARRAY != vam->json_tree.type)
10406 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10407 vat_json_init_array (&vam->json_tree);
10409 node = vat_json_array_add (&vam->json_tree);
10411 vat_json_init_object (node);
10412 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10413 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10417 api_sw_interface_tap_dump (vat_main_t * vam)
10419 vl_api_sw_interface_tap_dump_t *mp;
10420 vl_api_control_ping_t *mp_ping;
10423 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10424 /* Get list of tap interfaces */
10425 M (SW_INTERFACE_TAP_DUMP, mp);
10428 /* Use a control ping for synchronization */
10429 M (CONTROL_PING, mp_ping);
10436 static uword unformat_vxlan_decap_next
10437 (unformat_input_t * input, va_list * args)
10439 u32 *result = va_arg (*args, u32 *);
10442 if (unformat (input, "l2"))
10443 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10444 else if (unformat (input, "%d", &tmp))
10452 api_vxlan_add_del_tunnel (vat_main_t * vam)
10454 unformat_input_t *line_input = vam->input;
10455 vl_api_vxlan_add_del_tunnel_t *mp;
10456 ip46_address_t src, dst;
10458 u8 ipv4_set = 0, ipv6_set = 0;
10462 u32 mcast_sw_if_index = ~0;
10463 u32 encap_vrf_id = 0;
10464 u32 decap_next_index = ~0;
10468 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10469 memset (&src, 0, sizeof src);
10470 memset (&dst, 0, sizeof dst);
10472 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10474 if (unformat (line_input, "del"))
10477 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10483 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10489 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10495 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10500 else if (unformat (line_input, "group %U %U",
10501 unformat_ip4_address, &dst.ip4,
10502 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10504 grp_set = dst_set = 1;
10507 else if (unformat (line_input, "group %U",
10508 unformat_ip4_address, &dst.ip4))
10510 grp_set = dst_set = 1;
10513 else if (unformat (line_input, "group %U %U",
10514 unformat_ip6_address, &dst.ip6,
10515 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10517 grp_set = dst_set = 1;
10520 else if (unformat (line_input, "group %U",
10521 unformat_ip6_address, &dst.ip6))
10523 grp_set = dst_set = 1;
10527 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10529 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10531 else if (unformat (line_input, "decap-next %U",
10532 unformat_vxlan_decap_next, &decap_next_index))
10534 else if (unformat (line_input, "vni %d", &vni))
10538 errmsg ("parse error '%U'", format_unformat_error, line_input);
10545 errmsg ("tunnel src address not specified");
10550 errmsg ("tunnel dst address not specified");
10554 if (grp_set && !ip46_address_is_multicast (&dst))
10556 errmsg ("tunnel group address not multicast");
10559 if (grp_set && mcast_sw_if_index == ~0)
10561 errmsg ("tunnel nonexistent multicast device");
10564 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10566 errmsg ("tunnel dst address must be unicast");
10571 if (ipv4_set && ipv6_set)
10573 errmsg ("both IPv4 and IPv6 addresses specified");
10577 if ((vni == 0) || (vni >> 24))
10579 errmsg ("vni not specified or out of range");
10583 M (VXLAN_ADD_DEL_TUNNEL, mp);
10587 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10588 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10592 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10593 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10595 mp->encap_vrf_id = ntohl (encap_vrf_id);
10596 mp->decap_next_index = ntohl (decap_next_index);
10597 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10598 mp->vni = ntohl (vni);
10599 mp->is_add = is_add;
10600 mp->is_ipv6 = ipv6_set;
10607 static void vl_api_vxlan_tunnel_details_t_handler
10608 (vl_api_vxlan_tunnel_details_t * mp)
10610 vat_main_t *vam = &vat_main;
10611 ip46_address_t src, dst;
10613 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10614 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10616 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10617 ntohl (mp->sw_if_index),
10618 format_ip46_address, &src, IP46_TYPE_ANY,
10619 format_ip46_address, &dst, IP46_TYPE_ANY,
10620 ntohl (mp->encap_vrf_id),
10621 ntohl (mp->decap_next_index), ntohl (mp->vni),
10622 ntohl (mp->mcast_sw_if_index));
10625 static void vl_api_vxlan_tunnel_details_t_handler_json
10626 (vl_api_vxlan_tunnel_details_t * mp)
10628 vat_main_t *vam = &vat_main;
10629 vat_json_node_t *node = NULL;
10631 if (VAT_JSON_ARRAY != vam->json_tree.type)
10633 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10634 vat_json_init_array (&vam->json_tree);
10636 node = vat_json_array_add (&vam->json_tree);
10638 vat_json_init_object (node);
10639 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10642 struct in6_addr ip6;
10644 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10645 vat_json_object_add_ip6 (node, "src_address", ip6);
10646 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10647 vat_json_object_add_ip6 (node, "dst_address", ip6);
10651 struct in_addr ip4;
10653 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10654 vat_json_object_add_ip4 (node, "src_address", ip4);
10655 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10656 vat_json_object_add_ip4 (node, "dst_address", ip4);
10658 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10659 vat_json_object_add_uint (node, "decap_next_index",
10660 ntohl (mp->decap_next_index));
10661 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10662 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10663 vat_json_object_add_uint (node, "mcast_sw_if_index",
10664 ntohl (mp->mcast_sw_if_index));
10668 api_vxlan_tunnel_dump (vat_main_t * vam)
10670 unformat_input_t *i = vam->input;
10671 vl_api_vxlan_tunnel_dump_t *mp;
10672 vl_api_control_ping_t *mp_ping;
10674 u8 sw_if_index_set = 0;
10677 /* Parse args required to build the message */
10678 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10680 if (unformat (i, "sw_if_index %d", &sw_if_index))
10681 sw_if_index_set = 1;
10686 if (sw_if_index_set == 0)
10691 if (!vam->json_output)
10693 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10694 "sw_if_index", "src_address", "dst_address",
10695 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10698 /* Get list of vxlan-tunnel interfaces */
10699 M (VXLAN_TUNNEL_DUMP, mp);
10701 mp->sw_if_index = htonl (sw_if_index);
10705 /* Use a control ping for synchronization */
10706 M (CONTROL_PING, mp_ping);
10714 api_gre_add_del_tunnel (vat_main_t * vam)
10716 unformat_input_t *line_input = vam->input;
10717 vl_api_gre_add_del_tunnel_t *mp;
10718 ip4_address_t src4, dst4;
10723 u32 outer_fib_id = 0;
10726 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10728 if (unformat (line_input, "del"))
10730 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10732 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10734 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10736 else if (unformat (line_input, "teb"))
10740 errmsg ("parse error '%U'", format_unformat_error, line_input);
10747 errmsg ("tunnel src address not specified");
10752 errmsg ("tunnel dst address not specified");
10757 M (GRE_ADD_DEL_TUNNEL, mp);
10759 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10760 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10761 mp->outer_fib_id = ntohl (outer_fib_id);
10762 mp->is_add = is_add;
10770 static void vl_api_gre_tunnel_details_t_handler
10771 (vl_api_gre_tunnel_details_t * mp)
10773 vat_main_t *vam = &vat_main;
10775 print (vam->ofp, "%11d%15U%15U%6d%14d",
10776 ntohl (mp->sw_if_index),
10777 format_ip4_address, &mp->src_address,
10778 format_ip4_address, &mp->dst_address,
10779 mp->teb, ntohl (mp->outer_fib_id));
10782 static void vl_api_gre_tunnel_details_t_handler_json
10783 (vl_api_gre_tunnel_details_t * mp)
10785 vat_main_t *vam = &vat_main;
10786 vat_json_node_t *node = NULL;
10787 struct in_addr ip4;
10789 if (VAT_JSON_ARRAY != vam->json_tree.type)
10791 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10792 vat_json_init_array (&vam->json_tree);
10794 node = vat_json_array_add (&vam->json_tree);
10796 vat_json_init_object (node);
10797 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10798 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10799 vat_json_object_add_ip4 (node, "src_address", ip4);
10800 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10801 vat_json_object_add_ip4 (node, "dst_address", ip4);
10802 vat_json_object_add_uint (node, "teb", mp->teb);
10803 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10807 api_gre_tunnel_dump (vat_main_t * vam)
10809 unformat_input_t *i = vam->input;
10810 vl_api_gre_tunnel_dump_t *mp;
10811 vl_api_control_ping_t *mp_ping;
10813 u8 sw_if_index_set = 0;
10816 /* Parse args required to build the message */
10817 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10819 if (unformat (i, "sw_if_index %d", &sw_if_index))
10820 sw_if_index_set = 1;
10825 if (sw_if_index_set == 0)
10830 if (!vam->json_output)
10832 print (vam->ofp, "%11s%15s%15s%6s%14s",
10833 "sw_if_index", "src_address", "dst_address", "teb",
10837 /* Get list of gre-tunnel interfaces */
10838 M (GRE_TUNNEL_DUMP, mp);
10840 mp->sw_if_index = htonl (sw_if_index);
10844 /* Use a control ping for synchronization */
10845 M (CONTROL_PING, mp_ping);
10853 api_l2_fib_clear_table (vat_main_t * vam)
10855 // unformat_input_t * i = vam->input;
10856 vl_api_l2_fib_clear_table_t *mp;
10859 M (L2_FIB_CLEAR_TABLE, mp);
10867 api_l2_interface_efp_filter (vat_main_t * vam)
10869 unformat_input_t *i = vam->input;
10870 vl_api_l2_interface_efp_filter_t *mp;
10873 u8 sw_if_index_set = 0;
10876 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10878 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10879 sw_if_index_set = 1;
10880 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10881 sw_if_index_set = 1;
10882 else if (unformat (i, "enable"))
10884 else if (unformat (i, "disable"))
10888 clib_warning ("parse error '%U'", format_unformat_error, i);
10893 if (sw_if_index_set == 0)
10895 errmsg ("missing sw_if_index");
10899 M (L2_INTERFACE_EFP_FILTER, mp);
10901 mp->sw_if_index = ntohl (sw_if_index);
10902 mp->enable_disable = enable;
10909 #define foreach_vtr_op \
10910 _("disable", L2_VTR_DISABLED) \
10911 _("push-1", L2_VTR_PUSH_1) \
10912 _("push-2", L2_VTR_PUSH_2) \
10913 _("pop-1", L2_VTR_POP_1) \
10914 _("pop-2", L2_VTR_POP_2) \
10915 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10916 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10917 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10918 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10921 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10923 unformat_input_t *i = vam->input;
10924 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10926 u8 sw_if_index_set = 0;
10929 u32 push_dot1q = 1;
10934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10936 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10937 sw_if_index_set = 1;
10938 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10939 sw_if_index_set = 1;
10940 else if (unformat (i, "vtr_op %d", &vtr_op))
10942 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
10945 else if (unformat (i, "push_dot1q %d", &push_dot1q))
10947 else if (unformat (i, "tag1 %d", &tag1))
10949 else if (unformat (i, "tag2 %d", &tag2))
10953 clib_warning ("parse error '%U'", format_unformat_error, i);
10958 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
10960 errmsg ("missing vtr operation or sw_if_index");
10964 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
10965 mp->sw_if_index = ntohl (sw_if_index);
10966 mp->vtr_op = ntohl (vtr_op);
10967 mp->push_dot1q = ntohl (push_dot1q);
10968 mp->tag1 = ntohl (tag1);
10969 mp->tag2 = ntohl (tag2);
10977 api_create_vhost_user_if (vat_main_t * vam)
10979 unformat_input_t *i = vam->input;
10980 vl_api_create_vhost_user_if_t *mp;
10983 u8 file_name_set = 0;
10984 u32 custom_dev_instance = ~0;
10986 u8 use_custom_mac = 0;
10990 /* Shut up coverity */
10991 memset (hwaddr, 0, sizeof (hwaddr));
10993 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10995 if (unformat (i, "socket %s", &file_name))
10999 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11001 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11002 use_custom_mac = 1;
11003 else if (unformat (i, "server"))
11005 else if (unformat (i, "tag %s", &tag))
11011 if (file_name_set == 0)
11013 errmsg ("missing socket file name");
11017 if (vec_len (file_name) > 255)
11019 errmsg ("socket file name too long");
11022 vec_add1 (file_name, 0);
11024 M (CREATE_VHOST_USER_IF, mp);
11026 mp->is_server = is_server;
11027 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11028 vec_free (file_name);
11029 if (custom_dev_instance != ~0)
11032 mp->custom_dev_instance = ntohl (custom_dev_instance);
11034 mp->use_custom_mac = use_custom_mac;
11035 clib_memcpy (mp->mac_address, hwaddr, 6);
11037 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11046 api_modify_vhost_user_if (vat_main_t * vam)
11048 unformat_input_t *i = vam->input;
11049 vl_api_modify_vhost_user_if_t *mp;
11052 u8 file_name_set = 0;
11053 u32 custom_dev_instance = ~0;
11054 u8 sw_if_index_set = 0;
11055 u32 sw_if_index = (u32) ~ 0;
11058 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11060 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11061 sw_if_index_set = 1;
11062 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11063 sw_if_index_set = 1;
11064 else if (unformat (i, "socket %s", &file_name))
11068 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11070 else if (unformat (i, "server"))
11076 if (sw_if_index_set == 0)
11078 errmsg ("missing sw_if_index or interface name");
11082 if (file_name_set == 0)
11084 errmsg ("missing socket file name");
11088 if (vec_len (file_name) > 255)
11090 errmsg ("socket file name too long");
11093 vec_add1 (file_name, 0);
11095 M (MODIFY_VHOST_USER_IF, mp);
11097 mp->sw_if_index = ntohl (sw_if_index);
11098 mp->is_server = is_server;
11099 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11100 vec_free (file_name);
11101 if (custom_dev_instance != ~0)
11104 mp->custom_dev_instance = ntohl (custom_dev_instance);
11113 api_delete_vhost_user_if (vat_main_t * vam)
11115 unformat_input_t *i = vam->input;
11116 vl_api_delete_vhost_user_if_t *mp;
11117 u32 sw_if_index = ~0;
11118 u8 sw_if_index_set = 0;
11121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11123 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11124 sw_if_index_set = 1;
11125 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11126 sw_if_index_set = 1;
11131 if (sw_if_index_set == 0)
11133 errmsg ("missing sw_if_index or interface name");
11138 M (DELETE_VHOST_USER_IF, mp);
11140 mp->sw_if_index = ntohl (sw_if_index);
11147 static void vl_api_sw_interface_vhost_user_details_t_handler
11148 (vl_api_sw_interface_vhost_user_details_t * mp)
11150 vat_main_t *vam = &vat_main;
11152 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11153 (char *) mp->interface_name,
11154 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11155 clib_net_to_host_u64 (mp->features), mp->is_server,
11156 ntohl (mp->num_regions), (char *) mp->sock_filename);
11157 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11160 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11161 (vl_api_sw_interface_vhost_user_details_t * mp)
11163 vat_main_t *vam = &vat_main;
11164 vat_json_node_t *node = NULL;
11166 if (VAT_JSON_ARRAY != vam->json_tree.type)
11168 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11169 vat_json_init_array (&vam->json_tree);
11171 node = vat_json_array_add (&vam->json_tree);
11173 vat_json_init_object (node);
11174 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11175 vat_json_object_add_string_copy (node, "interface_name",
11176 mp->interface_name);
11177 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11178 ntohl (mp->virtio_net_hdr_sz));
11179 vat_json_object_add_uint (node, "features",
11180 clib_net_to_host_u64 (mp->features));
11181 vat_json_object_add_uint (node, "is_server", mp->is_server);
11182 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11183 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11184 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11188 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11190 vl_api_sw_interface_vhost_user_dump_t *mp;
11191 vl_api_control_ping_t *mp_ping;
11194 "Interface name idx hdr_sz features server regions filename");
11196 /* Get list of vhost-user interfaces */
11197 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11200 /* Use a control ping for synchronization */
11201 M (CONTROL_PING, mp_ping);
11209 api_show_version (vat_main_t * vam)
11211 vl_api_show_version_t *mp;
11214 M (SHOW_VERSION, mp);
11223 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11225 unformat_input_t *line_input = vam->input;
11226 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11227 ip4_address_t local4, remote4;
11228 ip6_address_t local6, remote6;
11230 u8 ipv4_set = 0, ipv6_set = 0;
11233 u32 encap_vrf_id = 0;
11234 u32 decap_vrf_id = 0;
11240 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11242 if (unformat (line_input, "del"))
11244 else if (unformat (line_input, "local %U",
11245 unformat_ip4_address, &local4))
11250 else if (unformat (line_input, "remote %U",
11251 unformat_ip4_address, &remote4))
11256 else if (unformat (line_input, "local %U",
11257 unformat_ip6_address, &local6))
11262 else if (unformat (line_input, "remote %U",
11263 unformat_ip6_address, &remote6))
11268 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11270 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11272 else if (unformat (line_input, "vni %d", &vni))
11274 else if (unformat (line_input, "next-ip4"))
11276 else if (unformat (line_input, "next-ip6"))
11278 else if (unformat (line_input, "next-ethernet"))
11280 else if (unformat (line_input, "next-nsh"))
11284 errmsg ("parse error '%U'", format_unformat_error, line_input);
11289 if (local_set == 0)
11291 errmsg ("tunnel local address not specified");
11294 if (remote_set == 0)
11296 errmsg ("tunnel remote address not specified");
11299 if (ipv4_set && ipv6_set)
11301 errmsg ("both IPv4 and IPv6 addresses specified");
11307 errmsg ("vni not specified");
11311 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11316 clib_memcpy (&mp->local, &local6, sizeof (local6));
11317 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11321 clib_memcpy (&mp->local, &local4, sizeof (local4));
11322 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11325 mp->encap_vrf_id = ntohl (encap_vrf_id);
11326 mp->decap_vrf_id = ntohl (decap_vrf_id);
11327 mp->protocol = protocol;
11328 mp->vni = ntohl (vni);
11329 mp->is_add = is_add;
11330 mp->is_ipv6 = ipv6_set;
11337 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11338 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11340 vat_main_t *vam = &vat_main;
11342 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11343 ntohl (mp->sw_if_index),
11344 format_ip46_address, &(mp->local[0]),
11345 format_ip46_address, &(mp->remote[0]),
11347 ntohl (mp->protocol),
11348 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11351 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11352 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11354 vat_main_t *vam = &vat_main;
11355 vat_json_node_t *node = NULL;
11356 struct in_addr ip4;
11357 struct in6_addr ip6;
11359 if (VAT_JSON_ARRAY != vam->json_tree.type)
11361 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11362 vat_json_init_array (&vam->json_tree);
11364 node = vat_json_array_add (&vam->json_tree);
11366 vat_json_init_object (node);
11367 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11370 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11371 vat_json_object_add_ip6 (node, "local", ip6);
11372 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11373 vat_json_object_add_ip6 (node, "remote", ip6);
11377 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11378 vat_json_object_add_ip4 (node, "local", ip4);
11379 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11380 vat_json_object_add_ip4 (node, "remote", ip4);
11382 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11383 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11384 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11385 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11386 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11390 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11392 unformat_input_t *i = vam->input;
11393 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11394 vl_api_control_ping_t *mp_ping;
11396 u8 sw_if_index_set = 0;
11399 /* Parse args required to build the message */
11400 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11402 if (unformat (i, "sw_if_index %d", &sw_if_index))
11403 sw_if_index_set = 1;
11408 if (sw_if_index_set == 0)
11413 if (!vam->json_output)
11415 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11416 "sw_if_index", "local", "remote", "vni",
11417 "protocol", "encap_vrf_id", "decap_vrf_id");
11420 /* Get list of vxlan-tunnel interfaces */
11421 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11423 mp->sw_if_index = htonl (sw_if_index);
11427 /* Use a control ping for synchronization */
11428 M (CONTROL_PING, mp_ping);
11436 format_l2_fib_mac_address (u8 * s, va_list * args)
11438 u8 *a = va_arg (*args, u8 *);
11440 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11441 a[2], a[3], a[4], a[5], a[6], a[7]);
11444 static void vl_api_l2_fib_table_entry_t_handler
11445 (vl_api_l2_fib_table_entry_t * mp)
11447 vat_main_t *vam = &vat_main;
11449 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11451 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11452 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11456 static void vl_api_l2_fib_table_entry_t_handler_json
11457 (vl_api_l2_fib_table_entry_t * mp)
11459 vat_main_t *vam = &vat_main;
11460 vat_json_node_t *node = NULL;
11462 if (VAT_JSON_ARRAY != vam->json_tree.type)
11464 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11465 vat_json_init_array (&vam->json_tree);
11467 node = vat_json_array_add (&vam->json_tree);
11469 vat_json_init_object (node);
11470 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11471 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11472 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11473 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11474 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11475 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11479 api_l2_fib_table_dump (vat_main_t * vam)
11481 unformat_input_t *i = vam->input;
11482 vl_api_l2_fib_table_dump_t *mp;
11483 vl_api_control_ping_t *mp_ping;
11488 /* Parse args required to build the message */
11489 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11491 if (unformat (i, "bd_id %d", &bd_id))
11497 if (bd_id_set == 0)
11499 errmsg ("missing bridge domain");
11503 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11505 /* Get list of l2 fib entries */
11506 M (L2_FIB_TABLE_DUMP, mp);
11508 mp->bd_id = ntohl (bd_id);
11511 /* Use a control ping for synchronization */
11512 M (CONTROL_PING, mp_ping);
11521 api_interface_name_renumber (vat_main_t * vam)
11523 unformat_input_t *line_input = vam->input;
11524 vl_api_interface_name_renumber_t *mp;
11525 u32 sw_if_index = ~0;
11526 u32 new_show_dev_instance = ~0;
11529 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11531 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11534 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11536 else if (unformat (line_input, "new_show_dev_instance %d",
11537 &new_show_dev_instance))
11543 if (sw_if_index == ~0)
11545 errmsg ("missing interface name or sw_if_index");
11549 if (new_show_dev_instance == ~0)
11551 errmsg ("missing new_show_dev_instance");
11555 M (INTERFACE_NAME_RENUMBER, mp);
11557 mp->sw_if_index = ntohl (sw_if_index);
11558 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11566 api_want_ip4_arp_events (vat_main_t * vam)
11568 unformat_input_t *line_input = vam->input;
11569 vl_api_want_ip4_arp_events_t *mp;
11570 ip4_address_t address;
11571 int address_set = 0;
11572 u32 enable_disable = 1;
11575 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11577 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11579 else if (unformat (line_input, "del"))
11580 enable_disable = 0;
11585 if (address_set == 0)
11587 errmsg ("missing addresses");
11591 M (WANT_IP4_ARP_EVENTS, mp);
11592 mp->enable_disable = enable_disable;
11593 mp->pid = getpid ();
11594 mp->address = address.as_u32;
11602 api_want_ip6_nd_events (vat_main_t * vam)
11604 unformat_input_t *line_input = vam->input;
11605 vl_api_want_ip6_nd_events_t *mp;
11606 ip6_address_t address;
11607 int address_set = 0;
11608 u32 enable_disable = 1;
11611 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11613 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11615 else if (unformat (line_input, "del"))
11616 enable_disable = 0;
11621 if (address_set == 0)
11623 errmsg ("missing addresses");
11627 M (WANT_IP6_ND_EVENTS, mp);
11628 mp->enable_disable = enable_disable;
11629 mp->pid = getpid ();
11630 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11638 api_input_acl_set_interface (vat_main_t * vam)
11640 unformat_input_t *i = vam->input;
11641 vl_api_input_acl_set_interface_t *mp;
11643 int sw_if_index_set;
11644 u32 ip4_table_index = ~0;
11645 u32 ip6_table_index = ~0;
11646 u32 l2_table_index = ~0;
11650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11652 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11653 sw_if_index_set = 1;
11654 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11655 sw_if_index_set = 1;
11656 else if (unformat (i, "del"))
11658 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11660 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11662 else if (unformat (i, "l2-table %d", &l2_table_index))
11666 clib_warning ("parse error '%U'", format_unformat_error, i);
11671 if (sw_if_index_set == 0)
11673 errmsg ("missing interface name or sw_if_index");
11677 M (INPUT_ACL_SET_INTERFACE, mp);
11679 mp->sw_if_index = ntohl (sw_if_index);
11680 mp->ip4_table_index = ntohl (ip4_table_index);
11681 mp->ip6_table_index = ntohl (ip6_table_index);
11682 mp->l2_table_index = ntohl (l2_table_index);
11683 mp->is_add = is_add;
11691 api_ip_address_dump (vat_main_t * vam)
11693 unformat_input_t *i = vam->input;
11694 vl_api_ip_address_dump_t *mp;
11695 vl_api_control_ping_t *mp_ping;
11696 u32 sw_if_index = ~0;
11697 u8 sw_if_index_set = 0;
11702 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11704 if (unformat (i, "sw_if_index %d", &sw_if_index))
11705 sw_if_index_set = 1;
11707 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11708 sw_if_index_set = 1;
11709 else if (unformat (i, "ipv4"))
11711 else if (unformat (i, "ipv6"))
11717 if (ipv4_set && ipv6_set)
11719 errmsg ("ipv4 and ipv6 flags cannot be both set");
11723 if ((!ipv4_set) && (!ipv6_set))
11725 errmsg ("no ipv4 nor ipv6 flag set");
11729 if (sw_if_index_set == 0)
11731 errmsg ("missing interface name or sw_if_index");
11735 vam->current_sw_if_index = sw_if_index;
11736 vam->is_ipv6 = ipv6_set;
11738 M (IP_ADDRESS_DUMP, mp);
11739 mp->sw_if_index = ntohl (sw_if_index);
11740 mp->is_ipv6 = ipv6_set;
11743 /* Use a control ping for synchronization */
11744 M (CONTROL_PING, mp_ping);
11752 api_ip_dump (vat_main_t * vam)
11754 vl_api_ip_dump_t *mp;
11755 vl_api_control_ping_t *mp_ping;
11756 unformat_input_t *in = vam->input;
11763 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11765 if (unformat (in, "ipv4"))
11767 else if (unformat (in, "ipv6"))
11773 if (ipv4_set && ipv6_set)
11775 errmsg ("ipv4 and ipv6 flags cannot be both set");
11779 if ((!ipv4_set) && (!ipv6_set))
11781 errmsg ("no ipv4 nor ipv6 flag set");
11785 is_ipv6 = ipv6_set;
11786 vam->is_ipv6 = is_ipv6;
11788 /* free old data */
11789 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11791 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11793 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11796 mp->is_ipv6 = ipv6_set;
11799 /* Use a control ping for synchronization */
11800 M (CONTROL_PING, mp_ping);
11808 api_ipsec_spd_add_del (vat_main_t * vam)
11810 unformat_input_t *i = vam->input;
11811 vl_api_ipsec_spd_add_del_t *mp;
11816 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11818 if (unformat (i, "spd_id %d", &spd_id))
11820 else if (unformat (i, "del"))
11824 clib_warning ("parse error '%U'", format_unformat_error, i);
11830 errmsg ("spd_id must be set");
11834 M (IPSEC_SPD_ADD_DEL, mp);
11836 mp->spd_id = ntohl (spd_id);
11837 mp->is_add = is_add;
11845 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11847 unformat_input_t *i = vam->input;
11848 vl_api_ipsec_interface_add_del_spd_t *mp;
11850 u8 sw_if_index_set = 0;
11851 u32 spd_id = (u32) ~ 0;
11855 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11857 if (unformat (i, "del"))
11859 else if (unformat (i, "spd_id %d", &spd_id))
11862 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11863 sw_if_index_set = 1;
11864 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11865 sw_if_index_set = 1;
11868 clib_warning ("parse error '%U'", format_unformat_error, i);
11874 if (spd_id == (u32) ~ 0)
11876 errmsg ("spd_id must be set");
11880 if (sw_if_index_set == 0)
11882 errmsg ("missing interface name or sw_if_index");
11886 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
11888 mp->spd_id = ntohl (spd_id);
11889 mp->sw_if_index = ntohl (sw_if_index);
11890 mp->is_add = is_add;
11898 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11900 unformat_input_t *i = vam->input;
11901 vl_api_ipsec_spd_add_del_entry_t *mp;
11902 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11903 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11905 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11906 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11907 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11908 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11911 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11912 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11913 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11914 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11915 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11916 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11918 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11920 if (unformat (i, "del"))
11922 if (unformat (i, "outbound"))
11924 if (unformat (i, "inbound"))
11926 else if (unformat (i, "spd_id %d", &spd_id))
11928 else if (unformat (i, "sa_id %d", &sa_id))
11930 else if (unformat (i, "priority %d", &priority))
11932 else if (unformat (i, "protocol %d", &protocol))
11934 else if (unformat (i, "lport_start %d", &lport_start))
11936 else if (unformat (i, "lport_stop %d", &lport_stop))
11938 else if (unformat (i, "rport_start %d", &rport_start))
11940 else if (unformat (i, "rport_stop %d", &rport_stop))
11944 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
11950 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
11957 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
11963 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
11970 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
11976 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
11983 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
11989 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
11995 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
11997 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
11999 clib_warning ("unsupported action: 'resolve'");
12005 clib_warning ("parse error '%U'", format_unformat_error, i);
12011 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12013 mp->spd_id = ntohl (spd_id);
12014 mp->priority = ntohl (priority);
12015 mp->is_outbound = is_outbound;
12017 mp->is_ipv6 = is_ipv6;
12018 if (is_ipv6 || is_ip_any)
12020 clib_memcpy (mp->remote_address_start, &raddr6_start,
12021 sizeof (ip6_address_t));
12022 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12023 sizeof (ip6_address_t));
12024 clib_memcpy (mp->local_address_start, &laddr6_start,
12025 sizeof (ip6_address_t));
12026 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12027 sizeof (ip6_address_t));
12031 clib_memcpy (mp->remote_address_start, &raddr4_start,
12032 sizeof (ip4_address_t));
12033 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12034 sizeof (ip4_address_t));
12035 clib_memcpy (mp->local_address_start, &laddr4_start,
12036 sizeof (ip4_address_t));
12037 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12038 sizeof (ip4_address_t));
12040 mp->protocol = (u8) protocol;
12041 mp->local_port_start = ntohs ((u16) lport_start);
12042 mp->local_port_stop = ntohs ((u16) lport_stop);
12043 mp->remote_port_start = ntohs ((u16) rport_start);
12044 mp->remote_port_stop = ntohs ((u16) rport_stop);
12045 mp->policy = (u8) policy;
12046 mp->sa_id = ntohl (sa_id);
12047 mp->is_add = is_add;
12048 mp->is_ip_any = is_ip_any;
12055 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12057 unformat_input_t *i = vam->input;
12058 vl_api_ipsec_sad_add_del_entry_t *mp;
12059 u32 sad_id = 0, spi = 0;
12060 u8 *ck = 0, *ik = 0;
12063 u8 protocol = IPSEC_PROTOCOL_AH;
12064 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12065 u32 crypto_alg = 0, integ_alg = 0;
12066 ip4_address_t tun_src4;
12067 ip4_address_t tun_dst4;
12068 ip6_address_t tun_src6;
12069 ip6_address_t tun_dst6;
12072 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12074 if (unformat (i, "del"))
12076 else if (unformat (i, "sad_id %d", &sad_id))
12078 else if (unformat (i, "spi %d", &spi))
12080 else if (unformat (i, "esp"))
12081 protocol = IPSEC_PROTOCOL_ESP;
12082 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12085 is_tunnel_ipv6 = 0;
12087 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12090 is_tunnel_ipv6 = 0;
12092 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12095 is_tunnel_ipv6 = 1;
12097 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12100 is_tunnel_ipv6 = 1;
12104 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12106 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12107 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12109 clib_warning ("unsupported crypto-alg: '%U'",
12110 format_ipsec_crypto_alg, crypto_alg);
12114 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12118 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12120 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12121 integ_alg >= IPSEC_INTEG_N_ALG)
12123 clib_warning ("unsupported integ-alg: '%U'",
12124 format_ipsec_integ_alg, integ_alg);
12128 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12132 clib_warning ("parse error '%U'", format_unformat_error, i);
12138 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12140 mp->sad_id = ntohl (sad_id);
12141 mp->is_add = is_add;
12142 mp->protocol = protocol;
12143 mp->spi = ntohl (spi);
12144 mp->is_tunnel = is_tunnel;
12145 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12146 mp->crypto_algorithm = crypto_alg;
12147 mp->integrity_algorithm = integ_alg;
12148 mp->crypto_key_length = vec_len (ck);
12149 mp->integrity_key_length = vec_len (ik);
12151 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12152 mp->crypto_key_length = sizeof (mp->crypto_key);
12154 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12155 mp->integrity_key_length = sizeof (mp->integrity_key);
12158 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12160 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12164 if (is_tunnel_ipv6)
12166 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12167 sizeof (ip6_address_t));
12168 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12169 sizeof (ip6_address_t));
12173 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12174 sizeof (ip4_address_t));
12175 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12176 sizeof (ip4_address_t));
12186 api_ipsec_sa_set_key (vat_main_t * vam)
12188 unformat_input_t *i = vam->input;
12189 vl_api_ipsec_sa_set_key_t *mp;
12191 u8 *ck = 0, *ik = 0;
12194 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12196 if (unformat (i, "sa_id %d", &sa_id))
12198 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12200 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12204 clib_warning ("parse error '%U'", format_unformat_error, i);
12209 M (IPSEC_SA_SET_KEY, mp);
12211 mp->sa_id = ntohl (sa_id);
12212 mp->crypto_key_length = vec_len (ck);
12213 mp->integrity_key_length = vec_len (ik);
12215 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12216 mp->crypto_key_length = sizeof (mp->crypto_key);
12218 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12219 mp->integrity_key_length = sizeof (mp->integrity_key);
12222 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12224 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12232 api_ikev2_profile_add_del (vat_main_t * vam)
12234 unformat_input_t *i = vam->input;
12235 vl_api_ikev2_profile_add_del_t *mp;
12240 const char *valid_chars = "a-zA-Z0-9_";
12242 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12244 if (unformat (i, "del"))
12246 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12247 vec_add1 (name, 0);
12250 errmsg ("parse error '%U'", format_unformat_error, i);
12255 if (!vec_len (name))
12257 errmsg ("profile name must be specified");
12261 if (vec_len (name) > 64)
12263 errmsg ("profile name too long");
12267 M (IKEV2_PROFILE_ADD_DEL, mp);
12269 clib_memcpy (mp->name, name, vec_len (name));
12270 mp->is_add = is_add;
12279 api_ikev2_profile_set_auth (vat_main_t * vam)
12281 unformat_input_t *i = vam->input;
12282 vl_api_ikev2_profile_set_auth_t *mp;
12285 u32 auth_method = 0;
12289 const char *valid_chars = "a-zA-Z0-9_";
12291 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12293 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12294 vec_add1 (name, 0);
12295 else if (unformat (i, "auth_method %U",
12296 unformat_ikev2_auth_method, &auth_method))
12298 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12300 else if (unformat (i, "auth_data %v", &data))
12304 errmsg ("parse error '%U'", format_unformat_error, i);
12309 if (!vec_len (name))
12311 errmsg ("profile name must be specified");
12315 if (vec_len (name) > 64)
12317 errmsg ("profile name too long");
12321 if (!vec_len (data))
12323 errmsg ("auth_data must be specified");
12329 errmsg ("auth_method must be specified");
12333 M (IKEV2_PROFILE_SET_AUTH, mp);
12335 mp->is_hex = is_hex;
12336 mp->auth_method = (u8) auth_method;
12337 mp->data_len = vec_len (data);
12338 clib_memcpy (mp->name, name, vec_len (name));
12339 clib_memcpy (mp->data, data, vec_len (data));
12349 api_ikev2_profile_set_id (vat_main_t * vam)
12351 unformat_input_t *i = vam->input;
12352 vl_api_ikev2_profile_set_id_t *mp;
12360 const char *valid_chars = "a-zA-Z0-9_";
12362 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12364 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12365 vec_add1 (name, 0);
12366 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12368 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12370 data = vec_new (u8, 4);
12371 clib_memcpy (data, ip4.as_u8, 4);
12373 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12375 else if (unformat (i, "id_data %v", &data))
12377 else if (unformat (i, "local"))
12379 else if (unformat (i, "remote"))
12383 errmsg ("parse error '%U'", format_unformat_error, i);
12388 if (!vec_len (name))
12390 errmsg ("profile name must be specified");
12394 if (vec_len (name) > 64)
12396 errmsg ("profile name too long");
12400 if (!vec_len (data))
12402 errmsg ("id_data must be specified");
12408 errmsg ("id_type must be specified");
12412 M (IKEV2_PROFILE_SET_ID, mp);
12414 mp->is_local = is_local;
12415 mp->id_type = (u8) id_type;
12416 mp->data_len = vec_len (data);
12417 clib_memcpy (mp->name, name, vec_len (name));
12418 clib_memcpy (mp->data, data, vec_len (data));
12428 api_ikev2_profile_set_ts (vat_main_t * vam)
12430 unformat_input_t *i = vam->input;
12431 vl_api_ikev2_profile_set_ts_t *mp;
12434 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12435 ip4_address_t start_addr, end_addr;
12437 const char *valid_chars = "a-zA-Z0-9_";
12440 start_addr.as_u32 = 0;
12441 end_addr.as_u32 = (u32) ~ 0;
12443 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12445 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12446 vec_add1 (name, 0);
12447 else if (unformat (i, "protocol %d", &proto))
12449 else if (unformat (i, "start_port %d", &start_port))
12451 else if (unformat (i, "end_port %d", &end_port))
12454 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12456 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12458 else if (unformat (i, "local"))
12460 else if (unformat (i, "remote"))
12464 errmsg ("parse error '%U'", format_unformat_error, i);
12469 if (!vec_len (name))
12471 errmsg ("profile name must be specified");
12475 if (vec_len (name) > 64)
12477 errmsg ("profile name too long");
12481 M (IKEV2_PROFILE_SET_TS, mp);
12483 mp->is_local = is_local;
12484 mp->proto = (u8) proto;
12485 mp->start_port = (u16) start_port;
12486 mp->end_port = (u16) end_port;
12487 mp->start_addr = start_addr.as_u32;
12488 mp->end_addr = end_addr.as_u32;
12489 clib_memcpy (mp->name, name, vec_len (name));
12498 api_ikev2_set_local_key (vat_main_t * vam)
12500 unformat_input_t *i = vam->input;
12501 vl_api_ikev2_set_local_key_t *mp;
12505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12507 if (unformat (i, "file %v", &file))
12508 vec_add1 (file, 0);
12511 errmsg ("parse error '%U'", format_unformat_error, i);
12516 if (!vec_len (file))
12518 errmsg ("RSA key file must be specified");
12522 if (vec_len (file) > 256)
12524 errmsg ("file name too long");
12528 M (IKEV2_SET_LOCAL_KEY, mp);
12530 clib_memcpy (mp->key_file, file, vec_len (file));
12539 api_ikev2_set_responder (vat_main_t * vam)
12541 unformat_input_t *i = vam->input;
12542 vl_api_ikev2_set_responder_t *mp;
12545 u32 sw_if_index = ~0;
12546 ip4_address_t address;
12548 const char *valid_chars = "a-zA-Z0-9_";
12550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12553 (i, "%U interface %d address %U", unformat_token, valid_chars,
12554 &name, &sw_if_index, unformat_ip4_address, &address))
12555 vec_add1 (name, 0);
12558 errmsg ("parse error '%U'", format_unformat_error, i);
12563 if (!vec_len (name))
12565 errmsg ("profile name must be specified");
12569 if (vec_len (name) > 64)
12571 errmsg ("profile name too long");
12575 M (IKEV2_SET_RESPONDER, mp);
12577 clib_memcpy (mp->name, name, vec_len (name));
12580 mp->sw_if_index = sw_if_index;
12581 clib_memcpy (mp->address, &address, sizeof (address));
12589 api_ikev2_set_ike_transforms (vat_main_t * vam)
12591 unformat_input_t *i = vam->input;
12592 vl_api_ikev2_set_ike_transforms_t *mp;
12595 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12597 const char *valid_chars = "a-zA-Z0-9_";
12599 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12601 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12602 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12603 vec_add1 (name, 0);
12606 errmsg ("parse error '%U'", format_unformat_error, i);
12611 if (!vec_len (name))
12613 errmsg ("profile name must be specified");
12617 if (vec_len (name) > 64)
12619 errmsg ("profile name too long");
12623 M (IKEV2_SET_IKE_TRANSFORMS, mp);
12625 clib_memcpy (mp->name, name, vec_len (name));
12627 mp->crypto_alg = crypto_alg;
12628 mp->crypto_key_size = crypto_key_size;
12629 mp->integ_alg = integ_alg;
12630 mp->dh_group = dh_group;
12639 api_ikev2_set_esp_transforms (vat_main_t * vam)
12641 unformat_input_t *i = vam->input;
12642 vl_api_ikev2_set_esp_transforms_t *mp;
12645 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12647 const char *valid_chars = "a-zA-Z0-9_";
12649 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12651 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12652 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12653 vec_add1 (name, 0);
12656 errmsg ("parse error '%U'", format_unformat_error, i);
12661 if (!vec_len (name))
12663 errmsg ("profile name must be specified");
12667 if (vec_len (name) > 64)
12669 errmsg ("profile name too long");
12673 M (IKEV2_SET_ESP_TRANSFORMS, mp);
12675 clib_memcpy (mp->name, name, vec_len (name));
12677 mp->crypto_alg = crypto_alg;
12678 mp->crypto_key_size = crypto_key_size;
12679 mp->integ_alg = integ_alg;
12680 mp->dh_group = dh_group;
12688 api_ikev2_set_sa_lifetime (vat_main_t * vam)
12690 unformat_input_t *i = vam->input;
12691 vl_api_ikev2_set_sa_lifetime_t *mp;
12694 u64 lifetime, lifetime_maxdata;
12695 u32 lifetime_jitter, handover;
12697 const char *valid_chars = "a-zA-Z0-9_";
12699 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12701 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
12702 &lifetime, &lifetime_jitter, &handover,
12703 &lifetime_maxdata))
12704 vec_add1 (name, 0);
12707 errmsg ("parse error '%U'", format_unformat_error, i);
12712 if (!vec_len (name))
12714 errmsg ("profile name must be specified");
12718 if (vec_len (name) > 64)
12720 errmsg ("profile name too long");
12724 M (IKEV2_SET_SA_LIFETIME, mp);
12726 clib_memcpy (mp->name, name, vec_len (name));
12728 mp->lifetime = lifetime;
12729 mp->lifetime_jitter = lifetime_jitter;
12730 mp->handover = handover;
12731 mp->lifetime_maxdata = lifetime_maxdata;
12739 api_ikev2_initiate_sa_init (vat_main_t * vam)
12741 unformat_input_t *i = vam->input;
12742 vl_api_ikev2_initiate_sa_init_t *mp;
12746 const char *valid_chars = "a-zA-Z0-9_";
12748 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12750 if (unformat (i, "%U", unformat_token, valid_chars, &name))
12751 vec_add1 (name, 0);
12754 errmsg ("parse error '%U'", format_unformat_error, i);
12759 if (!vec_len (name))
12761 errmsg ("profile name must be specified");
12765 if (vec_len (name) > 64)
12767 errmsg ("profile name too long");
12771 M (IKEV2_INITIATE_SA_INIT, mp);
12773 clib_memcpy (mp->name, name, vec_len (name));
12782 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
12784 unformat_input_t *i = vam->input;
12785 vl_api_ikev2_initiate_del_ike_sa_t *mp;
12790 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12792 if (unformat (i, "%lx", &ispi))
12796 errmsg ("parse error '%U'", format_unformat_error, i);
12801 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
12811 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
12813 unformat_input_t *i = vam->input;
12814 vl_api_ikev2_initiate_del_child_sa_t *mp;
12819 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12821 if (unformat (i, "%x", &ispi))
12825 errmsg ("parse error '%U'", format_unformat_error, i);
12830 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
12840 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
12842 unformat_input_t *i = vam->input;
12843 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
12848 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12850 if (unformat (i, "%x", &ispi))
12854 errmsg ("parse error '%U'", format_unformat_error, i);
12859 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
12872 api_map_add_domain (vat_main_t * vam)
12874 unformat_input_t *i = vam->input;
12875 vl_api_map_add_domain_t *mp;
12877 ip4_address_t ip4_prefix;
12878 ip6_address_t ip6_prefix;
12879 ip6_address_t ip6_src;
12880 u32 num_m_args = 0;
12881 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12882 0, psid_length = 0;
12883 u8 is_translation = 0;
12885 u32 ip6_src_len = 128;
12888 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12890 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12891 &ip4_prefix, &ip4_prefix_len))
12893 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12894 &ip6_prefix, &ip6_prefix_len))
12898 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12901 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12903 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12905 else if (unformat (i, "psid-offset %d", &psid_offset))
12907 else if (unformat (i, "psid-len %d", &psid_length))
12909 else if (unformat (i, "mtu %d", &mtu))
12911 else if (unformat (i, "map-t"))
12912 is_translation = 1;
12915 clib_warning ("parse error '%U'", format_unformat_error, i);
12920 if (num_m_args < 3)
12922 errmsg ("mandatory argument(s) missing");
12926 /* Construct the API message */
12927 M (MAP_ADD_DOMAIN, mp);
12929 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12930 mp->ip4_prefix_len = ip4_prefix_len;
12932 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12933 mp->ip6_prefix_len = ip6_prefix_len;
12935 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12936 mp->ip6_src_prefix_len = ip6_src_len;
12938 mp->ea_bits_len = ea_bits_len;
12939 mp->psid_offset = psid_offset;
12940 mp->psid_length = psid_length;
12941 mp->is_translation = is_translation;
12942 mp->mtu = htons (mtu);
12947 /* Wait for a reply, return good/bad news */
12953 api_map_del_domain (vat_main_t * vam)
12955 unformat_input_t *i = vam->input;
12956 vl_api_map_del_domain_t *mp;
12958 u32 num_m_args = 0;
12962 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12964 if (unformat (i, "index %d", &index))
12968 clib_warning ("parse error '%U'", format_unformat_error, i);
12973 if (num_m_args != 1)
12975 errmsg ("mandatory argument(s) missing");
12979 /* Construct the API message */
12980 M (MAP_DEL_DOMAIN, mp);
12982 mp->index = ntohl (index);
12987 /* Wait for a reply, return good/bad news */
12993 api_map_add_del_rule (vat_main_t * vam)
12995 unformat_input_t *i = vam->input;
12996 vl_api_map_add_del_rule_t *mp;
12998 ip6_address_t ip6_dst;
12999 u32 num_m_args = 0, index, psid = 0;
13002 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13004 if (unformat (i, "index %d", &index))
13006 else if (unformat (i, "psid %d", &psid))
13008 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13010 else if (unformat (i, "del"))
13016 clib_warning ("parse error '%U'", format_unformat_error, i);
13021 /* Construct the API message */
13022 M (MAP_ADD_DEL_RULE, mp);
13024 mp->index = ntohl (index);
13025 mp->is_add = is_add;
13026 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13027 mp->psid = ntohs (psid);
13032 /* Wait for a reply, return good/bad news */
13038 api_map_domain_dump (vat_main_t * vam)
13040 vl_api_map_domain_dump_t *mp;
13041 vl_api_control_ping_t *mp_ping;
13044 /* Construct the API message */
13045 M (MAP_DOMAIN_DUMP, mp);
13050 /* Use a control ping for synchronization */
13051 M (CONTROL_PING, mp_ping);
13059 api_map_rule_dump (vat_main_t * vam)
13061 unformat_input_t *i = vam->input;
13062 vl_api_map_rule_dump_t *mp;
13063 vl_api_control_ping_t *mp_ping;
13064 u32 domain_index = ~0;
13067 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13069 if (unformat (i, "index %u", &domain_index))
13075 if (domain_index == ~0)
13077 clib_warning ("parse error: domain index expected");
13081 /* Construct the API message */
13082 M (MAP_RULE_DUMP, mp);
13084 mp->domain_index = htonl (domain_index);
13089 /* Use a control ping for synchronization */
13090 M (CONTROL_PING, mp_ping);
13097 static void vl_api_map_add_domain_reply_t_handler
13098 (vl_api_map_add_domain_reply_t * mp)
13100 vat_main_t *vam = &vat_main;
13101 i32 retval = ntohl (mp->retval);
13103 if (vam->async_mode)
13105 vam->async_errors += (retval < 0);
13109 vam->retval = retval;
13110 vam->result_ready = 1;
13114 static void vl_api_map_add_domain_reply_t_handler_json
13115 (vl_api_map_add_domain_reply_t * mp)
13117 vat_main_t *vam = &vat_main;
13118 vat_json_node_t node;
13120 vat_json_init_object (&node);
13121 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13122 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13124 vat_json_print (vam->ofp, &node);
13125 vat_json_free (&node);
13127 vam->retval = ntohl (mp->retval);
13128 vam->result_ready = 1;
13132 api_get_first_msg_id (vat_main_t * vam)
13134 vl_api_get_first_msg_id_t *mp;
13135 unformat_input_t *i = vam->input;
13140 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13142 if (unformat (i, "client %s", &name))
13150 errmsg ("missing client name");
13153 vec_add1 (name, 0);
13155 if (vec_len (name) > 63)
13157 errmsg ("client name too long");
13161 M (GET_FIRST_MSG_ID, mp);
13162 clib_memcpy (mp->name, name, vec_len (name));
13169 api_cop_interface_enable_disable (vat_main_t * vam)
13171 unformat_input_t *line_input = vam->input;
13172 vl_api_cop_interface_enable_disable_t *mp;
13173 u32 sw_if_index = ~0;
13174 u8 enable_disable = 1;
13177 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13179 if (unformat (line_input, "disable"))
13180 enable_disable = 0;
13181 if (unformat (line_input, "enable"))
13182 enable_disable = 1;
13183 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13184 vam, &sw_if_index))
13186 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13192 if (sw_if_index == ~0)
13194 errmsg ("missing interface name or sw_if_index");
13198 /* Construct the API message */
13199 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13200 mp->sw_if_index = ntohl (sw_if_index);
13201 mp->enable_disable = enable_disable;
13205 /* Wait for the reply */
13211 api_cop_whitelist_enable_disable (vat_main_t * vam)
13213 unformat_input_t *line_input = vam->input;
13214 vl_api_cop_whitelist_enable_disable_t *mp;
13215 u32 sw_if_index = ~0;
13216 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13220 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13222 if (unformat (line_input, "ip4"))
13224 else if (unformat (line_input, "ip6"))
13226 else if (unformat (line_input, "default"))
13228 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13229 vam, &sw_if_index))
13231 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13233 else if (unformat (line_input, "fib-id %d", &fib_id))
13239 if (sw_if_index == ~0)
13241 errmsg ("missing interface name or sw_if_index");
13245 /* Construct the API message */
13246 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13247 mp->sw_if_index = ntohl (sw_if_index);
13248 mp->fib_id = ntohl (fib_id);
13251 mp->default_cop = default_cop;
13255 /* Wait for the reply */
13261 api_get_node_graph (vat_main_t * vam)
13263 vl_api_get_node_graph_t *mp;
13266 M (GET_NODE_GRAPH, mp);
13270 /* Wait for the reply */
13276 /** Used for parsing LISP eids */
13277 typedef CLIB_PACKED(struct{
13278 u8 addr[16]; /**< eid address */
13279 u32 len; /**< prefix length if IP */
13280 u8 type; /**< type of eid */
13285 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13287 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13289 memset (a, 0, sizeof (a[0]));
13291 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13293 a->type = 0; /* ipv4 type */
13295 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13297 a->type = 1; /* ipv6 type */
13299 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13301 a->type = 2; /* mac type */
13308 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13317 lisp_eid_size_vat (u8 type)
13332 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13334 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13338 api_one_add_del_locator_set (vat_main_t * vam)
13340 unformat_input_t *input = vam->input;
13341 vl_api_one_add_del_locator_set_t *mp;
13343 u8 *locator_set_name = NULL;
13344 u8 locator_set_name_set = 0;
13345 vl_api_local_locator_t locator, *locators = 0;
13346 u32 sw_if_index, priority, weight;
13350 /* Parse args required to build the message */
13351 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13353 if (unformat (input, "del"))
13357 else if (unformat (input, "locator-set %s", &locator_set_name))
13359 locator_set_name_set = 1;
13361 else if (unformat (input, "sw_if_index %u p %u w %u",
13362 &sw_if_index, &priority, &weight))
13364 locator.sw_if_index = htonl (sw_if_index);
13365 locator.priority = priority;
13366 locator.weight = weight;
13367 vec_add1 (locators, locator);
13371 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13372 &sw_if_index, &priority, &weight))
13374 locator.sw_if_index = htonl (sw_if_index);
13375 locator.priority = priority;
13376 locator.weight = weight;
13377 vec_add1 (locators, locator);
13383 if (locator_set_name_set == 0)
13385 errmsg ("missing locator-set name");
13386 vec_free (locators);
13390 if (vec_len (locator_set_name) > 64)
13392 errmsg ("locator-set name too long");
13393 vec_free (locator_set_name);
13394 vec_free (locators);
13397 vec_add1 (locator_set_name, 0);
13399 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13401 /* Construct the API message */
13402 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
13404 mp->is_add = is_add;
13405 clib_memcpy (mp->locator_set_name, locator_set_name,
13406 vec_len (locator_set_name));
13407 vec_free (locator_set_name);
13409 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13411 clib_memcpy (mp->locators, locators, data_len);
13412 vec_free (locators);
13417 /* Wait for a reply... */
13422 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
13425 api_one_add_del_locator (vat_main_t * vam)
13427 unformat_input_t *input = vam->input;
13428 vl_api_one_add_del_locator_t *mp;
13429 u32 tmp_if_index = ~0;
13430 u32 sw_if_index = ~0;
13431 u8 sw_if_index_set = 0;
13432 u8 sw_if_index_if_name_set = 0;
13434 u8 priority_set = 0;
13438 u8 *locator_set_name = NULL;
13439 u8 locator_set_name_set = 0;
13442 /* Parse args required to build the message */
13443 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13445 if (unformat (input, "del"))
13449 else if (unformat (input, "locator-set %s", &locator_set_name))
13451 locator_set_name_set = 1;
13453 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13456 sw_if_index_if_name_set = 1;
13457 sw_if_index = tmp_if_index;
13459 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13461 sw_if_index_set = 1;
13462 sw_if_index = tmp_if_index;
13464 else if (unformat (input, "p %d", &priority))
13468 else if (unformat (input, "w %d", &weight))
13476 if (locator_set_name_set == 0)
13478 errmsg ("missing locator-set name");
13482 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13484 errmsg ("missing sw_if_index");
13485 vec_free (locator_set_name);
13489 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13491 errmsg ("cannot use both params interface name and sw_if_index");
13492 vec_free (locator_set_name);
13496 if (priority_set == 0)
13498 errmsg ("missing locator-set priority");
13499 vec_free (locator_set_name);
13503 if (weight_set == 0)
13505 errmsg ("missing locator-set weight");
13506 vec_free (locator_set_name);
13510 if (vec_len (locator_set_name) > 64)
13512 errmsg ("locator-set name too long");
13513 vec_free (locator_set_name);
13516 vec_add1 (locator_set_name, 0);
13518 /* Construct the API message */
13519 M (ONE_ADD_DEL_LOCATOR, mp);
13521 mp->is_add = is_add;
13522 mp->sw_if_index = ntohl (sw_if_index);
13523 mp->priority = priority;
13524 mp->weight = weight;
13525 clib_memcpy (mp->locator_set_name, locator_set_name,
13526 vec_len (locator_set_name));
13527 vec_free (locator_set_name);
13532 /* Wait for a reply... */
13537 #define api_lisp_add_del_locator api_one_add_del_locator
13540 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13542 u32 *key_id = va_arg (*args, u32 *);
13545 if (unformat (input, "%s", &s))
13547 if (!strcmp ((char *) s, "sha1"))
13548 key_id[0] = HMAC_SHA_1_96;
13549 else if (!strcmp ((char *) s, "sha256"))
13550 key_id[0] = HMAC_SHA_256_128;
13553 clib_warning ("invalid key_id: '%s'", s);
13554 key_id[0] = HMAC_NO_KEY;
13565 api_one_add_del_local_eid (vat_main_t * vam)
13567 unformat_input_t *input = vam->input;
13568 vl_api_one_add_del_local_eid_t *mp;
13571 lisp_eid_vat_t _eid, *eid = &_eid;
13572 u8 *locator_set_name = 0;
13573 u8 locator_set_name_set = 0;
13579 /* Parse args required to build the message */
13580 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13582 if (unformat (input, "del"))
13586 else if (unformat (input, "vni %d", &vni))
13590 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13594 else if (unformat (input, "locator-set %s", &locator_set_name))
13596 locator_set_name_set = 1;
13598 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13600 else if (unformat (input, "secret-key %_%v%_", &key))
13606 if (locator_set_name_set == 0)
13608 errmsg ("missing locator-set name");
13614 errmsg ("EID address not set!");
13615 vec_free (locator_set_name);
13619 if (key && (0 == key_id))
13621 errmsg ("invalid key_id!");
13625 if (vec_len (key) > 64)
13627 errmsg ("key too long");
13632 if (vec_len (locator_set_name) > 64)
13634 errmsg ("locator-set name too long");
13635 vec_free (locator_set_name);
13638 vec_add1 (locator_set_name, 0);
13640 /* Construct the API message */
13641 M (ONE_ADD_DEL_LOCAL_EID, mp);
13643 mp->is_add = is_add;
13644 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13645 mp->eid_type = eid->type;
13646 mp->prefix_len = eid->len;
13647 mp->vni = clib_host_to_net_u32 (vni);
13648 mp->key_id = clib_host_to_net_u16 (key_id);
13649 clib_memcpy (mp->locator_set_name, locator_set_name,
13650 vec_len (locator_set_name));
13651 clib_memcpy (mp->key, key, vec_len (key));
13653 vec_free (locator_set_name);
13659 /* Wait for a reply... */
13664 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
13667 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13669 u32 dp_table = 0, vni = 0;;
13670 unformat_input_t *input = vam->input;
13671 vl_api_gpe_add_del_fwd_entry_t *mp;
13673 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13674 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13675 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13676 u32 action = ~0, w;
13677 ip4_address_t rmt_rloc4, lcl_rloc4;
13678 ip6_address_t rmt_rloc6, lcl_rloc6;
13679 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13682 memset (&rloc, 0, sizeof (rloc));
13684 /* Parse args required to build the message */
13685 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13687 if (unformat (input, "del"))
13689 else if (unformat (input, "add"))
13691 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13695 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13699 else if (unformat (input, "vrf %d", &dp_table))
13701 else if (unformat (input, "bd %d", &dp_table))
13703 else if (unformat (input, "vni %d", &vni))
13705 else if (unformat (input, "w %d", &w))
13709 errmsg ("No RLOC configured for setting priority/weight!");
13712 curr_rloc->weight = w;
13714 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13715 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13719 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13721 vec_add1 (lcl_locs, rloc);
13723 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13724 vec_add1 (rmt_locs, rloc);
13725 /* weight saved in rmt loc */
13726 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13728 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13729 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13732 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13734 vec_add1 (lcl_locs, rloc);
13736 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13737 vec_add1 (rmt_locs, rloc);
13738 /* weight saved in rmt loc */
13739 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13741 else if (unformat (input, "action %d", &action))
13747 clib_warning ("parse error '%U'", format_unformat_error, input);
13754 errmsg ("remote eid addresses not set");
13758 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13760 errmsg ("eid types don't match");
13764 if (0 == rmt_locs && (u32) ~ 0 == action)
13766 errmsg ("action not set for negative mapping");
13770 /* Construct the API message */
13771 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
13772 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
13774 mp->is_add = is_add;
13775 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13776 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13777 mp->eid_type = rmt_eid->type;
13778 mp->dp_table = clib_host_to_net_u32 (dp_table);
13779 mp->vni = clib_host_to_net_u32 (vni);
13780 mp->rmt_len = rmt_eid->len;
13781 mp->lcl_len = lcl_eid->len;
13782 mp->action = action;
13784 if (0 != rmt_locs && 0 != lcl_locs)
13786 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
13787 clib_memcpy (mp->locs, lcl_locs,
13788 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
13790 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
13791 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
13792 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
13794 vec_free (lcl_locs);
13795 vec_free (rmt_locs);
13800 /* Wait for a reply... */
13806 api_one_add_del_map_server (vat_main_t * vam)
13808 unformat_input_t *input = vam->input;
13809 vl_api_one_add_del_map_server_t *mp;
13813 ip4_address_t ipv4;
13814 ip6_address_t ipv6;
13817 /* Parse args required to build the message */
13818 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13820 if (unformat (input, "del"))
13824 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13828 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13836 if (ipv4_set && ipv6_set)
13838 errmsg ("both eid v4 and v6 addresses set");
13842 if (!ipv4_set && !ipv6_set)
13844 errmsg ("eid addresses not set");
13848 /* Construct the API message */
13849 M (ONE_ADD_DEL_MAP_SERVER, mp);
13851 mp->is_add = is_add;
13855 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13860 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13866 /* Wait for a reply... */
13871 #define api_lisp_add_del_map_server api_one_add_del_map_server
13874 api_one_add_del_map_resolver (vat_main_t * vam)
13876 unformat_input_t *input = vam->input;
13877 vl_api_one_add_del_map_resolver_t *mp;
13881 ip4_address_t ipv4;
13882 ip6_address_t ipv6;
13885 /* Parse args required to build the message */
13886 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13888 if (unformat (input, "del"))
13892 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13896 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13904 if (ipv4_set && ipv6_set)
13906 errmsg ("both eid v4 and v6 addresses set");
13910 if (!ipv4_set && !ipv6_set)
13912 errmsg ("eid addresses not set");
13916 /* Construct the API message */
13917 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
13919 mp->is_add = is_add;
13923 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13928 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13934 /* Wait for a reply... */
13939 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
13942 api_lisp_gpe_enable_disable (vat_main_t * vam)
13944 unformat_input_t *input = vam->input;
13945 vl_api_gpe_enable_disable_t *mp;
13950 /* Parse args required to build the message */
13951 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13953 if (unformat (input, "enable"))
13958 else if (unformat (input, "disable"))
13969 errmsg ("Value not set");
13973 /* Construct the API message */
13974 M (GPE_ENABLE_DISABLE, mp);
13981 /* Wait for a reply... */
13987 api_one_rloc_probe_enable_disable (vat_main_t * vam)
13989 unformat_input_t *input = vam->input;
13990 vl_api_one_rloc_probe_enable_disable_t *mp;
13995 /* Parse args required to build the message */
13996 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13998 if (unformat (input, "enable"))
14003 else if (unformat (input, "disable"))
14011 errmsg ("Value not set");
14015 /* Construct the API message */
14016 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14018 mp->is_enabled = is_en;
14023 /* Wait for a reply... */
14028 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14031 api_one_map_register_enable_disable (vat_main_t * vam)
14033 unformat_input_t *input = vam->input;
14034 vl_api_one_map_register_enable_disable_t *mp;
14039 /* Parse args required to build the message */
14040 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14042 if (unformat (input, "enable"))
14047 else if (unformat (input, "disable"))
14055 errmsg ("Value not set");
14059 /* Construct the API message */
14060 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14062 mp->is_enabled = is_en;
14067 /* Wait for a reply... */
14072 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14075 api_one_enable_disable (vat_main_t * vam)
14077 unformat_input_t *input = vam->input;
14078 vl_api_one_enable_disable_t *mp;
14083 /* Parse args required to build the message */
14084 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14086 if (unformat (input, "enable"))
14091 else if (unformat (input, "disable"))
14101 errmsg ("Value not set");
14105 /* Construct the API message */
14106 M (ONE_ENABLE_DISABLE, mp);
14113 /* Wait for a reply... */
14118 #define api_lisp_enable_disable api_one_enable_disable
14121 api_show_one_map_register_state (vat_main_t * vam)
14123 vl_api_show_one_map_register_state_t *mp;
14126 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14131 /* wait for reply */
14136 #define api_show_lisp_map_register_state api_show_one_map_register_state
14139 api_show_one_rloc_probe_state (vat_main_t * vam)
14141 vl_api_show_one_rloc_probe_state_t *mp;
14144 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14149 /* wait for reply */
14154 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14157 api_show_one_map_request_mode (vat_main_t * vam)
14159 vl_api_show_one_map_request_mode_t *mp;
14162 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
14167 /* wait for reply */
14172 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
14175 api_one_map_request_mode (vat_main_t * vam)
14177 unformat_input_t *input = vam->input;
14178 vl_api_one_map_request_mode_t *mp;
14182 /* Parse args required to build the message */
14183 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14185 if (unformat (input, "dst-only"))
14187 else if (unformat (input, "src-dst"))
14191 errmsg ("parse error '%U'", format_unformat_error, input);
14196 M (ONE_MAP_REQUEST_MODE, mp);
14203 /* wait for reply */
14208 #define api_lisp_map_request_mode api_one_map_request_mode
14211 * Enable/disable ONE proxy ITR.
14213 * @param vam vpp API test context
14214 * @return return code
14217 api_one_pitr_set_locator_set (vat_main_t * vam)
14219 u8 ls_name_set = 0;
14220 unformat_input_t *input = vam->input;
14221 vl_api_one_pitr_set_locator_set_t *mp;
14226 /* Parse args required to build the message */
14227 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14229 if (unformat (input, "del"))
14231 else if (unformat (input, "locator-set %s", &ls_name))
14235 errmsg ("parse error '%U'", format_unformat_error, input);
14242 errmsg ("locator-set name not set!");
14246 M (ONE_PITR_SET_LOCATOR_SET, mp);
14248 mp->is_add = is_add;
14249 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14250 vec_free (ls_name);
14255 /* wait for reply */
14260 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
14263 api_show_one_pitr (vat_main_t * vam)
14265 vl_api_show_one_pitr_t *mp;
14268 if (!vam->json_output)
14270 print (vam->ofp, "%=20s", "lisp status:");
14273 M (SHOW_ONE_PITR, mp);
14277 /* Wait for a reply... */
14282 #define api_show_lisp_pitr api_show_one_pitr
14285 * Add/delete mapping between vni and vrf
14288 api_one_eid_table_add_del_map (vat_main_t * vam)
14290 unformat_input_t *input = vam->input;
14291 vl_api_one_eid_table_add_del_map_t *mp;
14292 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
14293 u32 vni, vrf, bd_index;
14296 /* Parse args required to build the message */
14297 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14299 if (unformat (input, "del"))
14301 else if (unformat (input, "vrf %d", &vrf))
14303 else if (unformat (input, "bd_index %d", &bd_index))
14305 else if (unformat (input, "vni %d", &vni))
14311 if (!vni_set || (!vrf_set && !bd_index_set))
14313 errmsg ("missing arguments!");
14317 if (vrf_set && bd_index_set)
14319 errmsg ("error: both vrf and bd entered!");
14323 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
14325 mp->is_add = is_add;
14326 mp->vni = htonl (vni);
14327 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
14328 mp->is_l2 = bd_index_set;
14333 /* wait for reply */
14338 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
14341 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
14343 u32 *action = va_arg (*args, u32 *);
14346 if (unformat (input, "%s", &s))
14348 if (!strcmp ((char *) s, "no-action"))
14350 else if (!strcmp ((char *) s, "natively-forward"))
14352 else if (!strcmp ((char *) s, "send-map-request"))
14354 else if (!strcmp ((char *) s, "drop"))
14358 clib_warning ("invalid action: '%s'", s);
14370 * Add/del remote mapping to/from ONE control plane
14372 * @param vam vpp API test context
14373 * @return return code
14376 api_one_add_del_remote_mapping (vat_main_t * vam)
14378 unformat_input_t *input = vam->input;
14379 vl_api_one_add_del_remote_mapping_t *mp;
14381 lisp_eid_vat_t _eid, *eid = &_eid;
14382 lisp_eid_vat_t _seid, *seid = &_seid;
14383 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
14384 u32 action = ~0, p, w, data_len;
14385 ip4_address_t rloc4;
14386 ip6_address_t rloc6;
14387 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
14390 memset (&rloc, 0, sizeof (rloc));
14392 /* Parse args required to build the message */
14393 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14395 if (unformat (input, "del-all"))
14399 else if (unformat (input, "del"))
14403 else if (unformat (input, "add"))
14407 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14411 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14415 else if (unformat (input, "vni %d", &vni))
14419 else if (unformat (input, "p %d w %d", &p, &w))
14423 errmsg ("No RLOC configured for setting priority/weight!");
14426 curr_rloc->priority = p;
14427 curr_rloc->weight = w;
14429 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14432 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14433 vec_add1 (rlocs, rloc);
14434 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14436 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14439 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14440 vec_add1 (rlocs, rloc);
14441 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14443 else if (unformat (input, "action %U",
14444 unformat_negative_mapping_action, &action))
14450 clib_warning ("parse error '%U'", format_unformat_error, input);
14457 errmsg ("missing params!");
14461 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14463 errmsg ("no action set for negative map-reply!");
14467 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
14469 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
14470 mp->is_add = is_add;
14471 mp->vni = htonl (vni);
14472 mp->action = (u8) action;
14473 mp->is_src_dst = seid_set;
14474 mp->eid_len = eid->len;
14475 mp->seid_len = seid->len;
14476 mp->del_all = del_all;
14477 mp->eid_type = eid->type;
14478 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14479 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14481 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14482 clib_memcpy (mp->rlocs, rlocs, data_len);
14488 /* Wait for a reply... */
14493 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
14496 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
14497 * forwarding entries in data-plane accordingly.
14499 * @param vam vpp API test context
14500 * @return return code
14503 api_one_add_del_adjacency (vat_main_t * vam)
14505 unformat_input_t *input = vam->input;
14506 vl_api_one_add_del_adjacency_t *mp;
14508 ip4_address_t leid4, reid4;
14509 ip6_address_t leid6, reid6;
14510 u8 reid_mac[6] = { 0 };
14511 u8 leid_mac[6] = { 0 };
14512 u8 reid_type, leid_type;
14513 u32 leid_len = 0, reid_len = 0, len;
14517 leid_type = reid_type = (u8) ~ 0;
14519 /* Parse args required to build the message */
14520 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14522 if (unformat (input, "del"))
14526 else if (unformat (input, "add"))
14530 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14533 reid_type = 0; /* ipv4 */
14536 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14539 reid_type = 1; /* ipv6 */
14542 else if (unformat (input, "reid %U", unformat_ethernet_address,
14545 reid_type = 2; /* mac */
14547 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14550 leid_type = 0; /* ipv4 */
14553 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14556 leid_type = 1; /* ipv6 */
14559 else if (unformat (input, "leid %U", unformat_ethernet_address,
14562 leid_type = 2; /* mac */
14564 else if (unformat (input, "vni %d", &vni))
14570 errmsg ("parse error '%U'", format_unformat_error, input);
14575 if ((u8) ~ 0 == reid_type)
14577 errmsg ("missing params!");
14581 if (leid_type != reid_type)
14583 errmsg ("remote and local EIDs are of different types!");
14587 M (ONE_ADD_DEL_ADJACENCY, mp);
14588 mp->is_add = is_add;
14589 mp->vni = htonl (vni);
14590 mp->leid_len = leid_len;
14591 mp->reid_len = reid_len;
14592 mp->eid_type = reid_type;
14594 switch (mp->eid_type)
14597 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14598 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14601 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14602 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14605 clib_memcpy (mp->leid, leid_mac, 6);
14606 clib_memcpy (mp->reid, reid_mac, 6);
14609 errmsg ("unknown EID type %d!", mp->eid_type);
14616 /* Wait for a reply... */
14621 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
14624 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
14626 u32 *mode = va_arg (*args, u32 *);
14628 if (unformat (input, "lisp"))
14630 else if (unformat (input, "vxlan"))
14639 api_gpe_get_encap_mode (vat_main_t * vam)
14641 vl_api_gpe_get_encap_mode_t *mp;
14644 /* Construct the API message */
14645 M (GPE_GET_ENCAP_MODE, mp);
14650 /* Wait for a reply... */
14656 api_gpe_set_encap_mode (vat_main_t * vam)
14658 unformat_input_t *input = vam->input;
14659 vl_api_gpe_set_encap_mode_t *mp;
14663 /* Parse args required to build the message */
14664 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14666 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
14672 /* Construct the API message */
14673 M (GPE_SET_ENCAP_MODE, mp);
14680 /* Wait for a reply... */
14686 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14688 unformat_input_t *input = vam->input;
14689 vl_api_gpe_add_del_iface_t *mp;
14690 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14691 u32 dp_table = 0, vni = 0;
14694 /* Parse args required to build the message */
14695 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14697 if (unformat (input, "up"))
14702 else if (unformat (input, "down"))
14707 else if (unformat (input, "table_id %d", &dp_table))
14711 else if (unformat (input, "bd_id %d", &dp_table))
14716 else if (unformat (input, "vni %d", &vni))
14724 if (action_set == 0)
14726 errmsg ("Action not set");
14729 if (dp_table_set == 0 || vni_set == 0)
14731 errmsg ("vni and dp_table must be set");
14735 /* Construct the API message */
14736 M (GPE_ADD_DEL_IFACE, mp);
14738 mp->is_add = is_add;
14739 mp->dp_table = dp_table;
14746 /* Wait for a reply... */
14752 * Add/del map request itr rlocs from ONE control plane and updates
14754 * @param vam vpp API test context
14755 * @return return code
14758 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
14760 unformat_input_t *input = vam->input;
14761 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
14762 u8 *locator_set_name = 0;
14763 u8 locator_set_name_set = 0;
14767 /* Parse args required to build the message */
14768 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14770 if (unformat (input, "del"))
14774 else if (unformat (input, "%_%v%_", &locator_set_name))
14776 locator_set_name_set = 1;
14780 clib_warning ("parse error '%U'", format_unformat_error, input);
14785 if (is_add && !locator_set_name_set)
14787 errmsg ("itr-rloc is not set!");
14791 if (is_add && vec_len (locator_set_name) > 64)
14793 errmsg ("itr-rloc locator-set name too long");
14794 vec_free (locator_set_name);
14798 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
14799 mp->is_add = is_add;
14802 clib_memcpy (mp->locator_set_name, locator_set_name,
14803 vec_len (locator_set_name));
14807 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14809 vec_free (locator_set_name);
14814 /* Wait for a reply... */
14819 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
14822 api_one_locator_dump (vat_main_t * vam)
14824 unformat_input_t *input = vam->input;
14825 vl_api_one_locator_dump_t *mp;
14826 vl_api_control_ping_t *mp_ping;
14827 u8 is_index_set = 0, is_name_set = 0;
14832 /* Parse args required to build the message */
14833 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14835 if (unformat (input, "ls_name %_%v%_", &ls_name))
14839 else if (unformat (input, "ls_index %d", &ls_index))
14845 errmsg ("parse error '%U'", format_unformat_error, input);
14850 if (!is_index_set && !is_name_set)
14852 errmsg ("error: expected one of index or name!");
14856 if (is_index_set && is_name_set)
14858 errmsg ("error: only one param expected!");
14862 if (vec_len (ls_name) > 62)
14864 errmsg ("error: locator set name too long!");
14868 if (!vam->json_output)
14870 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
14873 M (ONE_LOCATOR_DUMP, mp);
14874 mp->is_index_set = is_index_set;
14877 mp->ls_index = clib_host_to_net_u32 (ls_index);
14880 vec_add1 (ls_name, 0);
14881 strncpy ((char *) mp->ls_name, (char *) ls_name,
14882 sizeof (mp->ls_name) - 1);
14888 /* Use a control ping for synchronization */
14889 M (CONTROL_PING, mp_ping);
14892 /* Wait for a reply... */
14897 #define api_lisp_locator_dump api_one_locator_dump
14900 api_one_locator_set_dump (vat_main_t * vam)
14902 vl_api_one_locator_set_dump_t *mp;
14903 vl_api_control_ping_t *mp_ping;
14904 unformat_input_t *input = vam->input;
14908 /* Parse args required to build the message */
14909 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14911 if (unformat (input, "local"))
14915 else if (unformat (input, "remote"))
14921 errmsg ("parse error '%U'", format_unformat_error, input);
14926 if (!vam->json_output)
14928 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
14931 M (ONE_LOCATOR_SET_DUMP, mp);
14933 mp->filter = filter;
14938 /* Use a control ping for synchronization */
14939 M (CONTROL_PING, mp_ping);
14942 /* Wait for a reply... */
14947 #define api_lisp_locator_set_dump api_one_locator_set_dump
14950 api_one_eid_table_map_dump (vat_main_t * vam)
14954 unformat_input_t *input = vam->input;
14955 vl_api_one_eid_table_map_dump_t *mp;
14956 vl_api_control_ping_t *mp_ping;
14959 /* Parse args required to build the message */
14960 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14962 if (unformat (input, "l2"))
14967 else if (unformat (input, "l3"))
14974 errmsg ("parse error '%U'", format_unformat_error, input);
14981 errmsg ("expected one of 'l2' or 'l3' parameter!");
14985 if (!vam->json_output)
14987 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
14990 M (ONE_EID_TABLE_MAP_DUMP, mp);
14996 /* Use a control ping for synchronization */
14997 M (CONTROL_PING, mp_ping);
15000 /* Wait for a reply... */
15005 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
15008 api_one_eid_table_vni_dump (vat_main_t * vam)
15010 vl_api_one_eid_table_vni_dump_t *mp;
15011 vl_api_control_ping_t *mp_ping;
15014 if (!vam->json_output)
15016 print (vam->ofp, "VNI");
15019 M (ONE_EID_TABLE_VNI_DUMP, mp);
15024 /* Use a control ping for synchronization */
15025 M (CONTROL_PING, mp_ping);
15028 /* Wait for a reply... */
15033 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
15036 api_one_eid_table_dump (vat_main_t * vam)
15038 unformat_input_t *i = vam->input;
15039 vl_api_one_eid_table_dump_t *mp;
15040 vl_api_control_ping_t *mp_ping;
15041 struct in_addr ip4;
15042 struct in6_addr ip6;
15044 u8 eid_type = ~0, eid_set = 0;
15045 u32 prefix_length = ~0, t, vni = 0;
15049 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15051 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
15057 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
15063 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
15068 else if (unformat (i, "vni %d", &t))
15072 else if (unformat (i, "local"))
15076 else if (unformat (i, "remote"))
15082 errmsg ("parse error '%U'", format_unformat_error, i);
15087 if (!vam->json_output)
15089 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
15090 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
15093 M (ONE_EID_TABLE_DUMP, mp);
15095 mp->filter = filter;
15099 mp->vni = htonl (vni);
15100 mp->eid_type = eid_type;
15104 mp->prefix_length = prefix_length;
15105 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
15108 mp->prefix_length = prefix_length;
15109 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
15112 clib_memcpy (mp->eid, mac, sizeof (mac));
15115 errmsg ("unknown EID type %d!", eid_type);
15123 /* Use a control ping for synchronization */
15124 M (CONTROL_PING, mp_ping);
15127 /* Wait for a reply... */
15132 #define api_lisp_eid_table_dump api_one_eid_table_dump
15135 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
15137 unformat_input_t *i = vam->input;
15138 vl_api_gpe_fwd_entries_get_t *mp;
15143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15145 if (unformat (i, "vni %d", &vni))
15151 errmsg ("parse error '%U'", format_unformat_error, i);
15158 errmsg ("vni not set!");
15162 if (!vam->json_output)
15164 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15168 M (GPE_FWD_ENTRIES_GET, mp);
15169 mp->vni = clib_host_to_net_u32 (vni);
15174 /* Wait for a reply... */
15179 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15180 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15181 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15182 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
15185 api_one_adjacencies_get (vat_main_t * vam)
15187 unformat_input_t *i = vam->input;
15188 vl_api_one_adjacencies_get_t *mp;
15193 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15195 if (unformat (i, "vni %d", &vni))
15201 errmsg ("parse error '%U'", format_unformat_error, i);
15208 errmsg ("vni not set!");
15212 if (!vam->json_output)
15214 print (vam->ofp, "%s %40s", "leid", "reid");
15217 M (ONE_ADJACENCIES_GET, mp);
15218 mp->vni = clib_host_to_net_u32 (vni);
15223 /* Wait for a reply... */
15228 #define api_lisp_adjacencies_get api_one_adjacencies_get
15231 api_one_map_server_dump (vat_main_t * vam)
15233 vl_api_one_map_server_dump_t *mp;
15234 vl_api_control_ping_t *mp_ping;
15237 if (!vam->json_output)
15239 print (vam->ofp, "%=20s", "Map server");
15242 M (ONE_MAP_SERVER_DUMP, mp);
15246 /* Use a control ping for synchronization */
15247 M (CONTROL_PING, mp_ping);
15250 /* Wait for a reply... */
15255 #define api_lisp_map_server_dump api_one_map_server_dump
15258 api_one_map_resolver_dump (vat_main_t * vam)
15260 vl_api_one_map_resolver_dump_t *mp;
15261 vl_api_control_ping_t *mp_ping;
15264 if (!vam->json_output)
15266 print (vam->ofp, "%=20s", "Map resolver");
15269 M (ONE_MAP_RESOLVER_DUMP, mp);
15273 /* Use a control ping for synchronization */
15274 M (CONTROL_PING, mp_ping);
15277 /* Wait for a reply... */
15282 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
15285 api_show_one_status (vat_main_t * vam)
15287 vl_api_show_one_status_t *mp;
15290 if (!vam->json_output)
15292 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
15295 M (SHOW_ONE_STATUS, mp);
15298 /* Wait for a reply... */
15303 #define api_show_lisp_status api_show_one_status
15306 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
15308 vl_api_gpe_fwd_entry_path_dump_t *mp;
15309 vl_api_control_ping_t *mp_ping;
15310 unformat_input_t *i = vam->input;
15311 u32 fwd_entry_index = ~0;
15314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15316 if (unformat (i, "index %d", &fwd_entry_index))
15322 if (~0 == fwd_entry_index)
15324 errmsg ("no index specified!");
15328 if (!vam->json_output)
15330 print (vam->ofp, "first line");
15333 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
15337 /* Use a control ping for synchronization */
15338 M (CONTROL_PING, mp_ping);
15341 /* Wait for a reply... */
15347 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
15349 vl_api_one_get_map_request_itr_rlocs_t *mp;
15352 if (!vam->json_output)
15354 print (vam->ofp, "%=20s", "itr-rlocs:");
15357 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
15360 /* Wait for a reply... */
15365 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
15368 api_af_packet_create (vat_main_t * vam)
15370 unformat_input_t *i = vam->input;
15371 vl_api_af_packet_create_t *mp;
15372 u8 *host_if_name = 0;
15374 u8 random_hw_addr = 1;
15377 memset (hw_addr, 0, sizeof (hw_addr));
15379 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15381 if (unformat (i, "name %s", &host_if_name))
15382 vec_add1 (host_if_name, 0);
15383 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15384 random_hw_addr = 0;
15389 if (!vec_len (host_if_name))
15391 errmsg ("host-interface name must be specified");
15395 if (vec_len (host_if_name) > 64)
15397 errmsg ("host-interface name too long");
15401 M (AF_PACKET_CREATE, mp);
15403 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15404 clib_memcpy (mp->hw_addr, hw_addr, 6);
15405 mp->use_random_hw_addr = random_hw_addr;
15406 vec_free (host_if_name);
15414 fprintf (vam->ofp ? vam->ofp : stderr,
15415 " new sw_if_index = %d\n", vam->sw_if_index);
15422 api_af_packet_delete (vat_main_t * vam)
15424 unformat_input_t *i = vam->input;
15425 vl_api_af_packet_delete_t *mp;
15426 u8 *host_if_name = 0;
15429 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15431 if (unformat (i, "name %s", &host_if_name))
15432 vec_add1 (host_if_name, 0);
15437 if (!vec_len (host_if_name))
15439 errmsg ("host-interface name must be specified");
15443 if (vec_len (host_if_name) > 64)
15445 errmsg ("host-interface name too long");
15449 M (AF_PACKET_DELETE, mp);
15451 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15452 vec_free (host_if_name);
15460 api_policer_add_del (vat_main_t * vam)
15462 unformat_input_t *i = vam->input;
15463 vl_api_policer_add_del_t *mp;
15473 u8 color_aware = 0;
15474 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
15477 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
15478 conform_action.dscp = 0;
15479 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
15480 exceed_action.dscp = 0;
15481 violate_action.action_type = SSE2_QOS_ACTION_DROP;
15482 violate_action.dscp = 0;
15484 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15486 if (unformat (i, "del"))
15488 else if (unformat (i, "name %s", &name))
15489 vec_add1 (name, 0);
15490 else if (unformat (i, "cir %u", &cir))
15492 else if (unformat (i, "eir %u", &eir))
15494 else if (unformat (i, "cb %u", &cb))
15496 else if (unformat (i, "eb %u", &eb))
15498 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
15501 else if (unformat (i, "round_type %U", unformat_policer_round_type,
15504 else if (unformat (i, "type %U", unformat_policer_type, &type))
15506 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
15509 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
15512 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
15515 else if (unformat (i, "color-aware"))
15521 if (!vec_len (name))
15523 errmsg ("policer name must be specified");
15527 if (vec_len (name) > 64)
15529 errmsg ("policer name too long");
15533 M (POLICER_ADD_DEL, mp);
15535 clib_memcpy (mp->name, name, vec_len (name));
15537 mp->is_add = is_add;
15542 mp->rate_type = rate_type;
15543 mp->round_type = round_type;
15545 mp->conform_action_type = conform_action.action_type;
15546 mp->conform_dscp = conform_action.dscp;
15547 mp->exceed_action_type = exceed_action.action_type;
15548 mp->exceed_dscp = exceed_action.dscp;
15549 mp->violate_action_type = violate_action.action_type;
15550 mp->violate_dscp = violate_action.dscp;
15551 mp->color_aware = color_aware;
15559 api_policer_dump (vat_main_t * vam)
15561 unformat_input_t *i = vam->input;
15562 vl_api_policer_dump_t *mp;
15563 vl_api_control_ping_t *mp_ping;
15564 u8 *match_name = 0;
15565 u8 match_name_valid = 0;
15568 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15570 if (unformat (i, "name %s", &match_name))
15572 vec_add1 (match_name, 0);
15573 match_name_valid = 1;
15579 M (POLICER_DUMP, mp);
15580 mp->match_name_valid = match_name_valid;
15581 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15582 vec_free (match_name);
15586 /* Use a control ping for synchronization */
15587 M (CONTROL_PING, mp_ping);
15590 /* Wait for a reply... */
15596 api_policer_classify_set_interface (vat_main_t * vam)
15598 unformat_input_t *i = vam->input;
15599 vl_api_policer_classify_set_interface_t *mp;
15601 int sw_if_index_set;
15602 u32 ip4_table_index = ~0;
15603 u32 ip6_table_index = ~0;
15604 u32 l2_table_index = ~0;
15608 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15610 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15611 sw_if_index_set = 1;
15612 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15613 sw_if_index_set = 1;
15614 else if (unformat (i, "del"))
15616 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15618 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15620 else if (unformat (i, "l2-table %d", &l2_table_index))
15624 clib_warning ("parse error '%U'", format_unformat_error, i);
15629 if (sw_if_index_set == 0)
15631 errmsg ("missing interface name or sw_if_index");
15635 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
15637 mp->sw_if_index = ntohl (sw_if_index);
15638 mp->ip4_table_index = ntohl (ip4_table_index);
15639 mp->ip6_table_index = ntohl (ip6_table_index);
15640 mp->l2_table_index = ntohl (l2_table_index);
15641 mp->is_add = is_add;
15649 api_policer_classify_dump (vat_main_t * vam)
15651 unformat_input_t *i = vam->input;
15652 vl_api_policer_classify_dump_t *mp;
15653 vl_api_control_ping_t *mp_ping;
15654 u8 type = POLICER_CLASSIFY_N_TABLES;
15657 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15661 errmsg ("classify table type must be specified");
15665 if (!vam->json_output)
15667 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15670 M (POLICER_CLASSIFY_DUMP, mp);
15675 /* Use a control ping for synchronization */
15676 M (CONTROL_PING, mp_ping);
15679 /* Wait for a reply... */
15685 api_netmap_create (vat_main_t * vam)
15687 unformat_input_t *i = vam->input;
15688 vl_api_netmap_create_t *mp;
15691 u8 random_hw_addr = 1;
15696 memset (hw_addr, 0, sizeof (hw_addr));
15698 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15700 if (unformat (i, "name %s", &if_name))
15701 vec_add1 (if_name, 0);
15702 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15703 random_hw_addr = 0;
15704 else if (unformat (i, "pipe"))
15706 else if (unformat (i, "master"))
15708 else if (unformat (i, "slave"))
15714 if (!vec_len (if_name))
15716 errmsg ("interface name must be specified");
15720 if (vec_len (if_name) > 64)
15722 errmsg ("interface name too long");
15726 M (NETMAP_CREATE, mp);
15728 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15729 clib_memcpy (mp->hw_addr, hw_addr, 6);
15730 mp->use_random_hw_addr = random_hw_addr;
15731 mp->is_pipe = is_pipe;
15732 mp->is_master = is_master;
15733 vec_free (if_name);
15741 api_netmap_delete (vat_main_t * vam)
15743 unformat_input_t *i = vam->input;
15744 vl_api_netmap_delete_t *mp;
15748 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15750 if (unformat (i, "name %s", &if_name))
15751 vec_add1 (if_name, 0);
15756 if (!vec_len (if_name))
15758 errmsg ("interface name must be specified");
15762 if (vec_len (if_name) > 64)
15764 errmsg ("interface name too long");
15768 M (NETMAP_DELETE, mp);
15770 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15771 vec_free (if_name);
15778 static void vl_api_mpls_tunnel_details_t_handler
15779 (vl_api_mpls_tunnel_details_t * mp)
15781 vat_main_t *vam = &vat_main;
15782 i32 len = mp->mt_next_hop_n_labels;
15785 print (vam->ofp, "[%d]: via %U %d labels ",
15787 format_ip4_address, mp->mt_next_hop,
15788 ntohl (mp->mt_next_hop_sw_if_index));
15789 for (i = 0; i < len; i++)
15791 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15793 print (vam->ofp, "");
15796 static void vl_api_mpls_tunnel_details_t_handler_json
15797 (vl_api_mpls_tunnel_details_t * mp)
15799 vat_main_t *vam = &vat_main;
15800 vat_json_node_t *node = NULL;
15801 struct in_addr ip4;
15803 i32 len = mp->mt_next_hop_n_labels;
15805 if (VAT_JSON_ARRAY != vam->json_tree.type)
15807 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15808 vat_json_init_array (&vam->json_tree);
15810 node = vat_json_array_add (&vam->json_tree);
15812 vat_json_init_object (node);
15813 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15814 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15815 vat_json_object_add_ip4 (node, "next_hop", ip4);
15816 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15817 ntohl (mp->mt_next_hop_sw_if_index));
15818 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15819 vat_json_object_add_uint (node, "label_count", len);
15820 for (i = 0; i < len; i++)
15822 vat_json_object_add_uint (node, "label",
15823 ntohl (mp->mt_next_hop_out_labels[i]));
15828 api_mpls_tunnel_dump (vat_main_t * vam)
15830 vl_api_mpls_tunnel_dump_t *mp;
15831 vl_api_control_ping_t *mp_ping;
15835 /* Parse args required to build the message */
15836 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15838 if (!unformat (vam->input, "tunnel_index %d", &index))
15845 print (vam->ofp, " tunnel_index %d", index);
15847 M (MPLS_TUNNEL_DUMP, mp);
15848 mp->tunnel_index = htonl (index);
15851 /* Use a control ping for synchronization */
15852 M (CONTROL_PING, mp_ping);
15859 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
15860 #define vl_api_mpls_fib_details_t_print vl_noop_handler
15863 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
15865 vat_main_t *vam = &vat_main;
15866 int count = ntohl (mp->count);
15867 vl_api_fib_path2_t *fp;
15871 "table-id %d, label %u, ess_bit %u",
15872 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
15874 for (i = 0; i < count; i++)
15876 if (fp->afi == IP46_TYPE_IP6)
15878 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15879 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15880 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15881 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15882 format_ip6_address, fp->next_hop);
15883 else if (fp->afi == IP46_TYPE_IP4)
15885 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15886 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15887 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15888 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15889 format_ip4_address, fp->next_hop);
15894 static void vl_api_mpls_fib_details_t_handler_json
15895 (vl_api_mpls_fib_details_t * mp)
15897 vat_main_t *vam = &vat_main;
15898 int count = ntohl (mp->count);
15899 vat_json_node_t *node = NULL;
15900 struct in_addr ip4;
15901 struct in6_addr ip6;
15902 vl_api_fib_path2_t *fp;
15905 if (VAT_JSON_ARRAY != vam->json_tree.type)
15907 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15908 vat_json_init_array (&vam->json_tree);
15910 node = vat_json_array_add (&vam->json_tree);
15912 vat_json_init_object (node);
15913 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15914 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
15915 vat_json_object_add_uint (node, "label", ntohl (mp->label));
15916 vat_json_object_add_uint (node, "path_count", count);
15918 for (i = 0; i < count; i++)
15920 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15921 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15922 vat_json_object_add_uint (node, "is_local", fp->is_local);
15923 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15924 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15925 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15926 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15927 if (fp->afi == IP46_TYPE_IP4)
15929 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15930 vat_json_object_add_ip4 (node, "next_hop", ip4);
15932 else if (fp->afi == IP46_TYPE_IP6)
15934 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15935 vat_json_object_add_ip6 (node, "next_hop", ip6);
15941 api_mpls_fib_dump (vat_main_t * vam)
15943 vl_api_mpls_fib_dump_t *mp;
15944 vl_api_control_ping_t *mp_ping;
15947 M (MPLS_FIB_DUMP, mp);
15950 /* Use a control ping for synchronization */
15951 M (CONTROL_PING, mp_ping);
15958 #define vl_api_ip_fib_details_t_endian vl_noop_handler
15959 #define vl_api_ip_fib_details_t_print vl_noop_handler
15962 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
15964 vat_main_t *vam = &vat_main;
15965 int count = ntohl (mp->count);
15966 vl_api_fib_path_t *fp;
15970 "table-id %d, prefix %U/%d",
15971 ntohl (mp->table_id), format_ip4_address, mp->address,
15972 mp->address_length);
15974 for (i = 0; i < count; i++)
15976 if (fp->afi == IP46_TYPE_IP6)
15978 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15979 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15980 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15981 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15982 format_ip6_address, fp->next_hop);
15983 else if (fp->afi == IP46_TYPE_IP4)
15985 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15986 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15987 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15988 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15989 format_ip4_address, fp->next_hop);
15994 static void vl_api_ip_fib_details_t_handler_json
15995 (vl_api_ip_fib_details_t * mp)
15997 vat_main_t *vam = &vat_main;
15998 int count = ntohl (mp->count);
15999 vat_json_node_t *node = NULL;
16000 struct in_addr ip4;
16001 struct in6_addr ip6;
16002 vl_api_fib_path_t *fp;
16005 if (VAT_JSON_ARRAY != vam->json_tree.type)
16007 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16008 vat_json_init_array (&vam->json_tree);
16010 node = vat_json_array_add (&vam->json_tree);
16012 vat_json_init_object (node);
16013 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16014 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
16015 vat_json_object_add_ip4 (node, "prefix", ip4);
16016 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16017 vat_json_object_add_uint (node, "path_count", count);
16019 for (i = 0; i < count; i++)
16021 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16022 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16023 vat_json_object_add_uint (node, "is_local", fp->is_local);
16024 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16025 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16026 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16027 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16028 if (fp->afi == IP46_TYPE_IP4)
16030 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16031 vat_json_object_add_ip4 (node, "next_hop", ip4);
16033 else if (fp->afi == IP46_TYPE_IP6)
16035 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16036 vat_json_object_add_ip6 (node, "next_hop", ip6);
16042 api_ip_fib_dump (vat_main_t * vam)
16044 vl_api_ip_fib_dump_t *mp;
16045 vl_api_control_ping_t *mp_ping;
16048 M (IP_FIB_DUMP, mp);
16051 /* Use a control ping for synchronization */
16052 M (CONTROL_PING, mp_ping);
16060 api_ip_mfib_dump (vat_main_t * vam)
16062 vl_api_ip_mfib_dump_t *mp;
16063 vl_api_control_ping_t *mp_ping;
16066 M (IP_MFIB_DUMP, mp);
16069 /* Use a control ping for synchronization */
16070 M (CONTROL_PING, mp_ping);
16077 static void vl_api_ip_neighbor_details_t_handler
16078 (vl_api_ip_neighbor_details_t * mp)
16080 vat_main_t *vam = &vat_main;
16082 print (vam->ofp, "%c %U %U",
16083 (mp->is_static) ? 'S' : 'D',
16084 format_ethernet_address, &mp->mac_address,
16085 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
16089 static void vl_api_ip_neighbor_details_t_handler_json
16090 (vl_api_ip_neighbor_details_t * mp)
16093 vat_main_t *vam = &vat_main;
16094 vat_json_node_t *node;
16095 struct in_addr ip4;
16096 struct in6_addr ip6;
16098 if (VAT_JSON_ARRAY != vam->json_tree.type)
16100 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16101 vat_json_init_array (&vam->json_tree);
16103 node = vat_json_array_add (&vam->json_tree);
16105 vat_json_init_object (node);
16106 vat_json_object_add_string_copy (node, "flag",
16107 (mp->is_static) ? (u8 *) "static" : (u8 *)
16110 vat_json_object_add_string_copy (node, "link_layer",
16111 format (0, "%U", format_ethernet_address,
16112 &mp->mac_address));
16116 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
16117 vat_json_object_add_ip6 (node, "ip_address", ip6);
16121 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
16122 vat_json_object_add_ip4 (node, "ip_address", ip4);
16127 api_ip_neighbor_dump (vat_main_t * vam)
16129 unformat_input_t *i = vam->input;
16130 vl_api_ip_neighbor_dump_t *mp;
16131 vl_api_control_ping_t *mp_ping;
16133 u32 sw_if_index = ~0;
16136 /* Parse args required to build the message */
16137 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16139 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16141 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16143 else if (unformat (i, "ip6"))
16149 if (sw_if_index == ~0)
16151 errmsg ("missing interface name or sw_if_index");
16155 M (IP_NEIGHBOR_DUMP, mp);
16156 mp->is_ipv6 = (u8) is_ipv6;
16157 mp->sw_if_index = ntohl (sw_if_index);
16160 /* Use a control ping for synchronization */
16161 M (CONTROL_PING, mp_ping);
16168 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
16169 #define vl_api_ip6_fib_details_t_print vl_noop_handler
16172 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
16174 vat_main_t *vam = &vat_main;
16175 int count = ntohl (mp->count);
16176 vl_api_fib_path_t *fp;
16180 "table-id %d, prefix %U/%d",
16181 ntohl (mp->table_id), format_ip6_address, mp->address,
16182 mp->address_length);
16184 for (i = 0; i < count; i++)
16186 if (fp->afi == IP46_TYPE_IP6)
16188 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16189 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16190 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16191 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16192 format_ip6_address, fp->next_hop);
16193 else if (fp->afi == IP46_TYPE_IP4)
16195 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16196 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16197 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16198 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16199 format_ip4_address, fp->next_hop);
16204 static void vl_api_ip6_fib_details_t_handler_json
16205 (vl_api_ip6_fib_details_t * mp)
16207 vat_main_t *vam = &vat_main;
16208 int count = ntohl (mp->count);
16209 vat_json_node_t *node = NULL;
16210 struct in_addr ip4;
16211 struct in6_addr ip6;
16212 vl_api_fib_path_t *fp;
16215 if (VAT_JSON_ARRAY != vam->json_tree.type)
16217 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16218 vat_json_init_array (&vam->json_tree);
16220 node = vat_json_array_add (&vam->json_tree);
16222 vat_json_init_object (node);
16223 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16224 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
16225 vat_json_object_add_ip6 (node, "prefix", ip6);
16226 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16227 vat_json_object_add_uint (node, "path_count", count);
16229 for (i = 0; i < count; i++)
16231 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16232 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16233 vat_json_object_add_uint (node, "is_local", fp->is_local);
16234 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16235 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16236 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16237 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16238 if (fp->afi == IP46_TYPE_IP4)
16240 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16241 vat_json_object_add_ip4 (node, "next_hop", ip4);
16243 else if (fp->afi == IP46_TYPE_IP6)
16245 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16246 vat_json_object_add_ip6 (node, "next_hop", ip6);
16252 api_ip6_fib_dump (vat_main_t * vam)
16254 vl_api_ip6_fib_dump_t *mp;
16255 vl_api_control_ping_t *mp_ping;
16258 M (IP6_FIB_DUMP, mp);
16261 /* Use a control ping for synchronization */
16262 M (CONTROL_PING, mp_ping);
16270 api_ip6_mfib_dump (vat_main_t * vam)
16272 vl_api_ip6_mfib_dump_t *mp;
16273 vl_api_control_ping_t *mp_ping;
16276 M (IP6_MFIB_DUMP, mp);
16279 /* Use a control ping for synchronization */
16280 M (CONTROL_PING, mp_ping);
16288 api_classify_table_ids (vat_main_t * vam)
16290 vl_api_classify_table_ids_t *mp;
16293 /* Construct the API message */
16294 M (CLASSIFY_TABLE_IDS, mp);
16303 api_classify_table_by_interface (vat_main_t * vam)
16305 unformat_input_t *input = vam->input;
16306 vl_api_classify_table_by_interface_t *mp;
16308 u32 sw_if_index = ~0;
16310 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16312 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16314 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16319 if (sw_if_index == ~0)
16321 errmsg ("missing interface name or sw_if_index");
16325 /* Construct the API message */
16326 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
16328 mp->sw_if_index = ntohl (sw_if_index);
16336 api_classify_table_info (vat_main_t * vam)
16338 unformat_input_t *input = vam->input;
16339 vl_api_classify_table_info_t *mp;
16343 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16345 if (unformat (input, "table_id %d", &table_id))
16350 if (table_id == ~0)
16352 errmsg ("missing table id");
16356 /* Construct the API message */
16357 M (CLASSIFY_TABLE_INFO, mp);
16359 mp->table_id = ntohl (table_id);
16367 api_classify_session_dump (vat_main_t * vam)
16369 unformat_input_t *input = vam->input;
16370 vl_api_classify_session_dump_t *mp;
16371 vl_api_control_ping_t *mp_ping;
16375 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16377 if (unformat (input, "table_id %d", &table_id))
16382 if (table_id == ~0)
16384 errmsg ("missing table id");
16388 /* Construct the API message */
16389 M (CLASSIFY_SESSION_DUMP, mp);
16391 mp->table_id = ntohl (table_id);
16394 /* Use a control ping for synchronization */
16395 M (CONTROL_PING, mp_ping);
16403 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
16405 vat_main_t *vam = &vat_main;
16407 print (vam->ofp, "collector_address %U, collector_port %d, "
16408 "src_address %U, vrf_id %d, path_mtu %u, "
16409 "template_interval %u, udp_checksum %d",
16410 format_ip4_address, mp->collector_address,
16411 ntohs (mp->collector_port),
16412 format_ip4_address, mp->src_address,
16413 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
16414 ntohl (mp->template_interval), mp->udp_checksum);
16417 vam->result_ready = 1;
16421 vl_api_ipfix_exporter_details_t_handler_json
16422 (vl_api_ipfix_exporter_details_t * mp)
16424 vat_main_t *vam = &vat_main;
16425 vat_json_node_t node;
16426 struct in_addr collector_address;
16427 struct in_addr src_address;
16429 vat_json_init_object (&node);
16430 clib_memcpy (&collector_address, &mp->collector_address,
16431 sizeof (collector_address));
16432 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
16433 vat_json_object_add_uint (&node, "collector_port",
16434 ntohs (mp->collector_port));
16435 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
16436 vat_json_object_add_ip4 (&node, "src_address", src_address);
16437 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
16438 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
16439 vat_json_object_add_uint (&node, "template_interval",
16440 ntohl (mp->template_interval));
16441 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
16443 vat_json_print (vam->ofp, &node);
16444 vat_json_free (&node);
16446 vam->result_ready = 1;
16450 api_ipfix_exporter_dump (vat_main_t * vam)
16452 vl_api_ipfix_exporter_dump_t *mp;
16455 /* Construct the API message */
16456 M (IPFIX_EXPORTER_DUMP, mp);
16465 api_ipfix_classify_stream_dump (vat_main_t * vam)
16467 vl_api_ipfix_classify_stream_dump_t *mp;
16470 /* Construct the API message */
16471 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
16482 vl_api_ipfix_classify_stream_details_t_handler
16483 (vl_api_ipfix_classify_stream_details_t * mp)
16485 vat_main_t *vam = &vat_main;
16486 print (vam->ofp, "domain_id %d, src_port %d",
16487 ntohl (mp->domain_id), ntohs (mp->src_port));
16489 vam->result_ready = 1;
16493 vl_api_ipfix_classify_stream_details_t_handler_json
16494 (vl_api_ipfix_classify_stream_details_t * mp)
16496 vat_main_t *vam = &vat_main;
16497 vat_json_node_t node;
16499 vat_json_init_object (&node);
16500 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
16501 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
16503 vat_json_print (vam->ofp, &node);
16504 vat_json_free (&node);
16506 vam->result_ready = 1;
16510 api_ipfix_classify_table_dump (vat_main_t * vam)
16512 vl_api_ipfix_classify_table_dump_t *mp;
16513 vl_api_control_ping_t *mp_ping;
16516 if (!vam->json_output)
16518 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
16519 "transport_protocol");
16522 /* Construct the API message */
16523 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
16528 /* Use a control ping for synchronization */
16529 M (CONTROL_PING, mp_ping);
16537 vl_api_ipfix_classify_table_details_t_handler
16538 (vl_api_ipfix_classify_table_details_t * mp)
16540 vat_main_t *vam = &vat_main;
16541 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
16542 mp->transport_protocol);
16546 vl_api_ipfix_classify_table_details_t_handler_json
16547 (vl_api_ipfix_classify_table_details_t * mp)
16549 vat_json_node_t *node = NULL;
16550 vat_main_t *vam = &vat_main;
16552 if (VAT_JSON_ARRAY != vam->json_tree.type)
16554 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16555 vat_json_init_array (&vam->json_tree);
16558 node = vat_json_array_add (&vam->json_tree);
16559 vat_json_init_object (node);
16561 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
16562 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
16563 vat_json_object_add_uint (node, "transport_protocol",
16564 mp->transport_protocol);
16568 api_sw_interface_span_enable_disable (vat_main_t * vam)
16570 unformat_input_t *i = vam->input;
16571 vl_api_sw_interface_span_enable_disable_t *mp;
16572 u32 src_sw_if_index = ~0;
16573 u32 dst_sw_if_index = ~0;
16577 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16580 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
16582 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
16586 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
16588 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16590 else if (unformat (i, "disable"))
16592 else if (unformat (i, "rx"))
16594 else if (unformat (i, "tx"))
16596 else if (unformat (i, "both"))
16602 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
16604 mp->sw_if_index_from = htonl (src_sw_if_index);
16605 mp->sw_if_index_to = htonl (dst_sw_if_index);
16614 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16617 vat_main_t *vam = &vat_main;
16618 u8 *sw_if_from_name = 0;
16619 u8 *sw_if_to_name = 0;
16620 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16621 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16622 char *states[] = { "none", "rx", "tx", "both" };
16626 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16628 if ((u32) p->value[0] == sw_if_index_from)
16630 sw_if_from_name = (u8 *)(p->key);
16634 if ((u32) p->value[0] == sw_if_index_to)
16636 sw_if_to_name = (u8 *)(p->key);
16637 if (sw_if_from_name)
16642 print (vam->ofp, "%20s => %20s (%s)",
16643 sw_if_from_name, sw_if_to_name, states[mp->state]);
16647 vl_api_sw_interface_span_details_t_handler_json
16648 (vl_api_sw_interface_span_details_t * mp)
16650 vat_main_t *vam = &vat_main;
16651 vat_json_node_t *node = NULL;
16652 u8 *sw_if_from_name = 0;
16653 u8 *sw_if_to_name = 0;
16654 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16655 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16659 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16661 if ((u32) p->value[0] == sw_if_index_from)
16663 sw_if_from_name = (u8 *)(p->key);
16667 if ((u32) p->value[0] == sw_if_index_to)
16669 sw_if_to_name = (u8 *)(p->key);
16670 if (sw_if_from_name)
16676 if (VAT_JSON_ARRAY != vam->json_tree.type)
16678 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16679 vat_json_init_array (&vam->json_tree);
16681 node = vat_json_array_add (&vam->json_tree);
16683 vat_json_init_object (node);
16684 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16685 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16686 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16687 if (0 != sw_if_to_name)
16689 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16691 vat_json_object_add_uint (node, "state", mp->state);
16695 api_sw_interface_span_dump (vat_main_t * vam)
16697 vl_api_sw_interface_span_dump_t *mp;
16698 vl_api_control_ping_t *mp_ping;
16701 M (SW_INTERFACE_SPAN_DUMP, mp);
16704 /* Use a control ping for synchronization */
16705 M (CONTROL_PING, mp_ping);
16713 api_pg_create_interface (vat_main_t * vam)
16715 unformat_input_t *input = vam->input;
16716 vl_api_pg_create_interface_t *mp;
16720 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16722 if (unformat (input, "if_id %d", &if_id))
16729 errmsg ("missing pg interface index");
16733 /* Construct the API message */
16734 M (PG_CREATE_INTERFACE, mp);
16736 mp->interface_id = ntohl (if_id);
16744 api_pg_capture (vat_main_t * vam)
16746 unformat_input_t *input = vam->input;
16747 vl_api_pg_capture_t *mp;
16752 u8 pcap_file_set = 0;
16755 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16757 if (unformat (input, "if_id %d", &if_id))
16759 else if (unformat (input, "pcap %s", &pcap_file))
16761 else if (unformat (input, "count %d", &count))
16763 else if (unformat (input, "disable"))
16770 errmsg ("missing pg interface index");
16773 if (pcap_file_set > 0)
16775 if (vec_len (pcap_file) > 255)
16777 errmsg ("pcap file name is too long");
16782 u32 name_len = vec_len (pcap_file);
16783 /* Construct the API message */
16784 M (PG_CAPTURE, mp);
16786 mp->interface_id = ntohl (if_id);
16787 mp->is_enabled = enable;
16788 mp->count = ntohl (count);
16789 mp->pcap_name_length = ntohl (name_len);
16790 if (pcap_file_set != 0)
16792 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16794 vec_free (pcap_file);
16802 api_pg_enable_disable (vat_main_t * vam)
16804 unformat_input_t *input = vam->input;
16805 vl_api_pg_enable_disable_t *mp;
16808 u8 stream_name_set = 0;
16809 u8 *stream_name = 0;
16811 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16813 if (unformat (input, "stream %s", &stream_name))
16814 stream_name_set = 1;
16815 else if (unformat (input, "disable"))
16821 if (stream_name_set > 0)
16823 if (vec_len (stream_name) > 255)
16825 errmsg ("stream name too long");
16830 u32 name_len = vec_len (stream_name);
16831 /* Construct the API message */
16832 M (PG_ENABLE_DISABLE, mp);
16834 mp->is_enabled = enable;
16835 if (stream_name_set != 0)
16837 mp->stream_name_length = ntohl (name_len);
16838 clib_memcpy (mp->stream_name, stream_name, name_len);
16840 vec_free (stream_name);
16848 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16850 unformat_input_t *input = vam->input;
16851 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16853 u16 *low_ports = 0;
16854 u16 *high_ports = 0;
16857 ip4_address_t ip4_addr;
16858 ip6_address_t ip6_addr;
16867 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16869 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
16875 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
16880 else if (unformat (input, "vrf %d", &vrf_id))
16882 else if (unformat (input, "del"))
16884 else if (unformat (input, "port %d", &tmp))
16886 if (tmp == 0 || tmp > 65535)
16888 errmsg ("port %d out of range", tmp);
16892 this_hi = this_low + 1;
16893 vec_add1 (low_ports, this_low);
16894 vec_add1 (high_ports, this_hi);
16896 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
16898 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
16900 errmsg ("incorrect range parameters");
16904 /* Note: in debug CLI +1 is added to high before
16905 passing to real fn that does "the work"
16906 (ip_source_and_port_range_check_add_del).
16907 This fn is a wrapper around the binary API fn a
16908 control plane will call, which expects this increment
16909 to have occurred. Hence letting the binary API control
16910 plane fn do the increment for consistency between VAT
16911 and other control planes.
16914 vec_add1 (low_ports, this_low);
16915 vec_add1 (high_ports, this_hi);
16921 if (prefix_set == 0)
16923 errmsg ("<address>/<mask> not specified");
16929 errmsg ("VRF ID required, not specified");
16936 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16940 if (vec_len (low_ports) == 0)
16942 errmsg ("At least one port or port range required");
16946 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
16948 mp->is_add = is_add;
16953 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
16958 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
16961 mp->mask_length = length;
16962 mp->number_of_ranges = vec_len (low_ports);
16964 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
16965 vec_free (low_ports);
16967 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
16968 vec_free (high_ports);
16970 mp->vrf_id = ntohl (vrf_id);
16978 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
16980 unformat_input_t *input = vam->input;
16981 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
16982 u32 sw_if_index = ~0;
16984 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
16985 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
16989 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16991 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16993 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16995 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
16997 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
16999 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
17001 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
17003 else if (unformat (input, "del"))
17009 if (sw_if_index == ~0)
17011 errmsg ("Interface required but not specified");
17017 errmsg ("VRF ID required but not specified");
17021 if (tcp_out_vrf_id == 0
17022 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
17025 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17029 /* Construct the API message */
17030 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
17032 mp->sw_if_index = ntohl (sw_if_index);
17033 mp->is_add = is_add;
17034 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
17035 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
17036 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
17037 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
17042 /* Wait for a reply... */
17048 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
17050 unformat_input_t *i = vam->input;
17051 vl_api_ipsec_gre_add_del_tunnel_t *mp;
17052 u32 local_sa_id = 0;
17053 u32 remote_sa_id = 0;
17054 ip4_address_t src_address;
17055 ip4_address_t dst_address;
17059 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17061 if (unformat (i, "local_sa %d", &local_sa_id))
17063 else if (unformat (i, "remote_sa %d", &remote_sa_id))
17065 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
17067 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
17069 else if (unformat (i, "del"))
17073 clib_warning ("parse error '%U'", format_unformat_error, i);
17078 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
17080 mp->local_sa_id = ntohl (local_sa_id);
17081 mp->remote_sa_id = ntohl (remote_sa_id);
17082 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
17083 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
17084 mp->is_add = is_add;
17092 api_punt (vat_main_t * vam)
17094 unformat_input_t *i = vam->input;
17102 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17104 if (unformat (i, "ip %d", &ipv))
17106 else if (unformat (i, "protocol %d", &protocol))
17108 else if (unformat (i, "port %d", &port))
17110 else if (unformat (i, "del"))
17114 clib_warning ("parse error '%U'", format_unformat_error, i);
17121 mp->is_add = (u8) is_add;
17122 mp->ipv = (u8) ipv;
17123 mp->l4_protocol = (u8) protocol;
17124 mp->l4_port = htons ((u16) port);
17131 static void vl_api_ipsec_gre_tunnel_details_t_handler
17132 (vl_api_ipsec_gre_tunnel_details_t * mp)
17134 vat_main_t *vam = &vat_main;
17136 print (vam->ofp, "%11d%15U%15U%14d%14d",
17137 ntohl (mp->sw_if_index),
17138 format_ip4_address, &mp->src_address,
17139 format_ip4_address, &mp->dst_address,
17140 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
17143 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
17144 (vl_api_ipsec_gre_tunnel_details_t * mp)
17146 vat_main_t *vam = &vat_main;
17147 vat_json_node_t *node = NULL;
17148 struct in_addr ip4;
17150 if (VAT_JSON_ARRAY != vam->json_tree.type)
17152 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17153 vat_json_init_array (&vam->json_tree);
17155 node = vat_json_array_add (&vam->json_tree);
17157 vat_json_init_object (node);
17158 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17159 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
17160 vat_json_object_add_ip4 (node, "src_address", ip4);
17161 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
17162 vat_json_object_add_ip4 (node, "dst_address", ip4);
17163 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
17164 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
17168 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
17170 unformat_input_t *i = vam->input;
17171 vl_api_ipsec_gre_tunnel_dump_t *mp;
17172 vl_api_control_ping_t *mp_ping;
17174 u8 sw_if_index_set = 0;
17177 /* Parse args required to build the message */
17178 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17180 if (unformat (i, "sw_if_index %d", &sw_if_index))
17181 sw_if_index_set = 1;
17186 if (sw_if_index_set == 0)
17191 if (!vam->json_output)
17193 print (vam->ofp, "%11s%15s%15s%14s%14s",
17194 "sw_if_index", "src_address", "dst_address",
17195 "local_sa_id", "remote_sa_id");
17198 /* Get list of gre-tunnel interfaces */
17199 M (IPSEC_GRE_TUNNEL_DUMP, mp);
17201 mp->sw_if_index = htonl (sw_if_index);
17205 /* Use a control ping for synchronization */
17206 M (CONTROL_PING, mp_ping);
17214 api_delete_subif (vat_main_t * vam)
17216 unformat_input_t *i = vam->input;
17217 vl_api_delete_subif_t *mp;
17218 u32 sw_if_index = ~0;
17221 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17223 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17225 if (unformat (i, "sw_if_index %d", &sw_if_index))
17231 if (sw_if_index == ~0)
17233 errmsg ("missing sw_if_index");
17237 /* Construct the API message */
17238 M (DELETE_SUBIF, mp);
17239 mp->sw_if_index = ntohl (sw_if_index);
17246 #define foreach_pbb_vtr_op \
17247 _("disable", L2_VTR_DISABLED) \
17248 _("pop", L2_VTR_POP_2) \
17249 _("push", L2_VTR_PUSH_2)
17252 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
17254 unformat_input_t *i = vam->input;
17255 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
17256 u32 sw_if_index = ~0, vtr_op = ~0;
17257 u16 outer_tag = ~0;
17258 u8 dmac[6], smac[6];
17259 u8 dmac_set = 0, smac_set = 0;
17265 /* Shut up coverity */
17266 memset (dmac, 0, sizeof (dmac));
17267 memset (smac, 0, sizeof (smac));
17269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17271 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17273 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17275 else if (unformat (i, "vtr_op %d", &vtr_op))
17277 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
17280 else if (unformat (i, "translate_pbb_stag"))
17282 if (unformat (i, "%d", &tmp))
17284 vtr_op = L2_VTR_TRANSLATE_2_1;
17290 ("translate_pbb_stag operation requires outer tag definition");
17294 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
17296 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
17298 else if (unformat (i, "sid %d", &sid))
17300 else if (unformat (i, "vlanid %d", &tmp))
17304 clib_warning ("parse error '%U'", format_unformat_error, i);
17309 if ((sw_if_index == ~0) || (vtr_op == ~0))
17311 errmsg ("missing sw_if_index or vtr operation");
17314 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
17315 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
17318 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
17322 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
17323 mp->sw_if_index = ntohl (sw_if_index);
17324 mp->vtr_op = ntohl (vtr_op);
17325 mp->outer_tag = ntohs (outer_tag);
17326 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
17327 clib_memcpy (mp->b_smac, smac, sizeof (smac));
17328 mp->b_vlanid = ntohs (vlanid);
17329 mp->i_sid = ntohl (sid);
17337 api_flow_classify_set_interface (vat_main_t * vam)
17339 unformat_input_t *i = vam->input;
17340 vl_api_flow_classify_set_interface_t *mp;
17342 int sw_if_index_set;
17343 u32 ip4_table_index = ~0;
17344 u32 ip6_table_index = ~0;
17348 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17350 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17351 sw_if_index_set = 1;
17352 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17353 sw_if_index_set = 1;
17354 else if (unformat (i, "del"))
17356 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17358 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17362 clib_warning ("parse error '%U'", format_unformat_error, i);
17367 if (sw_if_index_set == 0)
17369 errmsg ("missing interface name or sw_if_index");
17373 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
17375 mp->sw_if_index = ntohl (sw_if_index);
17376 mp->ip4_table_index = ntohl (ip4_table_index);
17377 mp->ip6_table_index = ntohl (ip6_table_index);
17378 mp->is_add = is_add;
17386 api_flow_classify_dump (vat_main_t * vam)
17388 unformat_input_t *i = vam->input;
17389 vl_api_flow_classify_dump_t *mp;
17390 vl_api_control_ping_t *mp_ping;
17391 u8 type = FLOW_CLASSIFY_N_TABLES;
17394 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
17398 errmsg ("classify table type must be specified");
17402 if (!vam->json_output)
17404 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17407 M (FLOW_CLASSIFY_DUMP, mp);
17412 /* Use a control ping for synchronization */
17413 M (CONTROL_PING, mp_ping);
17416 /* Wait for a reply... */
17422 api_feature_enable_disable (vat_main_t * vam)
17424 unformat_input_t *i = vam->input;
17425 vl_api_feature_enable_disable_t *mp;
17427 u8 *feature_name = 0;
17428 u32 sw_if_index = ~0;
17432 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17434 if (unformat (i, "arc_name %s", &arc_name))
17436 else if (unformat (i, "feature_name %s", &feature_name))
17439 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17441 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17443 else if (unformat (i, "disable"))
17451 errmsg ("missing arc name");
17454 if (vec_len (arc_name) > 63)
17456 errmsg ("arc name too long");
17459 if (feature_name == 0)
17461 errmsg ("missing feature name");
17464 if (vec_len (feature_name) > 63)
17466 errmsg ("feature name too long");
17469 if (sw_if_index == ~0)
17471 errmsg ("missing interface name or sw_if_index");
17475 /* Construct the API message */
17476 M (FEATURE_ENABLE_DISABLE, mp);
17477 mp->sw_if_index = ntohl (sw_if_index);
17478 mp->enable = enable;
17479 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
17480 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
17481 vec_free (arc_name);
17482 vec_free (feature_name);
17490 api_sw_interface_tag_add_del (vat_main_t * vam)
17492 unformat_input_t *i = vam->input;
17493 vl_api_sw_interface_tag_add_del_t *mp;
17494 u32 sw_if_index = ~0;
17499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17501 if (unformat (i, "tag %s", &tag))
17503 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17505 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17507 else if (unformat (i, "del"))
17513 if (sw_if_index == ~0)
17515 errmsg ("missing interface name or sw_if_index");
17519 if (enable && (tag == 0))
17521 errmsg ("no tag specified");
17525 /* Construct the API message */
17526 M (SW_INTERFACE_TAG_ADD_DEL, mp);
17527 mp->sw_if_index = ntohl (sw_if_index);
17528 mp->is_add = enable;
17530 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
17538 static void vl_api_l2_xconnect_details_t_handler
17539 (vl_api_l2_xconnect_details_t * mp)
17541 vat_main_t *vam = &vat_main;
17543 print (vam->ofp, "%15d%15d",
17544 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
17547 static void vl_api_l2_xconnect_details_t_handler_json
17548 (vl_api_l2_xconnect_details_t * mp)
17550 vat_main_t *vam = &vat_main;
17551 vat_json_node_t *node = NULL;
17553 if (VAT_JSON_ARRAY != vam->json_tree.type)
17555 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17556 vat_json_init_array (&vam->json_tree);
17558 node = vat_json_array_add (&vam->json_tree);
17560 vat_json_init_object (node);
17561 vat_json_object_add_uint (node, "rx_sw_if_index",
17562 ntohl (mp->rx_sw_if_index));
17563 vat_json_object_add_uint (node, "tx_sw_if_index",
17564 ntohl (mp->tx_sw_if_index));
17568 api_l2_xconnect_dump (vat_main_t * vam)
17570 vl_api_l2_xconnect_dump_t *mp;
17571 vl_api_control_ping_t *mp_ping;
17574 if (!vam->json_output)
17576 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
17579 M (L2_XCONNECT_DUMP, mp);
17583 /* Use a control ping for synchronization */
17584 M (CONTROL_PING, mp_ping);
17592 api_sw_interface_set_mtu (vat_main_t * vam)
17594 unformat_input_t *i = vam->input;
17595 vl_api_sw_interface_set_mtu_t *mp;
17596 u32 sw_if_index = ~0;
17600 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17602 if (unformat (i, "mtu %d", &mtu))
17604 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17606 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17612 if (sw_if_index == ~0)
17614 errmsg ("missing interface name or sw_if_index");
17620 errmsg ("no mtu specified");
17624 /* Construct the API message */
17625 M (SW_INTERFACE_SET_MTU, mp);
17626 mp->sw_if_index = ntohl (sw_if_index);
17627 mp->mtu = ntohs ((u16) mtu);
17636 q_or_quit (vat_main_t * vam)
17638 #if VPP_API_TEST_BUILTIN == 0
17639 longjmp (vam->jump_buf, 1);
17641 return 0; /* not so much */
17645 q (vat_main_t * vam)
17647 return q_or_quit (vam);
17651 quit (vat_main_t * vam)
17653 return q_or_quit (vam);
17657 comment (vat_main_t * vam)
17663 cmd_cmp (void *a1, void *a2)
17668 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17672 help (vat_main_t * vam)
17677 unformat_input_t *i = vam->input;
17680 if (unformat (i, "%s", &name))
17684 vec_add1 (name, 0);
17686 hs = hash_get_mem (vam->help_by_name, name);
17688 print (vam->ofp, "usage: %s %s", name, hs[0]);
17690 print (vam->ofp, "No such msg / command '%s'", name);
17695 print (vam->ofp, "Help is available for the following:");
17698 hash_foreach_pair (p, vam->function_by_name,
17700 vec_add1 (cmds, (u8 *)(p->key));
17704 vec_sort_with_function (cmds, cmd_cmp);
17706 for (j = 0; j < vec_len (cmds); j++)
17707 print (vam->ofp, "%s", cmds[j]);
17714 set (vat_main_t * vam)
17716 u8 *name = 0, *value = 0;
17717 unformat_input_t *i = vam->input;
17719 if (unformat (i, "%s", &name))
17721 /* The input buffer is a vector, not a string. */
17722 value = vec_dup (i->buffer);
17723 vec_delete (value, i->index, 0);
17724 /* Almost certainly has a trailing newline */
17725 if (value[vec_len (value) - 1] == '\n')
17726 value[vec_len (value) - 1] = 0;
17727 /* Make sure it's a proper string, one way or the other */
17728 vec_add1 (value, 0);
17729 (void) clib_macro_set_value (&vam->macro_main,
17730 (char *) name, (char *) value);
17733 errmsg ("usage: set <name> <value>");
17741 unset (vat_main_t * vam)
17745 if (unformat (vam->input, "%s", &name))
17746 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17747 errmsg ("unset: %s wasn't set", name);
17760 macro_sort_cmp (void *a1, void *a2)
17762 macro_sort_t *s1 = a1;
17763 macro_sort_t *s2 = a2;
17765 return strcmp ((char *) (s1->name), (char *) (s2->name));
17769 dump_macro_table (vat_main_t * vam)
17771 macro_sort_t *sort_me = 0, *sm;
17776 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17778 vec_add2 (sort_me, sm, 1);
17779 sm->name = (u8 *)(p->key);
17780 sm->value = (u8 *) (p->value[0]);
17784 vec_sort_with_function (sort_me, macro_sort_cmp);
17786 if (vec_len (sort_me))
17787 print (vam->ofp, "%-15s%s", "Name", "Value");
17789 print (vam->ofp, "The macro table is empty...");
17791 for (i = 0; i < vec_len (sort_me); i++)
17792 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17797 dump_node_table (vat_main_t * vam)
17800 vlib_node_t *node, *next_node;
17802 if (vec_len (vam->graph_nodes) == 0)
17804 print (vam->ofp, "Node table empty, issue get_node_graph...");
17808 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17810 node = vam->graph_nodes[i];
17811 print (vam->ofp, "[%d] %s", i, node->name);
17812 for (j = 0; j < vec_len (node->next_nodes); j++)
17814 if (node->next_nodes[j] != ~0)
17816 next_node = vam->graph_nodes[node->next_nodes[j]];
17817 print (vam->ofp, " [%d] %s", j, next_node->name);
17825 value_sort_cmp (void *a1, void *a2)
17827 name_sort_t *n1 = a1;
17828 name_sort_t *n2 = a2;
17830 if (n1->value < n2->value)
17832 if (n1->value > n2->value)
17839 dump_msg_api_table (vat_main_t * vam)
17841 api_main_t *am = &api_main;
17842 name_sort_t *nses = 0, *ns;
17847 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17849 vec_add2 (nses, ns, 1);
17850 ns->name = (u8 *)(hp->key);
17851 ns->value = (u32) hp->value[0];
17855 vec_sort_with_function (nses, value_sort_cmp);
17857 for (i = 0; i < vec_len (nses); i++)
17858 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
17864 get_msg_id (vat_main_t * vam)
17869 if (unformat (vam->input, "%s", &name_and_crc))
17871 message_index = vl_api_get_msg_index (name_and_crc);
17872 if (message_index == ~0)
17874 print (vam->ofp, " '%s' not found", name_and_crc);
17877 print (vam->ofp, " '%s' has message index %d",
17878 name_and_crc, message_index);
17881 errmsg ("name_and_crc required...");
17886 search_node_table (vat_main_t * vam)
17888 unformat_input_t *line_input = vam->input;
17891 vlib_node_t *node, *next_node;
17894 if (vam->graph_node_index_by_name == 0)
17896 print (vam->ofp, "Node table empty, issue get_node_graph...");
17900 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
17902 if (unformat (line_input, "%s", &node_to_find))
17904 vec_add1 (node_to_find, 0);
17905 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
17908 print (vam->ofp, "%s not found...", node_to_find);
17911 node = vam->graph_nodes[p[0]];
17912 print (vam->ofp, "[%d] %s", p[0], node->name);
17913 for (j = 0; j < vec_len (node->next_nodes); j++)
17915 if (node->next_nodes[j] != ~0)
17917 next_node = vam->graph_nodes[node->next_nodes[j]];
17918 print (vam->ofp, " [%d] %s", j, next_node->name);
17925 clib_warning ("parse error '%U'", format_unformat_error,
17931 vec_free (node_to_find);
17940 script (vat_main_t * vam)
17942 #if (VPP_API_TEST_BUILTIN==0)
17944 char *save_current_file;
17945 unformat_input_t save_input;
17946 jmp_buf save_jump_buf;
17947 u32 save_line_number;
17949 FILE *new_fp, *save_ifp;
17951 if (unformat (vam->input, "%s", &s))
17953 new_fp = fopen ((char *) s, "r");
17956 errmsg ("Couldn't open script file %s", s);
17963 errmsg ("Missing script name");
17967 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
17968 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
17969 save_ifp = vam->ifp;
17970 save_line_number = vam->input_line_number;
17971 save_current_file = (char *) vam->current_file;
17973 vam->input_line_number = 0;
17975 vam->current_file = s;
17978 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
17979 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
17980 vam->ifp = save_ifp;
17981 vam->input_line_number = save_line_number;
17982 vam->current_file = (u8 *) save_current_file;
17987 clib_warning ("use the exec command...");
17993 echo (vat_main_t * vam)
17995 print (vam->ofp, "%v", vam->input->buffer);
17999 /* List of API message constructors, CLI names map to api_xxx */
18000 #define foreach_vpe_api_msg \
18001 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
18002 _(sw_interface_dump,"") \
18003 _(sw_interface_set_flags, \
18004 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
18005 _(sw_interface_add_del_address, \
18006 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
18007 _(sw_interface_set_table, \
18008 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
18009 _(sw_interface_set_mpls_enable, \
18010 "<intfc> | sw_if_index [disable | dis]") \
18011 _(sw_interface_set_vpath, \
18012 "<intfc> | sw_if_index <id> enable | disable") \
18013 _(sw_interface_set_vxlan_bypass, \
18014 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
18015 _(sw_interface_set_l2_xconnect, \
18016 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18017 "enable | disable") \
18018 _(sw_interface_set_l2_bridge, \
18019 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
18020 "[shg <split-horizon-group>] [bvi]\n" \
18021 "enable | disable") \
18022 _(bridge_domain_add_del, \
18023 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
18024 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
18026 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
18028 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
18030 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
18032 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
18034 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
18036 "<vpp-if-name> | sw_if_index <id>") \
18037 _(sw_interface_tap_dump, "") \
18038 _(ip_add_del_route, \
18039 "<addr>/<mask> via <addr> [table-id <n>]\n" \
18040 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18041 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18042 "[multipath] [count <n>]") \
18043 _(ip_mroute_add_del, \
18044 "<src> <grp>/<mask> [table-id <n>]\n" \
18045 "[<intfc> | sw_if_index <id>] [local] [del]") \
18046 _(mpls_route_add_del, \
18047 "<label> <eos> via <addr> [table-id <n>]\n" \
18048 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18049 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18050 "[multipath] [count <n>]") \
18051 _(mpls_ip_bind_unbind, \
18052 "<label> <addr/len>") \
18053 _(mpls_tunnel_add_del, \
18054 " via <addr> [table-id <n>]\n" \
18055 "sw_if_index <id>] [l2] [del]") \
18056 _(proxy_arp_add_del, \
18057 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
18058 _(proxy_arp_intfc_enable_disable, \
18059 "<intfc> | sw_if_index <id> enable | disable") \
18060 _(sw_interface_set_unnumbered, \
18061 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
18062 _(ip_neighbor_add_del, \
18063 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
18064 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
18065 _(reset_vrf, "vrf <id> [ipv6]") \
18066 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
18067 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
18068 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
18069 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
18070 "[outer_vlan_id_any][inner_vlan_id_any]") \
18071 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
18072 _(reset_fib, "vrf <n> [ipv6]") \
18073 _(dhcp_proxy_config, \
18074 "svr <v46-address> src <v46-address>\n" \
18075 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
18076 _(dhcp_proxy_set_vss, \
18077 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
18078 _(dhcp_proxy_dump, "ip6") \
18079 _(dhcp_client_config, \
18080 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
18081 _(set_ip_flow_hash, \
18082 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
18083 _(sw_interface_ip6_enable_disable, \
18084 "<intfc> | sw_if_index <id> enable | disable") \
18085 _(sw_interface_ip6_set_link_local_address, \
18086 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
18087 _(ip6nd_proxy_add_del, \
18088 "<intfc> | sw_if_index <id> <ip6-address>") \
18089 _(ip6nd_proxy_dump, "") \
18090 _(sw_interface_ip6nd_ra_prefix, \
18091 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
18092 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
18093 "[nolink] [isno]") \
18094 _(sw_interface_ip6nd_ra_config, \
18095 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
18096 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
18097 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
18098 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
18099 _(l2_patch_add_del, \
18100 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18101 "enable | disable") \
18102 _(sr_localsid_add_del, \
18103 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
18104 "fib-table <num> (end.psp) sw_if_index <num>") \
18105 _(classify_add_del_table, \
18106 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
18107 " [del] [del-chain] mask <mask-value>\n" \
18108 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
18109 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
18110 _(classify_add_del_session, \
18111 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
18112 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
18113 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
18114 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
18115 _(classify_set_interface_ip_table, \
18116 "<intfc> | sw_if_index <nn> table <nn>") \
18117 _(classify_set_interface_l2_tables, \
18118 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18119 " [other-table <nn>]") \
18120 _(get_node_index, "node <node-name") \
18121 _(add_node_next, "node <node-name> next <next-node-name>") \
18122 _(l2tpv3_create_tunnel, \
18123 "client_address <ip6-addr> our_address <ip6-addr>\n" \
18124 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
18125 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
18126 _(l2tpv3_set_tunnel_cookies, \
18127 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
18128 "[new_remote_cookie <nn>]\n") \
18129 _(l2tpv3_interface_enable_disable, \
18130 "<intfc> | sw_if_index <nn> enable | disable") \
18131 _(l2tpv3_set_lookup_key, \
18132 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
18133 _(sw_if_l2tpv3_tunnel_dump, "") \
18134 _(vxlan_add_del_tunnel, \
18135 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
18136 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
18137 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
18138 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18139 _(gre_add_del_tunnel, \
18140 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
18141 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18142 _(l2_fib_clear_table, "") \
18143 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
18144 _(l2_interface_vlan_tag_rewrite, \
18145 "<intfc> | sw_if_index <nn> \n" \
18146 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
18147 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
18148 _(create_vhost_user_if, \
18149 "socket <filename> [server] [renumber <dev_instance>] " \
18150 "[mac <mac_address>]") \
18151 _(modify_vhost_user_if, \
18152 "<intfc> | sw_if_index <nn> socket <filename>\n" \
18153 "[server] [renumber <dev_instance>]") \
18154 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
18155 _(sw_interface_vhost_user_dump, "") \
18156 _(show_version, "") \
18157 _(vxlan_gpe_add_del_tunnel, \
18158 "local <addr> remote <addr> vni <nn>\n" \
18159 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
18160 "[next-ethernet] [next-nsh]\n") \
18161 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18162 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
18163 _(interface_name_renumber, \
18164 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
18165 _(input_acl_set_interface, \
18166 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18167 " [l2-table <nn>] [del]") \
18168 _(want_ip4_arp_events, "address <ip4-address> [del]") \
18169 _(want_ip6_nd_events, "address <ip6-address> [del]") \
18170 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
18171 _(ip_dump, "ipv4 | ipv6") \
18172 _(ipsec_spd_add_del, "spd_id <n> [del]") \
18173 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
18175 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
18176 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
18177 " integ_alg <alg> integ_key <hex>") \
18178 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
18179 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
18180 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
18181 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
18182 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
18183 _(ikev2_profile_add_del, "name <profile_name> [del]") \
18184 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
18185 "(auth_data 0x<data> | auth_data <data>)") \
18186 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
18187 "(id_data 0x<data> | id_data <data>) (local|remote)") \
18188 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
18189 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
18190 "(local|remote)") \
18191 _(ikev2_set_local_key, "file <absolute_file_path>") \
18192 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
18193 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18194 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18195 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
18196 _(ikev2_initiate_sa_init, "<profile_name>") \
18197 _(ikev2_initiate_del_ike_sa, "<ispi>") \
18198 _(ikev2_initiate_del_child_sa, "<ispi>") \
18199 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
18200 _(delete_loopback,"sw_if_index <nn>") \
18201 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
18202 _(map_add_domain, \
18203 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
18204 "ip6-src <ip6addr> " \
18205 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
18206 _(map_del_domain, "index <n>") \
18207 _(map_add_del_rule, \
18208 "index <n> psid <n> dst <ip6addr> [del]") \
18209 _(map_domain_dump, "") \
18210 _(map_rule_dump, "index <map-domain>") \
18211 _(want_interface_events, "enable|disable") \
18212 _(want_stats,"enable|disable") \
18213 _(get_first_msg_id, "client <name>") \
18214 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
18215 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
18216 "fib-id <nn> [ip4][ip6][default]") \
18217 _(get_node_graph, " ") \
18218 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
18219 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
18220 _(ioam_disable, "") \
18221 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
18222 " sw_if_index <sw_if_index> p <priority> " \
18223 "w <weight>] [del]") \
18224 _(one_add_del_locator, "locator-set <locator_name> " \
18225 "iface <intf> | sw_if_index <sw_if_index> " \
18226 "p <priority> w <weight> [del]") \
18227 _(one_add_del_local_eid,"vni <vni> eid " \
18228 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18229 "locator-set <locator_name> [del]" \
18230 "[key-id sha1|sha256 secret-key <secret-key>]")\
18231 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
18232 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
18233 _(one_enable_disable, "enable|disable") \
18234 _(one_map_register_enable_disable, "enable|disable") \
18235 _(one_rloc_probe_enable_disable, "enable|disable") \
18236 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18238 "rloc <locator> p <prio> " \
18239 "w <weight> [rloc <loc> ... ] " \
18240 "action <action> [del-all]") \
18241 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18243 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18244 _(one_map_request_mode, "src-dst|dst-only") \
18245 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18246 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18247 _(one_locator_set_dump, "[local | remote]") \
18248 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
18249 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18250 "[local] | [remote]") \
18251 _(one_eid_table_vni_dump, "") \
18252 _(one_eid_table_map_dump, "l2|l3") \
18253 _(one_map_resolver_dump, "") \
18254 _(one_map_server_dump, "") \
18255 _(one_adjacencies_get, "vni <vni>") \
18256 _(show_one_rloc_probe_state, "") \
18257 _(show_one_map_register_state, "") \
18258 _(show_one_status, "") \
18259 _(one_get_map_request_itr_rlocs, "") \
18260 _(show_one_pitr, "") \
18261 _(show_one_map_request_mode, "") \
18262 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
18263 " sw_if_index <sw_if_index> p <priority> " \
18264 "w <weight>] [del]") \
18265 _(lisp_add_del_locator, "locator-set <locator_name> " \
18266 "iface <intf> | sw_if_index <sw_if_index> " \
18267 "p <priority> w <weight> [del]") \
18268 _(lisp_add_del_local_eid,"vni <vni> eid " \
18269 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18270 "locator-set <locator_name> [del]" \
18271 "[key-id sha1|sha256 secret-key <secret-key>]") \
18272 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
18273 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
18274 _(lisp_enable_disable, "enable|disable") \
18275 _(lisp_map_register_enable_disable, "enable|disable") \
18276 _(lisp_rloc_probe_enable_disable, "enable|disable") \
18277 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18279 "rloc <locator> p <prio> " \
18280 "w <weight> [rloc <loc> ... ] " \
18281 "action <action> [del-all]") \
18282 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18284 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18285 _(lisp_map_request_mode, "src-dst|dst-only") \
18286 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18287 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18288 _(lisp_locator_set_dump, "[local | remote]") \
18289 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
18290 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18291 "[local] | [remote]") \
18292 _(lisp_eid_table_vni_dump, "") \
18293 _(lisp_eid_table_map_dump, "l2|l3") \
18294 _(lisp_map_resolver_dump, "") \
18295 _(lisp_map_server_dump, "") \
18296 _(lisp_adjacencies_get, "vni <vni>") \
18297 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
18298 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
18299 _(gpe_set_encap_mode, "lisp|vxlan") \
18300 _(gpe_get_encap_mode, "") \
18301 _(lisp_gpe_add_del_iface, "up|down") \
18302 _(lisp_gpe_enable_disable, "enable|disable") \
18303 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
18304 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
18305 _(show_lisp_rloc_probe_state, "") \
18306 _(show_lisp_map_register_state, "") \
18307 _(show_lisp_status, "") \
18308 _(lisp_get_map_request_itr_rlocs, "") \
18309 _(show_lisp_pitr, "") \
18310 _(show_lisp_map_request_mode, "") \
18311 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
18312 _(af_packet_delete, "name <host interface name>") \
18313 _(policer_add_del, "name <policer name> <params> [del]") \
18314 _(policer_dump, "[name <policer name>]") \
18315 _(policer_classify_set_interface, \
18316 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18317 " [l2-table <nn>] [del]") \
18318 _(policer_classify_dump, "type [ip4|ip6|l2]") \
18319 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
18320 "[master|slave]") \
18321 _(netmap_delete, "name <interface name>") \
18322 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
18323 _(mpls_fib_dump, "") \
18324 _(classify_table_ids, "") \
18325 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
18326 _(classify_table_info, "table_id <nn>") \
18327 _(classify_session_dump, "table_id <nn>") \
18328 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
18329 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
18330 "[template_interval <nn>] [udp_checksum]") \
18331 _(ipfix_exporter_dump, "") \
18332 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
18333 _(ipfix_classify_stream_dump, "") \
18334 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
18335 _(ipfix_classify_table_dump, "") \
18336 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
18337 _(sw_interface_span_dump, "") \
18338 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
18339 _(pg_create_interface, "if_id <nn>") \
18340 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
18341 _(pg_enable_disable, "[stream <id>] disable") \
18342 _(ip_source_and_port_range_check_add_del, \
18343 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
18344 _(ip_source_and_port_range_check_interface_add_del, \
18345 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
18346 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
18347 _(ipsec_gre_add_del_tunnel, \
18348 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
18349 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
18350 _(delete_subif,"<intfc> | sw_if_index <nn>") \
18351 _(l2_interface_pbb_tag_rewrite, \
18352 "<intfc> | sw_if_index <nn> \n" \
18353 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
18354 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
18355 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
18356 _(flow_classify_set_interface, \
18357 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
18358 _(flow_classify_dump, "type [ip4|ip6]") \
18359 _(ip_fib_dump, "") \
18360 _(ip_mfib_dump, "") \
18361 _(ip6_fib_dump, "") \
18362 _(ip6_mfib_dump, "") \
18363 _(feature_enable_disable, "arc_name <arc_name> " \
18364 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
18365 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
18367 _(l2_xconnect_dump, "") \
18368 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
18369 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
18370 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
18372 /* List of command functions, CLI names map directly to functions */
18373 #define foreach_cli_function \
18374 _(comment, "usage: comment <ignore-rest-of-line>") \
18375 _(dump_interface_table, "usage: dump_interface_table") \
18376 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
18377 _(dump_ipv4_table, "usage: dump_ipv4_table") \
18378 _(dump_ipv6_table, "usage: dump_ipv6_table") \
18379 _(dump_stats_table, "usage: dump_stats_table") \
18380 _(dump_macro_table, "usage: dump_macro_table ") \
18381 _(dump_node_table, "usage: dump_node_table") \
18382 _(dump_msg_api_table, "usage: dump_msg_api_table") \
18383 _(get_msg_id, "usage: get_msg_id name_and_crc") \
18384 _(echo, "usage: echo <message>") \
18385 _(exec, "usage: exec <vpe-debug-CLI-command>") \
18386 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
18387 _(help, "usage: help") \
18388 _(q, "usage: quit") \
18389 _(quit, "usage: quit") \
18390 _(search_node_table, "usage: search_node_table <name>...") \
18391 _(set, "usage: set <variable-name> <value>") \
18392 _(script, "usage: script <file-name>") \
18393 _(unset, "usage: unset <variable-name>")
18396 static void vl_api_##n##_t_handler_uni \
18397 (vl_api_##n##_t * mp) \
18399 vat_main_t * vam = &vat_main; \
18400 if (vam->json_output) { \
18401 vl_api_##n##_t_handler_json(mp); \
18403 vl_api_##n##_t_handler(mp); \
18406 foreach_vpe_api_reply_msg;
18407 #if VPP_API_TEST_BUILTIN == 0
18408 foreach_standalone_reply_msg;
18413 vat_api_hookup (vat_main_t * vam)
18416 vl_msg_api_set_handlers(VL_API_##N, #n, \
18417 vl_api_##n##_t_handler_uni, \
18419 vl_api_##n##_t_endian, \
18420 vl_api_##n##_t_print, \
18421 sizeof(vl_api_##n##_t), 1);
18422 foreach_vpe_api_reply_msg;
18423 #if VPP_API_TEST_BUILTIN == 0
18424 foreach_standalone_reply_msg;
18428 #if (VPP_API_TEST_BUILTIN==0)
18429 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
18431 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
18433 vam->function_by_name = hash_create_string (0, sizeof (uword));
18435 vam->help_by_name = hash_create_string (0, sizeof (uword));
18438 /* API messages we can send */
18439 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18440 foreach_vpe_api_msg;
18444 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18445 foreach_vpe_api_msg;
18448 /* CLI functions */
18449 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
18450 foreach_cli_function;
18454 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18455 foreach_cli_function;
18459 #if VPP_API_TEST_BUILTIN
18460 static clib_error_t *
18461 vat_api_hookup_shim (vlib_main_t * vm)
18463 vat_api_hookup (&vat_main);
18467 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
18471 * fd.io coding-style-patch-verification: ON
18474 * eval: (c-set-style "gnu")