2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vlibapi/api.h>
22 #include <vlibmemory/api.h>
23 #include <vlibsocket/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/l2/l2_input.h>
26 #include <vnet/l2tp/l2tp.h>
27 #include <vnet/vxlan/vxlan.h>
28 #include <vnet/gre/gre.h>
29 #include <vnet/vxlan-gpe/vxlan_gpe.h>
30 #include <vnet/lisp-gpe/lisp_gpe.h>
32 #include <vpp/api/vpe_msg_enum.h>
33 #include <vnet/l2/l2_classify.h>
34 #include <vnet/l2/l2_vtr.h>
35 #include <vnet/classify/input_acl.h>
36 #include <vnet/classify/policer_classify.h>
37 #include <vnet/classify/flow_classify.h>
38 #include <vnet/mpls/mpls.h>
39 #include <vnet/ipsec/ipsec.h>
40 #include <vnet/ipsec/ikev2.h>
42 #include <vnet/map/map.h>
43 #include <vnet/cop/cop.h>
44 #include <vnet/ip/ip6_hop_by_hop.h>
45 #include <vnet/ip/ip_source_and_port_range_check.h>
46 #include <vnet/policer/xlate.h>
47 #include <vnet/span/span.h>
48 #include <vnet/policer/policer.h>
49 #include <vnet/policer/police.h>
50 #include <vnet/mfib/mfib_types.h>
52 #include "vat/json_format.h"
57 #define vl_typedefs /* define message structures */
58 #include <vpp/api/vpe_all_api_h.h>
61 /* declare message handlers for each api */
63 #define vl_endianfun /* define message structures */
64 #include <vpp/api/vpe_all_api_h.h>
67 /* instantiate all the print functions we know about */
68 #define vl_print(handle, ...)
70 #include <vpp/api/vpe_all_api_h.h>
73 #define __plugin_msg_base 0
74 #include <vlibapi/vat_helper_macros.h>
77 vat_time_now (vat_main_t * vam)
79 #if VPP_API_TEST_BUILTIN
80 return vlib_time_now (vam->vlib_main);
82 return clib_time_now (&vam->clib_time);
87 errmsg (char *fmt, ...)
89 vat_main_t *vam = &vat_main;
94 s = va_format (0, fmt, &va);
99 #if VPP_API_TEST_BUILTIN
100 vlib_cli_output (vam->vlib_main, (char *) s);
103 if (vam->ifp != stdin)
104 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
105 vam->input_line_number);
106 fformat (vam->ofp, (char *) s);
114 #if VPP_API_TEST_BUILTIN == 0
116 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
118 vat_main_t *vam = va_arg (*args, vat_main_t *);
119 u32 *result = va_arg (*args, u32 *);
123 if (!unformat (input, "%s", &if_name))
126 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
133 /* Parse an IP4 address %d.%d.%d.%d. */
135 unformat_ip4_address (unformat_input_t * input, va_list * args)
137 u8 *result = va_arg (*args, u8 *);
140 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
143 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
155 unformat_ethernet_address (unformat_input_t * input, va_list * args)
157 u8 *result = va_arg (*args, u8 *);
160 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
161 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
165 for (i = 0; i < 6; i++)
166 if (a[i] >= (1 << 8))
169 for (i = 0; i < 6; i++)
175 /* Returns ethernet type as an int in host byte order. */
177 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
180 u16 *result = va_arg (*args, u16 *);
184 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
186 if (type >= (1 << 16))
194 /* Parse an IP6 address. */
196 unformat_ip6_address (unformat_input_t * input, va_list * args)
198 ip6_address_t *result = va_arg (*args, ip6_address_t *);
200 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
201 uword c, n_colon, double_colon_index;
203 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
204 double_colon_index = ARRAY_LEN (hex_quads);
205 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
208 if (c >= '0' && c <= '9')
210 else if (c >= 'a' && c <= 'f')
211 hex_digit = c + 10 - 'a';
212 else if (c >= 'A' && c <= 'F')
213 hex_digit = c + 10 - 'A';
214 else if (c == ':' && n_colon < 2)
218 unformat_put_input (input);
222 /* Too many hex quads. */
223 if (n_hex_quads >= ARRAY_LEN (hex_quads))
228 hex_quad = (hex_quad << 4) | hex_digit;
230 /* Hex quad must fit in 16 bits. */
231 if (n_hex_digits >= 4)
238 /* Save position of :: */
241 /* More than one :: ? */
242 if (double_colon_index < ARRAY_LEN (hex_quads))
244 double_colon_index = n_hex_quads;
247 if (n_colon > 0 && n_hex_digits > 0)
249 hex_quads[n_hex_quads++] = hex_quad;
255 if (n_hex_digits > 0)
256 hex_quads[n_hex_quads++] = hex_quad;
261 /* Expand :: to appropriate number of zero hex quads. */
262 if (double_colon_index < ARRAY_LEN (hex_quads))
264 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
266 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
267 hex_quads[n_zero + i] = hex_quads[i];
269 for (i = 0; i < n_zero; i++)
270 hex_quads[double_colon_index + i] = 0;
272 n_hex_quads = ARRAY_LEN (hex_quads);
275 /* Too few hex quads given. */
276 if (n_hex_quads < ARRAY_LEN (hex_quads))
279 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
280 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
287 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
289 u32 *r = va_arg (*args, u32 *);
292 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
293 foreach_ipsec_policy_action
301 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
303 u32 *r = va_arg (*args, u32 *);
306 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
307 foreach_ipsec_crypto_alg
315 format_ipsec_crypto_alg (u8 * s, va_list * args)
317 u32 i = va_arg (*args, u32);
322 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
323 foreach_ipsec_crypto_alg
326 return format (s, "unknown");
328 return format (s, "%s", t);
332 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
334 u32 *r = va_arg (*args, u32 *);
337 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
338 foreach_ipsec_integ_alg
346 format_ipsec_integ_alg (u8 * s, va_list * args)
348 u32 i = va_arg (*args, u32);
353 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
354 foreach_ipsec_integ_alg
357 return format (s, "unknown");
359 return format (s, "%s", t);
363 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
365 u32 *r = va_arg (*args, u32 *);
368 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
369 foreach_ikev2_auth_method
377 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
379 u32 *r = va_arg (*args, u32 *);
382 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
383 foreach_ikev2_id_type
389 #else /* VPP_API_TEST_BUILTIN == 1 */
391 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
393 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
394 vnet_main_t *vnm = vnet_get_main ();
395 u32 *result = va_arg (*args, u32 *);
398 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
401 *result = sw_if_index;
404 #endif /* VPP_API_TEST_BUILTIN */
407 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
409 u8 *r = va_arg (*args, u8 *);
411 if (unformat (input, "kbps"))
412 *r = SSE2_QOS_RATE_KBPS;
413 else if (unformat (input, "pps"))
414 *r = SSE2_QOS_RATE_PPS;
421 unformat_policer_round_type (unformat_input_t * input, va_list * args)
423 u8 *r = va_arg (*args, u8 *);
425 if (unformat (input, "closest"))
426 *r = SSE2_QOS_ROUND_TO_CLOSEST;
427 else if (unformat (input, "up"))
428 *r = SSE2_QOS_ROUND_TO_UP;
429 else if (unformat (input, "down"))
430 *r = SSE2_QOS_ROUND_TO_DOWN;
437 unformat_policer_type (unformat_input_t * input, va_list * args)
439 u8 *r = va_arg (*args, u8 *);
441 if (unformat (input, "1r2c"))
442 *r = SSE2_QOS_POLICER_TYPE_1R2C;
443 else if (unformat (input, "1r3c"))
444 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
445 else if (unformat (input, "2r3c-2698"))
446 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
447 else if (unformat (input, "2r3c-4115"))
448 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
449 else if (unformat (input, "2r3c-mef5cf1"))
450 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
457 unformat_dscp (unformat_input_t * input, va_list * va)
459 u8 *r = va_arg (*va, u8 *);
462 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
471 unformat_policer_action_type (unformat_input_t * input, va_list * va)
473 sse2_qos_pol_action_params_st *a
474 = va_arg (*va, sse2_qos_pol_action_params_st *);
476 if (unformat (input, "drop"))
477 a->action_type = SSE2_QOS_ACTION_DROP;
478 else if (unformat (input, "transmit"))
479 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
480 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
481 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
488 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
490 u32 *r = va_arg (*va, u32 *);
493 if (unformat (input, "ip4"))
494 tid = POLICER_CLASSIFY_TABLE_IP4;
495 else if (unformat (input, "ip6"))
496 tid = POLICER_CLASSIFY_TABLE_IP6;
497 else if (unformat (input, "l2"))
498 tid = POLICER_CLASSIFY_TABLE_L2;
507 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
509 u32 *r = va_arg (*va, u32 *);
512 if (unformat (input, "ip4"))
513 tid = FLOW_CLASSIFY_TABLE_IP4;
514 else if (unformat (input, "ip6"))
515 tid = FLOW_CLASSIFY_TABLE_IP6;
523 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
524 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
525 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
526 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
528 #if (VPP_API_TEST_BUILTIN==0)
530 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
532 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
533 mfib_itf_attribute_t attr;
536 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
538 if (unformat (input, mfib_itf_flag_long_names[attr]))
539 *iflags |= (1 << attr);
541 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
543 if (unformat (input, mfib_itf_flag_names[attr]))
544 *iflags |= (1 << attr);
547 return (old == *iflags ? 0 : 1);
551 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
553 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
554 mfib_entry_attribute_t attr;
557 FOR_EACH_MFIB_ATTRIBUTE (attr)
559 if (unformat (input, mfib_flag_long_names[attr]))
560 *eflags |= (1 << attr);
562 FOR_EACH_MFIB_ATTRIBUTE (attr)
564 if (unformat (input, mfib_flag_names[attr]))
565 *eflags |= (1 << attr);
568 return (old == *eflags ? 0 : 1);
572 format_ip4_address (u8 * s, va_list * args)
574 u8 *a = va_arg (*args, u8 *);
575 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
579 format_ip6_address (u8 * s, va_list * args)
581 ip6_address_t *a = va_arg (*args, ip6_address_t *);
582 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
584 i_max_n_zero = ARRAY_LEN (a->as_u16);
586 i_first_zero = i_max_n_zero;
588 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
590 u32 is_zero = a->as_u16[i] == 0;
591 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
597 if ((!is_zero && n_zeros > max_n_zeros)
598 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
600 i_max_n_zero = i_first_zero;
601 max_n_zeros = n_zeros;
602 i_first_zero = ARRAY_LEN (a->as_u16);
607 last_double_colon = 0;
608 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
610 if (i == i_max_n_zero && max_n_zeros > 1)
612 s = format (s, "::");
613 i += max_n_zeros - 1;
614 last_double_colon = 1;
618 s = format (s, "%s%x",
619 (last_double_colon || i == 0) ? "" : ":",
620 clib_net_to_host_u16 (a->as_u16[i]));
621 last_double_colon = 0;
628 /* Format an IP46 address. */
630 format_ip46_address (u8 * s, va_list * args)
632 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
633 ip46_type_t type = va_arg (*args, ip46_type_t);
639 is_ip4 = ip46_address_is_ip4 (ip46);
650 format (s, "%U", format_ip4_address, &ip46->ip4) :
651 format (s, "%U", format_ip6_address, &ip46->ip6);
655 format_ethernet_address (u8 * s, va_list * args)
657 u8 *a = va_arg (*args, u8 *);
659 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
660 a[0], a[1], a[2], a[3], a[4], a[5]);
665 increment_v4_address (ip4_address_t * a)
669 v = ntohl (a->as_u32) + 1;
670 a->as_u32 = ntohl (v);
674 increment_v6_address (ip6_address_t * a)
678 v0 = clib_net_to_host_u64 (a->as_u64[0]);
679 v1 = clib_net_to_host_u64 (a->as_u64[1]);
684 a->as_u64[0] = clib_net_to_host_u64 (v0);
685 a->as_u64[1] = clib_net_to_host_u64 (v1);
689 increment_mac_address (u64 * mac)
693 tmp = clib_net_to_host_u64 (tmp);
694 tmp += 1 << 16; /* skip unused (least significant) octets */
695 tmp = clib_host_to_net_u64 (tmp);
699 static void vl_api_create_loopback_reply_t_handler
700 (vl_api_create_loopback_reply_t * mp)
702 vat_main_t *vam = &vat_main;
703 i32 retval = ntohl (mp->retval);
705 vam->retval = retval;
706 vam->regenerate_interface_table = 1;
707 vam->sw_if_index = ntohl (mp->sw_if_index);
708 vam->result_ready = 1;
711 static void vl_api_create_loopback_reply_t_handler_json
712 (vl_api_create_loopback_reply_t * mp)
714 vat_main_t *vam = &vat_main;
715 vat_json_node_t node;
717 vat_json_init_object (&node);
718 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
719 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
721 vat_json_print (vam->ofp, &node);
722 vat_json_free (&node);
723 vam->retval = ntohl (mp->retval);
724 vam->result_ready = 1;
727 static void vl_api_create_loopback_instance_reply_t_handler
728 (vl_api_create_loopback_instance_reply_t * mp)
730 vat_main_t *vam = &vat_main;
731 i32 retval = ntohl (mp->retval);
733 vam->retval = retval;
734 vam->regenerate_interface_table = 1;
735 vam->sw_if_index = ntohl (mp->sw_if_index);
736 vam->result_ready = 1;
739 static void vl_api_create_loopback_instance_reply_t_handler_json
740 (vl_api_create_loopback_instance_reply_t * mp)
742 vat_main_t *vam = &vat_main;
743 vat_json_node_t node;
745 vat_json_init_object (&node);
746 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
747 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
749 vat_json_print (vam->ofp, &node);
750 vat_json_free (&node);
751 vam->retval = ntohl (mp->retval);
752 vam->result_ready = 1;
755 static void vl_api_af_packet_create_reply_t_handler
756 (vl_api_af_packet_create_reply_t * mp)
758 vat_main_t *vam = &vat_main;
759 i32 retval = ntohl (mp->retval);
761 vam->retval = retval;
762 vam->regenerate_interface_table = 1;
763 vam->sw_if_index = ntohl (mp->sw_if_index);
764 vam->result_ready = 1;
767 static void vl_api_af_packet_create_reply_t_handler_json
768 (vl_api_af_packet_create_reply_t * mp)
770 vat_main_t *vam = &vat_main;
771 vat_json_node_t node;
773 vat_json_init_object (&node);
774 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
775 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
777 vat_json_print (vam->ofp, &node);
778 vat_json_free (&node);
780 vam->retval = ntohl (mp->retval);
781 vam->result_ready = 1;
784 static void vl_api_create_vlan_subif_reply_t_handler
785 (vl_api_create_vlan_subif_reply_t * mp)
787 vat_main_t *vam = &vat_main;
788 i32 retval = ntohl (mp->retval);
790 vam->retval = retval;
791 vam->regenerate_interface_table = 1;
792 vam->sw_if_index = ntohl (mp->sw_if_index);
793 vam->result_ready = 1;
796 static void vl_api_create_vlan_subif_reply_t_handler_json
797 (vl_api_create_vlan_subif_reply_t * mp)
799 vat_main_t *vam = &vat_main;
800 vat_json_node_t node;
802 vat_json_init_object (&node);
803 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
804 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
806 vat_json_print (vam->ofp, &node);
807 vat_json_free (&node);
809 vam->retval = ntohl (mp->retval);
810 vam->result_ready = 1;
813 static void vl_api_create_subif_reply_t_handler
814 (vl_api_create_subif_reply_t * mp)
816 vat_main_t *vam = &vat_main;
817 i32 retval = ntohl (mp->retval);
819 vam->retval = retval;
820 vam->regenerate_interface_table = 1;
821 vam->sw_if_index = ntohl (mp->sw_if_index);
822 vam->result_ready = 1;
825 static void vl_api_create_subif_reply_t_handler_json
826 (vl_api_create_subif_reply_t * mp)
828 vat_main_t *vam = &vat_main;
829 vat_json_node_t node;
831 vat_json_init_object (&node);
832 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
833 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
835 vat_json_print (vam->ofp, &node);
836 vat_json_free (&node);
838 vam->retval = ntohl (mp->retval);
839 vam->result_ready = 1;
842 static void vl_api_interface_name_renumber_reply_t_handler
843 (vl_api_interface_name_renumber_reply_t * mp)
845 vat_main_t *vam = &vat_main;
846 i32 retval = ntohl (mp->retval);
848 vam->retval = retval;
849 vam->regenerate_interface_table = 1;
850 vam->result_ready = 1;
853 static void vl_api_interface_name_renumber_reply_t_handler_json
854 (vl_api_interface_name_renumber_reply_t * mp)
856 vat_main_t *vam = &vat_main;
857 vat_json_node_t node;
859 vat_json_init_object (&node);
860 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
862 vat_json_print (vam->ofp, &node);
863 vat_json_free (&node);
865 vam->retval = ntohl (mp->retval);
866 vam->result_ready = 1;
870 * Special-case: build the interface table, maintain
871 * the next loopback sw_if_index vbl.
873 static void vl_api_sw_interface_details_t_handler
874 (vl_api_sw_interface_details_t * mp)
876 vat_main_t *vam = &vat_main;
877 u8 *s = format (0, "%s%c", mp->interface_name, 0);
879 hash_set_mem (vam->sw_if_index_by_interface_name, s,
880 ntohl (mp->sw_if_index));
882 /* In sub interface case, fill the sub interface table entry */
883 if (mp->sw_if_index != mp->sup_sw_if_index)
885 sw_interface_subif_t *sub = NULL;
887 vec_add2 (vam->sw_if_subif_table, sub, 1);
889 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
890 strncpy ((char *) sub->interface_name, (char *) s,
891 vec_len (sub->interface_name));
892 sub->sw_if_index = ntohl (mp->sw_if_index);
893 sub->sub_id = ntohl (mp->sub_id);
895 sub->sub_dot1ad = mp->sub_dot1ad;
896 sub->sub_number_of_tags = mp->sub_number_of_tags;
897 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
898 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
899 sub->sub_exact_match = mp->sub_exact_match;
900 sub->sub_default = mp->sub_default;
901 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
902 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
904 /* vlan tag rewrite */
905 sub->vtr_op = ntohl (mp->vtr_op);
906 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
907 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
908 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
912 static void vl_api_sw_interface_details_t_handler_json
913 (vl_api_sw_interface_details_t * mp)
915 vat_main_t *vam = &vat_main;
916 vat_json_node_t *node = NULL;
918 if (VAT_JSON_ARRAY != vam->json_tree.type)
920 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
921 vat_json_init_array (&vam->json_tree);
923 node = vat_json_array_add (&vam->json_tree);
925 vat_json_init_object (node);
926 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
927 vat_json_object_add_uint (node, "sup_sw_if_index",
928 ntohl (mp->sup_sw_if_index));
929 vat_json_object_add_uint (node, "l2_address_length",
930 ntohl (mp->l2_address_length));
931 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
932 sizeof (mp->l2_address));
933 vat_json_object_add_string_copy (node, "interface_name",
935 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
936 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
937 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
938 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
939 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
940 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
941 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
942 vat_json_object_add_uint (node, "sub_number_of_tags",
943 mp->sub_number_of_tags);
944 vat_json_object_add_uint (node, "sub_outer_vlan_id",
945 ntohs (mp->sub_outer_vlan_id));
946 vat_json_object_add_uint (node, "sub_inner_vlan_id",
947 ntohs (mp->sub_inner_vlan_id));
948 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
949 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
950 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
951 mp->sub_outer_vlan_id_any);
952 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
953 mp->sub_inner_vlan_id_any);
954 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
955 vat_json_object_add_uint (node, "vtr_push_dot1q",
956 ntohl (mp->vtr_push_dot1q));
957 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
958 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
961 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
963 format_ethernet_address,
965 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
967 format_ethernet_address,
969 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
970 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
974 #if VPP_API_TEST_BUILTIN == 0
975 static void vl_api_sw_interface_set_flags_t_handler
976 (vl_api_sw_interface_set_flags_t * mp)
978 vat_main_t *vam = &vat_main;
979 if (vam->interface_event_display)
980 errmsg ("interface flags: sw_if_index %d %s %s",
981 ntohl (mp->sw_if_index),
982 mp->admin_up_down ? "admin-up" : "admin-down",
983 mp->link_up_down ? "link-up" : "link-down");
987 static void vl_api_sw_interface_set_flags_t_handler_json
988 (vl_api_sw_interface_set_flags_t * mp)
990 /* JSON output not supported */
994 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
996 vat_main_t *vam = &vat_main;
997 i32 retval = ntohl (mp->retval);
999 vam->retval = retval;
1000 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1001 vam->result_ready = 1;
1005 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1007 vat_main_t *vam = &vat_main;
1008 vat_json_node_t node;
1009 api_main_t *am = &api_main;
1013 vat_json_init_object (&node);
1014 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1015 vat_json_object_add_uint (&node, "reply_in_shmem",
1016 ntohl (mp->reply_in_shmem));
1017 /* Toss the shared-memory original... */
1018 pthread_mutex_lock (&am->vlib_rp->mutex);
1019 oldheap = svm_push_data_heap (am->vlib_rp);
1021 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1024 svm_pop_heap (oldheap);
1025 pthread_mutex_unlock (&am->vlib_rp->mutex);
1027 vat_json_print (vam->ofp, &node);
1028 vat_json_free (&node);
1030 vam->retval = ntohl (mp->retval);
1031 vam->result_ready = 1;
1035 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1037 vat_main_t *vam = &vat_main;
1038 i32 retval = ntohl (mp->retval);
1040 vam->retval = retval;
1041 vam->cmd_reply = mp->reply;
1042 vam->result_ready = 1;
1046 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1048 vat_main_t *vam = &vat_main;
1049 vat_json_node_t node;
1051 vat_json_init_object (&node);
1052 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1053 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1055 vat_json_print (vam->ofp, &node);
1056 vat_json_free (&node);
1058 vam->retval = ntohl (mp->retval);
1059 vam->result_ready = 1;
1062 static void vl_api_classify_add_del_table_reply_t_handler
1063 (vl_api_classify_add_del_table_reply_t * mp)
1065 vat_main_t *vam = &vat_main;
1066 i32 retval = ntohl (mp->retval);
1067 if (vam->async_mode)
1069 vam->async_errors += (retval < 0);
1073 vam->retval = retval;
1075 ((mp->new_table_index != 0xFFFFFFFF) ||
1076 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1077 (mp->match_n_vectors != 0xFFFFFFFF)))
1079 * Note: this is just barely thread-safe, depends on
1080 * the main thread spinning waiting for an answer...
1082 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1083 ntohl (mp->new_table_index),
1084 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1085 vam->result_ready = 1;
1089 static void vl_api_classify_add_del_table_reply_t_handler_json
1090 (vl_api_classify_add_del_table_reply_t * mp)
1092 vat_main_t *vam = &vat_main;
1093 vat_json_node_t node;
1095 vat_json_init_object (&node);
1096 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1097 vat_json_object_add_uint (&node, "new_table_index",
1098 ntohl (mp->new_table_index));
1099 vat_json_object_add_uint (&node, "skip_n_vectors",
1100 ntohl (mp->skip_n_vectors));
1101 vat_json_object_add_uint (&node, "match_n_vectors",
1102 ntohl (mp->match_n_vectors));
1104 vat_json_print (vam->ofp, &node);
1105 vat_json_free (&node);
1107 vam->retval = ntohl (mp->retval);
1108 vam->result_ready = 1;
1111 static void vl_api_get_node_index_reply_t_handler
1112 (vl_api_get_node_index_reply_t * mp)
1114 vat_main_t *vam = &vat_main;
1115 i32 retval = ntohl (mp->retval);
1116 if (vam->async_mode)
1118 vam->async_errors += (retval < 0);
1122 vam->retval = retval;
1124 errmsg ("node index %d", ntohl (mp->node_index));
1125 vam->result_ready = 1;
1129 static void vl_api_get_node_index_reply_t_handler_json
1130 (vl_api_get_node_index_reply_t * mp)
1132 vat_main_t *vam = &vat_main;
1133 vat_json_node_t node;
1135 vat_json_init_object (&node);
1136 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1137 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1139 vat_json_print (vam->ofp, &node);
1140 vat_json_free (&node);
1142 vam->retval = ntohl (mp->retval);
1143 vam->result_ready = 1;
1146 static void vl_api_get_next_index_reply_t_handler
1147 (vl_api_get_next_index_reply_t * mp)
1149 vat_main_t *vam = &vat_main;
1150 i32 retval = ntohl (mp->retval);
1151 if (vam->async_mode)
1153 vam->async_errors += (retval < 0);
1157 vam->retval = retval;
1159 errmsg ("next node index %d", ntohl (mp->next_index));
1160 vam->result_ready = 1;
1164 static void vl_api_get_next_index_reply_t_handler_json
1165 (vl_api_get_next_index_reply_t * mp)
1167 vat_main_t *vam = &vat_main;
1168 vat_json_node_t node;
1170 vat_json_init_object (&node);
1171 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1172 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1174 vat_json_print (vam->ofp, &node);
1175 vat_json_free (&node);
1177 vam->retval = ntohl (mp->retval);
1178 vam->result_ready = 1;
1181 static void vl_api_add_node_next_reply_t_handler
1182 (vl_api_add_node_next_reply_t * mp)
1184 vat_main_t *vam = &vat_main;
1185 i32 retval = ntohl (mp->retval);
1186 if (vam->async_mode)
1188 vam->async_errors += (retval < 0);
1192 vam->retval = retval;
1194 errmsg ("next index %d", ntohl (mp->next_index));
1195 vam->result_ready = 1;
1199 static void vl_api_add_node_next_reply_t_handler_json
1200 (vl_api_add_node_next_reply_t * mp)
1202 vat_main_t *vam = &vat_main;
1203 vat_json_node_t node;
1205 vat_json_init_object (&node);
1206 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1207 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1209 vat_json_print (vam->ofp, &node);
1210 vat_json_free (&node);
1212 vam->retval = ntohl (mp->retval);
1213 vam->result_ready = 1;
1216 static void vl_api_show_version_reply_t_handler
1217 (vl_api_show_version_reply_t * mp)
1219 vat_main_t *vam = &vat_main;
1220 i32 retval = ntohl (mp->retval);
1224 errmsg (" program: %s", mp->program);
1225 errmsg (" version: %s", mp->version);
1226 errmsg (" build date: %s", mp->build_date);
1227 errmsg ("build directory: %s", mp->build_directory);
1229 vam->retval = retval;
1230 vam->result_ready = 1;
1233 static void vl_api_show_version_reply_t_handler_json
1234 (vl_api_show_version_reply_t * mp)
1236 vat_main_t *vam = &vat_main;
1237 vat_json_node_t node;
1239 vat_json_init_object (&node);
1240 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1241 vat_json_object_add_string_copy (&node, "program", mp->program);
1242 vat_json_object_add_string_copy (&node, "version", mp->version);
1243 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1244 vat_json_object_add_string_copy (&node, "build_directory",
1245 mp->build_directory);
1247 vat_json_print (vam->ofp, &node);
1248 vat_json_free (&node);
1250 vam->retval = ntohl (mp->retval);
1251 vam->result_ready = 1;
1255 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1257 u32 sw_if_index = ntohl (mp->sw_if_index);
1258 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1259 mp->mac_ip ? "mac/ip binding" : "address resolution",
1260 ntohl (mp->pid), format_ip4_address, &mp->address,
1261 format_ethernet_address, mp->new_mac, sw_if_index);
1265 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1267 /* JSON output not supported */
1271 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1273 u32 sw_if_index = ntohl (mp->sw_if_index);
1274 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1275 mp->mac_ip ? "mac/ip binding" : "address resolution",
1276 ntohl (mp->pid), format_ip6_address, mp->address,
1277 format_ethernet_address, mp->new_mac, sw_if_index);
1281 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1283 /* JSON output not supported */
1286 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1287 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1290 * Special-case: build the bridge domain table, maintain
1291 * the next bd id vbl.
1293 static void vl_api_bridge_domain_details_t_handler
1294 (vl_api_bridge_domain_details_t * mp)
1296 vat_main_t *vam = &vat_main;
1297 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1300 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1301 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1303 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1304 ntohl (mp->bd_id), mp->learn, mp->forward,
1305 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1309 vl_api_bridge_domain_sw_if_t *sw_ifs;
1310 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1313 sw_ifs = mp->sw_if_details;
1314 for (i = 0; i < n_sw_ifs; i++)
1320 sw_if_index = ntohl (sw_ifs->sw_if_index);
1323 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1325 if ((u32) p->value[0] == sw_if_index)
1327 sw_if_name = (u8 *)(p->key);
1332 print (vam->ofp, "%7d %3d %s", sw_if_index,
1333 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1334 "sw_if_index not found!");
1341 static void vl_api_bridge_domain_details_t_handler_json
1342 (vl_api_bridge_domain_details_t * mp)
1344 vat_main_t *vam = &vat_main;
1345 vat_json_node_t *node, *array = NULL;
1346 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1348 if (VAT_JSON_ARRAY != vam->json_tree.type)
1350 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1351 vat_json_init_array (&vam->json_tree);
1353 node = vat_json_array_add (&vam->json_tree);
1355 vat_json_init_object (node);
1356 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1357 vat_json_object_add_uint (node, "flood", mp->flood);
1358 vat_json_object_add_uint (node, "forward", mp->forward);
1359 vat_json_object_add_uint (node, "learn", mp->learn);
1360 vat_json_object_add_uint (node, "bvi_sw_if_index",
1361 ntohl (mp->bvi_sw_if_index));
1362 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1363 array = vat_json_object_add (node, "sw_if");
1364 vat_json_init_array (array);
1370 vl_api_bridge_domain_sw_if_t *sw_ifs;
1373 sw_ifs = mp->sw_if_details;
1374 for (i = 0; i < n_sw_ifs; i++)
1376 node = vat_json_array_add (array);
1377 vat_json_init_object (node);
1378 vat_json_object_add_uint (node, "sw_if_index",
1379 ntohl (sw_ifs->sw_if_index));
1380 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1386 static void vl_api_control_ping_reply_t_handler
1387 (vl_api_control_ping_reply_t * mp)
1389 vat_main_t *vam = &vat_main;
1390 i32 retval = ntohl (mp->retval);
1391 if (vam->async_mode)
1393 vam->async_errors += (retval < 0);
1397 vam->retval = retval;
1398 vam->result_ready = 1;
1402 static void vl_api_control_ping_reply_t_handler_json
1403 (vl_api_control_ping_reply_t * mp)
1405 vat_main_t *vam = &vat_main;
1406 i32 retval = ntohl (mp->retval);
1408 if (VAT_JSON_NONE != vam->json_tree.type)
1410 vat_json_print (vam->ofp, &vam->json_tree);
1411 vat_json_free (&vam->json_tree);
1412 vam->json_tree.type = VAT_JSON_NONE;
1417 vat_json_init_array (&vam->json_tree);
1418 vat_json_print (vam->ofp, &vam->json_tree);
1419 vam->json_tree.type = VAT_JSON_NONE;
1422 vam->retval = retval;
1423 vam->result_ready = 1;
1427 vl_api_bridge_domain_set_mac_age_reply_t_handler
1428 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1430 vat_main_t *vam = &vat_main;
1431 i32 retval = ntohl (mp->retval);
1432 if (vam->async_mode)
1434 vam->async_errors += (retval < 0);
1438 vam->retval = retval;
1439 vam->result_ready = 1;
1443 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1444 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1446 vat_main_t *vam = &vat_main;
1447 vat_json_node_t node;
1449 vat_json_init_object (&node);
1450 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1452 vat_json_print (vam->ofp, &node);
1453 vat_json_free (&node);
1455 vam->retval = ntohl (mp->retval);
1456 vam->result_ready = 1;
1460 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1462 vat_main_t *vam = &vat_main;
1463 i32 retval = ntohl (mp->retval);
1464 if (vam->async_mode)
1466 vam->async_errors += (retval < 0);
1470 vam->retval = retval;
1471 vam->result_ready = 1;
1475 static void vl_api_l2_flags_reply_t_handler_json
1476 (vl_api_l2_flags_reply_t * mp)
1478 vat_main_t *vam = &vat_main;
1479 vat_json_node_t node;
1481 vat_json_init_object (&node);
1482 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1483 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1484 ntohl (mp->resulting_feature_bitmap));
1486 vat_json_print (vam->ofp, &node);
1487 vat_json_free (&node);
1489 vam->retval = ntohl (mp->retval);
1490 vam->result_ready = 1;
1493 static void vl_api_bridge_flags_reply_t_handler
1494 (vl_api_bridge_flags_reply_t * mp)
1496 vat_main_t *vam = &vat_main;
1497 i32 retval = ntohl (mp->retval);
1498 if (vam->async_mode)
1500 vam->async_errors += (retval < 0);
1504 vam->retval = retval;
1505 vam->result_ready = 1;
1509 static void vl_api_bridge_flags_reply_t_handler_json
1510 (vl_api_bridge_flags_reply_t * mp)
1512 vat_main_t *vam = &vat_main;
1513 vat_json_node_t node;
1515 vat_json_init_object (&node);
1516 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1517 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1518 ntohl (mp->resulting_feature_bitmap));
1520 vat_json_print (vam->ofp, &node);
1521 vat_json_free (&node);
1523 vam->retval = ntohl (mp->retval);
1524 vam->result_ready = 1;
1527 static void vl_api_tap_connect_reply_t_handler
1528 (vl_api_tap_connect_reply_t * mp)
1530 vat_main_t *vam = &vat_main;
1531 i32 retval = ntohl (mp->retval);
1532 if (vam->async_mode)
1534 vam->async_errors += (retval < 0);
1538 vam->retval = retval;
1539 vam->sw_if_index = ntohl (mp->sw_if_index);
1540 vam->result_ready = 1;
1545 static void vl_api_tap_connect_reply_t_handler_json
1546 (vl_api_tap_connect_reply_t * mp)
1548 vat_main_t *vam = &vat_main;
1549 vat_json_node_t node;
1551 vat_json_init_object (&node);
1552 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1553 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1555 vat_json_print (vam->ofp, &node);
1556 vat_json_free (&node);
1558 vam->retval = ntohl (mp->retval);
1559 vam->result_ready = 1;
1564 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1566 vat_main_t *vam = &vat_main;
1567 i32 retval = ntohl (mp->retval);
1568 if (vam->async_mode)
1570 vam->async_errors += (retval < 0);
1574 vam->retval = retval;
1575 vam->sw_if_index = ntohl (mp->sw_if_index);
1576 vam->result_ready = 1;
1580 static void vl_api_tap_modify_reply_t_handler_json
1581 (vl_api_tap_modify_reply_t * mp)
1583 vat_main_t *vam = &vat_main;
1584 vat_json_node_t node;
1586 vat_json_init_object (&node);
1587 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1588 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1590 vat_json_print (vam->ofp, &node);
1591 vat_json_free (&node);
1593 vam->retval = ntohl (mp->retval);
1594 vam->result_ready = 1;
1598 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1600 vat_main_t *vam = &vat_main;
1601 i32 retval = ntohl (mp->retval);
1602 if (vam->async_mode)
1604 vam->async_errors += (retval < 0);
1608 vam->retval = retval;
1609 vam->result_ready = 1;
1613 static void vl_api_tap_delete_reply_t_handler_json
1614 (vl_api_tap_delete_reply_t * mp)
1616 vat_main_t *vam = &vat_main;
1617 vat_json_node_t node;
1619 vat_json_init_object (&node);
1620 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1622 vat_json_print (vam->ofp, &node);
1623 vat_json_free (&node);
1625 vam->retval = ntohl (mp->retval);
1626 vam->result_ready = 1;
1629 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1630 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1632 vat_main_t *vam = &vat_main;
1633 i32 retval = ntohl (mp->retval);
1634 if (vam->async_mode)
1636 vam->async_errors += (retval < 0);
1640 vam->retval = retval;
1641 vam->result_ready = 1;
1645 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1646 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1648 vat_main_t *vam = &vat_main;
1649 vat_json_node_t node;
1651 vat_json_init_object (&node);
1652 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1653 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1654 ntohl (mp->sw_if_index));
1656 vat_json_print (vam->ofp, &node);
1657 vat_json_free (&node);
1659 vam->retval = ntohl (mp->retval);
1660 vam->result_ready = 1;
1663 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1664 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1666 vat_main_t *vam = &vat_main;
1667 i32 retval = ntohl (mp->retval);
1668 if (vam->async_mode)
1670 vam->async_errors += (retval < 0);
1674 vam->retval = retval;
1675 vam->sw_if_index = ntohl (mp->sw_if_index);
1676 vam->result_ready = 1;
1680 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1681 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1683 vat_main_t *vam = &vat_main;
1684 vat_json_node_t node;
1686 vat_json_init_object (&node);
1687 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1688 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1690 vat_json_print (vam->ofp, &node);
1691 vat_json_free (&node);
1693 vam->retval = ntohl (mp->retval);
1694 vam->result_ready = 1;
1698 static void vl_api_one_add_del_locator_set_reply_t_handler
1699 (vl_api_one_add_del_locator_set_reply_t * mp)
1701 vat_main_t *vam = &vat_main;
1702 i32 retval = ntohl (mp->retval);
1703 if (vam->async_mode)
1705 vam->async_errors += (retval < 0);
1709 vam->retval = retval;
1710 vam->result_ready = 1;
1714 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1715 (vl_api_one_add_del_locator_set_reply_t * mp)
1717 vat_main_t *vam = &vat_main;
1718 vat_json_node_t node;
1720 vat_json_init_object (&node);
1721 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1722 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1724 vat_json_print (vam->ofp, &node);
1725 vat_json_free (&node);
1727 vam->retval = ntohl (mp->retval);
1728 vam->result_ready = 1;
1731 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1732 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1734 vat_main_t *vam = &vat_main;
1735 i32 retval = ntohl (mp->retval);
1736 if (vam->async_mode)
1738 vam->async_errors += (retval < 0);
1742 vam->retval = retval;
1743 vam->sw_if_index = ntohl (mp->sw_if_index);
1744 vam->result_ready = 1;
1748 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1749 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1751 vat_main_t *vam = &vat_main;
1752 vat_json_node_t node;
1754 vat_json_init_object (&node);
1755 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1756 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1758 vat_json_print (vam->ofp, &node);
1759 vat_json_free (&node);
1761 vam->retval = ntohl (mp->retval);
1762 vam->result_ready = 1;
1765 static void vl_api_gre_add_del_tunnel_reply_t_handler
1766 (vl_api_gre_add_del_tunnel_reply_t * mp)
1768 vat_main_t *vam = &vat_main;
1769 i32 retval = ntohl (mp->retval);
1770 if (vam->async_mode)
1772 vam->async_errors += (retval < 0);
1776 vam->retval = retval;
1777 vam->sw_if_index = ntohl (mp->sw_if_index);
1778 vam->result_ready = 1;
1782 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1783 (vl_api_gre_add_del_tunnel_reply_t * mp)
1785 vat_main_t *vam = &vat_main;
1786 vat_json_node_t node;
1788 vat_json_init_object (&node);
1789 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1790 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1792 vat_json_print (vam->ofp, &node);
1793 vat_json_free (&node);
1795 vam->retval = ntohl (mp->retval);
1796 vam->result_ready = 1;
1799 static void vl_api_create_vhost_user_if_reply_t_handler
1800 (vl_api_create_vhost_user_if_reply_t * mp)
1802 vat_main_t *vam = &vat_main;
1803 i32 retval = ntohl (mp->retval);
1804 if (vam->async_mode)
1806 vam->async_errors += (retval < 0);
1810 vam->retval = retval;
1811 vam->sw_if_index = ntohl (mp->sw_if_index);
1812 vam->result_ready = 1;
1816 static void vl_api_create_vhost_user_if_reply_t_handler_json
1817 (vl_api_create_vhost_user_if_reply_t * mp)
1819 vat_main_t *vam = &vat_main;
1820 vat_json_node_t node;
1822 vat_json_init_object (&node);
1823 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1824 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1826 vat_json_print (vam->ofp, &node);
1827 vat_json_free (&node);
1829 vam->retval = ntohl (mp->retval);
1830 vam->result_ready = 1;
1833 static void vl_api_ip_address_details_t_handler
1834 (vl_api_ip_address_details_t * mp)
1836 vat_main_t *vam = &vat_main;
1837 static ip_address_details_t empty_ip_address_details = { {0} };
1838 ip_address_details_t *address = NULL;
1839 ip_details_t *current_ip_details = NULL;
1840 ip_details_t *details = NULL;
1842 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1844 if (!details || vam->current_sw_if_index >= vec_len (details)
1845 || !details[vam->current_sw_if_index].present)
1847 errmsg ("ip address details arrived but not stored");
1848 errmsg ("ip_dump should be called first");
1852 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1854 #define addresses (current_ip_details->addr)
1856 vec_validate_init_empty (addresses, vec_len (addresses),
1857 empty_ip_address_details);
1859 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1861 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1862 address->prefix_length = mp->prefix_length;
1866 static void vl_api_ip_address_details_t_handler_json
1867 (vl_api_ip_address_details_t * mp)
1869 vat_main_t *vam = &vat_main;
1870 vat_json_node_t *node = NULL;
1871 struct in6_addr ip6;
1874 if (VAT_JSON_ARRAY != vam->json_tree.type)
1876 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1877 vat_json_init_array (&vam->json_tree);
1879 node = vat_json_array_add (&vam->json_tree);
1881 vat_json_init_object (node);
1884 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1885 vat_json_object_add_ip6 (node, "ip", ip6);
1889 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1890 vat_json_object_add_ip4 (node, "ip", ip4);
1892 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1896 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1898 vat_main_t *vam = &vat_main;
1899 static ip_details_t empty_ip_details = { 0 };
1900 ip_details_t *ip = NULL;
1901 u32 sw_if_index = ~0;
1903 sw_if_index = ntohl (mp->sw_if_index);
1905 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1906 sw_if_index, empty_ip_details);
1908 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1915 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1917 vat_main_t *vam = &vat_main;
1919 if (VAT_JSON_ARRAY != vam->json_tree.type)
1921 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1922 vat_json_init_array (&vam->json_tree);
1924 vat_json_array_add_uint (&vam->json_tree,
1925 clib_net_to_host_u32 (mp->sw_if_index));
1928 static void vl_api_map_domain_details_t_handler_json
1929 (vl_api_map_domain_details_t * mp)
1931 vat_json_node_t *node = NULL;
1932 vat_main_t *vam = &vat_main;
1933 struct in6_addr ip6;
1936 if (VAT_JSON_ARRAY != vam->json_tree.type)
1938 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1939 vat_json_init_array (&vam->json_tree);
1942 node = vat_json_array_add (&vam->json_tree);
1943 vat_json_init_object (node);
1945 vat_json_object_add_uint (node, "domain_index",
1946 clib_net_to_host_u32 (mp->domain_index));
1947 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1948 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1949 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1950 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1951 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1952 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1953 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1954 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1955 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1956 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1957 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1958 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1959 vat_json_object_add_uint (node, "flags", mp->flags);
1960 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1961 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1964 static void vl_api_map_domain_details_t_handler
1965 (vl_api_map_domain_details_t * mp)
1967 vat_main_t *vam = &vat_main;
1969 if (mp->is_translation)
1972 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
1973 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1974 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1975 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1976 clib_net_to_host_u32 (mp->domain_index));
1981 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
1982 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1983 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1984 format_ip6_address, mp->ip6_src,
1985 clib_net_to_host_u32 (mp->domain_index));
1987 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
1988 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1989 mp->is_translation ? "map-t" : "");
1992 static void vl_api_map_rule_details_t_handler_json
1993 (vl_api_map_rule_details_t * mp)
1995 struct in6_addr ip6;
1996 vat_json_node_t *node = NULL;
1997 vat_main_t *vam = &vat_main;
1999 if (VAT_JSON_ARRAY != vam->json_tree.type)
2001 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2002 vat_json_init_array (&vam->json_tree);
2005 node = vat_json_array_add (&vam->json_tree);
2006 vat_json_init_object (node);
2008 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2009 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2010 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2014 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2016 vat_main_t *vam = &vat_main;
2017 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2018 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2022 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2024 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2025 "router_addr %U host_mac %U",
2026 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2027 format_ip4_address, &mp->host_address,
2028 format_ip4_address, &mp->router_address,
2029 format_ethernet_address, mp->host_mac);
2032 static void vl_api_dhcp_compl_event_t_handler_json
2033 (vl_api_dhcp_compl_event_t * mp)
2035 /* JSON output not supported */
2039 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2042 vat_main_t *vam = &vat_main;
2043 static u64 default_counter = 0;
2045 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2047 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2048 sw_if_index, default_counter);
2049 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2053 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2054 interface_counter_t counter)
2056 vat_main_t *vam = &vat_main;
2057 static interface_counter_t default_counter = { 0, };
2059 vec_validate_init_empty (vam->combined_interface_counters,
2060 vnet_counter_type, NULL);
2061 vec_validate_init_empty (vam->combined_interface_counters
2062 [vnet_counter_type], sw_if_index, default_counter);
2063 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2066 static void vl_api_vnet_interface_simple_counters_t_handler
2067 (vl_api_vnet_interface_simple_counters_t * mp)
2072 static void vl_api_vnet_interface_combined_counters_t_handler
2073 (vl_api_vnet_interface_combined_counters_t * mp)
2078 static void vl_api_vnet_interface_simple_counters_t_handler_json
2079 (vl_api_vnet_interface_simple_counters_t * mp)
2084 u32 first_sw_if_index;
2087 count = ntohl (mp->count);
2088 first_sw_if_index = ntohl (mp->first_sw_if_index);
2090 v_packets = (u64 *) & mp->data;
2091 for (i = 0; i < count; i++)
2093 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2094 set_simple_interface_counter (mp->vnet_counter_type,
2095 first_sw_if_index + i, packets);
2100 static void vl_api_vnet_interface_combined_counters_t_handler_json
2101 (vl_api_vnet_interface_combined_counters_t * mp)
2103 interface_counter_t counter;
2105 u32 first_sw_if_index;
2109 count = ntohl (mp->count);
2110 first_sw_if_index = ntohl (mp->first_sw_if_index);
2112 v = (vlib_counter_t *) & mp->data;
2113 for (i = 0; i < count; i++)
2116 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2118 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2119 set_combined_interface_counter (mp->vnet_counter_type,
2120 first_sw_if_index + i, counter);
2126 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2128 vat_main_t *vam = &vat_main;
2131 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2133 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2142 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2144 vat_main_t *vam = &vat_main;
2147 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2149 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2157 static void vl_api_vnet_ip4_fib_counters_t_handler
2158 (vl_api_vnet_ip4_fib_counters_t * mp)
2163 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2164 (vl_api_vnet_ip4_fib_counters_t * mp)
2166 vat_main_t *vam = &vat_main;
2167 vl_api_ip4_fib_counter_t *v;
2168 ip4_fib_counter_t *counter;
2175 vrf_id = ntohl (mp->vrf_id);
2176 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2177 if (~0 == vrf_index)
2179 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2180 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2181 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2182 vec_validate (vam->ip4_fib_counters, vrf_index);
2183 vam->ip4_fib_counters[vrf_index] = NULL;
2186 vec_free (vam->ip4_fib_counters[vrf_index]);
2187 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2188 count = ntohl (mp->count);
2189 for (i = 0; i < count; i++)
2191 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2192 counter = &vam->ip4_fib_counters[vrf_index][i];
2193 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2194 counter->address = ip4;
2195 counter->address_length = v->address_length;
2196 counter->packets = clib_net_to_host_u64 (v->packets);
2197 counter->bytes = clib_net_to_host_u64 (v->bytes);
2202 static void vl_api_vnet_ip4_nbr_counters_t_handler
2203 (vl_api_vnet_ip4_nbr_counters_t * mp)
2208 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2209 (vl_api_vnet_ip4_nbr_counters_t * mp)
2211 vat_main_t *vam = &vat_main;
2212 vl_api_ip4_nbr_counter_t *v;
2213 ip4_nbr_counter_t *counter;
2218 sw_if_index = ntohl (mp->sw_if_index);
2219 count = ntohl (mp->count);
2220 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2223 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2225 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2226 for (i = 0; i < count; i++)
2228 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2229 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2230 counter->address.s_addr = v->address;
2231 counter->packets = clib_net_to_host_u64 (v->packets);
2232 counter->bytes = clib_net_to_host_u64 (v->bytes);
2233 counter->linkt = v->link_type;
2238 static void vl_api_vnet_ip6_fib_counters_t_handler
2239 (vl_api_vnet_ip6_fib_counters_t * mp)
2244 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2245 (vl_api_vnet_ip6_fib_counters_t * mp)
2247 vat_main_t *vam = &vat_main;
2248 vl_api_ip6_fib_counter_t *v;
2249 ip6_fib_counter_t *counter;
2250 struct in6_addr ip6;
2256 vrf_id = ntohl (mp->vrf_id);
2257 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2258 if (~0 == vrf_index)
2260 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2261 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2262 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2263 vec_validate (vam->ip6_fib_counters, vrf_index);
2264 vam->ip6_fib_counters[vrf_index] = NULL;
2267 vec_free (vam->ip6_fib_counters[vrf_index]);
2268 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2269 count = ntohl (mp->count);
2270 for (i = 0; i < count; i++)
2272 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2273 counter = &vam->ip6_fib_counters[vrf_index][i];
2274 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2275 counter->address = ip6;
2276 counter->address_length = v->address_length;
2277 counter->packets = clib_net_to_host_u64 (v->packets);
2278 counter->bytes = clib_net_to_host_u64 (v->bytes);
2283 static void vl_api_vnet_ip6_nbr_counters_t_handler
2284 (vl_api_vnet_ip6_nbr_counters_t * mp)
2289 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2290 (vl_api_vnet_ip6_nbr_counters_t * mp)
2292 vat_main_t *vam = &vat_main;
2293 vl_api_ip6_nbr_counter_t *v;
2294 ip6_nbr_counter_t *counter;
2295 struct in6_addr ip6;
2300 sw_if_index = ntohl (mp->sw_if_index);
2301 count = ntohl (mp->count);
2302 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2305 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2307 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2308 for (i = 0; i < count; i++)
2310 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2311 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2312 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2313 counter->address = ip6;
2314 counter->packets = clib_net_to_host_u64 (v->packets);
2315 counter->bytes = clib_net_to_host_u64 (v->bytes);
2320 static void vl_api_get_first_msg_id_reply_t_handler
2321 (vl_api_get_first_msg_id_reply_t * mp)
2323 vat_main_t *vam = &vat_main;
2324 i32 retval = ntohl (mp->retval);
2326 if (vam->async_mode)
2328 vam->async_errors += (retval < 0);
2332 vam->retval = retval;
2333 vam->result_ready = 1;
2337 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2341 static void vl_api_get_first_msg_id_reply_t_handler_json
2342 (vl_api_get_first_msg_id_reply_t * mp)
2344 vat_main_t *vam = &vat_main;
2345 vat_json_node_t node;
2347 vat_json_init_object (&node);
2348 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2349 vat_json_object_add_uint (&node, "first_msg_id",
2350 (uint) ntohs (mp->first_msg_id));
2352 vat_json_print (vam->ofp, &node);
2353 vat_json_free (&node);
2355 vam->retval = ntohl (mp->retval);
2356 vam->result_ready = 1;
2359 static void vl_api_get_node_graph_reply_t_handler
2360 (vl_api_get_node_graph_reply_t * mp)
2362 vat_main_t *vam = &vat_main;
2363 api_main_t *am = &api_main;
2364 i32 retval = ntohl (mp->retval);
2365 u8 *pvt_copy, *reply;
2370 if (vam->async_mode)
2372 vam->async_errors += (retval < 0);
2376 vam->retval = retval;
2377 vam->result_ready = 1;
2380 /* "Should never happen..." */
2384 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2385 pvt_copy = vec_dup (reply);
2387 /* Toss the shared-memory original... */
2388 pthread_mutex_lock (&am->vlib_rp->mutex);
2389 oldheap = svm_push_data_heap (am->vlib_rp);
2393 svm_pop_heap (oldheap);
2394 pthread_mutex_unlock (&am->vlib_rp->mutex);
2396 if (vam->graph_nodes)
2398 hash_free (vam->graph_node_index_by_name);
2400 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2402 node = vam->graph_nodes[i];
2403 vec_free (node->name);
2404 vec_free (node->next_nodes);
2407 vec_free (vam->graph_nodes);
2410 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2411 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2412 vec_free (pvt_copy);
2414 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2416 node = vam->graph_nodes[i];
2417 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2421 static void vl_api_get_node_graph_reply_t_handler_json
2422 (vl_api_get_node_graph_reply_t * mp)
2424 vat_main_t *vam = &vat_main;
2425 api_main_t *am = &api_main;
2427 vat_json_node_t node;
2430 /* $$$$ make this real? */
2431 vat_json_init_object (&node);
2432 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2433 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2435 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2437 /* Toss the shared-memory original... */
2438 pthread_mutex_lock (&am->vlib_rp->mutex);
2439 oldheap = svm_push_data_heap (am->vlib_rp);
2443 svm_pop_heap (oldheap);
2444 pthread_mutex_unlock (&am->vlib_rp->mutex);
2446 vat_json_print (vam->ofp, &node);
2447 vat_json_free (&node);
2449 vam->retval = ntohl (mp->retval);
2450 vam->result_ready = 1;
2454 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2456 vat_main_t *vam = &vat_main;
2461 s = format (s, "%=16d%=16d%=16d",
2462 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2466 s = format (s, "%=16U%=16d%=16d",
2467 mp->is_ipv6 ? format_ip6_address :
2469 mp->ip_address, mp->priority, mp->weight);
2472 print (vam->ofp, "%v", s);
2477 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2479 vat_main_t *vam = &vat_main;
2480 vat_json_node_t *node = NULL;
2481 struct in6_addr ip6;
2484 if (VAT_JSON_ARRAY != vam->json_tree.type)
2486 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2487 vat_json_init_array (&vam->json_tree);
2489 node = vat_json_array_add (&vam->json_tree);
2490 vat_json_init_object (node);
2492 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2493 vat_json_object_add_uint (node, "priority", mp->priority);
2494 vat_json_object_add_uint (node, "weight", mp->weight);
2497 vat_json_object_add_uint (node, "sw_if_index",
2498 clib_net_to_host_u32 (mp->sw_if_index));
2503 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2504 vat_json_object_add_ip6 (node, "address", ip6);
2508 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2509 vat_json_object_add_ip4 (node, "address", ip4);
2515 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2518 vat_main_t *vam = &vat_main;
2521 ls_name = format (0, "%s", mp->ls_name);
2523 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2529 vl_api_one_locator_set_details_t_handler_json
2530 (vl_api_one_locator_set_details_t * mp)
2532 vat_main_t *vam = &vat_main;
2533 vat_json_node_t *node = 0;
2536 ls_name = format (0, "%s", mp->ls_name);
2537 vec_add1 (ls_name, 0);
2539 if (VAT_JSON_ARRAY != vam->json_tree.type)
2541 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2542 vat_json_init_array (&vam->json_tree);
2544 node = vat_json_array_add (&vam->json_tree);
2546 vat_json_init_object (node);
2547 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2548 vat_json_object_add_uint (node, "ls_index",
2549 clib_net_to_host_u32 (mp->ls_index));
2554 format_lisp_flat_eid (u8 * s, va_list * args)
2556 u32 type = va_arg (*args, u32);
2557 u8 *eid = va_arg (*args, u8 *);
2558 u32 eid_len = va_arg (*args, u32);
2563 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2565 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2567 return format (s, "%U", format_ethernet_address, eid);
2573 format_lisp_eid_vat (u8 * s, va_list * args)
2575 u32 type = va_arg (*args, u32);
2576 u8 *eid = va_arg (*args, u8 *);
2577 u32 eid_len = va_arg (*args, u32);
2578 u8 *seid = va_arg (*args, u8 *);
2579 u32 seid_len = va_arg (*args, u32);
2580 u32 is_src_dst = va_arg (*args, u32);
2583 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2585 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2591 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2593 vat_main_t *vam = &vat_main;
2594 u8 *s = 0, *eid = 0;
2596 if (~0 == mp->locator_set_index)
2597 s = format (0, "action: %d", mp->action);
2599 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2601 eid = format (0, "%U", format_lisp_eid_vat,
2605 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2608 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2609 clib_net_to_host_u32 (mp->vni),
2611 mp->is_local ? "local" : "remote",
2612 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2613 clib_net_to_host_u16 (mp->key_id), mp->key);
2620 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2623 vat_main_t *vam = &vat_main;
2624 vat_json_node_t *node = 0;
2627 if (VAT_JSON_ARRAY != vam->json_tree.type)
2629 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2630 vat_json_init_array (&vam->json_tree);
2632 node = vat_json_array_add (&vam->json_tree);
2634 vat_json_init_object (node);
2635 if (~0 == mp->locator_set_index)
2636 vat_json_object_add_uint (node, "action", mp->action);
2638 vat_json_object_add_uint (node, "locator_set_index",
2639 clib_net_to_host_u32 (mp->locator_set_index));
2641 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2642 eid = format (0, "%U", format_lisp_eid_vat,
2646 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2648 vat_json_object_add_string_copy (node, "eid", eid);
2649 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2650 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2651 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2655 vat_json_object_add_uint (node, "key_id",
2656 clib_net_to_host_u16 (mp->key_id));
2657 vat_json_object_add_string_copy (node, "key", mp->key);
2663 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
2665 vat_main_t *vam = &vat_main;
2666 u8 *seid = 0, *deid = 0;
2667 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2669 deid = format (0, "%U", format_lisp_eid_vat,
2670 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2672 seid = format (0, "%U", format_lisp_eid_vat,
2673 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2679 format_ip_address_fcn = format_ip4_address;
2681 format_ip_address_fcn = format_ip6_address;
2684 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
2685 clib_net_to_host_u32 (mp->vni),
2687 format_ip_address_fcn, mp->lloc,
2688 format_ip_address_fcn, mp->rloc,
2689 clib_net_to_host_u32 (mp->pkt_count),
2690 clib_net_to_host_u32 (mp->bytes));
2697 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
2699 struct in6_addr ip6;
2701 vat_main_t *vam = &vat_main;
2702 vat_json_node_t *node = 0;
2703 u8 *deid = 0, *seid = 0;
2705 if (VAT_JSON_ARRAY != vam->json_tree.type)
2707 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2708 vat_json_init_array (&vam->json_tree);
2710 node = vat_json_array_add (&vam->json_tree);
2712 vat_json_init_object (node);
2713 deid = format (0, "%U", format_lisp_eid_vat,
2714 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2716 seid = format (0, "%U", format_lisp_eid_vat,
2717 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2722 vat_json_object_add_string_copy (node, "seid", seid);
2723 vat_json_object_add_string_copy (node, "deid", deid);
2724 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2728 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
2729 vat_json_object_add_ip4 (node, "lloc", ip4);
2730 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
2731 vat_json_object_add_ip4 (node, "rloc", ip4);
2735 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
2736 vat_json_object_add_ip6 (node, "lloc", ip6);
2737 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
2738 vat_json_object_add_ip6 (node, "rloc", ip6);
2740 vat_json_object_add_uint (node, "pkt_count",
2741 clib_net_to_host_u32 (mp->pkt_count));
2742 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
2749 vl_api_one_eid_table_map_details_t_handler
2750 (vl_api_one_eid_table_map_details_t * mp)
2752 vat_main_t *vam = &vat_main;
2754 u8 *line = format (0, "%=10d%=10d",
2755 clib_net_to_host_u32 (mp->vni),
2756 clib_net_to_host_u32 (mp->dp_table));
2757 print (vam->ofp, "%v", line);
2762 vl_api_one_eid_table_map_details_t_handler_json
2763 (vl_api_one_eid_table_map_details_t * mp)
2765 vat_main_t *vam = &vat_main;
2766 vat_json_node_t *node = NULL;
2768 if (VAT_JSON_ARRAY != vam->json_tree.type)
2770 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2771 vat_json_init_array (&vam->json_tree);
2773 node = vat_json_array_add (&vam->json_tree);
2774 vat_json_init_object (node);
2775 vat_json_object_add_uint (node, "dp_table",
2776 clib_net_to_host_u32 (mp->dp_table));
2777 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2781 vl_api_one_eid_table_vni_details_t_handler
2782 (vl_api_one_eid_table_vni_details_t * mp)
2784 vat_main_t *vam = &vat_main;
2786 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2787 print (vam->ofp, "%v", line);
2792 vl_api_one_eid_table_vni_details_t_handler_json
2793 (vl_api_one_eid_table_vni_details_t * mp)
2795 vat_main_t *vam = &vat_main;
2796 vat_json_node_t *node = NULL;
2798 if (VAT_JSON_ARRAY != vam->json_tree.type)
2800 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2801 vat_json_init_array (&vam->json_tree);
2803 node = vat_json_array_add (&vam->json_tree);
2804 vat_json_init_object (node);
2805 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2809 vl_api_show_one_map_register_state_reply_t_handler
2810 (vl_api_show_one_map_register_state_reply_t * mp)
2812 vat_main_t *vam = &vat_main;
2813 int retval = clib_net_to_host_u32 (mp->retval);
2815 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2817 vam->retval = retval;
2818 vam->result_ready = 1;
2822 vl_api_show_one_map_register_state_reply_t_handler_json
2823 (vl_api_show_one_map_register_state_reply_t * mp)
2825 vat_main_t *vam = &vat_main;
2826 vat_json_node_t _node, *node = &_node;
2827 int retval = clib_net_to_host_u32 (mp->retval);
2829 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2831 vat_json_init_object (node);
2832 vat_json_object_add_string_copy (node, "state", s);
2834 vat_json_print (vam->ofp, node);
2835 vat_json_free (node);
2837 vam->retval = retval;
2838 vam->result_ready = 1;
2843 vl_api_show_one_rloc_probe_state_reply_t_handler
2844 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2846 vat_main_t *vam = &vat_main;
2847 int retval = clib_net_to_host_u32 (mp->retval);
2852 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2854 vam->retval = retval;
2855 vam->result_ready = 1;
2859 vl_api_show_one_rloc_probe_state_reply_t_handler_json
2860 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2862 vat_main_t *vam = &vat_main;
2863 vat_json_node_t _node, *node = &_node;
2864 int retval = clib_net_to_host_u32 (mp->retval);
2866 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2867 vat_json_init_object (node);
2868 vat_json_object_add_string_copy (node, "state", s);
2870 vat_json_print (vam->ofp, node);
2871 vat_json_free (node);
2873 vam->retval = retval;
2874 vam->result_ready = 1;
2879 vl_api_show_one_stats_enable_disable_reply_t_handler
2880 (vl_api_show_one_stats_enable_disable_reply_t * mp)
2882 vat_main_t *vam = &vat_main;
2883 int retval = clib_net_to_host_u32 (mp->retval);
2888 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
2890 vam->retval = retval;
2891 vam->result_ready = 1;
2895 vl_api_show_one_stats_enable_disable_reply_t_handler_json
2896 (vl_api_show_one_stats_enable_disable_reply_t * mp)
2898 vat_main_t *vam = &vat_main;
2899 vat_json_node_t _node, *node = &_node;
2900 int retval = clib_net_to_host_u32 (mp->retval);
2902 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
2903 vat_json_init_object (node);
2904 vat_json_object_add_string_copy (node, "state", s);
2906 vat_json_print (vam->ofp, node);
2907 vat_json_free (node);
2909 vam->retval = retval;
2910 vam->result_ready = 1;
2915 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
2917 e->dp_table = clib_net_to_host_u32 (e->dp_table);
2918 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
2919 e->vni = clib_net_to_host_u32 (e->vni);
2923 gpe_fwd_entries_get_reply_t_net_to_host
2924 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2928 mp->count = clib_net_to_host_u32 (mp->count);
2929 for (i = 0; i < mp->count; i++)
2931 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
2936 format_gpe_encap_mode (u8 * s, va_list * args)
2938 u32 mode = va_arg (*args, u32);
2943 return format (s, "lisp");
2945 return format (s, "vxlan");
2951 vl_api_gpe_get_encap_mode_reply_t_handler
2952 (vl_api_gpe_get_encap_mode_reply_t * mp)
2954 vat_main_t *vam = &vat_main;
2956 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
2957 vam->retval = ntohl (mp->retval);
2958 vam->result_ready = 1;
2962 vl_api_gpe_get_encap_mode_reply_t_handler_json
2963 (vl_api_gpe_get_encap_mode_reply_t * mp)
2965 vat_main_t *vam = &vat_main;
2966 vat_json_node_t node;
2968 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
2969 vec_add1 (encap_mode, 0);
2971 vat_json_init_object (&node);
2972 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
2974 vec_free (encap_mode);
2975 vat_json_print (vam->ofp, &node);
2976 vat_json_free (&node);
2978 vam->retval = ntohl (mp->retval);
2979 vam->result_ready = 1;
2983 vl_api_gpe_fwd_entry_path_details_t_handler
2984 (vl_api_gpe_fwd_entry_path_details_t * mp)
2986 vat_main_t *vam = &vat_main;
2987 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2989 if (mp->lcl_loc.is_ip4)
2990 format_ip_address_fcn = format_ip4_address;
2992 format_ip_address_fcn = format_ip6_address;
2994 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
2995 format_ip_address_fcn, &mp->lcl_loc,
2996 format_ip_address_fcn, &mp->rmt_loc);
3000 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3002 struct in6_addr ip6;
3007 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3008 vat_json_object_add_ip4 (n, "address", ip4);
3012 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3013 vat_json_object_add_ip6 (n, "address", ip6);
3015 vat_json_object_add_uint (n, "weight", loc->weight);
3019 vl_api_gpe_fwd_entry_path_details_t_handler_json
3020 (vl_api_gpe_fwd_entry_path_details_t * mp)
3022 vat_main_t *vam = &vat_main;
3023 vat_json_node_t *node = NULL;
3024 vat_json_node_t *loc_node;
3026 if (VAT_JSON_ARRAY != vam->json_tree.type)
3028 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3029 vat_json_init_array (&vam->json_tree);
3031 node = vat_json_array_add (&vam->json_tree);
3032 vat_json_init_object (node);
3034 loc_node = vat_json_object_add (node, "local_locator");
3035 vat_json_init_object (loc_node);
3036 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3038 loc_node = vat_json_object_add (node, "remote_locator");
3039 vat_json_init_object (loc_node);
3040 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3044 vl_api_gpe_fwd_entries_get_reply_t_handler
3045 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3047 vat_main_t *vam = &vat_main;
3049 int retval = clib_net_to_host_u32 (mp->retval);
3050 vl_api_gpe_fwd_entry_t *e;
3055 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3057 for (i = 0; i < mp->count; i++)
3059 e = &mp->entries[i];
3060 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3061 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3062 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3066 vam->retval = retval;
3067 vam->result_ready = 1;
3071 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3072 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3075 vat_main_t *vam = &vat_main;
3076 vat_json_node_t *e = 0, root;
3078 int retval = clib_net_to_host_u32 (mp->retval);
3079 vl_api_gpe_fwd_entry_t *fwd;
3084 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3085 vat_json_init_array (&root);
3087 for (i = 0; i < mp->count; i++)
3089 e = vat_json_array_add (&root);
3090 fwd = &mp->entries[i];
3092 vat_json_init_object (e);
3093 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3094 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3095 vat_json_object_add_int (e, "vni", fwd->vni);
3096 vat_json_object_add_int (e, "action", fwd->action);
3098 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3099 fwd->leid_prefix_len);
3101 vat_json_object_add_string_copy (e, "leid", s);
3104 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3105 fwd->reid_prefix_len);
3107 vat_json_object_add_string_copy (e, "reid", s);
3111 vat_json_print (vam->ofp, &root);
3112 vat_json_free (&root);
3115 vam->retval = retval;
3116 vam->result_ready = 1;
3120 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3121 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3123 vat_main_t *vam = &vat_main;
3125 int retval = clib_net_to_host_u32 (mp->retval);
3130 n = clib_net_to_host_u32 (mp->count);
3132 for (i = 0; i < n; i++)
3133 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3136 vam->retval = retval;
3137 vam->result_ready = 1;
3141 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3142 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3144 vat_main_t *vam = &vat_main;
3145 vat_json_node_t root;
3147 int retval = clib_net_to_host_u32 (mp->retval);
3152 n = clib_net_to_host_u32 (mp->count);
3153 vat_json_init_array (&root);
3155 for (i = 0; i < n; i++)
3156 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3158 vat_json_print (vam->ofp, &root);
3159 vat_json_free (&root);
3162 vam->retval = retval;
3163 vam->result_ready = 1;
3167 vl_api_one_l2_arp_entries_get_reply_t_handler
3168 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3170 vat_main_t *vam = &vat_main;
3172 int retval = clib_net_to_host_u32 (mp->retval);
3177 n = clib_net_to_host_u32 (mp->count);
3179 for (i = 0; i < n; i++)
3180 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3181 format_ethernet_address, mp->entries[i].mac);
3184 vam->retval = retval;
3185 vam->result_ready = 1;
3189 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3190 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3193 vat_main_t *vam = &vat_main;
3194 vat_json_node_t *e = 0, root;
3196 int retval = clib_net_to_host_u32 (mp->retval);
3197 vl_api_one_l2_arp_entry_t *arp_entry;
3202 n = clib_net_to_host_u32 (mp->count);
3203 vat_json_init_array (&root);
3205 for (i = 0; i < n; i++)
3207 e = vat_json_array_add (&root);
3208 arp_entry = &mp->entries[i];
3210 vat_json_init_object (e);
3211 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3214 vat_json_object_add_string_copy (e, "mac", s);
3217 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3219 vat_json_object_add_string_copy (e, "ip4", s);
3223 vat_json_print (vam->ofp, &root);
3224 vat_json_free (&root);
3227 vam->retval = retval;
3228 vam->result_ready = 1;
3232 vl_api_one_l2_arp_bd_get_reply_t_handler
3233 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3235 vat_main_t *vam = &vat_main;
3237 int retval = clib_net_to_host_u32 (mp->retval);
3242 n = clib_net_to_host_u32 (mp->count);
3244 for (i = 0; i < n; i++)
3246 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3250 vam->retval = retval;
3251 vam->result_ready = 1;
3255 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3256 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3258 vat_main_t *vam = &vat_main;
3259 vat_json_node_t root;
3261 int retval = clib_net_to_host_u32 (mp->retval);
3266 n = clib_net_to_host_u32 (mp->count);
3267 vat_json_init_array (&root);
3269 for (i = 0; i < n; i++)
3271 vat_json_array_add_uint (&root,
3272 clib_net_to_host_u32 (mp->bridge_domains[i]));
3275 vat_json_print (vam->ofp, &root);
3276 vat_json_free (&root);
3279 vam->retval = retval;
3280 vam->result_ready = 1;
3284 vl_api_one_adjacencies_get_reply_t_handler
3285 (vl_api_one_adjacencies_get_reply_t * mp)
3287 vat_main_t *vam = &vat_main;
3289 int retval = clib_net_to_host_u32 (mp->retval);
3290 vl_api_one_adjacency_t *a;
3295 n = clib_net_to_host_u32 (mp->count);
3297 for (i = 0; i < n; i++)
3299 a = &mp->adjacencies[i];
3300 print (vam->ofp, "%U %40U",
3301 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3302 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3306 vam->retval = retval;
3307 vam->result_ready = 1;
3311 vl_api_one_adjacencies_get_reply_t_handler_json
3312 (vl_api_one_adjacencies_get_reply_t * mp)
3315 vat_main_t *vam = &vat_main;
3316 vat_json_node_t *e = 0, root;
3318 int retval = clib_net_to_host_u32 (mp->retval);
3319 vl_api_one_adjacency_t *a;
3324 n = clib_net_to_host_u32 (mp->count);
3325 vat_json_init_array (&root);
3327 for (i = 0; i < n; i++)
3329 e = vat_json_array_add (&root);
3330 a = &mp->adjacencies[i];
3332 vat_json_init_object (e);
3333 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3334 a->leid_prefix_len);
3336 vat_json_object_add_string_copy (e, "leid", s);
3339 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3340 a->reid_prefix_len);
3342 vat_json_object_add_string_copy (e, "reid", s);
3346 vat_json_print (vam->ofp, &root);
3347 vat_json_free (&root);
3350 vam->retval = retval;
3351 vam->result_ready = 1;
3355 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3357 vat_main_t *vam = &vat_main;
3359 print (vam->ofp, "%=20U",
3360 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3365 vl_api_one_map_server_details_t_handler_json
3366 (vl_api_one_map_server_details_t * mp)
3368 vat_main_t *vam = &vat_main;
3369 vat_json_node_t *node = NULL;
3370 struct in6_addr ip6;
3373 if (VAT_JSON_ARRAY != vam->json_tree.type)
3375 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3376 vat_json_init_array (&vam->json_tree);
3378 node = vat_json_array_add (&vam->json_tree);
3380 vat_json_init_object (node);
3383 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3384 vat_json_object_add_ip6 (node, "map-server", ip6);
3388 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3389 vat_json_object_add_ip4 (node, "map-server", ip4);
3394 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3397 vat_main_t *vam = &vat_main;
3399 print (vam->ofp, "%=20U",
3400 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3405 vl_api_one_map_resolver_details_t_handler_json
3406 (vl_api_one_map_resolver_details_t * mp)
3408 vat_main_t *vam = &vat_main;
3409 vat_json_node_t *node = NULL;
3410 struct in6_addr ip6;
3413 if (VAT_JSON_ARRAY != vam->json_tree.type)
3415 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3416 vat_json_init_array (&vam->json_tree);
3418 node = vat_json_array_add (&vam->json_tree);
3420 vat_json_init_object (node);
3423 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3424 vat_json_object_add_ip6 (node, "map resolver", ip6);
3428 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3429 vat_json_object_add_ip4 (node, "map resolver", ip4);
3434 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3436 vat_main_t *vam = &vat_main;
3437 i32 retval = ntohl (mp->retval);
3441 print (vam->ofp, "feature: %s\ngpe: %s",
3442 mp->feature_status ? "enabled" : "disabled",
3443 mp->gpe_status ? "enabled" : "disabled");
3446 vam->retval = retval;
3447 vam->result_ready = 1;
3451 vl_api_show_one_status_reply_t_handler_json
3452 (vl_api_show_one_status_reply_t * mp)
3454 vat_main_t *vam = &vat_main;
3455 vat_json_node_t node;
3456 u8 *gpe_status = NULL;
3457 u8 *feature_status = NULL;
3459 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3460 feature_status = format (0, "%s",
3461 mp->feature_status ? "enabled" : "disabled");
3462 vec_add1 (gpe_status, 0);
3463 vec_add1 (feature_status, 0);
3465 vat_json_init_object (&node);
3466 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3467 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3469 vec_free (gpe_status);
3470 vec_free (feature_status);
3472 vat_json_print (vam->ofp, &node);
3473 vat_json_free (&node);
3475 vam->retval = ntohl (mp->retval);
3476 vam->result_ready = 1;
3480 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3481 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3483 vat_main_t *vam = &vat_main;
3484 i32 retval = ntohl (mp->retval);
3488 print (vam->ofp, "%=20s", mp->locator_set_name);
3491 vam->retval = retval;
3492 vam->result_ready = 1;
3496 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3497 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3499 vat_main_t *vam = &vat_main;
3500 vat_json_node_t *node = NULL;
3502 if (VAT_JSON_ARRAY != vam->json_tree.type)
3504 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3505 vat_json_init_array (&vam->json_tree);
3507 node = vat_json_array_add (&vam->json_tree);
3509 vat_json_init_object (node);
3510 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3512 vat_json_print (vam->ofp, node);
3513 vat_json_free (node);
3515 vam->retval = ntohl (mp->retval);
3516 vam->result_ready = 1;
3520 format_lisp_map_request_mode (u8 * s, va_list * args)
3522 u32 mode = va_arg (*args, u32);
3527 return format (0, "dst-only");
3529 return format (0, "src-dst");
3535 vl_api_show_one_map_request_mode_reply_t_handler
3536 (vl_api_show_one_map_request_mode_reply_t * mp)
3538 vat_main_t *vam = &vat_main;
3539 i32 retval = ntohl (mp->retval);
3543 u32 mode = mp->mode;
3544 print (vam->ofp, "map_request_mode: %U",
3545 format_lisp_map_request_mode, mode);
3548 vam->retval = retval;
3549 vam->result_ready = 1;
3553 vl_api_show_one_map_request_mode_reply_t_handler_json
3554 (vl_api_show_one_map_request_mode_reply_t * mp)
3556 vat_main_t *vam = &vat_main;
3557 vat_json_node_t node;
3562 s = format (0, "%U", format_lisp_map_request_mode, mode);
3565 vat_json_init_object (&node);
3566 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3567 vat_json_print (vam->ofp, &node);
3568 vat_json_free (&node);
3571 vam->retval = ntohl (mp->retval);
3572 vam->result_ready = 1;
3576 vl_api_show_one_use_petr_reply_t_handler
3577 (vl_api_show_one_use_petr_reply_t * mp)
3579 vat_main_t *vam = &vat_main;
3580 i32 retval = ntohl (mp->retval);
3584 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
3587 print (vam->ofp, "Proxy-ETR address; %U",
3588 mp->is_ip4 ? format_ip4_address : format_ip6_address,
3593 vam->retval = retval;
3594 vam->result_ready = 1;
3598 vl_api_show_one_use_petr_reply_t_handler_json
3599 (vl_api_show_one_use_petr_reply_t * mp)
3601 vat_main_t *vam = &vat_main;
3602 vat_json_node_t node;
3605 struct in6_addr ip6;
3607 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3608 vec_add1 (status, 0);
3610 vat_json_init_object (&node);
3611 vat_json_object_add_string_copy (&node, "status", status);
3616 clib_memcpy (&ip6, mp->address, sizeof (ip6));
3617 vat_json_object_add_ip6 (&node, "address", ip6);
3621 clib_memcpy (&ip4, mp->address, sizeof (ip4));
3622 vat_json_object_add_ip4 (&node, "address", ip4);
3628 vat_json_print (vam->ofp, &node);
3629 vat_json_free (&node);
3631 vam->retval = ntohl (mp->retval);
3632 vam->result_ready = 1;
3636 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3638 vat_main_t *vam = &vat_main;
3639 i32 retval = ntohl (mp->retval);
3643 print (vam->ofp, "%-20s%-16s",
3644 mp->status ? "enabled" : "disabled",
3645 mp->status ? (char *) mp->locator_set_name : "");
3648 vam->retval = retval;
3649 vam->result_ready = 1;
3653 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3655 vat_main_t *vam = &vat_main;
3656 vat_json_node_t node;
3659 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3660 vec_add1 (status, 0);
3662 vat_json_init_object (&node);
3663 vat_json_object_add_string_copy (&node, "status", status);
3666 vat_json_object_add_string_copy (&node, "locator_set",
3667 mp->locator_set_name);
3672 vat_json_print (vam->ofp, &node);
3673 vat_json_free (&node);
3675 vam->retval = ntohl (mp->retval);
3676 vam->result_ready = 1;
3680 format_policer_type (u8 * s, va_list * va)
3682 u32 i = va_arg (*va, u32);
3684 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3685 s = format (s, "1r2c");
3686 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3687 s = format (s, "1r3c");
3688 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3689 s = format (s, "2r3c-2698");
3690 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3691 s = format (s, "2r3c-4115");
3692 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3693 s = format (s, "2r3c-mef5cf1");
3695 s = format (s, "ILLEGAL");
3700 format_policer_rate_type (u8 * s, va_list * va)
3702 u32 i = va_arg (*va, u32);
3704 if (i == SSE2_QOS_RATE_KBPS)
3705 s = format (s, "kbps");
3706 else if (i == SSE2_QOS_RATE_PPS)
3707 s = format (s, "pps");
3709 s = format (s, "ILLEGAL");
3714 format_policer_round_type (u8 * s, va_list * va)
3716 u32 i = va_arg (*va, u32);
3718 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3719 s = format (s, "closest");
3720 else if (i == SSE2_QOS_ROUND_TO_UP)
3721 s = format (s, "up");
3722 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3723 s = format (s, "down");
3725 s = format (s, "ILLEGAL");
3730 format_policer_action_type (u8 * s, va_list * va)
3732 u32 i = va_arg (*va, u32);
3734 if (i == SSE2_QOS_ACTION_DROP)
3735 s = format (s, "drop");
3736 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3737 s = format (s, "transmit");
3738 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3739 s = format (s, "mark-and-transmit");
3741 s = format (s, "ILLEGAL");
3746 format_dscp (u8 * s, va_list * va)
3748 u32 i = va_arg (*va, u32);
3753 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3757 return format (s, "ILLEGAL");
3759 s = format (s, "%s", t);
3764 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3766 vat_main_t *vam = &vat_main;
3767 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3769 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3770 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3772 conform_dscp_str = format (0, "");
3774 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3775 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3777 exceed_dscp_str = format (0, "");
3779 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3780 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3782 violate_dscp_str = format (0, "");
3784 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3785 "rate type %U, round type %U, %s rate, %s color-aware, "
3786 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3787 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3788 "conform action %U%s, exceed action %U%s, violate action %U%s",
3790 format_policer_type, mp->type,
3793 clib_net_to_host_u64 (mp->cb),
3794 clib_net_to_host_u64 (mp->eb),
3795 format_policer_rate_type, mp->rate_type,
3796 format_policer_round_type, mp->round_type,
3797 mp->single_rate ? "single" : "dual",
3798 mp->color_aware ? "is" : "not",
3799 ntohl (mp->cir_tokens_per_period),
3800 ntohl (mp->pir_tokens_per_period),
3802 ntohl (mp->current_limit),
3803 ntohl (mp->current_bucket),
3804 ntohl (mp->extended_limit),
3805 ntohl (mp->extended_bucket),
3806 clib_net_to_host_u64 (mp->last_update_time),
3807 format_policer_action_type, mp->conform_action_type,
3809 format_policer_action_type, mp->exceed_action_type,
3811 format_policer_action_type, mp->violate_action_type,
3814 vec_free (conform_dscp_str);
3815 vec_free (exceed_dscp_str);
3816 vec_free (violate_dscp_str);
3819 static void vl_api_policer_details_t_handler_json
3820 (vl_api_policer_details_t * mp)
3822 vat_main_t *vam = &vat_main;
3823 vat_json_node_t *node;
3824 u8 *rate_type_str, *round_type_str, *type_str;
3825 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3827 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3829 format (0, "%U", format_policer_round_type, mp->round_type);
3830 type_str = format (0, "%U", format_policer_type, mp->type);
3831 conform_action_str = format (0, "%U", format_policer_action_type,
3832 mp->conform_action_type);
3833 exceed_action_str = format (0, "%U", format_policer_action_type,
3834 mp->exceed_action_type);
3835 violate_action_str = format (0, "%U", format_policer_action_type,
3836 mp->violate_action_type);
3838 if (VAT_JSON_ARRAY != vam->json_tree.type)
3840 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3841 vat_json_init_array (&vam->json_tree);
3843 node = vat_json_array_add (&vam->json_tree);
3845 vat_json_init_object (node);
3846 vat_json_object_add_string_copy (node, "name", mp->name);
3847 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3848 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3849 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
3850 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
3851 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3852 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3853 vat_json_object_add_string_copy (node, "type", type_str);
3854 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3855 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3856 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3857 vat_json_object_add_uint (node, "cir_tokens_per_period",
3858 ntohl (mp->cir_tokens_per_period));
3859 vat_json_object_add_uint (node, "eir_tokens_per_period",
3860 ntohl (mp->pir_tokens_per_period));
3861 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3862 vat_json_object_add_uint (node, "current_bucket",
3863 ntohl (mp->current_bucket));
3864 vat_json_object_add_uint (node, "extended_limit",
3865 ntohl (mp->extended_limit));
3866 vat_json_object_add_uint (node, "extended_bucket",
3867 ntohl (mp->extended_bucket));
3868 vat_json_object_add_uint (node, "last_update_time",
3869 ntohl (mp->last_update_time));
3870 vat_json_object_add_string_copy (node, "conform_action",
3871 conform_action_str);
3872 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3874 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3875 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3876 vec_free (dscp_str);
3878 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3879 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3881 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3882 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3883 vec_free (dscp_str);
3885 vat_json_object_add_string_copy (node, "violate_action",
3886 violate_action_str);
3887 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3889 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3890 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3891 vec_free (dscp_str);
3894 vec_free (rate_type_str);
3895 vec_free (round_type_str);
3896 vec_free (type_str);
3897 vec_free (conform_action_str);
3898 vec_free (exceed_action_str);
3899 vec_free (violate_action_str);
3903 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3906 vat_main_t *vam = &vat_main;
3907 int i, count = ntohl (mp->count);
3910 print (vam->ofp, "classify table ids (%d) : ", count);
3911 for (i = 0; i < count; i++)
3913 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3914 print (vam->ofp, (i < count - 1) ? "," : "");
3916 vam->retval = ntohl (mp->retval);
3917 vam->result_ready = 1;
3921 vl_api_classify_table_ids_reply_t_handler_json
3922 (vl_api_classify_table_ids_reply_t * mp)
3924 vat_main_t *vam = &vat_main;
3925 int i, count = ntohl (mp->count);
3929 vat_json_node_t node;
3931 vat_json_init_object (&node);
3932 for (i = 0; i < count; i++)
3934 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3936 vat_json_print (vam->ofp, &node);
3937 vat_json_free (&node);
3939 vam->retval = ntohl (mp->retval);
3940 vam->result_ready = 1;
3944 vl_api_classify_table_by_interface_reply_t_handler
3945 (vl_api_classify_table_by_interface_reply_t * mp)
3947 vat_main_t *vam = &vat_main;
3950 table_id = ntohl (mp->l2_table_id);
3952 print (vam->ofp, "l2 table id : %d", table_id);
3954 print (vam->ofp, "l2 table id : No input ACL tables configured");
3955 table_id = ntohl (mp->ip4_table_id);
3957 print (vam->ofp, "ip4 table id : %d", table_id);
3959 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3960 table_id = ntohl (mp->ip6_table_id);
3962 print (vam->ofp, "ip6 table id : %d", table_id);
3964 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3965 vam->retval = ntohl (mp->retval);
3966 vam->result_ready = 1;
3970 vl_api_classify_table_by_interface_reply_t_handler_json
3971 (vl_api_classify_table_by_interface_reply_t * mp)
3973 vat_main_t *vam = &vat_main;
3974 vat_json_node_t node;
3976 vat_json_init_object (&node);
3978 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3979 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3980 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3982 vat_json_print (vam->ofp, &node);
3983 vat_json_free (&node);
3985 vam->retval = ntohl (mp->retval);
3986 vam->result_ready = 1;
3989 static void vl_api_policer_add_del_reply_t_handler
3990 (vl_api_policer_add_del_reply_t * mp)
3992 vat_main_t *vam = &vat_main;
3993 i32 retval = ntohl (mp->retval);
3994 if (vam->async_mode)
3996 vam->async_errors += (retval < 0);
4000 vam->retval = retval;
4001 vam->result_ready = 1;
4002 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4004 * Note: this is just barely thread-safe, depends on
4005 * the main thread spinning waiting for an answer...
4007 errmsg ("policer index %d", ntohl (mp->policer_index));
4011 static void vl_api_policer_add_del_reply_t_handler_json
4012 (vl_api_policer_add_del_reply_t * mp)
4014 vat_main_t *vam = &vat_main;
4015 vat_json_node_t node;
4017 vat_json_init_object (&node);
4018 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4019 vat_json_object_add_uint (&node, "policer_index",
4020 ntohl (mp->policer_index));
4022 vat_json_print (vam->ofp, &node);
4023 vat_json_free (&node);
4025 vam->retval = ntohl (mp->retval);
4026 vam->result_ready = 1;
4029 /* Format hex dump. */
4031 format_hex_bytes (u8 * s, va_list * va)
4033 u8 *bytes = va_arg (*va, u8 *);
4034 int n_bytes = va_arg (*va, int);
4037 /* Print short or long form depending on byte count. */
4038 uword short_form = n_bytes <= 32;
4039 uword indent = format_get_indent (s);
4044 for (i = 0; i < n_bytes; i++)
4046 if (!short_form && (i % 32) == 0)
4047 s = format (s, "%08x: ", i);
4048 s = format (s, "%02x", bytes[i]);
4049 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4050 s = format (s, "\n%U", format_white_space, indent);
4057 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4060 vat_main_t *vam = &vat_main;
4061 i32 retval = ntohl (mp->retval);
4064 print (vam->ofp, "classify table info :");
4065 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4066 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4067 ntohl (mp->miss_next_index));
4068 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4069 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4070 ntohl (mp->match_n_vectors));
4071 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4072 ntohl (mp->mask_length));
4074 vam->retval = retval;
4075 vam->result_ready = 1;
4079 vl_api_classify_table_info_reply_t_handler_json
4080 (vl_api_classify_table_info_reply_t * mp)
4082 vat_main_t *vam = &vat_main;
4083 vat_json_node_t node;
4085 i32 retval = ntohl (mp->retval);
4088 vat_json_init_object (&node);
4090 vat_json_object_add_int (&node, "sessions",
4091 ntohl (mp->active_sessions));
4092 vat_json_object_add_int (&node, "nexttbl",
4093 ntohl (mp->next_table_index));
4094 vat_json_object_add_int (&node, "nextnode",
4095 ntohl (mp->miss_next_index));
4096 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4097 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4098 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4099 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4100 ntohl (mp->mask_length), 0);
4101 vat_json_object_add_string_copy (&node, "mask", s);
4103 vat_json_print (vam->ofp, &node);
4104 vat_json_free (&node);
4106 vam->retval = ntohl (mp->retval);
4107 vam->result_ready = 1;
4111 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4114 vat_main_t *vam = &vat_main;
4116 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4117 ntohl (mp->hit_next_index), ntohl (mp->advance),
4118 ntohl (mp->opaque_index));
4119 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4120 ntohl (mp->match_length));
4124 vl_api_classify_session_details_t_handler_json
4125 (vl_api_classify_session_details_t * mp)
4127 vat_main_t *vam = &vat_main;
4128 vat_json_node_t *node = NULL;
4130 if (VAT_JSON_ARRAY != vam->json_tree.type)
4132 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4133 vat_json_init_array (&vam->json_tree);
4135 node = vat_json_array_add (&vam->json_tree);
4137 vat_json_init_object (node);
4138 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4139 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4140 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4142 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4144 vat_json_object_add_string_copy (node, "match", s);
4147 static void vl_api_pg_create_interface_reply_t_handler
4148 (vl_api_pg_create_interface_reply_t * mp)
4150 vat_main_t *vam = &vat_main;
4152 vam->retval = ntohl (mp->retval);
4153 vam->result_ready = 1;
4156 static void vl_api_pg_create_interface_reply_t_handler_json
4157 (vl_api_pg_create_interface_reply_t * mp)
4159 vat_main_t *vam = &vat_main;
4160 vat_json_node_t node;
4162 i32 retval = ntohl (mp->retval);
4165 vat_json_init_object (&node);
4167 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4169 vat_json_print (vam->ofp, &node);
4170 vat_json_free (&node);
4172 vam->retval = ntohl (mp->retval);
4173 vam->result_ready = 1;
4176 static void vl_api_policer_classify_details_t_handler
4177 (vl_api_policer_classify_details_t * mp)
4179 vat_main_t *vam = &vat_main;
4181 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4182 ntohl (mp->table_index));
4185 static void vl_api_policer_classify_details_t_handler_json
4186 (vl_api_policer_classify_details_t * mp)
4188 vat_main_t *vam = &vat_main;
4189 vat_json_node_t *node;
4191 if (VAT_JSON_ARRAY != vam->json_tree.type)
4193 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4194 vat_json_init_array (&vam->json_tree);
4196 node = vat_json_array_add (&vam->json_tree);
4198 vat_json_init_object (node);
4199 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4200 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4203 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4204 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4206 vat_main_t *vam = &vat_main;
4207 i32 retval = ntohl (mp->retval);
4208 if (vam->async_mode)
4210 vam->async_errors += (retval < 0);
4214 vam->retval = retval;
4215 vam->sw_if_index = ntohl (mp->sw_if_index);
4216 vam->result_ready = 1;
4220 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4221 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4223 vat_main_t *vam = &vat_main;
4224 vat_json_node_t node;
4226 vat_json_init_object (&node);
4227 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4228 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4230 vat_json_print (vam->ofp, &node);
4231 vat_json_free (&node);
4233 vam->retval = ntohl (mp->retval);
4234 vam->result_ready = 1;
4237 static void vl_api_flow_classify_details_t_handler
4238 (vl_api_flow_classify_details_t * mp)
4240 vat_main_t *vam = &vat_main;
4242 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4243 ntohl (mp->table_index));
4246 static void vl_api_flow_classify_details_t_handler_json
4247 (vl_api_flow_classify_details_t * mp)
4249 vat_main_t *vam = &vat_main;
4250 vat_json_node_t *node;
4252 if (VAT_JSON_ARRAY != vam->json_tree.type)
4254 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4255 vat_json_init_array (&vam->json_tree);
4257 node = vat_json_array_add (&vam->json_tree);
4259 vat_json_init_object (node);
4260 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4261 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4264 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
4265 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
4266 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
4267 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
4268 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4269 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4270 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4271 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4272 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4273 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4274 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4275 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4276 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4277 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4278 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
4279 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
4280 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
4281 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
4284 * Generate boilerplate reply handlers, which
4285 * dig the return value out of the xxx_reply_t API message,
4286 * stick it into vam->retval, and set vam->result_ready
4288 * Could also do this by pointing N message decode slots at
4289 * a single function, but that could break in subtle ways.
4292 #define foreach_standard_reply_retval_handler \
4293 _(sw_interface_set_flags_reply) \
4294 _(sw_interface_add_del_address_reply) \
4295 _(sw_interface_set_table_reply) \
4296 _(sw_interface_set_mpls_enable_reply) \
4297 _(sw_interface_set_vpath_reply) \
4298 _(sw_interface_set_vxlan_bypass_reply) \
4299 _(sw_interface_set_l2_bridge_reply) \
4300 _(bridge_domain_add_del_reply) \
4301 _(sw_interface_set_l2_xconnect_reply) \
4302 _(l2fib_add_del_reply) \
4303 _(l2fib_flush_int_reply) \
4304 _(l2fib_flush_bd_reply) \
4305 _(ip_add_del_route_reply) \
4306 _(ip_mroute_add_del_reply) \
4307 _(mpls_route_add_del_reply) \
4308 _(mpls_ip_bind_unbind_reply) \
4309 _(proxy_arp_add_del_reply) \
4310 _(proxy_arp_intfc_enable_disable_reply) \
4311 _(sw_interface_set_unnumbered_reply) \
4312 _(ip_neighbor_add_del_reply) \
4313 _(reset_vrf_reply) \
4314 _(oam_add_del_reply) \
4315 _(reset_fib_reply) \
4316 _(dhcp_proxy_config_reply) \
4317 _(dhcp_proxy_set_vss_reply) \
4318 _(dhcp_client_config_reply) \
4319 _(set_ip_flow_hash_reply) \
4320 _(sw_interface_ip6_enable_disable_reply) \
4321 _(sw_interface_ip6_set_link_local_address_reply) \
4322 _(ip6nd_proxy_add_del_reply) \
4323 _(sw_interface_ip6nd_ra_prefix_reply) \
4324 _(sw_interface_ip6nd_ra_config_reply) \
4325 _(set_arp_neighbor_limit_reply) \
4326 _(l2_patch_add_del_reply) \
4327 _(sr_policy_add_reply) \
4328 _(sr_policy_mod_reply) \
4329 _(sr_policy_del_reply) \
4330 _(sr_localsid_add_del_reply) \
4331 _(sr_steering_add_del_reply) \
4332 _(classify_add_del_session_reply) \
4333 _(classify_set_interface_ip_table_reply) \
4334 _(classify_set_interface_l2_tables_reply) \
4335 _(l2tpv3_set_tunnel_cookies_reply) \
4336 _(l2tpv3_interface_enable_disable_reply) \
4337 _(l2tpv3_set_lookup_key_reply) \
4338 _(l2_fib_clear_table_reply) \
4339 _(l2_interface_efp_filter_reply) \
4340 _(l2_interface_vlan_tag_rewrite_reply) \
4341 _(modify_vhost_user_if_reply) \
4342 _(delete_vhost_user_if_reply) \
4343 _(want_ip4_arp_events_reply) \
4344 _(want_ip6_nd_events_reply) \
4345 _(input_acl_set_interface_reply) \
4346 _(ipsec_spd_add_del_reply) \
4347 _(ipsec_interface_add_del_spd_reply) \
4348 _(ipsec_spd_add_del_entry_reply) \
4349 _(ipsec_sad_add_del_entry_reply) \
4350 _(ipsec_sa_set_key_reply) \
4351 _(ipsec_tunnel_if_add_del_reply) \
4352 _(ikev2_profile_add_del_reply) \
4353 _(ikev2_profile_set_auth_reply) \
4354 _(ikev2_profile_set_id_reply) \
4355 _(ikev2_profile_set_ts_reply) \
4356 _(ikev2_set_local_key_reply) \
4357 _(ikev2_set_responder_reply) \
4358 _(ikev2_set_ike_transforms_reply) \
4359 _(ikev2_set_esp_transforms_reply) \
4360 _(ikev2_set_sa_lifetime_reply) \
4361 _(ikev2_initiate_sa_init_reply) \
4362 _(ikev2_initiate_del_ike_sa_reply) \
4363 _(ikev2_initiate_del_child_sa_reply) \
4364 _(ikev2_initiate_rekey_child_sa_reply) \
4365 _(delete_loopback_reply) \
4366 _(bd_ip_mac_add_del_reply) \
4367 _(map_del_domain_reply) \
4368 _(map_add_del_rule_reply) \
4369 _(want_interface_events_reply) \
4370 _(want_stats_reply) \
4371 _(cop_interface_enable_disable_reply) \
4372 _(cop_whitelist_enable_disable_reply) \
4373 _(sw_interface_clear_stats_reply) \
4374 _(ioam_enable_reply) \
4375 _(ioam_disable_reply) \
4376 _(one_add_del_locator_reply) \
4377 _(one_add_del_local_eid_reply) \
4378 _(one_add_del_remote_mapping_reply) \
4379 _(one_add_del_adjacency_reply) \
4380 _(one_add_del_map_resolver_reply) \
4381 _(one_add_del_map_server_reply) \
4382 _(one_enable_disable_reply) \
4383 _(one_rloc_probe_enable_disable_reply) \
4384 _(one_map_register_enable_disable_reply) \
4385 _(one_pitr_set_locator_set_reply) \
4386 _(one_map_request_mode_reply) \
4387 _(one_add_del_map_request_itr_rlocs_reply) \
4388 _(one_eid_table_add_del_map_reply) \
4389 _(one_use_petr_reply) \
4390 _(one_stats_enable_disable_reply) \
4391 _(one_add_del_l2_arp_entry_reply) \
4392 _(one_stats_flush_reply) \
4393 _(gpe_add_del_fwd_entry_reply) \
4394 _(gpe_enable_disable_reply) \
4395 _(gpe_set_encap_mode_reply) \
4396 _(gpe_add_del_iface_reply) \
4397 _(vxlan_gpe_add_del_tunnel_reply) \
4398 _(af_packet_delete_reply) \
4399 _(policer_classify_set_interface_reply) \
4400 _(netmap_create_reply) \
4401 _(netmap_delete_reply) \
4402 _(set_ipfix_exporter_reply) \
4403 _(set_ipfix_classify_stream_reply) \
4404 _(ipfix_classify_table_add_del_reply) \
4405 _(flow_classify_set_interface_reply) \
4406 _(sw_interface_span_enable_disable_reply) \
4407 _(pg_capture_reply) \
4408 _(pg_enable_disable_reply) \
4409 _(ip_source_and_port_range_check_add_del_reply) \
4410 _(ip_source_and_port_range_check_interface_add_del_reply)\
4411 _(delete_subif_reply) \
4412 _(l2_interface_pbb_tag_rewrite_reply) \
4414 _(feature_enable_disable_reply) \
4415 _(sw_interface_tag_add_del_reply) \
4416 _(sw_interface_set_mtu_reply)
4419 static void vl_api_##n##_t_handler \
4420 (vl_api_##n##_t * mp) \
4422 vat_main_t * vam = &vat_main; \
4423 i32 retval = ntohl(mp->retval); \
4424 if (vam->async_mode) { \
4425 vam->async_errors += (retval < 0); \
4427 vam->retval = retval; \
4428 vam->result_ready = 1; \
4431 foreach_standard_reply_retval_handler;
4435 static void vl_api_##n##_t_handler_json \
4436 (vl_api_##n##_t * mp) \
4438 vat_main_t * vam = &vat_main; \
4439 vat_json_node_t node; \
4440 vat_json_init_object(&node); \
4441 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4442 vat_json_print(vam->ofp, &node); \
4443 vam->retval = ntohl(mp->retval); \
4444 vam->result_ready = 1; \
4446 foreach_standard_reply_retval_handler;
4450 * Table of message reply handlers, must include boilerplate handlers
4454 #define foreach_vpe_api_reply_msg \
4455 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4456 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4457 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4458 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4459 _(CONTROL_PING_REPLY, control_ping_reply) \
4460 _(CLI_REPLY, cli_reply) \
4461 _(CLI_INBAND_REPLY, cli_inband_reply) \
4462 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4463 sw_interface_add_del_address_reply) \
4464 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4465 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4466 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4467 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4468 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4469 sw_interface_set_l2_xconnect_reply) \
4470 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4471 sw_interface_set_l2_bridge_reply) \
4472 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4473 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4474 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
4475 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4476 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
4477 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
4478 _(L2_FLAGS_REPLY, l2_flags_reply) \
4479 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4480 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4481 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4482 _(TAP_DELETE_REPLY, tap_delete_reply) \
4483 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4484 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4485 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4486 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4487 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4488 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4489 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4490 proxy_arp_intfc_enable_disable_reply) \
4491 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4492 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4493 sw_interface_set_unnumbered_reply) \
4494 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4495 _(RESET_VRF_REPLY, reset_vrf_reply) \
4496 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4497 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4498 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4499 _(RESET_FIB_REPLY, reset_fib_reply) \
4500 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4501 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4502 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4503 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4504 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4505 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4506 sw_interface_ip6_enable_disable_reply) \
4507 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4508 sw_interface_ip6_set_link_local_address_reply) \
4509 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
4510 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
4511 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4512 sw_interface_ip6nd_ra_prefix_reply) \
4513 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4514 sw_interface_ip6nd_ra_config_reply) \
4515 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4516 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4517 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4518 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4519 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4520 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4521 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4522 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4523 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4524 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4525 classify_set_interface_ip_table_reply) \
4526 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4527 classify_set_interface_l2_tables_reply) \
4528 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4529 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4530 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4531 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4532 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4533 l2tpv3_interface_enable_disable_reply) \
4534 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4535 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4536 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4537 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4538 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4539 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4540 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4541 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4542 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4543 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4544 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4545 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4546 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4547 _(SHOW_VERSION_REPLY, show_version_reply) \
4548 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
4549 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4550 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4551 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4552 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4553 _(IP4_ARP_EVENT, ip4_arp_event) \
4554 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4555 _(IP6_ND_EVENT, ip6_nd_event) \
4556 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4557 _(IP_ADDRESS_DETAILS, ip_address_details) \
4558 _(IP_DETAILS, ip_details) \
4559 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4560 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4561 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4562 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4563 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4564 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
4565 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4566 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4567 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4568 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4569 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4570 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4571 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4572 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4573 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4574 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4575 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4576 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4577 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4578 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4579 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4580 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4581 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4582 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4583 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4584 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4585 _(MAP_RULE_DETAILS, map_rule_details) \
4586 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4587 _(WANT_STATS_REPLY, want_stats_reply) \
4588 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4589 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4590 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4591 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4592 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4593 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4594 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4595 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4596 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4597 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4598 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4599 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4600 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4601 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4602 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4603 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4604 one_map_register_enable_disable_reply) \
4605 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4606 one_rloc_probe_enable_disable_reply) \
4607 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4608 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
4609 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4610 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4611 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4612 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4613 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4614 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4615 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4616 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4617 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4618 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4619 _(ONE_STATS_DETAILS, one_stats_details) \
4620 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
4621 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
4622 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
4623 show_one_stats_enable_disable_reply) \
4624 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
4625 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
4626 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
4627 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4628 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4629 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4630 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4631 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4632 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
4633 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4634 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4635 gpe_fwd_entry_path_details) \
4636 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4637 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4638 one_add_del_map_request_itr_rlocs_reply) \
4639 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4640 one_get_map_request_itr_rlocs_reply) \
4641 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4642 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
4643 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4644 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4645 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4646 show_one_map_register_state_reply) \
4647 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4648 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4649 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4650 _(POLICER_DETAILS, policer_details) \
4651 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4652 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4653 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4654 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4655 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4656 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4657 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4658 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4659 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4660 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4661 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4662 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4663 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4664 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4665 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4666 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4667 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4668 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4669 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4670 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4671 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4672 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4673 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4674 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4675 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4676 ip_source_and_port_range_check_add_del_reply) \
4677 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4678 ip_source_and_port_range_check_interface_add_del_reply) \
4679 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4680 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4681 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4682 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4683 _(PUNT_REPLY, punt_reply) \
4684 _(IP_FIB_DETAILS, ip_fib_details) \
4685 _(IP6_FIB_DETAILS, ip6_fib_details) \
4686 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4687 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4688 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4689 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4690 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4691 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4693 #define foreach_standalone_reply_msg \
4694 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4695 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
4696 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
4697 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4698 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4699 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4700 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
4709 #define STR_VTR_OP_CASE(op) \
4710 case L2_VTR_ ## op: \
4714 str_vtr_op (u32 vtr_op)
4718 STR_VTR_OP_CASE (DISABLED);
4719 STR_VTR_OP_CASE (PUSH_1);
4720 STR_VTR_OP_CASE (PUSH_2);
4721 STR_VTR_OP_CASE (POP_1);
4722 STR_VTR_OP_CASE (POP_2);
4723 STR_VTR_OP_CASE (TRANSLATE_1_1);
4724 STR_VTR_OP_CASE (TRANSLATE_1_2);
4725 STR_VTR_OP_CASE (TRANSLATE_2_1);
4726 STR_VTR_OP_CASE (TRANSLATE_2_2);
4733 dump_sub_interface_table (vat_main_t * vam)
4735 const sw_interface_subif_t *sub = NULL;
4737 if (vam->json_output)
4740 ("JSON output supported only for VPE API calls and dump_stats_table");
4745 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4746 "Interface", "sw_if_index",
4747 "sub id", "dot1ad", "tags", "outer id",
4748 "inner id", "exact", "default", "outer any", "inner any");
4750 vec_foreach (sub, vam->sw_if_subif_table)
4753 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4754 sub->interface_name,
4756 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4757 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4758 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4759 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4760 if (sub->vtr_op != L2_VTR_DISABLED)
4763 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4764 "tag1: %d tag2: %d ]",
4765 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4766 sub->vtr_tag1, sub->vtr_tag2);
4774 name_sort_cmp (void *a1, void *a2)
4776 name_sort_t *n1 = a1;
4777 name_sort_t *n2 = a2;
4779 return strcmp ((char *) n1->name, (char *) n2->name);
4783 dump_interface_table (vat_main_t * vam)
4786 name_sort_t *nses = 0, *ns;
4788 if (vam->json_output)
4791 ("JSON output supported only for VPE API calls and dump_stats_table");
4796 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4798 vec_add2 (nses, ns, 1);
4799 ns->name = (u8 *)(p->key);
4800 ns->value = (u32) p->value[0];
4804 vec_sort_with_function (nses, name_sort_cmp);
4806 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4807 vec_foreach (ns, nses)
4809 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4816 dump_ip_table (vat_main_t * vam, int is_ipv6)
4818 const ip_details_t *det = NULL;
4819 const ip_address_details_t *address = NULL;
4822 print (vam->ofp, "%-12s", "sw_if_index");
4824 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4831 print (vam->ofp, "%-12d", i);
4832 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4837 vec_foreach (address, det->addr)
4841 is_ipv6 ? format_ip6_address : format_ip4_address,
4842 address->ip, address->prefix_length);
4850 dump_ipv4_table (vat_main_t * vam)
4852 if (vam->json_output)
4855 ("JSON output supported only for VPE API calls and dump_stats_table");
4859 return dump_ip_table (vam, 0);
4863 dump_ipv6_table (vat_main_t * vam)
4865 if (vam->json_output)
4868 ("JSON output supported only for VPE API calls and dump_stats_table");
4872 return dump_ip_table (vam, 1);
4876 counter_type_to_str (u8 counter_type, u8 is_combined)
4880 switch (counter_type)
4882 case VNET_INTERFACE_COUNTER_DROP:
4884 case VNET_INTERFACE_COUNTER_PUNT:
4886 case VNET_INTERFACE_COUNTER_IP4:
4888 case VNET_INTERFACE_COUNTER_IP6:
4890 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4892 case VNET_INTERFACE_COUNTER_RX_MISS:
4894 case VNET_INTERFACE_COUNTER_RX_ERROR:
4896 case VNET_INTERFACE_COUNTER_TX_ERROR:
4899 return "INVALID-COUNTER-TYPE";
4904 switch (counter_type)
4906 case VNET_INTERFACE_COUNTER_RX:
4908 case VNET_INTERFACE_COUNTER_TX:
4911 return "INVALID-COUNTER-TYPE";
4917 dump_stats_table (vat_main_t * vam)
4919 vat_json_node_t node;
4920 vat_json_node_t *msg_array;
4921 vat_json_node_t *msg;
4922 vat_json_node_t *counter_array;
4923 vat_json_node_t *counter;
4924 interface_counter_t c;
4926 ip4_fib_counter_t *c4;
4927 ip6_fib_counter_t *c6;
4928 ip4_nbr_counter_t *n4;
4929 ip6_nbr_counter_t *n6;
4932 if (!vam->json_output)
4934 clib_warning ("dump_stats_table supported only in JSON format");
4938 vat_json_init_object (&node);
4940 /* interface counters */
4941 msg_array = vat_json_object_add (&node, "interface_counters");
4942 vat_json_init_array (msg_array);
4943 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4945 msg = vat_json_array_add (msg_array);
4946 vat_json_init_object (msg);
4947 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4948 (u8 *) counter_type_to_str (i, 0));
4949 vat_json_object_add_int (msg, "is_combined", 0);
4950 counter_array = vat_json_object_add (msg, "data");
4951 vat_json_init_array (counter_array);
4952 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4954 packets = vam->simple_interface_counters[i][j];
4955 vat_json_array_add_uint (counter_array, packets);
4958 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4960 msg = vat_json_array_add (msg_array);
4961 vat_json_init_object (msg);
4962 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4963 (u8 *) counter_type_to_str (i, 1));
4964 vat_json_object_add_int (msg, "is_combined", 1);
4965 counter_array = vat_json_object_add (msg, "data");
4966 vat_json_init_array (counter_array);
4967 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4969 c = vam->combined_interface_counters[i][j];
4970 counter = vat_json_array_add (counter_array);
4971 vat_json_init_object (counter);
4972 vat_json_object_add_uint (counter, "packets", c.packets);
4973 vat_json_object_add_uint (counter, "bytes", c.bytes);
4977 /* ip4 fib counters */
4978 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4979 vat_json_init_array (msg_array);
4980 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4982 msg = vat_json_array_add (msg_array);
4983 vat_json_init_object (msg);
4984 vat_json_object_add_uint (msg, "vrf_id",
4985 vam->ip4_fib_counters_vrf_id_by_index[i]);
4986 counter_array = vat_json_object_add (msg, "c");
4987 vat_json_init_array (counter_array);
4988 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4990 counter = vat_json_array_add (counter_array);
4991 vat_json_init_object (counter);
4992 c4 = &vam->ip4_fib_counters[i][j];
4993 vat_json_object_add_ip4 (counter, "address", c4->address);
4994 vat_json_object_add_uint (counter, "address_length",
4995 c4->address_length);
4996 vat_json_object_add_uint (counter, "packets", c4->packets);
4997 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5001 /* ip6 fib counters */
5002 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5003 vat_json_init_array (msg_array);
5004 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5006 msg = vat_json_array_add (msg_array);
5007 vat_json_init_object (msg);
5008 vat_json_object_add_uint (msg, "vrf_id",
5009 vam->ip6_fib_counters_vrf_id_by_index[i]);
5010 counter_array = vat_json_object_add (msg, "c");
5011 vat_json_init_array (counter_array);
5012 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5014 counter = vat_json_array_add (counter_array);
5015 vat_json_init_object (counter);
5016 c6 = &vam->ip6_fib_counters[i][j];
5017 vat_json_object_add_ip6 (counter, "address", c6->address);
5018 vat_json_object_add_uint (counter, "address_length",
5019 c6->address_length);
5020 vat_json_object_add_uint (counter, "packets", c6->packets);
5021 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5025 /* ip4 nbr counters */
5026 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5027 vat_json_init_array (msg_array);
5028 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5030 msg = vat_json_array_add (msg_array);
5031 vat_json_init_object (msg);
5032 vat_json_object_add_uint (msg, "sw_if_index", i);
5033 counter_array = vat_json_object_add (msg, "c");
5034 vat_json_init_array (counter_array);
5035 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5037 counter = vat_json_array_add (counter_array);
5038 vat_json_init_object (counter);
5039 n4 = &vam->ip4_nbr_counters[i][j];
5040 vat_json_object_add_ip4 (counter, "address", n4->address);
5041 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5042 vat_json_object_add_uint (counter, "packets", n4->packets);
5043 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5047 /* ip6 nbr counters */
5048 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5049 vat_json_init_array (msg_array);
5050 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5052 msg = vat_json_array_add (msg_array);
5053 vat_json_init_object (msg);
5054 vat_json_object_add_uint (msg, "sw_if_index", i);
5055 counter_array = vat_json_object_add (msg, "c");
5056 vat_json_init_array (counter_array);
5057 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5059 counter = vat_json_array_add (counter_array);
5060 vat_json_init_object (counter);
5061 n6 = &vam->ip6_nbr_counters[i][j];
5062 vat_json_object_add_ip6 (counter, "address", n6->address);
5063 vat_json_object_add_uint (counter, "packets", n6->packets);
5064 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5068 vat_json_print (vam->ofp, &node);
5069 vat_json_free (&node);
5075 exec (vat_main_t * vam)
5077 api_main_t *am = &api_main;
5082 unformat_input_t *i = vam->input;
5084 if (vec_len (i->buffer) == 0)
5087 if (vam->exec_mode == 0 && unformat (i, "mode"))
5092 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5102 * Copy cmd into shared memory.
5103 * In order for the CLI command to work, it
5104 * must be a vector ending in \n, not a C-string ending
5107 pthread_mutex_lock (&am->vlib_rp->mutex);
5108 oldheap = svm_push_data_heap (am->vlib_rp);
5110 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
5111 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
5113 svm_pop_heap (oldheap);
5114 pthread_mutex_unlock (&am->vlib_rp->mutex);
5116 mp->cmd_in_shmem = pointer_to_uword (cmd);
5118 timeout = vat_time_now (vam) + 10.0;
5120 while (vat_time_now (vam) < timeout)
5122 if (vam->result_ready == 1)
5125 if (vam->shmem_result != NULL)
5126 print (vam->ofp, "%s", vam->shmem_result);
5127 pthread_mutex_lock (&am->vlib_rp->mutex);
5128 oldheap = svm_push_data_heap (am->vlib_rp);
5130 free_me = (u8 *) vam->shmem_result;
5133 svm_pop_heap (oldheap);
5134 pthread_mutex_unlock (&am->vlib_rp->mutex);
5142 * Future replacement of exec() that passes CLI buffers directly in
5143 * the API messages instead of an additional shared memory area.
5146 exec_inband (vat_main_t * vam)
5148 vl_api_cli_inband_t *mp;
5149 unformat_input_t *i = vam->input;
5152 if (vec_len (i->buffer) == 0)
5155 if (vam->exec_mode == 0 && unformat (i, "mode"))
5160 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5167 * In order for the CLI command to work, it
5168 * must be a vector ending in \n, not a C-string ending
5171 u32 len = vec_len (vam->input->buffer);
5172 M2 (CLI_INBAND, mp, len);
5173 clib_memcpy (mp->cmd, vam->input->buffer, len);
5174 mp->length = htonl (len);
5177 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
5182 api_create_loopback (vat_main_t * vam)
5184 unformat_input_t *i = vam->input;
5185 vl_api_create_loopback_t *mp;
5186 vl_api_create_loopback_instance_t *mp_lbi;
5189 u8 is_specified = 0;
5190 u32 user_instance = 0;
5193 memset (mac_address, 0, sizeof (mac_address));
5195 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5197 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5199 if (unformat (i, "instance %d", &user_instance))
5207 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5208 mp_lbi->is_specified = is_specified;
5210 mp_lbi->user_instance = htonl (user_instance);
5212 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5217 /* Construct the API message */
5218 M (CREATE_LOOPBACK, mp);
5220 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5229 api_delete_loopback (vat_main_t * vam)
5231 unformat_input_t *i = vam->input;
5232 vl_api_delete_loopback_t *mp;
5233 u32 sw_if_index = ~0;
5236 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5238 if (unformat (i, "sw_if_index %d", &sw_if_index))
5244 if (sw_if_index == ~0)
5246 errmsg ("missing sw_if_index");
5250 /* Construct the API message */
5251 M (DELETE_LOOPBACK, mp);
5252 mp->sw_if_index = ntohl (sw_if_index);
5260 api_want_stats (vat_main_t * vam)
5262 unformat_input_t *i = vam->input;
5263 vl_api_want_stats_t *mp;
5267 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5269 if (unformat (i, "enable"))
5271 else if (unformat (i, "disable"))
5279 errmsg ("missing enable|disable");
5284 mp->enable_disable = enable;
5292 api_want_interface_events (vat_main_t * vam)
5294 unformat_input_t *i = vam->input;
5295 vl_api_want_interface_events_t *mp;
5299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5301 if (unformat (i, "enable"))
5303 else if (unformat (i, "disable"))
5311 errmsg ("missing enable|disable");
5315 M (WANT_INTERFACE_EVENTS, mp);
5316 mp->enable_disable = enable;
5318 vam->interface_event_display = enable;
5326 /* Note: non-static, called once to set up the initial intfc table */
5328 api_sw_interface_dump (vat_main_t * vam)
5330 vl_api_sw_interface_dump_t *mp;
5331 vl_api_control_ping_t *mp_ping;
5333 name_sort_t *nses = 0, *ns;
5334 sw_interface_subif_t *sub = NULL;
5337 /* Toss the old name table */
5339 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5341 vec_add2 (nses, ns, 1);
5342 ns->name = (u8 *)(p->key);
5343 ns->value = (u32) p->value[0];
5347 hash_free (vam->sw_if_index_by_interface_name);
5349 vec_foreach (ns, nses) vec_free (ns->name);
5353 vec_foreach (sub, vam->sw_if_subif_table)
5355 vec_free (sub->interface_name);
5357 vec_free (vam->sw_if_subif_table);
5359 /* recreate the interface name hash table */
5360 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5362 /* Get list of ethernets */
5363 M (SW_INTERFACE_DUMP, mp);
5364 mp->name_filter_valid = 1;
5365 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
5368 /* and local / loopback interfaces */
5369 M (SW_INTERFACE_DUMP, mp);
5370 mp->name_filter_valid = 1;
5371 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
5374 /* and packet-generator interfaces */
5375 M (SW_INTERFACE_DUMP, mp);
5376 mp->name_filter_valid = 1;
5377 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
5380 /* and vxlan-gpe tunnel interfaces */
5381 M (SW_INTERFACE_DUMP, mp);
5382 mp->name_filter_valid = 1;
5383 strncpy ((char *) mp->name_filter, "vxlan_gpe",
5384 sizeof (mp->name_filter) - 1);
5387 /* and vxlan tunnel interfaces */
5388 M (SW_INTERFACE_DUMP, mp);
5389 mp->name_filter_valid = 1;
5390 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
5393 /* and host (af_packet) interfaces */
5394 M (SW_INTERFACE_DUMP, mp);
5395 mp->name_filter_valid = 1;
5396 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
5399 /* and l2tpv3 tunnel interfaces */
5400 M (SW_INTERFACE_DUMP, mp);
5401 mp->name_filter_valid = 1;
5402 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
5403 sizeof (mp->name_filter) - 1);
5406 /* and GRE tunnel interfaces */
5407 M (SW_INTERFACE_DUMP, mp);
5408 mp->name_filter_valid = 1;
5409 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
5412 /* and LISP-GPE interfaces */
5413 M (SW_INTERFACE_DUMP, mp);
5414 mp->name_filter_valid = 1;
5415 strncpy ((char *) mp->name_filter, "lisp_gpe",
5416 sizeof (mp->name_filter) - 1);
5419 /* and IPSEC tunnel interfaces */
5420 M (SW_INTERFACE_DUMP, mp);
5421 mp->name_filter_valid = 1;
5422 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
5425 /* Use a control ping for synchronization */
5426 M (CONTROL_PING, mp_ping);
5434 api_sw_interface_set_flags (vat_main_t * vam)
5436 unformat_input_t *i = vam->input;
5437 vl_api_sw_interface_set_flags_t *mp;
5439 u8 sw_if_index_set = 0;
5440 u8 admin_up = 0, link_up = 0;
5443 /* Parse args required to build the message */
5444 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5446 if (unformat (i, "admin-up"))
5448 else if (unformat (i, "admin-down"))
5450 else if (unformat (i, "link-up"))
5452 else if (unformat (i, "link-down"))
5455 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5456 sw_if_index_set = 1;
5457 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5458 sw_if_index_set = 1;
5463 if (sw_if_index_set == 0)
5465 errmsg ("missing interface name or sw_if_index");
5469 /* Construct the API message */
5470 M (SW_INTERFACE_SET_FLAGS, mp);
5471 mp->sw_if_index = ntohl (sw_if_index);
5472 mp->admin_up_down = admin_up;
5473 mp->link_up_down = link_up;
5478 /* Wait for a reply, return the good/bad news... */
5484 api_sw_interface_clear_stats (vat_main_t * vam)
5486 unformat_input_t *i = vam->input;
5487 vl_api_sw_interface_clear_stats_t *mp;
5489 u8 sw_if_index_set = 0;
5492 /* Parse args required to build the message */
5493 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5495 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5496 sw_if_index_set = 1;
5497 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5498 sw_if_index_set = 1;
5503 /* Construct the API message */
5504 M (SW_INTERFACE_CLEAR_STATS, mp);
5506 if (sw_if_index_set == 1)
5507 mp->sw_if_index = ntohl (sw_if_index);
5509 mp->sw_if_index = ~0;
5514 /* Wait for a reply, return the good/bad news... */
5520 api_sw_interface_add_del_address (vat_main_t * vam)
5522 unformat_input_t *i = vam->input;
5523 vl_api_sw_interface_add_del_address_t *mp;
5525 u8 sw_if_index_set = 0;
5526 u8 is_add = 1, del_all = 0;
5527 u32 address_length = 0;
5528 u8 v4_address_set = 0;
5529 u8 v6_address_set = 0;
5530 ip4_address_t v4address;
5531 ip6_address_t v6address;
5534 /* Parse args required to build the message */
5535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5537 if (unformat (i, "del-all"))
5539 else if (unformat (i, "del"))
5542 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5543 sw_if_index_set = 1;
5544 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5545 sw_if_index_set = 1;
5546 else if (unformat (i, "%U/%d",
5547 unformat_ip4_address, &v4address, &address_length))
5549 else if (unformat (i, "%U/%d",
5550 unformat_ip6_address, &v6address, &address_length))
5556 if (sw_if_index_set == 0)
5558 errmsg ("missing interface name or sw_if_index");
5561 if (v4_address_set && v6_address_set)
5563 errmsg ("both v4 and v6 addresses set");
5566 if (!v4_address_set && !v6_address_set && !del_all)
5568 errmsg ("no addresses set");
5572 /* Construct the API message */
5573 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5575 mp->sw_if_index = ntohl (sw_if_index);
5576 mp->is_add = is_add;
5577 mp->del_all = del_all;
5581 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5585 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5587 mp->address_length = address_length;
5592 /* Wait for a reply, return good/bad news */
5598 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5600 unformat_input_t *i = vam->input;
5601 vl_api_sw_interface_set_mpls_enable_t *mp;
5603 u8 sw_if_index_set = 0;
5607 /* Parse args required to build the message */
5608 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5610 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5611 sw_if_index_set = 1;
5612 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5613 sw_if_index_set = 1;
5614 else if (unformat (i, "disable"))
5616 else if (unformat (i, "dis"))
5622 if (sw_if_index_set == 0)
5624 errmsg ("missing interface name or sw_if_index");
5628 /* Construct the API message */
5629 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5631 mp->sw_if_index = ntohl (sw_if_index);
5632 mp->enable = enable;
5637 /* Wait for a reply... */
5643 api_sw_interface_set_table (vat_main_t * vam)
5645 unformat_input_t *i = vam->input;
5646 vl_api_sw_interface_set_table_t *mp;
5647 u32 sw_if_index, vrf_id = 0;
5648 u8 sw_if_index_set = 0;
5652 /* Parse args required to build the message */
5653 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5655 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5656 sw_if_index_set = 1;
5657 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5658 sw_if_index_set = 1;
5659 else if (unformat (i, "vrf %d", &vrf_id))
5661 else if (unformat (i, "ipv6"))
5667 if (sw_if_index_set == 0)
5669 errmsg ("missing interface name or sw_if_index");
5673 /* Construct the API message */
5674 M (SW_INTERFACE_SET_TABLE, mp);
5676 mp->sw_if_index = ntohl (sw_if_index);
5677 mp->is_ipv6 = is_ipv6;
5678 mp->vrf_id = ntohl (vrf_id);
5683 /* Wait for a reply... */
5688 static void vl_api_sw_interface_get_table_reply_t_handler
5689 (vl_api_sw_interface_get_table_reply_t * mp)
5691 vat_main_t *vam = &vat_main;
5693 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5695 vam->retval = ntohl (mp->retval);
5696 vam->result_ready = 1;
5700 static void vl_api_sw_interface_get_table_reply_t_handler_json
5701 (vl_api_sw_interface_get_table_reply_t * mp)
5703 vat_main_t *vam = &vat_main;
5704 vat_json_node_t node;
5706 vat_json_init_object (&node);
5707 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5708 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5710 vat_json_print (vam->ofp, &node);
5711 vat_json_free (&node);
5713 vam->retval = ntohl (mp->retval);
5714 vam->result_ready = 1;
5718 api_sw_interface_get_table (vat_main_t * vam)
5720 unformat_input_t *i = vam->input;
5721 vl_api_sw_interface_get_table_t *mp;
5723 u8 sw_if_index_set = 0;
5727 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5729 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5730 sw_if_index_set = 1;
5731 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5732 sw_if_index_set = 1;
5733 else if (unformat (i, "ipv6"))
5739 if (sw_if_index_set == 0)
5741 errmsg ("missing interface name or sw_if_index");
5745 M (SW_INTERFACE_GET_TABLE, mp);
5746 mp->sw_if_index = htonl (sw_if_index);
5747 mp->is_ipv6 = is_ipv6;
5755 api_sw_interface_set_vpath (vat_main_t * vam)
5757 unformat_input_t *i = vam->input;
5758 vl_api_sw_interface_set_vpath_t *mp;
5759 u32 sw_if_index = 0;
5760 u8 sw_if_index_set = 0;
5764 /* Parse args required to build the message */
5765 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5767 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5768 sw_if_index_set = 1;
5769 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5770 sw_if_index_set = 1;
5771 else if (unformat (i, "enable"))
5773 else if (unformat (i, "disable"))
5779 if (sw_if_index_set == 0)
5781 errmsg ("missing interface name or sw_if_index");
5785 /* Construct the API message */
5786 M (SW_INTERFACE_SET_VPATH, mp);
5788 mp->sw_if_index = ntohl (sw_if_index);
5789 mp->enable = is_enable;
5794 /* Wait for a reply... */
5800 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5802 unformat_input_t *i = vam->input;
5803 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5804 u32 sw_if_index = 0;
5805 u8 sw_if_index_set = 0;
5810 /* Parse args required to build the message */
5811 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5813 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5814 sw_if_index_set = 1;
5815 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5816 sw_if_index_set = 1;
5817 else if (unformat (i, "enable"))
5819 else if (unformat (i, "disable"))
5821 else if (unformat (i, "ip4"))
5823 else if (unformat (i, "ip6"))
5829 if (sw_if_index_set == 0)
5831 errmsg ("missing interface name or sw_if_index");
5835 /* Construct the API message */
5836 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5838 mp->sw_if_index = ntohl (sw_if_index);
5839 mp->enable = is_enable;
5840 mp->is_ipv6 = is_ipv6;
5845 /* Wait for a reply... */
5851 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5853 unformat_input_t *i = vam->input;
5854 vl_api_sw_interface_set_l2_xconnect_t *mp;
5856 u8 rx_sw_if_index_set = 0;
5858 u8 tx_sw_if_index_set = 0;
5862 /* Parse args required to build the message */
5863 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5865 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5866 rx_sw_if_index_set = 1;
5867 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5868 tx_sw_if_index_set = 1;
5869 else if (unformat (i, "rx"))
5871 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5873 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5875 rx_sw_if_index_set = 1;
5880 else if (unformat (i, "tx"))
5882 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5884 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5886 tx_sw_if_index_set = 1;
5891 else if (unformat (i, "enable"))
5893 else if (unformat (i, "disable"))
5899 if (rx_sw_if_index_set == 0)
5901 errmsg ("missing rx interface name or rx_sw_if_index");
5905 if (enable && (tx_sw_if_index_set == 0))
5907 errmsg ("missing tx interface name or tx_sw_if_index");
5911 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5913 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5914 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5915 mp->enable = enable;
5923 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5925 unformat_input_t *i = vam->input;
5926 vl_api_sw_interface_set_l2_bridge_t *mp;
5928 u8 rx_sw_if_index_set = 0;
5936 /* Parse args required to build the message */
5937 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5939 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5940 rx_sw_if_index_set = 1;
5941 else if (unformat (i, "bd_id %d", &bd_id))
5945 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5946 rx_sw_if_index_set = 1;
5947 else if (unformat (i, "shg %d", &shg))
5949 else if (unformat (i, "bvi"))
5951 else if (unformat (i, "enable"))
5953 else if (unformat (i, "disable"))
5959 if (rx_sw_if_index_set == 0)
5961 errmsg ("missing rx interface name or sw_if_index");
5965 if (enable && (bd_id_set == 0))
5967 errmsg ("missing bridge domain");
5971 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
5973 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5974 mp->bd_id = ntohl (bd_id);
5977 mp->enable = enable;
5985 api_bridge_domain_dump (vat_main_t * vam)
5987 unformat_input_t *i = vam->input;
5988 vl_api_bridge_domain_dump_t *mp;
5989 vl_api_control_ping_t *mp_ping;
5993 /* Parse args required to build the message */
5994 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5996 if (unformat (i, "bd_id %d", &bd_id))
6002 M (BRIDGE_DOMAIN_DUMP, mp);
6003 mp->bd_id = ntohl (bd_id);
6006 /* Use a control ping for synchronization */
6007 M (CONTROL_PING, mp_ping);
6015 api_bridge_domain_add_del (vat_main_t * vam)
6017 unformat_input_t *i = vam->input;
6018 vl_api_bridge_domain_add_del_t *mp;
6021 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6025 /* Parse args required to build the message */
6026 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6028 if (unformat (i, "bd_id %d", &bd_id))
6030 else if (unformat (i, "flood %d", &flood))
6032 else if (unformat (i, "uu-flood %d", &uu_flood))
6034 else if (unformat (i, "forward %d", &forward))
6036 else if (unformat (i, "learn %d", &learn))
6038 else if (unformat (i, "arp-term %d", &arp_term))
6040 else if (unformat (i, "mac-age %d", &mac_age))
6042 else if (unformat (i, "del"))
6045 flood = uu_flood = forward = learn = 0;
6053 errmsg ("missing bridge domain");
6059 errmsg ("mac age must be less than 256 ");
6063 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6065 mp->bd_id = ntohl (bd_id);
6067 mp->uu_flood = uu_flood;
6068 mp->forward = forward;
6070 mp->arp_term = arp_term;
6071 mp->is_add = is_add;
6072 mp->mac_age = (u8) mac_age;
6080 api_l2fib_flush_bd (vat_main_t * vam)
6082 unformat_input_t *i = vam->input;
6083 vl_api_l2fib_flush_bd_t *mp;
6087 /* Parse args required to build the message */
6088 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6090 if (unformat (i, "bd_id %d", &bd_id));
6097 errmsg ("missing bridge domain");
6101 M (L2FIB_FLUSH_BD, mp);
6103 mp->bd_id = htonl (bd_id);
6111 api_l2fib_flush_int (vat_main_t * vam)
6113 unformat_input_t *i = vam->input;
6114 vl_api_l2fib_flush_int_t *mp;
6115 u32 sw_if_index = ~0;
6118 /* Parse args required to build the message */
6119 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6121 if (unformat (i, "sw_if_index %d", &sw_if_index));
6123 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6128 if (sw_if_index == ~0)
6130 errmsg ("missing interface name or sw_if_index");
6134 M (L2FIB_FLUSH_INT, mp);
6136 mp->sw_if_index = ntohl (sw_if_index);
6144 api_l2fib_add_del (vat_main_t * vam)
6146 unformat_input_t *i = vam->input;
6147 vl_api_l2fib_add_del_t *mp;
6153 u32 sw_if_index = ~0;
6154 u8 sw_if_index_set = 0;
6163 /* Parse args required to build the message */
6164 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6166 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6168 else if (unformat (i, "bd_id %d", &bd_id))
6170 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6171 sw_if_index_set = 1;
6172 else if (unformat (i, "sw_if"))
6174 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6177 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6178 sw_if_index_set = 1;
6183 else if (unformat (i, "static"))
6185 else if (unformat (i, "filter"))
6190 else if (unformat (i, "bvi"))
6195 else if (unformat (i, "del"))
6197 else if (unformat (i, "count %d", &count))
6205 errmsg ("missing mac address");
6211 errmsg ("missing bridge domain");
6215 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6217 errmsg ("missing interface name or sw_if_index");
6223 /* Turn on async mode */
6224 vam->async_mode = 1;
6225 vam->async_errors = 0;
6226 before = vat_time_now (vam);
6229 for (j = 0; j < count; j++)
6231 M (L2FIB_ADD_DEL, mp);
6234 mp->bd_id = ntohl (bd_id);
6235 mp->is_add = is_add;
6239 mp->sw_if_index = ntohl (sw_if_index);
6240 mp->static_mac = static_mac;
6241 mp->filter_mac = filter_mac;
6242 mp->bvi_mac = bvi_mac;
6244 increment_mac_address (&mac);
6251 vl_api_control_ping_t *mp_ping;
6254 /* Shut off async mode */
6255 vam->async_mode = 0;
6257 M (CONTROL_PING, mp_ping);
6260 timeout = vat_time_now (vam) + 1.0;
6261 while (vat_time_now (vam) < timeout)
6262 if (vam->result_ready == 1)
6267 if (vam->retval == -99)
6270 if (vam->async_errors > 0)
6272 errmsg ("%d asynchronous errors", vam->async_errors);
6275 vam->async_errors = 0;
6276 after = vat_time_now (vam);
6278 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6279 count, after - before, count / (after - before));
6285 /* Wait for a reply... */
6289 /* Return the good/bad news */
6290 return (vam->retval);
6294 api_bridge_domain_set_mac_age (vat_main_t * vam)
6296 unformat_input_t *i = vam->input;
6297 vl_api_bridge_domain_set_mac_age_t *mp;
6302 /* Parse args required to build the message */
6303 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6305 if (unformat (i, "bd_id %d", &bd_id));
6306 else if (unformat (i, "mac-age %d", &mac_age));
6313 errmsg ("missing bridge domain");
6319 errmsg ("mac age must be less than 256 ");
6323 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6325 mp->bd_id = htonl (bd_id);
6326 mp->mac_age = (u8) mac_age;
6334 api_l2_flags (vat_main_t * vam)
6336 unformat_input_t *i = vam->input;
6337 vl_api_l2_flags_t *mp;
6339 u32 feature_bitmap = 0;
6340 u8 sw_if_index_set = 0;
6343 /* Parse args required to build the message */
6344 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6346 if (unformat (i, "sw_if_index %d", &sw_if_index))
6347 sw_if_index_set = 1;
6348 else if (unformat (i, "sw_if"))
6350 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6353 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6354 sw_if_index_set = 1;
6359 else if (unformat (i, "learn"))
6360 feature_bitmap |= L2INPUT_FEAT_LEARN;
6361 else if (unformat (i, "forward"))
6362 feature_bitmap |= L2INPUT_FEAT_FWD;
6363 else if (unformat (i, "flood"))
6364 feature_bitmap |= L2INPUT_FEAT_FLOOD;
6365 else if (unformat (i, "uu-flood"))
6366 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
6371 if (sw_if_index_set == 0)
6373 errmsg ("missing interface name or sw_if_index");
6379 mp->sw_if_index = ntohl (sw_if_index);
6380 mp->feature_bitmap = ntohl (feature_bitmap);
6388 api_bridge_flags (vat_main_t * vam)
6390 unformat_input_t *i = vam->input;
6391 vl_api_bridge_flags_t *mp;
6398 /* Parse args required to build the message */
6399 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6401 if (unformat (i, "bd_id %d", &bd_id))
6403 else if (unformat (i, "learn"))
6405 else if (unformat (i, "forward"))
6407 else if (unformat (i, "flood"))
6409 else if (unformat (i, "uu-flood"))
6410 flags |= L2_UU_FLOOD;
6411 else if (unformat (i, "arp-term"))
6412 flags |= L2_ARP_TERM;
6413 else if (unformat (i, "off"))
6415 else if (unformat (i, "disable"))
6423 errmsg ("missing bridge domain");
6427 M (BRIDGE_FLAGS, mp);
6429 mp->bd_id = ntohl (bd_id);
6430 mp->feature_bitmap = ntohl (flags);
6431 mp->is_set = is_set;
6439 api_bd_ip_mac_add_del (vat_main_t * vam)
6441 unformat_input_t *i = vam->input;
6442 vl_api_bd_ip_mac_add_del_t *mp;
6449 ip4_address_t v4addr;
6450 ip6_address_t v6addr;
6455 /* Parse args required to build the message */
6456 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6458 if (unformat (i, "bd_id %d", &bd_id))
6462 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6466 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6471 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6475 else if (unformat (i, "del"))
6483 errmsg ("missing bridge domain");
6486 else if (ip_set == 0)
6488 errmsg ("missing IP address");
6491 else if (mac_set == 0)
6493 errmsg ("missing MAC address");
6497 M (BD_IP_MAC_ADD_DEL, mp);
6499 mp->bd_id = ntohl (bd_id);
6500 mp->is_ipv6 = is_ipv6;
6501 mp->is_add = is_add;
6503 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6505 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6506 clib_memcpy (mp->mac_address, macaddr, 6);
6513 api_tap_connect (vat_main_t * vam)
6515 unformat_input_t *i = vam->input;
6516 vl_api_tap_connect_t *mp;
6522 ip4_address_t ip4_address;
6524 int ip4_address_set = 0;
6525 ip6_address_t ip6_address;
6527 int ip6_address_set = 0;
6530 memset (mac_address, 0, sizeof (mac_address));
6532 /* Parse args required to build the message */
6533 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6535 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6539 else if (unformat (i, "random-mac"))
6541 else if (unformat (i, "tapname %s", &tap_name))
6543 else if (unformat (i, "tag %s", &tag))
6545 else if (unformat (i, "address %U/%d",
6546 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6547 ip4_address_set = 1;
6548 else if (unformat (i, "address %U/%d",
6549 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6550 ip6_address_set = 1;
6557 errmsg ("missing tap name");
6560 if (vec_len (tap_name) > 63)
6562 errmsg ("tap name too long");
6565 vec_add1 (tap_name, 0);
6567 if (vec_len (tag) > 63)
6569 errmsg ("tag too long");
6573 /* Construct the API message */
6574 M (TAP_CONNECT, mp);
6576 mp->use_random_mac = random_mac;
6577 clib_memcpy (mp->mac_address, mac_address, 6);
6578 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6580 clib_memcpy (mp->tag, tag, vec_len (tag));
6582 if (ip4_address_set)
6584 mp->ip4_address_set = 1;
6585 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6586 mp->ip4_mask_width = ip4_mask_width;
6588 if (ip6_address_set)
6590 mp->ip6_address_set = 1;
6591 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6592 mp->ip6_mask_width = ip6_mask_width;
6595 vec_free (tap_name);
6601 /* Wait for a reply... */
6607 api_tap_modify (vat_main_t * vam)
6609 unformat_input_t *i = vam->input;
6610 vl_api_tap_modify_t *mp;
6615 u32 sw_if_index = ~0;
6616 u8 sw_if_index_set = 0;
6619 memset (mac_address, 0, sizeof (mac_address));
6621 /* Parse args required to build the message */
6622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6624 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6625 sw_if_index_set = 1;
6626 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6627 sw_if_index_set = 1;
6628 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6632 else if (unformat (i, "random-mac"))
6634 else if (unformat (i, "tapname %s", &tap_name))
6640 if (sw_if_index_set == 0)
6642 errmsg ("missing vpp interface name");
6647 errmsg ("missing tap name");
6650 if (vec_len (tap_name) > 63)
6652 errmsg ("tap name too long");
6654 vec_add1 (tap_name, 0);
6656 /* Construct the API message */
6659 mp->use_random_mac = random_mac;
6660 mp->sw_if_index = ntohl (sw_if_index);
6661 clib_memcpy (mp->mac_address, mac_address, 6);
6662 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6663 vec_free (tap_name);
6668 /* Wait for a reply... */
6674 api_tap_delete (vat_main_t * vam)
6676 unformat_input_t *i = vam->input;
6677 vl_api_tap_delete_t *mp;
6678 u32 sw_if_index = ~0;
6679 u8 sw_if_index_set = 0;
6682 /* Parse args required to build the message */
6683 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6685 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6686 sw_if_index_set = 1;
6687 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6688 sw_if_index_set = 1;
6693 if (sw_if_index_set == 0)
6695 errmsg ("missing vpp interface name");
6699 /* Construct the API message */
6702 mp->sw_if_index = ntohl (sw_if_index);
6707 /* Wait for a reply... */
6713 api_ip_add_del_route (vat_main_t * vam)
6715 unformat_input_t *i = vam->input;
6716 vl_api_ip_add_del_route_t *mp;
6717 u32 sw_if_index = ~0, vrf_id = 0;
6719 u8 is_local = 0, is_drop = 0;
6720 u8 is_unreach = 0, is_prohibit = 0;
6721 u8 create_vrf_if_needed = 0;
6723 u32 next_hop_weight = 1;
6725 u8 is_multipath = 0;
6727 u8 address_length_set = 0;
6728 u32 next_hop_table_id = 0;
6729 u32 resolve_attempts = 0;
6730 u32 dst_address_length = 0;
6731 u8 next_hop_set = 0;
6732 ip4_address_t v4_dst_address, v4_next_hop_address;
6733 ip6_address_t v6_dst_address, v6_next_hop_address;
6737 u32 random_add_del = 0;
6738 u32 *random_vector = 0;
6740 u32 random_seed = 0xdeaddabe;
6741 u32 classify_table_index = ~0;
6743 u8 resolve_host = 0, resolve_attached = 0;
6744 mpls_label_t *next_hop_out_label_stack = NULL;
6745 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6746 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6748 /* Parse args required to build the message */
6749 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6751 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6753 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6755 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6760 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6765 else if (unformat (i, "/%d", &dst_address_length))
6767 address_length_set = 1;
6770 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6771 &v4_next_hop_address))
6775 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6776 &v6_next_hop_address))
6780 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6782 else if (unformat (i, "weight %d", &next_hop_weight))
6784 else if (unformat (i, "drop"))
6788 else if (unformat (i, "null-send-unreach"))
6792 else if (unformat (i, "null-send-prohibit"))
6796 else if (unformat (i, "local"))
6800 else if (unformat (i, "classify %d", &classify_table_index))
6804 else if (unformat (i, "del"))
6806 else if (unformat (i, "add"))
6808 else if (unformat (i, "not-last"))
6810 else if (unformat (i, "resolve-via-host"))
6812 else if (unformat (i, "resolve-via-attached"))
6813 resolve_attached = 1;
6814 else if (unformat (i, "multipath"))
6816 else if (unformat (i, "vrf %d", &vrf_id))
6818 else if (unformat (i, "create-vrf"))
6819 create_vrf_if_needed = 1;
6820 else if (unformat (i, "count %d", &count))
6822 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6824 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6826 else if (unformat (i, "out-label %d", &next_hop_out_label))
6827 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6828 else if (unformat (i, "via-label %d", &next_hop_via_label))
6830 else if (unformat (i, "random"))
6832 else if (unformat (i, "seed %d", &random_seed))
6836 clib_warning ("parse error '%U'", format_unformat_error, i);
6841 if (!next_hop_set && !is_drop && !is_local &&
6842 !is_classify && !is_unreach && !is_prohibit &&
6843 MPLS_LABEL_INVALID == next_hop_via_label)
6846 ("next hop / local / drop / unreach / prohibit / classify not set");
6850 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6852 errmsg ("next hop and next-hop via label set");
6855 if (address_set == 0)
6857 errmsg ("missing addresses");
6861 if (address_length_set == 0)
6863 errmsg ("missing address length");
6867 /* Generate a pile of unique, random routes */
6870 u32 this_random_address;
6871 random_hash = hash_create (count, sizeof (uword));
6873 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6874 for (j = 0; j <= count; j++)
6878 this_random_address = random_u32 (&random_seed);
6879 this_random_address =
6880 clib_host_to_net_u32 (this_random_address);
6882 while (hash_get (random_hash, this_random_address));
6883 vec_add1 (random_vector, this_random_address);
6884 hash_set (random_hash, this_random_address, 1);
6886 hash_free (random_hash);
6887 v4_dst_address.as_u32 = random_vector[0];
6892 /* Turn on async mode */
6893 vam->async_mode = 1;
6894 vam->async_errors = 0;
6895 before = vat_time_now (vam);
6898 for (j = 0; j < count; j++)
6900 /* Construct the API message */
6901 M2 (IP_ADD_DEL_ROUTE, mp,
6902 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6904 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6905 mp->table_id = ntohl (vrf_id);
6906 mp->create_vrf_if_needed = create_vrf_if_needed;
6908 mp->is_add = is_add;
6909 mp->is_drop = is_drop;
6910 mp->is_unreach = is_unreach;
6911 mp->is_prohibit = is_prohibit;
6912 mp->is_ipv6 = is_ipv6;
6913 mp->is_local = is_local;
6914 mp->is_classify = is_classify;
6915 mp->is_multipath = is_multipath;
6916 mp->is_resolve_host = resolve_host;
6917 mp->is_resolve_attached = resolve_attached;
6918 mp->not_last = not_last;
6919 mp->next_hop_weight = next_hop_weight;
6920 mp->dst_address_length = dst_address_length;
6921 mp->next_hop_table_id = ntohl (next_hop_table_id);
6922 mp->classify_table_index = ntohl (classify_table_index);
6923 mp->next_hop_via_label = ntohl (next_hop_via_label);
6924 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6925 if (0 != mp->next_hop_n_out_labels)
6927 memcpy (mp->next_hop_out_label_stack,
6928 next_hop_out_label_stack,
6929 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6930 vec_free (next_hop_out_label_stack);
6935 clib_memcpy (mp->dst_address, &v6_dst_address,
6936 sizeof (v6_dst_address));
6938 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6939 sizeof (v6_next_hop_address));
6940 increment_v6_address (&v6_dst_address);
6944 clib_memcpy (mp->dst_address, &v4_dst_address,
6945 sizeof (v4_dst_address));
6947 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6948 sizeof (v4_next_hop_address));
6950 v4_dst_address.as_u32 = random_vector[j + 1];
6952 increment_v4_address (&v4_dst_address);
6956 /* If we receive SIGTERM, stop now... */
6961 /* When testing multiple add/del ops, use a control-ping to sync */
6964 vl_api_control_ping_t *mp_ping;
6968 /* Shut off async mode */
6969 vam->async_mode = 0;
6971 M (CONTROL_PING, mp_ping);
6974 timeout = vat_time_now (vam) + 1.0;
6975 while (vat_time_now (vam) < timeout)
6976 if (vam->result_ready == 1)
6981 if (vam->retval == -99)
6984 if (vam->async_errors > 0)
6986 errmsg ("%d asynchronous errors", vam->async_errors);
6989 vam->async_errors = 0;
6990 after = vat_time_now (vam);
6992 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6996 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6997 count, after - before, count / (after - before));
7003 /* Wait for a reply... */
7008 /* Return the good/bad news */
7009 return (vam->retval);
7013 api_ip_mroute_add_del (vat_main_t * vam)
7015 unformat_input_t *i = vam->input;
7016 vl_api_ip_mroute_add_del_t *mp;
7017 u32 sw_if_index = ~0, vrf_id = 0;
7020 u8 create_vrf_if_needed = 0;
7023 u32 grp_address_length = 0;
7024 ip4_address_t v4_grp_address, v4_src_address;
7025 ip6_address_t v6_grp_address, v6_src_address;
7026 mfib_itf_flags_t iflags = 0;
7027 mfib_entry_flags_t eflags = 0;
7030 /* Parse args required to build the message */
7031 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7033 if (unformat (i, "sw_if_index %d", &sw_if_index))
7035 else if (unformat (i, "%U %U",
7036 unformat_ip4_address, &v4_src_address,
7037 unformat_ip4_address, &v4_grp_address))
7039 grp_address_length = 64;
7043 else if (unformat (i, "%U %U",
7044 unformat_ip6_address, &v6_src_address,
7045 unformat_ip6_address, &v6_grp_address))
7047 grp_address_length = 256;
7051 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7053 memset (&v4_src_address, 0, sizeof (v4_src_address));
7054 grp_address_length = 32;
7058 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7060 memset (&v6_src_address, 0, sizeof (v6_src_address));
7061 grp_address_length = 128;
7065 else if (unformat (i, "/%d", &grp_address_length))
7067 else if (unformat (i, "local"))
7071 else if (unformat (i, "del"))
7073 else if (unformat (i, "add"))
7075 else if (unformat (i, "vrf %d", &vrf_id))
7077 else if (unformat (i, "create-vrf"))
7078 create_vrf_if_needed = 1;
7079 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7081 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7085 clib_warning ("parse error '%U'", format_unformat_error, i);
7090 if (address_set == 0)
7092 errmsg ("missing addresses\n");
7096 /* Construct the API message */
7097 M (IP_MROUTE_ADD_DEL, mp);
7099 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7100 mp->table_id = ntohl (vrf_id);
7101 mp->create_vrf_if_needed = create_vrf_if_needed;
7103 mp->is_add = is_add;
7104 mp->is_ipv6 = is_ipv6;
7105 mp->is_local = is_local;
7106 mp->itf_flags = ntohl (iflags);
7107 mp->entry_flags = ntohl (eflags);
7108 mp->grp_address_length = grp_address_length;
7109 mp->grp_address_length = ntohs (mp->grp_address_length);
7113 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7114 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7118 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7119 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7125 /* Wait for a reply... */
7131 api_mpls_route_add_del (vat_main_t * vam)
7133 unformat_input_t *i = vam->input;
7134 vl_api_mpls_route_add_del_t *mp;
7135 u32 sw_if_index = ~0, table_id = 0;
7136 u8 create_table_if_needed = 0;
7138 u32 next_hop_weight = 1;
7139 u8 is_multipath = 0;
7140 u32 next_hop_table_id = 0;
7141 u8 next_hop_set = 0;
7142 ip4_address_t v4_next_hop_address = {
7145 ip6_address_t v6_next_hop_address = { {0} };
7149 u32 classify_table_index = ~0;
7151 u8 resolve_host = 0, resolve_attached = 0;
7152 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7153 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7154 mpls_label_t *next_hop_out_label_stack = NULL;
7155 mpls_label_t local_label = MPLS_LABEL_INVALID;
7157 u8 next_hop_proto_is_ip4 = 1;
7159 /* Parse args required to build the message */
7160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7162 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7164 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7166 else if (unformat (i, "%d", &local_label))
7168 else if (unformat (i, "eos"))
7170 else if (unformat (i, "non-eos"))
7172 else if (unformat (i, "via %U", unformat_ip4_address,
7173 &v4_next_hop_address))
7176 next_hop_proto_is_ip4 = 1;
7178 else if (unformat (i, "via %U", unformat_ip6_address,
7179 &v6_next_hop_address))
7182 next_hop_proto_is_ip4 = 0;
7184 else if (unformat (i, "weight %d", &next_hop_weight))
7186 else if (unformat (i, "create-table"))
7187 create_table_if_needed = 1;
7188 else if (unformat (i, "classify %d", &classify_table_index))
7192 else if (unformat (i, "del"))
7194 else if (unformat (i, "add"))
7196 else if (unformat (i, "resolve-via-host"))
7198 else if (unformat (i, "resolve-via-attached"))
7199 resolve_attached = 1;
7200 else if (unformat (i, "multipath"))
7202 else if (unformat (i, "count %d", &count))
7204 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
7207 next_hop_proto_is_ip4 = 1;
7209 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
7212 next_hop_proto_is_ip4 = 0;
7214 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7216 else if (unformat (i, "via-label %d", &next_hop_via_label))
7218 else if (unformat (i, "out-label %d", &next_hop_out_label))
7219 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7222 clib_warning ("parse error '%U'", format_unformat_error, i);
7227 if (!next_hop_set && !is_classify)
7229 errmsg ("next hop / classify not set");
7233 if (MPLS_LABEL_INVALID == local_label)
7235 errmsg ("missing label");
7241 /* Turn on async mode */
7242 vam->async_mode = 1;
7243 vam->async_errors = 0;
7244 before = vat_time_now (vam);
7247 for (j = 0; j < count; j++)
7249 /* Construct the API message */
7250 M2 (MPLS_ROUTE_ADD_DEL, mp,
7251 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7253 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
7254 mp->mr_table_id = ntohl (table_id);
7255 mp->mr_create_table_if_needed = create_table_if_needed;
7257 mp->mr_is_add = is_add;
7258 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7259 mp->mr_is_classify = is_classify;
7260 mp->mr_is_multipath = is_multipath;
7261 mp->mr_is_resolve_host = resolve_host;
7262 mp->mr_is_resolve_attached = resolve_attached;
7263 mp->mr_next_hop_weight = next_hop_weight;
7264 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
7265 mp->mr_classify_table_index = ntohl (classify_table_index);
7266 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
7267 mp->mr_label = ntohl (local_label);
7268 mp->mr_eos = is_eos;
7270 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7271 if (0 != mp->mr_next_hop_n_out_labels)
7273 memcpy (mp->mr_next_hop_out_label_stack,
7274 next_hop_out_label_stack,
7275 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7276 vec_free (next_hop_out_label_stack);
7281 if (next_hop_proto_is_ip4)
7283 clib_memcpy (mp->mr_next_hop,
7284 &v4_next_hop_address,
7285 sizeof (v4_next_hop_address));
7289 clib_memcpy (mp->mr_next_hop,
7290 &v6_next_hop_address,
7291 sizeof (v6_next_hop_address));
7298 /* If we receive SIGTERM, stop now... */
7303 /* When testing multiple add/del ops, use a control-ping to sync */
7306 vl_api_control_ping_t *mp_ping;
7310 /* Shut off async mode */
7311 vam->async_mode = 0;
7313 M (CONTROL_PING, mp_ping);
7316 timeout = vat_time_now (vam) + 1.0;
7317 while (vat_time_now (vam) < timeout)
7318 if (vam->result_ready == 1)
7323 if (vam->retval == -99)
7326 if (vam->async_errors > 0)
7328 errmsg ("%d asynchronous errors", vam->async_errors);
7331 vam->async_errors = 0;
7332 after = vat_time_now (vam);
7334 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7338 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7339 count, after - before, count / (after - before));
7345 /* Wait for a reply... */
7350 /* Return the good/bad news */
7351 return (vam->retval);
7355 api_mpls_ip_bind_unbind (vat_main_t * vam)
7357 unformat_input_t *i = vam->input;
7358 vl_api_mpls_ip_bind_unbind_t *mp;
7359 u32 ip_table_id = 0;
7360 u8 create_table_if_needed = 0;
7363 ip4_address_t v4_address;
7364 ip6_address_t v6_address;
7367 mpls_label_t local_label = MPLS_LABEL_INVALID;
7370 /* Parse args required to build the message */
7371 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7373 if (unformat (i, "%U/%d", unformat_ip4_address,
7374 &v4_address, &address_length))
7379 else if (unformat (i, "%U/%d", unformat_ip6_address,
7380 &v6_address, &address_length))
7385 else if (unformat (i, "%d", &local_label))
7387 else if (unformat (i, "create-table"))
7388 create_table_if_needed = 1;
7389 else if (unformat (i, "table-id %d", &ip_table_id))
7391 else if (unformat (i, "unbind"))
7393 else if (unformat (i, "bind"))
7397 clib_warning ("parse error '%U'", format_unformat_error, i);
7404 errmsg ("IP addres not set");
7408 if (MPLS_LABEL_INVALID == local_label)
7410 errmsg ("missing label");
7414 /* Construct the API message */
7415 M (MPLS_IP_BIND_UNBIND, mp);
7417 mp->mb_create_table_if_needed = create_table_if_needed;
7418 mp->mb_is_bind = is_bind;
7419 mp->mb_is_ip4 = is_ip4;
7420 mp->mb_ip_table_id = ntohl (ip_table_id);
7421 mp->mb_mpls_table_id = 0;
7422 mp->mb_label = ntohl (local_label);
7423 mp->mb_address_length = address_length;
7426 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7428 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7433 /* Wait for a reply... */
7439 api_proxy_arp_add_del (vat_main_t * vam)
7441 unformat_input_t *i = vam->input;
7442 vl_api_proxy_arp_add_del_t *mp;
7445 ip4_address_t lo, hi;
7449 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7451 if (unformat (i, "vrf %d", &vrf_id))
7453 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7454 unformat_ip4_address, &hi))
7456 else if (unformat (i, "del"))
7460 clib_warning ("parse error '%U'", format_unformat_error, i);
7467 errmsg ("address range not set");
7471 M (PROXY_ARP_ADD_DEL, mp);
7473 mp->vrf_id = ntohl (vrf_id);
7474 mp->is_add = is_add;
7475 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7476 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7484 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7486 unformat_input_t *i = vam->input;
7487 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7490 u8 sw_if_index_set = 0;
7493 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7495 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7496 sw_if_index_set = 1;
7497 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7498 sw_if_index_set = 1;
7499 else if (unformat (i, "enable"))
7501 else if (unformat (i, "disable"))
7505 clib_warning ("parse error '%U'", format_unformat_error, i);
7510 if (sw_if_index_set == 0)
7512 errmsg ("missing interface name or sw_if_index");
7516 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7518 mp->sw_if_index = ntohl (sw_if_index);
7519 mp->enable_disable = enable;
7527 api_mpls_tunnel_add_del (vat_main_t * vam)
7529 unformat_input_t *i = vam->input;
7530 vl_api_mpls_tunnel_add_del_t *mp;
7534 u32 sw_if_index = ~0;
7535 u32 next_hop_sw_if_index = ~0;
7536 u32 next_hop_proto_is_ip4 = 1;
7538 u32 next_hop_table_id = 0;
7539 ip4_address_t v4_next_hop_address = {
7542 ip6_address_t v6_next_hop_address = { {0} };
7543 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7546 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7548 if (unformat (i, "add"))
7550 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7552 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7554 else if (unformat (i, "via %U",
7555 unformat_ip4_address, &v4_next_hop_address))
7557 next_hop_proto_is_ip4 = 1;
7559 else if (unformat (i, "via %U",
7560 unformat_ip6_address, &v6_next_hop_address))
7562 next_hop_proto_is_ip4 = 0;
7564 else if (unformat (i, "l2-only"))
7566 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7568 else if (unformat (i, "out-label %d", &next_hop_out_label))
7569 vec_add1 (labels, ntohl (next_hop_out_label));
7572 clib_warning ("parse error '%U'", format_unformat_error, i);
7577 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7579 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7580 mp->mt_sw_if_index = ntohl (sw_if_index);
7581 mp->mt_is_add = is_add;
7582 mp->mt_l2_only = l2_only;
7583 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7584 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7586 mp->mt_next_hop_n_out_labels = vec_len (labels);
7588 if (0 != mp->mt_next_hop_n_out_labels)
7590 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7591 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7595 if (next_hop_proto_is_ip4)
7597 clib_memcpy (mp->mt_next_hop,
7598 &v4_next_hop_address, sizeof (v4_next_hop_address));
7602 clib_memcpy (mp->mt_next_hop,
7603 &v6_next_hop_address, sizeof (v6_next_hop_address));
7612 api_sw_interface_set_unnumbered (vat_main_t * vam)
7614 unformat_input_t *i = vam->input;
7615 vl_api_sw_interface_set_unnumbered_t *mp;
7617 u32 unnum_sw_index = ~0;
7619 u8 sw_if_index_set = 0;
7622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7624 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7625 sw_if_index_set = 1;
7626 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7627 sw_if_index_set = 1;
7628 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7630 else if (unformat (i, "del"))
7634 clib_warning ("parse error '%U'", format_unformat_error, i);
7639 if (sw_if_index_set == 0)
7641 errmsg ("missing interface name or sw_if_index");
7645 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7647 mp->sw_if_index = ntohl (sw_if_index);
7648 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7649 mp->is_add = is_add;
7657 api_ip_neighbor_add_del (vat_main_t * vam)
7659 unformat_input_t *i = vam->input;
7660 vl_api_ip_neighbor_add_del_t *mp;
7662 u8 sw_if_index_set = 0;
7665 u8 is_no_fib_entry = 0;
7668 u8 v4_address_set = 0;
7669 u8 v6_address_set = 0;
7670 ip4_address_t v4address;
7671 ip6_address_t v6address;
7674 memset (mac_address, 0, sizeof (mac_address));
7676 /* Parse args required to build the message */
7677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7679 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7683 else if (unformat (i, "del"))
7686 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7687 sw_if_index_set = 1;
7688 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7689 sw_if_index_set = 1;
7690 else if (unformat (i, "is_static"))
7692 else if (unformat (i, "no-fib-entry"))
7693 is_no_fib_entry = 1;
7694 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7696 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7700 clib_warning ("parse error '%U'", format_unformat_error, i);
7705 if (sw_if_index_set == 0)
7707 errmsg ("missing interface name or sw_if_index");
7710 if (v4_address_set && v6_address_set)
7712 errmsg ("both v4 and v6 addresses set");
7715 if (!v4_address_set && !v6_address_set)
7717 errmsg ("no address set");
7721 /* Construct the API message */
7722 M (IP_NEIGHBOR_ADD_DEL, mp);
7724 mp->sw_if_index = ntohl (sw_if_index);
7725 mp->is_add = is_add;
7726 mp->is_static = is_static;
7727 mp->is_no_adj_fib = is_no_fib_entry;
7729 clib_memcpy (mp->mac_address, mac_address, 6);
7733 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7737 /* mp->is_ipv6 = 0; via memset in M macro above */
7738 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7744 /* Wait for a reply, return good/bad news */
7750 api_reset_vrf (vat_main_t * vam)
7752 unformat_input_t *i = vam->input;
7753 vl_api_reset_vrf_t *mp;
7759 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7761 if (unformat (i, "vrf %d", &vrf_id))
7763 else if (unformat (i, "ipv6"))
7767 clib_warning ("parse error '%U'", format_unformat_error, i);
7772 if (vrf_id_set == 0)
7774 errmsg ("missing vrf id");
7780 mp->vrf_id = ntohl (vrf_id);
7781 mp->is_ipv6 = is_ipv6;
7789 api_create_vlan_subif (vat_main_t * vam)
7791 unformat_input_t *i = vam->input;
7792 vl_api_create_vlan_subif_t *mp;
7794 u8 sw_if_index_set = 0;
7799 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7801 if (unformat (i, "sw_if_index %d", &sw_if_index))
7802 sw_if_index_set = 1;
7804 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7805 sw_if_index_set = 1;
7806 else if (unformat (i, "vlan %d", &vlan_id))
7810 clib_warning ("parse error '%U'", format_unformat_error, i);
7815 if (sw_if_index_set == 0)
7817 errmsg ("missing interface name or sw_if_index");
7821 if (vlan_id_set == 0)
7823 errmsg ("missing vlan_id");
7826 M (CREATE_VLAN_SUBIF, mp);
7828 mp->sw_if_index = ntohl (sw_if_index);
7829 mp->vlan_id = ntohl (vlan_id);
7836 #define foreach_create_subif_bit \
7843 _(outer_vlan_id_any) \
7844 _(inner_vlan_id_any)
7847 api_create_subif (vat_main_t * vam)
7849 unformat_input_t *i = vam->input;
7850 vl_api_create_subif_t *mp;
7852 u8 sw_if_index_set = 0;
7859 u32 exact_match = 0;
7860 u32 default_sub = 0;
7861 u32 outer_vlan_id_any = 0;
7862 u32 inner_vlan_id_any = 0;
7864 u16 outer_vlan_id = 0;
7865 u16 inner_vlan_id = 0;
7868 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7870 if (unformat (i, "sw_if_index %d", &sw_if_index))
7871 sw_if_index_set = 1;
7873 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7874 sw_if_index_set = 1;
7875 else if (unformat (i, "sub_id %d", &sub_id))
7877 else if (unformat (i, "outer_vlan_id %d", &tmp))
7878 outer_vlan_id = tmp;
7879 else if (unformat (i, "inner_vlan_id %d", &tmp))
7880 inner_vlan_id = tmp;
7882 #define _(a) else if (unformat (i, #a)) a = 1 ;
7883 foreach_create_subif_bit
7887 clib_warning ("parse error '%U'", format_unformat_error, i);
7892 if (sw_if_index_set == 0)
7894 errmsg ("missing interface name or sw_if_index");
7898 if (sub_id_set == 0)
7900 errmsg ("missing sub_id");
7903 M (CREATE_SUBIF, mp);
7905 mp->sw_if_index = ntohl (sw_if_index);
7906 mp->sub_id = ntohl (sub_id);
7908 #define _(a) mp->a = a;
7909 foreach_create_subif_bit;
7912 mp->outer_vlan_id = ntohs (outer_vlan_id);
7913 mp->inner_vlan_id = ntohs (inner_vlan_id);
7921 api_oam_add_del (vat_main_t * vam)
7923 unformat_input_t *i = vam->input;
7924 vl_api_oam_add_del_t *mp;
7927 ip4_address_t src, dst;
7932 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7934 if (unformat (i, "vrf %d", &vrf_id))
7936 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7938 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7940 else if (unformat (i, "del"))
7944 clib_warning ("parse error '%U'", format_unformat_error, i);
7951 errmsg ("missing src addr");
7957 errmsg ("missing dst addr");
7961 M (OAM_ADD_DEL, mp);
7963 mp->vrf_id = ntohl (vrf_id);
7964 mp->is_add = is_add;
7965 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7966 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7974 api_reset_fib (vat_main_t * vam)
7976 unformat_input_t *i = vam->input;
7977 vl_api_reset_fib_t *mp;
7983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7985 if (unformat (i, "vrf %d", &vrf_id))
7987 else if (unformat (i, "ipv6"))
7991 clib_warning ("parse error '%U'", format_unformat_error, i);
7996 if (vrf_id_set == 0)
7998 errmsg ("missing vrf id");
8004 mp->vrf_id = ntohl (vrf_id);
8005 mp->is_ipv6 = is_ipv6;
8013 api_dhcp_proxy_config (vat_main_t * vam)
8015 unformat_input_t *i = vam->input;
8016 vl_api_dhcp_proxy_config_t *mp;
8018 u32 server_vrf_id = 0;
8020 u8 v4_address_set = 0;
8021 u8 v6_address_set = 0;
8022 ip4_address_t v4address;
8023 ip6_address_t v6address;
8024 u8 v4_src_address_set = 0;
8025 u8 v6_src_address_set = 0;
8026 ip4_address_t v4srcaddress;
8027 ip6_address_t v6srcaddress;
8030 /* Parse args required to build the message */
8031 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8033 if (unformat (i, "del"))
8035 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8037 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8039 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8041 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8043 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8044 v4_src_address_set = 1;
8045 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8046 v6_src_address_set = 1;
8051 if (v4_address_set && v6_address_set)
8053 errmsg ("both v4 and v6 server addresses set");
8056 if (!v4_address_set && !v6_address_set)
8058 errmsg ("no server addresses set");
8062 if (v4_src_address_set && v6_src_address_set)
8064 errmsg ("both v4 and v6 src addresses set");
8067 if (!v4_src_address_set && !v6_src_address_set)
8069 errmsg ("no src addresses set");
8073 if (!(v4_src_address_set && v4_address_set) &&
8074 !(v6_src_address_set && v6_address_set))
8076 errmsg ("no matching server and src addresses set");
8080 /* Construct the API message */
8081 M (DHCP_PROXY_CONFIG, mp);
8083 mp->is_add = is_add;
8084 mp->rx_vrf_id = ntohl (rx_vrf_id);
8085 mp->server_vrf_id = ntohl (server_vrf_id);
8089 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
8090 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
8094 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
8095 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
8101 /* Wait for a reply, return good/bad news */
8106 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
8107 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
8110 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
8112 vat_main_t *vam = &vat_main;
8113 u32 i, count = mp->count;
8114 vl_api_dhcp_server_t *s;
8118 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8119 ntohl (mp->rx_vrf_id),
8120 format_ip6_address, mp->dhcp_src_address,
8121 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8124 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8125 ntohl (mp->rx_vrf_id),
8126 format_ip4_address, mp->dhcp_src_address,
8127 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8129 for (i = 0; i < count; i++)
8131 s = &mp->servers[i];
8135 " Server Table-ID %d, Server Address %U",
8136 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
8139 " Server Table-ID %d, Server Address %U",
8140 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
8144 static void vl_api_dhcp_proxy_details_t_handler_json
8145 (vl_api_dhcp_proxy_details_t * mp)
8147 vat_main_t *vam = &vat_main;
8148 vat_json_node_t *node = NULL;
8149 u32 i, count = mp->count;
8151 struct in6_addr ip6;
8152 vl_api_dhcp_server_t *s;
8154 if (VAT_JSON_ARRAY != vam->json_tree.type)
8156 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8157 vat_json_init_array (&vam->json_tree);
8159 node = vat_json_array_add (&vam->json_tree);
8161 vat_json_init_object (node);
8162 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
8163 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
8164 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
8168 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
8169 vat_json_object_add_ip6 (node, "src_address", ip6);
8173 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
8174 vat_json_object_add_ip4 (node, "src_address", ip4);
8177 for (i = 0; i < count; i++)
8179 s = &mp->servers[i];
8181 vat_json_object_add_uint (node, "server-table-id",
8182 ntohl (s->server_vrf_id));
8186 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
8187 vat_json_object_add_ip4 (node, "src_address", ip4);
8191 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
8192 vat_json_object_add_ip6 (node, "server_address", ip6);
8198 api_dhcp_proxy_dump (vat_main_t * vam)
8200 unformat_input_t *i = vam->input;
8201 vl_api_control_ping_t *mp_ping;
8202 vl_api_dhcp_proxy_dump_t *mp;
8206 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8208 if (unformat (i, "ipv6"))
8212 clib_warning ("parse error '%U'", format_unformat_error, i);
8217 M (DHCP_PROXY_DUMP, mp);
8219 mp->is_ip6 = is_ipv6;
8222 /* Use a control ping for synchronization */
8223 M (CONTROL_PING, mp_ping);
8231 api_dhcp_proxy_set_vss (vat_main_t * vam)
8233 unformat_input_t *i = vam->input;
8234 vl_api_dhcp_proxy_set_vss_t *mp;
8245 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8247 if (unformat (i, "tbl_id %d", &tbl_id))
8249 if (unformat (i, "fib_id %d", &fib_id))
8251 if (unformat (i, "oui %d", &oui))
8253 else if (unformat (i, "ipv6"))
8255 else if (unformat (i, "del"))
8259 clib_warning ("parse error '%U'", format_unformat_error, i);
8264 if (tbl_id_set == 0)
8266 errmsg ("missing tbl id");
8270 if (fib_id_set == 0)
8272 errmsg ("missing fib id");
8277 errmsg ("missing oui");
8281 M (DHCP_PROXY_SET_VSS, mp);
8282 mp->tbl_id = ntohl (tbl_id);
8283 mp->fib_id = ntohl (fib_id);
8284 mp->oui = ntohl (oui);
8285 mp->is_ipv6 = is_ipv6;
8286 mp->is_add = is_add;
8294 api_dhcp_client_config (vat_main_t * vam)
8296 unformat_input_t *i = vam->input;
8297 vl_api_dhcp_client_config_t *mp;
8299 u8 sw_if_index_set = 0;
8302 u8 disable_event = 0;
8305 /* Parse args required to build the message */
8306 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8308 if (unformat (i, "del"))
8311 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8312 sw_if_index_set = 1;
8313 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8314 sw_if_index_set = 1;
8315 else if (unformat (i, "hostname %s", &hostname))
8317 else if (unformat (i, "disable_event"))
8323 if (sw_if_index_set == 0)
8325 errmsg ("missing interface name or sw_if_index");
8329 if (vec_len (hostname) > 63)
8331 errmsg ("hostname too long");
8333 vec_add1 (hostname, 0);
8335 /* Construct the API message */
8336 M (DHCP_CLIENT_CONFIG, mp);
8338 mp->sw_if_index = htonl (sw_if_index);
8339 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
8340 vec_free (hostname);
8341 mp->is_add = is_add;
8342 mp->want_dhcp_event = disable_event ? 0 : 1;
8343 mp->pid = htonl (getpid ());
8348 /* Wait for a reply, return good/bad news */
8354 api_set_ip_flow_hash (vat_main_t * vam)
8356 unformat_input_t *i = vam->input;
8357 vl_api_set_ip_flow_hash_t *mp;
8369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8371 if (unformat (i, "vrf %d", &vrf_id))
8373 else if (unformat (i, "ipv6"))
8375 else if (unformat (i, "src"))
8377 else if (unformat (i, "dst"))
8379 else if (unformat (i, "sport"))
8381 else if (unformat (i, "dport"))
8383 else if (unformat (i, "proto"))
8385 else if (unformat (i, "reverse"))
8390 clib_warning ("parse error '%U'", format_unformat_error, i);
8395 if (vrf_id_set == 0)
8397 errmsg ("missing vrf id");
8401 M (SET_IP_FLOW_HASH, mp);
8407 mp->reverse = reverse;
8408 mp->vrf_id = ntohl (vrf_id);
8409 mp->is_ipv6 = is_ipv6;
8417 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8419 unformat_input_t *i = vam->input;
8420 vl_api_sw_interface_ip6_enable_disable_t *mp;
8422 u8 sw_if_index_set = 0;
8426 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8428 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8429 sw_if_index_set = 1;
8430 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8431 sw_if_index_set = 1;
8432 else if (unformat (i, "enable"))
8434 else if (unformat (i, "disable"))
8438 clib_warning ("parse error '%U'", format_unformat_error, i);
8443 if (sw_if_index_set == 0)
8445 errmsg ("missing interface name or sw_if_index");
8449 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8451 mp->sw_if_index = ntohl (sw_if_index);
8452 mp->enable = enable;
8460 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8462 unformat_input_t *i = vam->input;
8463 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8465 u8 sw_if_index_set = 0;
8466 u8 v6_address_set = 0;
8467 ip6_address_t v6address;
8470 /* Parse args required to build the message */
8471 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8473 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8474 sw_if_index_set = 1;
8475 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8476 sw_if_index_set = 1;
8477 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8483 if (sw_if_index_set == 0)
8485 errmsg ("missing interface name or sw_if_index");
8488 if (!v6_address_set)
8490 errmsg ("no address set");
8494 /* Construct the API message */
8495 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8497 mp->sw_if_index = ntohl (sw_if_index);
8498 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8503 /* Wait for a reply, return good/bad news */
8509 api_ip6nd_proxy_add_del (vat_main_t * vam)
8511 unformat_input_t *i = vam->input;
8512 vl_api_ip6nd_proxy_add_del_t *mp;
8513 u32 sw_if_index = ~0;
8514 u8 v6_address_set = 0;
8515 ip6_address_t v6address;
8519 /* Parse args required to build the message */
8520 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8522 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8524 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8526 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8528 if (unformat (i, "del"))
8532 clib_warning ("parse error '%U'", format_unformat_error, i);
8537 if (sw_if_index == ~0)
8539 errmsg ("missing interface name or sw_if_index");
8542 if (!v6_address_set)
8544 errmsg ("no address set");
8548 /* Construct the API message */
8549 M (IP6ND_PROXY_ADD_DEL, mp);
8551 mp->is_del = is_del;
8552 mp->sw_if_index = ntohl (sw_if_index);
8553 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8558 /* Wait for a reply, return good/bad news */
8564 api_ip6nd_proxy_dump (vat_main_t * vam)
8566 vl_api_ip6nd_proxy_dump_t *mp;
8567 vl_api_control_ping_t *mp_ping;
8570 M (IP6ND_PROXY_DUMP, mp);
8574 /* Use a control ping for synchronization */
8575 M (CONTROL_PING, mp_ping);
8582 static void vl_api_ip6nd_proxy_details_t_handler
8583 (vl_api_ip6nd_proxy_details_t * mp)
8585 vat_main_t *vam = &vat_main;
8587 print (vam->ofp, "host %U sw_if_index %d",
8588 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
8591 static void vl_api_ip6nd_proxy_details_t_handler_json
8592 (vl_api_ip6nd_proxy_details_t * mp)
8594 vat_main_t *vam = &vat_main;
8595 struct in6_addr ip6;
8596 vat_json_node_t *node = NULL;
8598 if (VAT_JSON_ARRAY != vam->json_tree.type)
8600 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8601 vat_json_init_array (&vam->json_tree);
8603 node = vat_json_array_add (&vam->json_tree);
8605 vat_json_init_object (node);
8606 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
8608 clib_memcpy (&ip6, mp->address, sizeof (ip6));
8609 vat_json_object_add_ip6 (node, "host", ip6);
8613 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8615 unformat_input_t *i = vam->input;
8616 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8618 u8 sw_if_index_set = 0;
8619 u32 address_length = 0;
8620 u8 v6_address_set = 0;
8621 ip6_address_t v6address;
8623 u8 no_advertise = 0;
8625 u8 no_autoconfig = 0;
8628 u32 val_lifetime = 0;
8629 u32 pref_lifetime = 0;
8632 /* Parse args required to build the message */
8633 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8635 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8636 sw_if_index_set = 1;
8637 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8638 sw_if_index_set = 1;
8639 else if (unformat (i, "%U/%d",
8640 unformat_ip6_address, &v6address, &address_length))
8642 else if (unformat (i, "val_life %d", &val_lifetime))
8644 else if (unformat (i, "pref_life %d", &pref_lifetime))
8646 else if (unformat (i, "def"))
8648 else if (unformat (i, "noadv"))
8650 else if (unformat (i, "offl"))
8652 else if (unformat (i, "noauto"))
8654 else if (unformat (i, "nolink"))
8656 else if (unformat (i, "isno"))
8660 clib_warning ("parse error '%U'", format_unformat_error, i);
8665 if (sw_if_index_set == 0)
8667 errmsg ("missing interface name or sw_if_index");
8670 if (!v6_address_set)
8672 errmsg ("no address set");
8676 /* Construct the API message */
8677 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8679 mp->sw_if_index = ntohl (sw_if_index);
8680 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8681 mp->address_length = address_length;
8682 mp->use_default = use_default;
8683 mp->no_advertise = no_advertise;
8684 mp->off_link = off_link;
8685 mp->no_autoconfig = no_autoconfig;
8686 mp->no_onlink = no_onlink;
8688 mp->val_lifetime = ntohl (val_lifetime);
8689 mp->pref_lifetime = ntohl (pref_lifetime);
8694 /* Wait for a reply, return good/bad news */
8700 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8702 unformat_input_t *i = vam->input;
8703 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8705 u8 sw_if_index_set = 0;
8710 u8 send_unicast = 0;
8713 u8 default_router = 0;
8714 u32 max_interval = 0;
8715 u32 min_interval = 0;
8717 u32 initial_count = 0;
8718 u32 initial_interval = 0;
8722 /* Parse args required to build the message */
8723 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8725 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8726 sw_if_index_set = 1;
8727 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8728 sw_if_index_set = 1;
8729 else if (unformat (i, "maxint %d", &max_interval))
8731 else if (unformat (i, "minint %d", &min_interval))
8733 else if (unformat (i, "life %d", &lifetime))
8735 else if (unformat (i, "count %d", &initial_count))
8737 else if (unformat (i, "interval %d", &initial_interval))
8739 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8741 else if (unformat (i, "managed"))
8743 else if (unformat (i, "other"))
8745 else if (unformat (i, "ll"))
8747 else if (unformat (i, "send"))
8749 else if (unformat (i, "cease"))
8751 else if (unformat (i, "isno"))
8753 else if (unformat (i, "def"))
8757 clib_warning ("parse error '%U'", format_unformat_error, i);
8762 if (sw_if_index_set == 0)
8764 errmsg ("missing interface name or sw_if_index");
8768 /* Construct the API message */
8769 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8771 mp->sw_if_index = ntohl (sw_if_index);
8772 mp->max_interval = ntohl (max_interval);
8773 mp->min_interval = ntohl (min_interval);
8774 mp->lifetime = ntohl (lifetime);
8775 mp->initial_count = ntohl (initial_count);
8776 mp->initial_interval = ntohl (initial_interval);
8777 mp->suppress = suppress;
8778 mp->managed = managed;
8780 mp->ll_option = ll_option;
8781 mp->send_unicast = send_unicast;
8784 mp->default_router = default_router;
8789 /* Wait for a reply, return good/bad news */
8795 api_set_arp_neighbor_limit (vat_main_t * vam)
8797 unformat_input_t *i = vam->input;
8798 vl_api_set_arp_neighbor_limit_t *mp;
8804 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8806 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8808 else if (unformat (i, "ipv6"))
8812 clib_warning ("parse error '%U'", format_unformat_error, i);
8819 errmsg ("missing limit value");
8823 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8825 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8826 mp->is_ipv6 = is_ipv6;
8834 api_l2_patch_add_del (vat_main_t * vam)
8836 unformat_input_t *i = vam->input;
8837 vl_api_l2_patch_add_del_t *mp;
8839 u8 rx_sw_if_index_set = 0;
8841 u8 tx_sw_if_index_set = 0;
8845 /* Parse args required to build the message */
8846 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8848 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8849 rx_sw_if_index_set = 1;
8850 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8851 tx_sw_if_index_set = 1;
8852 else if (unformat (i, "rx"))
8854 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8856 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8858 rx_sw_if_index_set = 1;
8863 else if (unformat (i, "tx"))
8865 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8867 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8869 tx_sw_if_index_set = 1;
8874 else if (unformat (i, "del"))
8880 if (rx_sw_if_index_set == 0)
8882 errmsg ("missing rx interface name or rx_sw_if_index");
8886 if (tx_sw_if_index_set == 0)
8888 errmsg ("missing tx interface name or tx_sw_if_index");
8892 M (L2_PATCH_ADD_DEL, mp);
8894 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8895 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8896 mp->is_add = is_add;
8904 u8 localsid_addr[16];
8913 api_sr_localsid_add_del (vat_main_t * vam)
8915 unformat_input_t *i = vam->input;
8916 vl_api_sr_localsid_add_del_t *mp;
8919 ip6_address_t localsid;
8923 u32 fib_table = ~(u32) 0;
8924 ip6_address_t next_hop;
8926 bool nexthop_set = 0;
8930 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8932 if (unformat (i, "del"))
8934 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
8935 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
8937 else if (unformat (i, "behavior %u", &behavior));
8938 else if (unformat (i, "sw_if_index %u", &sw_if_index));
8939 else if (unformat (i, "fib-table %u", &fib_table));
8940 else if (unformat (i, "end.psp %u", &behavior));
8945 M (SR_LOCALSID_ADD_DEL, mp);
8947 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
8949 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
8950 mp->behavior = behavior;
8951 mp->sw_if_index = ntohl (sw_if_index);
8952 mp->fib_table = ntohl (fib_table);
8953 mp->end_psp = end_psp;
8954 mp->is_del = is_del;
8962 api_ioam_enable (vat_main_t * vam)
8964 unformat_input_t *input = vam->input;
8965 vl_api_ioam_enable_t *mp;
8967 int has_trace_option = 0;
8968 int has_pot_option = 0;
8969 int has_seqno_option = 0;
8970 int has_analyse_option = 0;
8973 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8975 if (unformat (input, "trace"))
8976 has_trace_option = 1;
8977 else if (unformat (input, "pot"))
8979 else if (unformat (input, "seqno"))
8980 has_seqno_option = 1;
8981 else if (unformat (input, "analyse"))
8982 has_analyse_option = 1;
8986 M (IOAM_ENABLE, mp);
8987 mp->id = htons (id);
8988 mp->seqno = has_seqno_option;
8989 mp->analyse = has_analyse_option;
8990 mp->pot_enable = has_pot_option;
8991 mp->trace_enable = has_trace_option;
9000 api_ioam_disable (vat_main_t * vam)
9002 vl_api_ioam_disable_t *mp;
9005 M (IOAM_DISABLE, mp);
9011 #define foreach_tcp_proto_field \
9015 #define foreach_udp_proto_field \
9019 #define foreach_ip4_proto_field \
9031 u16 src_port, dst_port;
9034 #if VPP_API_TEST_BUILTIN == 0
9036 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9038 u8 **maskp = va_arg (*args, u8 **);
9040 u8 found_something = 0;
9043 #define _(a) u8 a=0;
9044 foreach_tcp_proto_field;
9047 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9050 #define _(a) else if (unformat (input, #a)) a=1;
9051 foreach_tcp_proto_field
9057 #define _(a) found_something += a;
9058 foreach_tcp_proto_field;
9061 if (found_something == 0)
9064 vec_validate (mask, sizeof (*tcp) - 1);
9066 tcp = (tcp_header_t *) mask;
9068 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9069 foreach_tcp_proto_field;
9077 unformat_udp_mask (unformat_input_t * input, va_list * args)
9079 u8 **maskp = va_arg (*args, u8 **);
9081 u8 found_something = 0;
9084 #define _(a) u8 a=0;
9085 foreach_udp_proto_field;
9088 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9091 #define _(a) else if (unformat (input, #a)) a=1;
9092 foreach_udp_proto_field
9098 #define _(a) found_something += a;
9099 foreach_udp_proto_field;
9102 if (found_something == 0)
9105 vec_validate (mask, sizeof (*udp) - 1);
9107 udp = (udp_header_t *) mask;
9109 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
9110 foreach_udp_proto_field;
9118 unformat_l4_mask (unformat_input_t * input, va_list * args)
9120 u8 **maskp = va_arg (*args, u8 **);
9121 u16 src_port = 0, dst_port = 0;
9122 tcpudp_header_t *tcpudp;
9124 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9126 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9128 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9130 else if (unformat (input, "src_port"))
9132 else if (unformat (input, "dst_port"))
9138 if (!src_port && !dst_port)
9142 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9144 tcpudp = (tcpudp_header_t *) mask;
9145 tcpudp->src_port = src_port;
9146 tcpudp->dst_port = dst_port;
9154 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9156 u8 **maskp = va_arg (*args, u8 **);
9158 u8 found_something = 0;
9161 #define _(a) u8 a=0;
9162 foreach_ip4_proto_field;
9168 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9170 if (unformat (input, "version"))
9172 else if (unformat (input, "hdr_length"))
9174 else if (unformat (input, "src"))
9176 else if (unformat (input, "dst"))
9178 else if (unformat (input, "proto"))
9181 #define _(a) else if (unformat (input, #a)) a=1;
9182 foreach_ip4_proto_field
9188 #define _(a) found_something += a;
9189 foreach_ip4_proto_field;
9192 if (found_something == 0)
9195 vec_validate (mask, sizeof (*ip) - 1);
9197 ip = (ip4_header_t *) mask;
9199 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9200 foreach_ip4_proto_field;
9203 ip->ip_version_and_header_length = 0;
9206 ip->ip_version_and_header_length |= 0xF0;
9209 ip->ip_version_and_header_length |= 0x0F;
9215 #define foreach_ip6_proto_field \
9223 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9225 u8 **maskp = va_arg (*args, u8 **);
9227 u8 found_something = 0;
9229 u32 ip_version_traffic_class_and_flow_label;
9231 #define _(a) u8 a=0;
9232 foreach_ip6_proto_field;
9235 u8 traffic_class = 0;
9238 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9240 if (unformat (input, "version"))
9242 else if (unformat (input, "traffic-class"))
9244 else if (unformat (input, "flow-label"))
9246 else if (unformat (input, "src"))
9248 else if (unformat (input, "dst"))
9250 else if (unformat (input, "proto"))
9253 #define _(a) else if (unformat (input, #a)) a=1;
9254 foreach_ip6_proto_field
9260 #define _(a) found_something += a;
9261 foreach_ip6_proto_field;
9264 if (found_something == 0)
9267 vec_validate (mask, sizeof (*ip) - 1);
9269 ip = (ip6_header_t *) mask;
9271 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9272 foreach_ip6_proto_field;
9275 ip_version_traffic_class_and_flow_label = 0;
9278 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9281 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9284 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9286 ip->ip_version_traffic_class_and_flow_label =
9287 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9294 unformat_l3_mask (unformat_input_t * input, va_list * args)
9296 u8 **maskp = va_arg (*args, u8 **);
9298 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9300 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9302 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9311 unformat_l2_mask (unformat_input_t * input, va_list * args)
9313 u8 **maskp = va_arg (*args, u8 **);
9328 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9330 if (unformat (input, "src"))
9332 else if (unformat (input, "dst"))
9334 else if (unformat (input, "proto"))
9336 else if (unformat (input, "tag1"))
9338 else if (unformat (input, "tag2"))
9340 else if (unformat (input, "ignore-tag1"))
9342 else if (unformat (input, "ignore-tag2"))
9344 else if (unformat (input, "cos1"))
9346 else if (unformat (input, "cos2"))
9348 else if (unformat (input, "dot1q"))
9350 else if (unformat (input, "dot1ad"))
9355 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9356 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9359 if (tag1 || ignore_tag1 || cos1 || dot1q)
9361 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9364 vec_validate (mask, len - 1);
9367 memset (mask, 0xff, 6);
9370 memset (mask + 6, 0xff, 6);
9374 /* inner vlan tag */
9383 mask[21] = mask[20] = 0xff;
9404 mask[16] = mask[17] = 0xff;
9414 mask[12] = mask[13] = 0xff;
9421 unformat_classify_mask (unformat_input_t * input, va_list * args)
9423 u8 **maskp = va_arg (*args, u8 **);
9424 u32 *skipp = va_arg (*args, u32 *);
9425 u32 *matchp = va_arg (*args, u32 *);
9433 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9435 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9437 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9439 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9441 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9455 if (mask || l2 || l3 || l4)
9459 /* "With a free Ethernet header in every package" */
9461 vec_validate (l2, 13);
9465 vec_append (mask, l3);
9470 vec_append (mask, l4);
9475 /* Scan forward looking for the first significant mask octet */
9476 for (i = 0; i < vec_len (mask); i++)
9480 /* compute (skip, match) params */
9481 *skipp = i / sizeof (u32x4);
9482 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9484 /* Pad mask to an even multiple of the vector size */
9485 while (vec_len (mask) % sizeof (u32x4))
9488 match = vec_len (mask) / sizeof (u32x4);
9490 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9492 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9493 if (*tmp || *(tmp + 1))
9498 clib_warning ("BUG: match 0");
9500 _vec_len (mask) = match * sizeof (u32x4);
9510 #endif /* VPP_API_TEST_BUILTIN */
9512 #define foreach_l2_next \
9514 _(ethernet, ETHERNET_INPUT) \
9519 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9521 u32 *miss_next_indexp = va_arg (*args, u32 *);
9526 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9530 if (unformat (input, "%d", &tmp))
9539 *miss_next_indexp = next_index;
9543 #define foreach_ip_next \
9549 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9551 u32 *miss_next_indexp = va_arg (*args, u32 *);
9556 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9560 if (unformat (input, "%d", &tmp))
9569 *miss_next_indexp = next_index;
9573 #define foreach_acl_next \
9577 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9579 u32 *miss_next_indexp = va_arg (*args, u32 *);
9584 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9588 if (unformat (input, "permit"))
9593 else if (unformat (input, "%d", &tmp))
9602 *miss_next_indexp = next_index;
9607 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9609 u32 *r = va_arg (*args, u32 *);
9611 if (unformat (input, "conform-color"))
9612 *r = POLICE_CONFORM;
9613 else if (unformat (input, "exceed-color"))
9622 api_classify_add_del_table (vat_main_t * vam)
9624 unformat_input_t *i = vam->input;
9625 vl_api_classify_add_del_table_t *mp;
9632 u32 table_index = ~0;
9633 u32 next_table_index = ~0;
9634 u32 miss_next_index = ~0;
9635 u32 memory_size = 32 << 20;
9637 u32 current_data_flag = 0;
9638 int current_data_offset = 0;
9641 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9643 if (unformat (i, "del"))
9645 else if (unformat (i, "del-chain"))
9650 else if (unformat (i, "buckets %d", &nbuckets))
9652 else if (unformat (i, "memory_size %d", &memory_size))
9654 else if (unformat (i, "skip %d", &skip))
9656 else if (unformat (i, "match %d", &match))
9658 else if (unformat (i, "table %d", &table_index))
9660 else if (unformat (i, "mask %U", unformat_classify_mask,
9661 &mask, &skip, &match))
9663 else if (unformat (i, "next-table %d", &next_table_index))
9665 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9668 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9671 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9674 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9676 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9682 if (is_add && mask == 0)
9684 errmsg ("Mask required");
9688 if (is_add && skip == ~0)
9690 errmsg ("skip count required");
9694 if (is_add && match == ~0)
9696 errmsg ("match count required");
9700 if (!is_add && table_index == ~0)
9702 errmsg ("table index required for delete");
9706 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9708 mp->is_add = is_add;
9709 mp->del_chain = del_chain;
9710 mp->table_index = ntohl (table_index);
9711 mp->nbuckets = ntohl (nbuckets);
9712 mp->memory_size = ntohl (memory_size);
9713 mp->skip_n_vectors = ntohl (skip);
9714 mp->match_n_vectors = ntohl (match);
9715 mp->next_table_index = ntohl (next_table_index);
9716 mp->miss_next_index = ntohl (miss_next_index);
9717 mp->current_data_flag = ntohl (current_data_flag);
9718 mp->current_data_offset = ntohl (current_data_offset);
9719 clib_memcpy (mp->mask, mask, vec_len (mask));
9728 #if VPP_API_TEST_BUILTIN == 0
9730 unformat_l4_match (unformat_input_t * input, va_list * args)
9732 u8 **matchp = va_arg (*args, u8 **);
9734 u8 *proto_header = 0;
9740 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9742 if (unformat (input, "src_port %d", &src_port))
9744 else if (unformat (input, "dst_port %d", &dst_port))
9750 h.src_port = clib_host_to_net_u16 (src_port);
9751 h.dst_port = clib_host_to_net_u16 (dst_port);
9752 vec_validate (proto_header, sizeof (h) - 1);
9753 memcpy (proto_header, &h, sizeof (h));
9755 *matchp = proto_header;
9761 unformat_ip4_match (unformat_input_t * input, va_list * args)
9763 u8 **matchp = va_arg (*args, u8 **);
9770 int src = 0, dst = 0;
9771 ip4_address_t src_val, dst_val;
9778 int fragment_id = 0;
9779 u32 fragment_id_val;
9785 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9787 if (unformat (input, "version %d", &version_val))
9789 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9791 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9793 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9795 else if (unformat (input, "proto %d", &proto_val))
9797 else if (unformat (input, "tos %d", &tos_val))
9799 else if (unformat (input, "length %d", &length_val))
9801 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9803 else if (unformat (input, "ttl %d", &ttl_val))
9805 else if (unformat (input, "checksum %d", &checksum_val))
9811 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9812 + ttl + checksum == 0)
9816 * Aligned because we use the real comparison functions
9818 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9820 ip = (ip4_header_t *) match;
9822 /* These are realistically matched in practice */
9824 ip->src_address.as_u32 = src_val.as_u32;
9827 ip->dst_address.as_u32 = dst_val.as_u32;
9830 ip->protocol = proto_val;
9833 /* These are not, but they're included for completeness */
9835 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9838 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9844 ip->length = clib_host_to_net_u16 (length_val);
9850 ip->checksum = clib_host_to_net_u16 (checksum_val);
9857 unformat_ip6_match (unformat_input_t * input, va_list * args)
9859 u8 **matchp = va_arg (*args, u8 **);
9864 u8 traffic_class = 0;
9865 u32 traffic_class_val = 0;
9868 int src = 0, dst = 0;
9869 ip6_address_t src_val, dst_val;
9872 int payload_length = 0;
9873 u32 payload_length_val;
9876 u32 ip_version_traffic_class_and_flow_label;
9878 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9880 if (unformat (input, "version %d", &version_val))
9882 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9884 else if (unformat (input, "flow_label %d", &flow_label_val))
9886 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9888 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9890 else if (unformat (input, "proto %d", &proto_val))
9892 else if (unformat (input, "payload_length %d", &payload_length_val))
9894 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9900 if (version + traffic_class + flow_label + src + dst + proto +
9901 payload_length + hop_limit == 0)
9905 * Aligned because we use the real comparison functions
9907 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9909 ip = (ip6_header_t *) match;
9912 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9915 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9918 ip->protocol = proto_val;
9920 ip_version_traffic_class_and_flow_label = 0;
9923 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9926 ip_version_traffic_class_and_flow_label |=
9927 (traffic_class_val & 0xFF) << 20;
9930 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9932 ip->ip_version_traffic_class_and_flow_label =
9933 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9936 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9939 ip->hop_limit = hop_limit_val;
9946 unformat_l3_match (unformat_input_t * input, va_list * args)
9948 u8 **matchp = va_arg (*args, u8 **);
9950 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9952 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9954 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9963 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9965 u8 *tagp = va_arg (*args, u8 *);
9968 if (unformat (input, "%d", &tag))
9970 tagp[0] = (tag >> 8) & 0x0F;
9971 tagp[1] = tag & 0xFF;
9979 unformat_l2_match (unformat_input_t * input, va_list * args)
9981 u8 **matchp = va_arg (*args, u8 **);
10001 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10003 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10006 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10008 else if (unformat (input, "proto %U",
10009 unformat_ethernet_type_host_byte_order, &proto_val))
10011 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10013 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10015 else if (unformat (input, "ignore-tag1"))
10017 else if (unformat (input, "ignore-tag2"))
10019 else if (unformat (input, "cos1 %d", &cos1_val))
10021 else if (unformat (input, "cos2 %d", &cos2_val))
10026 if ((src + dst + proto + tag1 + tag2 +
10027 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10030 if (tag1 || ignore_tag1 || cos1)
10032 if (tag2 || ignore_tag2 || cos2)
10035 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10038 clib_memcpy (match, dst_val, 6);
10041 clib_memcpy (match + 6, src_val, 6);
10045 /* inner vlan tag */
10046 match[19] = tag2_val[1];
10047 match[18] = tag2_val[0];
10049 match[18] |= (cos2_val & 0x7) << 5;
10052 match[21] = proto_val & 0xff;
10053 match[20] = proto_val >> 8;
10057 match[15] = tag1_val[1];
10058 match[14] = tag1_val[0];
10061 match[14] |= (cos1_val & 0x7) << 5;
10067 match[15] = tag1_val[1];
10068 match[14] = tag1_val[0];
10071 match[17] = proto_val & 0xff;
10072 match[16] = proto_val >> 8;
10075 match[14] |= (cos1_val & 0x7) << 5;
10081 match[18] |= (cos2_val & 0x7) << 5;
10083 match[14] |= (cos1_val & 0x7) << 5;
10086 match[13] = proto_val & 0xff;
10087 match[12] = proto_val >> 8;
10096 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10098 u8 **matchp = va_arg (*args, u8 **);
10099 u32 skip_n_vectors = va_arg (*args, u32);
10100 u32 match_n_vectors = va_arg (*args, u32);
10107 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10109 if (unformat (input, "hex %U", unformat_hex_string, &match))
10111 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10113 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10115 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10129 if (match || l2 || l3 || l4)
10131 if (l2 || l3 || l4)
10133 /* "Win a free Ethernet header in every packet" */
10135 vec_validate_aligned (l2, 13, sizeof (u32x4));
10139 vec_append_aligned (match, l3, sizeof (u32x4));
10144 vec_append_aligned (match, l4, sizeof (u32x4));
10149 /* Make sure the vector is big enough even if key is all 0's */
10150 vec_validate_aligned
10151 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10154 /* Set size, include skipped vectors */
10155 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10166 api_classify_add_del_session (vat_main_t * vam)
10168 unformat_input_t *i = vam->input;
10169 vl_api_classify_add_del_session_t *mp;
10171 u32 table_index = ~0;
10172 u32 hit_next_index = ~0;
10173 u32 opaque_index = ~0;
10176 u32 skip_n_vectors = 0;
10177 u32 match_n_vectors = 0;
10183 * Warning: you have to supply skip_n and match_n
10184 * because the API client cant simply look at the classify
10188 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10190 if (unformat (i, "del"))
10192 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10195 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10198 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10201 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10203 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10205 else if (unformat (i, "opaque-index %d", &opaque_index))
10207 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10209 else if (unformat (i, "match_n %d", &match_n_vectors))
10211 else if (unformat (i, "match %U", api_unformat_classify_match,
10212 &match, skip_n_vectors, match_n_vectors))
10214 else if (unformat (i, "advance %d", &advance))
10216 else if (unformat (i, "table-index %d", &table_index))
10218 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10220 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10222 else if (unformat (i, "action %d", &action))
10224 else if (unformat (i, "metadata %d", &metadata))
10230 if (table_index == ~0)
10232 errmsg ("Table index required");
10236 if (is_add && match == 0)
10238 errmsg ("Match value required");
10242 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10244 mp->is_add = is_add;
10245 mp->table_index = ntohl (table_index);
10246 mp->hit_next_index = ntohl (hit_next_index);
10247 mp->opaque_index = ntohl (opaque_index);
10248 mp->advance = ntohl (advance);
10249 mp->action = action;
10250 mp->metadata = ntohl (metadata);
10251 clib_memcpy (mp->match, match, vec_len (match));
10260 api_classify_set_interface_ip_table (vat_main_t * vam)
10262 unformat_input_t *i = vam->input;
10263 vl_api_classify_set_interface_ip_table_t *mp;
10265 int sw_if_index_set;
10266 u32 table_index = ~0;
10270 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10272 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10273 sw_if_index_set = 1;
10274 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10275 sw_if_index_set = 1;
10276 else if (unformat (i, "table %d", &table_index))
10280 clib_warning ("parse error '%U'", format_unformat_error, i);
10285 if (sw_if_index_set == 0)
10287 errmsg ("missing interface name or sw_if_index");
10292 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10294 mp->sw_if_index = ntohl (sw_if_index);
10295 mp->table_index = ntohl (table_index);
10296 mp->is_ipv6 = is_ipv6;
10304 api_classify_set_interface_l2_tables (vat_main_t * vam)
10306 unformat_input_t *i = vam->input;
10307 vl_api_classify_set_interface_l2_tables_t *mp;
10309 int sw_if_index_set;
10310 u32 ip4_table_index = ~0;
10311 u32 ip6_table_index = ~0;
10312 u32 other_table_index = ~0;
10316 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10318 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10319 sw_if_index_set = 1;
10320 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10321 sw_if_index_set = 1;
10322 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10324 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10326 else if (unformat (i, "other-table %d", &other_table_index))
10328 else if (unformat (i, "is-input %d", &is_input))
10332 clib_warning ("parse error '%U'", format_unformat_error, i);
10337 if (sw_if_index_set == 0)
10339 errmsg ("missing interface name or sw_if_index");
10344 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10346 mp->sw_if_index = ntohl (sw_if_index);
10347 mp->ip4_table_index = ntohl (ip4_table_index);
10348 mp->ip6_table_index = ntohl (ip6_table_index);
10349 mp->other_table_index = ntohl (other_table_index);
10350 mp->is_input = (u8) is_input;
10358 api_set_ipfix_exporter (vat_main_t * vam)
10360 unformat_input_t *i = vam->input;
10361 vl_api_set_ipfix_exporter_t *mp;
10362 ip4_address_t collector_address;
10363 u8 collector_address_set = 0;
10364 u32 collector_port = ~0;
10365 ip4_address_t src_address;
10366 u8 src_address_set = 0;
10369 u32 template_interval = ~0;
10370 u8 udp_checksum = 0;
10373 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10375 if (unformat (i, "collector_address %U", unformat_ip4_address,
10376 &collector_address))
10377 collector_address_set = 1;
10378 else if (unformat (i, "collector_port %d", &collector_port))
10380 else if (unformat (i, "src_address %U", unformat_ip4_address,
10382 src_address_set = 1;
10383 else if (unformat (i, "vrf_id %d", &vrf_id))
10385 else if (unformat (i, "path_mtu %d", &path_mtu))
10387 else if (unformat (i, "template_interval %d", &template_interval))
10389 else if (unformat (i, "udp_checksum"))
10395 if (collector_address_set == 0)
10397 errmsg ("collector_address required");
10401 if (src_address_set == 0)
10403 errmsg ("src_address required");
10407 M (SET_IPFIX_EXPORTER, mp);
10409 memcpy (mp->collector_address, collector_address.data,
10410 sizeof (collector_address.data));
10411 mp->collector_port = htons ((u16) collector_port);
10412 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10413 mp->vrf_id = htonl (vrf_id);
10414 mp->path_mtu = htonl (path_mtu);
10415 mp->template_interval = htonl (template_interval);
10416 mp->udp_checksum = udp_checksum;
10424 api_set_ipfix_classify_stream (vat_main_t * vam)
10426 unformat_input_t *i = vam->input;
10427 vl_api_set_ipfix_classify_stream_t *mp;
10429 u32 src_port = UDP_DST_PORT_ipfix;
10432 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10434 if (unformat (i, "domain %d", &domain_id))
10436 else if (unformat (i, "src_port %d", &src_port))
10440 errmsg ("unknown input `%U'", format_unformat_error, i);
10445 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10447 mp->domain_id = htonl (domain_id);
10448 mp->src_port = htons ((u16) src_port);
10456 api_ipfix_classify_table_add_del (vat_main_t * vam)
10458 unformat_input_t *i = vam->input;
10459 vl_api_ipfix_classify_table_add_del_t *mp;
10461 u32 classify_table_index = ~0;
10463 u8 transport_protocol = 255;
10466 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10468 if (unformat (i, "add"))
10470 else if (unformat (i, "del"))
10472 else if (unformat (i, "table %d", &classify_table_index))
10474 else if (unformat (i, "ip4"))
10476 else if (unformat (i, "ip6"))
10478 else if (unformat (i, "tcp"))
10479 transport_protocol = 6;
10480 else if (unformat (i, "udp"))
10481 transport_protocol = 17;
10484 errmsg ("unknown input `%U'", format_unformat_error, i);
10491 errmsg ("expecting: add|del");
10494 if (classify_table_index == ~0)
10496 errmsg ("classifier table not specified");
10499 if (ip_version == 0)
10501 errmsg ("IP version not specified");
10505 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10507 mp->is_add = is_add;
10508 mp->table_id = htonl (classify_table_index);
10509 mp->ip_version = ip_version;
10510 mp->transport_protocol = transport_protocol;
10518 api_get_node_index (vat_main_t * vam)
10520 unformat_input_t *i = vam->input;
10521 vl_api_get_node_index_t *mp;
10525 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10527 if (unformat (i, "node %s", &name))
10534 errmsg ("node name required");
10537 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10539 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10543 M (GET_NODE_INDEX, mp);
10544 clib_memcpy (mp->node_name, name, vec_len (name));
10553 api_get_next_index (vat_main_t * vam)
10555 unformat_input_t *i = vam->input;
10556 vl_api_get_next_index_t *mp;
10557 u8 *node_name = 0, *next_node_name = 0;
10560 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10562 if (unformat (i, "node-name %s", &node_name))
10564 else if (unformat (i, "next-node-name %s", &next_node_name))
10568 if (node_name == 0)
10570 errmsg ("node name required");
10573 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10575 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10579 if (next_node_name == 0)
10581 errmsg ("next node name required");
10584 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10586 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10590 M (GET_NEXT_INDEX, mp);
10591 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10592 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10593 vec_free (node_name);
10594 vec_free (next_node_name);
10602 api_add_node_next (vat_main_t * vam)
10604 unformat_input_t *i = vam->input;
10605 vl_api_add_node_next_t *mp;
10610 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10612 if (unformat (i, "node %s", &name))
10614 else if (unformat (i, "next %s", &next))
10621 errmsg ("node name required");
10624 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10626 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10631 errmsg ("next node required");
10634 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10636 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10640 M (ADD_NODE_NEXT, mp);
10641 clib_memcpy (mp->node_name, name, vec_len (name));
10642 clib_memcpy (mp->next_name, next, vec_len (next));
10652 api_l2tpv3_create_tunnel (vat_main_t * vam)
10654 unformat_input_t *i = vam->input;
10655 ip6_address_t client_address, our_address;
10656 int client_address_set = 0;
10657 int our_address_set = 0;
10658 u32 local_session_id = 0;
10659 u32 remote_session_id = 0;
10660 u64 local_cookie = 0;
10661 u64 remote_cookie = 0;
10662 u8 l2_sublayer_present = 0;
10663 vl_api_l2tpv3_create_tunnel_t *mp;
10666 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10668 if (unformat (i, "client_address %U", unformat_ip6_address,
10670 client_address_set = 1;
10671 else if (unformat (i, "our_address %U", unformat_ip6_address,
10673 our_address_set = 1;
10674 else if (unformat (i, "local_session_id %d", &local_session_id))
10676 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10678 else if (unformat (i, "local_cookie %lld", &local_cookie))
10680 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10682 else if (unformat (i, "l2-sublayer-present"))
10683 l2_sublayer_present = 1;
10688 if (client_address_set == 0)
10690 errmsg ("client_address required");
10694 if (our_address_set == 0)
10696 errmsg ("our_address required");
10700 M (L2TPV3_CREATE_TUNNEL, mp);
10702 clib_memcpy (mp->client_address, client_address.as_u8,
10703 sizeof (mp->client_address));
10705 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10707 mp->local_session_id = ntohl (local_session_id);
10708 mp->remote_session_id = ntohl (remote_session_id);
10709 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10710 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10711 mp->l2_sublayer_present = l2_sublayer_present;
10720 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10722 unformat_input_t *i = vam->input;
10724 u8 sw_if_index_set = 0;
10725 u64 new_local_cookie = 0;
10726 u64 new_remote_cookie = 0;
10727 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10730 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10732 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10733 sw_if_index_set = 1;
10734 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10735 sw_if_index_set = 1;
10736 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10738 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10744 if (sw_if_index_set == 0)
10746 errmsg ("missing interface name or sw_if_index");
10750 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10752 mp->sw_if_index = ntohl (sw_if_index);
10753 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10754 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10762 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10764 unformat_input_t *i = vam->input;
10765 vl_api_l2tpv3_interface_enable_disable_t *mp;
10767 u8 sw_if_index_set = 0;
10768 u8 enable_disable = 1;
10771 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10773 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10774 sw_if_index_set = 1;
10775 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10776 sw_if_index_set = 1;
10777 else if (unformat (i, "enable"))
10778 enable_disable = 1;
10779 else if (unformat (i, "disable"))
10780 enable_disable = 0;
10785 if (sw_if_index_set == 0)
10787 errmsg ("missing interface name or sw_if_index");
10791 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10793 mp->sw_if_index = ntohl (sw_if_index);
10794 mp->enable_disable = enable_disable;
10802 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10804 unformat_input_t *i = vam->input;
10805 vl_api_l2tpv3_set_lookup_key_t *mp;
10809 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10811 if (unformat (i, "lookup_v6_src"))
10812 key = L2T_LOOKUP_SRC_ADDRESS;
10813 else if (unformat (i, "lookup_v6_dst"))
10814 key = L2T_LOOKUP_DST_ADDRESS;
10815 else if (unformat (i, "lookup_session_id"))
10816 key = L2T_LOOKUP_SESSION_ID;
10821 if (key == (u8) ~ 0)
10823 errmsg ("l2tp session lookup key unset");
10827 M (L2TPV3_SET_LOOKUP_KEY, mp);
10836 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10837 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10839 vat_main_t *vam = &vat_main;
10841 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10842 format_ip6_address, mp->our_address,
10843 format_ip6_address, mp->client_address,
10844 clib_net_to_host_u32 (mp->sw_if_index));
10847 " local cookies %016llx %016llx remote cookie %016llx",
10848 clib_net_to_host_u64 (mp->local_cookie[0]),
10849 clib_net_to_host_u64 (mp->local_cookie[1]),
10850 clib_net_to_host_u64 (mp->remote_cookie));
10852 print (vam->ofp, " local session-id %d remote session-id %d",
10853 clib_net_to_host_u32 (mp->local_session_id),
10854 clib_net_to_host_u32 (mp->remote_session_id));
10856 print (vam->ofp, " l2 specific sublayer %s\n",
10857 mp->l2_sublayer_present ? "preset" : "absent");
10861 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10862 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10864 vat_main_t *vam = &vat_main;
10865 vat_json_node_t *node = NULL;
10866 struct in6_addr addr;
10868 if (VAT_JSON_ARRAY != vam->json_tree.type)
10870 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10871 vat_json_init_array (&vam->json_tree);
10873 node = vat_json_array_add (&vam->json_tree);
10875 vat_json_init_object (node);
10877 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10878 vat_json_object_add_ip6 (node, "our_address", addr);
10879 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10880 vat_json_object_add_ip6 (node, "client_address", addr);
10882 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10883 vat_json_init_array (lc);
10884 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10885 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10886 vat_json_object_add_uint (node, "remote_cookie",
10887 clib_net_to_host_u64 (mp->remote_cookie));
10889 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10890 vat_json_object_add_uint (node, "local_session_id",
10891 clib_net_to_host_u32 (mp->local_session_id));
10892 vat_json_object_add_uint (node, "remote_session_id",
10893 clib_net_to_host_u32 (mp->remote_session_id));
10894 vat_json_object_add_string_copy (node, "l2_sublayer",
10895 mp->l2_sublayer_present ? (u8 *) "present"
10896 : (u8 *) "absent");
10900 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10902 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10903 vl_api_control_ping_t *mp_ping;
10906 /* Get list of l2tpv3-tunnel interfaces */
10907 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10910 /* Use a control ping for synchronization */
10911 M (CONTROL_PING, mp_ping);
10919 static void vl_api_sw_interface_tap_details_t_handler
10920 (vl_api_sw_interface_tap_details_t * mp)
10922 vat_main_t *vam = &vat_main;
10924 print (vam->ofp, "%-16s %d",
10925 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10928 static void vl_api_sw_interface_tap_details_t_handler_json
10929 (vl_api_sw_interface_tap_details_t * mp)
10931 vat_main_t *vam = &vat_main;
10932 vat_json_node_t *node = NULL;
10934 if (VAT_JSON_ARRAY != vam->json_tree.type)
10936 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10937 vat_json_init_array (&vam->json_tree);
10939 node = vat_json_array_add (&vam->json_tree);
10941 vat_json_init_object (node);
10942 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10943 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10947 api_sw_interface_tap_dump (vat_main_t * vam)
10949 vl_api_sw_interface_tap_dump_t *mp;
10950 vl_api_control_ping_t *mp_ping;
10953 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10954 /* Get list of tap interfaces */
10955 M (SW_INTERFACE_TAP_DUMP, mp);
10958 /* Use a control ping for synchronization */
10959 M (CONTROL_PING, mp_ping);
10966 static uword unformat_vxlan_decap_next
10967 (unformat_input_t * input, va_list * args)
10969 u32 *result = va_arg (*args, u32 *);
10972 if (unformat (input, "l2"))
10973 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10974 else if (unformat (input, "%d", &tmp))
10982 api_vxlan_add_del_tunnel (vat_main_t * vam)
10984 unformat_input_t *line_input = vam->input;
10985 vl_api_vxlan_add_del_tunnel_t *mp;
10986 ip46_address_t src, dst;
10988 u8 ipv4_set = 0, ipv6_set = 0;
10992 u32 mcast_sw_if_index = ~0;
10993 u32 encap_vrf_id = 0;
10994 u32 decap_next_index = ~0;
10998 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10999 memset (&src, 0, sizeof src);
11000 memset (&dst, 0, sizeof dst);
11002 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11004 if (unformat (line_input, "del"))
11007 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11013 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11019 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11025 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11030 else if (unformat (line_input, "group %U %U",
11031 unformat_ip4_address, &dst.ip4,
11032 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11034 grp_set = dst_set = 1;
11037 else if (unformat (line_input, "group %U",
11038 unformat_ip4_address, &dst.ip4))
11040 grp_set = dst_set = 1;
11043 else if (unformat (line_input, "group %U %U",
11044 unformat_ip6_address, &dst.ip6,
11045 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11047 grp_set = dst_set = 1;
11050 else if (unformat (line_input, "group %U",
11051 unformat_ip6_address, &dst.ip6))
11053 grp_set = dst_set = 1;
11057 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11059 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11061 else if (unformat (line_input, "decap-next %U",
11062 unformat_vxlan_decap_next, &decap_next_index))
11064 else if (unformat (line_input, "vni %d", &vni))
11068 errmsg ("parse error '%U'", format_unformat_error, line_input);
11075 errmsg ("tunnel src address not specified");
11080 errmsg ("tunnel dst address not specified");
11084 if (grp_set && !ip46_address_is_multicast (&dst))
11086 errmsg ("tunnel group address not multicast");
11089 if (grp_set && mcast_sw_if_index == ~0)
11091 errmsg ("tunnel nonexistent multicast device");
11094 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11096 errmsg ("tunnel dst address must be unicast");
11101 if (ipv4_set && ipv6_set)
11103 errmsg ("both IPv4 and IPv6 addresses specified");
11107 if ((vni == 0) || (vni >> 24))
11109 errmsg ("vni not specified or out of range");
11113 M (VXLAN_ADD_DEL_TUNNEL, mp);
11117 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
11118 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
11122 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
11123 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
11125 mp->encap_vrf_id = ntohl (encap_vrf_id);
11126 mp->decap_next_index = ntohl (decap_next_index);
11127 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11128 mp->vni = ntohl (vni);
11129 mp->is_add = is_add;
11130 mp->is_ipv6 = ipv6_set;
11137 static void vl_api_vxlan_tunnel_details_t_handler
11138 (vl_api_vxlan_tunnel_details_t * mp)
11140 vat_main_t *vam = &vat_main;
11141 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
11142 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
11144 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
11145 ntohl (mp->sw_if_index),
11146 format_ip46_address, &src, IP46_TYPE_ANY,
11147 format_ip46_address, &dst, IP46_TYPE_ANY,
11148 ntohl (mp->encap_vrf_id),
11149 ntohl (mp->decap_next_index), ntohl (mp->vni),
11150 ntohl (mp->mcast_sw_if_index));
11153 static void vl_api_vxlan_tunnel_details_t_handler_json
11154 (vl_api_vxlan_tunnel_details_t * mp)
11156 vat_main_t *vam = &vat_main;
11157 vat_json_node_t *node = NULL;
11159 if (VAT_JSON_ARRAY != vam->json_tree.type)
11161 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11162 vat_json_init_array (&vam->json_tree);
11164 node = vat_json_array_add (&vam->json_tree);
11166 vat_json_init_object (node);
11167 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11170 struct in6_addr ip6;
11172 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
11173 vat_json_object_add_ip6 (node, "src_address", ip6);
11174 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
11175 vat_json_object_add_ip6 (node, "dst_address", ip6);
11179 struct in_addr ip4;
11181 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
11182 vat_json_object_add_ip4 (node, "src_address", ip4);
11183 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
11184 vat_json_object_add_ip4 (node, "dst_address", ip4);
11186 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11187 vat_json_object_add_uint (node, "decap_next_index",
11188 ntohl (mp->decap_next_index));
11189 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11190 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11191 vat_json_object_add_uint (node, "mcast_sw_if_index",
11192 ntohl (mp->mcast_sw_if_index));
11196 api_vxlan_tunnel_dump (vat_main_t * vam)
11198 unformat_input_t *i = vam->input;
11199 vl_api_vxlan_tunnel_dump_t *mp;
11200 vl_api_control_ping_t *mp_ping;
11202 u8 sw_if_index_set = 0;
11205 /* Parse args required to build the message */
11206 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11208 if (unformat (i, "sw_if_index %d", &sw_if_index))
11209 sw_if_index_set = 1;
11214 if (sw_if_index_set == 0)
11219 if (!vam->json_output)
11221 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
11222 "sw_if_index", "src_address", "dst_address",
11223 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11226 /* Get list of vxlan-tunnel interfaces */
11227 M (VXLAN_TUNNEL_DUMP, mp);
11229 mp->sw_if_index = htonl (sw_if_index);
11233 /* Use a control ping for synchronization */
11234 M (CONTROL_PING, mp_ping);
11242 api_gre_add_del_tunnel (vat_main_t * vam)
11244 unformat_input_t *line_input = vam->input;
11245 vl_api_gre_add_del_tunnel_t *mp;
11246 ip4_address_t src4, dst4;
11247 ip6_address_t src6, dst6;
11254 u32 outer_fib_id = 0;
11257 memset (&src4, 0, sizeof src4);
11258 memset (&dst4, 0, sizeof dst4);
11259 memset (&src6, 0, sizeof src6);
11260 memset (&dst6, 0, sizeof dst6);
11262 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11264 if (unformat (line_input, "del"))
11266 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
11271 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
11276 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
11281 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
11286 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
11288 else if (unformat (line_input, "teb"))
11292 errmsg ("parse error '%U'", format_unformat_error, line_input);
11299 errmsg ("tunnel src address not specified");
11304 errmsg ("tunnel dst address not specified");
11307 if (ipv4_set && ipv6_set)
11309 errmsg ("both IPv4 and IPv6 addresses specified");
11314 M (GRE_ADD_DEL_TUNNEL, mp);
11318 clib_memcpy (&mp->src_address, &src4, 4);
11319 clib_memcpy (&mp->dst_address, &dst4, 4);
11323 clib_memcpy (&mp->src_address, &src6, 16);
11324 clib_memcpy (&mp->dst_address, &dst6, 16);
11326 mp->outer_fib_id = ntohl (outer_fib_id);
11327 mp->is_add = is_add;
11329 mp->is_ipv6 = ipv6_set;
11336 static void vl_api_gre_tunnel_details_t_handler
11337 (vl_api_gre_tunnel_details_t * mp)
11339 vat_main_t *vam = &vat_main;
11340 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
11341 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
11343 print (vam->ofp, "%11d%24U%24U%6d%14d",
11344 ntohl (mp->sw_if_index),
11345 format_ip46_address, &src, IP46_TYPE_ANY,
11346 format_ip46_address, &dst, IP46_TYPE_ANY,
11347 mp->teb, ntohl (mp->outer_fib_id));
11350 static void vl_api_gre_tunnel_details_t_handler_json
11351 (vl_api_gre_tunnel_details_t * mp)
11353 vat_main_t *vam = &vat_main;
11354 vat_json_node_t *node = NULL;
11355 struct in_addr ip4;
11356 struct in6_addr ip6;
11358 if (VAT_JSON_ARRAY != vam->json_tree.type)
11360 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11361 vat_json_init_array (&vam->json_tree);
11363 node = vat_json_array_add (&vam->json_tree);
11365 vat_json_init_object (node);
11366 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11369 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11370 vat_json_object_add_ip4 (node, "src_address", ip4);
11371 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11372 vat_json_object_add_ip4 (node, "dst_address", ip4);
11376 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
11377 vat_json_object_add_ip6 (node, "src_address", ip6);
11378 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
11379 vat_json_object_add_ip6 (node, "dst_address", ip6);
11381 vat_json_object_add_uint (node, "teb", mp->teb);
11382 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11383 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
11387 api_gre_tunnel_dump (vat_main_t * vam)
11389 unformat_input_t *i = vam->input;
11390 vl_api_gre_tunnel_dump_t *mp;
11391 vl_api_control_ping_t *mp_ping;
11393 u8 sw_if_index_set = 0;
11396 /* Parse args required to build the message */
11397 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11399 if (unformat (i, "sw_if_index %d", &sw_if_index))
11400 sw_if_index_set = 1;
11405 if (sw_if_index_set == 0)
11410 if (!vam->json_output)
11412 print (vam->ofp, "%11s%24s%24s%6s%14s",
11413 "sw_if_index", "src_address", "dst_address", "teb",
11417 /* Get list of gre-tunnel interfaces */
11418 M (GRE_TUNNEL_DUMP, mp);
11420 mp->sw_if_index = htonl (sw_if_index);
11424 /* Use a control ping for synchronization */
11425 M (CONTROL_PING, mp_ping);
11433 api_l2_fib_clear_table (vat_main_t * vam)
11435 // unformat_input_t * i = vam->input;
11436 vl_api_l2_fib_clear_table_t *mp;
11439 M (L2_FIB_CLEAR_TABLE, mp);
11447 api_l2_interface_efp_filter (vat_main_t * vam)
11449 unformat_input_t *i = vam->input;
11450 vl_api_l2_interface_efp_filter_t *mp;
11453 u8 sw_if_index_set = 0;
11456 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11458 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11459 sw_if_index_set = 1;
11460 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11461 sw_if_index_set = 1;
11462 else if (unformat (i, "enable"))
11464 else if (unformat (i, "disable"))
11468 clib_warning ("parse error '%U'", format_unformat_error, i);
11473 if (sw_if_index_set == 0)
11475 errmsg ("missing sw_if_index");
11479 M (L2_INTERFACE_EFP_FILTER, mp);
11481 mp->sw_if_index = ntohl (sw_if_index);
11482 mp->enable_disable = enable;
11489 #define foreach_vtr_op \
11490 _("disable", L2_VTR_DISABLED) \
11491 _("push-1", L2_VTR_PUSH_1) \
11492 _("push-2", L2_VTR_PUSH_2) \
11493 _("pop-1", L2_VTR_POP_1) \
11494 _("pop-2", L2_VTR_POP_2) \
11495 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11496 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11497 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11498 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11501 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11503 unformat_input_t *i = vam->input;
11504 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11506 u8 sw_if_index_set = 0;
11509 u32 push_dot1q = 1;
11514 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11516 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11517 sw_if_index_set = 1;
11518 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11519 sw_if_index_set = 1;
11520 else if (unformat (i, "vtr_op %d", &vtr_op))
11522 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11525 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11527 else if (unformat (i, "tag1 %d", &tag1))
11529 else if (unformat (i, "tag2 %d", &tag2))
11533 clib_warning ("parse error '%U'", format_unformat_error, i);
11538 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11540 errmsg ("missing vtr operation or sw_if_index");
11544 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11545 mp->sw_if_index = ntohl (sw_if_index);
11546 mp->vtr_op = ntohl (vtr_op);
11547 mp->push_dot1q = ntohl (push_dot1q);
11548 mp->tag1 = ntohl (tag1);
11549 mp->tag2 = ntohl (tag2);
11557 api_create_vhost_user_if (vat_main_t * vam)
11559 unformat_input_t *i = vam->input;
11560 vl_api_create_vhost_user_if_t *mp;
11563 u8 file_name_set = 0;
11564 u32 custom_dev_instance = ~0;
11566 u8 use_custom_mac = 0;
11570 /* Shut up coverity */
11571 memset (hwaddr, 0, sizeof (hwaddr));
11573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11575 if (unformat (i, "socket %s", &file_name))
11579 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11581 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11582 use_custom_mac = 1;
11583 else if (unformat (i, "server"))
11585 else if (unformat (i, "tag %s", &tag))
11591 if (file_name_set == 0)
11593 errmsg ("missing socket file name");
11597 if (vec_len (file_name) > 255)
11599 errmsg ("socket file name too long");
11602 vec_add1 (file_name, 0);
11604 M (CREATE_VHOST_USER_IF, mp);
11606 mp->is_server = is_server;
11607 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11608 vec_free (file_name);
11609 if (custom_dev_instance != ~0)
11612 mp->custom_dev_instance = ntohl (custom_dev_instance);
11614 mp->use_custom_mac = use_custom_mac;
11615 clib_memcpy (mp->mac_address, hwaddr, 6);
11617 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11626 api_modify_vhost_user_if (vat_main_t * vam)
11628 unformat_input_t *i = vam->input;
11629 vl_api_modify_vhost_user_if_t *mp;
11632 u8 file_name_set = 0;
11633 u32 custom_dev_instance = ~0;
11634 u8 sw_if_index_set = 0;
11635 u32 sw_if_index = (u32) ~ 0;
11638 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11640 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11641 sw_if_index_set = 1;
11642 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11643 sw_if_index_set = 1;
11644 else if (unformat (i, "socket %s", &file_name))
11648 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11650 else if (unformat (i, "server"))
11656 if (sw_if_index_set == 0)
11658 errmsg ("missing sw_if_index or interface name");
11662 if (file_name_set == 0)
11664 errmsg ("missing socket file name");
11668 if (vec_len (file_name) > 255)
11670 errmsg ("socket file name too long");
11673 vec_add1 (file_name, 0);
11675 M (MODIFY_VHOST_USER_IF, mp);
11677 mp->sw_if_index = ntohl (sw_if_index);
11678 mp->is_server = is_server;
11679 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11680 vec_free (file_name);
11681 if (custom_dev_instance != ~0)
11684 mp->custom_dev_instance = ntohl (custom_dev_instance);
11693 api_delete_vhost_user_if (vat_main_t * vam)
11695 unformat_input_t *i = vam->input;
11696 vl_api_delete_vhost_user_if_t *mp;
11697 u32 sw_if_index = ~0;
11698 u8 sw_if_index_set = 0;
11701 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11703 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11704 sw_if_index_set = 1;
11705 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11706 sw_if_index_set = 1;
11711 if (sw_if_index_set == 0)
11713 errmsg ("missing sw_if_index or interface name");
11718 M (DELETE_VHOST_USER_IF, mp);
11720 mp->sw_if_index = ntohl (sw_if_index);
11727 static void vl_api_sw_interface_vhost_user_details_t_handler
11728 (vl_api_sw_interface_vhost_user_details_t * mp)
11730 vat_main_t *vam = &vat_main;
11732 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11733 (char *) mp->interface_name,
11734 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11735 clib_net_to_host_u64 (mp->features), mp->is_server,
11736 ntohl (mp->num_regions), (char *) mp->sock_filename);
11737 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11740 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11741 (vl_api_sw_interface_vhost_user_details_t * mp)
11743 vat_main_t *vam = &vat_main;
11744 vat_json_node_t *node = NULL;
11746 if (VAT_JSON_ARRAY != vam->json_tree.type)
11748 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11749 vat_json_init_array (&vam->json_tree);
11751 node = vat_json_array_add (&vam->json_tree);
11753 vat_json_init_object (node);
11754 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11755 vat_json_object_add_string_copy (node, "interface_name",
11756 mp->interface_name);
11757 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11758 ntohl (mp->virtio_net_hdr_sz));
11759 vat_json_object_add_uint (node, "features",
11760 clib_net_to_host_u64 (mp->features));
11761 vat_json_object_add_uint (node, "is_server", mp->is_server);
11762 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11763 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11764 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11768 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11770 vl_api_sw_interface_vhost_user_dump_t *mp;
11771 vl_api_control_ping_t *mp_ping;
11774 "Interface name idx hdr_sz features server regions filename");
11776 /* Get list of vhost-user interfaces */
11777 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11780 /* Use a control ping for synchronization */
11781 M (CONTROL_PING, mp_ping);
11789 api_show_version (vat_main_t * vam)
11791 vl_api_show_version_t *mp;
11794 M (SHOW_VERSION, mp);
11803 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11805 unformat_input_t *line_input = vam->input;
11806 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11807 ip4_address_t local4, remote4;
11808 ip6_address_t local6, remote6;
11810 u8 ipv4_set = 0, ipv6_set = 0;
11813 u32 encap_vrf_id = 0;
11814 u32 decap_vrf_id = 0;
11820 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11822 if (unformat (line_input, "del"))
11824 else if (unformat (line_input, "local %U",
11825 unformat_ip4_address, &local4))
11830 else if (unformat (line_input, "remote %U",
11831 unformat_ip4_address, &remote4))
11836 else if (unformat (line_input, "local %U",
11837 unformat_ip6_address, &local6))
11842 else if (unformat (line_input, "remote %U",
11843 unformat_ip6_address, &remote6))
11848 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11850 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11852 else if (unformat (line_input, "vni %d", &vni))
11854 else if (unformat (line_input, "next-ip4"))
11856 else if (unformat (line_input, "next-ip6"))
11858 else if (unformat (line_input, "next-ethernet"))
11860 else if (unformat (line_input, "next-nsh"))
11864 errmsg ("parse error '%U'", format_unformat_error, line_input);
11869 if (local_set == 0)
11871 errmsg ("tunnel local address not specified");
11874 if (remote_set == 0)
11876 errmsg ("tunnel remote address not specified");
11879 if (ipv4_set && ipv6_set)
11881 errmsg ("both IPv4 and IPv6 addresses specified");
11887 errmsg ("vni not specified");
11891 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11896 clib_memcpy (&mp->local, &local6, sizeof (local6));
11897 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11901 clib_memcpy (&mp->local, &local4, sizeof (local4));
11902 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11905 mp->encap_vrf_id = ntohl (encap_vrf_id);
11906 mp->decap_vrf_id = ntohl (decap_vrf_id);
11907 mp->protocol = protocol;
11908 mp->vni = ntohl (vni);
11909 mp->is_add = is_add;
11910 mp->is_ipv6 = ipv6_set;
11917 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11918 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11920 vat_main_t *vam = &vat_main;
11922 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11923 ntohl (mp->sw_if_index),
11924 format_ip46_address, &(mp->local[0]),
11925 format_ip46_address, &(mp->remote[0]),
11927 ntohl (mp->protocol),
11928 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11931 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11932 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11934 vat_main_t *vam = &vat_main;
11935 vat_json_node_t *node = NULL;
11936 struct in_addr ip4;
11937 struct in6_addr ip6;
11939 if (VAT_JSON_ARRAY != vam->json_tree.type)
11941 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11942 vat_json_init_array (&vam->json_tree);
11944 node = vat_json_array_add (&vam->json_tree);
11946 vat_json_init_object (node);
11947 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11950 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11951 vat_json_object_add_ip6 (node, "local", ip6);
11952 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11953 vat_json_object_add_ip6 (node, "remote", ip6);
11957 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11958 vat_json_object_add_ip4 (node, "local", ip4);
11959 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11960 vat_json_object_add_ip4 (node, "remote", ip4);
11962 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11963 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11964 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11965 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11966 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11970 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11972 unformat_input_t *i = vam->input;
11973 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11974 vl_api_control_ping_t *mp_ping;
11976 u8 sw_if_index_set = 0;
11979 /* Parse args required to build the message */
11980 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11982 if (unformat (i, "sw_if_index %d", &sw_if_index))
11983 sw_if_index_set = 1;
11988 if (sw_if_index_set == 0)
11993 if (!vam->json_output)
11995 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11996 "sw_if_index", "local", "remote", "vni",
11997 "protocol", "encap_vrf_id", "decap_vrf_id");
12000 /* Get list of vxlan-tunnel interfaces */
12001 M (VXLAN_GPE_TUNNEL_DUMP, mp);
12003 mp->sw_if_index = htonl (sw_if_index);
12007 /* Use a control ping for synchronization */
12008 M (CONTROL_PING, mp_ping);
12016 format_l2_fib_mac_address (u8 * s, va_list * args)
12018 u8 *a = va_arg (*args, u8 *);
12020 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
12021 a[2], a[3], a[4], a[5], a[6], a[7]);
12024 static void vl_api_l2_fib_table_details_t_handler
12025 (vl_api_l2_fib_table_details_t * mp)
12027 vat_main_t *vam = &vat_main;
12029 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
12031 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
12032 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
12036 static void vl_api_l2_fib_table_details_t_handler_json
12037 (vl_api_l2_fib_table_details_t * mp)
12039 vat_main_t *vam = &vat_main;
12040 vat_json_node_t *node = NULL;
12042 if (VAT_JSON_ARRAY != vam->json_tree.type)
12044 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12045 vat_json_init_array (&vam->json_tree);
12047 node = vat_json_array_add (&vam->json_tree);
12049 vat_json_init_object (node);
12050 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
12051 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
12052 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12053 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
12054 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
12055 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
12059 api_l2_fib_table_dump (vat_main_t * vam)
12061 unformat_input_t *i = vam->input;
12062 vl_api_l2_fib_table_dump_t *mp;
12063 vl_api_control_ping_t *mp_ping;
12068 /* Parse args required to build the message */
12069 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12071 if (unformat (i, "bd_id %d", &bd_id))
12077 if (bd_id_set == 0)
12079 errmsg ("missing bridge domain");
12083 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
12085 /* Get list of l2 fib entries */
12086 M (L2_FIB_TABLE_DUMP, mp);
12088 mp->bd_id = ntohl (bd_id);
12091 /* Use a control ping for synchronization */
12092 M (CONTROL_PING, mp_ping);
12101 api_interface_name_renumber (vat_main_t * vam)
12103 unformat_input_t *line_input = vam->input;
12104 vl_api_interface_name_renumber_t *mp;
12105 u32 sw_if_index = ~0;
12106 u32 new_show_dev_instance = ~0;
12109 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12111 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
12114 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12116 else if (unformat (line_input, "new_show_dev_instance %d",
12117 &new_show_dev_instance))
12123 if (sw_if_index == ~0)
12125 errmsg ("missing interface name or sw_if_index");
12129 if (new_show_dev_instance == ~0)
12131 errmsg ("missing new_show_dev_instance");
12135 M (INTERFACE_NAME_RENUMBER, mp);
12137 mp->sw_if_index = ntohl (sw_if_index);
12138 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
12146 api_want_ip4_arp_events (vat_main_t * vam)
12148 unformat_input_t *line_input = vam->input;
12149 vl_api_want_ip4_arp_events_t *mp;
12150 ip4_address_t address;
12151 int address_set = 0;
12152 u32 enable_disable = 1;
12155 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12157 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
12159 else if (unformat (line_input, "del"))
12160 enable_disable = 0;
12165 if (address_set == 0)
12167 errmsg ("missing addresses");
12171 M (WANT_IP4_ARP_EVENTS, mp);
12172 mp->enable_disable = enable_disable;
12173 mp->pid = htonl (getpid ());
12174 mp->address = address.as_u32;
12182 api_want_ip6_nd_events (vat_main_t * vam)
12184 unformat_input_t *line_input = vam->input;
12185 vl_api_want_ip6_nd_events_t *mp;
12186 ip6_address_t address;
12187 int address_set = 0;
12188 u32 enable_disable = 1;
12191 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12193 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
12195 else if (unformat (line_input, "del"))
12196 enable_disable = 0;
12201 if (address_set == 0)
12203 errmsg ("missing addresses");
12207 M (WANT_IP6_ND_EVENTS, mp);
12208 mp->enable_disable = enable_disable;
12209 mp->pid = htonl (getpid ());
12210 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
12218 api_input_acl_set_interface (vat_main_t * vam)
12220 unformat_input_t *i = vam->input;
12221 vl_api_input_acl_set_interface_t *mp;
12223 int sw_if_index_set;
12224 u32 ip4_table_index = ~0;
12225 u32 ip6_table_index = ~0;
12226 u32 l2_table_index = ~0;
12230 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12232 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12233 sw_if_index_set = 1;
12234 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12235 sw_if_index_set = 1;
12236 else if (unformat (i, "del"))
12238 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12240 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12242 else if (unformat (i, "l2-table %d", &l2_table_index))
12246 clib_warning ("parse error '%U'", format_unformat_error, i);
12251 if (sw_if_index_set == 0)
12253 errmsg ("missing interface name or sw_if_index");
12257 M (INPUT_ACL_SET_INTERFACE, mp);
12259 mp->sw_if_index = ntohl (sw_if_index);
12260 mp->ip4_table_index = ntohl (ip4_table_index);
12261 mp->ip6_table_index = ntohl (ip6_table_index);
12262 mp->l2_table_index = ntohl (l2_table_index);
12263 mp->is_add = is_add;
12271 api_ip_address_dump (vat_main_t * vam)
12273 unformat_input_t *i = vam->input;
12274 vl_api_ip_address_dump_t *mp;
12275 vl_api_control_ping_t *mp_ping;
12276 u32 sw_if_index = ~0;
12277 u8 sw_if_index_set = 0;
12282 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12284 if (unformat (i, "sw_if_index %d", &sw_if_index))
12285 sw_if_index_set = 1;
12287 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12288 sw_if_index_set = 1;
12289 else if (unformat (i, "ipv4"))
12291 else if (unformat (i, "ipv6"))
12297 if (ipv4_set && ipv6_set)
12299 errmsg ("ipv4 and ipv6 flags cannot be both set");
12303 if ((!ipv4_set) && (!ipv6_set))
12305 errmsg ("no ipv4 nor ipv6 flag set");
12309 if (sw_if_index_set == 0)
12311 errmsg ("missing interface name or sw_if_index");
12315 vam->current_sw_if_index = sw_if_index;
12316 vam->is_ipv6 = ipv6_set;
12318 M (IP_ADDRESS_DUMP, mp);
12319 mp->sw_if_index = ntohl (sw_if_index);
12320 mp->is_ipv6 = ipv6_set;
12323 /* Use a control ping for synchronization */
12324 M (CONTROL_PING, mp_ping);
12332 api_ip_dump (vat_main_t * vam)
12334 vl_api_ip_dump_t *mp;
12335 vl_api_control_ping_t *mp_ping;
12336 unformat_input_t *in = vam->input;
12343 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
12345 if (unformat (in, "ipv4"))
12347 else if (unformat (in, "ipv6"))
12353 if (ipv4_set && ipv6_set)
12355 errmsg ("ipv4 and ipv6 flags cannot be both set");
12359 if ((!ipv4_set) && (!ipv6_set))
12361 errmsg ("no ipv4 nor ipv6 flag set");
12365 is_ipv6 = ipv6_set;
12366 vam->is_ipv6 = is_ipv6;
12368 /* free old data */
12369 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12371 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12373 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12376 mp->is_ipv6 = ipv6_set;
12379 /* Use a control ping for synchronization */
12380 M (CONTROL_PING, mp_ping);
12388 api_ipsec_spd_add_del (vat_main_t * vam)
12390 unformat_input_t *i = vam->input;
12391 vl_api_ipsec_spd_add_del_t *mp;
12396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12398 if (unformat (i, "spd_id %d", &spd_id))
12400 else if (unformat (i, "del"))
12404 clib_warning ("parse error '%U'", format_unformat_error, i);
12410 errmsg ("spd_id must be set");
12414 M (IPSEC_SPD_ADD_DEL, mp);
12416 mp->spd_id = ntohl (spd_id);
12417 mp->is_add = is_add;
12425 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12427 unformat_input_t *i = vam->input;
12428 vl_api_ipsec_interface_add_del_spd_t *mp;
12430 u8 sw_if_index_set = 0;
12431 u32 spd_id = (u32) ~ 0;
12435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12437 if (unformat (i, "del"))
12439 else if (unformat (i, "spd_id %d", &spd_id))
12442 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12443 sw_if_index_set = 1;
12444 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12445 sw_if_index_set = 1;
12448 clib_warning ("parse error '%U'", format_unformat_error, i);
12454 if (spd_id == (u32) ~ 0)
12456 errmsg ("spd_id must be set");
12460 if (sw_if_index_set == 0)
12462 errmsg ("missing interface name or sw_if_index");
12466 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12468 mp->spd_id = ntohl (spd_id);
12469 mp->sw_if_index = ntohl (sw_if_index);
12470 mp->is_add = is_add;
12478 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12480 unformat_input_t *i = vam->input;
12481 vl_api_ipsec_spd_add_del_entry_t *mp;
12482 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12483 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12485 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12486 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12487 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12488 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12491 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12492 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12493 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12494 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12495 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12496 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12498 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12500 if (unformat (i, "del"))
12502 if (unformat (i, "outbound"))
12504 if (unformat (i, "inbound"))
12506 else if (unformat (i, "spd_id %d", &spd_id))
12508 else if (unformat (i, "sa_id %d", &sa_id))
12510 else if (unformat (i, "priority %d", &priority))
12512 else if (unformat (i, "protocol %d", &protocol))
12514 else if (unformat (i, "lport_start %d", &lport_start))
12516 else if (unformat (i, "lport_stop %d", &lport_stop))
12518 else if (unformat (i, "rport_start %d", &rport_start))
12520 else if (unformat (i, "rport_stop %d", &rport_stop))
12524 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12530 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12537 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12543 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12550 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12556 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12563 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12569 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12575 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12577 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12579 clib_warning ("unsupported action: 'resolve'");
12585 clib_warning ("parse error '%U'", format_unformat_error, i);
12591 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12593 mp->spd_id = ntohl (spd_id);
12594 mp->priority = ntohl (priority);
12595 mp->is_outbound = is_outbound;
12597 mp->is_ipv6 = is_ipv6;
12598 if (is_ipv6 || is_ip_any)
12600 clib_memcpy (mp->remote_address_start, &raddr6_start,
12601 sizeof (ip6_address_t));
12602 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12603 sizeof (ip6_address_t));
12604 clib_memcpy (mp->local_address_start, &laddr6_start,
12605 sizeof (ip6_address_t));
12606 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12607 sizeof (ip6_address_t));
12611 clib_memcpy (mp->remote_address_start, &raddr4_start,
12612 sizeof (ip4_address_t));
12613 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12614 sizeof (ip4_address_t));
12615 clib_memcpy (mp->local_address_start, &laddr4_start,
12616 sizeof (ip4_address_t));
12617 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12618 sizeof (ip4_address_t));
12620 mp->protocol = (u8) protocol;
12621 mp->local_port_start = ntohs ((u16) lport_start);
12622 mp->local_port_stop = ntohs ((u16) lport_stop);
12623 mp->remote_port_start = ntohs ((u16) rport_start);
12624 mp->remote_port_stop = ntohs ((u16) rport_stop);
12625 mp->policy = (u8) policy;
12626 mp->sa_id = ntohl (sa_id);
12627 mp->is_add = is_add;
12628 mp->is_ip_any = is_ip_any;
12635 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12637 unformat_input_t *i = vam->input;
12638 vl_api_ipsec_sad_add_del_entry_t *mp;
12639 u32 sad_id = 0, spi = 0;
12640 u8 *ck = 0, *ik = 0;
12643 u8 protocol = IPSEC_PROTOCOL_AH;
12644 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12645 u32 crypto_alg = 0, integ_alg = 0;
12646 ip4_address_t tun_src4;
12647 ip4_address_t tun_dst4;
12648 ip6_address_t tun_src6;
12649 ip6_address_t tun_dst6;
12652 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12654 if (unformat (i, "del"))
12656 else if (unformat (i, "sad_id %d", &sad_id))
12658 else if (unformat (i, "spi %d", &spi))
12660 else if (unformat (i, "esp"))
12661 protocol = IPSEC_PROTOCOL_ESP;
12662 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12665 is_tunnel_ipv6 = 0;
12667 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12670 is_tunnel_ipv6 = 0;
12672 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12675 is_tunnel_ipv6 = 1;
12677 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12680 is_tunnel_ipv6 = 1;
12684 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12686 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12687 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12689 clib_warning ("unsupported crypto-alg: '%U'",
12690 format_ipsec_crypto_alg, crypto_alg);
12694 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12698 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12700 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12701 integ_alg >= IPSEC_INTEG_N_ALG)
12703 clib_warning ("unsupported integ-alg: '%U'",
12704 format_ipsec_integ_alg, integ_alg);
12708 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12712 clib_warning ("parse error '%U'", format_unformat_error, i);
12718 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12720 mp->sad_id = ntohl (sad_id);
12721 mp->is_add = is_add;
12722 mp->protocol = protocol;
12723 mp->spi = ntohl (spi);
12724 mp->is_tunnel = is_tunnel;
12725 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12726 mp->crypto_algorithm = crypto_alg;
12727 mp->integrity_algorithm = integ_alg;
12728 mp->crypto_key_length = vec_len (ck);
12729 mp->integrity_key_length = vec_len (ik);
12731 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12732 mp->crypto_key_length = sizeof (mp->crypto_key);
12734 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12735 mp->integrity_key_length = sizeof (mp->integrity_key);
12738 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12740 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12744 if (is_tunnel_ipv6)
12746 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12747 sizeof (ip6_address_t));
12748 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12749 sizeof (ip6_address_t));
12753 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12754 sizeof (ip4_address_t));
12755 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12756 sizeof (ip4_address_t));
12766 api_ipsec_sa_set_key (vat_main_t * vam)
12768 unformat_input_t *i = vam->input;
12769 vl_api_ipsec_sa_set_key_t *mp;
12771 u8 *ck = 0, *ik = 0;
12774 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12776 if (unformat (i, "sa_id %d", &sa_id))
12778 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12780 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12784 clib_warning ("parse error '%U'", format_unformat_error, i);
12789 M (IPSEC_SA_SET_KEY, mp);
12791 mp->sa_id = ntohl (sa_id);
12792 mp->crypto_key_length = vec_len (ck);
12793 mp->integrity_key_length = vec_len (ik);
12795 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12796 mp->crypto_key_length = sizeof (mp->crypto_key);
12798 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12799 mp->integrity_key_length = sizeof (mp->integrity_key);
12802 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12804 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12812 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
12814 unformat_input_t *i = vam->input;
12815 vl_api_ipsec_tunnel_if_add_del_t *mp;
12816 u32 local_spi = 0, remote_spi = 0;
12817 u32 crypto_alg = 0, integ_alg = 0;
12818 u8 *lck = NULL, *rck = NULL;
12819 u8 *lik = NULL, *rik = NULL;
12820 ip4_address_t local_ip = { {0} };
12821 ip4_address_t remote_ip = { {0} };
12824 u8 anti_replay = 0;
12827 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12829 if (unformat (i, "del"))
12831 else if (unformat (i, "esn"))
12833 else if (unformat (i, "anti_replay"))
12835 else if (unformat (i, "local_spi %d", &local_spi))
12837 else if (unformat (i, "remote_spi %d", &remote_spi))
12839 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
12841 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
12843 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
12846 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
12848 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
12850 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
12854 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12856 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12857 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12859 errmsg ("unsupported crypto-alg: '%U'\n",
12860 format_ipsec_crypto_alg, crypto_alg);
12866 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12868 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12869 integ_alg >= IPSEC_INTEG_N_ALG)
12871 errmsg ("unsupported integ-alg: '%U'\n",
12872 format_ipsec_integ_alg, integ_alg);
12878 errmsg ("parse error '%U'\n", format_unformat_error, i);
12883 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
12885 mp->is_add = is_add;
12887 mp->anti_replay = anti_replay;
12889 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
12890 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
12892 mp->local_spi = htonl (local_spi);
12893 mp->remote_spi = htonl (remote_spi);
12894 mp->crypto_alg = (u8) crypto_alg;
12896 mp->local_crypto_key_len = 0;
12899 mp->local_crypto_key_len = vec_len (lck);
12900 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
12901 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
12902 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
12905 mp->remote_crypto_key_len = 0;
12908 mp->remote_crypto_key_len = vec_len (rck);
12909 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
12910 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
12911 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
12914 mp->integ_alg = (u8) integ_alg;
12916 mp->local_integ_key_len = 0;
12919 mp->local_integ_key_len = vec_len (lik);
12920 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
12921 mp->local_integ_key_len = sizeof (mp->local_integ_key);
12922 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
12925 mp->remote_integ_key_len = 0;
12928 mp->remote_integ_key_len = vec_len (rik);
12929 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
12930 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
12931 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
12940 api_ikev2_profile_add_del (vat_main_t * vam)
12942 unformat_input_t *i = vam->input;
12943 vl_api_ikev2_profile_add_del_t *mp;
12948 const char *valid_chars = "a-zA-Z0-9_";
12950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12952 if (unformat (i, "del"))
12954 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12955 vec_add1 (name, 0);
12958 errmsg ("parse error '%U'", format_unformat_error, i);
12963 if (!vec_len (name))
12965 errmsg ("profile name must be specified");
12969 if (vec_len (name) > 64)
12971 errmsg ("profile name too long");
12975 M (IKEV2_PROFILE_ADD_DEL, mp);
12977 clib_memcpy (mp->name, name, vec_len (name));
12978 mp->is_add = is_add;
12987 api_ikev2_profile_set_auth (vat_main_t * vam)
12989 unformat_input_t *i = vam->input;
12990 vl_api_ikev2_profile_set_auth_t *mp;
12993 u32 auth_method = 0;
12997 const char *valid_chars = "a-zA-Z0-9_";
12999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13001 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13002 vec_add1 (name, 0);
13003 else if (unformat (i, "auth_method %U",
13004 unformat_ikev2_auth_method, &auth_method))
13006 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
13008 else if (unformat (i, "auth_data %v", &data))
13012 errmsg ("parse error '%U'", format_unformat_error, i);
13017 if (!vec_len (name))
13019 errmsg ("profile name must be specified");
13023 if (vec_len (name) > 64)
13025 errmsg ("profile name too long");
13029 if (!vec_len (data))
13031 errmsg ("auth_data must be specified");
13037 errmsg ("auth_method must be specified");
13041 M (IKEV2_PROFILE_SET_AUTH, mp);
13043 mp->is_hex = is_hex;
13044 mp->auth_method = (u8) auth_method;
13045 mp->data_len = vec_len (data);
13046 clib_memcpy (mp->name, name, vec_len (name));
13047 clib_memcpy (mp->data, data, vec_len (data));
13057 api_ikev2_profile_set_id (vat_main_t * vam)
13059 unformat_input_t *i = vam->input;
13060 vl_api_ikev2_profile_set_id_t *mp;
13068 const char *valid_chars = "a-zA-Z0-9_";
13070 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13072 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13073 vec_add1 (name, 0);
13074 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
13076 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
13078 data = vec_new (u8, 4);
13079 clib_memcpy (data, ip4.as_u8, 4);
13081 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
13083 else if (unformat (i, "id_data %v", &data))
13085 else if (unformat (i, "local"))
13087 else if (unformat (i, "remote"))
13091 errmsg ("parse error '%U'", format_unformat_error, i);
13096 if (!vec_len (name))
13098 errmsg ("profile name must be specified");
13102 if (vec_len (name) > 64)
13104 errmsg ("profile name too long");
13108 if (!vec_len (data))
13110 errmsg ("id_data must be specified");
13116 errmsg ("id_type must be specified");
13120 M (IKEV2_PROFILE_SET_ID, mp);
13122 mp->is_local = is_local;
13123 mp->id_type = (u8) id_type;
13124 mp->data_len = vec_len (data);
13125 clib_memcpy (mp->name, name, vec_len (name));
13126 clib_memcpy (mp->data, data, vec_len (data));
13136 api_ikev2_profile_set_ts (vat_main_t * vam)
13138 unformat_input_t *i = vam->input;
13139 vl_api_ikev2_profile_set_ts_t *mp;
13142 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
13143 ip4_address_t start_addr, end_addr;
13145 const char *valid_chars = "a-zA-Z0-9_";
13148 start_addr.as_u32 = 0;
13149 end_addr.as_u32 = (u32) ~ 0;
13151 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13153 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13154 vec_add1 (name, 0);
13155 else if (unformat (i, "protocol %d", &proto))
13157 else if (unformat (i, "start_port %d", &start_port))
13159 else if (unformat (i, "end_port %d", &end_port))
13162 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
13164 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
13166 else if (unformat (i, "local"))
13168 else if (unformat (i, "remote"))
13172 errmsg ("parse error '%U'", format_unformat_error, i);
13177 if (!vec_len (name))
13179 errmsg ("profile name must be specified");
13183 if (vec_len (name) > 64)
13185 errmsg ("profile name too long");
13189 M (IKEV2_PROFILE_SET_TS, mp);
13191 mp->is_local = is_local;
13192 mp->proto = (u8) proto;
13193 mp->start_port = (u16) start_port;
13194 mp->end_port = (u16) end_port;
13195 mp->start_addr = start_addr.as_u32;
13196 mp->end_addr = end_addr.as_u32;
13197 clib_memcpy (mp->name, name, vec_len (name));
13206 api_ikev2_set_local_key (vat_main_t * vam)
13208 unformat_input_t *i = vam->input;
13209 vl_api_ikev2_set_local_key_t *mp;
13213 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13215 if (unformat (i, "file %v", &file))
13216 vec_add1 (file, 0);
13219 errmsg ("parse error '%U'", format_unformat_error, i);
13224 if (!vec_len (file))
13226 errmsg ("RSA key file must be specified");
13230 if (vec_len (file) > 256)
13232 errmsg ("file name too long");
13236 M (IKEV2_SET_LOCAL_KEY, mp);
13238 clib_memcpy (mp->key_file, file, vec_len (file));
13247 api_ikev2_set_responder (vat_main_t * vam)
13249 unformat_input_t *i = vam->input;
13250 vl_api_ikev2_set_responder_t *mp;
13253 u32 sw_if_index = ~0;
13254 ip4_address_t address;
13256 const char *valid_chars = "a-zA-Z0-9_";
13258 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13261 (i, "%U interface %d address %U", unformat_token, valid_chars,
13262 &name, &sw_if_index, unformat_ip4_address, &address))
13263 vec_add1 (name, 0);
13266 errmsg ("parse error '%U'", format_unformat_error, i);
13271 if (!vec_len (name))
13273 errmsg ("profile name must be specified");
13277 if (vec_len (name) > 64)
13279 errmsg ("profile name too long");
13283 M (IKEV2_SET_RESPONDER, mp);
13285 clib_memcpy (mp->name, name, vec_len (name));
13288 mp->sw_if_index = sw_if_index;
13289 clib_memcpy (mp->address, &address, sizeof (address));
13297 api_ikev2_set_ike_transforms (vat_main_t * vam)
13299 unformat_input_t *i = vam->input;
13300 vl_api_ikev2_set_ike_transforms_t *mp;
13303 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13305 const char *valid_chars = "a-zA-Z0-9_";
13307 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13309 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13310 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13311 vec_add1 (name, 0);
13314 errmsg ("parse error '%U'", format_unformat_error, i);
13319 if (!vec_len (name))
13321 errmsg ("profile name must be specified");
13325 if (vec_len (name) > 64)
13327 errmsg ("profile name too long");
13331 M (IKEV2_SET_IKE_TRANSFORMS, mp);
13333 clib_memcpy (mp->name, name, vec_len (name));
13335 mp->crypto_alg = crypto_alg;
13336 mp->crypto_key_size = crypto_key_size;
13337 mp->integ_alg = integ_alg;
13338 mp->dh_group = dh_group;
13347 api_ikev2_set_esp_transforms (vat_main_t * vam)
13349 unformat_input_t *i = vam->input;
13350 vl_api_ikev2_set_esp_transforms_t *mp;
13353 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13355 const char *valid_chars = "a-zA-Z0-9_";
13357 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13359 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13360 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13361 vec_add1 (name, 0);
13364 errmsg ("parse error '%U'", format_unformat_error, i);
13369 if (!vec_len (name))
13371 errmsg ("profile name must be specified");
13375 if (vec_len (name) > 64)
13377 errmsg ("profile name too long");
13381 M (IKEV2_SET_ESP_TRANSFORMS, mp);
13383 clib_memcpy (mp->name, name, vec_len (name));
13385 mp->crypto_alg = crypto_alg;
13386 mp->crypto_key_size = crypto_key_size;
13387 mp->integ_alg = integ_alg;
13388 mp->dh_group = dh_group;
13396 api_ikev2_set_sa_lifetime (vat_main_t * vam)
13398 unformat_input_t *i = vam->input;
13399 vl_api_ikev2_set_sa_lifetime_t *mp;
13402 u64 lifetime, lifetime_maxdata;
13403 u32 lifetime_jitter, handover;
13405 const char *valid_chars = "a-zA-Z0-9_";
13407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13409 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
13410 &lifetime, &lifetime_jitter, &handover,
13411 &lifetime_maxdata))
13412 vec_add1 (name, 0);
13415 errmsg ("parse error '%U'", format_unformat_error, i);
13420 if (!vec_len (name))
13422 errmsg ("profile name must be specified");
13426 if (vec_len (name) > 64)
13428 errmsg ("profile name too long");
13432 M (IKEV2_SET_SA_LIFETIME, mp);
13434 clib_memcpy (mp->name, name, vec_len (name));
13436 mp->lifetime = lifetime;
13437 mp->lifetime_jitter = lifetime_jitter;
13438 mp->handover = handover;
13439 mp->lifetime_maxdata = lifetime_maxdata;
13447 api_ikev2_initiate_sa_init (vat_main_t * vam)
13449 unformat_input_t *i = vam->input;
13450 vl_api_ikev2_initiate_sa_init_t *mp;
13454 const char *valid_chars = "a-zA-Z0-9_";
13456 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13458 if (unformat (i, "%U", unformat_token, valid_chars, &name))
13459 vec_add1 (name, 0);
13462 errmsg ("parse error '%U'", format_unformat_error, i);
13467 if (!vec_len (name))
13469 errmsg ("profile name must be specified");
13473 if (vec_len (name) > 64)
13475 errmsg ("profile name too long");
13479 M (IKEV2_INITIATE_SA_INIT, mp);
13481 clib_memcpy (mp->name, name, vec_len (name));
13490 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
13492 unformat_input_t *i = vam->input;
13493 vl_api_ikev2_initiate_del_ike_sa_t *mp;
13498 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13500 if (unformat (i, "%lx", &ispi))
13504 errmsg ("parse error '%U'", format_unformat_error, i);
13509 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
13519 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13521 unformat_input_t *i = vam->input;
13522 vl_api_ikev2_initiate_del_child_sa_t *mp;
13527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13529 if (unformat (i, "%x", &ispi))
13533 errmsg ("parse error '%U'", format_unformat_error, i);
13538 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13548 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13550 unformat_input_t *i = vam->input;
13551 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13556 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13558 if (unformat (i, "%x", &ispi))
13562 errmsg ("parse error '%U'", format_unformat_error, i);
13567 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
13580 api_map_add_domain (vat_main_t * vam)
13582 unformat_input_t *i = vam->input;
13583 vl_api_map_add_domain_t *mp;
13585 ip4_address_t ip4_prefix;
13586 ip6_address_t ip6_prefix;
13587 ip6_address_t ip6_src;
13588 u32 num_m_args = 0;
13589 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
13590 0, psid_length = 0;
13591 u8 is_translation = 0;
13593 u32 ip6_src_len = 128;
13596 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13598 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
13599 &ip4_prefix, &ip4_prefix_len))
13601 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
13602 &ip6_prefix, &ip6_prefix_len))
13606 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
13609 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
13611 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
13613 else if (unformat (i, "psid-offset %d", &psid_offset))
13615 else if (unformat (i, "psid-len %d", &psid_length))
13617 else if (unformat (i, "mtu %d", &mtu))
13619 else if (unformat (i, "map-t"))
13620 is_translation = 1;
13623 clib_warning ("parse error '%U'", format_unformat_error, i);
13628 if (num_m_args < 3)
13630 errmsg ("mandatory argument(s) missing");
13634 /* Construct the API message */
13635 M (MAP_ADD_DOMAIN, mp);
13637 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
13638 mp->ip4_prefix_len = ip4_prefix_len;
13640 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
13641 mp->ip6_prefix_len = ip6_prefix_len;
13643 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
13644 mp->ip6_src_prefix_len = ip6_src_len;
13646 mp->ea_bits_len = ea_bits_len;
13647 mp->psid_offset = psid_offset;
13648 mp->psid_length = psid_length;
13649 mp->is_translation = is_translation;
13650 mp->mtu = htons (mtu);
13655 /* Wait for a reply, return good/bad news */
13661 api_map_del_domain (vat_main_t * vam)
13663 unformat_input_t *i = vam->input;
13664 vl_api_map_del_domain_t *mp;
13666 u32 num_m_args = 0;
13670 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13672 if (unformat (i, "index %d", &index))
13676 clib_warning ("parse error '%U'", format_unformat_error, i);
13681 if (num_m_args != 1)
13683 errmsg ("mandatory argument(s) missing");
13687 /* Construct the API message */
13688 M (MAP_DEL_DOMAIN, mp);
13690 mp->index = ntohl (index);
13695 /* Wait for a reply, return good/bad news */
13701 api_map_add_del_rule (vat_main_t * vam)
13703 unformat_input_t *i = vam->input;
13704 vl_api_map_add_del_rule_t *mp;
13706 ip6_address_t ip6_dst;
13707 u32 num_m_args = 0, index, psid = 0;
13710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13712 if (unformat (i, "index %d", &index))
13714 else if (unformat (i, "psid %d", &psid))
13716 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13718 else if (unformat (i, "del"))
13724 clib_warning ("parse error '%U'", format_unformat_error, i);
13729 /* Construct the API message */
13730 M (MAP_ADD_DEL_RULE, mp);
13732 mp->index = ntohl (index);
13733 mp->is_add = is_add;
13734 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13735 mp->psid = ntohs (psid);
13740 /* Wait for a reply, return good/bad news */
13746 api_map_domain_dump (vat_main_t * vam)
13748 vl_api_map_domain_dump_t *mp;
13749 vl_api_control_ping_t *mp_ping;
13752 /* Construct the API message */
13753 M (MAP_DOMAIN_DUMP, mp);
13758 /* Use a control ping for synchronization */
13759 M (CONTROL_PING, mp_ping);
13767 api_map_rule_dump (vat_main_t * vam)
13769 unformat_input_t *i = vam->input;
13770 vl_api_map_rule_dump_t *mp;
13771 vl_api_control_ping_t *mp_ping;
13772 u32 domain_index = ~0;
13775 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13777 if (unformat (i, "index %u", &domain_index))
13783 if (domain_index == ~0)
13785 clib_warning ("parse error: domain index expected");
13789 /* Construct the API message */
13790 M (MAP_RULE_DUMP, mp);
13792 mp->domain_index = htonl (domain_index);
13797 /* Use a control ping for synchronization */
13798 M (CONTROL_PING, mp_ping);
13805 static void vl_api_map_add_domain_reply_t_handler
13806 (vl_api_map_add_domain_reply_t * mp)
13808 vat_main_t *vam = &vat_main;
13809 i32 retval = ntohl (mp->retval);
13811 if (vam->async_mode)
13813 vam->async_errors += (retval < 0);
13817 vam->retval = retval;
13818 vam->result_ready = 1;
13822 static void vl_api_map_add_domain_reply_t_handler_json
13823 (vl_api_map_add_domain_reply_t * mp)
13825 vat_main_t *vam = &vat_main;
13826 vat_json_node_t node;
13828 vat_json_init_object (&node);
13829 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13830 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13832 vat_json_print (vam->ofp, &node);
13833 vat_json_free (&node);
13835 vam->retval = ntohl (mp->retval);
13836 vam->result_ready = 1;
13840 api_get_first_msg_id (vat_main_t * vam)
13842 vl_api_get_first_msg_id_t *mp;
13843 unformat_input_t *i = vam->input;
13848 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13850 if (unformat (i, "client %s", &name))
13858 errmsg ("missing client name");
13861 vec_add1 (name, 0);
13863 if (vec_len (name) > 63)
13865 errmsg ("client name too long");
13869 M (GET_FIRST_MSG_ID, mp);
13870 clib_memcpy (mp->name, name, vec_len (name));
13877 api_cop_interface_enable_disable (vat_main_t * vam)
13879 unformat_input_t *line_input = vam->input;
13880 vl_api_cop_interface_enable_disable_t *mp;
13881 u32 sw_if_index = ~0;
13882 u8 enable_disable = 1;
13885 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13887 if (unformat (line_input, "disable"))
13888 enable_disable = 0;
13889 if (unformat (line_input, "enable"))
13890 enable_disable = 1;
13891 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13892 vam, &sw_if_index))
13894 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13900 if (sw_if_index == ~0)
13902 errmsg ("missing interface name or sw_if_index");
13906 /* Construct the API message */
13907 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13908 mp->sw_if_index = ntohl (sw_if_index);
13909 mp->enable_disable = enable_disable;
13913 /* Wait for the reply */
13919 api_cop_whitelist_enable_disable (vat_main_t * vam)
13921 unformat_input_t *line_input = vam->input;
13922 vl_api_cop_whitelist_enable_disable_t *mp;
13923 u32 sw_if_index = ~0;
13924 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13928 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13930 if (unformat (line_input, "ip4"))
13932 else if (unformat (line_input, "ip6"))
13934 else if (unformat (line_input, "default"))
13936 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13937 vam, &sw_if_index))
13939 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13941 else if (unformat (line_input, "fib-id %d", &fib_id))
13947 if (sw_if_index == ~0)
13949 errmsg ("missing interface name or sw_if_index");
13953 /* Construct the API message */
13954 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13955 mp->sw_if_index = ntohl (sw_if_index);
13956 mp->fib_id = ntohl (fib_id);
13959 mp->default_cop = default_cop;
13963 /* Wait for the reply */
13969 api_get_node_graph (vat_main_t * vam)
13971 vl_api_get_node_graph_t *mp;
13974 M (GET_NODE_GRAPH, mp);
13978 /* Wait for the reply */
13984 /** Used for parsing LISP eids */
13985 typedef CLIB_PACKED(struct{
13986 u8 addr[16]; /**< eid address */
13987 u32 len; /**< prefix length if IP */
13988 u8 type; /**< type of eid */
13993 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13995 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13997 memset (a, 0, sizeof (a[0]));
13999 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
14001 a->type = 0; /* ipv4 type */
14003 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
14005 a->type = 1; /* ipv6 type */
14007 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
14009 a->type = 2; /* mac type */
14016 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
14025 lisp_eid_size_vat (u8 type)
14040 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
14042 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
14046 api_one_add_del_locator_set (vat_main_t * vam)
14048 unformat_input_t *input = vam->input;
14049 vl_api_one_add_del_locator_set_t *mp;
14051 u8 *locator_set_name = NULL;
14052 u8 locator_set_name_set = 0;
14053 vl_api_local_locator_t locator, *locators = 0;
14054 u32 sw_if_index, priority, weight;
14058 /* Parse args required to build the message */
14059 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14061 if (unformat (input, "del"))
14065 else if (unformat (input, "locator-set %s", &locator_set_name))
14067 locator_set_name_set = 1;
14069 else if (unformat (input, "sw_if_index %u p %u w %u",
14070 &sw_if_index, &priority, &weight))
14072 locator.sw_if_index = htonl (sw_if_index);
14073 locator.priority = priority;
14074 locator.weight = weight;
14075 vec_add1 (locators, locator);
14079 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14080 &sw_if_index, &priority, &weight))
14082 locator.sw_if_index = htonl (sw_if_index);
14083 locator.priority = priority;
14084 locator.weight = weight;
14085 vec_add1 (locators, locator);
14091 if (locator_set_name_set == 0)
14093 errmsg ("missing locator-set name");
14094 vec_free (locators);
14098 if (vec_len (locator_set_name) > 64)
14100 errmsg ("locator-set name too long");
14101 vec_free (locator_set_name);
14102 vec_free (locators);
14105 vec_add1 (locator_set_name, 0);
14107 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14109 /* Construct the API message */
14110 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14112 mp->is_add = is_add;
14113 clib_memcpy (mp->locator_set_name, locator_set_name,
14114 vec_len (locator_set_name));
14115 vec_free (locator_set_name);
14117 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14119 clib_memcpy (mp->locators, locators, data_len);
14120 vec_free (locators);
14125 /* Wait for a reply... */
14130 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14133 api_one_add_del_locator (vat_main_t * vam)
14135 unformat_input_t *input = vam->input;
14136 vl_api_one_add_del_locator_t *mp;
14137 u32 tmp_if_index = ~0;
14138 u32 sw_if_index = ~0;
14139 u8 sw_if_index_set = 0;
14140 u8 sw_if_index_if_name_set = 0;
14142 u8 priority_set = 0;
14146 u8 *locator_set_name = NULL;
14147 u8 locator_set_name_set = 0;
14150 /* Parse args required to build the message */
14151 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14153 if (unformat (input, "del"))
14157 else if (unformat (input, "locator-set %s", &locator_set_name))
14159 locator_set_name_set = 1;
14161 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14164 sw_if_index_if_name_set = 1;
14165 sw_if_index = tmp_if_index;
14167 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14169 sw_if_index_set = 1;
14170 sw_if_index = tmp_if_index;
14172 else if (unformat (input, "p %d", &priority))
14176 else if (unformat (input, "w %d", &weight))
14184 if (locator_set_name_set == 0)
14186 errmsg ("missing locator-set name");
14190 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14192 errmsg ("missing sw_if_index");
14193 vec_free (locator_set_name);
14197 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14199 errmsg ("cannot use both params interface name and sw_if_index");
14200 vec_free (locator_set_name);
14204 if (priority_set == 0)
14206 errmsg ("missing locator-set priority");
14207 vec_free (locator_set_name);
14211 if (weight_set == 0)
14213 errmsg ("missing locator-set weight");
14214 vec_free (locator_set_name);
14218 if (vec_len (locator_set_name) > 64)
14220 errmsg ("locator-set name too long");
14221 vec_free (locator_set_name);
14224 vec_add1 (locator_set_name, 0);
14226 /* Construct the API message */
14227 M (ONE_ADD_DEL_LOCATOR, mp);
14229 mp->is_add = is_add;
14230 mp->sw_if_index = ntohl (sw_if_index);
14231 mp->priority = priority;
14232 mp->weight = weight;
14233 clib_memcpy (mp->locator_set_name, locator_set_name,
14234 vec_len (locator_set_name));
14235 vec_free (locator_set_name);
14240 /* Wait for a reply... */
14245 #define api_lisp_add_del_locator api_one_add_del_locator
14248 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14250 u32 *key_id = va_arg (*args, u32 *);
14253 if (unformat (input, "%s", &s))
14255 if (!strcmp ((char *) s, "sha1"))
14256 key_id[0] = HMAC_SHA_1_96;
14257 else if (!strcmp ((char *) s, "sha256"))
14258 key_id[0] = HMAC_SHA_256_128;
14261 clib_warning ("invalid key_id: '%s'", s);
14262 key_id[0] = HMAC_NO_KEY;
14273 api_one_add_del_local_eid (vat_main_t * vam)
14275 unformat_input_t *input = vam->input;
14276 vl_api_one_add_del_local_eid_t *mp;
14279 lisp_eid_vat_t _eid, *eid = &_eid;
14280 u8 *locator_set_name = 0;
14281 u8 locator_set_name_set = 0;
14287 /* Parse args required to build the message */
14288 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14290 if (unformat (input, "del"))
14294 else if (unformat (input, "vni %d", &vni))
14298 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14302 else if (unformat (input, "locator-set %s", &locator_set_name))
14304 locator_set_name_set = 1;
14306 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14308 else if (unformat (input, "secret-key %_%v%_", &key))
14314 if (locator_set_name_set == 0)
14316 errmsg ("missing locator-set name");
14322 errmsg ("EID address not set!");
14323 vec_free (locator_set_name);
14327 if (key && (0 == key_id))
14329 errmsg ("invalid key_id!");
14333 if (vec_len (key) > 64)
14335 errmsg ("key too long");
14340 if (vec_len (locator_set_name) > 64)
14342 errmsg ("locator-set name too long");
14343 vec_free (locator_set_name);
14346 vec_add1 (locator_set_name, 0);
14348 /* Construct the API message */
14349 M (ONE_ADD_DEL_LOCAL_EID, mp);
14351 mp->is_add = is_add;
14352 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14353 mp->eid_type = eid->type;
14354 mp->prefix_len = eid->len;
14355 mp->vni = clib_host_to_net_u32 (vni);
14356 mp->key_id = clib_host_to_net_u16 (key_id);
14357 clib_memcpy (mp->locator_set_name, locator_set_name,
14358 vec_len (locator_set_name));
14359 clib_memcpy (mp->key, key, vec_len (key));
14361 vec_free (locator_set_name);
14367 /* Wait for a reply... */
14372 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14375 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14377 u32 dp_table = 0, vni = 0;;
14378 unformat_input_t *input = vam->input;
14379 vl_api_gpe_add_del_fwd_entry_t *mp;
14381 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14382 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14383 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14384 u32 action = ~0, w;
14385 ip4_address_t rmt_rloc4, lcl_rloc4;
14386 ip6_address_t rmt_rloc6, lcl_rloc6;
14387 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 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"))
14397 else if (unformat (input, "add"))
14399 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14403 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14407 else if (unformat (input, "vrf %d", &dp_table))
14409 else if (unformat (input, "bd %d", &dp_table))
14411 else if (unformat (input, "vni %d", &vni))
14413 else if (unformat (input, "w %d", &w))
14417 errmsg ("No RLOC configured for setting priority/weight!");
14420 curr_rloc->weight = w;
14422 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14423 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14427 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
14429 vec_add1 (lcl_locs, rloc);
14431 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
14432 vec_add1 (rmt_locs, rloc);
14433 /* weight saved in rmt loc */
14434 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14436 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14437 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14440 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
14442 vec_add1 (lcl_locs, rloc);
14444 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
14445 vec_add1 (rmt_locs, rloc);
14446 /* weight saved in rmt loc */
14447 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14449 else if (unformat (input, "action %d", &action))
14455 clib_warning ("parse error '%U'", format_unformat_error, input);
14462 errmsg ("remote eid addresses not set");
14466 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14468 errmsg ("eid types don't match");
14472 if (0 == rmt_locs && (u32) ~ 0 == action)
14474 errmsg ("action not set for negative mapping");
14478 /* Construct the API message */
14479 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14480 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14482 mp->is_add = is_add;
14483 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14484 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14485 mp->eid_type = rmt_eid->type;
14486 mp->dp_table = clib_host_to_net_u32 (dp_table);
14487 mp->vni = clib_host_to_net_u32 (vni);
14488 mp->rmt_len = rmt_eid->len;
14489 mp->lcl_len = lcl_eid->len;
14490 mp->action = action;
14492 if (0 != rmt_locs && 0 != lcl_locs)
14494 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14495 clib_memcpy (mp->locs, lcl_locs,
14496 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14498 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14499 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14500 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14502 vec_free (lcl_locs);
14503 vec_free (rmt_locs);
14508 /* Wait for a reply... */
14514 api_one_add_del_map_server (vat_main_t * vam)
14516 unformat_input_t *input = vam->input;
14517 vl_api_one_add_del_map_server_t *mp;
14521 ip4_address_t ipv4;
14522 ip6_address_t ipv6;
14525 /* Parse args required to build the message */
14526 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14528 if (unformat (input, "del"))
14532 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14536 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14544 if (ipv4_set && ipv6_set)
14546 errmsg ("both eid v4 and v6 addresses set");
14550 if (!ipv4_set && !ipv6_set)
14552 errmsg ("eid addresses not set");
14556 /* Construct the API message */
14557 M (ONE_ADD_DEL_MAP_SERVER, mp);
14559 mp->is_add = is_add;
14563 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14568 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14574 /* Wait for a reply... */
14579 #define api_lisp_add_del_map_server api_one_add_del_map_server
14582 api_one_add_del_map_resolver (vat_main_t * vam)
14584 unformat_input_t *input = vam->input;
14585 vl_api_one_add_del_map_resolver_t *mp;
14589 ip4_address_t ipv4;
14590 ip6_address_t ipv6;
14593 /* Parse args required to build the message */
14594 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14596 if (unformat (input, "del"))
14600 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14604 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14612 if (ipv4_set && ipv6_set)
14614 errmsg ("both eid v4 and v6 addresses set");
14618 if (!ipv4_set && !ipv6_set)
14620 errmsg ("eid addresses not set");
14624 /* Construct the API message */
14625 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14627 mp->is_add = is_add;
14631 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14636 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14642 /* Wait for a reply... */
14647 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14650 api_lisp_gpe_enable_disable (vat_main_t * vam)
14652 unformat_input_t *input = vam->input;
14653 vl_api_gpe_enable_disable_t *mp;
14658 /* Parse args required to build the message */
14659 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14661 if (unformat (input, "enable"))
14666 else if (unformat (input, "disable"))
14677 errmsg ("Value not set");
14681 /* Construct the API message */
14682 M (GPE_ENABLE_DISABLE, mp);
14689 /* Wait for a reply... */
14695 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14697 unformat_input_t *input = vam->input;
14698 vl_api_one_rloc_probe_enable_disable_t *mp;
14703 /* Parse args required to build the message */
14704 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14706 if (unformat (input, "enable"))
14711 else if (unformat (input, "disable"))
14719 errmsg ("Value not set");
14723 /* Construct the API message */
14724 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14726 mp->is_enabled = is_en;
14731 /* Wait for a reply... */
14736 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14739 api_one_map_register_enable_disable (vat_main_t * vam)
14741 unformat_input_t *input = vam->input;
14742 vl_api_one_map_register_enable_disable_t *mp;
14747 /* Parse args required to build the message */
14748 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14750 if (unformat (input, "enable"))
14755 else if (unformat (input, "disable"))
14763 errmsg ("Value not set");
14767 /* Construct the API message */
14768 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14770 mp->is_enabled = is_en;
14775 /* Wait for a reply... */
14780 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14783 api_one_enable_disable (vat_main_t * vam)
14785 unformat_input_t *input = vam->input;
14786 vl_api_one_enable_disable_t *mp;
14791 /* Parse args required to build the message */
14792 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14794 if (unformat (input, "enable"))
14799 else if (unformat (input, "disable"))
14809 errmsg ("Value not set");
14813 /* Construct the API message */
14814 M (ONE_ENABLE_DISABLE, mp);
14821 /* Wait for a reply... */
14826 #define api_lisp_enable_disable api_one_enable_disable
14829 api_show_one_map_register_state (vat_main_t * vam)
14831 vl_api_show_one_map_register_state_t *mp;
14834 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14839 /* wait for reply */
14844 #define api_show_lisp_map_register_state api_show_one_map_register_state
14847 api_show_one_rloc_probe_state (vat_main_t * vam)
14849 vl_api_show_one_rloc_probe_state_t *mp;
14852 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14857 /* wait for reply */
14862 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14865 api_one_add_del_l2_arp_entry (vat_main_t * vam)
14867 vl_api_one_add_del_l2_arp_entry_t *mp;
14868 unformat_input_t *input = vam->input;
14873 u8 mac[6] = { 0, };
14874 u32 ip4 = 0, bd = ~0;
14877 /* Parse args required to build the message */
14878 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14880 if (unformat (input, "del"))
14882 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
14884 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
14886 else if (unformat (input, "bd %d", &bd))
14890 errmsg ("parse error '%U'", format_unformat_error, input);
14895 if (!bd_set || !ip_set || (!mac_set && is_add))
14897 errmsg ("Missing BD, IP or MAC!");
14901 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
14902 mp->is_add = is_add;
14903 clib_memcpy (mp->mac, mac, 6);
14904 mp->bd = clib_host_to_net_u32 (bd);
14910 /* wait for reply */
14916 api_one_l2_arp_bd_get (vat_main_t * vam)
14918 vl_api_one_l2_arp_bd_get_t *mp;
14921 M (ONE_L2_ARP_BD_GET, mp);
14926 /* wait for reply */
14932 api_one_l2_arp_entries_get (vat_main_t * vam)
14934 vl_api_one_l2_arp_entries_get_t *mp;
14935 unformat_input_t *input = vam->input;
14940 /* Parse args required to build the message */
14941 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14943 if (unformat (input, "bd %d", &bd))
14947 errmsg ("parse error '%U'", format_unformat_error, input);
14954 errmsg ("Expected bridge domain!");
14958 M (ONE_L2_ARP_ENTRIES_GET, mp);
14959 mp->bd = clib_host_to_net_u32 (bd);
14964 /* wait for reply */
14970 api_one_stats_enable_disable (vat_main_t * vam)
14972 vl_api_one_stats_enable_disable_t *mp;
14973 unformat_input_t *input = vam->input;
14978 /* Parse args required to build the message */
14979 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14981 if (unformat (input, "enable"))
14986 else if (unformat (input, "disable"))
14996 errmsg ("Value not set");
15000 M (ONE_STATS_ENABLE_DISABLE, mp);
15006 /* wait for reply */
15012 api_show_one_stats_enable_disable (vat_main_t * vam)
15014 vl_api_show_one_stats_enable_disable_t *mp;
15017 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
15022 /* wait for reply */
15028 api_show_one_map_request_mode (vat_main_t * vam)
15030 vl_api_show_one_map_request_mode_t *mp;
15033 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
15038 /* wait for reply */
15043 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
15046 api_one_map_request_mode (vat_main_t * vam)
15048 unformat_input_t *input = vam->input;
15049 vl_api_one_map_request_mode_t *mp;
15053 /* Parse args required to build the message */
15054 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15056 if (unformat (input, "dst-only"))
15058 else if (unformat (input, "src-dst"))
15062 errmsg ("parse error '%U'", format_unformat_error, input);
15067 M (ONE_MAP_REQUEST_MODE, mp);
15074 /* wait for reply */
15079 #define api_lisp_map_request_mode api_one_map_request_mode
15082 * Enable/disable ONE proxy ITR.
15084 * @param vam vpp API test context
15085 * @return return code
15088 api_one_pitr_set_locator_set (vat_main_t * vam)
15090 u8 ls_name_set = 0;
15091 unformat_input_t *input = vam->input;
15092 vl_api_one_pitr_set_locator_set_t *mp;
15097 /* Parse args required to build the message */
15098 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15100 if (unformat (input, "del"))
15102 else if (unformat (input, "locator-set %s", &ls_name))
15106 errmsg ("parse error '%U'", format_unformat_error, input);
15113 errmsg ("locator-set name not set!");
15117 M (ONE_PITR_SET_LOCATOR_SET, mp);
15119 mp->is_add = is_add;
15120 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15121 vec_free (ls_name);
15126 /* wait for reply */
15131 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
15134 api_show_one_pitr (vat_main_t * vam)
15136 vl_api_show_one_pitr_t *mp;
15139 if (!vam->json_output)
15141 print (vam->ofp, "%=20s", "lisp status:");
15144 M (SHOW_ONE_PITR, mp);
15148 /* Wait for a reply... */
15153 #define api_show_lisp_pitr api_show_one_pitr
15156 api_one_use_petr (vat_main_t * vam)
15158 unformat_input_t *input = vam->input;
15159 vl_api_one_use_petr_t *mp;
15164 memset (&ip, 0, sizeof (ip));
15166 /* Parse args required to build the message */
15167 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15169 if (unformat (input, "disable"))
15172 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
15175 ip_addr_version (&ip) = IP4;
15178 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
15181 ip_addr_version (&ip) = IP6;
15185 errmsg ("parse error '%U'", format_unformat_error, input);
15190 M (ONE_USE_PETR, mp);
15192 mp->is_add = is_add;
15195 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
15197 clib_memcpy (mp->address, &ip, 4);
15199 clib_memcpy (mp->address, &ip, 16);
15205 /* wait for reply */
15210 #define api_lisp_use_petr api_one_use_petr
15213 api_show_one_use_petr (vat_main_t * vam)
15215 vl_api_show_one_use_petr_t *mp;
15218 if (!vam->json_output)
15220 print (vam->ofp, "%=20s", "Proxy-ETR status:");
15223 M (SHOW_ONE_USE_PETR, mp);
15227 /* Wait for a reply... */
15232 #define api_show_lisp_use_petr api_show_one_use_petr
15235 * Add/delete mapping between vni and vrf
15238 api_one_eid_table_add_del_map (vat_main_t * vam)
15240 unformat_input_t *input = vam->input;
15241 vl_api_one_eid_table_add_del_map_t *mp;
15242 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15243 u32 vni, vrf, bd_index;
15246 /* Parse args required to build the message */
15247 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15249 if (unformat (input, "del"))
15251 else if (unformat (input, "vrf %d", &vrf))
15253 else if (unformat (input, "bd_index %d", &bd_index))
15255 else if (unformat (input, "vni %d", &vni))
15261 if (!vni_set || (!vrf_set && !bd_index_set))
15263 errmsg ("missing arguments!");
15267 if (vrf_set && bd_index_set)
15269 errmsg ("error: both vrf and bd entered!");
15273 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15275 mp->is_add = is_add;
15276 mp->vni = htonl (vni);
15277 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15278 mp->is_l2 = bd_index_set;
15283 /* wait for reply */
15288 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15291 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15293 u32 *action = va_arg (*args, u32 *);
15296 if (unformat (input, "%s", &s))
15298 if (!strcmp ((char *) s, "no-action"))
15300 else if (!strcmp ((char *) s, "natively-forward"))
15302 else if (!strcmp ((char *) s, "send-map-request"))
15304 else if (!strcmp ((char *) s, "drop"))
15308 clib_warning ("invalid action: '%s'", s);
15320 * Add/del remote mapping to/from ONE control plane
15322 * @param vam vpp API test context
15323 * @return return code
15326 api_one_add_del_remote_mapping (vat_main_t * vam)
15328 unformat_input_t *input = vam->input;
15329 vl_api_one_add_del_remote_mapping_t *mp;
15331 lisp_eid_vat_t _eid, *eid = &_eid;
15332 lisp_eid_vat_t _seid, *seid = &_seid;
15333 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15334 u32 action = ~0, p, w, data_len;
15335 ip4_address_t rloc4;
15336 ip6_address_t rloc6;
15337 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15340 memset (&rloc, 0, sizeof (rloc));
15342 /* Parse args required to build the message */
15343 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15345 if (unformat (input, "del-all"))
15349 else if (unformat (input, "del"))
15353 else if (unformat (input, "add"))
15357 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15361 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15365 else if (unformat (input, "vni %d", &vni))
15369 else if (unformat (input, "p %d w %d", &p, &w))
15373 errmsg ("No RLOC configured for setting priority/weight!");
15376 curr_rloc->priority = p;
15377 curr_rloc->weight = w;
15379 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15382 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
15383 vec_add1 (rlocs, rloc);
15384 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15386 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15389 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
15390 vec_add1 (rlocs, rloc);
15391 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15393 else if (unformat (input, "action %U",
15394 unformat_negative_mapping_action, &action))
15400 clib_warning ("parse error '%U'", format_unformat_error, input);
15407 errmsg ("missing params!");
15411 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15413 errmsg ("no action set for negative map-reply!");
15417 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15419 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15420 mp->is_add = is_add;
15421 mp->vni = htonl (vni);
15422 mp->action = (u8) action;
15423 mp->is_src_dst = seid_set;
15424 mp->eid_len = eid->len;
15425 mp->seid_len = seid->len;
15426 mp->del_all = del_all;
15427 mp->eid_type = eid->type;
15428 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15429 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
15431 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15432 clib_memcpy (mp->rlocs, rlocs, data_len);
15438 /* Wait for a reply... */
15443 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15446 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15447 * forwarding entries in data-plane accordingly.
15449 * @param vam vpp API test context
15450 * @return return code
15453 api_one_add_del_adjacency (vat_main_t * vam)
15455 unformat_input_t *input = vam->input;
15456 vl_api_one_add_del_adjacency_t *mp;
15458 ip4_address_t leid4, reid4;
15459 ip6_address_t leid6, reid6;
15460 u8 reid_mac[6] = { 0 };
15461 u8 leid_mac[6] = { 0 };
15462 u8 reid_type, leid_type;
15463 u32 leid_len = 0, reid_len = 0, len;
15467 leid_type = reid_type = (u8) ~ 0;
15469 /* Parse args required to build the message */
15470 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15472 if (unformat (input, "del"))
15476 else if (unformat (input, "add"))
15480 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
15483 reid_type = 0; /* ipv4 */
15486 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
15489 reid_type = 1; /* ipv6 */
15492 else if (unformat (input, "reid %U", unformat_ethernet_address,
15495 reid_type = 2; /* mac */
15497 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
15500 leid_type = 0; /* ipv4 */
15503 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
15506 leid_type = 1; /* ipv6 */
15509 else if (unformat (input, "leid %U", unformat_ethernet_address,
15512 leid_type = 2; /* mac */
15514 else if (unformat (input, "vni %d", &vni))
15520 errmsg ("parse error '%U'", format_unformat_error, input);
15525 if ((u8) ~ 0 == reid_type)
15527 errmsg ("missing params!");
15531 if (leid_type != reid_type)
15533 errmsg ("remote and local EIDs are of different types!");
15537 M (ONE_ADD_DEL_ADJACENCY, mp);
15538 mp->is_add = is_add;
15539 mp->vni = htonl (vni);
15540 mp->leid_len = leid_len;
15541 mp->reid_len = reid_len;
15542 mp->eid_type = reid_type;
15544 switch (mp->eid_type)
15547 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
15548 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
15551 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
15552 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
15555 clib_memcpy (mp->leid, leid_mac, 6);
15556 clib_memcpy (mp->reid, reid_mac, 6);
15559 errmsg ("unknown EID type %d!", mp->eid_type);
15566 /* Wait for a reply... */
15571 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
15574 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
15576 u32 *mode = va_arg (*args, u32 *);
15578 if (unformat (input, "lisp"))
15580 else if (unformat (input, "vxlan"))
15589 api_gpe_get_encap_mode (vat_main_t * vam)
15591 vl_api_gpe_get_encap_mode_t *mp;
15594 /* Construct the API message */
15595 M (GPE_GET_ENCAP_MODE, mp);
15600 /* Wait for a reply... */
15606 api_gpe_set_encap_mode (vat_main_t * vam)
15608 unformat_input_t *input = vam->input;
15609 vl_api_gpe_set_encap_mode_t *mp;
15613 /* Parse args required to build the message */
15614 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15616 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
15622 /* Construct the API message */
15623 M (GPE_SET_ENCAP_MODE, mp);
15630 /* Wait for a reply... */
15636 api_lisp_gpe_add_del_iface (vat_main_t * vam)
15638 unformat_input_t *input = vam->input;
15639 vl_api_gpe_add_del_iface_t *mp;
15640 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
15641 u32 dp_table = 0, vni = 0;
15644 /* Parse args required to build the message */
15645 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15647 if (unformat (input, "up"))
15652 else if (unformat (input, "down"))
15657 else if (unformat (input, "table_id %d", &dp_table))
15661 else if (unformat (input, "bd_id %d", &dp_table))
15666 else if (unformat (input, "vni %d", &vni))
15674 if (action_set == 0)
15676 errmsg ("Action not set");
15679 if (dp_table_set == 0 || vni_set == 0)
15681 errmsg ("vni and dp_table must be set");
15685 /* Construct the API message */
15686 M (GPE_ADD_DEL_IFACE, mp);
15688 mp->is_add = is_add;
15689 mp->dp_table = dp_table;
15696 /* Wait for a reply... */
15702 * Add/del map request itr rlocs from ONE control plane and updates
15704 * @param vam vpp API test context
15705 * @return return code
15708 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
15710 unformat_input_t *input = vam->input;
15711 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
15712 u8 *locator_set_name = 0;
15713 u8 locator_set_name_set = 0;
15717 /* Parse args required to build the message */
15718 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15720 if (unformat (input, "del"))
15724 else if (unformat (input, "%_%v%_", &locator_set_name))
15726 locator_set_name_set = 1;
15730 clib_warning ("parse error '%U'", format_unformat_error, input);
15735 if (is_add && !locator_set_name_set)
15737 errmsg ("itr-rloc is not set!");
15741 if (is_add && vec_len (locator_set_name) > 64)
15743 errmsg ("itr-rloc locator-set name too long");
15744 vec_free (locator_set_name);
15748 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
15749 mp->is_add = is_add;
15752 clib_memcpy (mp->locator_set_name, locator_set_name,
15753 vec_len (locator_set_name));
15757 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
15759 vec_free (locator_set_name);
15764 /* Wait for a reply... */
15769 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
15772 api_one_locator_dump (vat_main_t * vam)
15774 unformat_input_t *input = vam->input;
15775 vl_api_one_locator_dump_t *mp;
15776 vl_api_control_ping_t *mp_ping;
15777 u8 is_index_set = 0, is_name_set = 0;
15782 /* Parse args required to build the message */
15783 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15785 if (unformat (input, "ls_name %_%v%_", &ls_name))
15789 else if (unformat (input, "ls_index %d", &ls_index))
15795 errmsg ("parse error '%U'", format_unformat_error, input);
15800 if (!is_index_set && !is_name_set)
15802 errmsg ("error: expected one of index or name!");
15806 if (is_index_set && is_name_set)
15808 errmsg ("error: only one param expected!");
15812 if (vec_len (ls_name) > 62)
15814 errmsg ("error: locator set name too long!");
15818 if (!vam->json_output)
15820 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
15823 M (ONE_LOCATOR_DUMP, mp);
15824 mp->is_index_set = is_index_set;
15827 mp->ls_index = clib_host_to_net_u32 (ls_index);
15830 vec_add1 (ls_name, 0);
15831 strncpy ((char *) mp->ls_name, (char *) ls_name,
15832 sizeof (mp->ls_name) - 1);
15838 /* Use a control ping for synchronization */
15839 M (CONTROL_PING, mp_ping);
15842 /* Wait for a reply... */
15847 #define api_lisp_locator_dump api_one_locator_dump
15850 api_one_locator_set_dump (vat_main_t * vam)
15852 vl_api_one_locator_set_dump_t *mp;
15853 vl_api_control_ping_t *mp_ping;
15854 unformat_input_t *input = vam->input;
15858 /* Parse args required to build the message */
15859 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15861 if (unformat (input, "local"))
15865 else if (unformat (input, "remote"))
15871 errmsg ("parse error '%U'", format_unformat_error, input);
15876 if (!vam->json_output)
15878 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
15881 M (ONE_LOCATOR_SET_DUMP, mp);
15883 mp->filter = filter;
15888 /* Use a control ping for synchronization */
15889 M (CONTROL_PING, mp_ping);
15892 /* Wait for a reply... */
15897 #define api_lisp_locator_set_dump api_one_locator_set_dump
15900 api_one_eid_table_map_dump (vat_main_t * vam)
15904 unformat_input_t *input = vam->input;
15905 vl_api_one_eid_table_map_dump_t *mp;
15906 vl_api_control_ping_t *mp_ping;
15909 /* Parse args required to build the message */
15910 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15912 if (unformat (input, "l2"))
15917 else if (unformat (input, "l3"))
15924 errmsg ("parse error '%U'", format_unformat_error, input);
15931 errmsg ("expected one of 'l2' or 'l3' parameter!");
15935 if (!vam->json_output)
15937 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
15940 M (ONE_EID_TABLE_MAP_DUMP, mp);
15946 /* Use a control ping for synchronization */
15947 M (CONTROL_PING, mp_ping);
15950 /* Wait for a reply... */
15955 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
15958 api_one_eid_table_vni_dump (vat_main_t * vam)
15960 vl_api_one_eid_table_vni_dump_t *mp;
15961 vl_api_control_ping_t *mp_ping;
15964 if (!vam->json_output)
15966 print (vam->ofp, "VNI");
15969 M (ONE_EID_TABLE_VNI_DUMP, mp);
15974 /* Use a control ping for synchronization */
15975 M (CONTROL_PING, mp_ping);
15978 /* Wait for a reply... */
15983 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
15986 api_one_eid_table_dump (vat_main_t * vam)
15988 unformat_input_t *i = vam->input;
15989 vl_api_one_eid_table_dump_t *mp;
15990 vl_api_control_ping_t *mp_ping;
15991 struct in_addr ip4;
15992 struct in6_addr ip6;
15994 u8 eid_type = ~0, eid_set = 0;
15995 u32 prefix_length = ~0, t, vni = 0;
15999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16001 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
16007 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
16013 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
16018 else if (unformat (i, "vni %d", &t))
16022 else if (unformat (i, "local"))
16026 else if (unformat (i, "remote"))
16032 errmsg ("parse error '%U'", format_unformat_error, i);
16037 if (!vam->json_output)
16039 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
16040 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
16043 M (ONE_EID_TABLE_DUMP, mp);
16045 mp->filter = filter;
16049 mp->vni = htonl (vni);
16050 mp->eid_type = eid_type;
16054 mp->prefix_length = prefix_length;
16055 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
16058 mp->prefix_length = prefix_length;
16059 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
16062 clib_memcpy (mp->eid, mac, sizeof (mac));
16065 errmsg ("unknown EID type %d!", eid_type);
16073 /* Use a control ping for synchronization */
16074 M (CONTROL_PING, mp_ping);
16077 /* Wait for a reply... */
16082 #define api_lisp_eid_table_dump api_one_eid_table_dump
16085 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
16087 unformat_input_t *i = vam->input;
16088 vl_api_gpe_fwd_entries_get_t *mp;
16093 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16095 if (unformat (i, "vni %d", &vni))
16101 errmsg ("parse error '%U'", format_unformat_error, i);
16108 errmsg ("vni not set!");
16112 if (!vam->json_output)
16114 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
16118 M (GPE_FWD_ENTRIES_GET, mp);
16119 mp->vni = clib_host_to_net_u32 (vni);
16124 /* Wait for a reply... */
16129 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
16130 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
16131 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
16132 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
16133 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
16134 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
16137 api_one_adjacencies_get (vat_main_t * vam)
16139 unformat_input_t *i = vam->input;
16140 vl_api_one_adjacencies_get_t *mp;
16145 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16147 if (unformat (i, "vni %d", &vni))
16153 errmsg ("parse error '%U'", format_unformat_error, i);
16160 errmsg ("vni not set!");
16164 if (!vam->json_output)
16166 print (vam->ofp, "%s %40s", "leid", "reid");
16169 M (ONE_ADJACENCIES_GET, mp);
16170 mp->vni = clib_host_to_net_u32 (vni);
16175 /* Wait for a reply... */
16180 #define api_lisp_adjacencies_get api_one_adjacencies_get
16183 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
16185 vl_api_gpe_fwd_entry_vnis_get_t *mp;
16188 if (!vam->json_output)
16190 print (vam->ofp, "VNIs");
16193 M (GPE_FWD_ENTRY_VNIS_GET, mp);
16198 /* Wait for a reply... */
16204 api_one_map_server_dump (vat_main_t * vam)
16206 vl_api_one_map_server_dump_t *mp;
16207 vl_api_control_ping_t *mp_ping;
16210 if (!vam->json_output)
16212 print (vam->ofp, "%=20s", "Map server");
16215 M (ONE_MAP_SERVER_DUMP, mp);
16219 /* Use a control ping for synchronization */
16220 M (CONTROL_PING, mp_ping);
16223 /* Wait for a reply... */
16228 #define api_lisp_map_server_dump api_one_map_server_dump
16231 api_one_map_resolver_dump (vat_main_t * vam)
16233 vl_api_one_map_resolver_dump_t *mp;
16234 vl_api_control_ping_t *mp_ping;
16237 if (!vam->json_output)
16239 print (vam->ofp, "%=20s", "Map resolver");
16242 M (ONE_MAP_RESOLVER_DUMP, mp);
16246 /* Use a control ping for synchronization */
16247 M (CONTROL_PING, mp_ping);
16250 /* Wait for a reply... */
16255 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
16258 api_one_stats_flush (vat_main_t * vam)
16260 vl_api_one_stats_flush_t *mp;
16263 M (ONE_STATS_FLUSH, mp);
16270 api_one_stats_dump (vat_main_t * vam)
16272 vl_api_one_stats_dump_t *mp;
16273 vl_api_control_ping_t *mp_ping;
16276 M (ONE_STATS_DUMP, mp);
16280 /* Use a control ping for synchronization */
16281 M (CONTROL_PING, mp_ping);
16284 /* Wait for a reply... */
16290 api_show_one_status (vat_main_t * vam)
16292 vl_api_show_one_status_t *mp;
16295 if (!vam->json_output)
16297 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
16300 M (SHOW_ONE_STATUS, mp);
16303 /* Wait for a reply... */
16308 #define api_show_lisp_status api_show_one_status
16311 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
16313 vl_api_gpe_fwd_entry_path_dump_t *mp;
16314 vl_api_control_ping_t *mp_ping;
16315 unformat_input_t *i = vam->input;
16316 u32 fwd_entry_index = ~0;
16319 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16321 if (unformat (i, "index %d", &fwd_entry_index))
16327 if (~0 == fwd_entry_index)
16329 errmsg ("no index specified!");
16333 if (!vam->json_output)
16335 print (vam->ofp, "first line");
16338 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
16342 /* Use a control ping for synchronization */
16343 M (CONTROL_PING, mp_ping);
16346 /* Wait for a reply... */
16352 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
16354 vl_api_one_get_map_request_itr_rlocs_t *mp;
16357 if (!vam->json_output)
16359 print (vam->ofp, "%=20s", "itr-rlocs:");
16362 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
16365 /* Wait for a reply... */
16370 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
16373 api_af_packet_create (vat_main_t * vam)
16375 unformat_input_t *i = vam->input;
16376 vl_api_af_packet_create_t *mp;
16377 u8 *host_if_name = 0;
16379 u8 random_hw_addr = 1;
16382 memset (hw_addr, 0, sizeof (hw_addr));
16384 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16386 if (unformat (i, "name %s", &host_if_name))
16387 vec_add1 (host_if_name, 0);
16388 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16389 random_hw_addr = 0;
16394 if (!vec_len (host_if_name))
16396 errmsg ("host-interface name must be specified");
16400 if (vec_len (host_if_name) > 64)
16402 errmsg ("host-interface name too long");
16406 M (AF_PACKET_CREATE, mp);
16408 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16409 clib_memcpy (mp->hw_addr, hw_addr, 6);
16410 mp->use_random_hw_addr = random_hw_addr;
16411 vec_free (host_if_name);
16419 fprintf (vam->ofp ? vam->ofp : stderr,
16420 " new sw_if_index = %d\n", vam->sw_if_index);
16427 api_af_packet_delete (vat_main_t * vam)
16429 unformat_input_t *i = vam->input;
16430 vl_api_af_packet_delete_t *mp;
16431 u8 *host_if_name = 0;
16434 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16436 if (unformat (i, "name %s", &host_if_name))
16437 vec_add1 (host_if_name, 0);
16442 if (!vec_len (host_if_name))
16444 errmsg ("host-interface name must be specified");
16448 if (vec_len (host_if_name) > 64)
16450 errmsg ("host-interface name too long");
16454 M (AF_PACKET_DELETE, mp);
16456 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16457 vec_free (host_if_name);
16465 api_policer_add_del (vat_main_t * vam)
16467 unformat_input_t *i = vam->input;
16468 vl_api_policer_add_del_t *mp;
16478 u8 color_aware = 0;
16479 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
16482 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
16483 conform_action.dscp = 0;
16484 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
16485 exceed_action.dscp = 0;
16486 violate_action.action_type = SSE2_QOS_ACTION_DROP;
16487 violate_action.dscp = 0;
16489 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16491 if (unformat (i, "del"))
16493 else if (unformat (i, "name %s", &name))
16494 vec_add1 (name, 0);
16495 else if (unformat (i, "cir %u", &cir))
16497 else if (unformat (i, "eir %u", &eir))
16499 else if (unformat (i, "cb %u", &cb))
16501 else if (unformat (i, "eb %u", &eb))
16503 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
16506 else if (unformat (i, "round_type %U", unformat_policer_round_type,
16509 else if (unformat (i, "type %U", unformat_policer_type, &type))
16511 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
16514 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
16517 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
16520 else if (unformat (i, "color-aware"))
16526 if (!vec_len (name))
16528 errmsg ("policer name must be specified");
16532 if (vec_len (name) > 64)
16534 errmsg ("policer name too long");
16538 M (POLICER_ADD_DEL, mp);
16540 clib_memcpy (mp->name, name, vec_len (name));
16542 mp->is_add = is_add;
16547 mp->rate_type = rate_type;
16548 mp->round_type = round_type;
16550 mp->conform_action_type = conform_action.action_type;
16551 mp->conform_dscp = conform_action.dscp;
16552 mp->exceed_action_type = exceed_action.action_type;
16553 mp->exceed_dscp = exceed_action.dscp;
16554 mp->violate_action_type = violate_action.action_type;
16555 mp->violate_dscp = violate_action.dscp;
16556 mp->color_aware = color_aware;
16564 api_policer_dump (vat_main_t * vam)
16566 unformat_input_t *i = vam->input;
16567 vl_api_policer_dump_t *mp;
16568 vl_api_control_ping_t *mp_ping;
16569 u8 *match_name = 0;
16570 u8 match_name_valid = 0;
16573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16575 if (unformat (i, "name %s", &match_name))
16577 vec_add1 (match_name, 0);
16578 match_name_valid = 1;
16584 M (POLICER_DUMP, mp);
16585 mp->match_name_valid = match_name_valid;
16586 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
16587 vec_free (match_name);
16591 /* Use a control ping for synchronization */
16592 M (CONTROL_PING, mp_ping);
16595 /* Wait for a reply... */
16601 api_policer_classify_set_interface (vat_main_t * vam)
16603 unformat_input_t *i = vam->input;
16604 vl_api_policer_classify_set_interface_t *mp;
16606 int sw_if_index_set;
16607 u32 ip4_table_index = ~0;
16608 u32 ip6_table_index = ~0;
16609 u32 l2_table_index = ~0;
16613 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16615 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16616 sw_if_index_set = 1;
16617 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16618 sw_if_index_set = 1;
16619 else if (unformat (i, "del"))
16621 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16623 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16625 else if (unformat (i, "l2-table %d", &l2_table_index))
16629 clib_warning ("parse error '%U'", format_unformat_error, i);
16634 if (sw_if_index_set == 0)
16636 errmsg ("missing interface name or sw_if_index");
16640 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
16642 mp->sw_if_index = ntohl (sw_if_index);
16643 mp->ip4_table_index = ntohl (ip4_table_index);
16644 mp->ip6_table_index = ntohl (ip6_table_index);
16645 mp->l2_table_index = ntohl (l2_table_index);
16646 mp->is_add = is_add;
16654 api_policer_classify_dump (vat_main_t * vam)
16656 unformat_input_t *i = vam->input;
16657 vl_api_policer_classify_dump_t *mp;
16658 vl_api_control_ping_t *mp_ping;
16659 u8 type = POLICER_CLASSIFY_N_TABLES;
16662 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
16666 errmsg ("classify table type must be specified");
16670 if (!vam->json_output)
16672 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
16675 M (POLICER_CLASSIFY_DUMP, mp);
16680 /* Use a control ping for synchronization */
16681 M (CONTROL_PING, mp_ping);
16684 /* Wait for a reply... */
16690 api_netmap_create (vat_main_t * vam)
16692 unformat_input_t *i = vam->input;
16693 vl_api_netmap_create_t *mp;
16696 u8 random_hw_addr = 1;
16701 memset (hw_addr, 0, sizeof (hw_addr));
16703 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16705 if (unformat (i, "name %s", &if_name))
16706 vec_add1 (if_name, 0);
16707 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16708 random_hw_addr = 0;
16709 else if (unformat (i, "pipe"))
16711 else if (unformat (i, "master"))
16713 else if (unformat (i, "slave"))
16719 if (!vec_len (if_name))
16721 errmsg ("interface name must be specified");
16725 if (vec_len (if_name) > 64)
16727 errmsg ("interface name too long");
16731 M (NETMAP_CREATE, mp);
16733 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16734 clib_memcpy (mp->hw_addr, hw_addr, 6);
16735 mp->use_random_hw_addr = random_hw_addr;
16736 mp->is_pipe = is_pipe;
16737 mp->is_master = is_master;
16738 vec_free (if_name);
16746 api_netmap_delete (vat_main_t * vam)
16748 unformat_input_t *i = vam->input;
16749 vl_api_netmap_delete_t *mp;
16753 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16755 if (unformat (i, "name %s", &if_name))
16756 vec_add1 (if_name, 0);
16761 if (!vec_len (if_name))
16763 errmsg ("interface name must be specified");
16767 if (vec_len (if_name) > 64)
16769 errmsg ("interface name too long");
16773 M (NETMAP_DELETE, mp);
16775 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16776 vec_free (if_name);
16784 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
16786 if (fp->afi == IP46_TYPE_IP6)
16788 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16789 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16790 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16791 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16792 format_ip6_address, fp->next_hop);
16793 else if (fp->afi == IP46_TYPE_IP4)
16795 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16796 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16797 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16798 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16799 format_ip4_address, fp->next_hop);
16803 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
16804 vl_api_fib_path2_t * fp)
16806 struct in_addr ip4;
16807 struct in6_addr ip6;
16809 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16810 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16811 vat_json_object_add_uint (node, "is_local", fp->is_local);
16812 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16813 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16814 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16815 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16816 if (fp->afi == IP46_TYPE_IP4)
16818 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16819 vat_json_object_add_ip4 (node, "next_hop", ip4);
16821 else if (fp->afi == IP46_TYPE_IP6)
16823 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16824 vat_json_object_add_ip6 (node, "next_hop", ip6);
16829 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
16831 vat_main_t *vam = &vat_main;
16832 int count = ntohl (mp->mt_count);
16833 vl_api_fib_path2_t *fp;
16836 print (vam->ofp, "[%d]: sw_if_index %d via:",
16837 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
16839 for (i = 0; i < count; i++)
16841 vl_api_mpls_fib_path_print (vam, fp);
16845 print (vam->ofp, "");
16848 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
16849 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
16852 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
16854 vat_main_t *vam = &vat_main;
16855 vat_json_node_t *node = NULL;
16856 int count = ntohl (mp->mt_count);
16857 vl_api_fib_path2_t *fp;
16860 if (VAT_JSON_ARRAY != vam->json_tree.type)
16862 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16863 vat_json_init_array (&vam->json_tree);
16865 node = vat_json_array_add (&vam->json_tree);
16867 vat_json_init_object (node);
16868 vat_json_object_add_uint (node, "tunnel_index",
16869 ntohl (mp->mt_tunnel_index));
16870 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
16872 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
16875 for (i = 0; i < count; i++)
16877 vl_api_mpls_fib_path_json_print (node, fp);
16883 api_mpls_tunnel_dump (vat_main_t * vam)
16885 vl_api_mpls_tunnel_dump_t *mp;
16886 vl_api_control_ping_t *mp_ping;
16890 /* Parse args required to build the message */
16891 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
16893 if (!unformat (vam->input, "tunnel_index %d", &index))
16900 print (vam->ofp, " tunnel_index %d", index);
16902 M (MPLS_TUNNEL_DUMP, mp);
16903 mp->tunnel_index = htonl (index);
16906 /* Use a control ping for synchronization */
16907 M (CONTROL_PING, mp_ping);
16914 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
16915 #define vl_api_mpls_fib_details_t_print vl_noop_handler
16919 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
16921 vat_main_t *vam = &vat_main;
16922 int count = ntohl (mp->count);
16923 vl_api_fib_path2_t *fp;
16927 "table-id %d, label %u, ess_bit %u",
16928 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
16930 for (i = 0; i < count; i++)
16932 vl_api_mpls_fib_path_print (vam, fp);
16937 static void vl_api_mpls_fib_details_t_handler_json
16938 (vl_api_mpls_fib_details_t * mp)
16940 vat_main_t *vam = &vat_main;
16941 int count = ntohl (mp->count);
16942 vat_json_node_t *node = NULL;
16943 vl_api_fib_path2_t *fp;
16946 if (VAT_JSON_ARRAY != vam->json_tree.type)
16948 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16949 vat_json_init_array (&vam->json_tree);
16951 node = vat_json_array_add (&vam->json_tree);
16953 vat_json_init_object (node);
16954 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16955 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
16956 vat_json_object_add_uint (node, "label", ntohl (mp->label));
16957 vat_json_object_add_uint (node, "path_count", count);
16959 for (i = 0; i < count; i++)
16961 vl_api_mpls_fib_path_json_print (node, fp);
16967 api_mpls_fib_dump (vat_main_t * vam)
16969 vl_api_mpls_fib_dump_t *mp;
16970 vl_api_control_ping_t *mp_ping;
16973 M (MPLS_FIB_DUMP, mp);
16976 /* Use a control ping for synchronization */
16977 M (CONTROL_PING, mp_ping);
16984 #define vl_api_ip_fib_details_t_endian vl_noop_handler
16985 #define vl_api_ip_fib_details_t_print vl_noop_handler
16988 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
16990 vat_main_t *vam = &vat_main;
16991 int count = ntohl (mp->count);
16992 vl_api_fib_path_t *fp;
16996 "table-id %d, prefix %U/%d",
16997 ntohl (mp->table_id), format_ip4_address, mp->address,
16998 mp->address_length);
17000 for (i = 0; i < count; i++)
17002 if (fp->afi == IP46_TYPE_IP6)
17004 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17005 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17006 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17007 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17008 format_ip6_address, fp->next_hop);
17009 else if (fp->afi == IP46_TYPE_IP4)
17011 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17012 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17013 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17014 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17015 format_ip4_address, fp->next_hop);
17020 static void vl_api_ip_fib_details_t_handler_json
17021 (vl_api_ip_fib_details_t * mp)
17023 vat_main_t *vam = &vat_main;
17024 int count = ntohl (mp->count);
17025 vat_json_node_t *node = NULL;
17026 struct in_addr ip4;
17027 struct in6_addr ip6;
17028 vl_api_fib_path_t *fp;
17031 if (VAT_JSON_ARRAY != vam->json_tree.type)
17033 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17034 vat_json_init_array (&vam->json_tree);
17036 node = vat_json_array_add (&vam->json_tree);
17038 vat_json_init_object (node);
17039 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17040 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
17041 vat_json_object_add_ip4 (node, "prefix", ip4);
17042 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17043 vat_json_object_add_uint (node, "path_count", count);
17045 for (i = 0; i < count; i++)
17047 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17048 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17049 vat_json_object_add_uint (node, "is_local", fp->is_local);
17050 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17051 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17052 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17053 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17054 if (fp->afi == IP46_TYPE_IP4)
17056 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17057 vat_json_object_add_ip4 (node, "next_hop", ip4);
17059 else if (fp->afi == IP46_TYPE_IP6)
17061 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17062 vat_json_object_add_ip6 (node, "next_hop", ip6);
17068 api_ip_fib_dump (vat_main_t * vam)
17070 vl_api_ip_fib_dump_t *mp;
17071 vl_api_control_ping_t *mp_ping;
17074 M (IP_FIB_DUMP, mp);
17077 /* Use a control ping for synchronization */
17078 M (CONTROL_PING, mp_ping);
17086 api_ip_mfib_dump (vat_main_t * vam)
17088 vl_api_ip_mfib_dump_t *mp;
17089 vl_api_control_ping_t *mp_ping;
17092 M (IP_MFIB_DUMP, mp);
17095 /* Use a control ping for synchronization */
17096 M (CONTROL_PING, mp_ping);
17103 static void vl_api_ip_neighbor_details_t_handler
17104 (vl_api_ip_neighbor_details_t * mp)
17106 vat_main_t *vam = &vat_main;
17108 print (vam->ofp, "%c %U %U",
17109 (mp->is_static) ? 'S' : 'D',
17110 format_ethernet_address, &mp->mac_address,
17111 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
17115 static void vl_api_ip_neighbor_details_t_handler_json
17116 (vl_api_ip_neighbor_details_t * mp)
17119 vat_main_t *vam = &vat_main;
17120 vat_json_node_t *node;
17121 struct in_addr ip4;
17122 struct in6_addr ip6;
17124 if (VAT_JSON_ARRAY != vam->json_tree.type)
17126 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17127 vat_json_init_array (&vam->json_tree);
17129 node = vat_json_array_add (&vam->json_tree);
17131 vat_json_init_object (node);
17132 vat_json_object_add_string_copy (node, "flag",
17133 (mp->is_static) ? (u8 *) "static" : (u8 *)
17136 vat_json_object_add_string_copy (node, "link_layer",
17137 format (0, "%U", format_ethernet_address,
17138 &mp->mac_address));
17142 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
17143 vat_json_object_add_ip6 (node, "ip_address", ip6);
17147 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
17148 vat_json_object_add_ip4 (node, "ip_address", ip4);
17153 api_ip_neighbor_dump (vat_main_t * vam)
17155 unformat_input_t *i = vam->input;
17156 vl_api_ip_neighbor_dump_t *mp;
17157 vl_api_control_ping_t *mp_ping;
17159 u32 sw_if_index = ~0;
17162 /* Parse args required to build the message */
17163 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17165 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17167 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17169 else if (unformat (i, "ip6"))
17175 if (sw_if_index == ~0)
17177 errmsg ("missing interface name or sw_if_index");
17181 M (IP_NEIGHBOR_DUMP, mp);
17182 mp->is_ipv6 = (u8) is_ipv6;
17183 mp->sw_if_index = ntohl (sw_if_index);
17186 /* Use a control ping for synchronization */
17187 M (CONTROL_PING, mp_ping);
17194 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
17195 #define vl_api_ip6_fib_details_t_print vl_noop_handler
17198 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
17200 vat_main_t *vam = &vat_main;
17201 int count = ntohl (mp->count);
17202 vl_api_fib_path_t *fp;
17206 "table-id %d, prefix %U/%d",
17207 ntohl (mp->table_id), format_ip6_address, mp->address,
17208 mp->address_length);
17210 for (i = 0; i < count; i++)
17212 if (fp->afi == IP46_TYPE_IP6)
17214 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17215 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17216 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17217 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17218 format_ip6_address, fp->next_hop);
17219 else if (fp->afi == IP46_TYPE_IP4)
17221 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17222 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17223 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17224 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17225 format_ip4_address, fp->next_hop);
17230 static void vl_api_ip6_fib_details_t_handler_json
17231 (vl_api_ip6_fib_details_t * mp)
17233 vat_main_t *vam = &vat_main;
17234 int count = ntohl (mp->count);
17235 vat_json_node_t *node = NULL;
17236 struct in_addr ip4;
17237 struct in6_addr ip6;
17238 vl_api_fib_path_t *fp;
17241 if (VAT_JSON_ARRAY != vam->json_tree.type)
17243 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17244 vat_json_init_array (&vam->json_tree);
17246 node = vat_json_array_add (&vam->json_tree);
17248 vat_json_init_object (node);
17249 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17250 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
17251 vat_json_object_add_ip6 (node, "prefix", ip6);
17252 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17253 vat_json_object_add_uint (node, "path_count", count);
17255 for (i = 0; i < count; i++)
17257 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17258 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17259 vat_json_object_add_uint (node, "is_local", fp->is_local);
17260 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17261 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17262 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17263 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17264 if (fp->afi == IP46_TYPE_IP4)
17266 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17267 vat_json_object_add_ip4 (node, "next_hop", ip4);
17269 else if (fp->afi == IP46_TYPE_IP6)
17271 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17272 vat_json_object_add_ip6 (node, "next_hop", ip6);
17278 api_ip6_fib_dump (vat_main_t * vam)
17280 vl_api_ip6_fib_dump_t *mp;
17281 vl_api_control_ping_t *mp_ping;
17284 M (IP6_FIB_DUMP, mp);
17287 /* Use a control ping for synchronization */
17288 M (CONTROL_PING, mp_ping);
17296 api_ip6_mfib_dump (vat_main_t * vam)
17298 vl_api_ip6_mfib_dump_t *mp;
17299 vl_api_control_ping_t *mp_ping;
17302 M (IP6_MFIB_DUMP, mp);
17305 /* Use a control ping for synchronization */
17306 M (CONTROL_PING, mp_ping);
17314 api_classify_table_ids (vat_main_t * vam)
17316 vl_api_classify_table_ids_t *mp;
17319 /* Construct the API message */
17320 M (CLASSIFY_TABLE_IDS, mp);
17329 api_classify_table_by_interface (vat_main_t * vam)
17331 unformat_input_t *input = vam->input;
17332 vl_api_classify_table_by_interface_t *mp;
17334 u32 sw_if_index = ~0;
17336 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17338 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17340 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17345 if (sw_if_index == ~0)
17347 errmsg ("missing interface name or sw_if_index");
17351 /* Construct the API message */
17352 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
17354 mp->sw_if_index = ntohl (sw_if_index);
17362 api_classify_table_info (vat_main_t * vam)
17364 unformat_input_t *input = vam->input;
17365 vl_api_classify_table_info_t *mp;
17369 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17371 if (unformat (input, "table_id %d", &table_id))
17376 if (table_id == ~0)
17378 errmsg ("missing table id");
17382 /* Construct the API message */
17383 M (CLASSIFY_TABLE_INFO, mp);
17385 mp->table_id = ntohl (table_id);
17393 api_classify_session_dump (vat_main_t * vam)
17395 unformat_input_t *input = vam->input;
17396 vl_api_classify_session_dump_t *mp;
17397 vl_api_control_ping_t *mp_ping;
17401 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17403 if (unformat (input, "table_id %d", &table_id))
17408 if (table_id == ~0)
17410 errmsg ("missing table id");
17414 /* Construct the API message */
17415 M (CLASSIFY_SESSION_DUMP, mp);
17417 mp->table_id = ntohl (table_id);
17420 /* Use a control ping for synchronization */
17421 M (CONTROL_PING, mp_ping);
17429 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
17431 vat_main_t *vam = &vat_main;
17433 print (vam->ofp, "collector_address %U, collector_port %d, "
17434 "src_address %U, vrf_id %d, path_mtu %u, "
17435 "template_interval %u, udp_checksum %d",
17436 format_ip4_address, mp->collector_address,
17437 ntohs (mp->collector_port),
17438 format_ip4_address, mp->src_address,
17439 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
17440 ntohl (mp->template_interval), mp->udp_checksum);
17443 vam->result_ready = 1;
17447 vl_api_ipfix_exporter_details_t_handler_json
17448 (vl_api_ipfix_exporter_details_t * mp)
17450 vat_main_t *vam = &vat_main;
17451 vat_json_node_t node;
17452 struct in_addr collector_address;
17453 struct in_addr src_address;
17455 vat_json_init_object (&node);
17456 clib_memcpy (&collector_address, &mp->collector_address,
17457 sizeof (collector_address));
17458 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
17459 vat_json_object_add_uint (&node, "collector_port",
17460 ntohs (mp->collector_port));
17461 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
17462 vat_json_object_add_ip4 (&node, "src_address", src_address);
17463 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
17464 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
17465 vat_json_object_add_uint (&node, "template_interval",
17466 ntohl (mp->template_interval));
17467 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
17469 vat_json_print (vam->ofp, &node);
17470 vat_json_free (&node);
17472 vam->result_ready = 1;
17476 api_ipfix_exporter_dump (vat_main_t * vam)
17478 vl_api_ipfix_exporter_dump_t *mp;
17481 /* Construct the API message */
17482 M (IPFIX_EXPORTER_DUMP, mp);
17491 api_ipfix_classify_stream_dump (vat_main_t * vam)
17493 vl_api_ipfix_classify_stream_dump_t *mp;
17496 /* Construct the API message */
17497 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
17508 vl_api_ipfix_classify_stream_details_t_handler
17509 (vl_api_ipfix_classify_stream_details_t * mp)
17511 vat_main_t *vam = &vat_main;
17512 print (vam->ofp, "domain_id %d, src_port %d",
17513 ntohl (mp->domain_id), ntohs (mp->src_port));
17515 vam->result_ready = 1;
17519 vl_api_ipfix_classify_stream_details_t_handler_json
17520 (vl_api_ipfix_classify_stream_details_t * mp)
17522 vat_main_t *vam = &vat_main;
17523 vat_json_node_t node;
17525 vat_json_init_object (&node);
17526 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
17527 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
17529 vat_json_print (vam->ofp, &node);
17530 vat_json_free (&node);
17532 vam->result_ready = 1;
17536 api_ipfix_classify_table_dump (vat_main_t * vam)
17538 vl_api_ipfix_classify_table_dump_t *mp;
17539 vl_api_control_ping_t *mp_ping;
17542 if (!vam->json_output)
17544 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
17545 "transport_protocol");
17548 /* Construct the API message */
17549 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
17554 /* Use a control ping for synchronization */
17555 M (CONTROL_PING, mp_ping);
17563 vl_api_ipfix_classify_table_details_t_handler
17564 (vl_api_ipfix_classify_table_details_t * mp)
17566 vat_main_t *vam = &vat_main;
17567 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
17568 mp->transport_protocol);
17572 vl_api_ipfix_classify_table_details_t_handler_json
17573 (vl_api_ipfix_classify_table_details_t * mp)
17575 vat_json_node_t *node = NULL;
17576 vat_main_t *vam = &vat_main;
17578 if (VAT_JSON_ARRAY != vam->json_tree.type)
17580 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17581 vat_json_init_array (&vam->json_tree);
17584 node = vat_json_array_add (&vam->json_tree);
17585 vat_json_init_object (node);
17587 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
17588 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
17589 vat_json_object_add_uint (node, "transport_protocol",
17590 mp->transport_protocol);
17594 api_sw_interface_span_enable_disable (vat_main_t * vam)
17596 unformat_input_t *i = vam->input;
17597 vl_api_sw_interface_span_enable_disable_t *mp;
17598 u32 src_sw_if_index = ~0;
17599 u32 dst_sw_if_index = ~0;
17603 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17606 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
17608 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
17612 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
17614 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
17616 else if (unformat (i, "disable"))
17618 else if (unformat (i, "rx"))
17620 else if (unformat (i, "tx"))
17622 else if (unformat (i, "both"))
17628 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
17630 mp->sw_if_index_from = htonl (src_sw_if_index);
17631 mp->sw_if_index_to = htonl (dst_sw_if_index);
17640 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
17643 vat_main_t *vam = &vat_main;
17644 u8 *sw_if_from_name = 0;
17645 u8 *sw_if_to_name = 0;
17646 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17647 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17648 char *states[] = { "none", "rx", "tx", "both" };
17652 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17654 if ((u32) p->value[0] == sw_if_index_from)
17656 sw_if_from_name = (u8 *)(p->key);
17660 if ((u32) p->value[0] == sw_if_index_to)
17662 sw_if_to_name = (u8 *)(p->key);
17663 if (sw_if_from_name)
17668 print (vam->ofp, "%20s => %20s (%s)",
17669 sw_if_from_name, sw_if_to_name, states[mp->state]);
17673 vl_api_sw_interface_span_details_t_handler_json
17674 (vl_api_sw_interface_span_details_t * mp)
17676 vat_main_t *vam = &vat_main;
17677 vat_json_node_t *node = NULL;
17678 u8 *sw_if_from_name = 0;
17679 u8 *sw_if_to_name = 0;
17680 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17681 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17685 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17687 if ((u32) p->value[0] == sw_if_index_from)
17689 sw_if_from_name = (u8 *)(p->key);
17693 if ((u32) p->value[0] == sw_if_index_to)
17695 sw_if_to_name = (u8 *)(p->key);
17696 if (sw_if_from_name)
17702 if (VAT_JSON_ARRAY != vam->json_tree.type)
17704 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17705 vat_json_init_array (&vam->json_tree);
17707 node = vat_json_array_add (&vam->json_tree);
17709 vat_json_init_object (node);
17710 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
17711 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
17712 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
17713 if (0 != sw_if_to_name)
17715 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
17717 vat_json_object_add_uint (node, "state", mp->state);
17721 api_sw_interface_span_dump (vat_main_t * vam)
17723 vl_api_sw_interface_span_dump_t *mp;
17724 vl_api_control_ping_t *mp_ping;
17727 M (SW_INTERFACE_SPAN_DUMP, mp);
17730 /* Use a control ping for synchronization */
17731 M (CONTROL_PING, mp_ping);
17739 api_pg_create_interface (vat_main_t * vam)
17741 unformat_input_t *input = vam->input;
17742 vl_api_pg_create_interface_t *mp;
17746 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17748 if (unformat (input, "if_id %d", &if_id))
17755 errmsg ("missing pg interface index");
17759 /* Construct the API message */
17760 M (PG_CREATE_INTERFACE, mp);
17762 mp->interface_id = ntohl (if_id);
17770 api_pg_capture (vat_main_t * vam)
17772 unformat_input_t *input = vam->input;
17773 vl_api_pg_capture_t *mp;
17778 u8 pcap_file_set = 0;
17781 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17783 if (unformat (input, "if_id %d", &if_id))
17785 else if (unformat (input, "pcap %s", &pcap_file))
17787 else if (unformat (input, "count %d", &count))
17789 else if (unformat (input, "disable"))
17796 errmsg ("missing pg interface index");
17799 if (pcap_file_set > 0)
17801 if (vec_len (pcap_file) > 255)
17803 errmsg ("pcap file name is too long");
17808 u32 name_len = vec_len (pcap_file);
17809 /* Construct the API message */
17810 M (PG_CAPTURE, mp);
17812 mp->interface_id = ntohl (if_id);
17813 mp->is_enabled = enable;
17814 mp->count = ntohl (count);
17815 mp->pcap_name_length = ntohl (name_len);
17816 if (pcap_file_set != 0)
17818 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
17820 vec_free (pcap_file);
17828 api_pg_enable_disable (vat_main_t * vam)
17830 unformat_input_t *input = vam->input;
17831 vl_api_pg_enable_disable_t *mp;
17834 u8 stream_name_set = 0;
17835 u8 *stream_name = 0;
17837 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17839 if (unformat (input, "stream %s", &stream_name))
17840 stream_name_set = 1;
17841 else if (unformat (input, "disable"))
17847 if (stream_name_set > 0)
17849 if (vec_len (stream_name) > 255)
17851 errmsg ("stream name too long");
17856 u32 name_len = vec_len (stream_name);
17857 /* Construct the API message */
17858 M (PG_ENABLE_DISABLE, mp);
17860 mp->is_enabled = enable;
17861 if (stream_name_set != 0)
17863 mp->stream_name_length = ntohl (name_len);
17864 clib_memcpy (mp->stream_name, stream_name, name_len);
17866 vec_free (stream_name);
17874 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
17876 unformat_input_t *input = vam->input;
17877 vl_api_ip_source_and_port_range_check_add_del_t *mp;
17879 u16 *low_ports = 0;
17880 u16 *high_ports = 0;
17883 ip4_address_t ip4_addr;
17884 ip6_address_t ip6_addr;
17893 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17895 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
17901 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
17906 else if (unformat (input, "vrf %d", &vrf_id))
17908 else if (unformat (input, "del"))
17910 else if (unformat (input, "port %d", &tmp))
17912 if (tmp == 0 || tmp > 65535)
17914 errmsg ("port %d out of range", tmp);
17918 this_hi = this_low + 1;
17919 vec_add1 (low_ports, this_low);
17920 vec_add1 (high_ports, this_hi);
17922 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
17924 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
17926 errmsg ("incorrect range parameters");
17930 /* Note: in debug CLI +1 is added to high before
17931 passing to real fn that does "the work"
17932 (ip_source_and_port_range_check_add_del).
17933 This fn is a wrapper around the binary API fn a
17934 control plane will call, which expects this increment
17935 to have occurred. Hence letting the binary API control
17936 plane fn do the increment for consistency between VAT
17937 and other control planes.
17940 vec_add1 (low_ports, this_low);
17941 vec_add1 (high_ports, this_hi);
17947 if (prefix_set == 0)
17949 errmsg ("<address>/<mask> not specified");
17955 errmsg ("VRF ID required, not specified");
17962 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17966 if (vec_len (low_ports) == 0)
17968 errmsg ("At least one port or port range required");
17972 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
17974 mp->is_add = is_add;
17979 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
17984 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
17987 mp->mask_length = length;
17988 mp->number_of_ranges = vec_len (low_ports);
17990 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
17991 vec_free (low_ports);
17993 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
17994 vec_free (high_ports);
17996 mp->vrf_id = ntohl (vrf_id);
18004 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
18006 unformat_input_t *input = vam->input;
18007 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
18008 u32 sw_if_index = ~0;
18010 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
18011 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
18015 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18017 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18019 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18021 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
18023 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
18025 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
18027 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
18029 else if (unformat (input, "del"))
18035 if (sw_if_index == ~0)
18037 errmsg ("Interface required but not specified");
18043 errmsg ("VRF ID required but not specified");
18047 if (tcp_out_vrf_id == 0
18048 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
18051 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18055 /* Construct the API message */
18056 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
18058 mp->sw_if_index = ntohl (sw_if_index);
18059 mp->is_add = is_add;
18060 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
18061 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
18062 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
18063 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
18068 /* Wait for a reply... */
18074 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
18076 unformat_input_t *i = vam->input;
18077 vl_api_ipsec_gre_add_del_tunnel_t *mp;
18078 u32 local_sa_id = 0;
18079 u32 remote_sa_id = 0;
18080 ip4_address_t src_address;
18081 ip4_address_t dst_address;
18085 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18087 if (unformat (i, "local_sa %d", &local_sa_id))
18089 else if (unformat (i, "remote_sa %d", &remote_sa_id))
18091 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
18093 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
18095 else if (unformat (i, "del"))
18099 clib_warning ("parse error '%U'", format_unformat_error, i);
18104 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
18106 mp->local_sa_id = ntohl (local_sa_id);
18107 mp->remote_sa_id = ntohl (remote_sa_id);
18108 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
18109 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
18110 mp->is_add = is_add;
18118 api_punt (vat_main_t * vam)
18120 unformat_input_t *i = vam->input;
18128 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18130 if (unformat (i, "ip %d", &ipv))
18132 else if (unformat (i, "protocol %d", &protocol))
18134 else if (unformat (i, "port %d", &port))
18136 else if (unformat (i, "del"))
18140 clib_warning ("parse error '%U'", format_unformat_error, i);
18147 mp->is_add = (u8) is_add;
18148 mp->ipv = (u8) ipv;
18149 mp->l4_protocol = (u8) protocol;
18150 mp->l4_port = htons ((u16) port);
18157 static void vl_api_ipsec_gre_tunnel_details_t_handler
18158 (vl_api_ipsec_gre_tunnel_details_t * mp)
18160 vat_main_t *vam = &vat_main;
18162 print (vam->ofp, "%11d%15U%15U%14d%14d",
18163 ntohl (mp->sw_if_index),
18164 format_ip4_address, &mp->src_address,
18165 format_ip4_address, &mp->dst_address,
18166 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
18169 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
18170 (vl_api_ipsec_gre_tunnel_details_t * mp)
18172 vat_main_t *vam = &vat_main;
18173 vat_json_node_t *node = NULL;
18174 struct in_addr ip4;
18176 if (VAT_JSON_ARRAY != vam->json_tree.type)
18178 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18179 vat_json_init_array (&vam->json_tree);
18181 node = vat_json_array_add (&vam->json_tree);
18183 vat_json_init_object (node);
18184 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18185 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
18186 vat_json_object_add_ip4 (node, "src_address", ip4);
18187 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
18188 vat_json_object_add_ip4 (node, "dst_address", ip4);
18189 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
18190 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
18194 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
18196 unformat_input_t *i = vam->input;
18197 vl_api_ipsec_gre_tunnel_dump_t *mp;
18198 vl_api_control_ping_t *mp_ping;
18200 u8 sw_if_index_set = 0;
18203 /* Parse args required to build the message */
18204 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18206 if (unformat (i, "sw_if_index %d", &sw_if_index))
18207 sw_if_index_set = 1;
18212 if (sw_if_index_set == 0)
18217 if (!vam->json_output)
18219 print (vam->ofp, "%11s%15s%15s%14s%14s",
18220 "sw_if_index", "src_address", "dst_address",
18221 "local_sa_id", "remote_sa_id");
18224 /* Get list of gre-tunnel interfaces */
18225 M (IPSEC_GRE_TUNNEL_DUMP, mp);
18227 mp->sw_if_index = htonl (sw_if_index);
18231 /* Use a control ping for synchronization */
18232 M (CONTROL_PING, mp_ping);
18240 api_delete_subif (vat_main_t * vam)
18242 unformat_input_t *i = vam->input;
18243 vl_api_delete_subif_t *mp;
18244 u32 sw_if_index = ~0;
18247 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18249 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18251 if (unformat (i, "sw_if_index %d", &sw_if_index))
18257 if (sw_if_index == ~0)
18259 errmsg ("missing sw_if_index");
18263 /* Construct the API message */
18264 M (DELETE_SUBIF, mp);
18265 mp->sw_if_index = ntohl (sw_if_index);
18272 #define foreach_pbb_vtr_op \
18273 _("disable", L2_VTR_DISABLED) \
18274 _("pop", L2_VTR_POP_2) \
18275 _("push", L2_VTR_PUSH_2)
18278 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
18280 unformat_input_t *i = vam->input;
18281 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
18282 u32 sw_if_index = ~0, vtr_op = ~0;
18283 u16 outer_tag = ~0;
18284 u8 dmac[6], smac[6];
18285 u8 dmac_set = 0, smac_set = 0;
18291 /* Shut up coverity */
18292 memset (dmac, 0, sizeof (dmac));
18293 memset (smac, 0, sizeof (smac));
18295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18297 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18299 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18301 else if (unformat (i, "vtr_op %d", &vtr_op))
18303 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
18306 else if (unformat (i, "translate_pbb_stag"))
18308 if (unformat (i, "%d", &tmp))
18310 vtr_op = L2_VTR_TRANSLATE_2_1;
18316 ("translate_pbb_stag operation requires outer tag definition");
18320 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
18322 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
18324 else if (unformat (i, "sid %d", &sid))
18326 else if (unformat (i, "vlanid %d", &tmp))
18330 clib_warning ("parse error '%U'", format_unformat_error, i);
18335 if ((sw_if_index == ~0) || (vtr_op == ~0))
18337 errmsg ("missing sw_if_index or vtr operation");
18340 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
18341 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
18344 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
18348 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
18349 mp->sw_if_index = ntohl (sw_if_index);
18350 mp->vtr_op = ntohl (vtr_op);
18351 mp->outer_tag = ntohs (outer_tag);
18352 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
18353 clib_memcpy (mp->b_smac, smac, sizeof (smac));
18354 mp->b_vlanid = ntohs (vlanid);
18355 mp->i_sid = ntohl (sid);
18363 api_flow_classify_set_interface (vat_main_t * vam)
18365 unformat_input_t *i = vam->input;
18366 vl_api_flow_classify_set_interface_t *mp;
18368 int sw_if_index_set;
18369 u32 ip4_table_index = ~0;
18370 u32 ip6_table_index = ~0;
18374 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18376 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18377 sw_if_index_set = 1;
18378 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18379 sw_if_index_set = 1;
18380 else if (unformat (i, "del"))
18382 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18384 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18388 clib_warning ("parse error '%U'", format_unformat_error, i);
18393 if (sw_if_index_set == 0)
18395 errmsg ("missing interface name or sw_if_index");
18399 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
18401 mp->sw_if_index = ntohl (sw_if_index);
18402 mp->ip4_table_index = ntohl (ip4_table_index);
18403 mp->ip6_table_index = ntohl (ip6_table_index);
18404 mp->is_add = is_add;
18412 api_flow_classify_dump (vat_main_t * vam)
18414 unformat_input_t *i = vam->input;
18415 vl_api_flow_classify_dump_t *mp;
18416 vl_api_control_ping_t *mp_ping;
18417 u8 type = FLOW_CLASSIFY_N_TABLES;
18420 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
18424 errmsg ("classify table type must be specified");
18428 if (!vam->json_output)
18430 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18433 M (FLOW_CLASSIFY_DUMP, mp);
18438 /* Use a control ping for synchronization */
18439 M (CONTROL_PING, mp_ping);
18442 /* Wait for a reply... */
18448 api_feature_enable_disable (vat_main_t * vam)
18450 unformat_input_t *i = vam->input;
18451 vl_api_feature_enable_disable_t *mp;
18453 u8 *feature_name = 0;
18454 u32 sw_if_index = ~0;
18458 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18460 if (unformat (i, "arc_name %s", &arc_name))
18462 else if (unformat (i, "feature_name %s", &feature_name))
18465 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18467 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18469 else if (unformat (i, "disable"))
18477 errmsg ("missing arc name");
18480 if (vec_len (arc_name) > 63)
18482 errmsg ("arc name too long");
18485 if (feature_name == 0)
18487 errmsg ("missing feature name");
18490 if (vec_len (feature_name) > 63)
18492 errmsg ("feature name too long");
18495 if (sw_if_index == ~0)
18497 errmsg ("missing interface name or sw_if_index");
18501 /* Construct the API message */
18502 M (FEATURE_ENABLE_DISABLE, mp);
18503 mp->sw_if_index = ntohl (sw_if_index);
18504 mp->enable = enable;
18505 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
18506 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
18507 vec_free (arc_name);
18508 vec_free (feature_name);
18516 api_sw_interface_tag_add_del (vat_main_t * vam)
18518 unformat_input_t *i = vam->input;
18519 vl_api_sw_interface_tag_add_del_t *mp;
18520 u32 sw_if_index = ~0;
18525 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18527 if (unformat (i, "tag %s", &tag))
18529 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18531 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18533 else if (unformat (i, "del"))
18539 if (sw_if_index == ~0)
18541 errmsg ("missing interface name or sw_if_index");
18545 if (enable && (tag == 0))
18547 errmsg ("no tag specified");
18551 /* Construct the API message */
18552 M (SW_INTERFACE_TAG_ADD_DEL, mp);
18553 mp->sw_if_index = ntohl (sw_if_index);
18554 mp->is_add = enable;
18556 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
18564 static void vl_api_l2_xconnect_details_t_handler
18565 (vl_api_l2_xconnect_details_t * mp)
18567 vat_main_t *vam = &vat_main;
18569 print (vam->ofp, "%15d%15d",
18570 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
18573 static void vl_api_l2_xconnect_details_t_handler_json
18574 (vl_api_l2_xconnect_details_t * mp)
18576 vat_main_t *vam = &vat_main;
18577 vat_json_node_t *node = NULL;
18579 if (VAT_JSON_ARRAY != vam->json_tree.type)
18581 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18582 vat_json_init_array (&vam->json_tree);
18584 node = vat_json_array_add (&vam->json_tree);
18586 vat_json_init_object (node);
18587 vat_json_object_add_uint (node, "rx_sw_if_index",
18588 ntohl (mp->rx_sw_if_index));
18589 vat_json_object_add_uint (node, "tx_sw_if_index",
18590 ntohl (mp->tx_sw_if_index));
18594 api_l2_xconnect_dump (vat_main_t * vam)
18596 vl_api_l2_xconnect_dump_t *mp;
18597 vl_api_control_ping_t *mp_ping;
18600 if (!vam->json_output)
18602 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
18605 M (L2_XCONNECT_DUMP, mp);
18609 /* Use a control ping for synchronization */
18610 M (CONTROL_PING, mp_ping);
18618 api_sw_interface_set_mtu (vat_main_t * vam)
18620 unformat_input_t *i = vam->input;
18621 vl_api_sw_interface_set_mtu_t *mp;
18622 u32 sw_if_index = ~0;
18626 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18628 if (unformat (i, "mtu %d", &mtu))
18630 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18632 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18638 if (sw_if_index == ~0)
18640 errmsg ("missing interface name or sw_if_index");
18646 errmsg ("no mtu specified");
18650 /* Construct the API message */
18651 M (SW_INTERFACE_SET_MTU, mp);
18652 mp->sw_if_index = ntohl (sw_if_index);
18653 mp->mtu = ntohs ((u16) mtu);
18662 q_or_quit (vat_main_t * vam)
18664 #if VPP_API_TEST_BUILTIN == 0
18665 longjmp (vam->jump_buf, 1);
18667 return 0; /* not so much */
18671 q (vat_main_t * vam)
18673 return q_or_quit (vam);
18677 quit (vat_main_t * vam)
18679 return q_or_quit (vam);
18683 comment (vat_main_t * vam)
18689 cmd_cmp (void *a1, void *a2)
18694 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
18698 help (vat_main_t * vam)
18703 unformat_input_t *i = vam->input;
18706 if (unformat (i, "%s", &name))
18710 vec_add1 (name, 0);
18712 hs = hash_get_mem (vam->help_by_name, name);
18714 print (vam->ofp, "usage: %s %s", name, hs[0]);
18716 print (vam->ofp, "No such msg / command '%s'", name);
18721 print (vam->ofp, "Help is available for the following:");
18724 hash_foreach_pair (p, vam->function_by_name,
18726 vec_add1 (cmds, (u8 *)(p->key));
18730 vec_sort_with_function (cmds, cmd_cmp);
18732 for (j = 0; j < vec_len (cmds); j++)
18733 print (vam->ofp, "%s", cmds[j]);
18740 set (vat_main_t * vam)
18742 u8 *name = 0, *value = 0;
18743 unformat_input_t *i = vam->input;
18745 if (unformat (i, "%s", &name))
18747 /* The input buffer is a vector, not a string. */
18748 value = vec_dup (i->buffer);
18749 vec_delete (value, i->index, 0);
18750 /* Almost certainly has a trailing newline */
18751 if (value[vec_len (value) - 1] == '\n')
18752 value[vec_len (value) - 1] = 0;
18753 /* Make sure it's a proper string, one way or the other */
18754 vec_add1 (value, 0);
18755 (void) clib_macro_set_value (&vam->macro_main,
18756 (char *) name, (char *) value);
18759 errmsg ("usage: set <name> <value>");
18767 unset (vat_main_t * vam)
18771 if (unformat (vam->input, "%s", &name))
18772 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
18773 errmsg ("unset: %s wasn't set", name);
18786 macro_sort_cmp (void *a1, void *a2)
18788 macro_sort_t *s1 = a1;
18789 macro_sort_t *s2 = a2;
18791 return strcmp ((char *) (s1->name), (char *) (s2->name));
18795 dump_macro_table (vat_main_t * vam)
18797 macro_sort_t *sort_me = 0, *sm;
18802 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
18804 vec_add2 (sort_me, sm, 1);
18805 sm->name = (u8 *)(p->key);
18806 sm->value = (u8 *) (p->value[0]);
18810 vec_sort_with_function (sort_me, macro_sort_cmp);
18812 if (vec_len (sort_me))
18813 print (vam->ofp, "%-15s%s", "Name", "Value");
18815 print (vam->ofp, "The macro table is empty...");
18817 for (i = 0; i < vec_len (sort_me); i++)
18818 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
18823 dump_node_table (vat_main_t * vam)
18826 vlib_node_t *node, *next_node;
18828 if (vec_len (vam->graph_nodes) == 0)
18830 print (vam->ofp, "Node table empty, issue get_node_graph...");
18834 for (i = 0; i < vec_len (vam->graph_nodes); i++)
18836 node = vam->graph_nodes[i];
18837 print (vam->ofp, "[%d] %s", i, node->name);
18838 for (j = 0; j < vec_len (node->next_nodes); j++)
18840 if (node->next_nodes[j] != ~0)
18842 next_node = vam->graph_nodes[node->next_nodes[j]];
18843 print (vam->ofp, " [%d] %s", j, next_node->name);
18851 value_sort_cmp (void *a1, void *a2)
18853 name_sort_t *n1 = a1;
18854 name_sort_t *n2 = a2;
18856 if (n1->value < n2->value)
18858 if (n1->value > n2->value)
18865 dump_msg_api_table (vat_main_t * vam)
18867 api_main_t *am = &api_main;
18868 name_sort_t *nses = 0, *ns;
18873 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
18875 vec_add2 (nses, ns, 1);
18876 ns->name = (u8 *)(hp->key);
18877 ns->value = (u32) hp->value[0];
18881 vec_sort_with_function (nses, value_sort_cmp);
18883 for (i = 0; i < vec_len (nses); i++)
18884 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
18890 get_msg_id (vat_main_t * vam)
18895 if (unformat (vam->input, "%s", &name_and_crc))
18897 message_index = vl_api_get_msg_index (name_and_crc);
18898 if (message_index == ~0)
18900 print (vam->ofp, " '%s' not found", name_and_crc);
18903 print (vam->ofp, " '%s' has message index %d",
18904 name_and_crc, message_index);
18907 errmsg ("name_and_crc required...");
18912 search_node_table (vat_main_t * vam)
18914 unformat_input_t *line_input = vam->input;
18917 vlib_node_t *node, *next_node;
18920 if (vam->graph_node_index_by_name == 0)
18922 print (vam->ofp, "Node table empty, issue get_node_graph...");
18926 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
18928 if (unformat (line_input, "%s", &node_to_find))
18930 vec_add1 (node_to_find, 0);
18931 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
18934 print (vam->ofp, "%s not found...", node_to_find);
18937 node = vam->graph_nodes[p[0]];
18938 print (vam->ofp, "[%d] %s", p[0], node->name);
18939 for (j = 0; j < vec_len (node->next_nodes); j++)
18941 if (node->next_nodes[j] != ~0)
18943 next_node = vam->graph_nodes[node->next_nodes[j]];
18944 print (vam->ofp, " [%d] %s", j, next_node->name);
18951 clib_warning ("parse error '%U'", format_unformat_error,
18957 vec_free (node_to_find);
18966 script (vat_main_t * vam)
18968 #if (VPP_API_TEST_BUILTIN==0)
18970 char *save_current_file;
18971 unformat_input_t save_input;
18972 jmp_buf save_jump_buf;
18973 u32 save_line_number;
18975 FILE *new_fp, *save_ifp;
18977 if (unformat (vam->input, "%s", &s))
18979 new_fp = fopen ((char *) s, "r");
18982 errmsg ("Couldn't open script file %s", s);
18989 errmsg ("Missing script name");
18993 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
18994 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
18995 save_ifp = vam->ifp;
18996 save_line_number = vam->input_line_number;
18997 save_current_file = (char *) vam->current_file;
18999 vam->input_line_number = 0;
19001 vam->current_file = s;
19004 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
19005 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
19006 vam->ifp = save_ifp;
19007 vam->input_line_number = save_line_number;
19008 vam->current_file = (u8 *) save_current_file;
19013 clib_warning ("use the exec command...");
19019 echo (vat_main_t * vam)
19021 print (vam->ofp, "%v", vam->input->buffer);
19025 /* List of API message constructors, CLI names map to api_xxx */
19026 #define foreach_vpe_api_msg \
19027 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
19028 _(sw_interface_dump,"") \
19029 _(sw_interface_set_flags, \
19030 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
19031 _(sw_interface_add_del_address, \
19032 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
19033 _(sw_interface_set_table, \
19034 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
19035 _(sw_interface_set_mpls_enable, \
19036 "<intfc> | sw_if_index [disable | dis]") \
19037 _(sw_interface_set_vpath, \
19038 "<intfc> | sw_if_index <id> enable | disable") \
19039 _(sw_interface_set_vxlan_bypass, \
19040 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
19041 _(sw_interface_set_l2_xconnect, \
19042 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
19043 "enable | disable") \
19044 _(sw_interface_set_l2_bridge, \
19045 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
19046 "[shg <split-horizon-group>] [bvi]\n" \
19047 "enable | disable") \
19048 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
19049 _(bridge_domain_add_del, \
19050 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [mac-age 0-255] [del]\n") \
19051 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
19053 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
19054 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
19055 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
19057 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
19059 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
19061 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
19063 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
19065 "<vpp-if-name> | sw_if_index <id>") \
19066 _(sw_interface_tap_dump, "") \
19067 _(ip_add_del_route, \
19068 "<addr>/<mask> via <addr> [table-id <n>]\n" \
19069 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
19070 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
19071 "[multipath] [count <n>]") \
19072 _(ip_mroute_add_del, \
19073 "<src> <grp>/<mask> [table-id <n>]\n" \
19074 "[<intfc> | sw_if_index <id>] [local] [del]") \
19075 _(mpls_route_add_del, \
19076 "<label> <eos> via <addr> [table-id <n>]\n" \
19077 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
19078 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
19079 "[multipath] [count <n>]") \
19080 _(mpls_ip_bind_unbind, \
19081 "<label> <addr/len>") \
19082 _(mpls_tunnel_add_del, \
19083 " via <addr> [table-id <n>]\n" \
19084 "sw_if_index <id>] [l2] [del]") \
19085 _(proxy_arp_add_del, \
19086 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
19087 _(proxy_arp_intfc_enable_disable, \
19088 "<intfc> | sw_if_index <id> enable | disable") \
19089 _(sw_interface_set_unnumbered, \
19090 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
19091 _(ip_neighbor_add_del, \
19092 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
19093 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
19094 _(reset_vrf, "vrf <id> [ipv6]") \
19095 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
19096 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
19097 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
19098 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
19099 "[outer_vlan_id_any][inner_vlan_id_any]") \
19100 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
19101 _(reset_fib, "vrf <n> [ipv6]") \
19102 _(dhcp_proxy_config, \
19103 "svr <v46-address> src <v46-address>\n" \
19104 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
19105 _(dhcp_proxy_set_vss, \
19106 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
19107 _(dhcp_proxy_dump, "ip6") \
19108 _(dhcp_client_config, \
19109 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
19110 _(set_ip_flow_hash, \
19111 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
19112 _(sw_interface_ip6_enable_disable, \
19113 "<intfc> | sw_if_index <id> enable | disable") \
19114 _(sw_interface_ip6_set_link_local_address, \
19115 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
19116 _(ip6nd_proxy_add_del, \
19117 "<intfc> | sw_if_index <id> <ip6-address>") \
19118 _(ip6nd_proxy_dump, "") \
19119 _(sw_interface_ip6nd_ra_prefix, \
19120 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
19121 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
19122 "[nolink] [isno]") \
19123 _(sw_interface_ip6nd_ra_config, \
19124 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
19125 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
19126 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
19127 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
19128 _(l2_patch_add_del, \
19129 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
19130 "enable | disable") \
19131 _(sr_localsid_add_del, \
19132 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
19133 "fib-table <num> (end.psp) sw_if_index <num>") \
19134 _(classify_add_del_table, \
19135 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
19136 " [del] [del-chain] mask <mask-value>\n" \
19137 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
19138 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
19139 _(classify_add_del_session, \
19140 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
19141 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
19142 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
19143 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
19144 _(classify_set_interface_ip_table, \
19145 "<intfc> | sw_if_index <nn> table <nn>") \
19146 _(classify_set_interface_l2_tables, \
19147 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19148 " [other-table <nn>]") \
19149 _(get_node_index, "node <node-name") \
19150 _(add_node_next, "node <node-name> next <next-node-name>") \
19151 _(l2tpv3_create_tunnel, \
19152 "client_address <ip6-addr> our_address <ip6-addr>\n" \
19153 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
19154 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
19155 _(l2tpv3_set_tunnel_cookies, \
19156 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
19157 "[new_remote_cookie <nn>]\n") \
19158 _(l2tpv3_interface_enable_disable, \
19159 "<intfc> | sw_if_index <nn> enable | disable") \
19160 _(l2tpv3_set_lookup_key, \
19161 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
19162 _(sw_if_l2tpv3_tunnel_dump, "") \
19163 _(vxlan_add_del_tunnel, \
19164 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
19165 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
19166 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
19167 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19168 _(gre_add_del_tunnel, \
19169 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
19170 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19171 _(l2_fib_clear_table, "") \
19172 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
19173 _(l2_interface_vlan_tag_rewrite, \
19174 "<intfc> | sw_if_index <nn> \n" \
19175 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
19176 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
19177 _(create_vhost_user_if, \
19178 "socket <filename> [server] [renumber <dev_instance>] " \
19179 "[mac <mac_address>]") \
19180 _(modify_vhost_user_if, \
19181 "<intfc> | sw_if_index <nn> socket <filename>\n" \
19182 "[server] [renumber <dev_instance>]") \
19183 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
19184 _(sw_interface_vhost_user_dump, "") \
19185 _(show_version, "") \
19186 _(vxlan_gpe_add_del_tunnel, \
19187 "local <addr> remote <addr> vni <nn>\n" \
19188 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
19189 "[next-ethernet] [next-nsh]\n") \
19190 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19191 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
19192 _(interface_name_renumber, \
19193 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
19194 _(input_acl_set_interface, \
19195 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19196 " [l2-table <nn>] [del]") \
19197 _(want_ip4_arp_events, "address <ip4-address> [del]") \
19198 _(want_ip6_nd_events, "address <ip6-address> [del]") \
19199 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
19200 _(ip_dump, "ipv4 | ipv6") \
19201 _(ipsec_spd_add_del, "spd_id <n> [del]") \
19202 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
19204 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
19205 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
19206 " integ_alg <alg> integ_key <hex>") \
19207 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
19208 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
19209 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
19210 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
19211 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
19212 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
19213 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
19214 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
19215 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
19216 _(ikev2_profile_add_del, "name <profile_name> [del]") \
19217 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
19218 "(auth_data 0x<data> | auth_data <data>)") \
19219 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
19220 "(id_data 0x<data> | id_data <data>) (local|remote)") \
19221 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
19222 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
19223 "(local|remote)") \
19224 _(ikev2_set_local_key, "file <absolute_file_path>") \
19225 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
19226 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
19227 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
19228 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
19229 _(ikev2_initiate_sa_init, "<profile_name>") \
19230 _(ikev2_initiate_del_ike_sa, "<ispi>") \
19231 _(ikev2_initiate_del_child_sa, "<ispi>") \
19232 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
19233 _(delete_loopback,"sw_if_index <nn>") \
19234 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
19235 _(map_add_domain, \
19236 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
19237 "ip6-src <ip6addr> " \
19238 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
19239 _(map_del_domain, "index <n>") \
19240 _(map_add_del_rule, \
19241 "index <n> psid <n> dst <ip6addr> [del]") \
19242 _(map_domain_dump, "") \
19243 _(map_rule_dump, "index <map-domain>") \
19244 _(want_interface_events, "enable|disable") \
19245 _(want_stats,"enable|disable") \
19246 _(get_first_msg_id, "client <name>") \
19247 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
19248 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
19249 "fib-id <nn> [ip4][ip6][default]") \
19250 _(get_node_graph, " ") \
19251 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
19252 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
19253 _(ioam_disable, "") \
19254 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
19255 " sw_if_index <sw_if_index> p <priority> " \
19256 "w <weight>] [del]") \
19257 _(one_add_del_locator, "locator-set <locator_name> " \
19258 "iface <intf> | sw_if_index <sw_if_index> " \
19259 "p <priority> w <weight> [del]") \
19260 _(one_add_del_local_eid,"vni <vni> eid " \
19261 "<ipv4|ipv6>/<prefix> | <L2 address> " \
19262 "locator-set <locator_name> [del]" \
19263 "[key-id sha1|sha256 secret-key <secret-key>]")\
19264 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
19265 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
19266 _(one_enable_disable, "enable|disable") \
19267 _(one_map_register_enable_disable, "enable|disable") \
19268 _(one_rloc_probe_enable_disable, "enable|disable") \
19269 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
19271 "rloc <locator> p <prio> " \
19272 "w <weight> [rloc <loc> ... ] " \
19273 "action <action> [del-all]") \
19274 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
19276 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
19277 _(one_use_petr, "ip-address> | disable") \
19278 _(one_map_request_mode, "src-dst|dst-only") \
19279 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
19280 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
19281 _(one_locator_set_dump, "[local | remote]") \
19282 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
19283 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
19284 "[local] | [remote]") \
19285 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
19286 _(one_l2_arp_bd_get, "") \
19287 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
19288 _(one_stats_enable_disable, "enable|disalbe") \
19289 _(show_one_stats_enable_disable, "") \
19290 _(one_eid_table_vni_dump, "") \
19291 _(one_eid_table_map_dump, "l2|l3") \
19292 _(one_map_resolver_dump, "") \
19293 _(one_map_server_dump, "") \
19294 _(one_adjacencies_get, "vni <vni>") \
19295 _(show_one_rloc_probe_state, "") \
19296 _(show_one_map_register_state, "") \
19297 _(show_one_status, "") \
19298 _(one_stats_dump, "") \
19299 _(one_stats_flush, "") \
19300 _(one_get_map_request_itr_rlocs, "") \
19301 _(show_one_pitr, "") \
19302 _(show_one_use_petr, "") \
19303 _(show_one_map_request_mode, "") \
19304 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
19305 " sw_if_index <sw_if_index> p <priority> " \
19306 "w <weight>] [del]") \
19307 _(lisp_add_del_locator, "locator-set <locator_name> " \
19308 "iface <intf> | sw_if_index <sw_if_index> " \
19309 "p <priority> w <weight> [del]") \
19310 _(lisp_add_del_local_eid,"vni <vni> eid " \
19311 "<ipv4|ipv6>/<prefix> | <L2 address> " \
19312 "locator-set <locator_name> [del]" \
19313 "[key-id sha1|sha256 secret-key <secret-key>]") \
19314 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
19315 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
19316 _(lisp_enable_disable, "enable|disable") \
19317 _(lisp_map_register_enable_disable, "enable|disable") \
19318 _(lisp_rloc_probe_enable_disable, "enable|disable") \
19319 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
19321 "rloc <locator> p <prio> " \
19322 "w <weight> [rloc <loc> ... ] " \
19323 "action <action> [del-all]") \
19324 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
19326 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
19327 _(lisp_use_petr, "<ip-address> | disable") \
19328 _(lisp_map_request_mode, "src-dst|dst-only") \
19329 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
19330 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
19331 _(lisp_locator_set_dump, "[local | remote]") \
19332 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
19333 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
19334 "[local] | [remote]") \
19335 _(lisp_eid_table_vni_dump, "") \
19336 _(lisp_eid_table_map_dump, "l2|l3") \
19337 _(lisp_map_resolver_dump, "") \
19338 _(lisp_map_server_dump, "") \
19339 _(lisp_adjacencies_get, "vni <vni>") \
19340 _(gpe_fwd_entry_vnis_get, "") \
19341 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
19342 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
19343 _(gpe_set_encap_mode, "lisp|vxlan") \
19344 _(gpe_get_encap_mode, "") \
19345 _(lisp_gpe_add_del_iface, "up|down") \
19346 _(lisp_gpe_enable_disable, "enable|disable") \
19347 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
19348 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
19349 _(show_lisp_rloc_probe_state, "") \
19350 _(show_lisp_map_register_state, "") \
19351 _(show_lisp_status, "") \
19352 _(lisp_get_map_request_itr_rlocs, "") \
19353 _(show_lisp_pitr, "") \
19354 _(show_lisp_use_petr, "") \
19355 _(show_lisp_map_request_mode, "") \
19356 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
19357 _(af_packet_delete, "name <host interface name>") \
19358 _(policer_add_del, "name <policer name> <params> [del]") \
19359 _(policer_dump, "[name <policer name>]") \
19360 _(policer_classify_set_interface, \
19361 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19362 " [l2-table <nn>] [del]") \
19363 _(policer_classify_dump, "type [ip4|ip6|l2]") \
19364 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
19365 "[master|slave]") \
19366 _(netmap_delete, "name <interface name>") \
19367 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
19368 _(mpls_fib_dump, "") \
19369 _(classify_table_ids, "") \
19370 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
19371 _(classify_table_info, "table_id <nn>") \
19372 _(classify_session_dump, "table_id <nn>") \
19373 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
19374 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
19375 "[template_interval <nn>] [udp_checksum]") \
19376 _(ipfix_exporter_dump, "") \
19377 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
19378 _(ipfix_classify_stream_dump, "") \
19379 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
19380 _(ipfix_classify_table_dump, "") \
19381 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
19382 _(sw_interface_span_dump, "") \
19383 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
19384 _(pg_create_interface, "if_id <nn>") \
19385 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
19386 _(pg_enable_disable, "[stream <id>] disable") \
19387 _(ip_source_and_port_range_check_add_del, \
19388 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
19389 _(ip_source_and_port_range_check_interface_add_del, \
19390 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
19391 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
19392 _(ipsec_gre_add_del_tunnel, \
19393 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
19394 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
19395 _(delete_subif,"<intfc> | sw_if_index <nn>") \
19396 _(l2_interface_pbb_tag_rewrite, \
19397 "<intfc> | sw_if_index <nn> \n" \
19398 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
19399 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
19400 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
19401 _(flow_classify_set_interface, \
19402 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
19403 _(flow_classify_dump, "type [ip4|ip6]") \
19404 _(ip_fib_dump, "") \
19405 _(ip_mfib_dump, "") \
19406 _(ip6_fib_dump, "") \
19407 _(ip6_mfib_dump, "") \
19408 _(feature_enable_disable, "arc_name <arc_name> " \
19409 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
19410 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
19412 _(l2_xconnect_dump, "") \
19413 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
19414 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
19415 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
19417 /* List of command functions, CLI names map directly to functions */
19418 #define foreach_cli_function \
19419 _(comment, "usage: comment <ignore-rest-of-line>") \
19420 _(dump_interface_table, "usage: dump_interface_table") \
19421 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
19422 _(dump_ipv4_table, "usage: dump_ipv4_table") \
19423 _(dump_ipv6_table, "usage: dump_ipv6_table") \
19424 _(dump_stats_table, "usage: dump_stats_table") \
19425 _(dump_macro_table, "usage: dump_macro_table ") \
19426 _(dump_node_table, "usage: dump_node_table") \
19427 _(dump_msg_api_table, "usage: dump_msg_api_table") \
19428 _(get_msg_id, "usage: get_msg_id name_and_crc") \
19429 _(echo, "usage: echo <message>") \
19430 _(exec, "usage: exec <vpe-debug-CLI-command>") \
19431 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
19432 _(help, "usage: help") \
19433 _(q, "usage: quit") \
19434 _(quit, "usage: quit") \
19435 _(search_node_table, "usage: search_node_table <name>...") \
19436 _(set, "usage: set <variable-name> <value>") \
19437 _(script, "usage: script <file-name>") \
19438 _(unset, "usage: unset <variable-name>")
19441 static void vl_api_##n##_t_handler_uni \
19442 (vl_api_##n##_t * mp) \
19444 vat_main_t * vam = &vat_main; \
19445 if (vam->json_output) { \
19446 vl_api_##n##_t_handler_json(mp); \
19448 vl_api_##n##_t_handler(mp); \
19451 foreach_vpe_api_reply_msg;
19452 #if VPP_API_TEST_BUILTIN == 0
19453 foreach_standalone_reply_msg;
19458 vat_api_hookup (vat_main_t * vam)
19461 vl_msg_api_set_handlers(VL_API_##N, #n, \
19462 vl_api_##n##_t_handler_uni, \
19464 vl_api_##n##_t_endian, \
19465 vl_api_##n##_t_print, \
19466 sizeof(vl_api_##n##_t), 1);
19467 foreach_vpe_api_reply_msg;
19468 #if VPP_API_TEST_BUILTIN == 0
19469 foreach_standalone_reply_msg;
19473 #if (VPP_API_TEST_BUILTIN==0)
19474 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
19476 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
19478 vam->function_by_name = hash_create_string (0, sizeof (uword));
19480 vam->help_by_name = hash_create_string (0, sizeof (uword));
19483 /* API messages we can send */
19484 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
19485 foreach_vpe_api_msg;
19489 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
19490 foreach_vpe_api_msg;
19493 /* CLI functions */
19494 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
19495 foreach_cli_function;
19499 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
19500 foreach_cli_function;
19504 #if VPP_API_TEST_BUILTIN
19505 static clib_error_t *
19506 vat_api_hookup_shim (vlib_main_t * vm)
19508 vat_api_hookup (&vat_main);
19512 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
19516 * fd.io coding-style-patch-verification: ON
19519 * eval: (c-set-style "gnu")