2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vlibapi/api.h>
22 #include <vlibmemory/api.h>
23 #include <vlibsocket/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/l2/l2_input.h>
26 #include <vnet/l2tp/l2tp.h>
27 #include <vnet/vxlan/vxlan.h>
28 #include <vnet/gre/gre.h>
29 #include <vnet/vxlan-gpe/vxlan_gpe.h>
30 #include <vnet/lisp-gpe/lisp_gpe.h>
32 #include <vpp/api/vpe_msg_enum.h>
33 #include <vnet/l2/l2_classify.h>
34 #include <vnet/l2/l2_vtr.h>
35 #include <vnet/classify/input_acl.h>
36 #include <vnet/classify/policer_classify.h>
37 #include <vnet/classify/flow_classify.h>
38 #include <vnet/mpls/mpls.h>
39 #include <vnet/ipsec/ipsec.h>
40 #include <vnet/ipsec/ikev2.h>
42 #include <vnet/map/map.h>
43 #include <vnet/cop/cop.h>
44 #include <vnet/ip/ip6_hop_by_hop.h>
45 #include <vnet/ip/ip_source_and_port_range_check.h>
46 #include <vnet/policer/xlate.h>
47 #include <vnet/span/span.h>
48 #include <vnet/policer/policer.h>
49 #include <vnet/policer/police.h>
50 #include <vnet/mfib/mfib_types.h>
52 #include "vat/json_format.h"
57 #define vl_typedefs /* define message structures */
58 #include <vpp/api/vpe_all_api_h.h>
61 /* declare message handlers for each api */
63 #define vl_endianfun /* define message structures */
64 #include <vpp/api/vpe_all_api_h.h>
67 /* instantiate all the print functions we know about */
68 #define vl_print(handle, ...)
70 #include <vpp/api/vpe_all_api_h.h>
73 #define __plugin_msg_base 0
74 #include <vlibapi/vat_helper_macros.h>
77 vat_time_now (vat_main_t * vam)
79 #if VPP_API_TEST_BUILTIN
80 return vlib_time_now (vam->vlib_main);
82 return clib_time_now (&vam->clib_time);
87 errmsg (char *fmt, ...)
89 vat_main_t *vam = &vat_main;
94 s = va_format (0, fmt, &va);
99 #if VPP_API_TEST_BUILTIN
100 vlib_cli_output (vam->vlib_main, (char *) s);
103 if (vam->ifp != stdin)
104 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
105 vam->input_line_number);
106 fformat (vam->ofp, (char *) s);
114 #if VPP_API_TEST_BUILTIN == 0
116 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
118 vat_main_t *vam = va_arg (*args, vat_main_t *);
119 u32 *result = va_arg (*args, u32 *);
123 if (!unformat (input, "%s", &if_name))
126 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
133 /* Parse an IP4 address %d.%d.%d.%d. */
135 unformat_ip4_address (unformat_input_t * input, va_list * args)
137 u8 *result = va_arg (*args, u8 *);
140 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
143 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
155 unformat_ethernet_address (unformat_input_t * input, va_list * args)
157 u8 *result = va_arg (*args, u8 *);
160 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
161 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
165 for (i = 0; i < 6; i++)
166 if (a[i] >= (1 << 8))
169 for (i = 0; i < 6; i++)
175 /* Returns ethernet type as an int in host byte order. */
177 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
180 u16 *result = va_arg (*args, u16 *);
184 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
186 if (type >= (1 << 16))
194 /* Parse an IP6 address. */
196 unformat_ip6_address (unformat_input_t * input, va_list * args)
198 ip6_address_t *result = va_arg (*args, ip6_address_t *);
200 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
201 uword c, n_colon, double_colon_index;
203 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
204 double_colon_index = ARRAY_LEN (hex_quads);
205 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
208 if (c >= '0' && c <= '9')
210 else if (c >= 'a' && c <= 'f')
211 hex_digit = c + 10 - 'a';
212 else if (c >= 'A' && c <= 'F')
213 hex_digit = c + 10 - 'A';
214 else if (c == ':' && n_colon < 2)
218 unformat_put_input (input);
222 /* Too many hex quads. */
223 if (n_hex_quads >= ARRAY_LEN (hex_quads))
228 hex_quad = (hex_quad << 4) | hex_digit;
230 /* Hex quad must fit in 16 bits. */
231 if (n_hex_digits >= 4)
238 /* Save position of :: */
241 /* More than one :: ? */
242 if (double_colon_index < ARRAY_LEN (hex_quads))
244 double_colon_index = n_hex_quads;
247 if (n_colon > 0 && n_hex_digits > 0)
249 hex_quads[n_hex_quads++] = hex_quad;
255 if (n_hex_digits > 0)
256 hex_quads[n_hex_quads++] = hex_quad;
261 /* Expand :: to appropriate number of zero hex quads. */
262 if (double_colon_index < ARRAY_LEN (hex_quads))
264 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
266 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
267 hex_quads[n_zero + i] = hex_quads[i];
269 for (i = 0; i < n_zero; i++)
270 hex_quads[double_colon_index + i] = 0;
272 n_hex_quads = ARRAY_LEN (hex_quads);
275 /* Too few hex quads given. */
276 if (n_hex_quads < ARRAY_LEN (hex_quads))
279 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
280 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
287 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
289 u32 *r = va_arg (*args, u32 *);
292 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
293 foreach_ipsec_policy_action
301 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
303 u32 *r = va_arg (*args, u32 *);
306 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
307 foreach_ipsec_crypto_alg
315 format_ipsec_crypto_alg (u8 * s, va_list * args)
317 u32 i = va_arg (*args, u32);
322 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
323 foreach_ipsec_crypto_alg
326 return format (s, "unknown");
328 return format (s, "%s", t);
332 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
334 u32 *r = va_arg (*args, u32 *);
337 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
338 foreach_ipsec_integ_alg
346 format_ipsec_integ_alg (u8 * s, va_list * args)
348 u32 i = va_arg (*args, u32);
353 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
354 foreach_ipsec_integ_alg
357 return format (s, "unknown");
359 return format (s, "%s", t);
363 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
365 u32 *r = va_arg (*args, u32 *);
368 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
369 foreach_ikev2_auth_method
377 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
379 u32 *r = va_arg (*args, u32 *);
382 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
383 foreach_ikev2_id_type
389 #else /* VPP_API_TEST_BUILTIN == 1 */
391 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
393 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
394 vnet_main_t *vnm = vnet_get_main ();
395 u32 *result = va_arg (*args, u32 *);
398 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
401 *result = sw_if_index;
404 #endif /* VPP_API_TEST_BUILTIN */
407 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
409 u8 *r = va_arg (*args, u8 *);
411 if (unformat (input, "kbps"))
412 *r = SSE2_QOS_RATE_KBPS;
413 else if (unformat (input, "pps"))
414 *r = SSE2_QOS_RATE_PPS;
421 unformat_policer_round_type (unformat_input_t * input, va_list * args)
423 u8 *r = va_arg (*args, u8 *);
425 if (unformat (input, "closest"))
426 *r = SSE2_QOS_ROUND_TO_CLOSEST;
427 else if (unformat (input, "up"))
428 *r = SSE2_QOS_ROUND_TO_UP;
429 else if (unformat (input, "down"))
430 *r = SSE2_QOS_ROUND_TO_DOWN;
437 unformat_policer_type (unformat_input_t * input, va_list * args)
439 u8 *r = va_arg (*args, u8 *);
441 if (unformat (input, "1r2c"))
442 *r = SSE2_QOS_POLICER_TYPE_1R2C;
443 else if (unformat (input, "1r3c"))
444 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
445 else if (unformat (input, "2r3c-2698"))
446 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
447 else if (unformat (input, "2r3c-4115"))
448 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
449 else if (unformat (input, "2r3c-mef5cf1"))
450 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
457 unformat_dscp (unformat_input_t * input, va_list * va)
459 u8 *r = va_arg (*va, u8 *);
462 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
471 unformat_policer_action_type (unformat_input_t * input, va_list * va)
473 sse2_qos_pol_action_params_st *a
474 = va_arg (*va, sse2_qos_pol_action_params_st *);
476 if (unformat (input, "drop"))
477 a->action_type = SSE2_QOS_ACTION_DROP;
478 else if (unformat (input, "transmit"))
479 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
480 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
481 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
488 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
490 u32 *r = va_arg (*va, u32 *);
493 if (unformat (input, "ip4"))
494 tid = POLICER_CLASSIFY_TABLE_IP4;
495 else if (unformat (input, "ip6"))
496 tid = POLICER_CLASSIFY_TABLE_IP6;
497 else if (unformat (input, "l2"))
498 tid = POLICER_CLASSIFY_TABLE_L2;
507 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
509 u32 *r = va_arg (*va, u32 *);
512 if (unformat (input, "ip4"))
513 tid = FLOW_CLASSIFY_TABLE_IP4;
514 else if (unformat (input, "ip6"))
515 tid = FLOW_CLASSIFY_TABLE_IP6;
523 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
524 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
525 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
526 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
528 #if (VPP_API_TEST_BUILTIN==0)
530 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
532 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
533 mfib_itf_attribute_t attr;
536 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
538 if (unformat (input, mfib_itf_flag_long_names[attr]))
539 *iflags |= (1 << attr);
541 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
543 if (unformat (input, mfib_itf_flag_names[attr]))
544 *iflags |= (1 << attr);
547 return (old == *iflags ? 0 : 1);
551 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
553 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
554 mfib_entry_attribute_t attr;
557 FOR_EACH_MFIB_ATTRIBUTE (attr)
559 if (unformat (input, mfib_flag_long_names[attr]))
560 *eflags |= (1 << attr);
562 FOR_EACH_MFIB_ATTRIBUTE (attr)
564 if (unformat (input, mfib_flag_names[attr]))
565 *eflags |= (1 << attr);
568 return (old == *eflags ? 0 : 1);
572 format_ip4_address (u8 * s, va_list * args)
574 u8 *a = va_arg (*args, u8 *);
575 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
579 format_ip6_address (u8 * s, va_list * args)
581 ip6_address_t *a = va_arg (*args, ip6_address_t *);
582 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
584 i_max_n_zero = ARRAY_LEN (a->as_u16);
586 i_first_zero = i_max_n_zero;
588 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
590 u32 is_zero = a->as_u16[i] == 0;
591 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
597 if ((!is_zero && n_zeros > max_n_zeros)
598 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
600 i_max_n_zero = i_first_zero;
601 max_n_zeros = n_zeros;
602 i_first_zero = ARRAY_LEN (a->as_u16);
607 last_double_colon = 0;
608 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
610 if (i == i_max_n_zero && max_n_zeros > 1)
612 s = format (s, "::");
613 i += max_n_zeros - 1;
614 last_double_colon = 1;
618 s = format (s, "%s%x",
619 (last_double_colon || i == 0) ? "" : ":",
620 clib_net_to_host_u16 (a->as_u16[i]));
621 last_double_colon = 0;
628 /* Format an IP46 address. */
630 format_ip46_address (u8 * s, va_list * args)
632 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
633 ip46_type_t type = va_arg (*args, ip46_type_t);
639 is_ip4 = ip46_address_is_ip4 (ip46);
650 format (s, "%U", format_ip4_address, &ip46->ip4) :
651 format (s, "%U", format_ip6_address, &ip46->ip6);
655 format_ethernet_address (u8 * s, va_list * args)
657 u8 *a = va_arg (*args, u8 *);
659 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
660 a[0], a[1], a[2], a[3], a[4], a[5]);
665 increment_v4_address (ip4_address_t * a)
669 v = ntohl (a->as_u32) + 1;
670 a->as_u32 = ntohl (v);
674 increment_v6_address (ip6_address_t * a)
678 v0 = clib_net_to_host_u64 (a->as_u64[0]);
679 v1 = clib_net_to_host_u64 (a->as_u64[1]);
684 a->as_u64[0] = clib_net_to_host_u64 (v0);
685 a->as_u64[1] = clib_net_to_host_u64 (v1);
689 increment_mac_address (u64 * mac)
693 tmp = clib_net_to_host_u64 (tmp);
694 tmp += 1 << 16; /* skip unused (least significant) octets */
695 tmp = clib_host_to_net_u64 (tmp);
699 static void vl_api_create_loopback_reply_t_handler
700 (vl_api_create_loopback_reply_t * mp)
702 vat_main_t *vam = &vat_main;
703 i32 retval = ntohl (mp->retval);
705 vam->retval = retval;
706 vam->regenerate_interface_table = 1;
707 vam->sw_if_index = ntohl (mp->sw_if_index);
708 vam->result_ready = 1;
711 static void vl_api_create_loopback_reply_t_handler_json
712 (vl_api_create_loopback_reply_t * mp)
714 vat_main_t *vam = &vat_main;
715 vat_json_node_t node;
717 vat_json_init_object (&node);
718 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
719 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
721 vat_json_print (vam->ofp, &node);
722 vat_json_free (&node);
723 vam->retval = ntohl (mp->retval);
724 vam->result_ready = 1;
727 static void vl_api_create_loopback_instance_reply_t_handler
728 (vl_api_create_loopback_instance_reply_t * mp)
730 vat_main_t *vam = &vat_main;
731 i32 retval = ntohl (mp->retval);
733 vam->retval = retval;
734 vam->regenerate_interface_table = 1;
735 vam->sw_if_index = ntohl (mp->sw_if_index);
736 vam->result_ready = 1;
739 static void vl_api_create_loopback_instance_reply_t_handler_json
740 (vl_api_create_loopback_instance_reply_t * mp)
742 vat_main_t *vam = &vat_main;
743 vat_json_node_t node;
745 vat_json_init_object (&node);
746 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
747 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
749 vat_json_print (vam->ofp, &node);
750 vat_json_free (&node);
751 vam->retval = ntohl (mp->retval);
752 vam->result_ready = 1;
755 static void vl_api_af_packet_create_reply_t_handler
756 (vl_api_af_packet_create_reply_t * mp)
758 vat_main_t *vam = &vat_main;
759 i32 retval = ntohl (mp->retval);
761 vam->retval = retval;
762 vam->regenerate_interface_table = 1;
763 vam->sw_if_index = ntohl (mp->sw_if_index);
764 vam->result_ready = 1;
767 static void vl_api_af_packet_create_reply_t_handler_json
768 (vl_api_af_packet_create_reply_t * mp)
770 vat_main_t *vam = &vat_main;
771 vat_json_node_t node;
773 vat_json_init_object (&node);
774 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
775 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
777 vat_json_print (vam->ofp, &node);
778 vat_json_free (&node);
780 vam->retval = ntohl (mp->retval);
781 vam->result_ready = 1;
784 static void vl_api_create_vlan_subif_reply_t_handler
785 (vl_api_create_vlan_subif_reply_t * mp)
787 vat_main_t *vam = &vat_main;
788 i32 retval = ntohl (mp->retval);
790 vam->retval = retval;
791 vam->regenerate_interface_table = 1;
792 vam->sw_if_index = ntohl (mp->sw_if_index);
793 vam->result_ready = 1;
796 static void vl_api_create_vlan_subif_reply_t_handler_json
797 (vl_api_create_vlan_subif_reply_t * mp)
799 vat_main_t *vam = &vat_main;
800 vat_json_node_t node;
802 vat_json_init_object (&node);
803 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
804 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
806 vat_json_print (vam->ofp, &node);
807 vat_json_free (&node);
809 vam->retval = ntohl (mp->retval);
810 vam->result_ready = 1;
813 static void vl_api_create_subif_reply_t_handler
814 (vl_api_create_subif_reply_t * mp)
816 vat_main_t *vam = &vat_main;
817 i32 retval = ntohl (mp->retval);
819 vam->retval = retval;
820 vam->regenerate_interface_table = 1;
821 vam->sw_if_index = ntohl (mp->sw_if_index);
822 vam->result_ready = 1;
825 static void vl_api_create_subif_reply_t_handler_json
826 (vl_api_create_subif_reply_t * mp)
828 vat_main_t *vam = &vat_main;
829 vat_json_node_t node;
831 vat_json_init_object (&node);
832 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
833 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
835 vat_json_print (vam->ofp, &node);
836 vat_json_free (&node);
838 vam->retval = ntohl (mp->retval);
839 vam->result_ready = 1;
842 static void vl_api_interface_name_renumber_reply_t_handler
843 (vl_api_interface_name_renumber_reply_t * mp)
845 vat_main_t *vam = &vat_main;
846 i32 retval = ntohl (mp->retval);
848 vam->retval = retval;
849 vam->regenerate_interface_table = 1;
850 vam->result_ready = 1;
853 static void vl_api_interface_name_renumber_reply_t_handler_json
854 (vl_api_interface_name_renumber_reply_t * mp)
856 vat_main_t *vam = &vat_main;
857 vat_json_node_t node;
859 vat_json_init_object (&node);
860 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
862 vat_json_print (vam->ofp, &node);
863 vat_json_free (&node);
865 vam->retval = ntohl (mp->retval);
866 vam->result_ready = 1;
870 * Special-case: build the interface table, maintain
871 * the next loopback sw_if_index vbl.
873 static void vl_api_sw_interface_details_t_handler
874 (vl_api_sw_interface_details_t * mp)
876 vat_main_t *vam = &vat_main;
877 u8 *s = format (0, "%s%c", mp->interface_name, 0);
879 hash_set_mem (vam->sw_if_index_by_interface_name, s,
880 ntohl (mp->sw_if_index));
882 /* In sub interface case, fill the sub interface table entry */
883 if (mp->sw_if_index != mp->sup_sw_if_index)
885 sw_interface_subif_t *sub = NULL;
887 vec_add2 (vam->sw_if_subif_table, sub, 1);
889 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
890 strncpy ((char *) sub->interface_name, (char *) s,
891 vec_len (sub->interface_name));
892 sub->sw_if_index = ntohl (mp->sw_if_index);
893 sub->sub_id = ntohl (mp->sub_id);
895 sub->sub_dot1ad = mp->sub_dot1ad;
896 sub->sub_number_of_tags = mp->sub_number_of_tags;
897 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
898 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
899 sub->sub_exact_match = mp->sub_exact_match;
900 sub->sub_default = mp->sub_default;
901 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
902 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
904 /* vlan tag rewrite */
905 sub->vtr_op = ntohl (mp->vtr_op);
906 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
907 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
908 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
912 static void vl_api_sw_interface_details_t_handler_json
913 (vl_api_sw_interface_details_t * mp)
915 vat_main_t *vam = &vat_main;
916 vat_json_node_t *node = NULL;
918 if (VAT_JSON_ARRAY != vam->json_tree.type)
920 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
921 vat_json_init_array (&vam->json_tree);
923 node = vat_json_array_add (&vam->json_tree);
925 vat_json_init_object (node);
926 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
927 vat_json_object_add_uint (node, "sup_sw_if_index",
928 ntohl (mp->sup_sw_if_index));
929 vat_json_object_add_uint (node, "l2_address_length",
930 ntohl (mp->l2_address_length));
931 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
932 sizeof (mp->l2_address));
933 vat_json_object_add_string_copy (node, "interface_name",
935 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
936 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
937 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
938 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
939 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
940 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
941 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
942 vat_json_object_add_uint (node, "sub_number_of_tags",
943 mp->sub_number_of_tags);
944 vat_json_object_add_uint (node, "sub_outer_vlan_id",
945 ntohs (mp->sub_outer_vlan_id));
946 vat_json_object_add_uint (node, "sub_inner_vlan_id",
947 ntohs (mp->sub_inner_vlan_id));
948 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
949 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
950 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
951 mp->sub_outer_vlan_id_any);
952 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
953 mp->sub_inner_vlan_id_any);
954 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
955 vat_json_object_add_uint (node, "vtr_push_dot1q",
956 ntohl (mp->vtr_push_dot1q));
957 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
958 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
961 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
963 format_ethernet_address,
965 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
967 format_ethernet_address,
969 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
970 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
974 #if VPP_API_TEST_BUILTIN == 0
975 static void vl_api_sw_interface_set_flags_t_handler
976 (vl_api_sw_interface_set_flags_t * mp)
978 vat_main_t *vam = &vat_main;
979 if (vam->interface_event_display)
980 errmsg ("interface flags: sw_if_index %d %s %s",
981 ntohl (mp->sw_if_index),
982 mp->admin_up_down ? "admin-up" : "admin-down",
983 mp->link_up_down ? "link-up" : "link-down");
987 static void vl_api_sw_interface_set_flags_t_handler_json
988 (vl_api_sw_interface_set_flags_t * mp)
990 /* JSON output not supported */
994 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
996 vat_main_t *vam = &vat_main;
997 i32 retval = ntohl (mp->retval);
999 vam->retval = retval;
1000 vam->shmem_result = (u8 *) mp->reply_in_shmem;
1001 vam->result_ready = 1;
1005 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1007 vat_main_t *vam = &vat_main;
1008 vat_json_node_t node;
1009 api_main_t *am = &api_main;
1013 vat_json_init_object (&node);
1014 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1015 vat_json_object_add_uint (&node, "reply_in_shmem",
1016 ntohl (mp->reply_in_shmem));
1017 /* Toss the shared-memory original... */
1018 pthread_mutex_lock (&am->vlib_rp->mutex);
1019 oldheap = svm_push_data_heap (am->vlib_rp);
1021 reply = (u8 *) (mp->reply_in_shmem);
1024 svm_pop_heap (oldheap);
1025 pthread_mutex_unlock (&am->vlib_rp->mutex);
1027 vat_json_print (vam->ofp, &node);
1028 vat_json_free (&node);
1030 vam->retval = ntohl (mp->retval);
1031 vam->result_ready = 1;
1035 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1037 vat_main_t *vam = &vat_main;
1038 i32 retval = ntohl (mp->retval);
1040 vam->retval = retval;
1041 vam->cmd_reply = mp->reply;
1042 vam->result_ready = 1;
1046 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1048 vat_main_t *vam = &vat_main;
1049 vat_json_node_t node;
1051 vat_json_init_object (&node);
1052 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1053 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1055 vat_json_print (vam->ofp, &node);
1056 vat_json_free (&node);
1058 vam->retval = ntohl (mp->retval);
1059 vam->result_ready = 1;
1062 static void vl_api_classify_add_del_table_reply_t_handler
1063 (vl_api_classify_add_del_table_reply_t * mp)
1065 vat_main_t *vam = &vat_main;
1066 i32 retval = ntohl (mp->retval);
1067 if (vam->async_mode)
1069 vam->async_errors += (retval < 0);
1073 vam->retval = retval;
1075 ((mp->new_table_index != 0xFFFFFFFF) ||
1076 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1077 (mp->match_n_vectors != 0xFFFFFFFF)))
1079 * Note: this is just barely thread-safe, depends on
1080 * the main thread spinning waiting for an answer...
1082 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1083 ntohl (mp->new_table_index),
1084 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1085 vam->result_ready = 1;
1089 static void vl_api_classify_add_del_table_reply_t_handler_json
1090 (vl_api_classify_add_del_table_reply_t * mp)
1092 vat_main_t *vam = &vat_main;
1093 vat_json_node_t node;
1095 vat_json_init_object (&node);
1096 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1097 vat_json_object_add_uint (&node, "new_table_index",
1098 ntohl (mp->new_table_index));
1099 vat_json_object_add_uint (&node, "skip_n_vectors",
1100 ntohl (mp->skip_n_vectors));
1101 vat_json_object_add_uint (&node, "match_n_vectors",
1102 ntohl (mp->match_n_vectors));
1104 vat_json_print (vam->ofp, &node);
1105 vat_json_free (&node);
1107 vam->retval = ntohl (mp->retval);
1108 vam->result_ready = 1;
1111 static void vl_api_get_node_index_reply_t_handler
1112 (vl_api_get_node_index_reply_t * mp)
1114 vat_main_t *vam = &vat_main;
1115 i32 retval = ntohl (mp->retval);
1116 if (vam->async_mode)
1118 vam->async_errors += (retval < 0);
1122 vam->retval = retval;
1124 errmsg ("node index %d", ntohl (mp->node_index));
1125 vam->result_ready = 1;
1129 static void vl_api_get_node_index_reply_t_handler_json
1130 (vl_api_get_node_index_reply_t * mp)
1132 vat_main_t *vam = &vat_main;
1133 vat_json_node_t node;
1135 vat_json_init_object (&node);
1136 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1137 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1139 vat_json_print (vam->ofp, &node);
1140 vat_json_free (&node);
1142 vam->retval = ntohl (mp->retval);
1143 vam->result_ready = 1;
1146 static void vl_api_get_next_index_reply_t_handler
1147 (vl_api_get_next_index_reply_t * mp)
1149 vat_main_t *vam = &vat_main;
1150 i32 retval = ntohl (mp->retval);
1151 if (vam->async_mode)
1153 vam->async_errors += (retval < 0);
1157 vam->retval = retval;
1159 errmsg ("next node index %d", ntohl (mp->next_index));
1160 vam->result_ready = 1;
1164 static void vl_api_get_next_index_reply_t_handler_json
1165 (vl_api_get_next_index_reply_t * mp)
1167 vat_main_t *vam = &vat_main;
1168 vat_json_node_t node;
1170 vat_json_init_object (&node);
1171 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1172 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1174 vat_json_print (vam->ofp, &node);
1175 vat_json_free (&node);
1177 vam->retval = ntohl (mp->retval);
1178 vam->result_ready = 1;
1181 static void vl_api_add_node_next_reply_t_handler
1182 (vl_api_add_node_next_reply_t * mp)
1184 vat_main_t *vam = &vat_main;
1185 i32 retval = ntohl (mp->retval);
1186 if (vam->async_mode)
1188 vam->async_errors += (retval < 0);
1192 vam->retval = retval;
1194 errmsg ("next index %d", ntohl (mp->next_index));
1195 vam->result_ready = 1;
1199 static void vl_api_add_node_next_reply_t_handler_json
1200 (vl_api_add_node_next_reply_t * mp)
1202 vat_main_t *vam = &vat_main;
1203 vat_json_node_t node;
1205 vat_json_init_object (&node);
1206 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1207 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1209 vat_json_print (vam->ofp, &node);
1210 vat_json_free (&node);
1212 vam->retval = ntohl (mp->retval);
1213 vam->result_ready = 1;
1216 static void vl_api_show_version_reply_t_handler
1217 (vl_api_show_version_reply_t * mp)
1219 vat_main_t *vam = &vat_main;
1220 i32 retval = ntohl (mp->retval);
1224 errmsg (" program: %s", mp->program);
1225 errmsg (" version: %s", mp->version);
1226 errmsg (" build date: %s", mp->build_date);
1227 errmsg ("build directory: %s", mp->build_directory);
1229 vam->retval = retval;
1230 vam->result_ready = 1;
1233 static void vl_api_show_version_reply_t_handler_json
1234 (vl_api_show_version_reply_t * mp)
1236 vat_main_t *vam = &vat_main;
1237 vat_json_node_t node;
1239 vat_json_init_object (&node);
1240 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1241 vat_json_object_add_string_copy (&node, "program", mp->program);
1242 vat_json_object_add_string_copy (&node, "version", mp->version);
1243 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1244 vat_json_object_add_string_copy (&node, "build_directory",
1245 mp->build_directory);
1247 vat_json_print (vam->ofp, &node);
1248 vat_json_free (&node);
1250 vam->retval = ntohl (mp->retval);
1251 vam->result_ready = 1;
1255 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1257 u32 sw_if_index = ntohl (mp->sw_if_index);
1258 errmsg ("arp %s event: address %U new mac %U sw_if_index %d",
1259 mp->mac_ip ? "mac/ip binding" : "address resolution",
1260 format_ip4_address, &mp->address,
1261 format_ethernet_address, mp->new_mac, sw_if_index);
1265 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1267 /* JSON output not supported */
1271 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1273 u32 sw_if_index = ntohl (mp->sw_if_index);
1274 errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d",
1275 mp->mac_ip ? "mac/ip binding" : "address resolution",
1276 format_ip6_address, mp->address,
1277 format_ethernet_address, mp->new_mac, sw_if_index);
1281 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1283 /* JSON output not supported */
1287 * Special-case: build the bridge domain table, maintain
1288 * the next bd id vbl.
1290 static void vl_api_bridge_domain_details_t_handler
1291 (vl_api_bridge_domain_details_t * mp)
1293 vat_main_t *vam = &vat_main;
1294 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1296 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1297 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1299 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1300 ntohl (mp->bd_id), mp->learn, mp->forward,
1301 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1304 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG", "Interface Name");
1307 static void vl_api_bridge_domain_details_t_handler_json
1308 (vl_api_bridge_domain_details_t * mp)
1310 vat_main_t *vam = &vat_main;
1311 vat_json_node_t *node, *array = NULL;
1313 if (VAT_JSON_ARRAY != vam->json_tree.type)
1315 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1316 vat_json_init_array (&vam->json_tree);
1318 node = vat_json_array_add (&vam->json_tree);
1320 vat_json_init_object (node);
1321 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1322 vat_json_object_add_uint (node, "flood", mp->flood);
1323 vat_json_object_add_uint (node, "forward", mp->forward);
1324 vat_json_object_add_uint (node, "learn", mp->learn);
1325 vat_json_object_add_uint (node, "bvi_sw_if_index",
1326 ntohl (mp->bvi_sw_if_index));
1327 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1328 array = vat_json_object_add (node, "sw_if");
1329 vat_json_init_array (array);
1333 * Special-case: build the bridge domain sw if table.
1335 static void vl_api_bridge_domain_sw_if_details_t_handler
1336 (vl_api_bridge_domain_sw_if_details_t * mp)
1338 vat_main_t *vam = &vat_main;
1343 sw_if_index = ntohl (mp->sw_if_index);
1345 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1347 if ((u32) p->value[0] == sw_if_index)
1349 sw_if_name = (u8 *)(p->key);
1355 print (vam->ofp, "%7d %3d %s", sw_if_index,
1356 mp->shg, sw_if_name ? (char *) sw_if_name :
1357 "sw_if_index not found!");
1360 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1361 (vl_api_bridge_domain_sw_if_details_t * mp)
1363 vat_main_t *vam = &vat_main;
1364 vat_json_node_t *node = NULL;
1365 uword last_index = 0;
1367 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1368 ASSERT (vec_len (vam->json_tree.array) >= 1);
1369 last_index = vec_len (vam->json_tree.array) - 1;
1370 node = &vam->json_tree.array[last_index];
1371 node = vat_json_object_get_element (node, "sw_if");
1372 ASSERT (NULL != node);
1373 node = vat_json_array_add (node);
1375 vat_json_init_object (node);
1376 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1377 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1378 vat_json_object_add_uint (node, "shg", mp->shg);
1381 static void vl_api_control_ping_reply_t_handler
1382 (vl_api_control_ping_reply_t * mp)
1384 vat_main_t *vam = &vat_main;
1385 i32 retval = ntohl (mp->retval);
1386 if (vam->async_mode)
1388 vam->async_errors += (retval < 0);
1392 vam->retval = retval;
1393 vam->result_ready = 1;
1397 static void vl_api_control_ping_reply_t_handler_json
1398 (vl_api_control_ping_reply_t * mp)
1400 vat_main_t *vam = &vat_main;
1401 i32 retval = ntohl (mp->retval);
1403 if (VAT_JSON_NONE != vam->json_tree.type)
1405 vat_json_print (vam->ofp, &vam->json_tree);
1406 vat_json_free (&vam->json_tree);
1407 vam->json_tree.type = VAT_JSON_NONE;
1412 vat_json_init_array (&vam->json_tree);
1413 vat_json_print (vam->ofp, &vam->json_tree);
1414 vam->json_tree.type = VAT_JSON_NONE;
1417 vam->retval = retval;
1418 vam->result_ready = 1;
1422 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1424 vat_main_t *vam = &vat_main;
1425 i32 retval = ntohl (mp->retval);
1426 if (vam->async_mode)
1428 vam->async_errors += (retval < 0);
1432 vam->retval = retval;
1433 vam->result_ready = 1;
1437 static void vl_api_l2_flags_reply_t_handler_json
1438 (vl_api_l2_flags_reply_t * mp)
1440 vat_main_t *vam = &vat_main;
1441 vat_json_node_t node;
1443 vat_json_init_object (&node);
1444 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1445 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1446 ntohl (mp->resulting_feature_bitmap));
1448 vat_json_print (vam->ofp, &node);
1449 vat_json_free (&node);
1451 vam->retval = ntohl (mp->retval);
1452 vam->result_ready = 1;
1455 static void vl_api_bridge_flags_reply_t_handler
1456 (vl_api_bridge_flags_reply_t * mp)
1458 vat_main_t *vam = &vat_main;
1459 i32 retval = ntohl (mp->retval);
1460 if (vam->async_mode)
1462 vam->async_errors += (retval < 0);
1466 vam->retval = retval;
1467 vam->result_ready = 1;
1471 static void vl_api_bridge_flags_reply_t_handler_json
1472 (vl_api_bridge_flags_reply_t * mp)
1474 vat_main_t *vam = &vat_main;
1475 vat_json_node_t node;
1477 vat_json_init_object (&node);
1478 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1479 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1480 ntohl (mp->resulting_feature_bitmap));
1482 vat_json_print (vam->ofp, &node);
1483 vat_json_free (&node);
1485 vam->retval = ntohl (mp->retval);
1486 vam->result_ready = 1;
1489 static void vl_api_tap_connect_reply_t_handler
1490 (vl_api_tap_connect_reply_t * mp)
1492 vat_main_t *vam = &vat_main;
1493 i32 retval = ntohl (mp->retval);
1494 if (vam->async_mode)
1496 vam->async_errors += (retval < 0);
1500 vam->retval = retval;
1501 vam->sw_if_index = ntohl (mp->sw_if_index);
1502 vam->result_ready = 1;
1507 static void vl_api_tap_connect_reply_t_handler_json
1508 (vl_api_tap_connect_reply_t * mp)
1510 vat_main_t *vam = &vat_main;
1511 vat_json_node_t node;
1513 vat_json_init_object (&node);
1514 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1515 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1517 vat_json_print (vam->ofp, &node);
1518 vat_json_free (&node);
1520 vam->retval = ntohl (mp->retval);
1521 vam->result_ready = 1;
1526 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1528 vat_main_t *vam = &vat_main;
1529 i32 retval = ntohl (mp->retval);
1530 if (vam->async_mode)
1532 vam->async_errors += (retval < 0);
1536 vam->retval = retval;
1537 vam->sw_if_index = ntohl (mp->sw_if_index);
1538 vam->result_ready = 1;
1542 static void vl_api_tap_modify_reply_t_handler_json
1543 (vl_api_tap_modify_reply_t * mp)
1545 vat_main_t *vam = &vat_main;
1546 vat_json_node_t node;
1548 vat_json_init_object (&node);
1549 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1550 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1552 vat_json_print (vam->ofp, &node);
1553 vat_json_free (&node);
1555 vam->retval = ntohl (mp->retval);
1556 vam->result_ready = 1;
1560 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1562 vat_main_t *vam = &vat_main;
1563 i32 retval = ntohl (mp->retval);
1564 if (vam->async_mode)
1566 vam->async_errors += (retval < 0);
1570 vam->retval = retval;
1571 vam->result_ready = 1;
1575 static void vl_api_tap_delete_reply_t_handler_json
1576 (vl_api_tap_delete_reply_t * mp)
1578 vat_main_t *vam = &vat_main;
1579 vat_json_node_t node;
1581 vat_json_init_object (&node);
1582 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1584 vat_json_print (vam->ofp, &node);
1585 vat_json_free (&node);
1587 vam->retval = ntohl (mp->retval);
1588 vam->result_ready = 1;
1591 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1592 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1594 vat_main_t *vam = &vat_main;
1595 i32 retval = ntohl (mp->retval);
1596 if (vam->async_mode)
1598 vam->async_errors += (retval < 0);
1602 vam->retval = retval;
1603 vam->result_ready = 1;
1607 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1608 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1610 vat_main_t *vam = &vat_main;
1611 vat_json_node_t node;
1613 vat_json_init_object (&node);
1614 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1615 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1616 ntohl (mp->sw_if_index));
1618 vat_json_print (vam->ofp, &node);
1619 vat_json_free (&node);
1621 vam->retval = ntohl (mp->retval);
1622 vam->result_ready = 1;
1625 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1626 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1628 vat_main_t *vam = &vat_main;
1629 i32 retval = ntohl (mp->retval);
1630 if (vam->async_mode)
1632 vam->async_errors += (retval < 0);
1636 vam->retval = retval;
1637 vam->sw_if_index = ntohl (mp->sw_if_index);
1638 vam->result_ready = 1;
1642 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1643 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1645 vat_main_t *vam = &vat_main;
1646 vat_json_node_t node;
1648 vat_json_init_object (&node);
1649 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1650 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1652 vat_json_print (vam->ofp, &node);
1653 vat_json_free (&node);
1655 vam->retval = ntohl (mp->retval);
1656 vam->result_ready = 1;
1660 static void vl_api_one_add_del_locator_set_reply_t_handler
1661 (vl_api_one_add_del_locator_set_reply_t * mp)
1663 vat_main_t *vam = &vat_main;
1664 i32 retval = ntohl (mp->retval);
1665 if (vam->async_mode)
1667 vam->async_errors += (retval < 0);
1671 vam->retval = retval;
1672 vam->result_ready = 1;
1676 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1677 (vl_api_one_add_del_locator_set_reply_t * mp)
1679 vat_main_t *vam = &vat_main;
1680 vat_json_node_t node;
1682 vat_json_init_object (&node);
1683 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1684 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1686 vat_json_print (vam->ofp, &node);
1687 vat_json_free (&node);
1689 vam->retval = ntohl (mp->retval);
1690 vam->result_ready = 1;
1693 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1694 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1696 vat_main_t *vam = &vat_main;
1697 i32 retval = ntohl (mp->retval);
1698 if (vam->async_mode)
1700 vam->async_errors += (retval < 0);
1704 vam->retval = retval;
1705 vam->sw_if_index = ntohl (mp->sw_if_index);
1706 vam->result_ready = 1;
1710 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1711 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1713 vat_main_t *vam = &vat_main;
1714 vat_json_node_t node;
1716 vat_json_init_object (&node);
1717 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1718 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1720 vat_json_print (vam->ofp, &node);
1721 vat_json_free (&node);
1723 vam->retval = ntohl (mp->retval);
1724 vam->result_ready = 1;
1727 static void vl_api_gre_add_del_tunnel_reply_t_handler
1728 (vl_api_gre_add_del_tunnel_reply_t * mp)
1730 vat_main_t *vam = &vat_main;
1731 i32 retval = ntohl (mp->retval);
1732 if (vam->async_mode)
1734 vam->async_errors += (retval < 0);
1738 vam->retval = retval;
1739 vam->sw_if_index = ntohl (mp->sw_if_index);
1740 vam->result_ready = 1;
1744 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1745 (vl_api_gre_add_del_tunnel_reply_t * mp)
1747 vat_main_t *vam = &vat_main;
1748 vat_json_node_t node;
1750 vat_json_init_object (&node);
1751 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1752 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1754 vat_json_print (vam->ofp, &node);
1755 vat_json_free (&node);
1757 vam->retval = ntohl (mp->retval);
1758 vam->result_ready = 1;
1761 static void vl_api_create_vhost_user_if_reply_t_handler
1762 (vl_api_create_vhost_user_if_reply_t * mp)
1764 vat_main_t *vam = &vat_main;
1765 i32 retval = ntohl (mp->retval);
1766 if (vam->async_mode)
1768 vam->async_errors += (retval < 0);
1772 vam->retval = retval;
1773 vam->sw_if_index = ntohl (mp->sw_if_index);
1774 vam->result_ready = 1;
1778 static void vl_api_create_vhost_user_if_reply_t_handler_json
1779 (vl_api_create_vhost_user_if_reply_t * mp)
1781 vat_main_t *vam = &vat_main;
1782 vat_json_node_t node;
1784 vat_json_init_object (&node);
1785 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1786 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1788 vat_json_print (vam->ofp, &node);
1789 vat_json_free (&node);
1791 vam->retval = ntohl (mp->retval);
1792 vam->result_ready = 1;
1795 static void vl_api_ip_address_details_t_handler
1796 (vl_api_ip_address_details_t * mp)
1798 vat_main_t *vam = &vat_main;
1799 static ip_address_details_t empty_ip_address_details = { {0} };
1800 ip_address_details_t *address = NULL;
1801 ip_details_t *current_ip_details = NULL;
1802 ip_details_t *details = NULL;
1804 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1806 if (!details || vam->current_sw_if_index >= vec_len (details)
1807 || !details[vam->current_sw_if_index].present)
1809 errmsg ("ip address details arrived but not stored");
1810 errmsg ("ip_dump should be called first");
1814 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1816 #define addresses (current_ip_details->addr)
1818 vec_validate_init_empty (addresses, vec_len (addresses),
1819 empty_ip_address_details);
1821 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1823 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1824 address->prefix_length = mp->prefix_length;
1828 static void vl_api_ip_address_details_t_handler_json
1829 (vl_api_ip_address_details_t * mp)
1831 vat_main_t *vam = &vat_main;
1832 vat_json_node_t *node = NULL;
1833 struct in6_addr ip6;
1836 if (VAT_JSON_ARRAY != vam->json_tree.type)
1838 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1839 vat_json_init_array (&vam->json_tree);
1841 node = vat_json_array_add (&vam->json_tree);
1843 vat_json_init_object (node);
1846 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1847 vat_json_object_add_ip6 (node, "ip", ip6);
1851 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1852 vat_json_object_add_ip4 (node, "ip", ip4);
1854 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1858 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1860 vat_main_t *vam = &vat_main;
1861 static ip_details_t empty_ip_details = { 0 };
1862 ip_details_t *ip = NULL;
1863 u32 sw_if_index = ~0;
1865 sw_if_index = ntohl (mp->sw_if_index);
1867 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1868 sw_if_index, empty_ip_details);
1870 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1877 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1879 vat_main_t *vam = &vat_main;
1881 if (VAT_JSON_ARRAY != vam->json_tree.type)
1883 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1884 vat_json_init_array (&vam->json_tree);
1886 vat_json_array_add_uint (&vam->json_tree,
1887 clib_net_to_host_u32 (mp->sw_if_index));
1890 static void vl_api_map_domain_details_t_handler_json
1891 (vl_api_map_domain_details_t * mp)
1893 vat_json_node_t *node = NULL;
1894 vat_main_t *vam = &vat_main;
1895 struct in6_addr ip6;
1898 if (VAT_JSON_ARRAY != vam->json_tree.type)
1900 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1901 vat_json_init_array (&vam->json_tree);
1904 node = vat_json_array_add (&vam->json_tree);
1905 vat_json_init_object (node);
1907 vat_json_object_add_uint (node, "domain_index",
1908 clib_net_to_host_u32 (mp->domain_index));
1909 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1910 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1911 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1912 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1913 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1914 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1915 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1916 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1917 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1918 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1919 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1920 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1921 vat_json_object_add_uint (node, "flags", mp->flags);
1922 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1923 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1926 static void vl_api_map_domain_details_t_handler
1927 (vl_api_map_domain_details_t * mp)
1929 vat_main_t *vam = &vat_main;
1931 if (mp->is_translation)
1934 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
1935 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1936 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1937 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1938 clib_net_to_host_u32 (mp->domain_index));
1943 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
1944 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1945 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1946 format_ip6_address, mp->ip6_src,
1947 clib_net_to_host_u32 (mp->domain_index));
1949 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
1950 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1951 mp->is_translation ? "map-t" : "");
1954 static void vl_api_map_rule_details_t_handler_json
1955 (vl_api_map_rule_details_t * mp)
1957 struct in6_addr ip6;
1958 vat_json_node_t *node = NULL;
1959 vat_main_t *vam = &vat_main;
1961 if (VAT_JSON_ARRAY != vam->json_tree.type)
1963 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1964 vat_json_init_array (&vam->json_tree);
1967 node = vat_json_array_add (&vam->json_tree);
1968 vat_json_init_object (node);
1970 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1971 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1972 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1976 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1978 vat_main_t *vam = &vat_main;
1979 print (vam->ofp, " %d (psid) %U (ip6-dst)",
1980 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1984 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1986 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1987 "router_addr %U host_mac %U",
1988 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1989 format_ip4_address, &mp->host_address,
1990 format_ip4_address, &mp->router_address,
1991 format_ethernet_address, mp->host_mac);
1994 static void vl_api_dhcp_compl_event_t_handler_json
1995 (vl_api_dhcp_compl_event_t * mp)
1997 /* JSON output not supported */
2001 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2004 vat_main_t *vam = &vat_main;
2005 static u64 default_counter = 0;
2007 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2009 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2010 sw_if_index, default_counter);
2011 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2015 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2016 interface_counter_t counter)
2018 vat_main_t *vam = &vat_main;
2019 static interface_counter_t default_counter = { 0, };
2021 vec_validate_init_empty (vam->combined_interface_counters,
2022 vnet_counter_type, NULL);
2023 vec_validate_init_empty (vam->combined_interface_counters
2024 [vnet_counter_type], sw_if_index, default_counter);
2025 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2028 static void vl_api_vnet_interface_counters_t_handler
2029 (vl_api_vnet_interface_counters_t * mp)
2034 static void vl_api_vnet_interface_counters_t_handler_json
2035 (vl_api_vnet_interface_counters_t * mp)
2037 interface_counter_t counter;
2042 u32 first_sw_if_index;
2045 count = ntohl (mp->count);
2046 first_sw_if_index = ntohl (mp->first_sw_if_index);
2048 if (!mp->is_combined)
2050 v_packets = (u64 *) & mp->data;
2051 for (i = 0; i < count; i++)
2054 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2055 set_simple_interface_counter (mp->vnet_counter_type,
2056 first_sw_if_index + i, packets);
2062 v = (vlib_counter_t *) & mp->data;
2063 for (i = 0; i < count; i++)
2066 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2068 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2069 set_combined_interface_counter (mp->vnet_counter_type,
2070 first_sw_if_index + i, counter);
2077 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2079 vat_main_t *vam = &vat_main;
2082 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2084 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2093 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2095 vat_main_t *vam = &vat_main;
2098 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2100 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2108 static void vl_api_vnet_ip4_fib_counters_t_handler
2109 (vl_api_vnet_ip4_fib_counters_t * mp)
2114 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2115 (vl_api_vnet_ip4_fib_counters_t * mp)
2117 vat_main_t *vam = &vat_main;
2118 vl_api_ip4_fib_counter_t *v;
2119 ip4_fib_counter_t *counter;
2126 vrf_id = ntohl (mp->vrf_id);
2127 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2128 if (~0 == vrf_index)
2130 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2131 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2132 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2133 vec_validate (vam->ip4_fib_counters, vrf_index);
2134 vam->ip4_fib_counters[vrf_index] = NULL;
2137 vec_free (vam->ip4_fib_counters[vrf_index]);
2138 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2139 count = ntohl (mp->count);
2140 for (i = 0; i < count; i++)
2142 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2143 counter = &vam->ip4_fib_counters[vrf_index][i];
2144 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2145 counter->address = ip4;
2146 counter->address_length = v->address_length;
2147 counter->packets = clib_net_to_host_u64 (v->packets);
2148 counter->bytes = clib_net_to_host_u64 (v->bytes);
2153 static void vl_api_vnet_ip4_nbr_counters_t_handler
2154 (vl_api_vnet_ip4_nbr_counters_t * mp)
2159 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2160 (vl_api_vnet_ip4_nbr_counters_t * mp)
2162 vat_main_t *vam = &vat_main;
2163 vl_api_ip4_nbr_counter_t *v;
2164 ip4_nbr_counter_t *counter;
2169 sw_if_index = ntohl (mp->sw_if_index);
2170 count = ntohl (mp->count);
2171 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2174 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2176 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2177 for (i = 0; i < count; i++)
2179 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2180 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2181 counter->address.s_addr = v->address;
2182 counter->packets = clib_net_to_host_u64 (v->packets);
2183 counter->bytes = clib_net_to_host_u64 (v->bytes);
2184 counter->linkt = v->link_type;
2189 static void vl_api_vnet_ip6_fib_counters_t_handler
2190 (vl_api_vnet_ip6_fib_counters_t * mp)
2195 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2196 (vl_api_vnet_ip6_fib_counters_t * mp)
2198 vat_main_t *vam = &vat_main;
2199 vl_api_ip6_fib_counter_t *v;
2200 ip6_fib_counter_t *counter;
2201 struct in6_addr ip6;
2207 vrf_id = ntohl (mp->vrf_id);
2208 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2209 if (~0 == vrf_index)
2211 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2212 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2213 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2214 vec_validate (vam->ip6_fib_counters, vrf_index);
2215 vam->ip6_fib_counters[vrf_index] = NULL;
2218 vec_free (vam->ip6_fib_counters[vrf_index]);
2219 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2220 count = ntohl (mp->count);
2221 for (i = 0; i < count; i++)
2223 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2224 counter = &vam->ip6_fib_counters[vrf_index][i];
2225 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2226 counter->address = ip6;
2227 counter->address_length = v->address_length;
2228 counter->packets = clib_net_to_host_u64 (v->packets);
2229 counter->bytes = clib_net_to_host_u64 (v->bytes);
2234 static void vl_api_vnet_ip6_nbr_counters_t_handler
2235 (vl_api_vnet_ip6_nbr_counters_t * mp)
2240 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2241 (vl_api_vnet_ip6_nbr_counters_t * mp)
2243 vat_main_t *vam = &vat_main;
2244 vl_api_ip6_nbr_counter_t *v;
2245 ip6_nbr_counter_t *counter;
2246 struct in6_addr ip6;
2251 sw_if_index = ntohl (mp->sw_if_index);
2252 count = ntohl (mp->count);
2253 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2256 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2258 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2259 for (i = 0; i < count; i++)
2261 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2262 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2263 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2264 counter->address = ip6;
2265 counter->packets = clib_net_to_host_u64 (v->packets);
2266 counter->bytes = clib_net_to_host_u64 (v->bytes);
2271 static void vl_api_get_first_msg_id_reply_t_handler
2272 (vl_api_get_first_msg_id_reply_t * mp)
2274 vat_main_t *vam = &vat_main;
2275 i32 retval = ntohl (mp->retval);
2277 if (vam->async_mode)
2279 vam->async_errors += (retval < 0);
2283 vam->retval = retval;
2284 vam->result_ready = 1;
2288 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2292 static void vl_api_get_first_msg_id_reply_t_handler_json
2293 (vl_api_get_first_msg_id_reply_t * mp)
2295 vat_main_t *vam = &vat_main;
2296 vat_json_node_t node;
2298 vat_json_init_object (&node);
2299 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2300 vat_json_object_add_uint (&node, "first_msg_id",
2301 (uint) ntohs (mp->first_msg_id));
2303 vat_json_print (vam->ofp, &node);
2304 vat_json_free (&node);
2306 vam->retval = ntohl (mp->retval);
2307 vam->result_ready = 1;
2310 static void vl_api_get_node_graph_reply_t_handler
2311 (vl_api_get_node_graph_reply_t * mp)
2313 vat_main_t *vam = &vat_main;
2314 api_main_t *am = &api_main;
2315 i32 retval = ntohl (mp->retval);
2316 u8 *pvt_copy, *reply;
2321 if (vam->async_mode)
2323 vam->async_errors += (retval < 0);
2327 vam->retval = retval;
2328 vam->result_ready = 1;
2331 /* "Should never happen..." */
2335 reply = (u8 *) (mp->reply_in_shmem);
2336 pvt_copy = vec_dup (reply);
2338 /* Toss the shared-memory original... */
2339 pthread_mutex_lock (&am->vlib_rp->mutex);
2340 oldheap = svm_push_data_heap (am->vlib_rp);
2344 svm_pop_heap (oldheap);
2345 pthread_mutex_unlock (&am->vlib_rp->mutex);
2347 if (vam->graph_nodes)
2349 hash_free (vam->graph_node_index_by_name);
2351 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2353 node = vam->graph_nodes[i];
2354 vec_free (node->name);
2355 vec_free (node->next_nodes);
2358 vec_free (vam->graph_nodes);
2361 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2362 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2363 vec_free (pvt_copy);
2365 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2367 node = vam->graph_nodes[i];
2368 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2372 static void vl_api_get_node_graph_reply_t_handler_json
2373 (vl_api_get_node_graph_reply_t * mp)
2375 vat_main_t *vam = &vat_main;
2376 api_main_t *am = &api_main;
2378 vat_json_node_t node;
2381 /* $$$$ make this real? */
2382 vat_json_init_object (&node);
2383 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2384 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2386 reply = (u8 *) (mp->reply_in_shmem);
2388 /* Toss the shared-memory original... */
2389 pthread_mutex_lock (&am->vlib_rp->mutex);
2390 oldheap = svm_push_data_heap (am->vlib_rp);
2394 svm_pop_heap (oldheap);
2395 pthread_mutex_unlock (&am->vlib_rp->mutex);
2397 vat_json_print (vam->ofp, &node);
2398 vat_json_free (&node);
2400 vam->retval = ntohl (mp->retval);
2401 vam->result_ready = 1;
2405 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2407 vat_main_t *vam = &vat_main;
2412 s = format (s, "%=16d%=16d%=16d",
2413 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2417 s = format (s, "%=16U%=16d%=16d",
2418 mp->is_ipv6 ? format_ip6_address :
2420 mp->ip_address, mp->priority, mp->weight);
2423 print (vam->ofp, "%v", s);
2428 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2430 vat_main_t *vam = &vat_main;
2431 vat_json_node_t *node = NULL;
2432 struct in6_addr ip6;
2435 if (VAT_JSON_ARRAY != vam->json_tree.type)
2437 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2438 vat_json_init_array (&vam->json_tree);
2440 node = vat_json_array_add (&vam->json_tree);
2441 vat_json_init_object (node);
2443 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2444 vat_json_object_add_uint (node, "priority", mp->priority);
2445 vat_json_object_add_uint (node, "weight", mp->weight);
2448 vat_json_object_add_uint (node, "sw_if_index",
2449 clib_net_to_host_u32 (mp->sw_if_index));
2454 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2455 vat_json_object_add_ip6 (node, "address", ip6);
2459 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2460 vat_json_object_add_ip4 (node, "address", ip4);
2466 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2469 vat_main_t *vam = &vat_main;
2472 ls_name = format (0, "%s", mp->ls_name);
2474 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2480 vl_api_one_locator_set_details_t_handler_json
2481 (vl_api_one_locator_set_details_t * mp)
2483 vat_main_t *vam = &vat_main;
2484 vat_json_node_t *node = 0;
2487 ls_name = format (0, "%s", mp->ls_name);
2488 vec_add1 (ls_name, 0);
2490 if (VAT_JSON_ARRAY != vam->json_tree.type)
2492 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2493 vat_json_init_array (&vam->json_tree);
2495 node = vat_json_array_add (&vam->json_tree);
2497 vat_json_init_object (node);
2498 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2499 vat_json_object_add_uint (node, "ls_index",
2500 clib_net_to_host_u32 (mp->ls_index));
2505 format_lisp_flat_eid (u8 * s, va_list * args)
2507 u32 type = va_arg (*args, u32);
2508 u8 *eid = va_arg (*args, u8 *);
2509 u32 eid_len = va_arg (*args, u32);
2514 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2516 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2518 return format (s, "%U", format_ethernet_address, eid);
2524 format_lisp_eid_vat (u8 * s, va_list * args)
2526 u32 type = va_arg (*args, u32);
2527 u8 *eid = va_arg (*args, u8 *);
2528 u32 eid_len = va_arg (*args, u32);
2529 u8 *seid = va_arg (*args, u8 *);
2530 u32 seid_len = va_arg (*args, u32);
2531 u32 is_src_dst = va_arg (*args, u32);
2534 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2536 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2542 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2544 vat_main_t *vam = &vat_main;
2545 u8 *s = 0, *eid = 0;
2547 if (~0 == mp->locator_set_index)
2548 s = format (0, "action: %d", mp->action);
2550 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2552 eid = format (0, "%U", format_lisp_eid_vat,
2556 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2559 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2560 clib_net_to_host_u32 (mp->vni),
2562 mp->is_local ? "local" : "remote",
2563 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2564 clib_net_to_host_u16 (mp->key_id), mp->key);
2571 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2574 vat_main_t *vam = &vat_main;
2575 vat_json_node_t *node = 0;
2578 if (VAT_JSON_ARRAY != vam->json_tree.type)
2580 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2581 vat_json_init_array (&vam->json_tree);
2583 node = vat_json_array_add (&vam->json_tree);
2585 vat_json_init_object (node);
2586 if (~0 == mp->locator_set_index)
2587 vat_json_object_add_uint (node, "action", mp->action);
2589 vat_json_object_add_uint (node, "locator_set_index",
2590 clib_net_to_host_u32 (mp->locator_set_index));
2592 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2593 eid = format (0, "%U", format_lisp_eid_vat,
2597 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2599 vat_json_object_add_string_copy (node, "eid", eid);
2600 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2601 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2602 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2606 vat_json_object_add_uint (node, "key_id",
2607 clib_net_to_host_u16 (mp->key_id));
2608 vat_json_object_add_string_copy (node, "key", mp->key);
2614 vl_api_one_eid_table_map_details_t_handler
2615 (vl_api_one_eid_table_map_details_t * mp)
2617 vat_main_t *vam = &vat_main;
2619 u8 *line = format (0, "%=10d%=10d",
2620 clib_net_to_host_u32 (mp->vni),
2621 clib_net_to_host_u32 (mp->dp_table));
2622 print (vam->ofp, "%v", line);
2627 vl_api_one_eid_table_map_details_t_handler_json
2628 (vl_api_one_eid_table_map_details_t * mp)
2630 vat_main_t *vam = &vat_main;
2631 vat_json_node_t *node = NULL;
2633 if (VAT_JSON_ARRAY != vam->json_tree.type)
2635 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2636 vat_json_init_array (&vam->json_tree);
2638 node = vat_json_array_add (&vam->json_tree);
2639 vat_json_init_object (node);
2640 vat_json_object_add_uint (node, "dp_table",
2641 clib_net_to_host_u32 (mp->dp_table));
2642 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2646 vl_api_one_eid_table_vni_details_t_handler
2647 (vl_api_one_eid_table_vni_details_t * mp)
2649 vat_main_t *vam = &vat_main;
2651 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2652 print (vam->ofp, "%v", line);
2657 vl_api_one_eid_table_vni_details_t_handler_json
2658 (vl_api_one_eid_table_vni_details_t * mp)
2660 vat_main_t *vam = &vat_main;
2661 vat_json_node_t *node = NULL;
2663 if (VAT_JSON_ARRAY != vam->json_tree.type)
2665 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2666 vat_json_init_array (&vam->json_tree);
2668 node = vat_json_array_add (&vam->json_tree);
2669 vat_json_init_object (node);
2670 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2674 vl_api_show_one_map_register_state_reply_t_handler
2675 (vl_api_show_one_map_register_state_reply_t * mp)
2677 vat_main_t *vam = &vat_main;
2678 int retval = clib_net_to_host_u32 (mp->retval);
2680 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2682 vam->retval = retval;
2683 vam->result_ready = 1;
2687 vl_api_show_one_map_register_state_reply_t_handler_json
2688 (vl_api_show_one_map_register_state_reply_t * mp)
2690 vat_main_t *vam = &vat_main;
2691 vat_json_node_t _node, *node = &_node;
2692 int retval = clib_net_to_host_u32 (mp->retval);
2694 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2696 vat_json_init_object (node);
2697 vat_json_object_add_string_copy (node, "state", s);
2699 vat_json_print (vam->ofp, node);
2700 vat_json_free (node);
2702 vam->retval = retval;
2703 vam->result_ready = 1;
2708 vl_api_show_one_rloc_probe_state_reply_t_handler
2709 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2711 vat_main_t *vam = &vat_main;
2712 int retval = clib_net_to_host_u32 (mp->retval);
2717 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2719 vam->retval = retval;
2720 vam->result_ready = 1;
2724 vl_api_show_one_rloc_probe_state_reply_t_handler_json
2725 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2727 vat_main_t *vam = &vat_main;
2728 vat_json_node_t _node, *node = &_node;
2729 int retval = clib_net_to_host_u32 (mp->retval);
2731 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2732 vat_json_init_object (node);
2733 vat_json_object_add_string_copy (node, "state", s);
2735 vat_json_print (vam->ofp, node);
2736 vat_json_free (node);
2738 vam->retval = retval;
2739 vam->result_ready = 1;
2744 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
2746 e->dp_table = clib_net_to_host_u32 (e->dp_table);
2747 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
2751 gpe_fwd_entries_get_reply_t_net_to_host
2752 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2756 mp->count = clib_net_to_host_u32 (mp->count);
2757 for (i = 0; i < mp->count; i++)
2759 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
2764 format_gpe_encap_mode (u8 * s, va_list * args)
2766 u32 mode = va_arg (*args, u32);
2771 return format (s, "lisp");
2773 return format (s, "vxlan");
2779 vl_api_gpe_get_encap_mode_reply_t_handler
2780 (vl_api_gpe_get_encap_mode_reply_t * mp)
2782 vat_main_t *vam = &vat_main;
2784 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
2785 vam->retval = ntohl (mp->retval);
2786 vam->result_ready = 1;
2790 vl_api_gpe_get_encap_mode_reply_t_handler_json
2791 (vl_api_gpe_get_encap_mode_reply_t * mp)
2793 vat_main_t *vam = &vat_main;
2794 vat_json_node_t node;
2796 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
2797 vec_add1 (encap_mode, 0);
2799 vat_json_init_object (&node);
2800 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
2802 vec_free (encap_mode);
2803 vat_json_print (vam->ofp, &node);
2804 vat_json_free (&node);
2806 vam->retval = ntohl (mp->retval);
2807 vam->result_ready = 1;
2811 vl_api_gpe_fwd_entry_path_details_t_handler
2812 (vl_api_gpe_fwd_entry_path_details_t * mp)
2814 vat_main_t *vam = &vat_main;
2815 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2817 if (mp->lcl_loc.is_ip4)
2818 format_ip_address_fcn = format_ip4_address;
2820 format_ip_address_fcn = format_ip6_address;
2822 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
2823 format_ip_address_fcn, &mp->lcl_loc,
2824 format_ip_address_fcn, &mp->rmt_loc);
2828 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
2830 struct in6_addr ip6;
2835 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
2836 vat_json_object_add_ip4 (n, "address", ip4);
2840 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
2841 vat_json_object_add_ip6 (n, "address", ip6);
2843 vat_json_object_add_uint (n, "weight", loc->weight);
2847 vl_api_gpe_fwd_entry_path_details_t_handler_json
2848 (vl_api_gpe_fwd_entry_path_details_t * mp)
2850 vat_main_t *vam = &vat_main;
2851 vat_json_node_t *node = NULL;
2852 vat_json_node_t *loc_node;
2854 if (VAT_JSON_ARRAY != vam->json_tree.type)
2856 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2857 vat_json_init_array (&vam->json_tree);
2859 node = vat_json_array_add (&vam->json_tree);
2860 vat_json_init_object (node);
2862 loc_node = vat_json_object_add (node, "local_locator");
2863 vat_json_init_object (loc_node);
2864 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
2866 loc_node = vat_json_object_add (node, "remote_locator");
2867 vat_json_init_object (loc_node);
2868 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
2872 vl_api_gpe_fwd_entries_get_reply_t_handler
2873 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2875 vat_main_t *vam = &vat_main;
2877 int retval = clib_net_to_host_u32 (mp->retval);
2878 vl_api_gpe_fwd_entry_t *e;
2883 gpe_fwd_entries_get_reply_t_net_to_host (mp);
2885 for (i = 0; i < mp->count; i++)
2887 e = &mp->entries[i];
2888 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
2889 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
2890 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
2894 vam->retval = retval;
2895 vam->result_ready = 1;
2899 vl_api_gpe_fwd_entries_get_reply_t_handler_json
2900 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2903 vat_main_t *vam = &vat_main;
2904 vat_json_node_t *e = 0, root;
2906 int retval = clib_net_to_host_u32 (mp->retval);
2907 vl_api_gpe_fwd_entry_t *fwd;
2912 gpe_fwd_entries_get_reply_t_net_to_host (mp);
2913 vat_json_init_array (&root);
2915 for (i = 0; i < mp->count; i++)
2917 e = vat_json_array_add (&root);
2918 fwd = &mp->entries[i];
2920 vat_json_init_object (e);
2921 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
2922 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
2924 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
2925 fwd->leid_prefix_len);
2927 vat_json_object_add_string_copy (e, "leid", s);
2930 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
2931 fwd->reid_prefix_len);
2933 vat_json_object_add_string_copy (e, "reid", s);
2937 vat_json_print (vam->ofp, &root);
2938 vat_json_free (&root);
2941 vam->retval = retval;
2942 vam->result_ready = 1;
2946 vl_api_one_adjacencies_get_reply_t_handler
2947 (vl_api_one_adjacencies_get_reply_t * mp)
2949 vat_main_t *vam = &vat_main;
2951 int retval = clib_net_to_host_u32 (mp->retval);
2952 vl_api_one_adjacency_t *a;
2957 n = clib_net_to_host_u32 (mp->count);
2959 for (i = 0; i < n; i++)
2961 a = &mp->adjacencies[i];
2962 print (vam->ofp, "%U %40U",
2963 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2964 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
2968 vam->retval = retval;
2969 vam->result_ready = 1;
2973 vl_api_one_adjacencies_get_reply_t_handler_json
2974 (vl_api_one_adjacencies_get_reply_t * mp)
2977 vat_main_t *vam = &vat_main;
2978 vat_json_node_t *e = 0, root;
2980 int retval = clib_net_to_host_u32 (mp->retval);
2981 vl_api_one_adjacency_t *a;
2986 n = clib_net_to_host_u32 (mp->count);
2987 vat_json_init_array (&root);
2989 for (i = 0; i < n; i++)
2991 e = vat_json_array_add (&root);
2992 a = &mp->adjacencies[i];
2994 vat_json_init_object (e);
2995 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
2996 a->leid_prefix_len);
2998 vat_json_object_add_string_copy (e, "leid", s);
3001 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3002 a->reid_prefix_len);
3004 vat_json_object_add_string_copy (e, "reid", s);
3008 vat_json_print (vam->ofp, &root);
3009 vat_json_free (&root);
3012 vam->retval = retval;
3013 vam->result_ready = 1;
3017 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3019 vat_main_t *vam = &vat_main;
3021 print (vam->ofp, "%=20U",
3022 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3027 vl_api_one_map_server_details_t_handler_json
3028 (vl_api_one_map_server_details_t * mp)
3030 vat_main_t *vam = &vat_main;
3031 vat_json_node_t *node = NULL;
3032 struct in6_addr ip6;
3035 if (VAT_JSON_ARRAY != vam->json_tree.type)
3037 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3038 vat_json_init_array (&vam->json_tree);
3040 node = vat_json_array_add (&vam->json_tree);
3042 vat_json_init_object (node);
3045 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3046 vat_json_object_add_ip6 (node, "map-server", ip6);
3050 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3051 vat_json_object_add_ip4 (node, "map-server", ip4);
3056 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3059 vat_main_t *vam = &vat_main;
3061 print (vam->ofp, "%=20U",
3062 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3067 vl_api_one_map_resolver_details_t_handler_json
3068 (vl_api_one_map_resolver_details_t * mp)
3070 vat_main_t *vam = &vat_main;
3071 vat_json_node_t *node = NULL;
3072 struct in6_addr ip6;
3075 if (VAT_JSON_ARRAY != vam->json_tree.type)
3077 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3078 vat_json_init_array (&vam->json_tree);
3080 node = vat_json_array_add (&vam->json_tree);
3082 vat_json_init_object (node);
3085 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3086 vat_json_object_add_ip6 (node, "map resolver", ip6);
3090 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3091 vat_json_object_add_ip4 (node, "map resolver", ip4);
3096 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3098 vat_main_t *vam = &vat_main;
3099 i32 retval = ntohl (mp->retval);
3103 print (vam->ofp, "feature: %s\ngpe: %s",
3104 mp->feature_status ? "enabled" : "disabled",
3105 mp->gpe_status ? "enabled" : "disabled");
3108 vam->retval = retval;
3109 vam->result_ready = 1;
3113 vl_api_show_one_status_reply_t_handler_json
3114 (vl_api_show_one_status_reply_t * mp)
3116 vat_main_t *vam = &vat_main;
3117 vat_json_node_t node;
3118 u8 *gpe_status = NULL;
3119 u8 *feature_status = NULL;
3121 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3122 feature_status = format (0, "%s",
3123 mp->feature_status ? "enabled" : "disabled");
3124 vec_add1 (gpe_status, 0);
3125 vec_add1 (feature_status, 0);
3127 vat_json_init_object (&node);
3128 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3129 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3131 vec_free (gpe_status);
3132 vec_free (feature_status);
3134 vat_json_print (vam->ofp, &node);
3135 vat_json_free (&node);
3137 vam->retval = ntohl (mp->retval);
3138 vam->result_ready = 1;
3142 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3143 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3145 vat_main_t *vam = &vat_main;
3146 i32 retval = ntohl (mp->retval);
3150 print (vam->ofp, "%=20s", mp->locator_set_name);
3153 vam->retval = retval;
3154 vam->result_ready = 1;
3158 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3159 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3161 vat_main_t *vam = &vat_main;
3162 vat_json_node_t *node = NULL;
3164 if (VAT_JSON_ARRAY != vam->json_tree.type)
3166 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3167 vat_json_init_array (&vam->json_tree);
3169 node = vat_json_array_add (&vam->json_tree);
3171 vat_json_init_object (node);
3172 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3174 vat_json_print (vam->ofp, node);
3175 vat_json_free (node);
3177 vam->retval = ntohl (mp->retval);
3178 vam->result_ready = 1;
3182 format_lisp_map_request_mode (u8 * s, va_list * args)
3184 u32 mode = va_arg (*args, u32);
3189 return format (0, "dst-only");
3191 return format (0, "src-dst");
3197 vl_api_show_one_map_request_mode_reply_t_handler
3198 (vl_api_show_one_map_request_mode_reply_t * mp)
3200 vat_main_t *vam = &vat_main;
3201 i32 retval = ntohl (mp->retval);
3205 u32 mode = mp->mode;
3206 print (vam->ofp, "map_request_mode: %U",
3207 format_lisp_map_request_mode, mode);
3210 vam->retval = retval;
3211 vam->result_ready = 1;
3215 vl_api_show_one_map_request_mode_reply_t_handler_json
3216 (vl_api_show_one_map_request_mode_reply_t * mp)
3218 vat_main_t *vam = &vat_main;
3219 vat_json_node_t node;
3224 s = format (0, "%U", format_lisp_map_request_mode, mode);
3227 vat_json_init_object (&node);
3228 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3229 vat_json_print (vam->ofp, &node);
3230 vat_json_free (&node);
3233 vam->retval = ntohl (mp->retval);
3234 vam->result_ready = 1;
3238 vl_api_show_one_use_petr_reply_t_handler
3239 (vl_api_show_one_use_petr_reply_t * mp)
3241 vat_main_t *vam = &vat_main;
3242 i32 retval = ntohl (mp->retval);
3246 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
3249 print (vam->ofp, "Proxy-ETR address; %U",
3250 mp->is_ip4 ? format_ip4_address : format_ip6_address,
3255 vam->retval = retval;
3256 vam->result_ready = 1;
3260 vl_api_show_one_use_petr_reply_t_handler_json
3261 (vl_api_show_one_use_petr_reply_t * mp)
3263 vat_main_t *vam = &vat_main;
3264 vat_json_node_t node;
3267 struct in6_addr ip6;
3269 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3270 vec_add1 (status, 0);
3272 vat_json_init_object (&node);
3273 vat_json_object_add_string_copy (&node, "status", status);
3278 clib_memcpy (&ip6, mp->address, sizeof (ip6));
3279 vat_json_object_add_ip6 (&node, "address", ip6);
3283 clib_memcpy (&ip4, mp->address, sizeof (ip4));
3284 vat_json_object_add_ip4 (&node, "address", ip4);
3290 vat_json_print (vam->ofp, &node);
3291 vat_json_free (&node);
3293 vam->retval = ntohl (mp->retval);
3294 vam->result_ready = 1;
3298 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3300 vat_main_t *vam = &vat_main;
3301 i32 retval = ntohl (mp->retval);
3305 print (vam->ofp, "%-20s%-16s",
3306 mp->status ? "enabled" : "disabled",
3307 mp->status ? (char *) mp->locator_set_name : "");
3310 vam->retval = retval;
3311 vam->result_ready = 1;
3315 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3317 vat_main_t *vam = &vat_main;
3318 vat_json_node_t node;
3321 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3322 vec_add1 (status, 0);
3324 vat_json_init_object (&node);
3325 vat_json_object_add_string_copy (&node, "status", status);
3328 vat_json_object_add_string_copy (&node, "locator_set",
3329 mp->locator_set_name);
3334 vat_json_print (vam->ofp, &node);
3335 vat_json_free (&node);
3337 vam->retval = ntohl (mp->retval);
3338 vam->result_ready = 1;
3342 format_policer_type (u8 * s, va_list * va)
3344 u32 i = va_arg (*va, u32);
3346 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3347 s = format (s, "1r2c");
3348 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3349 s = format (s, "1r3c");
3350 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3351 s = format (s, "2r3c-2698");
3352 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3353 s = format (s, "2r3c-4115");
3354 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3355 s = format (s, "2r3c-mef5cf1");
3357 s = format (s, "ILLEGAL");
3362 format_policer_rate_type (u8 * s, va_list * va)
3364 u32 i = va_arg (*va, u32);
3366 if (i == SSE2_QOS_RATE_KBPS)
3367 s = format (s, "kbps");
3368 else if (i == SSE2_QOS_RATE_PPS)
3369 s = format (s, "pps");
3371 s = format (s, "ILLEGAL");
3376 format_policer_round_type (u8 * s, va_list * va)
3378 u32 i = va_arg (*va, u32);
3380 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3381 s = format (s, "closest");
3382 else if (i == SSE2_QOS_ROUND_TO_UP)
3383 s = format (s, "up");
3384 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3385 s = format (s, "down");
3387 s = format (s, "ILLEGAL");
3392 format_policer_action_type (u8 * s, va_list * va)
3394 u32 i = va_arg (*va, u32);
3396 if (i == SSE2_QOS_ACTION_DROP)
3397 s = format (s, "drop");
3398 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3399 s = format (s, "transmit");
3400 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3401 s = format (s, "mark-and-transmit");
3403 s = format (s, "ILLEGAL");
3408 format_dscp (u8 * s, va_list * va)
3410 u32 i = va_arg (*va, u32);
3415 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3419 return format (s, "ILLEGAL");
3421 s = format (s, "%s", t);
3426 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3428 vat_main_t *vam = &vat_main;
3429 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3431 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3432 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3434 conform_dscp_str = format (0, "");
3436 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3437 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3439 exceed_dscp_str = format (0, "");
3441 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3442 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3444 violate_dscp_str = format (0, "");
3446 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3447 "rate type %U, round type %U, %s rate, %s color-aware, "
3448 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3449 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3450 "conform action %U%s, exceed action %U%s, violate action %U%s",
3452 format_policer_type, mp->type,
3455 clib_net_to_host_u64 (mp->cb),
3456 clib_net_to_host_u64 (mp->eb),
3457 format_policer_rate_type, mp->rate_type,
3458 format_policer_round_type, mp->round_type,
3459 mp->single_rate ? "single" : "dual",
3460 mp->color_aware ? "is" : "not",
3461 ntohl (mp->cir_tokens_per_period),
3462 ntohl (mp->pir_tokens_per_period),
3464 ntohl (mp->current_limit),
3465 ntohl (mp->current_bucket),
3466 ntohl (mp->extended_limit),
3467 ntohl (mp->extended_bucket),
3468 clib_net_to_host_u64 (mp->last_update_time),
3469 format_policer_action_type, mp->conform_action_type,
3471 format_policer_action_type, mp->exceed_action_type,
3473 format_policer_action_type, mp->violate_action_type,
3476 vec_free (conform_dscp_str);
3477 vec_free (exceed_dscp_str);
3478 vec_free (violate_dscp_str);
3481 static void vl_api_policer_details_t_handler_json
3482 (vl_api_policer_details_t * mp)
3484 vat_main_t *vam = &vat_main;
3485 vat_json_node_t *node;
3486 u8 *rate_type_str, *round_type_str, *type_str;
3487 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3489 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3491 format (0, "%U", format_policer_round_type, mp->round_type);
3492 type_str = format (0, "%U", format_policer_type, mp->type);
3493 conform_action_str = format (0, "%U", format_policer_action_type,
3494 mp->conform_action_type);
3495 exceed_action_str = format (0, "%U", format_policer_action_type,
3496 mp->exceed_action_type);
3497 violate_action_str = format (0, "%U", format_policer_action_type,
3498 mp->violate_action_type);
3500 if (VAT_JSON_ARRAY != vam->json_tree.type)
3502 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3503 vat_json_init_array (&vam->json_tree);
3505 node = vat_json_array_add (&vam->json_tree);
3507 vat_json_init_object (node);
3508 vat_json_object_add_string_copy (node, "name", mp->name);
3509 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3510 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3511 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3512 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3513 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3514 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3515 vat_json_object_add_string_copy (node, "type", type_str);
3516 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3517 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3518 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3519 vat_json_object_add_uint (node, "cir_tokens_per_period",
3520 ntohl (mp->cir_tokens_per_period));
3521 vat_json_object_add_uint (node, "eir_tokens_per_period",
3522 ntohl (mp->pir_tokens_per_period));
3523 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3524 vat_json_object_add_uint (node, "current_bucket",
3525 ntohl (mp->current_bucket));
3526 vat_json_object_add_uint (node, "extended_limit",
3527 ntohl (mp->extended_limit));
3528 vat_json_object_add_uint (node, "extended_bucket",
3529 ntohl (mp->extended_bucket));
3530 vat_json_object_add_uint (node, "last_update_time",
3531 ntohl (mp->last_update_time));
3532 vat_json_object_add_string_copy (node, "conform_action",
3533 conform_action_str);
3534 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3536 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3537 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3538 vec_free (dscp_str);
3540 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3541 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3543 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3544 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3545 vec_free (dscp_str);
3547 vat_json_object_add_string_copy (node, "violate_action",
3548 violate_action_str);
3549 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3551 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3552 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3553 vec_free (dscp_str);
3556 vec_free (rate_type_str);
3557 vec_free (round_type_str);
3558 vec_free (type_str);
3559 vec_free (conform_action_str);
3560 vec_free (exceed_action_str);
3561 vec_free (violate_action_str);
3565 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3568 vat_main_t *vam = &vat_main;
3569 int i, count = ntohl (mp->count);
3572 print (vam->ofp, "classify table ids (%d) : ", count);
3573 for (i = 0; i < count; i++)
3575 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3576 print (vam->ofp, (i < count - 1) ? "," : "");
3578 vam->retval = ntohl (mp->retval);
3579 vam->result_ready = 1;
3583 vl_api_classify_table_ids_reply_t_handler_json
3584 (vl_api_classify_table_ids_reply_t * mp)
3586 vat_main_t *vam = &vat_main;
3587 int i, count = ntohl (mp->count);
3591 vat_json_node_t node;
3593 vat_json_init_object (&node);
3594 for (i = 0; i < count; i++)
3596 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3598 vat_json_print (vam->ofp, &node);
3599 vat_json_free (&node);
3601 vam->retval = ntohl (mp->retval);
3602 vam->result_ready = 1;
3606 vl_api_classify_table_by_interface_reply_t_handler
3607 (vl_api_classify_table_by_interface_reply_t * mp)
3609 vat_main_t *vam = &vat_main;
3612 table_id = ntohl (mp->l2_table_id);
3614 print (vam->ofp, "l2 table id : %d", table_id);
3616 print (vam->ofp, "l2 table id : No input ACL tables configured");
3617 table_id = ntohl (mp->ip4_table_id);
3619 print (vam->ofp, "ip4 table id : %d", table_id);
3621 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3622 table_id = ntohl (mp->ip6_table_id);
3624 print (vam->ofp, "ip6 table id : %d", table_id);
3626 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3627 vam->retval = ntohl (mp->retval);
3628 vam->result_ready = 1;
3632 vl_api_classify_table_by_interface_reply_t_handler_json
3633 (vl_api_classify_table_by_interface_reply_t * mp)
3635 vat_main_t *vam = &vat_main;
3636 vat_json_node_t node;
3638 vat_json_init_object (&node);
3640 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3641 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3642 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3644 vat_json_print (vam->ofp, &node);
3645 vat_json_free (&node);
3647 vam->retval = ntohl (mp->retval);
3648 vam->result_ready = 1;
3651 static void vl_api_policer_add_del_reply_t_handler
3652 (vl_api_policer_add_del_reply_t * mp)
3654 vat_main_t *vam = &vat_main;
3655 i32 retval = ntohl (mp->retval);
3656 if (vam->async_mode)
3658 vam->async_errors += (retval < 0);
3662 vam->retval = retval;
3663 vam->result_ready = 1;
3664 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3666 * Note: this is just barely thread-safe, depends on
3667 * the main thread spinning waiting for an answer...
3669 errmsg ("policer index %d", ntohl (mp->policer_index));
3673 static void vl_api_policer_add_del_reply_t_handler_json
3674 (vl_api_policer_add_del_reply_t * mp)
3676 vat_main_t *vam = &vat_main;
3677 vat_json_node_t node;
3679 vat_json_init_object (&node);
3680 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3681 vat_json_object_add_uint (&node, "policer_index",
3682 ntohl (mp->policer_index));
3684 vat_json_print (vam->ofp, &node);
3685 vat_json_free (&node);
3687 vam->retval = ntohl (mp->retval);
3688 vam->result_ready = 1;
3691 /* Format hex dump. */
3693 format_hex_bytes (u8 * s, va_list * va)
3695 u8 *bytes = va_arg (*va, u8 *);
3696 int n_bytes = va_arg (*va, int);
3699 /* Print short or long form depending on byte count. */
3700 uword short_form = n_bytes <= 32;
3701 uword indent = format_get_indent (s);
3706 for (i = 0; i < n_bytes; i++)
3708 if (!short_form && (i % 32) == 0)
3709 s = format (s, "%08x: ", i);
3710 s = format (s, "%02x", bytes[i]);
3711 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3712 s = format (s, "\n%U", format_white_space, indent);
3719 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3722 vat_main_t *vam = &vat_main;
3723 i32 retval = ntohl (mp->retval);
3726 print (vam->ofp, "classify table info :");
3727 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3728 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3729 ntohl (mp->miss_next_index));
3730 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3731 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3732 ntohl (mp->match_n_vectors));
3733 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3734 ntohl (mp->mask_length));
3736 vam->retval = retval;
3737 vam->result_ready = 1;
3741 vl_api_classify_table_info_reply_t_handler_json
3742 (vl_api_classify_table_info_reply_t * mp)
3744 vat_main_t *vam = &vat_main;
3745 vat_json_node_t node;
3747 i32 retval = ntohl (mp->retval);
3750 vat_json_init_object (&node);
3752 vat_json_object_add_int (&node, "sessions",
3753 ntohl (mp->active_sessions));
3754 vat_json_object_add_int (&node, "nexttbl",
3755 ntohl (mp->next_table_index));
3756 vat_json_object_add_int (&node, "nextnode",
3757 ntohl (mp->miss_next_index));
3758 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3759 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3760 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3761 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3762 ntohl (mp->mask_length), 0);
3763 vat_json_object_add_string_copy (&node, "mask", s);
3765 vat_json_print (vam->ofp, &node);
3766 vat_json_free (&node);
3768 vam->retval = ntohl (mp->retval);
3769 vam->result_ready = 1;
3773 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3776 vat_main_t *vam = &vat_main;
3778 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3779 ntohl (mp->hit_next_index), ntohl (mp->advance),
3780 ntohl (mp->opaque_index));
3781 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3782 ntohl (mp->match_length));
3786 vl_api_classify_session_details_t_handler_json
3787 (vl_api_classify_session_details_t * mp)
3789 vat_main_t *vam = &vat_main;
3790 vat_json_node_t *node = NULL;
3792 if (VAT_JSON_ARRAY != vam->json_tree.type)
3794 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3795 vat_json_init_array (&vam->json_tree);
3797 node = vat_json_array_add (&vam->json_tree);
3799 vat_json_init_object (node);
3800 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3801 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3802 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3804 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3806 vat_json_object_add_string_copy (node, "match", s);
3809 static void vl_api_pg_create_interface_reply_t_handler
3810 (vl_api_pg_create_interface_reply_t * mp)
3812 vat_main_t *vam = &vat_main;
3814 vam->retval = ntohl (mp->retval);
3815 vam->result_ready = 1;
3818 static void vl_api_pg_create_interface_reply_t_handler_json
3819 (vl_api_pg_create_interface_reply_t * mp)
3821 vat_main_t *vam = &vat_main;
3822 vat_json_node_t node;
3824 i32 retval = ntohl (mp->retval);
3827 vat_json_init_object (&node);
3829 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3831 vat_json_print (vam->ofp, &node);
3832 vat_json_free (&node);
3834 vam->retval = ntohl (mp->retval);
3835 vam->result_ready = 1;
3838 static void vl_api_policer_classify_details_t_handler
3839 (vl_api_policer_classify_details_t * mp)
3841 vat_main_t *vam = &vat_main;
3843 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3844 ntohl (mp->table_index));
3847 static void vl_api_policer_classify_details_t_handler_json
3848 (vl_api_policer_classify_details_t * mp)
3850 vat_main_t *vam = &vat_main;
3851 vat_json_node_t *node;
3853 if (VAT_JSON_ARRAY != vam->json_tree.type)
3855 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3856 vat_json_init_array (&vam->json_tree);
3858 node = vat_json_array_add (&vam->json_tree);
3860 vat_json_init_object (node);
3861 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3862 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3865 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3866 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3868 vat_main_t *vam = &vat_main;
3869 i32 retval = ntohl (mp->retval);
3870 if (vam->async_mode)
3872 vam->async_errors += (retval < 0);
3876 vam->retval = retval;
3877 vam->sw_if_index = ntohl (mp->sw_if_index);
3878 vam->result_ready = 1;
3882 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3883 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3885 vat_main_t *vam = &vat_main;
3886 vat_json_node_t node;
3888 vat_json_init_object (&node);
3889 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3890 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3892 vat_json_print (vam->ofp, &node);
3893 vat_json_free (&node);
3895 vam->retval = ntohl (mp->retval);
3896 vam->result_ready = 1;
3899 static void vl_api_flow_classify_details_t_handler
3900 (vl_api_flow_classify_details_t * mp)
3902 vat_main_t *vam = &vat_main;
3904 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3905 ntohl (mp->table_index));
3908 static void vl_api_flow_classify_details_t_handler_json
3909 (vl_api_flow_classify_details_t * mp)
3911 vat_main_t *vam = &vat_main;
3912 vat_json_node_t *node;
3914 if (VAT_JSON_ARRAY != vam->json_tree.type)
3916 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3917 vat_json_init_array (&vam->json_tree);
3919 node = vat_json_array_add (&vam->json_tree);
3921 vat_json_init_object (node);
3922 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3923 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3928 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3929 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3930 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3931 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3932 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
3933 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
3934 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
3935 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
3936 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
3937 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
3940 * Generate boilerplate reply handlers, which
3941 * dig the return value out of the xxx_reply_t API message,
3942 * stick it into vam->retval, and set vam->result_ready
3944 * Could also do this by pointing N message decode slots at
3945 * a single function, but that could break in subtle ways.
3948 #define foreach_standard_reply_retval_handler \
3949 _(sw_interface_set_flags_reply) \
3950 _(sw_interface_add_del_address_reply) \
3951 _(sw_interface_set_table_reply) \
3952 _(sw_interface_set_mpls_enable_reply) \
3953 _(sw_interface_set_vpath_reply) \
3954 _(sw_interface_set_vxlan_bypass_reply) \
3955 _(sw_interface_set_l2_bridge_reply) \
3956 _(bridge_domain_add_del_reply) \
3957 _(sw_interface_set_l2_xconnect_reply) \
3958 _(l2fib_add_del_reply) \
3959 _(ip_add_del_route_reply) \
3960 _(ip_mroute_add_del_reply) \
3961 _(mpls_route_add_del_reply) \
3962 _(mpls_ip_bind_unbind_reply) \
3963 _(proxy_arp_add_del_reply) \
3964 _(proxy_arp_intfc_enable_disable_reply) \
3965 _(sw_interface_set_unnumbered_reply) \
3966 _(ip_neighbor_add_del_reply) \
3967 _(reset_vrf_reply) \
3968 _(oam_add_del_reply) \
3969 _(reset_fib_reply) \
3970 _(dhcp_proxy_config_reply) \
3971 _(dhcp_proxy_set_vss_reply) \
3972 _(dhcp_client_config_reply) \
3973 _(set_ip_flow_hash_reply) \
3974 _(sw_interface_ip6_enable_disable_reply) \
3975 _(sw_interface_ip6_set_link_local_address_reply) \
3976 _(ip6nd_proxy_add_del_reply) \
3977 _(sw_interface_ip6nd_ra_prefix_reply) \
3978 _(sw_interface_ip6nd_ra_config_reply) \
3979 _(set_arp_neighbor_limit_reply) \
3980 _(l2_patch_add_del_reply) \
3981 _(sr_policy_add_reply) \
3982 _(sr_policy_mod_reply) \
3983 _(sr_policy_del_reply) \
3984 _(sr_localsid_add_del_reply) \
3985 _(sr_steering_add_del_reply) \
3986 _(classify_add_del_session_reply) \
3987 _(classify_set_interface_ip_table_reply) \
3988 _(classify_set_interface_l2_tables_reply) \
3989 _(l2tpv3_set_tunnel_cookies_reply) \
3990 _(l2tpv3_interface_enable_disable_reply) \
3991 _(l2tpv3_set_lookup_key_reply) \
3992 _(l2_fib_clear_table_reply) \
3993 _(l2_interface_efp_filter_reply) \
3994 _(l2_interface_vlan_tag_rewrite_reply) \
3995 _(modify_vhost_user_if_reply) \
3996 _(delete_vhost_user_if_reply) \
3997 _(want_ip4_arp_events_reply) \
3998 _(want_ip6_nd_events_reply) \
3999 _(input_acl_set_interface_reply) \
4000 _(ipsec_spd_add_del_reply) \
4001 _(ipsec_interface_add_del_spd_reply) \
4002 _(ipsec_spd_add_del_entry_reply) \
4003 _(ipsec_sad_add_del_entry_reply) \
4004 _(ipsec_sa_set_key_reply) \
4005 _(ikev2_profile_add_del_reply) \
4006 _(ikev2_profile_set_auth_reply) \
4007 _(ikev2_profile_set_id_reply) \
4008 _(ikev2_profile_set_ts_reply) \
4009 _(ikev2_set_local_key_reply) \
4010 _(ikev2_set_responder_reply) \
4011 _(ikev2_set_ike_transforms_reply) \
4012 _(ikev2_set_esp_transforms_reply) \
4013 _(ikev2_set_sa_lifetime_reply) \
4014 _(ikev2_initiate_sa_init_reply) \
4015 _(ikev2_initiate_del_ike_sa_reply) \
4016 _(ikev2_initiate_del_child_sa_reply) \
4017 _(ikev2_initiate_rekey_child_sa_reply) \
4018 _(delete_loopback_reply) \
4019 _(bd_ip_mac_add_del_reply) \
4020 _(map_del_domain_reply) \
4021 _(map_add_del_rule_reply) \
4022 _(want_interface_events_reply) \
4023 _(want_stats_reply) \
4024 _(cop_interface_enable_disable_reply) \
4025 _(cop_whitelist_enable_disable_reply) \
4026 _(sw_interface_clear_stats_reply) \
4027 _(ioam_enable_reply) \
4028 _(ioam_disable_reply) \
4029 _(one_add_del_locator_reply) \
4030 _(one_add_del_local_eid_reply) \
4031 _(one_add_del_remote_mapping_reply) \
4032 _(one_add_del_adjacency_reply) \
4033 _(one_add_del_map_resolver_reply) \
4034 _(one_add_del_map_server_reply) \
4035 _(one_enable_disable_reply) \
4036 _(one_rloc_probe_enable_disable_reply) \
4037 _(one_map_register_enable_disable_reply) \
4038 _(one_pitr_set_locator_set_reply) \
4039 _(one_map_request_mode_reply) \
4040 _(one_add_del_map_request_itr_rlocs_reply) \
4041 _(one_eid_table_add_del_map_reply) \
4042 _(one_use_petr_reply) \
4043 _(gpe_add_del_fwd_entry_reply) \
4044 _(gpe_enable_disable_reply) \
4045 _(gpe_set_encap_mode_reply) \
4046 _(gpe_add_del_iface_reply) \
4047 _(vxlan_gpe_add_del_tunnel_reply) \
4048 _(af_packet_delete_reply) \
4049 _(policer_classify_set_interface_reply) \
4050 _(netmap_create_reply) \
4051 _(netmap_delete_reply) \
4052 _(set_ipfix_exporter_reply) \
4053 _(set_ipfix_classify_stream_reply) \
4054 _(ipfix_classify_table_add_del_reply) \
4055 _(flow_classify_set_interface_reply) \
4056 _(sw_interface_span_enable_disable_reply) \
4057 _(pg_capture_reply) \
4058 _(pg_enable_disable_reply) \
4059 _(ip_source_and_port_range_check_add_del_reply) \
4060 _(ip_source_and_port_range_check_interface_add_del_reply)\
4061 _(delete_subif_reply) \
4062 _(l2_interface_pbb_tag_rewrite_reply) \
4064 _(feature_enable_disable_reply) \
4065 _(sw_interface_tag_add_del_reply) \
4066 _(sw_interface_set_mtu_reply)
4069 static void vl_api_##n##_t_handler \
4070 (vl_api_##n##_t * mp) \
4072 vat_main_t * vam = &vat_main; \
4073 i32 retval = ntohl(mp->retval); \
4074 if (vam->async_mode) { \
4075 vam->async_errors += (retval < 0); \
4077 vam->retval = retval; \
4078 vam->result_ready = 1; \
4081 foreach_standard_reply_retval_handler;
4085 static void vl_api_##n##_t_handler_json \
4086 (vl_api_##n##_t * mp) \
4088 vat_main_t * vam = &vat_main; \
4089 vat_json_node_t node; \
4090 vat_json_init_object(&node); \
4091 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4092 vat_json_print(vam->ofp, &node); \
4093 vam->retval = ntohl(mp->retval); \
4094 vam->result_ready = 1; \
4096 foreach_standard_reply_retval_handler;
4100 * Table of message reply handlers, must include boilerplate handlers
4104 #define foreach_vpe_api_reply_msg \
4105 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4106 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4107 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4108 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4109 _(CONTROL_PING_REPLY, control_ping_reply) \
4110 _(CLI_REPLY, cli_reply) \
4111 _(CLI_INBAND_REPLY, cli_inband_reply) \
4112 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4113 sw_interface_add_del_address_reply) \
4114 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4115 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4116 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4117 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4118 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4119 sw_interface_set_l2_xconnect_reply) \
4120 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4121 sw_interface_set_l2_bridge_reply) \
4122 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4123 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4124 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
4125 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4126 _(L2_FLAGS_REPLY, l2_flags_reply) \
4127 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4128 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4129 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4130 _(TAP_DELETE_REPLY, tap_delete_reply) \
4131 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4132 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4133 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4134 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4135 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4136 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4137 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4138 proxy_arp_intfc_enable_disable_reply) \
4139 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4140 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4141 sw_interface_set_unnumbered_reply) \
4142 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4143 _(RESET_VRF_REPLY, reset_vrf_reply) \
4144 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4145 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4146 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4147 _(RESET_FIB_REPLY, reset_fib_reply) \
4148 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4149 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4150 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4151 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4152 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4153 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4154 sw_interface_ip6_enable_disable_reply) \
4155 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4156 sw_interface_ip6_set_link_local_address_reply) \
4157 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
4158 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
4159 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4160 sw_interface_ip6nd_ra_prefix_reply) \
4161 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4162 sw_interface_ip6nd_ra_config_reply) \
4163 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4164 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4165 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4166 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4167 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4168 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4169 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4170 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4171 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4172 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4173 classify_set_interface_ip_table_reply) \
4174 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4175 classify_set_interface_l2_tables_reply) \
4176 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4177 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4178 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4179 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4180 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4181 l2tpv3_interface_enable_disable_reply) \
4182 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4183 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4184 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4185 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4186 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4187 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4188 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4189 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4190 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4191 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4192 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4193 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4194 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4195 _(SHOW_VERSION_REPLY, show_version_reply) \
4196 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
4197 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4198 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4199 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4200 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4201 _(IP4_ARP_EVENT, ip4_arp_event) \
4202 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4203 _(IP6_ND_EVENT, ip6_nd_event) \
4204 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4205 _(IP_ADDRESS_DETAILS, ip_address_details) \
4206 _(IP_DETAILS, ip_details) \
4207 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4208 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4209 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4210 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4211 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4212 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4213 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4214 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4215 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4216 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4217 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4218 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4219 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4220 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4221 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4222 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4223 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4224 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4225 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4226 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4227 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4228 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4229 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4230 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4231 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4232 _(MAP_RULE_DETAILS, map_rule_details) \
4233 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4234 _(WANT_STATS_REPLY, want_stats_reply) \
4235 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4236 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4237 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4238 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4239 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4240 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4241 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4242 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4243 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4244 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4245 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4246 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4247 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4248 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4249 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4250 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4251 one_map_register_enable_disable_reply) \
4252 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4253 one_rloc_probe_enable_disable_reply) \
4254 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4255 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
4256 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4257 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4258 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4259 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4260 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4261 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4262 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4263 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4264 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4265 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4266 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4267 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4268 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4269 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4270 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4271 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4272 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4273 gpe_fwd_entry_path_details) \
4274 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4275 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4276 one_add_del_map_request_itr_rlocs_reply) \
4277 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4278 one_get_map_request_itr_rlocs_reply) \
4279 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4280 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
4281 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4282 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4283 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4284 show_one_map_register_state_reply) \
4285 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4286 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4287 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4288 _(POLICER_DETAILS, policer_details) \
4289 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4290 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4291 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4292 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4293 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4294 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4295 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4296 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4297 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4298 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4299 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4300 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4301 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4302 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4303 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4304 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4305 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4306 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4307 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4308 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4309 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4310 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4311 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4312 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4313 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4314 ip_source_and_port_range_check_add_del_reply) \
4315 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4316 ip_source_and_port_range_check_interface_add_del_reply) \
4317 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4318 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4319 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4320 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4321 _(PUNT_REPLY, punt_reply) \
4322 _(IP_FIB_DETAILS, ip_fib_details) \
4323 _(IP6_FIB_DETAILS, ip6_fib_details) \
4324 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4325 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4326 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4327 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4328 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4329 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4331 #define foreach_standalone_reply_msg \
4332 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4333 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
4334 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4335 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4336 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4337 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
4346 #define STR_VTR_OP_CASE(op) \
4347 case L2_VTR_ ## op: \
4351 str_vtr_op (u32 vtr_op)
4355 STR_VTR_OP_CASE (DISABLED);
4356 STR_VTR_OP_CASE (PUSH_1);
4357 STR_VTR_OP_CASE (PUSH_2);
4358 STR_VTR_OP_CASE (POP_1);
4359 STR_VTR_OP_CASE (POP_2);
4360 STR_VTR_OP_CASE (TRANSLATE_1_1);
4361 STR_VTR_OP_CASE (TRANSLATE_1_2);
4362 STR_VTR_OP_CASE (TRANSLATE_2_1);
4363 STR_VTR_OP_CASE (TRANSLATE_2_2);
4370 dump_sub_interface_table (vat_main_t * vam)
4372 const sw_interface_subif_t *sub = NULL;
4374 if (vam->json_output)
4377 ("JSON output supported only for VPE API calls and dump_stats_table");
4382 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4383 "Interface", "sw_if_index",
4384 "sub id", "dot1ad", "tags", "outer id",
4385 "inner id", "exact", "default", "outer any", "inner any");
4387 vec_foreach (sub, vam->sw_if_subif_table)
4390 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4391 sub->interface_name,
4393 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4394 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4395 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4396 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4397 if (sub->vtr_op != L2_VTR_DISABLED)
4400 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4401 "tag1: %d tag2: %d ]",
4402 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4403 sub->vtr_tag1, sub->vtr_tag2);
4411 name_sort_cmp (void *a1, void *a2)
4413 name_sort_t *n1 = a1;
4414 name_sort_t *n2 = a2;
4416 return strcmp ((char *) n1->name, (char *) n2->name);
4420 dump_interface_table (vat_main_t * vam)
4423 name_sort_t *nses = 0, *ns;
4425 if (vam->json_output)
4428 ("JSON output supported only for VPE API calls and dump_stats_table");
4433 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4435 vec_add2 (nses, ns, 1);
4436 ns->name = (u8 *)(p->key);
4437 ns->value = (u32) p->value[0];
4441 vec_sort_with_function (nses, name_sort_cmp);
4443 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4444 vec_foreach (ns, nses)
4446 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4453 dump_ip_table (vat_main_t * vam, int is_ipv6)
4455 const ip_details_t *det = NULL;
4456 const ip_address_details_t *address = NULL;
4459 print (vam->ofp, "%-12s", "sw_if_index");
4461 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4468 print (vam->ofp, "%-12d", i);
4469 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4474 vec_foreach (address, det->addr)
4478 is_ipv6 ? format_ip6_address : format_ip4_address,
4479 address->ip, address->prefix_length);
4487 dump_ipv4_table (vat_main_t * vam)
4489 if (vam->json_output)
4492 ("JSON output supported only for VPE API calls and dump_stats_table");
4496 return dump_ip_table (vam, 0);
4500 dump_ipv6_table (vat_main_t * vam)
4502 if (vam->json_output)
4505 ("JSON output supported only for VPE API calls and dump_stats_table");
4509 return dump_ip_table (vam, 1);
4513 counter_type_to_str (u8 counter_type, u8 is_combined)
4517 switch (counter_type)
4519 case VNET_INTERFACE_COUNTER_DROP:
4521 case VNET_INTERFACE_COUNTER_PUNT:
4523 case VNET_INTERFACE_COUNTER_IP4:
4525 case VNET_INTERFACE_COUNTER_IP6:
4527 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4529 case VNET_INTERFACE_COUNTER_RX_MISS:
4531 case VNET_INTERFACE_COUNTER_RX_ERROR:
4533 case VNET_INTERFACE_COUNTER_TX_ERROR:
4536 return "INVALID-COUNTER-TYPE";
4541 switch (counter_type)
4543 case VNET_INTERFACE_COUNTER_RX:
4545 case VNET_INTERFACE_COUNTER_TX:
4548 return "INVALID-COUNTER-TYPE";
4554 dump_stats_table (vat_main_t * vam)
4556 vat_json_node_t node;
4557 vat_json_node_t *msg_array;
4558 vat_json_node_t *msg;
4559 vat_json_node_t *counter_array;
4560 vat_json_node_t *counter;
4561 interface_counter_t c;
4563 ip4_fib_counter_t *c4;
4564 ip6_fib_counter_t *c6;
4565 ip4_nbr_counter_t *n4;
4566 ip6_nbr_counter_t *n6;
4569 if (!vam->json_output)
4571 clib_warning ("dump_stats_table supported only in JSON format");
4575 vat_json_init_object (&node);
4577 /* interface counters */
4578 msg_array = vat_json_object_add (&node, "interface_counters");
4579 vat_json_init_array (msg_array);
4580 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4582 msg = vat_json_array_add (msg_array);
4583 vat_json_init_object (msg);
4584 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4585 (u8 *) counter_type_to_str (i, 0));
4586 vat_json_object_add_int (msg, "is_combined", 0);
4587 counter_array = vat_json_object_add (msg, "data");
4588 vat_json_init_array (counter_array);
4589 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4591 packets = vam->simple_interface_counters[i][j];
4592 vat_json_array_add_uint (counter_array, packets);
4595 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4597 msg = vat_json_array_add (msg_array);
4598 vat_json_init_object (msg);
4599 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4600 (u8 *) counter_type_to_str (i, 1));
4601 vat_json_object_add_int (msg, "is_combined", 1);
4602 counter_array = vat_json_object_add (msg, "data");
4603 vat_json_init_array (counter_array);
4604 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4606 c = vam->combined_interface_counters[i][j];
4607 counter = vat_json_array_add (counter_array);
4608 vat_json_init_object (counter);
4609 vat_json_object_add_uint (counter, "packets", c.packets);
4610 vat_json_object_add_uint (counter, "bytes", c.bytes);
4614 /* ip4 fib counters */
4615 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4616 vat_json_init_array (msg_array);
4617 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4619 msg = vat_json_array_add (msg_array);
4620 vat_json_init_object (msg);
4621 vat_json_object_add_uint (msg, "vrf_id",
4622 vam->ip4_fib_counters_vrf_id_by_index[i]);
4623 counter_array = vat_json_object_add (msg, "c");
4624 vat_json_init_array (counter_array);
4625 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4627 counter = vat_json_array_add (counter_array);
4628 vat_json_init_object (counter);
4629 c4 = &vam->ip4_fib_counters[i][j];
4630 vat_json_object_add_ip4 (counter, "address", c4->address);
4631 vat_json_object_add_uint (counter, "address_length",
4632 c4->address_length);
4633 vat_json_object_add_uint (counter, "packets", c4->packets);
4634 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4638 /* ip6 fib counters */
4639 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4640 vat_json_init_array (msg_array);
4641 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4643 msg = vat_json_array_add (msg_array);
4644 vat_json_init_object (msg);
4645 vat_json_object_add_uint (msg, "vrf_id",
4646 vam->ip6_fib_counters_vrf_id_by_index[i]);
4647 counter_array = vat_json_object_add (msg, "c");
4648 vat_json_init_array (counter_array);
4649 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4651 counter = vat_json_array_add (counter_array);
4652 vat_json_init_object (counter);
4653 c6 = &vam->ip6_fib_counters[i][j];
4654 vat_json_object_add_ip6 (counter, "address", c6->address);
4655 vat_json_object_add_uint (counter, "address_length",
4656 c6->address_length);
4657 vat_json_object_add_uint (counter, "packets", c6->packets);
4658 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4662 /* ip4 nbr counters */
4663 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4664 vat_json_init_array (msg_array);
4665 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4667 msg = vat_json_array_add (msg_array);
4668 vat_json_init_object (msg);
4669 vat_json_object_add_uint (msg, "sw_if_index", i);
4670 counter_array = vat_json_object_add (msg, "c");
4671 vat_json_init_array (counter_array);
4672 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4674 counter = vat_json_array_add (counter_array);
4675 vat_json_init_object (counter);
4676 n4 = &vam->ip4_nbr_counters[i][j];
4677 vat_json_object_add_ip4 (counter, "address", n4->address);
4678 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4679 vat_json_object_add_uint (counter, "packets", n4->packets);
4680 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4684 /* ip6 nbr counters */
4685 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4686 vat_json_init_array (msg_array);
4687 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4689 msg = vat_json_array_add (msg_array);
4690 vat_json_init_object (msg);
4691 vat_json_object_add_uint (msg, "sw_if_index", i);
4692 counter_array = vat_json_object_add (msg, "c");
4693 vat_json_init_array (counter_array);
4694 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4696 counter = vat_json_array_add (counter_array);
4697 vat_json_init_object (counter);
4698 n6 = &vam->ip6_nbr_counters[i][j];
4699 vat_json_object_add_ip6 (counter, "address", n6->address);
4700 vat_json_object_add_uint (counter, "packets", n6->packets);
4701 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4705 vat_json_print (vam->ofp, &node);
4706 vat_json_free (&node);
4712 exec (vat_main_t * vam)
4714 api_main_t *am = &api_main;
4715 vl_api_cli_request_t *mp;
4719 unformat_input_t *i = vam->input;
4721 if (vec_len (i->buffer) == 0)
4724 if (vam->exec_mode == 0 && unformat (i, "mode"))
4729 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4736 M (CLI_REQUEST, mp);
4739 * Copy cmd into shared memory.
4740 * In order for the CLI command to work, it
4741 * must be a vector ending in \n, not a C-string ending
4744 pthread_mutex_lock (&am->vlib_rp->mutex);
4745 oldheap = svm_push_data_heap (am->vlib_rp);
4747 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4748 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4750 svm_pop_heap (oldheap);
4751 pthread_mutex_unlock (&am->vlib_rp->mutex);
4753 mp->cmd_in_shmem = (u64) cmd;
4755 timeout = vat_time_now (vam) + 10.0;
4757 while (vat_time_now (vam) < timeout)
4759 if (vam->result_ready == 1)
4762 if (vam->shmem_result != NULL)
4763 print (vam->ofp, "%s", vam->shmem_result);
4764 pthread_mutex_lock (&am->vlib_rp->mutex);
4765 oldheap = svm_push_data_heap (am->vlib_rp);
4767 free_me = (u8 *) vam->shmem_result;
4770 svm_pop_heap (oldheap);
4771 pthread_mutex_unlock (&am->vlib_rp->mutex);
4779 * Future replacement of exec() that passes CLI buffers directly in
4780 * the API messages instead of an additional shared memory area.
4783 exec_inband (vat_main_t * vam)
4785 vl_api_cli_inband_t *mp;
4786 unformat_input_t *i = vam->input;
4789 if (vec_len (i->buffer) == 0)
4792 if (vam->exec_mode == 0 && unformat (i, "mode"))
4797 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4804 * In order for the CLI command to work, it
4805 * must be a vector ending in \n, not a C-string ending
4808 u32 len = vec_len (vam->input->buffer);
4809 M2 (CLI_INBAND, mp, len);
4810 clib_memcpy (mp->cmd, vam->input->buffer, len);
4811 mp->length = htonl (len);
4814 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
4819 api_create_loopback (vat_main_t * vam)
4821 unformat_input_t *i = vam->input;
4822 vl_api_create_loopback_t *mp;
4823 vl_api_create_loopback_instance_t *mp_lbi;
4826 u8 is_specified = 0;
4827 u32 user_instance = 0;
4830 memset (mac_address, 0, sizeof (mac_address));
4832 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4834 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4836 if (unformat (i, "instance %d", &user_instance))
4844 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
4845 mp_lbi->is_specified = is_specified;
4847 mp_lbi->user_instance = htonl (user_instance);
4849 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
4854 /* Construct the API message */
4855 M (CREATE_LOOPBACK, mp);
4857 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4866 api_delete_loopback (vat_main_t * vam)
4868 unformat_input_t *i = vam->input;
4869 vl_api_delete_loopback_t *mp;
4870 u32 sw_if_index = ~0;
4873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4875 if (unformat (i, "sw_if_index %d", &sw_if_index))
4881 if (sw_if_index == ~0)
4883 errmsg ("missing sw_if_index");
4887 /* Construct the API message */
4888 M (DELETE_LOOPBACK, mp);
4889 mp->sw_if_index = ntohl (sw_if_index);
4897 api_want_stats (vat_main_t * vam)
4899 unformat_input_t *i = vam->input;
4900 vl_api_want_stats_t *mp;
4904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4906 if (unformat (i, "enable"))
4908 else if (unformat (i, "disable"))
4916 errmsg ("missing enable|disable");
4921 mp->enable_disable = enable;
4929 api_want_interface_events (vat_main_t * vam)
4931 unformat_input_t *i = vam->input;
4932 vl_api_want_interface_events_t *mp;
4936 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4938 if (unformat (i, "enable"))
4940 else if (unformat (i, "disable"))
4948 errmsg ("missing enable|disable");
4952 M (WANT_INTERFACE_EVENTS, mp);
4953 mp->enable_disable = enable;
4955 vam->interface_event_display = enable;
4963 /* Note: non-static, called once to set up the initial intfc table */
4965 api_sw_interface_dump (vat_main_t * vam)
4967 vl_api_sw_interface_dump_t *mp;
4968 vl_api_control_ping_t *mp_ping;
4970 name_sort_t *nses = 0, *ns;
4971 sw_interface_subif_t *sub = NULL;
4974 /* Toss the old name table */
4976 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4978 vec_add2 (nses, ns, 1);
4979 ns->name = (u8 *)(p->key);
4980 ns->value = (u32) p->value[0];
4984 hash_free (vam->sw_if_index_by_interface_name);
4986 vec_foreach (ns, nses) vec_free (ns->name);
4990 vec_foreach (sub, vam->sw_if_subif_table)
4992 vec_free (sub->interface_name);
4994 vec_free (vam->sw_if_subif_table);
4996 /* recreate the interface name hash table */
4997 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4999 /* Get list of ethernets */
5000 M (SW_INTERFACE_DUMP, mp);
5001 mp->name_filter_valid = 1;
5002 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
5005 /* and local / loopback interfaces */
5006 M (SW_INTERFACE_DUMP, mp);
5007 mp->name_filter_valid = 1;
5008 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
5011 /* and packet-generator interfaces */
5012 M (SW_INTERFACE_DUMP, mp);
5013 mp->name_filter_valid = 1;
5014 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
5017 /* and vxlan-gpe tunnel interfaces */
5018 M (SW_INTERFACE_DUMP, mp);
5019 mp->name_filter_valid = 1;
5020 strncpy ((char *) mp->name_filter, "vxlan_gpe",
5021 sizeof (mp->name_filter) - 1);
5024 /* and vxlan tunnel interfaces */
5025 M (SW_INTERFACE_DUMP, mp);
5026 mp->name_filter_valid = 1;
5027 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
5030 /* and host (af_packet) interfaces */
5031 M (SW_INTERFACE_DUMP, mp);
5032 mp->name_filter_valid = 1;
5033 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
5036 /* and l2tpv3 tunnel interfaces */
5037 M (SW_INTERFACE_DUMP, mp);
5038 mp->name_filter_valid = 1;
5039 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
5040 sizeof (mp->name_filter) - 1);
5043 /* and GRE tunnel interfaces */
5044 M (SW_INTERFACE_DUMP, mp);
5045 mp->name_filter_valid = 1;
5046 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
5049 /* and LISP-GPE interfaces */
5050 M (SW_INTERFACE_DUMP, mp);
5051 mp->name_filter_valid = 1;
5052 strncpy ((char *) mp->name_filter, "lisp_gpe",
5053 sizeof (mp->name_filter) - 1);
5056 /* and IPSEC tunnel interfaces */
5057 M (SW_INTERFACE_DUMP, mp);
5058 mp->name_filter_valid = 1;
5059 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
5062 /* Use a control ping for synchronization */
5063 M (CONTROL_PING, mp_ping);
5071 api_sw_interface_set_flags (vat_main_t * vam)
5073 unformat_input_t *i = vam->input;
5074 vl_api_sw_interface_set_flags_t *mp;
5076 u8 sw_if_index_set = 0;
5077 u8 admin_up = 0, link_up = 0;
5080 /* Parse args required to build the message */
5081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5083 if (unformat (i, "admin-up"))
5085 else if (unformat (i, "admin-down"))
5087 else if (unformat (i, "link-up"))
5089 else if (unformat (i, "link-down"))
5092 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5093 sw_if_index_set = 1;
5094 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5095 sw_if_index_set = 1;
5100 if (sw_if_index_set == 0)
5102 errmsg ("missing interface name or sw_if_index");
5106 /* Construct the API message */
5107 M (SW_INTERFACE_SET_FLAGS, mp);
5108 mp->sw_if_index = ntohl (sw_if_index);
5109 mp->admin_up_down = admin_up;
5110 mp->link_up_down = link_up;
5115 /* Wait for a reply, return the good/bad news... */
5121 api_sw_interface_clear_stats (vat_main_t * vam)
5123 unformat_input_t *i = vam->input;
5124 vl_api_sw_interface_clear_stats_t *mp;
5126 u8 sw_if_index_set = 0;
5129 /* Parse args required to build the message */
5130 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5132 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5133 sw_if_index_set = 1;
5134 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5135 sw_if_index_set = 1;
5140 /* Construct the API message */
5141 M (SW_INTERFACE_CLEAR_STATS, mp);
5143 if (sw_if_index_set == 1)
5144 mp->sw_if_index = ntohl (sw_if_index);
5146 mp->sw_if_index = ~0;
5151 /* Wait for a reply, return the good/bad news... */
5157 api_sw_interface_add_del_address (vat_main_t * vam)
5159 unformat_input_t *i = vam->input;
5160 vl_api_sw_interface_add_del_address_t *mp;
5162 u8 sw_if_index_set = 0;
5163 u8 is_add = 1, del_all = 0;
5164 u32 address_length = 0;
5165 u8 v4_address_set = 0;
5166 u8 v6_address_set = 0;
5167 ip4_address_t v4address;
5168 ip6_address_t v6address;
5171 /* Parse args required to build the message */
5172 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5174 if (unformat (i, "del-all"))
5176 else if (unformat (i, "del"))
5179 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5180 sw_if_index_set = 1;
5181 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5182 sw_if_index_set = 1;
5183 else if (unformat (i, "%U/%d",
5184 unformat_ip4_address, &v4address, &address_length))
5186 else if (unformat (i, "%U/%d",
5187 unformat_ip6_address, &v6address, &address_length))
5193 if (sw_if_index_set == 0)
5195 errmsg ("missing interface name or sw_if_index");
5198 if (v4_address_set && v6_address_set)
5200 errmsg ("both v4 and v6 addresses set");
5203 if (!v4_address_set && !v6_address_set && !del_all)
5205 errmsg ("no addresses set");
5209 /* Construct the API message */
5210 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5212 mp->sw_if_index = ntohl (sw_if_index);
5213 mp->is_add = is_add;
5214 mp->del_all = del_all;
5218 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5222 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5224 mp->address_length = address_length;
5229 /* Wait for a reply, return good/bad news */
5235 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5237 unformat_input_t *i = vam->input;
5238 vl_api_sw_interface_set_mpls_enable_t *mp;
5240 u8 sw_if_index_set = 0;
5244 /* Parse args required to build the message */
5245 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5247 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5248 sw_if_index_set = 1;
5249 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5250 sw_if_index_set = 1;
5251 else if (unformat (i, "disable"))
5253 else if (unformat (i, "dis"))
5259 if (sw_if_index_set == 0)
5261 errmsg ("missing interface name or sw_if_index");
5265 /* Construct the API message */
5266 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5268 mp->sw_if_index = ntohl (sw_if_index);
5269 mp->enable = enable;
5274 /* Wait for a reply... */
5280 api_sw_interface_set_table (vat_main_t * vam)
5282 unformat_input_t *i = vam->input;
5283 vl_api_sw_interface_set_table_t *mp;
5284 u32 sw_if_index, vrf_id = 0;
5285 u8 sw_if_index_set = 0;
5289 /* Parse args required to build the message */
5290 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5292 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5293 sw_if_index_set = 1;
5294 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5295 sw_if_index_set = 1;
5296 else if (unformat (i, "vrf %d", &vrf_id))
5298 else if (unformat (i, "ipv6"))
5304 if (sw_if_index_set == 0)
5306 errmsg ("missing interface name or sw_if_index");
5310 /* Construct the API message */
5311 M (SW_INTERFACE_SET_TABLE, mp);
5313 mp->sw_if_index = ntohl (sw_if_index);
5314 mp->is_ipv6 = is_ipv6;
5315 mp->vrf_id = ntohl (vrf_id);
5320 /* Wait for a reply... */
5325 static void vl_api_sw_interface_get_table_reply_t_handler
5326 (vl_api_sw_interface_get_table_reply_t * mp)
5328 vat_main_t *vam = &vat_main;
5330 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5332 vam->retval = ntohl (mp->retval);
5333 vam->result_ready = 1;
5337 static void vl_api_sw_interface_get_table_reply_t_handler_json
5338 (vl_api_sw_interface_get_table_reply_t * mp)
5340 vat_main_t *vam = &vat_main;
5341 vat_json_node_t node;
5343 vat_json_init_object (&node);
5344 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5345 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5347 vat_json_print (vam->ofp, &node);
5348 vat_json_free (&node);
5350 vam->retval = ntohl (mp->retval);
5351 vam->result_ready = 1;
5355 api_sw_interface_get_table (vat_main_t * vam)
5357 unformat_input_t *i = vam->input;
5358 vl_api_sw_interface_get_table_t *mp;
5360 u8 sw_if_index_set = 0;
5364 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5366 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5367 sw_if_index_set = 1;
5368 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5369 sw_if_index_set = 1;
5370 else if (unformat (i, "ipv6"))
5376 if (sw_if_index_set == 0)
5378 errmsg ("missing interface name or sw_if_index");
5382 M (SW_INTERFACE_GET_TABLE, mp);
5383 mp->sw_if_index = htonl (sw_if_index);
5384 mp->is_ipv6 = is_ipv6;
5392 api_sw_interface_set_vpath (vat_main_t * vam)
5394 unformat_input_t *i = vam->input;
5395 vl_api_sw_interface_set_vpath_t *mp;
5396 u32 sw_if_index = 0;
5397 u8 sw_if_index_set = 0;
5401 /* Parse args required to build the message */
5402 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5404 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5405 sw_if_index_set = 1;
5406 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5407 sw_if_index_set = 1;
5408 else if (unformat (i, "enable"))
5410 else if (unformat (i, "disable"))
5416 if (sw_if_index_set == 0)
5418 errmsg ("missing interface name or sw_if_index");
5422 /* Construct the API message */
5423 M (SW_INTERFACE_SET_VPATH, mp);
5425 mp->sw_if_index = ntohl (sw_if_index);
5426 mp->enable = is_enable;
5431 /* Wait for a reply... */
5437 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5439 unformat_input_t *i = vam->input;
5440 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5441 u32 sw_if_index = 0;
5442 u8 sw_if_index_set = 0;
5447 /* Parse args required to build the message */
5448 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5450 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5451 sw_if_index_set = 1;
5452 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5453 sw_if_index_set = 1;
5454 else if (unformat (i, "enable"))
5456 else if (unformat (i, "disable"))
5458 else if (unformat (i, "ip4"))
5460 else if (unformat (i, "ip6"))
5466 if (sw_if_index_set == 0)
5468 errmsg ("missing interface name or sw_if_index");
5472 /* Construct the API message */
5473 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5475 mp->sw_if_index = ntohl (sw_if_index);
5476 mp->enable = is_enable;
5477 mp->is_ipv6 = is_ipv6;
5482 /* Wait for a reply... */
5488 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5490 unformat_input_t *i = vam->input;
5491 vl_api_sw_interface_set_l2_xconnect_t *mp;
5493 u8 rx_sw_if_index_set = 0;
5495 u8 tx_sw_if_index_set = 0;
5499 /* Parse args required to build the message */
5500 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5502 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5503 rx_sw_if_index_set = 1;
5504 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5505 tx_sw_if_index_set = 1;
5506 else if (unformat (i, "rx"))
5508 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5510 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5512 rx_sw_if_index_set = 1;
5517 else if (unformat (i, "tx"))
5519 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5521 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5523 tx_sw_if_index_set = 1;
5528 else if (unformat (i, "enable"))
5530 else if (unformat (i, "disable"))
5536 if (rx_sw_if_index_set == 0)
5538 errmsg ("missing rx interface name or rx_sw_if_index");
5542 if (enable && (tx_sw_if_index_set == 0))
5544 errmsg ("missing tx interface name or tx_sw_if_index");
5548 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5550 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5551 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5552 mp->enable = enable;
5560 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5562 unformat_input_t *i = vam->input;
5563 vl_api_sw_interface_set_l2_bridge_t *mp;
5565 u8 rx_sw_if_index_set = 0;
5573 /* Parse args required to build the message */
5574 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5576 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5577 rx_sw_if_index_set = 1;
5578 else if (unformat (i, "bd_id %d", &bd_id))
5582 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5583 rx_sw_if_index_set = 1;
5584 else if (unformat (i, "shg %d", &shg))
5586 else if (unformat (i, "bvi"))
5588 else if (unformat (i, "enable"))
5590 else if (unformat (i, "disable"))
5596 if (rx_sw_if_index_set == 0)
5598 errmsg ("missing rx interface name or sw_if_index");
5602 if (enable && (bd_id_set == 0))
5604 errmsg ("missing bridge domain");
5608 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
5610 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5611 mp->bd_id = ntohl (bd_id);
5614 mp->enable = enable;
5622 api_bridge_domain_dump (vat_main_t * vam)
5624 unformat_input_t *i = vam->input;
5625 vl_api_bridge_domain_dump_t *mp;
5626 vl_api_control_ping_t *mp_ping;
5630 /* Parse args required to build the message */
5631 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5633 if (unformat (i, "bd_id %d", &bd_id))
5639 M (BRIDGE_DOMAIN_DUMP, mp);
5640 mp->bd_id = ntohl (bd_id);
5643 /* Use a control ping for synchronization */
5644 M (CONTROL_PING, mp_ping);
5652 api_bridge_domain_add_del (vat_main_t * vam)
5654 unformat_input_t *i = vam->input;
5655 vl_api_bridge_domain_add_del_t *mp;
5658 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5662 /* Parse args required to build the message */
5663 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5665 if (unformat (i, "bd_id %d", &bd_id))
5667 else if (unformat (i, "flood %d", &flood))
5669 else if (unformat (i, "uu-flood %d", &uu_flood))
5671 else if (unformat (i, "forward %d", &forward))
5673 else if (unformat (i, "learn %d", &learn))
5675 else if (unformat (i, "arp-term %d", &arp_term))
5677 else if (unformat (i, "mac-age %d", &mac_age))
5679 else if (unformat (i, "del"))
5682 flood = uu_flood = forward = learn = 0;
5690 errmsg ("missing bridge domain");
5696 errmsg ("mac age must be less than 256 ");
5700 M (BRIDGE_DOMAIN_ADD_DEL, mp);
5702 mp->bd_id = ntohl (bd_id);
5704 mp->uu_flood = uu_flood;
5705 mp->forward = forward;
5707 mp->arp_term = arp_term;
5708 mp->is_add = is_add;
5709 mp->mac_age = (u8) mac_age;
5717 api_l2fib_add_del (vat_main_t * vam)
5719 unformat_input_t *i = vam->input;
5720 vl_api_l2fib_add_del_t *mp;
5726 u32 sw_if_index = ~0;
5727 u8 sw_if_index_set = 0;
5736 /* Parse args required to build the message */
5737 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5739 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5741 else if (unformat (i, "bd_id %d", &bd_id))
5743 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5744 sw_if_index_set = 1;
5745 else if (unformat (i, "sw_if"))
5747 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5750 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5751 sw_if_index_set = 1;
5756 else if (unformat (i, "static"))
5758 else if (unformat (i, "filter"))
5763 else if (unformat (i, "bvi"))
5768 else if (unformat (i, "del"))
5770 else if (unformat (i, "count %d", &count))
5778 errmsg ("missing mac address");
5784 errmsg ("missing bridge domain");
5788 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5790 errmsg ("missing interface name or sw_if_index");
5796 /* Turn on async mode */
5797 vam->async_mode = 1;
5798 vam->async_errors = 0;
5799 before = vat_time_now (vam);
5802 for (j = 0; j < count; j++)
5804 M (L2FIB_ADD_DEL, mp);
5807 mp->bd_id = ntohl (bd_id);
5808 mp->is_add = is_add;
5812 mp->sw_if_index = ntohl (sw_if_index);
5813 mp->static_mac = static_mac;
5814 mp->filter_mac = filter_mac;
5815 mp->bvi_mac = bvi_mac;
5817 increment_mac_address (&mac);
5824 vl_api_control_ping_t *mp_ping;
5827 /* Shut off async mode */
5828 vam->async_mode = 0;
5830 M (CONTROL_PING, mp_ping);
5833 timeout = vat_time_now (vam) + 1.0;
5834 while (vat_time_now (vam) < timeout)
5835 if (vam->result_ready == 1)
5840 if (vam->retval == -99)
5843 if (vam->async_errors > 0)
5845 errmsg ("%d asynchronous errors", vam->async_errors);
5848 vam->async_errors = 0;
5849 after = vat_time_now (vam);
5851 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
5852 count, after - before, count / (after - before));
5858 /* Wait for a reply... */
5862 /* Return the good/bad news */
5863 return (vam->retval);
5867 api_l2_flags (vat_main_t * vam)
5869 unformat_input_t *i = vam->input;
5870 vl_api_l2_flags_t *mp;
5872 u32 feature_bitmap = 0;
5873 u8 sw_if_index_set = 0;
5876 /* Parse args required to build the message */
5877 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5879 if (unformat (i, "sw_if_index %d", &sw_if_index))
5880 sw_if_index_set = 1;
5881 else if (unformat (i, "sw_if"))
5883 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5886 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5887 sw_if_index_set = 1;
5892 else if (unformat (i, "learn"))
5893 feature_bitmap |= L2INPUT_FEAT_LEARN;
5894 else if (unformat (i, "forward"))
5895 feature_bitmap |= L2INPUT_FEAT_FWD;
5896 else if (unformat (i, "flood"))
5897 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5898 else if (unformat (i, "uu-flood"))
5899 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5904 if (sw_if_index_set == 0)
5906 errmsg ("missing interface name or sw_if_index");
5912 mp->sw_if_index = ntohl (sw_if_index);
5913 mp->feature_bitmap = ntohl (feature_bitmap);
5921 api_bridge_flags (vat_main_t * vam)
5923 unformat_input_t *i = vam->input;
5924 vl_api_bridge_flags_t *mp;
5931 /* Parse args required to build the message */
5932 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5934 if (unformat (i, "bd_id %d", &bd_id))
5936 else if (unformat (i, "learn"))
5938 else if (unformat (i, "forward"))
5940 else if (unformat (i, "flood"))
5942 else if (unformat (i, "uu-flood"))
5943 flags |= L2_UU_FLOOD;
5944 else if (unformat (i, "arp-term"))
5945 flags |= L2_ARP_TERM;
5946 else if (unformat (i, "off"))
5948 else if (unformat (i, "disable"))
5956 errmsg ("missing bridge domain");
5960 M (BRIDGE_FLAGS, mp);
5962 mp->bd_id = ntohl (bd_id);
5963 mp->feature_bitmap = ntohl (flags);
5964 mp->is_set = is_set;
5972 api_bd_ip_mac_add_del (vat_main_t * vam)
5974 unformat_input_t *i = vam->input;
5975 vl_api_bd_ip_mac_add_del_t *mp;
5982 ip4_address_t v4addr;
5983 ip6_address_t v6addr;
5988 /* Parse args required to build the message */
5989 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5991 if (unformat (i, "bd_id %d", &bd_id))
5995 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5999 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6004 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6008 else if (unformat (i, "del"))
6016 errmsg ("missing bridge domain");
6019 else if (ip_set == 0)
6021 errmsg ("missing IP address");
6024 else if (mac_set == 0)
6026 errmsg ("missing MAC address");
6030 M (BD_IP_MAC_ADD_DEL, mp);
6032 mp->bd_id = ntohl (bd_id);
6033 mp->is_ipv6 = is_ipv6;
6034 mp->is_add = is_add;
6036 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6038 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6039 clib_memcpy (mp->mac_address, macaddr, 6);
6046 api_tap_connect (vat_main_t * vam)
6048 unformat_input_t *i = vam->input;
6049 vl_api_tap_connect_t *mp;
6055 ip4_address_t ip4_address;
6057 int ip4_address_set = 0;
6058 ip6_address_t ip6_address;
6060 int ip6_address_set = 0;
6063 memset (mac_address, 0, sizeof (mac_address));
6065 /* Parse args required to build the message */
6066 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6068 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6072 else if (unformat (i, "random-mac"))
6074 else if (unformat (i, "tapname %s", &tap_name))
6076 else if (unformat (i, "tag %s", &tag))
6078 else if (unformat (i, "address %U/%d",
6079 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6080 ip4_address_set = 1;
6081 else if (unformat (i, "address %U/%d",
6082 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6083 ip6_address_set = 1;
6090 errmsg ("missing tap name");
6093 if (vec_len (tap_name) > 63)
6095 errmsg ("tap name too long");
6098 vec_add1 (tap_name, 0);
6100 if (vec_len (tag) > 63)
6102 errmsg ("tag too long");
6106 /* Construct the API message */
6107 M (TAP_CONNECT, mp);
6109 mp->use_random_mac = random_mac;
6110 clib_memcpy (mp->mac_address, mac_address, 6);
6111 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6113 clib_memcpy (mp->tag, tag, vec_len (tag));
6115 if (ip4_address_set)
6117 mp->ip4_address_set = 1;
6118 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6119 mp->ip4_mask_width = ip4_mask_width;
6121 if (ip6_address_set)
6123 mp->ip6_address_set = 1;
6124 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6125 mp->ip6_mask_width = ip6_mask_width;
6128 vec_free (tap_name);
6134 /* Wait for a reply... */
6140 api_tap_modify (vat_main_t * vam)
6142 unformat_input_t *i = vam->input;
6143 vl_api_tap_modify_t *mp;
6148 u32 sw_if_index = ~0;
6149 u8 sw_if_index_set = 0;
6152 memset (mac_address, 0, sizeof (mac_address));
6154 /* Parse args required to build the message */
6155 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6157 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6158 sw_if_index_set = 1;
6159 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6160 sw_if_index_set = 1;
6161 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6165 else if (unformat (i, "random-mac"))
6167 else if (unformat (i, "tapname %s", &tap_name))
6173 if (sw_if_index_set == 0)
6175 errmsg ("missing vpp interface name");
6180 errmsg ("missing tap name");
6183 if (vec_len (tap_name) > 63)
6185 errmsg ("tap name too long");
6187 vec_add1 (tap_name, 0);
6189 /* Construct the API message */
6192 mp->use_random_mac = random_mac;
6193 mp->sw_if_index = ntohl (sw_if_index);
6194 clib_memcpy (mp->mac_address, mac_address, 6);
6195 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6196 vec_free (tap_name);
6201 /* Wait for a reply... */
6207 api_tap_delete (vat_main_t * vam)
6209 unformat_input_t *i = vam->input;
6210 vl_api_tap_delete_t *mp;
6211 u32 sw_if_index = ~0;
6212 u8 sw_if_index_set = 0;
6215 /* Parse args required to build the message */
6216 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6218 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6219 sw_if_index_set = 1;
6220 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6221 sw_if_index_set = 1;
6226 if (sw_if_index_set == 0)
6228 errmsg ("missing vpp interface name");
6232 /* Construct the API message */
6235 mp->sw_if_index = ntohl (sw_if_index);
6240 /* Wait for a reply... */
6246 api_ip_add_del_route (vat_main_t * vam)
6248 unformat_input_t *i = vam->input;
6249 vl_api_ip_add_del_route_t *mp;
6250 u32 sw_if_index = ~0, vrf_id = 0;
6252 u8 is_local = 0, is_drop = 0;
6253 u8 is_unreach = 0, is_prohibit = 0;
6254 u8 create_vrf_if_needed = 0;
6256 u32 next_hop_weight = 1;
6258 u8 is_multipath = 0;
6260 u8 address_length_set = 0;
6261 u32 next_hop_table_id = 0;
6262 u32 resolve_attempts = 0;
6263 u32 dst_address_length = 0;
6264 u8 next_hop_set = 0;
6265 ip4_address_t v4_dst_address, v4_next_hop_address;
6266 ip6_address_t v6_dst_address, v6_next_hop_address;
6270 u32 random_add_del = 0;
6271 u32 *random_vector = 0;
6273 u32 random_seed = 0xdeaddabe;
6274 u32 classify_table_index = ~0;
6276 u8 resolve_host = 0, resolve_attached = 0;
6277 mpls_label_t *next_hop_out_label_stack = NULL;
6278 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6279 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6281 /* Parse args required to build the message */
6282 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6284 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6286 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6288 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6293 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6298 else if (unformat (i, "/%d", &dst_address_length))
6300 address_length_set = 1;
6303 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6304 &v4_next_hop_address))
6308 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6309 &v6_next_hop_address))
6313 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6315 else if (unformat (i, "weight %d", &next_hop_weight))
6317 else if (unformat (i, "drop"))
6321 else if (unformat (i, "null-send-unreach"))
6325 else if (unformat (i, "null-send-prohibit"))
6329 else if (unformat (i, "local"))
6333 else if (unformat (i, "classify %d", &classify_table_index))
6337 else if (unformat (i, "del"))
6339 else if (unformat (i, "add"))
6341 else if (unformat (i, "not-last"))
6343 else if (unformat (i, "resolve-via-host"))
6345 else if (unformat (i, "resolve-via-attached"))
6346 resolve_attached = 1;
6347 else if (unformat (i, "multipath"))
6349 else if (unformat (i, "vrf %d", &vrf_id))
6351 else if (unformat (i, "create-vrf"))
6352 create_vrf_if_needed = 1;
6353 else if (unformat (i, "count %d", &count))
6355 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6357 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6359 else if (unformat (i, "out-label %d", &next_hop_out_label))
6360 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6361 else if (unformat (i, "via-label %d", &next_hop_via_label))
6363 else if (unformat (i, "random"))
6365 else if (unformat (i, "seed %d", &random_seed))
6369 clib_warning ("parse error '%U'", format_unformat_error, i);
6374 if (!next_hop_set && !is_drop && !is_local &&
6375 !is_classify && !is_unreach && !is_prohibit &&
6376 MPLS_LABEL_INVALID == next_hop_via_label)
6379 ("next hop / local / drop / unreach / prohibit / classify not set");
6383 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6385 errmsg ("next hop and next-hop via label set");
6388 if (address_set == 0)
6390 errmsg ("missing addresses");
6394 if (address_length_set == 0)
6396 errmsg ("missing address length");
6400 /* Generate a pile of unique, random routes */
6403 u32 this_random_address;
6404 random_hash = hash_create (count, sizeof (uword));
6406 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6407 for (j = 0; j <= count; j++)
6411 this_random_address = random_u32 (&random_seed);
6412 this_random_address =
6413 clib_host_to_net_u32 (this_random_address);
6415 while (hash_get (random_hash, this_random_address));
6416 vec_add1 (random_vector, this_random_address);
6417 hash_set (random_hash, this_random_address, 1);
6419 hash_free (random_hash);
6420 v4_dst_address.as_u32 = random_vector[0];
6425 /* Turn on async mode */
6426 vam->async_mode = 1;
6427 vam->async_errors = 0;
6428 before = vat_time_now (vam);
6431 for (j = 0; j < count; j++)
6433 /* Construct the API message */
6434 M2 (IP_ADD_DEL_ROUTE, mp,
6435 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6437 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6438 mp->table_id = ntohl (vrf_id);
6439 mp->create_vrf_if_needed = create_vrf_if_needed;
6441 mp->is_add = is_add;
6442 mp->is_drop = is_drop;
6443 mp->is_unreach = is_unreach;
6444 mp->is_prohibit = is_prohibit;
6445 mp->is_ipv6 = is_ipv6;
6446 mp->is_local = is_local;
6447 mp->is_classify = is_classify;
6448 mp->is_multipath = is_multipath;
6449 mp->is_resolve_host = resolve_host;
6450 mp->is_resolve_attached = resolve_attached;
6451 mp->not_last = not_last;
6452 mp->next_hop_weight = next_hop_weight;
6453 mp->dst_address_length = dst_address_length;
6454 mp->next_hop_table_id = ntohl (next_hop_table_id);
6455 mp->classify_table_index = ntohl (classify_table_index);
6456 mp->next_hop_via_label = ntohl (next_hop_via_label);
6457 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6458 if (0 != mp->next_hop_n_out_labels)
6460 memcpy (mp->next_hop_out_label_stack,
6461 next_hop_out_label_stack,
6462 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6463 vec_free (next_hop_out_label_stack);
6468 clib_memcpy (mp->dst_address, &v6_dst_address,
6469 sizeof (v6_dst_address));
6471 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6472 sizeof (v6_next_hop_address));
6473 increment_v6_address (&v6_dst_address);
6477 clib_memcpy (mp->dst_address, &v4_dst_address,
6478 sizeof (v4_dst_address));
6480 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6481 sizeof (v4_next_hop_address));
6483 v4_dst_address.as_u32 = random_vector[j + 1];
6485 increment_v4_address (&v4_dst_address);
6489 /* If we receive SIGTERM, stop now... */
6494 /* When testing multiple add/del ops, use a control-ping to sync */
6497 vl_api_control_ping_t *mp_ping;
6501 /* Shut off async mode */
6502 vam->async_mode = 0;
6504 M (CONTROL_PING, mp_ping);
6507 timeout = vat_time_now (vam) + 1.0;
6508 while (vat_time_now (vam) < timeout)
6509 if (vam->result_ready == 1)
6514 if (vam->retval == -99)
6517 if (vam->async_errors > 0)
6519 errmsg ("%d asynchronous errors", vam->async_errors);
6522 vam->async_errors = 0;
6523 after = vat_time_now (vam);
6525 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6529 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6530 count, after - before, count / (after - before));
6536 /* Wait for a reply... */
6541 /* Return the good/bad news */
6542 return (vam->retval);
6546 api_ip_mroute_add_del (vat_main_t * vam)
6548 unformat_input_t *i = vam->input;
6549 vl_api_ip_mroute_add_del_t *mp;
6550 u32 sw_if_index = ~0, vrf_id = 0;
6553 u8 create_vrf_if_needed = 0;
6556 u32 grp_address_length = 0;
6557 ip4_address_t v4_grp_address, v4_src_address;
6558 ip6_address_t v6_grp_address, v6_src_address;
6559 mfib_itf_flags_t iflags = 0;
6560 mfib_entry_flags_t eflags = 0;
6563 /* Parse args required to build the message */
6564 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6566 if (unformat (i, "sw_if_index %d", &sw_if_index))
6568 else if (unformat (i, "%U %U",
6569 unformat_ip4_address, &v4_src_address,
6570 unformat_ip4_address, &v4_grp_address))
6572 grp_address_length = 64;
6576 else if (unformat (i, "%U %U",
6577 unformat_ip6_address, &v6_src_address,
6578 unformat_ip6_address, &v6_grp_address))
6580 grp_address_length = 256;
6584 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
6586 memset (&v4_src_address, 0, sizeof (v4_src_address));
6587 grp_address_length = 32;
6591 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
6593 memset (&v6_src_address, 0, sizeof (v6_src_address));
6594 grp_address_length = 128;
6598 else if (unformat (i, "/%d", &grp_address_length))
6600 else if (unformat (i, "local"))
6604 else if (unformat (i, "del"))
6606 else if (unformat (i, "add"))
6608 else if (unformat (i, "vrf %d", &vrf_id))
6610 else if (unformat (i, "create-vrf"))
6611 create_vrf_if_needed = 1;
6612 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
6614 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
6618 clib_warning ("parse error '%U'", format_unformat_error, i);
6623 if (address_set == 0)
6625 errmsg ("missing addresses\n");
6629 /* Construct the API message */
6630 M (IP_MROUTE_ADD_DEL, mp);
6632 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6633 mp->table_id = ntohl (vrf_id);
6634 mp->create_vrf_if_needed = create_vrf_if_needed;
6636 mp->is_add = is_add;
6637 mp->is_ipv6 = is_ipv6;
6638 mp->is_local = is_local;
6639 mp->itf_flags = ntohl (iflags);
6640 mp->entry_flags = ntohl (eflags);
6641 mp->grp_address_length = grp_address_length;
6642 mp->grp_address_length = ntohs (mp->grp_address_length);
6646 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
6647 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
6651 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
6652 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
6658 /* Wait for a reply... */
6664 api_mpls_route_add_del (vat_main_t * vam)
6666 unformat_input_t *i = vam->input;
6667 vl_api_mpls_route_add_del_t *mp;
6668 u32 sw_if_index = ~0, table_id = 0;
6669 u8 create_table_if_needed = 0;
6671 u32 next_hop_weight = 1;
6672 u8 is_multipath = 0;
6673 u32 next_hop_table_id = 0;
6674 u8 next_hop_set = 0;
6675 ip4_address_t v4_next_hop_address = {
6678 ip6_address_t v6_next_hop_address = { {0} };
6682 u32 classify_table_index = ~0;
6684 u8 resolve_host = 0, resolve_attached = 0;
6685 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6686 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6687 mpls_label_t *next_hop_out_label_stack = NULL;
6688 mpls_label_t local_label = MPLS_LABEL_INVALID;
6690 u8 next_hop_proto_is_ip4 = 1;
6692 /* Parse args required to build the message */
6693 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6695 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6697 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6699 else if (unformat (i, "%d", &local_label))
6701 else if (unformat (i, "eos"))
6703 else if (unformat (i, "non-eos"))
6705 else if (unformat (i, "via %U", unformat_ip4_address,
6706 &v4_next_hop_address))
6709 next_hop_proto_is_ip4 = 1;
6711 else if (unformat (i, "via %U", unformat_ip6_address,
6712 &v6_next_hop_address))
6715 next_hop_proto_is_ip4 = 0;
6717 else if (unformat (i, "weight %d", &next_hop_weight))
6719 else if (unformat (i, "create-table"))
6720 create_table_if_needed = 1;
6721 else if (unformat (i, "classify %d", &classify_table_index))
6725 else if (unformat (i, "del"))
6727 else if (unformat (i, "add"))
6729 else if (unformat (i, "resolve-via-host"))
6731 else if (unformat (i, "resolve-via-attached"))
6732 resolve_attached = 1;
6733 else if (unformat (i, "multipath"))
6735 else if (unformat (i, "count %d", &count))
6737 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6740 next_hop_proto_is_ip4 = 1;
6742 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6745 next_hop_proto_is_ip4 = 0;
6747 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6749 else if (unformat (i, "via-label %d", &next_hop_via_label))
6751 else if (unformat (i, "out-label %d", &next_hop_out_label))
6752 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6755 clib_warning ("parse error '%U'", format_unformat_error, i);
6760 if (!next_hop_set && !is_classify)
6762 errmsg ("next hop / classify not set");
6766 if (MPLS_LABEL_INVALID == local_label)
6768 errmsg ("missing label");
6774 /* Turn on async mode */
6775 vam->async_mode = 1;
6776 vam->async_errors = 0;
6777 before = vat_time_now (vam);
6780 for (j = 0; j < count; j++)
6782 /* Construct the API message */
6783 M2 (MPLS_ROUTE_ADD_DEL, mp,
6784 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6786 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6787 mp->mr_table_id = ntohl (table_id);
6788 mp->mr_create_table_if_needed = create_table_if_needed;
6790 mp->mr_is_add = is_add;
6791 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6792 mp->mr_is_classify = is_classify;
6793 mp->mr_is_multipath = is_multipath;
6794 mp->mr_is_resolve_host = resolve_host;
6795 mp->mr_is_resolve_attached = resolve_attached;
6796 mp->mr_next_hop_weight = next_hop_weight;
6797 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6798 mp->mr_classify_table_index = ntohl (classify_table_index);
6799 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6800 mp->mr_label = ntohl (local_label);
6801 mp->mr_eos = is_eos;
6803 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6804 if (0 != mp->mr_next_hop_n_out_labels)
6806 memcpy (mp->mr_next_hop_out_label_stack,
6807 next_hop_out_label_stack,
6808 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6809 vec_free (next_hop_out_label_stack);
6814 if (next_hop_proto_is_ip4)
6816 clib_memcpy (mp->mr_next_hop,
6817 &v4_next_hop_address,
6818 sizeof (v4_next_hop_address));
6822 clib_memcpy (mp->mr_next_hop,
6823 &v6_next_hop_address,
6824 sizeof (v6_next_hop_address));
6831 /* If we receive SIGTERM, stop now... */
6836 /* When testing multiple add/del ops, use a control-ping to sync */
6839 vl_api_control_ping_t *mp_ping;
6843 /* Shut off async mode */
6844 vam->async_mode = 0;
6846 M (CONTROL_PING, mp_ping);
6849 timeout = vat_time_now (vam) + 1.0;
6850 while (vat_time_now (vam) < timeout)
6851 if (vam->result_ready == 1)
6856 if (vam->retval == -99)
6859 if (vam->async_errors > 0)
6861 errmsg ("%d asynchronous errors", vam->async_errors);
6864 vam->async_errors = 0;
6865 after = vat_time_now (vam);
6867 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6871 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6872 count, after - before, count / (after - before));
6878 /* Wait for a reply... */
6883 /* Return the good/bad news */
6884 return (vam->retval);
6888 api_mpls_ip_bind_unbind (vat_main_t * vam)
6890 unformat_input_t *i = vam->input;
6891 vl_api_mpls_ip_bind_unbind_t *mp;
6892 u32 ip_table_id = 0;
6893 u8 create_table_if_needed = 0;
6896 ip4_address_t v4_address;
6897 ip6_address_t v6_address;
6900 mpls_label_t local_label = MPLS_LABEL_INVALID;
6903 /* Parse args required to build the message */
6904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6906 if (unformat (i, "%U/%d", unformat_ip4_address,
6907 &v4_address, &address_length))
6912 else if (unformat (i, "%U/%d", unformat_ip6_address,
6913 &v6_address, &address_length))
6918 else if (unformat (i, "%d", &local_label))
6920 else if (unformat (i, "create-table"))
6921 create_table_if_needed = 1;
6922 else if (unformat (i, "table-id %d", &ip_table_id))
6924 else if (unformat (i, "unbind"))
6926 else if (unformat (i, "bind"))
6930 clib_warning ("parse error '%U'", format_unformat_error, i);
6937 errmsg ("IP addres not set");
6941 if (MPLS_LABEL_INVALID == local_label)
6943 errmsg ("missing label");
6947 /* Construct the API message */
6948 M (MPLS_IP_BIND_UNBIND, mp);
6950 mp->mb_create_table_if_needed = create_table_if_needed;
6951 mp->mb_is_bind = is_bind;
6952 mp->mb_is_ip4 = is_ip4;
6953 mp->mb_ip_table_id = ntohl (ip_table_id);
6954 mp->mb_mpls_table_id = 0;
6955 mp->mb_label = ntohl (local_label);
6956 mp->mb_address_length = address_length;
6959 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
6961 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
6966 /* Wait for a reply... */
6972 api_proxy_arp_add_del (vat_main_t * vam)
6974 unformat_input_t *i = vam->input;
6975 vl_api_proxy_arp_add_del_t *mp;
6978 ip4_address_t lo, hi;
6982 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6984 if (unformat (i, "vrf %d", &vrf_id))
6986 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
6987 unformat_ip4_address, &hi))
6989 else if (unformat (i, "del"))
6993 clib_warning ("parse error '%U'", format_unformat_error, i);
7000 errmsg ("address range not set");
7004 M (PROXY_ARP_ADD_DEL, mp);
7006 mp->vrf_id = ntohl (vrf_id);
7007 mp->is_add = is_add;
7008 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7009 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7017 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7019 unformat_input_t *i = vam->input;
7020 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7023 u8 sw_if_index_set = 0;
7026 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7028 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7029 sw_if_index_set = 1;
7030 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7031 sw_if_index_set = 1;
7032 else if (unformat (i, "enable"))
7034 else if (unformat (i, "disable"))
7038 clib_warning ("parse error '%U'", format_unformat_error, i);
7043 if (sw_if_index_set == 0)
7045 errmsg ("missing interface name or sw_if_index");
7049 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7051 mp->sw_if_index = ntohl (sw_if_index);
7052 mp->enable_disable = enable;
7060 api_mpls_tunnel_add_del (vat_main_t * vam)
7062 unformat_input_t *i = vam->input;
7063 vl_api_mpls_tunnel_add_del_t *mp;
7067 u32 sw_if_index = ~0;
7068 u32 next_hop_sw_if_index = ~0;
7069 u32 next_hop_proto_is_ip4 = 1;
7071 u32 next_hop_table_id = 0;
7072 ip4_address_t v4_next_hop_address = {
7075 ip6_address_t v6_next_hop_address = { {0} };
7076 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7081 if (unformat (i, "add"))
7083 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7085 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7087 else if (unformat (i, "via %U",
7088 unformat_ip4_address, &v4_next_hop_address))
7090 next_hop_proto_is_ip4 = 1;
7092 else if (unformat (i, "via %U",
7093 unformat_ip6_address, &v6_next_hop_address))
7095 next_hop_proto_is_ip4 = 0;
7097 else if (unformat (i, "l2-only"))
7099 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7101 else if (unformat (i, "out-label %d", &next_hop_out_label))
7102 vec_add1 (labels, ntohl (next_hop_out_label));
7105 clib_warning ("parse error '%U'", format_unformat_error, i);
7110 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7112 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7113 mp->mt_sw_if_index = ntohl (sw_if_index);
7114 mp->mt_is_add = is_add;
7115 mp->mt_l2_only = l2_only;
7116 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7117 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7119 mp->mt_next_hop_n_out_labels = vec_len (labels);
7121 if (0 != mp->mt_next_hop_n_out_labels)
7123 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7124 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7128 if (next_hop_proto_is_ip4)
7130 clib_memcpy (mp->mt_next_hop,
7131 &v4_next_hop_address, sizeof (v4_next_hop_address));
7135 clib_memcpy (mp->mt_next_hop,
7136 &v6_next_hop_address, sizeof (v6_next_hop_address));
7145 api_sw_interface_set_unnumbered (vat_main_t * vam)
7147 unformat_input_t *i = vam->input;
7148 vl_api_sw_interface_set_unnumbered_t *mp;
7150 u32 unnum_sw_index = ~0;
7152 u8 sw_if_index_set = 0;
7155 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7157 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7158 sw_if_index_set = 1;
7159 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7160 sw_if_index_set = 1;
7161 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7163 else if (unformat (i, "del"))
7167 clib_warning ("parse error '%U'", format_unformat_error, i);
7172 if (sw_if_index_set == 0)
7174 errmsg ("missing interface name or sw_if_index");
7178 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7180 mp->sw_if_index = ntohl (sw_if_index);
7181 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7182 mp->is_add = is_add;
7190 api_ip_neighbor_add_del (vat_main_t * vam)
7192 unformat_input_t *i = vam->input;
7193 vl_api_ip_neighbor_add_del_t *mp;
7195 u8 sw_if_index_set = 0;
7198 u8 is_no_fib_entry = 0;
7201 u8 v4_address_set = 0;
7202 u8 v6_address_set = 0;
7203 ip4_address_t v4address;
7204 ip6_address_t v6address;
7207 memset (mac_address, 0, sizeof (mac_address));
7209 /* Parse args required to build the message */
7210 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7212 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7216 else if (unformat (i, "del"))
7219 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7220 sw_if_index_set = 1;
7221 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7222 sw_if_index_set = 1;
7223 else if (unformat (i, "is_static"))
7225 else if (unformat (i, "no-fib-entry"))
7226 is_no_fib_entry = 1;
7227 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7229 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7233 clib_warning ("parse error '%U'", format_unformat_error, i);
7238 if (sw_if_index_set == 0)
7240 errmsg ("missing interface name or sw_if_index");
7243 if (v4_address_set && v6_address_set)
7245 errmsg ("both v4 and v6 addresses set");
7248 if (!v4_address_set && !v6_address_set)
7250 errmsg ("no address set");
7254 /* Construct the API message */
7255 M (IP_NEIGHBOR_ADD_DEL, mp);
7257 mp->sw_if_index = ntohl (sw_if_index);
7258 mp->is_add = is_add;
7259 mp->is_static = is_static;
7260 mp->is_no_adj_fib = is_no_fib_entry;
7262 clib_memcpy (mp->mac_address, mac_address, 6);
7266 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7270 /* mp->is_ipv6 = 0; via memset in M macro above */
7271 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7277 /* Wait for a reply, return good/bad news */
7283 api_reset_vrf (vat_main_t * vam)
7285 unformat_input_t *i = vam->input;
7286 vl_api_reset_vrf_t *mp;
7292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7294 if (unformat (i, "vrf %d", &vrf_id))
7296 else if (unformat (i, "ipv6"))
7300 clib_warning ("parse error '%U'", format_unformat_error, i);
7305 if (vrf_id_set == 0)
7307 errmsg ("missing vrf id");
7313 mp->vrf_id = ntohl (vrf_id);
7314 mp->is_ipv6 = is_ipv6;
7322 api_create_vlan_subif (vat_main_t * vam)
7324 unformat_input_t *i = vam->input;
7325 vl_api_create_vlan_subif_t *mp;
7327 u8 sw_if_index_set = 0;
7332 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7334 if (unformat (i, "sw_if_index %d", &sw_if_index))
7335 sw_if_index_set = 1;
7337 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7338 sw_if_index_set = 1;
7339 else if (unformat (i, "vlan %d", &vlan_id))
7343 clib_warning ("parse error '%U'", format_unformat_error, i);
7348 if (sw_if_index_set == 0)
7350 errmsg ("missing interface name or sw_if_index");
7354 if (vlan_id_set == 0)
7356 errmsg ("missing vlan_id");
7359 M (CREATE_VLAN_SUBIF, mp);
7361 mp->sw_if_index = ntohl (sw_if_index);
7362 mp->vlan_id = ntohl (vlan_id);
7369 #define foreach_create_subif_bit \
7376 _(outer_vlan_id_any) \
7377 _(inner_vlan_id_any)
7380 api_create_subif (vat_main_t * vam)
7382 unformat_input_t *i = vam->input;
7383 vl_api_create_subif_t *mp;
7385 u8 sw_if_index_set = 0;
7392 u32 exact_match = 0;
7393 u32 default_sub = 0;
7394 u32 outer_vlan_id_any = 0;
7395 u32 inner_vlan_id_any = 0;
7397 u16 outer_vlan_id = 0;
7398 u16 inner_vlan_id = 0;
7401 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7403 if (unformat (i, "sw_if_index %d", &sw_if_index))
7404 sw_if_index_set = 1;
7406 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7407 sw_if_index_set = 1;
7408 else if (unformat (i, "sub_id %d", &sub_id))
7410 else if (unformat (i, "outer_vlan_id %d", &tmp))
7411 outer_vlan_id = tmp;
7412 else if (unformat (i, "inner_vlan_id %d", &tmp))
7413 inner_vlan_id = tmp;
7415 #define _(a) else if (unformat (i, #a)) a = 1 ;
7416 foreach_create_subif_bit
7420 clib_warning ("parse error '%U'", format_unformat_error, i);
7425 if (sw_if_index_set == 0)
7427 errmsg ("missing interface name or sw_if_index");
7431 if (sub_id_set == 0)
7433 errmsg ("missing sub_id");
7436 M (CREATE_SUBIF, mp);
7438 mp->sw_if_index = ntohl (sw_if_index);
7439 mp->sub_id = ntohl (sub_id);
7441 #define _(a) mp->a = a;
7442 foreach_create_subif_bit;
7445 mp->outer_vlan_id = ntohs (outer_vlan_id);
7446 mp->inner_vlan_id = ntohs (inner_vlan_id);
7454 api_oam_add_del (vat_main_t * vam)
7456 unformat_input_t *i = vam->input;
7457 vl_api_oam_add_del_t *mp;
7460 ip4_address_t src, dst;
7465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7467 if (unformat (i, "vrf %d", &vrf_id))
7469 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7471 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7473 else if (unformat (i, "del"))
7477 clib_warning ("parse error '%U'", format_unformat_error, i);
7484 errmsg ("missing src addr");
7490 errmsg ("missing dst addr");
7494 M (OAM_ADD_DEL, mp);
7496 mp->vrf_id = ntohl (vrf_id);
7497 mp->is_add = is_add;
7498 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7499 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7507 api_reset_fib (vat_main_t * vam)
7509 unformat_input_t *i = vam->input;
7510 vl_api_reset_fib_t *mp;
7516 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7518 if (unformat (i, "vrf %d", &vrf_id))
7520 else if (unformat (i, "ipv6"))
7524 clib_warning ("parse error '%U'", format_unformat_error, i);
7529 if (vrf_id_set == 0)
7531 errmsg ("missing vrf id");
7537 mp->vrf_id = ntohl (vrf_id);
7538 mp->is_ipv6 = is_ipv6;
7546 api_dhcp_proxy_config (vat_main_t * vam)
7548 unformat_input_t *i = vam->input;
7549 vl_api_dhcp_proxy_config_t *mp;
7551 u32 server_vrf_id = 0;
7553 u8 v4_address_set = 0;
7554 u8 v6_address_set = 0;
7555 ip4_address_t v4address;
7556 ip6_address_t v6address;
7557 u8 v4_src_address_set = 0;
7558 u8 v6_src_address_set = 0;
7559 ip4_address_t v4srcaddress;
7560 ip6_address_t v6srcaddress;
7563 /* Parse args required to build the message */
7564 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7566 if (unformat (i, "del"))
7568 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7570 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7572 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7574 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7576 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7577 v4_src_address_set = 1;
7578 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7579 v6_src_address_set = 1;
7584 if (v4_address_set && v6_address_set)
7586 errmsg ("both v4 and v6 server addresses set");
7589 if (!v4_address_set && !v6_address_set)
7591 errmsg ("no server addresses set");
7595 if (v4_src_address_set && v6_src_address_set)
7597 errmsg ("both v4 and v6 src addresses set");
7600 if (!v4_src_address_set && !v6_src_address_set)
7602 errmsg ("no src addresses set");
7606 if (!(v4_src_address_set && v4_address_set) &&
7607 !(v6_src_address_set && v6_address_set))
7609 errmsg ("no matching server and src addresses set");
7613 /* Construct the API message */
7614 M (DHCP_PROXY_CONFIG, mp);
7616 mp->is_add = is_add;
7617 mp->rx_vrf_id = ntohl (rx_vrf_id);
7618 mp->server_vrf_id = ntohl (server_vrf_id);
7622 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7623 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7627 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7628 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7634 /* Wait for a reply, return good/bad news */
7639 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
7640 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
7643 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
7645 vat_main_t *vam = &vat_main;
7646 u32 i, count = mp->count;
7647 vl_api_dhcp_server_t *s;
7651 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7652 ntohl (mp->rx_vrf_id),
7653 format_ip6_address, mp->dhcp_src_address,
7654 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7657 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7658 ntohl (mp->rx_vrf_id),
7659 format_ip4_address, mp->dhcp_src_address,
7660 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7662 for (i = 0; i < count; i++)
7664 s = &mp->servers[i];
7668 " Server Table-ID %d, Server Address %U",
7669 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
7672 " Server Table-ID %d, Server Address %U",
7673 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
7677 static void vl_api_dhcp_proxy_details_t_handler_json
7678 (vl_api_dhcp_proxy_details_t * mp)
7680 vat_main_t *vam = &vat_main;
7681 vat_json_node_t *node = NULL;
7682 u32 i, count = mp->count;
7684 struct in6_addr ip6;
7685 vl_api_dhcp_server_t *s;
7687 if (VAT_JSON_ARRAY != vam->json_tree.type)
7689 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7690 vat_json_init_array (&vam->json_tree);
7692 node = vat_json_array_add (&vam->json_tree);
7694 vat_json_init_object (node);
7695 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
7696 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
7697 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
7701 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
7702 vat_json_object_add_ip6 (node, "src_address", ip6);
7706 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
7707 vat_json_object_add_ip4 (node, "src_address", ip4);
7710 for (i = 0; i < count; i++)
7712 s = &mp->servers[i];
7714 vat_json_object_add_uint (node, "server-table-id",
7715 ntohl (s->server_vrf_id));
7719 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
7720 vat_json_object_add_ip4 (node, "src_address", ip4);
7724 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
7725 vat_json_object_add_ip6 (node, "server_address", ip6);
7731 api_dhcp_proxy_dump (vat_main_t * vam)
7733 unformat_input_t *i = vam->input;
7734 vl_api_control_ping_t *mp_ping;
7735 vl_api_dhcp_proxy_dump_t *mp;
7739 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7741 if (unformat (i, "ipv6"))
7745 clib_warning ("parse error '%U'", format_unformat_error, i);
7750 M (DHCP_PROXY_DUMP, mp);
7752 mp->is_ip6 = is_ipv6;
7755 /* Use a control ping for synchronization */
7756 M (CONTROL_PING, mp_ping);
7764 api_dhcp_proxy_set_vss (vat_main_t * vam)
7766 unformat_input_t *i = vam->input;
7767 vl_api_dhcp_proxy_set_vss_t *mp;
7778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7780 if (unformat (i, "tbl_id %d", &tbl_id))
7782 if (unformat (i, "fib_id %d", &fib_id))
7784 if (unformat (i, "oui %d", &oui))
7786 else if (unformat (i, "ipv6"))
7788 else if (unformat (i, "del"))
7792 clib_warning ("parse error '%U'", format_unformat_error, i);
7797 if (tbl_id_set == 0)
7799 errmsg ("missing tbl id");
7803 if (fib_id_set == 0)
7805 errmsg ("missing fib id");
7810 errmsg ("missing oui");
7814 M (DHCP_PROXY_SET_VSS, mp);
7815 mp->tbl_id = ntohl (tbl_id);
7816 mp->fib_id = ntohl (fib_id);
7817 mp->oui = ntohl (oui);
7818 mp->is_ipv6 = is_ipv6;
7819 mp->is_add = is_add;
7827 api_dhcp_client_config (vat_main_t * vam)
7829 unformat_input_t *i = vam->input;
7830 vl_api_dhcp_client_config_t *mp;
7832 u8 sw_if_index_set = 0;
7835 u8 disable_event = 0;
7838 /* Parse args required to build the message */
7839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7841 if (unformat (i, "del"))
7844 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7845 sw_if_index_set = 1;
7846 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7847 sw_if_index_set = 1;
7848 else if (unformat (i, "hostname %s", &hostname))
7850 else if (unformat (i, "disable_event"))
7856 if (sw_if_index_set == 0)
7858 errmsg ("missing interface name or sw_if_index");
7862 if (vec_len (hostname) > 63)
7864 errmsg ("hostname too long");
7866 vec_add1 (hostname, 0);
7868 /* Construct the API message */
7869 M (DHCP_CLIENT_CONFIG, mp);
7871 mp->sw_if_index = ntohl (sw_if_index);
7872 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7873 vec_free (hostname);
7874 mp->is_add = is_add;
7875 mp->want_dhcp_event = disable_event ? 0 : 1;
7876 mp->pid = getpid ();
7881 /* Wait for a reply, return good/bad news */
7887 api_set_ip_flow_hash (vat_main_t * vam)
7889 unformat_input_t *i = vam->input;
7890 vl_api_set_ip_flow_hash_t *mp;
7902 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7904 if (unformat (i, "vrf %d", &vrf_id))
7906 else if (unformat (i, "ipv6"))
7908 else if (unformat (i, "src"))
7910 else if (unformat (i, "dst"))
7912 else if (unformat (i, "sport"))
7914 else if (unformat (i, "dport"))
7916 else if (unformat (i, "proto"))
7918 else if (unformat (i, "reverse"))
7923 clib_warning ("parse error '%U'", format_unformat_error, i);
7928 if (vrf_id_set == 0)
7930 errmsg ("missing vrf id");
7934 M (SET_IP_FLOW_HASH, mp);
7940 mp->reverse = reverse;
7941 mp->vrf_id = ntohl (vrf_id);
7942 mp->is_ipv6 = is_ipv6;
7950 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7952 unformat_input_t *i = vam->input;
7953 vl_api_sw_interface_ip6_enable_disable_t *mp;
7955 u8 sw_if_index_set = 0;
7959 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7961 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7962 sw_if_index_set = 1;
7963 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7964 sw_if_index_set = 1;
7965 else if (unformat (i, "enable"))
7967 else if (unformat (i, "disable"))
7971 clib_warning ("parse error '%U'", format_unformat_error, i);
7976 if (sw_if_index_set == 0)
7978 errmsg ("missing interface name or sw_if_index");
7982 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
7984 mp->sw_if_index = ntohl (sw_if_index);
7985 mp->enable = enable;
7993 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7995 unformat_input_t *i = vam->input;
7996 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7998 u8 sw_if_index_set = 0;
7999 u8 v6_address_set = 0;
8000 ip6_address_t v6address;
8003 /* Parse args required to build the message */
8004 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8006 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8007 sw_if_index_set = 1;
8008 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8009 sw_if_index_set = 1;
8010 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8016 if (sw_if_index_set == 0)
8018 errmsg ("missing interface name or sw_if_index");
8021 if (!v6_address_set)
8023 errmsg ("no address set");
8027 /* Construct the API message */
8028 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8030 mp->sw_if_index = ntohl (sw_if_index);
8031 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8036 /* Wait for a reply, return good/bad news */
8042 api_ip6nd_proxy_add_del (vat_main_t * vam)
8044 unformat_input_t *i = vam->input;
8045 vl_api_ip6nd_proxy_add_del_t *mp;
8046 u32 sw_if_index = ~0;
8047 u8 v6_address_set = 0;
8048 ip6_address_t v6address;
8052 /* Parse args required to build the message */
8053 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8055 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8057 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8059 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8061 if (unformat (i, "del"))
8065 clib_warning ("parse error '%U'", format_unformat_error, i);
8070 if (sw_if_index == ~0)
8072 errmsg ("missing interface name or sw_if_index");
8075 if (!v6_address_set)
8077 errmsg ("no address set");
8081 /* Construct the API message */
8082 M (IP6ND_PROXY_ADD_DEL, mp);
8084 mp->is_del = is_del;
8085 mp->sw_if_index = ntohl (sw_if_index);
8086 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8091 /* Wait for a reply, return good/bad news */
8097 api_ip6nd_proxy_dump (vat_main_t * vam)
8099 vl_api_ip6nd_proxy_dump_t *mp;
8100 vl_api_control_ping_t *mp_ping;
8103 M (IP6ND_PROXY_DUMP, mp);
8107 /* Use a control ping for synchronization */
8108 M (CONTROL_PING, mp_ping);
8115 static void vl_api_ip6nd_proxy_details_t_handler
8116 (vl_api_ip6nd_proxy_details_t * mp)
8118 vat_main_t *vam = &vat_main;
8120 print (vam->ofp, "host %U sw_if_index %d",
8121 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
8124 static void vl_api_ip6nd_proxy_details_t_handler_json
8125 (vl_api_ip6nd_proxy_details_t * mp)
8127 vat_main_t *vam = &vat_main;
8128 struct in6_addr ip6;
8129 vat_json_node_t *node = NULL;
8131 if (VAT_JSON_ARRAY != vam->json_tree.type)
8133 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8134 vat_json_init_array (&vam->json_tree);
8136 node = vat_json_array_add (&vam->json_tree);
8138 vat_json_init_object (node);
8139 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
8141 clib_memcpy (&ip6, mp->address, sizeof (ip6));
8142 vat_json_object_add_ip6 (node, "host", ip6);
8146 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8148 unformat_input_t *i = vam->input;
8149 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8151 u8 sw_if_index_set = 0;
8152 u32 address_length = 0;
8153 u8 v6_address_set = 0;
8154 ip6_address_t v6address;
8156 u8 no_advertise = 0;
8158 u8 no_autoconfig = 0;
8161 u32 val_lifetime = 0;
8162 u32 pref_lifetime = 0;
8165 /* Parse args required to build the message */
8166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8168 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8169 sw_if_index_set = 1;
8170 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8171 sw_if_index_set = 1;
8172 else if (unformat (i, "%U/%d",
8173 unformat_ip6_address, &v6address, &address_length))
8175 else if (unformat (i, "val_life %d", &val_lifetime))
8177 else if (unformat (i, "pref_life %d", &pref_lifetime))
8179 else if (unformat (i, "def"))
8181 else if (unformat (i, "noadv"))
8183 else if (unformat (i, "offl"))
8185 else if (unformat (i, "noauto"))
8187 else if (unformat (i, "nolink"))
8189 else if (unformat (i, "isno"))
8193 clib_warning ("parse error '%U'", format_unformat_error, i);
8198 if (sw_if_index_set == 0)
8200 errmsg ("missing interface name or sw_if_index");
8203 if (!v6_address_set)
8205 errmsg ("no address set");
8209 /* Construct the API message */
8210 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8212 mp->sw_if_index = ntohl (sw_if_index);
8213 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8214 mp->address_length = address_length;
8215 mp->use_default = use_default;
8216 mp->no_advertise = no_advertise;
8217 mp->off_link = off_link;
8218 mp->no_autoconfig = no_autoconfig;
8219 mp->no_onlink = no_onlink;
8221 mp->val_lifetime = ntohl (val_lifetime);
8222 mp->pref_lifetime = ntohl (pref_lifetime);
8227 /* Wait for a reply, return good/bad news */
8233 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8235 unformat_input_t *i = vam->input;
8236 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8238 u8 sw_if_index_set = 0;
8243 u8 send_unicast = 0;
8246 u8 default_router = 0;
8247 u32 max_interval = 0;
8248 u32 min_interval = 0;
8250 u32 initial_count = 0;
8251 u32 initial_interval = 0;
8255 /* Parse args required to build the message */
8256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8258 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8259 sw_if_index_set = 1;
8260 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8261 sw_if_index_set = 1;
8262 else if (unformat (i, "maxint %d", &max_interval))
8264 else if (unformat (i, "minint %d", &min_interval))
8266 else if (unformat (i, "life %d", &lifetime))
8268 else if (unformat (i, "count %d", &initial_count))
8270 else if (unformat (i, "interval %d", &initial_interval))
8272 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8274 else if (unformat (i, "managed"))
8276 else if (unformat (i, "other"))
8278 else if (unformat (i, "ll"))
8280 else if (unformat (i, "send"))
8282 else if (unformat (i, "cease"))
8284 else if (unformat (i, "isno"))
8286 else if (unformat (i, "def"))
8290 clib_warning ("parse error '%U'", format_unformat_error, i);
8295 if (sw_if_index_set == 0)
8297 errmsg ("missing interface name or sw_if_index");
8301 /* Construct the API message */
8302 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8304 mp->sw_if_index = ntohl (sw_if_index);
8305 mp->max_interval = ntohl (max_interval);
8306 mp->min_interval = ntohl (min_interval);
8307 mp->lifetime = ntohl (lifetime);
8308 mp->initial_count = ntohl (initial_count);
8309 mp->initial_interval = ntohl (initial_interval);
8310 mp->suppress = suppress;
8311 mp->managed = managed;
8313 mp->ll_option = ll_option;
8314 mp->send_unicast = send_unicast;
8317 mp->default_router = default_router;
8322 /* Wait for a reply, return good/bad news */
8328 api_set_arp_neighbor_limit (vat_main_t * vam)
8330 unformat_input_t *i = vam->input;
8331 vl_api_set_arp_neighbor_limit_t *mp;
8337 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8339 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8341 else if (unformat (i, "ipv6"))
8345 clib_warning ("parse error '%U'", format_unformat_error, i);
8352 errmsg ("missing limit value");
8356 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8358 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8359 mp->is_ipv6 = is_ipv6;
8367 api_l2_patch_add_del (vat_main_t * vam)
8369 unformat_input_t *i = vam->input;
8370 vl_api_l2_patch_add_del_t *mp;
8372 u8 rx_sw_if_index_set = 0;
8374 u8 tx_sw_if_index_set = 0;
8378 /* Parse args required to build the message */
8379 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8381 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8382 rx_sw_if_index_set = 1;
8383 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8384 tx_sw_if_index_set = 1;
8385 else if (unformat (i, "rx"))
8387 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8389 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8391 rx_sw_if_index_set = 1;
8396 else if (unformat (i, "tx"))
8398 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8400 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8402 tx_sw_if_index_set = 1;
8407 else if (unformat (i, "del"))
8413 if (rx_sw_if_index_set == 0)
8415 errmsg ("missing rx interface name or rx_sw_if_index");
8419 if (tx_sw_if_index_set == 0)
8421 errmsg ("missing tx interface name or tx_sw_if_index");
8425 M (L2_PATCH_ADD_DEL, mp);
8427 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8428 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8429 mp->is_add = is_add;
8437 u8 localsid_addr[16];
8446 api_sr_localsid_add_del (vat_main_t * vam)
8448 unformat_input_t *i = vam->input;
8449 vl_api_sr_localsid_add_del_t *mp;
8452 ip6_address_t localsid;
8456 u32 fib_table = ~(u32) 0;
8457 ip6_address_t next_hop;
8459 bool nexthop_set = 0;
8463 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8465 if (unformat (i, "del"))
8467 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
8468 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
8470 else if (unformat (i, "behavior %u", &behavior));
8471 else if (unformat (i, "sw_if_index %u", &sw_if_index));
8472 else if (unformat (i, "fib-table %u", &fib_table));
8473 else if (unformat (i, "end.psp %u", &behavior));
8478 M (SR_LOCALSID_ADD_DEL, mp);
8480 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
8482 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
8483 mp->behavior = behavior;
8484 mp->sw_if_index = ntohl (sw_if_index);
8485 mp->fib_table = ntohl (fib_table);
8486 mp->end_psp = end_psp;
8487 mp->is_del = is_del;
8495 api_ioam_enable (vat_main_t * vam)
8497 unformat_input_t *input = vam->input;
8498 vl_api_ioam_enable_t *mp;
8500 int has_trace_option = 0;
8501 int has_pot_option = 0;
8502 int has_seqno_option = 0;
8503 int has_analyse_option = 0;
8506 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8508 if (unformat (input, "trace"))
8509 has_trace_option = 1;
8510 else if (unformat (input, "pot"))
8512 else if (unformat (input, "seqno"))
8513 has_seqno_option = 1;
8514 else if (unformat (input, "analyse"))
8515 has_analyse_option = 1;
8519 M (IOAM_ENABLE, mp);
8520 mp->id = htons (id);
8521 mp->seqno = has_seqno_option;
8522 mp->analyse = has_analyse_option;
8523 mp->pot_enable = has_pot_option;
8524 mp->trace_enable = has_trace_option;
8533 api_ioam_disable (vat_main_t * vam)
8535 vl_api_ioam_disable_t *mp;
8538 M (IOAM_DISABLE, mp);
8544 #define foreach_tcp_proto_field \
8548 #define foreach_udp_proto_field \
8552 #define foreach_ip4_proto_field \
8564 u16 src_port, dst_port;
8567 #if VPP_API_TEST_BUILTIN == 0
8569 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8571 u8 **maskp = va_arg (*args, u8 **);
8573 u8 found_something = 0;
8576 #define _(a) u8 a=0;
8577 foreach_tcp_proto_field;
8580 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8583 #define _(a) else if (unformat (input, #a)) a=1;
8584 foreach_tcp_proto_field
8590 #define _(a) found_something += a;
8591 foreach_tcp_proto_field;
8594 if (found_something == 0)
8597 vec_validate (mask, sizeof (*tcp) - 1);
8599 tcp = (tcp_header_t *) mask;
8601 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8602 foreach_tcp_proto_field;
8610 unformat_udp_mask (unformat_input_t * input, va_list * args)
8612 u8 **maskp = va_arg (*args, u8 **);
8614 u8 found_something = 0;
8617 #define _(a) u8 a=0;
8618 foreach_udp_proto_field;
8621 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8624 #define _(a) else if (unformat (input, #a)) a=1;
8625 foreach_udp_proto_field
8631 #define _(a) found_something += a;
8632 foreach_udp_proto_field;
8635 if (found_something == 0)
8638 vec_validate (mask, sizeof (*udp) - 1);
8640 udp = (udp_header_t *) mask;
8642 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8643 foreach_udp_proto_field;
8651 unformat_l4_mask (unformat_input_t * input, va_list * args)
8653 u8 **maskp = va_arg (*args, u8 **);
8654 u16 src_port = 0, dst_port = 0;
8655 tcpudp_header_t *tcpudp;
8657 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8659 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8661 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8663 else if (unformat (input, "src_port"))
8665 else if (unformat (input, "dst_port"))
8671 if (!src_port && !dst_port)
8675 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8677 tcpudp = (tcpudp_header_t *) mask;
8678 tcpudp->src_port = src_port;
8679 tcpudp->dst_port = dst_port;
8687 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8689 u8 **maskp = va_arg (*args, u8 **);
8691 u8 found_something = 0;
8694 #define _(a) u8 a=0;
8695 foreach_ip4_proto_field;
8701 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8703 if (unformat (input, "version"))
8705 else if (unformat (input, "hdr_length"))
8707 else if (unformat (input, "src"))
8709 else if (unformat (input, "dst"))
8711 else if (unformat (input, "proto"))
8714 #define _(a) else if (unformat (input, #a)) a=1;
8715 foreach_ip4_proto_field
8721 #define _(a) found_something += a;
8722 foreach_ip4_proto_field;
8725 if (found_something == 0)
8728 vec_validate (mask, sizeof (*ip) - 1);
8730 ip = (ip4_header_t *) mask;
8732 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8733 foreach_ip4_proto_field;
8736 ip->ip_version_and_header_length = 0;
8739 ip->ip_version_and_header_length |= 0xF0;
8742 ip->ip_version_and_header_length |= 0x0F;
8748 #define foreach_ip6_proto_field \
8756 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8758 u8 **maskp = va_arg (*args, u8 **);
8760 u8 found_something = 0;
8762 u32 ip_version_traffic_class_and_flow_label;
8764 #define _(a) u8 a=0;
8765 foreach_ip6_proto_field;
8768 u8 traffic_class = 0;
8771 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8773 if (unformat (input, "version"))
8775 else if (unformat (input, "traffic-class"))
8777 else if (unformat (input, "flow-label"))
8779 else if (unformat (input, "src"))
8781 else if (unformat (input, "dst"))
8783 else if (unformat (input, "proto"))
8786 #define _(a) else if (unformat (input, #a)) a=1;
8787 foreach_ip6_proto_field
8793 #define _(a) found_something += a;
8794 foreach_ip6_proto_field;
8797 if (found_something == 0)
8800 vec_validate (mask, sizeof (*ip) - 1);
8802 ip = (ip6_header_t *) mask;
8804 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8805 foreach_ip6_proto_field;
8808 ip_version_traffic_class_and_flow_label = 0;
8811 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8814 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8817 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8819 ip->ip_version_traffic_class_and_flow_label =
8820 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8827 unformat_l3_mask (unformat_input_t * input, va_list * args)
8829 u8 **maskp = va_arg (*args, u8 **);
8831 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8833 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8835 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8844 unformat_l2_mask (unformat_input_t * input, va_list * args)
8846 u8 **maskp = va_arg (*args, u8 **);
8861 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8863 if (unformat (input, "src"))
8865 else if (unformat (input, "dst"))
8867 else if (unformat (input, "proto"))
8869 else if (unformat (input, "tag1"))
8871 else if (unformat (input, "tag2"))
8873 else if (unformat (input, "ignore-tag1"))
8875 else if (unformat (input, "ignore-tag2"))
8877 else if (unformat (input, "cos1"))
8879 else if (unformat (input, "cos2"))
8881 else if (unformat (input, "dot1q"))
8883 else if (unformat (input, "dot1ad"))
8888 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8889 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8892 if (tag1 || ignore_tag1 || cos1 || dot1q)
8894 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8897 vec_validate (mask, len - 1);
8900 memset (mask, 0xff, 6);
8903 memset (mask + 6, 0xff, 6);
8907 /* inner vlan tag */
8916 mask[21] = mask[20] = 0xff;
8937 mask[16] = mask[17] = 0xff;
8947 mask[12] = mask[13] = 0xff;
8954 unformat_classify_mask (unformat_input_t * input, va_list * args)
8956 u8 **maskp = va_arg (*args, u8 **);
8957 u32 *skipp = va_arg (*args, u32 *);
8958 u32 *matchp = va_arg (*args, u32 *);
8966 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8968 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8970 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8972 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8974 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
8988 if (mask || l2 || l3 || l4)
8992 /* "With a free Ethernet header in every package" */
8994 vec_validate (l2, 13);
8998 vec_append (mask, l3);
9003 vec_append (mask, l4);
9008 /* Scan forward looking for the first significant mask octet */
9009 for (i = 0; i < vec_len (mask); i++)
9013 /* compute (skip, match) params */
9014 *skipp = i / sizeof (u32x4);
9015 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9017 /* Pad mask to an even multiple of the vector size */
9018 while (vec_len (mask) % sizeof (u32x4))
9021 match = vec_len (mask) / sizeof (u32x4);
9023 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9025 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9026 if (*tmp || *(tmp + 1))
9031 clib_warning ("BUG: match 0");
9033 _vec_len (mask) = match * sizeof (u32x4);
9043 #endif /* VPP_API_TEST_BUILTIN */
9045 #define foreach_l2_next \
9047 _(ethernet, ETHERNET_INPUT) \
9052 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9054 u32 *miss_next_indexp = va_arg (*args, u32 *);
9059 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9063 if (unformat (input, "%d", &tmp))
9072 *miss_next_indexp = next_index;
9076 #define foreach_ip_next \
9082 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9084 u32 *miss_next_indexp = va_arg (*args, u32 *);
9089 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9093 if (unformat (input, "%d", &tmp))
9102 *miss_next_indexp = next_index;
9106 #define foreach_acl_next \
9110 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9112 u32 *miss_next_indexp = va_arg (*args, u32 *);
9117 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9121 if (unformat (input, "permit"))
9126 else if (unformat (input, "%d", &tmp))
9135 *miss_next_indexp = next_index;
9140 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9142 u32 *r = va_arg (*args, u32 *);
9144 if (unformat (input, "conform-color"))
9145 *r = POLICE_CONFORM;
9146 else if (unformat (input, "exceed-color"))
9155 api_classify_add_del_table (vat_main_t * vam)
9157 unformat_input_t *i = vam->input;
9158 vl_api_classify_add_del_table_t *mp;
9165 u32 table_index = ~0;
9166 u32 next_table_index = ~0;
9167 u32 miss_next_index = ~0;
9168 u32 memory_size = 32 << 20;
9170 u32 current_data_flag = 0;
9171 int current_data_offset = 0;
9174 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9176 if (unformat (i, "del"))
9178 else if (unformat (i, "del-chain"))
9183 else if (unformat (i, "buckets %d", &nbuckets))
9185 else if (unformat (i, "memory_size %d", &memory_size))
9187 else if (unformat (i, "skip %d", &skip))
9189 else if (unformat (i, "match %d", &match))
9191 else if (unformat (i, "table %d", &table_index))
9193 else if (unformat (i, "mask %U", unformat_classify_mask,
9194 &mask, &skip, &match))
9196 else if (unformat (i, "next-table %d", &next_table_index))
9198 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9201 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9204 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9207 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9209 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9215 if (is_add && mask == 0)
9217 errmsg ("Mask required");
9221 if (is_add && skip == ~0)
9223 errmsg ("skip count required");
9227 if (is_add && match == ~0)
9229 errmsg ("match count required");
9233 if (!is_add && table_index == ~0)
9235 errmsg ("table index required for delete");
9239 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9241 mp->is_add = is_add;
9242 mp->del_chain = del_chain;
9243 mp->table_index = ntohl (table_index);
9244 mp->nbuckets = ntohl (nbuckets);
9245 mp->memory_size = ntohl (memory_size);
9246 mp->skip_n_vectors = ntohl (skip);
9247 mp->match_n_vectors = ntohl (match);
9248 mp->next_table_index = ntohl (next_table_index);
9249 mp->miss_next_index = ntohl (miss_next_index);
9250 mp->current_data_flag = ntohl (current_data_flag);
9251 mp->current_data_offset = ntohl (current_data_offset);
9252 clib_memcpy (mp->mask, mask, vec_len (mask));
9261 #if VPP_API_TEST_BUILTIN == 0
9263 unformat_l4_match (unformat_input_t * input, va_list * args)
9265 u8 **matchp = va_arg (*args, u8 **);
9267 u8 *proto_header = 0;
9273 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9275 if (unformat (input, "src_port %d", &src_port))
9277 else if (unformat (input, "dst_port %d", &dst_port))
9283 h.src_port = clib_host_to_net_u16 (src_port);
9284 h.dst_port = clib_host_to_net_u16 (dst_port);
9285 vec_validate (proto_header, sizeof (h) - 1);
9286 memcpy (proto_header, &h, sizeof (h));
9288 *matchp = proto_header;
9294 unformat_ip4_match (unformat_input_t * input, va_list * args)
9296 u8 **matchp = va_arg (*args, u8 **);
9303 int src = 0, dst = 0;
9304 ip4_address_t src_val, dst_val;
9311 int fragment_id = 0;
9312 u32 fragment_id_val;
9318 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9320 if (unformat (input, "version %d", &version_val))
9322 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9324 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9326 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9328 else if (unformat (input, "proto %d", &proto_val))
9330 else if (unformat (input, "tos %d", &tos_val))
9332 else if (unformat (input, "length %d", &length_val))
9334 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9336 else if (unformat (input, "ttl %d", &ttl_val))
9338 else if (unformat (input, "checksum %d", &checksum_val))
9344 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9345 + ttl + checksum == 0)
9349 * Aligned because we use the real comparison functions
9351 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9353 ip = (ip4_header_t *) match;
9355 /* These are realistically matched in practice */
9357 ip->src_address.as_u32 = src_val.as_u32;
9360 ip->dst_address.as_u32 = dst_val.as_u32;
9363 ip->protocol = proto_val;
9366 /* These are not, but they're included for completeness */
9368 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9371 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9377 ip->length = clib_host_to_net_u16 (length_val);
9383 ip->checksum = clib_host_to_net_u16 (checksum_val);
9390 unformat_ip6_match (unformat_input_t * input, va_list * args)
9392 u8 **matchp = va_arg (*args, u8 **);
9397 u8 traffic_class = 0;
9398 u32 traffic_class_val = 0;
9401 int src = 0, dst = 0;
9402 ip6_address_t src_val, dst_val;
9405 int payload_length = 0;
9406 u32 payload_length_val;
9409 u32 ip_version_traffic_class_and_flow_label;
9411 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9413 if (unformat (input, "version %d", &version_val))
9415 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9417 else if (unformat (input, "flow_label %d", &flow_label_val))
9419 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9421 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9423 else if (unformat (input, "proto %d", &proto_val))
9425 else if (unformat (input, "payload_length %d", &payload_length_val))
9427 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9433 if (version + traffic_class + flow_label + src + dst + proto +
9434 payload_length + hop_limit == 0)
9438 * Aligned because we use the real comparison functions
9440 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9442 ip = (ip6_header_t *) match;
9445 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9448 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9451 ip->protocol = proto_val;
9453 ip_version_traffic_class_and_flow_label = 0;
9456 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9459 ip_version_traffic_class_and_flow_label |=
9460 (traffic_class_val & 0xFF) << 20;
9463 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9465 ip->ip_version_traffic_class_and_flow_label =
9466 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9469 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9472 ip->hop_limit = hop_limit_val;
9479 unformat_l3_match (unformat_input_t * input, va_list * args)
9481 u8 **matchp = va_arg (*args, u8 **);
9483 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9485 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9487 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9496 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9498 u8 *tagp = va_arg (*args, u8 *);
9501 if (unformat (input, "%d", &tag))
9503 tagp[0] = (tag >> 8) & 0x0F;
9504 tagp[1] = tag & 0xFF;
9512 unformat_l2_match (unformat_input_t * input, va_list * args)
9514 u8 **matchp = va_arg (*args, u8 **);
9534 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9536 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9539 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9541 else if (unformat (input, "proto %U",
9542 unformat_ethernet_type_host_byte_order, &proto_val))
9544 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9546 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9548 else if (unformat (input, "ignore-tag1"))
9550 else if (unformat (input, "ignore-tag2"))
9552 else if (unformat (input, "cos1 %d", &cos1_val))
9554 else if (unformat (input, "cos2 %d", &cos2_val))
9559 if ((src + dst + proto + tag1 + tag2 +
9560 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9563 if (tag1 || ignore_tag1 || cos1)
9565 if (tag2 || ignore_tag2 || cos2)
9568 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9571 clib_memcpy (match, dst_val, 6);
9574 clib_memcpy (match + 6, src_val, 6);
9578 /* inner vlan tag */
9579 match[19] = tag2_val[1];
9580 match[18] = tag2_val[0];
9582 match[18] |= (cos2_val & 0x7) << 5;
9585 match[21] = proto_val & 0xff;
9586 match[20] = proto_val >> 8;
9590 match[15] = tag1_val[1];
9591 match[14] = tag1_val[0];
9594 match[14] |= (cos1_val & 0x7) << 5;
9600 match[15] = tag1_val[1];
9601 match[14] = tag1_val[0];
9604 match[17] = proto_val & 0xff;
9605 match[16] = proto_val >> 8;
9608 match[14] |= (cos1_val & 0x7) << 5;
9614 match[18] |= (cos2_val & 0x7) << 5;
9616 match[14] |= (cos1_val & 0x7) << 5;
9619 match[13] = proto_val & 0xff;
9620 match[12] = proto_val >> 8;
9629 api_unformat_classify_match (unformat_input_t * input, va_list * args)
9631 u8 **matchp = va_arg (*args, u8 **);
9632 u32 skip_n_vectors = va_arg (*args, u32);
9633 u32 match_n_vectors = va_arg (*args, u32);
9640 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9642 if (unformat (input, "hex %U", unformat_hex_string, &match))
9644 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9646 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9648 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9662 if (match || l2 || l3 || l4)
9666 /* "Win a free Ethernet header in every packet" */
9668 vec_validate_aligned (l2, 13, sizeof (u32x4));
9672 vec_append_aligned (match, l3, sizeof (u32x4));
9677 vec_append_aligned (match, l4, sizeof (u32x4));
9682 /* Make sure the vector is big enough even if key is all 0's */
9683 vec_validate_aligned
9684 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9687 /* Set size, include skipped vectors */
9688 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9699 api_classify_add_del_session (vat_main_t * vam)
9701 unformat_input_t *i = vam->input;
9702 vl_api_classify_add_del_session_t *mp;
9704 u32 table_index = ~0;
9705 u32 hit_next_index = ~0;
9706 u32 opaque_index = ~0;
9709 u32 skip_n_vectors = 0;
9710 u32 match_n_vectors = 0;
9716 * Warning: you have to supply skip_n and match_n
9717 * because the API client cant simply look at the classify
9721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9723 if (unformat (i, "del"))
9725 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
9728 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9731 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
9734 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9736 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9738 else if (unformat (i, "opaque-index %d", &opaque_index))
9740 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9742 else if (unformat (i, "match_n %d", &match_n_vectors))
9744 else if (unformat (i, "match %U", api_unformat_classify_match,
9745 &match, skip_n_vectors, match_n_vectors))
9747 else if (unformat (i, "advance %d", &advance))
9749 else if (unformat (i, "table-index %d", &table_index))
9751 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9753 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9755 else if (unformat (i, "action %d", &action))
9757 else if (unformat (i, "metadata %d", &metadata))
9763 if (table_index == ~0)
9765 errmsg ("Table index required");
9769 if (is_add && match == 0)
9771 errmsg ("Match value required");
9775 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
9777 mp->is_add = is_add;
9778 mp->table_index = ntohl (table_index);
9779 mp->hit_next_index = ntohl (hit_next_index);
9780 mp->opaque_index = ntohl (opaque_index);
9781 mp->advance = ntohl (advance);
9782 mp->action = action;
9783 mp->metadata = ntohl (metadata);
9784 clib_memcpy (mp->match, match, vec_len (match));
9793 api_classify_set_interface_ip_table (vat_main_t * vam)
9795 unformat_input_t *i = vam->input;
9796 vl_api_classify_set_interface_ip_table_t *mp;
9798 int sw_if_index_set;
9799 u32 table_index = ~0;
9803 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9805 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9806 sw_if_index_set = 1;
9807 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9808 sw_if_index_set = 1;
9809 else if (unformat (i, "table %d", &table_index))
9813 clib_warning ("parse error '%U'", format_unformat_error, i);
9818 if (sw_if_index_set == 0)
9820 errmsg ("missing interface name or sw_if_index");
9825 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
9827 mp->sw_if_index = ntohl (sw_if_index);
9828 mp->table_index = ntohl (table_index);
9829 mp->is_ipv6 = is_ipv6;
9837 api_classify_set_interface_l2_tables (vat_main_t * vam)
9839 unformat_input_t *i = vam->input;
9840 vl_api_classify_set_interface_l2_tables_t *mp;
9842 int sw_if_index_set;
9843 u32 ip4_table_index = ~0;
9844 u32 ip6_table_index = ~0;
9845 u32 other_table_index = ~0;
9849 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9851 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9852 sw_if_index_set = 1;
9853 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9854 sw_if_index_set = 1;
9855 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9857 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9859 else if (unformat (i, "other-table %d", &other_table_index))
9861 else if (unformat (i, "is-input %d", &is_input))
9865 clib_warning ("parse error '%U'", format_unformat_error, i);
9870 if (sw_if_index_set == 0)
9872 errmsg ("missing interface name or sw_if_index");
9877 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
9879 mp->sw_if_index = ntohl (sw_if_index);
9880 mp->ip4_table_index = ntohl (ip4_table_index);
9881 mp->ip6_table_index = ntohl (ip6_table_index);
9882 mp->other_table_index = ntohl (other_table_index);
9883 mp->is_input = (u8) is_input;
9891 api_set_ipfix_exporter (vat_main_t * vam)
9893 unformat_input_t *i = vam->input;
9894 vl_api_set_ipfix_exporter_t *mp;
9895 ip4_address_t collector_address;
9896 u8 collector_address_set = 0;
9897 u32 collector_port = ~0;
9898 ip4_address_t src_address;
9899 u8 src_address_set = 0;
9902 u32 template_interval = ~0;
9903 u8 udp_checksum = 0;
9906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9908 if (unformat (i, "collector_address %U", unformat_ip4_address,
9909 &collector_address))
9910 collector_address_set = 1;
9911 else if (unformat (i, "collector_port %d", &collector_port))
9913 else if (unformat (i, "src_address %U", unformat_ip4_address,
9915 src_address_set = 1;
9916 else if (unformat (i, "vrf_id %d", &vrf_id))
9918 else if (unformat (i, "path_mtu %d", &path_mtu))
9920 else if (unformat (i, "template_interval %d", &template_interval))
9922 else if (unformat (i, "udp_checksum"))
9928 if (collector_address_set == 0)
9930 errmsg ("collector_address required");
9934 if (src_address_set == 0)
9936 errmsg ("src_address required");
9940 M (SET_IPFIX_EXPORTER, mp);
9942 memcpy (mp->collector_address, collector_address.data,
9943 sizeof (collector_address.data));
9944 mp->collector_port = htons ((u16) collector_port);
9945 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9946 mp->vrf_id = htonl (vrf_id);
9947 mp->path_mtu = htonl (path_mtu);
9948 mp->template_interval = htonl (template_interval);
9949 mp->udp_checksum = udp_checksum;
9957 api_set_ipfix_classify_stream (vat_main_t * vam)
9959 unformat_input_t *i = vam->input;
9960 vl_api_set_ipfix_classify_stream_t *mp;
9962 u32 src_port = UDP_DST_PORT_ipfix;
9965 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9967 if (unformat (i, "domain %d", &domain_id))
9969 else if (unformat (i, "src_port %d", &src_port))
9973 errmsg ("unknown input `%U'", format_unformat_error, i);
9978 M (SET_IPFIX_CLASSIFY_STREAM, mp);
9980 mp->domain_id = htonl (domain_id);
9981 mp->src_port = htons ((u16) src_port);
9989 api_ipfix_classify_table_add_del (vat_main_t * vam)
9991 unformat_input_t *i = vam->input;
9992 vl_api_ipfix_classify_table_add_del_t *mp;
9994 u32 classify_table_index = ~0;
9996 u8 transport_protocol = 255;
9999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10001 if (unformat (i, "add"))
10003 else if (unformat (i, "del"))
10005 else if (unformat (i, "table %d", &classify_table_index))
10007 else if (unformat (i, "ip4"))
10009 else if (unformat (i, "ip6"))
10011 else if (unformat (i, "tcp"))
10012 transport_protocol = 6;
10013 else if (unformat (i, "udp"))
10014 transport_protocol = 17;
10017 errmsg ("unknown input `%U'", format_unformat_error, i);
10024 errmsg ("expecting: add|del");
10027 if (classify_table_index == ~0)
10029 errmsg ("classifier table not specified");
10032 if (ip_version == 0)
10034 errmsg ("IP version not specified");
10038 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10040 mp->is_add = is_add;
10041 mp->table_id = htonl (classify_table_index);
10042 mp->ip_version = ip_version;
10043 mp->transport_protocol = transport_protocol;
10051 api_get_node_index (vat_main_t * vam)
10053 unformat_input_t *i = vam->input;
10054 vl_api_get_node_index_t *mp;
10058 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10060 if (unformat (i, "node %s", &name))
10067 errmsg ("node name required");
10070 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10072 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10076 M (GET_NODE_INDEX, mp);
10077 clib_memcpy (mp->node_name, name, vec_len (name));
10086 api_get_next_index (vat_main_t * vam)
10088 unformat_input_t *i = vam->input;
10089 vl_api_get_next_index_t *mp;
10090 u8 *node_name = 0, *next_node_name = 0;
10093 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10095 if (unformat (i, "node-name %s", &node_name))
10097 else if (unformat (i, "next-node-name %s", &next_node_name))
10101 if (node_name == 0)
10103 errmsg ("node name required");
10106 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10108 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10112 if (next_node_name == 0)
10114 errmsg ("next node name required");
10117 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10119 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10123 M (GET_NEXT_INDEX, mp);
10124 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10125 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10126 vec_free (node_name);
10127 vec_free (next_node_name);
10135 api_add_node_next (vat_main_t * vam)
10137 unformat_input_t *i = vam->input;
10138 vl_api_add_node_next_t *mp;
10143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10145 if (unformat (i, "node %s", &name))
10147 else if (unformat (i, "next %s", &next))
10154 errmsg ("node name required");
10157 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10159 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10164 errmsg ("next node required");
10167 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10169 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10173 M (ADD_NODE_NEXT, mp);
10174 clib_memcpy (mp->node_name, name, vec_len (name));
10175 clib_memcpy (mp->next_name, next, vec_len (next));
10185 api_l2tpv3_create_tunnel (vat_main_t * vam)
10187 unformat_input_t *i = vam->input;
10188 ip6_address_t client_address, our_address;
10189 int client_address_set = 0;
10190 int our_address_set = 0;
10191 u32 local_session_id = 0;
10192 u32 remote_session_id = 0;
10193 u64 local_cookie = 0;
10194 u64 remote_cookie = 0;
10195 u8 l2_sublayer_present = 0;
10196 vl_api_l2tpv3_create_tunnel_t *mp;
10199 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10201 if (unformat (i, "client_address %U", unformat_ip6_address,
10203 client_address_set = 1;
10204 else if (unformat (i, "our_address %U", unformat_ip6_address,
10206 our_address_set = 1;
10207 else if (unformat (i, "local_session_id %d", &local_session_id))
10209 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10211 else if (unformat (i, "local_cookie %lld", &local_cookie))
10213 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10215 else if (unformat (i, "l2-sublayer-present"))
10216 l2_sublayer_present = 1;
10221 if (client_address_set == 0)
10223 errmsg ("client_address required");
10227 if (our_address_set == 0)
10229 errmsg ("our_address required");
10233 M (L2TPV3_CREATE_TUNNEL, mp);
10235 clib_memcpy (mp->client_address, client_address.as_u8,
10236 sizeof (mp->client_address));
10238 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10240 mp->local_session_id = ntohl (local_session_id);
10241 mp->remote_session_id = ntohl (remote_session_id);
10242 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10243 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10244 mp->l2_sublayer_present = l2_sublayer_present;
10253 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10255 unformat_input_t *i = vam->input;
10257 u8 sw_if_index_set = 0;
10258 u64 new_local_cookie = 0;
10259 u64 new_remote_cookie = 0;
10260 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10265 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10266 sw_if_index_set = 1;
10267 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10268 sw_if_index_set = 1;
10269 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10271 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10277 if (sw_if_index_set == 0)
10279 errmsg ("missing interface name or sw_if_index");
10283 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10285 mp->sw_if_index = ntohl (sw_if_index);
10286 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10287 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10295 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10297 unformat_input_t *i = vam->input;
10298 vl_api_l2tpv3_interface_enable_disable_t *mp;
10300 u8 sw_if_index_set = 0;
10301 u8 enable_disable = 1;
10304 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10306 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10307 sw_if_index_set = 1;
10308 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10309 sw_if_index_set = 1;
10310 else if (unformat (i, "enable"))
10311 enable_disable = 1;
10312 else if (unformat (i, "disable"))
10313 enable_disable = 0;
10318 if (sw_if_index_set == 0)
10320 errmsg ("missing interface name or sw_if_index");
10324 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10326 mp->sw_if_index = ntohl (sw_if_index);
10327 mp->enable_disable = enable_disable;
10335 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10337 unformat_input_t *i = vam->input;
10338 vl_api_l2tpv3_set_lookup_key_t *mp;
10342 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10344 if (unformat (i, "lookup_v6_src"))
10345 key = L2T_LOOKUP_SRC_ADDRESS;
10346 else if (unformat (i, "lookup_v6_dst"))
10347 key = L2T_LOOKUP_DST_ADDRESS;
10348 else if (unformat (i, "lookup_session_id"))
10349 key = L2T_LOOKUP_SESSION_ID;
10354 if (key == (u8) ~ 0)
10356 errmsg ("l2tp session lookup key unset");
10360 M (L2TPV3_SET_LOOKUP_KEY, mp);
10369 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10370 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10372 vat_main_t *vam = &vat_main;
10374 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10375 format_ip6_address, mp->our_address,
10376 format_ip6_address, mp->client_address,
10377 clib_net_to_host_u32 (mp->sw_if_index));
10380 " local cookies %016llx %016llx remote cookie %016llx",
10381 clib_net_to_host_u64 (mp->local_cookie[0]),
10382 clib_net_to_host_u64 (mp->local_cookie[1]),
10383 clib_net_to_host_u64 (mp->remote_cookie));
10385 print (vam->ofp, " local session-id %d remote session-id %d",
10386 clib_net_to_host_u32 (mp->local_session_id),
10387 clib_net_to_host_u32 (mp->remote_session_id));
10389 print (vam->ofp, " l2 specific sublayer %s\n",
10390 mp->l2_sublayer_present ? "preset" : "absent");
10394 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10395 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10397 vat_main_t *vam = &vat_main;
10398 vat_json_node_t *node = NULL;
10399 struct in6_addr addr;
10401 if (VAT_JSON_ARRAY != vam->json_tree.type)
10403 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10404 vat_json_init_array (&vam->json_tree);
10406 node = vat_json_array_add (&vam->json_tree);
10408 vat_json_init_object (node);
10410 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10411 vat_json_object_add_ip6 (node, "our_address", addr);
10412 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10413 vat_json_object_add_ip6 (node, "client_address", addr);
10415 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10416 vat_json_init_array (lc);
10417 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10418 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10419 vat_json_object_add_uint (node, "remote_cookie",
10420 clib_net_to_host_u64 (mp->remote_cookie));
10422 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10423 vat_json_object_add_uint (node, "local_session_id",
10424 clib_net_to_host_u32 (mp->local_session_id));
10425 vat_json_object_add_uint (node, "remote_session_id",
10426 clib_net_to_host_u32 (mp->remote_session_id));
10427 vat_json_object_add_string_copy (node, "l2_sublayer",
10428 mp->l2_sublayer_present ? (u8 *) "present"
10429 : (u8 *) "absent");
10433 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10435 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10436 vl_api_control_ping_t *mp_ping;
10439 /* Get list of l2tpv3-tunnel interfaces */
10440 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10443 /* Use a control ping for synchronization */
10444 M (CONTROL_PING, mp_ping);
10452 static void vl_api_sw_interface_tap_details_t_handler
10453 (vl_api_sw_interface_tap_details_t * mp)
10455 vat_main_t *vam = &vat_main;
10457 print (vam->ofp, "%-16s %d",
10458 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10461 static void vl_api_sw_interface_tap_details_t_handler_json
10462 (vl_api_sw_interface_tap_details_t * mp)
10464 vat_main_t *vam = &vat_main;
10465 vat_json_node_t *node = NULL;
10467 if (VAT_JSON_ARRAY != vam->json_tree.type)
10469 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10470 vat_json_init_array (&vam->json_tree);
10472 node = vat_json_array_add (&vam->json_tree);
10474 vat_json_init_object (node);
10475 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10476 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10480 api_sw_interface_tap_dump (vat_main_t * vam)
10482 vl_api_sw_interface_tap_dump_t *mp;
10483 vl_api_control_ping_t *mp_ping;
10486 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10487 /* Get list of tap interfaces */
10488 M (SW_INTERFACE_TAP_DUMP, mp);
10491 /* Use a control ping for synchronization */
10492 M (CONTROL_PING, mp_ping);
10499 static uword unformat_vxlan_decap_next
10500 (unformat_input_t * input, va_list * args)
10502 u32 *result = va_arg (*args, u32 *);
10505 if (unformat (input, "l2"))
10506 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10507 else if (unformat (input, "%d", &tmp))
10515 api_vxlan_add_del_tunnel (vat_main_t * vam)
10517 unformat_input_t *line_input = vam->input;
10518 vl_api_vxlan_add_del_tunnel_t *mp;
10519 ip46_address_t src, dst;
10521 u8 ipv4_set = 0, ipv6_set = 0;
10525 u32 mcast_sw_if_index = ~0;
10526 u32 encap_vrf_id = 0;
10527 u32 decap_next_index = ~0;
10531 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10532 memset (&src, 0, sizeof src);
10533 memset (&dst, 0, sizeof dst);
10535 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10537 if (unformat (line_input, "del"))
10540 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10546 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10552 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10558 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10563 else if (unformat (line_input, "group %U %U",
10564 unformat_ip4_address, &dst.ip4,
10565 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10567 grp_set = dst_set = 1;
10570 else if (unformat (line_input, "group %U",
10571 unformat_ip4_address, &dst.ip4))
10573 grp_set = dst_set = 1;
10576 else if (unformat (line_input, "group %U %U",
10577 unformat_ip6_address, &dst.ip6,
10578 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10580 grp_set = dst_set = 1;
10583 else if (unformat (line_input, "group %U",
10584 unformat_ip6_address, &dst.ip6))
10586 grp_set = dst_set = 1;
10590 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10592 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10594 else if (unformat (line_input, "decap-next %U",
10595 unformat_vxlan_decap_next, &decap_next_index))
10597 else if (unformat (line_input, "vni %d", &vni))
10601 errmsg ("parse error '%U'", format_unformat_error, line_input);
10608 errmsg ("tunnel src address not specified");
10613 errmsg ("tunnel dst address not specified");
10617 if (grp_set && !ip46_address_is_multicast (&dst))
10619 errmsg ("tunnel group address not multicast");
10622 if (grp_set && mcast_sw_if_index == ~0)
10624 errmsg ("tunnel nonexistent multicast device");
10627 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10629 errmsg ("tunnel dst address must be unicast");
10634 if (ipv4_set && ipv6_set)
10636 errmsg ("both IPv4 and IPv6 addresses specified");
10640 if ((vni == 0) || (vni >> 24))
10642 errmsg ("vni not specified or out of range");
10646 M (VXLAN_ADD_DEL_TUNNEL, mp);
10650 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10651 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10655 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10656 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10658 mp->encap_vrf_id = ntohl (encap_vrf_id);
10659 mp->decap_next_index = ntohl (decap_next_index);
10660 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10661 mp->vni = ntohl (vni);
10662 mp->is_add = is_add;
10663 mp->is_ipv6 = ipv6_set;
10670 static void vl_api_vxlan_tunnel_details_t_handler
10671 (vl_api_vxlan_tunnel_details_t * mp)
10673 vat_main_t *vam = &vat_main;
10674 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
10675 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
10677 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10678 ntohl (mp->sw_if_index),
10679 format_ip46_address, &src, IP46_TYPE_ANY,
10680 format_ip46_address, &dst, IP46_TYPE_ANY,
10681 ntohl (mp->encap_vrf_id),
10682 ntohl (mp->decap_next_index), ntohl (mp->vni),
10683 ntohl (mp->mcast_sw_if_index));
10686 static void vl_api_vxlan_tunnel_details_t_handler_json
10687 (vl_api_vxlan_tunnel_details_t * mp)
10689 vat_main_t *vam = &vat_main;
10690 vat_json_node_t *node = NULL;
10692 if (VAT_JSON_ARRAY != vam->json_tree.type)
10694 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10695 vat_json_init_array (&vam->json_tree);
10697 node = vat_json_array_add (&vam->json_tree);
10699 vat_json_init_object (node);
10700 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10703 struct in6_addr ip6;
10705 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10706 vat_json_object_add_ip6 (node, "src_address", ip6);
10707 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10708 vat_json_object_add_ip6 (node, "dst_address", ip6);
10712 struct in_addr ip4;
10714 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10715 vat_json_object_add_ip4 (node, "src_address", ip4);
10716 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10717 vat_json_object_add_ip4 (node, "dst_address", ip4);
10719 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10720 vat_json_object_add_uint (node, "decap_next_index",
10721 ntohl (mp->decap_next_index));
10722 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10723 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10724 vat_json_object_add_uint (node, "mcast_sw_if_index",
10725 ntohl (mp->mcast_sw_if_index));
10729 api_vxlan_tunnel_dump (vat_main_t * vam)
10731 unformat_input_t *i = vam->input;
10732 vl_api_vxlan_tunnel_dump_t *mp;
10733 vl_api_control_ping_t *mp_ping;
10735 u8 sw_if_index_set = 0;
10738 /* Parse args required to build the message */
10739 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10741 if (unformat (i, "sw_if_index %d", &sw_if_index))
10742 sw_if_index_set = 1;
10747 if (sw_if_index_set == 0)
10752 if (!vam->json_output)
10754 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10755 "sw_if_index", "src_address", "dst_address",
10756 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10759 /* Get list of vxlan-tunnel interfaces */
10760 M (VXLAN_TUNNEL_DUMP, mp);
10762 mp->sw_if_index = htonl (sw_if_index);
10766 /* Use a control ping for synchronization */
10767 M (CONTROL_PING, mp_ping);
10775 api_gre_add_del_tunnel (vat_main_t * vam)
10777 unformat_input_t *line_input = vam->input;
10778 vl_api_gre_add_del_tunnel_t *mp;
10779 ip4_address_t src4, dst4;
10784 u32 outer_fib_id = 0;
10787 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10789 if (unformat (line_input, "del"))
10791 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10793 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10795 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10797 else if (unformat (line_input, "teb"))
10801 errmsg ("parse error '%U'", format_unformat_error, line_input);
10808 errmsg ("tunnel src address not specified");
10813 errmsg ("tunnel dst address not specified");
10818 M (GRE_ADD_DEL_TUNNEL, mp);
10820 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10821 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10822 mp->outer_fib_id = ntohl (outer_fib_id);
10823 mp->is_add = is_add;
10831 static void vl_api_gre_tunnel_details_t_handler
10832 (vl_api_gre_tunnel_details_t * mp)
10834 vat_main_t *vam = &vat_main;
10836 print (vam->ofp, "%11d%15U%15U%6d%14d",
10837 ntohl (mp->sw_if_index),
10838 format_ip4_address, &mp->src_address,
10839 format_ip4_address, &mp->dst_address,
10840 mp->teb, ntohl (mp->outer_fib_id));
10843 static void vl_api_gre_tunnel_details_t_handler_json
10844 (vl_api_gre_tunnel_details_t * mp)
10846 vat_main_t *vam = &vat_main;
10847 vat_json_node_t *node = NULL;
10848 struct in_addr ip4;
10850 if (VAT_JSON_ARRAY != vam->json_tree.type)
10852 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10853 vat_json_init_array (&vam->json_tree);
10855 node = vat_json_array_add (&vam->json_tree);
10857 vat_json_init_object (node);
10858 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10859 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10860 vat_json_object_add_ip4 (node, "src_address", ip4);
10861 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10862 vat_json_object_add_ip4 (node, "dst_address", ip4);
10863 vat_json_object_add_uint (node, "teb", mp->teb);
10864 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10868 api_gre_tunnel_dump (vat_main_t * vam)
10870 unformat_input_t *i = vam->input;
10871 vl_api_gre_tunnel_dump_t *mp;
10872 vl_api_control_ping_t *mp_ping;
10874 u8 sw_if_index_set = 0;
10877 /* Parse args required to build the message */
10878 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10880 if (unformat (i, "sw_if_index %d", &sw_if_index))
10881 sw_if_index_set = 1;
10886 if (sw_if_index_set == 0)
10891 if (!vam->json_output)
10893 print (vam->ofp, "%11s%15s%15s%6s%14s",
10894 "sw_if_index", "src_address", "dst_address", "teb",
10898 /* Get list of gre-tunnel interfaces */
10899 M (GRE_TUNNEL_DUMP, mp);
10901 mp->sw_if_index = htonl (sw_if_index);
10905 /* Use a control ping for synchronization */
10906 M (CONTROL_PING, mp_ping);
10914 api_l2_fib_clear_table (vat_main_t * vam)
10916 // unformat_input_t * i = vam->input;
10917 vl_api_l2_fib_clear_table_t *mp;
10920 M (L2_FIB_CLEAR_TABLE, mp);
10928 api_l2_interface_efp_filter (vat_main_t * vam)
10930 unformat_input_t *i = vam->input;
10931 vl_api_l2_interface_efp_filter_t *mp;
10934 u8 sw_if_index_set = 0;
10937 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10939 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10940 sw_if_index_set = 1;
10941 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10942 sw_if_index_set = 1;
10943 else if (unformat (i, "enable"))
10945 else if (unformat (i, "disable"))
10949 clib_warning ("parse error '%U'", format_unformat_error, i);
10954 if (sw_if_index_set == 0)
10956 errmsg ("missing sw_if_index");
10960 M (L2_INTERFACE_EFP_FILTER, mp);
10962 mp->sw_if_index = ntohl (sw_if_index);
10963 mp->enable_disable = enable;
10970 #define foreach_vtr_op \
10971 _("disable", L2_VTR_DISABLED) \
10972 _("push-1", L2_VTR_PUSH_1) \
10973 _("push-2", L2_VTR_PUSH_2) \
10974 _("pop-1", L2_VTR_POP_1) \
10975 _("pop-2", L2_VTR_POP_2) \
10976 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10977 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10978 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10979 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10982 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10984 unformat_input_t *i = vam->input;
10985 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10987 u8 sw_if_index_set = 0;
10990 u32 push_dot1q = 1;
10995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10997 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10998 sw_if_index_set = 1;
10999 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11000 sw_if_index_set = 1;
11001 else if (unformat (i, "vtr_op %d", &vtr_op))
11003 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11006 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11008 else if (unformat (i, "tag1 %d", &tag1))
11010 else if (unformat (i, "tag2 %d", &tag2))
11014 clib_warning ("parse error '%U'", format_unformat_error, i);
11019 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11021 errmsg ("missing vtr operation or sw_if_index");
11025 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11026 mp->sw_if_index = ntohl (sw_if_index);
11027 mp->vtr_op = ntohl (vtr_op);
11028 mp->push_dot1q = ntohl (push_dot1q);
11029 mp->tag1 = ntohl (tag1);
11030 mp->tag2 = ntohl (tag2);
11038 api_create_vhost_user_if (vat_main_t * vam)
11040 unformat_input_t *i = vam->input;
11041 vl_api_create_vhost_user_if_t *mp;
11044 u8 file_name_set = 0;
11045 u32 custom_dev_instance = ~0;
11047 u8 use_custom_mac = 0;
11051 /* Shut up coverity */
11052 memset (hwaddr, 0, sizeof (hwaddr));
11054 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11056 if (unformat (i, "socket %s", &file_name))
11060 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11062 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11063 use_custom_mac = 1;
11064 else if (unformat (i, "server"))
11066 else if (unformat (i, "tag %s", &tag))
11072 if (file_name_set == 0)
11074 errmsg ("missing socket file name");
11078 if (vec_len (file_name) > 255)
11080 errmsg ("socket file name too long");
11083 vec_add1 (file_name, 0);
11085 M (CREATE_VHOST_USER_IF, mp);
11087 mp->is_server = is_server;
11088 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11089 vec_free (file_name);
11090 if (custom_dev_instance != ~0)
11093 mp->custom_dev_instance = ntohl (custom_dev_instance);
11095 mp->use_custom_mac = use_custom_mac;
11096 clib_memcpy (mp->mac_address, hwaddr, 6);
11098 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11107 api_modify_vhost_user_if (vat_main_t * vam)
11109 unformat_input_t *i = vam->input;
11110 vl_api_modify_vhost_user_if_t *mp;
11113 u8 file_name_set = 0;
11114 u32 custom_dev_instance = ~0;
11115 u8 sw_if_index_set = 0;
11116 u32 sw_if_index = (u32) ~ 0;
11119 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11121 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11122 sw_if_index_set = 1;
11123 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11124 sw_if_index_set = 1;
11125 else if (unformat (i, "socket %s", &file_name))
11129 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11131 else if (unformat (i, "server"))
11137 if (sw_if_index_set == 0)
11139 errmsg ("missing sw_if_index or interface name");
11143 if (file_name_set == 0)
11145 errmsg ("missing socket file name");
11149 if (vec_len (file_name) > 255)
11151 errmsg ("socket file name too long");
11154 vec_add1 (file_name, 0);
11156 M (MODIFY_VHOST_USER_IF, mp);
11158 mp->sw_if_index = ntohl (sw_if_index);
11159 mp->is_server = is_server;
11160 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11161 vec_free (file_name);
11162 if (custom_dev_instance != ~0)
11165 mp->custom_dev_instance = ntohl (custom_dev_instance);
11174 api_delete_vhost_user_if (vat_main_t * vam)
11176 unformat_input_t *i = vam->input;
11177 vl_api_delete_vhost_user_if_t *mp;
11178 u32 sw_if_index = ~0;
11179 u8 sw_if_index_set = 0;
11182 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11184 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11185 sw_if_index_set = 1;
11186 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11187 sw_if_index_set = 1;
11192 if (sw_if_index_set == 0)
11194 errmsg ("missing sw_if_index or interface name");
11199 M (DELETE_VHOST_USER_IF, mp);
11201 mp->sw_if_index = ntohl (sw_if_index);
11208 static void vl_api_sw_interface_vhost_user_details_t_handler
11209 (vl_api_sw_interface_vhost_user_details_t * mp)
11211 vat_main_t *vam = &vat_main;
11213 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11214 (char *) mp->interface_name,
11215 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11216 clib_net_to_host_u64 (mp->features), mp->is_server,
11217 ntohl (mp->num_regions), (char *) mp->sock_filename);
11218 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11221 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11222 (vl_api_sw_interface_vhost_user_details_t * mp)
11224 vat_main_t *vam = &vat_main;
11225 vat_json_node_t *node = NULL;
11227 if (VAT_JSON_ARRAY != vam->json_tree.type)
11229 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11230 vat_json_init_array (&vam->json_tree);
11232 node = vat_json_array_add (&vam->json_tree);
11234 vat_json_init_object (node);
11235 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11236 vat_json_object_add_string_copy (node, "interface_name",
11237 mp->interface_name);
11238 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11239 ntohl (mp->virtio_net_hdr_sz));
11240 vat_json_object_add_uint (node, "features",
11241 clib_net_to_host_u64 (mp->features));
11242 vat_json_object_add_uint (node, "is_server", mp->is_server);
11243 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11244 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11245 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11249 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11251 vl_api_sw_interface_vhost_user_dump_t *mp;
11252 vl_api_control_ping_t *mp_ping;
11255 "Interface name idx hdr_sz features server regions filename");
11257 /* Get list of vhost-user interfaces */
11258 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11261 /* Use a control ping for synchronization */
11262 M (CONTROL_PING, mp_ping);
11270 api_show_version (vat_main_t * vam)
11272 vl_api_show_version_t *mp;
11275 M (SHOW_VERSION, mp);
11284 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11286 unformat_input_t *line_input = vam->input;
11287 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11288 ip4_address_t local4, remote4;
11289 ip6_address_t local6, remote6;
11291 u8 ipv4_set = 0, ipv6_set = 0;
11294 u32 encap_vrf_id = 0;
11295 u32 decap_vrf_id = 0;
11301 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11303 if (unformat (line_input, "del"))
11305 else if (unformat (line_input, "local %U",
11306 unformat_ip4_address, &local4))
11311 else if (unformat (line_input, "remote %U",
11312 unformat_ip4_address, &remote4))
11317 else if (unformat (line_input, "local %U",
11318 unformat_ip6_address, &local6))
11323 else if (unformat (line_input, "remote %U",
11324 unformat_ip6_address, &remote6))
11329 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11331 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11333 else if (unformat (line_input, "vni %d", &vni))
11335 else if (unformat (line_input, "next-ip4"))
11337 else if (unformat (line_input, "next-ip6"))
11339 else if (unformat (line_input, "next-ethernet"))
11341 else if (unformat (line_input, "next-nsh"))
11345 errmsg ("parse error '%U'", format_unformat_error, line_input);
11350 if (local_set == 0)
11352 errmsg ("tunnel local address not specified");
11355 if (remote_set == 0)
11357 errmsg ("tunnel remote address not specified");
11360 if (ipv4_set && ipv6_set)
11362 errmsg ("both IPv4 and IPv6 addresses specified");
11368 errmsg ("vni not specified");
11372 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11377 clib_memcpy (&mp->local, &local6, sizeof (local6));
11378 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11382 clib_memcpy (&mp->local, &local4, sizeof (local4));
11383 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11386 mp->encap_vrf_id = ntohl (encap_vrf_id);
11387 mp->decap_vrf_id = ntohl (decap_vrf_id);
11388 mp->protocol = protocol;
11389 mp->vni = ntohl (vni);
11390 mp->is_add = is_add;
11391 mp->is_ipv6 = ipv6_set;
11398 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11399 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11401 vat_main_t *vam = &vat_main;
11403 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11404 ntohl (mp->sw_if_index),
11405 format_ip46_address, &(mp->local[0]),
11406 format_ip46_address, &(mp->remote[0]),
11408 ntohl (mp->protocol),
11409 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11412 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11413 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11415 vat_main_t *vam = &vat_main;
11416 vat_json_node_t *node = NULL;
11417 struct in_addr ip4;
11418 struct in6_addr ip6;
11420 if (VAT_JSON_ARRAY != vam->json_tree.type)
11422 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11423 vat_json_init_array (&vam->json_tree);
11425 node = vat_json_array_add (&vam->json_tree);
11427 vat_json_init_object (node);
11428 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11431 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11432 vat_json_object_add_ip6 (node, "local", ip6);
11433 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11434 vat_json_object_add_ip6 (node, "remote", ip6);
11438 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11439 vat_json_object_add_ip4 (node, "local", ip4);
11440 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11441 vat_json_object_add_ip4 (node, "remote", ip4);
11443 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11444 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11445 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11446 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11447 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11451 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11453 unformat_input_t *i = vam->input;
11454 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11455 vl_api_control_ping_t *mp_ping;
11457 u8 sw_if_index_set = 0;
11460 /* Parse args required to build the message */
11461 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11463 if (unformat (i, "sw_if_index %d", &sw_if_index))
11464 sw_if_index_set = 1;
11469 if (sw_if_index_set == 0)
11474 if (!vam->json_output)
11476 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11477 "sw_if_index", "local", "remote", "vni",
11478 "protocol", "encap_vrf_id", "decap_vrf_id");
11481 /* Get list of vxlan-tunnel interfaces */
11482 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11484 mp->sw_if_index = htonl (sw_if_index);
11488 /* Use a control ping for synchronization */
11489 M (CONTROL_PING, mp_ping);
11497 format_l2_fib_mac_address (u8 * s, va_list * args)
11499 u8 *a = va_arg (*args, u8 *);
11501 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11502 a[2], a[3], a[4], a[5], a[6], a[7]);
11505 static void vl_api_l2_fib_table_entry_t_handler
11506 (vl_api_l2_fib_table_entry_t * mp)
11508 vat_main_t *vam = &vat_main;
11510 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11512 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11513 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11517 static void vl_api_l2_fib_table_entry_t_handler_json
11518 (vl_api_l2_fib_table_entry_t * mp)
11520 vat_main_t *vam = &vat_main;
11521 vat_json_node_t *node = NULL;
11523 if (VAT_JSON_ARRAY != vam->json_tree.type)
11525 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11526 vat_json_init_array (&vam->json_tree);
11528 node = vat_json_array_add (&vam->json_tree);
11530 vat_json_init_object (node);
11531 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11532 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11533 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11534 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11535 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11536 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11540 api_l2_fib_table_dump (vat_main_t * vam)
11542 unformat_input_t *i = vam->input;
11543 vl_api_l2_fib_table_dump_t *mp;
11544 vl_api_control_ping_t *mp_ping;
11549 /* Parse args required to build the message */
11550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11552 if (unformat (i, "bd_id %d", &bd_id))
11558 if (bd_id_set == 0)
11560 errmsg ("missing bridge domain");
11564 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11566 /* Get list of l2 fib entries */
11567 M (L2_FIB_TABLE_DUMP, mp);
11569 mp->bd_id = ntohl (bd_id);
11572 /* Use a control ping for synchronization */
11573 M (CONTROL_PING, mp_ping);
11582 api_interface_name_renumber (vat_main_t * vam)
11584 unformat_input_t *line_input = vam->input;
11585 vl_api_interface_name_renumber_t *mp;
11586 u32 sw_if_index = ~0;
11587 u32 new_show_dev_instance = ~0;
11590 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11592 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11595 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11597 else if (unformat (line_input, "new_show_dev_instance %d",
11598 &new_show_dev_instance))
11604 if (sw_if_index == ~0)
11606 errmsg ("missing interface name or sw_if_index");
11610 if (new_show_dev_instance == ~0)
11612 errmsg ("missing new_show_dev_instance");
11616 M (INTERFACE_NAME_RENUMBER, mp);
11618 mp->sw_if_index = ntohl (sw_if_index);
11619 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11627 api_want_ip4_arp_events (vat_main_t * vam)
11629 unformat_input_t *line_input = vam->input;
11630 vl_api_want_ip4_arp_events_t *mp;
11631 ip4_address_t address;
11632 int address_set = 0;
11633 u32 enable_disable = 1;
11636 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11638 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11640 else if (unformat (line_input, "del"))
11641 enable_disable = 0;
11646 if (address_set == 0)
11648 errmsg ("missing addresses");
11652 M (WANT_IP4_ARP_EVENTS, mp);
11653 mp->enable_disable = enable_disable;
11654 mp->pid = getpid ();
11655 mp->address = address.as_u32;
11663 api_want_ip6_nd_events (vat_main_t * vam)
11665 unformat_input_t *line_input = vam->input;
11666 vl_api_want_ip6_nd_events_t *mp;
11667 ip6_address_t address;
11668 int address_set = 0;
11669 u32 enable_disable = 1;
11672 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11674 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11676 else if (unformat (line_input, "del"))
11677 enable_disable = 0;
11682 if (address_set == 0)
11684 errmsg ("missing addresses");
11688 M (WANT_IP6_ND_EVENTS, mp);
11689 mp->enable_disable = enable_disable;
11690 mp->pid = getpid ();
11691 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11699 api_input_acl_set_interface (vat_main_t * vam)
11701 unformat_input_t *i = vam->input;
11702 vl_api_input_acl_set_interface_t *mp;
11704 int sw_if_index_set;
11705 u32 ip4_table_index = ~0;
11706 u32 ip6_table_index = ~0;
11707 u32 l2_table_index = ~0;
11711 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11713 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11714 sw_if_index_set = 1;
11715 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11716 sw_if_index_set = 1;
11717 else if (unformat (i, "del"))
11719 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11721 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11723 else if (unformat (i, "l2-table %d", &l2_table_index))
11727 clib_warning ("parse error '%U'", format_unformat_error, i);
11732 if (sw_if_index_set == 0)
11734 errmsg ("missing interface name or sw_if_index");
11738 M (INPUT_ACL_SET_INTERFACE, mp);
11740 mp->sw_if_index = ntohl (sw_if_index);
11741 mp->ip4_table_index = ntohl (ip4_table_index);
11742 mp->ip6_table_index = ntohl (ip6_table_index);
11743 mp->l2_table_index = ntohl (l2_table_index);
11744 mp->is_add = is_add;
11752 api_ip_address_dump (vat_main_t * vam)
11754 unformat_input_t *i = vam->input;
11755 vl_api_ip_address_dump_t *mp;
11756 vl_api_control_ping_t *mp_ping;
11757 u32 sw_if_index = ~0;
11758 u8 sw_if_index_set = 0;
11763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11765 if (unformat (i, "sw_if_index %d", &sw_if_index))
11766 sw_if_index_set = 1;
11768 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11769 sw_if_index_set = 1;
11770 else if (unformat (i, "ipv4"))
11772 else if (unformat (i, "ipv6"))
11778 if (ipv4_set && ipv6_set)
11780 errmsg ("ipv4 and ipv6 flags cannot be both set");
11784 if ((!ipv4_set) && (!ipv6_set))
11786 errmsg ("no ipv4 nor ipv6 flag set");
11790 if (sw_if_index_set == 0)
11792 errmsg ("missing interface name or sw_if_index");
11796 vam->current_sw_if_index = sw_if_index;
11797 vam->is_ipv6 = ipv6_set;
11799 M (IP_ADDRESS_DUMP, mp);
11800 mp->sw_if_index = ntohl (sw_if_index);
11801 mp->is_ipv6 = ipv6_set;
11804 /* Use a control ping for synchronization */
11805 M (CONTROL_PING, mp_ping);
11813 api_ip_dump (vat_main_t * vam)
11815 vl_api_ip_dump_t *mp;
11816 vl_api_control_ping_t *mp_ping;
11817 unformat_input_t *in = vam->input;
11824 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11826 if (unformat (in, "ipv4"))
11828 else if (unformat (in, "ipv6"))
11834 if (ipv4_set && ipv6_set)
11836 errmsg ("ipv4 and ipv6 flags cannot be both set");
11840 if ((!ipv4_set) && (!ipv6_set))
11842 errmsg ("no ipv4 nor ipv6 flag set");
11846 is_ipv6 = ipv6_set;
11847 vam->is_ipv6 = is_ipv6;
11849 /* free old data */
11850 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11852 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11854 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11857 mp->is_ipv6 = ipv6_set;
11860 /* Use a control ping for synchronization */
11861 M (CONTROL_PING, mp_ping);
11869 api_ipsec_spd_add_del (vat_main_t * vam)
11871 unformat_input_t *i = vam->input;
11872 vl_api_ipsec_spd_add_del_t *mp;
11877 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11879 if (unformat (i, "spd_id %d", &spd_id))
11881 else if (unformat (i, "del"))
11885 clib_warning ("parse error '%U'", format_unformat_error, i);
11891 errmsg ("spd_id must be set");
11895 M (IPSEC_SPD_ADD_DEL, mp);
11897 mp->spd_id = ntohl (spd_id);
11898 mp->is_add = is_add;
11906 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11908 unformat_input_t *i = vam->input;
11909 vl_api_ipsec_interface_add_del_spd_t *mp;
11911 u8 sw_if_index_set = 0;
11912 u32 spd_id = (u32) ~ 0;
11916 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11918 if (unformat (i, "del"))
11920 else if (unformat (i, "spd_id %d", &spd_id))
11923 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11924 sw_if_index_set = 1;
11925 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11926 sw_if_index_set = 1;
11929 clib_warning ("parse error '%U'", format_unformat_error, i);
11935 if (spd_id == (u32) ~ 0)
11937 errmsg ("spd_id must be set");
11941 if (sw_if_index_set == 0)
11943 errmsg ("missing interface name or sw_if_index");
11947 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
11949 mp->spd_id = ntohl (spd_id);
11950 mp->sw_if_index = ntohl (sw_if_index);
11951 mp->is_add = is_add;
11959 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11961 unformat_input_t *i = vam->input;
11962 vl_api_ipsec_spd_add_del_entry_t *mp;
11963 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11964 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11966 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11967 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11968 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11969 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11972 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11973 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11974 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11975 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11976 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11977 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11981 if (unformat (i, "del"))
11983 if (unformat (i, "outbound"))
11985 if (unformat (i, "inbound"))
11987 else if (unformat (i, "spd_id %d", &spd_id))
11989 else if (unformat (i, "sa_id %d", &sa_id))
11991 else if (unformat (i, "priority %d", &priority))
11993 else if (unformat (i, "protocol %d", &protocol))
11995 else if (unformat (i, "lport_start %d", &lport_start))
11997 else if (unformat (i, "lport_stop %d", &lport_stop))
11999 else if (unformat (i, "rport_start %d", &rport_start))
12001 else if (unformat (i, "rport_stop %d", &rport_stop))
12005 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12011 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12018 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12024 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12031 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12037 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12044 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12050 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12056 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12058 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12060 clib_warning ("unsupported action: 'resolve'");
12066 clib_warning ("parse error '%U'", format_unformat_error, i);
12072 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12074 mp->spd_id = ntohl (spd_id);
12075 mp->priority = ntohl (priority);
12076 mp->is_outbound = is_outbound;
12078 mp->is_ipv6 = is_ipv6;
12079 if (is_ipv6 || is_ip_any)
12081 clib_memcpy (mp->remote_address_start, &raddr6_start,
12082 sizeof (ip6_address_t));
12083 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12084 sizeof (ip6_address_t));
12085 clib_memcpy (mp->local_address_start, &laddr6_start,
12086 sizeof (ip6_address_t));
12087 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12088 sizeof (ip6_address_t));
12092 clib_memcpy (mp->remote_address_start, &raddr4_start,
12093 sizeof (ip4_address_t));
12094 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12095 sizeof (ip4_address_t));
12096 clib_memcpy (mp->local_address_start, &laddr4_start,
12097 sizeof (ip4_address_t));
12098 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12099 sizeof (ip4_address_t));
12101 mp->protocol = (u8) protocol;
12102 mp->local_port_start = ntohs ((u16) lport_start);
12103 mp->local_port_stop = ntohs ((u16) lport_stop);
12104 mp->remote_port_start = ntohs ((u16) rport_start);
12105 mp->remote_port_stop = ntohs ((u16) rport_stop);
12106 mp->policy = (u8) policy;
12107 mp->sa_id = ntohl (sa_id);
12108 mp->is_add = is_add;
12109 mp->is_ip_any = is_ip_any;
12116 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12118 unformat_input_t *i = vam->input;
12119 vl_api_ipsec_sad_add_del_entry_t *mp;
12120 u32 sad_id = 0, spi = 0;
12121 u8 *ck = 0, *ik = 0;
12124 u8 protocol = IPSEC_PROTOCOL_AH;
12125 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12126 u32 crypto_alg = 0, integ_alg = 0;
12127 ip4_address_t tun_src4;
12128 ip4_address_t tun_dst4;
12129 ip6_address_t tun_src6;
12130 ip6_address_t tun_dst6;
12133 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12135 if (unformat (i, "del"))
12137 else if (unformat (i, "sad_id %d", &sad_id))
12139 else if (unformat (i, "spi %d", &spi))
12141 else if (unformat (i, "esp"))
12142 protocol = IPSEC_PROTOCOL_ESP;
12143 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12146 is_tunnel_ipv6 = 0;
12148 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12151 is_tunnel_ipv6 = 0;
12153 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12156 is_tunnel_ipv6 = 1;
12158 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12161 is_tunnel_ipv6 = 1;
12165 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12167 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12168 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12170 clib_warning ("unsupported crypto-alg: '%U'",
12171 format_ipsec_crypto_alg, crypto_alg);
12175 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12179 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12181 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12182 integ_alg >= IPSEC_INTEG_N_ALG)
12184 clib_warning ("unsupported integ-alg: '%U'",
12185 format_ipsec_integ_alg, integ_alg);
12189 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12193 clib_warning ("parse error '%U'", format_unformat_error, i);
12199 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12201 mp->sad_id = ntohl (sad_id);
12202 mp->is_add = is_add;
12203 mp->protocol = protocol;
12204 mp->spi = ntohl (spi);
12205 mp->is_tunnel = is_tunnel;
12206 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12207 mp->crypto_algorithm = crypto_alg;
12208 mp->integrity_algorithm = integ_alg;
12209 mp->crypto_key_length = vec_len (ck);
12210 mp->integrity_key_length = vec_len (ik);
12212 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12213 mp->crypto_key_length = sizeof (mp->crypto_key);
12215 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12216 mp->integrity_key_length = sizeof (mp->integrity_key);
12219 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12221 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12225 if (is_tunnel_ipv6)
12227 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12228 sizeof (ip6_address_t));
12229 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12230 sizeof (ip6_address_t));
12234 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12235 sizeof (ip4_address_t));
12236 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12237 sizeof (ip4_address_t));
12247 api_ipsec_sa_set_key (vat_main_t * vam)
12249 unformat_input_t *i = vam->input;
12250 vl_api_ipsec_sa_set_key_t *mp;
12252 u8 *ck = 0, *ik = 0;
12255 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12257 if (unformat (i, "sa_id %d", &sa_id))
12259 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12261 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12265 clib_warning ("parse error '%U'", format_unformat_error, i);
12270 M (IPSEC_SA_SET_KEY, mp);
12272 mp->sa_id = ntohl (sa_id);
12273 mp->crypto_key_length = vec_len (ck);
12274 mp->integrity_key_length = vec_len (ik);
12276 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12277 mp->crypto_key_length = sizeof (mp->crypto_key);
12279 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12280 mp->integrity_key_length = sizeof (mp->integrity_key);
12283 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12285 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12293 api_ikev2_profile_add_del (vat_main_t * vam)
12295 unformat_input_t *i = vam->input;
12296 vl_api_ikev2_profile_add_del_t *mp;
12301 const char *valid_chars = "a-zA-Z0-9_";
12303 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12305 if (unformat (i, "del"))
12307 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12308 vec_add1 (name, 0);
12311 errmsg ("parse error '%U'", format_unformat_error, i);
12316 if (!vec_len (name))
12318 errmsg ("profile name must be specified");
12322 if (vec_len (name) > 64)
12324 errmsg ("profile name too long");
12328 M (IKEV2_PROFILE_ADD_DEL, mp);
12330 clib_memcpy (mp->name, name, vec_len (name));
12331 mp->is_add = is_add;
12340 api_ikev2_profile_set_auth (vat_main_t * vam)
12342 unformat_input_t *i = vam->input;
12343 vl_api_ikev2_profile_set_auth_t *mp;
12346 u32 auth_method = 0;
12350 const char *valid_chars = "a-zA-Z0-9_";
12352 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12354 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12355 vec_add1 (name, 0);
12356 else if (unformat (i, "auth_method %U",
12357 unformat_ikev2_auth_method, &auth_method))
12359 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12361 else if (unformat (i, "auth_data %v", &data))
12365 errmsg ("parse error '%U'", format_unformat_error, i);
12370 if (!vec_len (name))
12372 errmsg ("profile name must be specified");
12376 if (vec_len (name) > 64)
12378 errmsg ("profile name too long");
12382 if (!vec_len (data))
12384 errmsg ("auth_data must be specified");
12390 errmsg ("auth_method must be specified");
12394 M (IKEV2_PROFILE_SET_AUTH, mp);
12396 mp->is_hex = is_hex;
12397 mp->auth_method = (u8) auth_method;
12398 mp->data_len = vec_len (data);
12399 clib_memcpy (mp->name, name, vec_len (name));
12400 clib_memcpy (mp->data, data, vec_len (data));
12410 api_ikev2_profile_set_id (vat_main_t * vam)
12412 unformat_input_t *i = vam->input;
12413 vl_api_ikev2_profile_set_id_t *mp;
12421 const char *valid_chars = "a-zA-Z0-9_";
12423 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12425 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12426 vec_add1 (name, 0);
12427 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12429 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12431 data = vec_new (u8, 4);
12432 clib_memcpy (data, ip4.as_u8, 4);
12434 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12436 else if (unformat (i, "id_data %v", &data))
12438 else if (unformat (i, "local"))
12440 else if (unformat (i, "remote"))
12444 errmsg ("parse error '%U'", format_unformat_error, i);
12449 if (!vec_len (name))
12451 errmsg ("profile name must be specified");
12455 if (vec_len (name) > 64)
12457 errmsg ("profile name too long");
12461 if (!vec_len (data))
12463 errmsg ("id_data must be specified");
12469 errmsg ("id_type must be specified");
12473 M (IKEV2_PROFILE_SET_ID, mp);
12475 mp->is_local = is_local;
12476 mp->id_type = (u8) id_type;
12477 mp->data_len = vec_len (data);
12478 clib_memcpy (mp->name, name, vec_len (name));
12479 clib_memcpy (mp->data, data, vec_len (data));
12489 api_ikev2_profile_set_ts (vat_main_t * vam)
12491 unformat_input_t *i = vam->input;
12492 vl_api_ikev2_profile_set_ts_t *mp;
12495 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12496 ip4_address_t start_addr, end_addr;
12498 const char *valid_chars = "a-zA-Z0-9_";
12501 start_addr.as_u32 = 0;
12502 end_addr.as_u32 = (u32) ~ 0;
12504 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12506 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12507 vec_add1 (name, 0);
12508 else if (unformat (i, "protocol %d", &proto))
12510 else if (unformat (i, "start_port %d", &start_port))
12512 else if (unformat (i, "end_port %d", &end_port))
12515 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12517 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12519 else if (unformat (i, "local"))
12521 else if (unformat (i, "remote"))
12525 errmsg ("parse error '%U'", format_unformat_error, i);
12530 if (!vec_len (name))
12532 errmsg ("profile name must be specified");
12536 if (vec_len (name) > 64)
12538 errmsg ("profile name too long");
12542 M (IKEV2_PROFILE_SET_TS, mp);
12544 mp->is_local = is_local;
12545 mp->proto = (u8) proto;
12546 mp->start_port = (u16) start_port;
12547 mp->end_port = (u16) end_port;
12548 mp->start_addr = start_addr.as_u32;
12549 mp->end_addr = end_addr.as_u32;
12550 clib_memcpy (mp->name, name, vec_len (name));
12559 api_ikev2_set_local_key (vat_main_t * vam)
12561 unformat_input_t *i = vam->input;
12562 vl_api_ikev2_set_local_key_t *mp;
12566 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12568 if (unformat (i, "file %v", &file))
12569 vec_add1 (file, 0);
12572 errmsg ("parse error '%U'", format_unformat_error, i);
12577 if (!vec_len (file))
12579 errmsg ("RSA key file must be specified");
12583 if (vec_len (file) > 256)
12585 errmsg ("file name too long");
12589 M (IKEV2_SET_LOCAL_KEY, mp);
12591 clib_memcpy (mp->key_file, file, vec_len (file));
12600 api_ikev2_set_responder (vat_main_t * vam)
12602 unformat_input_t *i = vam->input;
12603 vl_api_ikev2_set_responder_t *mp;
12606 u32 sw_if_index = ~0;
12607 ip4_address_t address;
12609 const char *valid_chars = "a-zA-Z0-9_";
12611 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12614 (i, "%U interface %d address %U", unformat_token, valid_chars,
12615 &name, &sw_if_index, unformat_ip4_address, &address))
12616 vec_add1 (name, 0);
12619 errmsg ("parse error '%U'", format_unformat_error, i);
12624 if (!vec_len (name))
12626 errmsg ("profile name must be specified");
12630 if (vec_len (name) > 64)
12632 errmsg ("profile name too long");
12636 M (IKEV2_SET_RESPONDER, mp);
12638 clib_memcpy (mp->name, name, vec_len (name));
12641 mp->sw_if_index = sw_if_index;
12642 clib_memcpy (mp->address, &address, sizeof (address));
12650 api_ikev2_set_ike_transforms (vat_main_t * vam)
12652 unformat_input_t *i = vam->input;
12653 vl_api_ikev2_set_ike_transforms_t *mp;
12656 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12658 const char *valid_chars = "a-zA-Z0-9_";
12660 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12662 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12663 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12664 vec_add1 (name, 0);
12667 errmsg ("parse error '%U'", format_unformat_error, i);
12672 if (!vec_len (name))
12674 errmsg ("profile name must be specified");
12678 if (vec_len (name) > 64)
12680 errmsg ("profile name too long");
12684 M (IKEV2_SET_IKE_TRANSFORMS, mp);
12686 clib_memcpy (mp->name, name, vec_len (name));
12688 mp->crypto_alg = crypto_alg;
12689 mp->crypto_key_size = crypto_key_size;
12690 mp->integ_alg = integ_alg;
12691 mp->dh_group = dh_group;
12700 api_ikev2_set_esp_transforms (vat_main_t * vam)
12702 unformat_input_t *i = vam->input;
12703 vl_api_ikev2_set_esp_transforms_t *mp;
12706 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12708 const char *valid_chars = "a-zA-Z0-9_";
12710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12712 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12713 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12714 vec_add1 (name, 0);
12717 errmsg ("parse error '%U'", format_unformat_error, i);
12722 if (!vec_len (name))
12724 errmsg ("profile name must be specified");
12728 if (vec_len (name) > 64)
12730 errmsg ("profile name too long");
12734 M (IKEV2_SET_ESP_TRANSFORMS, mp);
12736 clib_memcpy (mp->name, name, vec_len (name));
12738 mp->crypto_alg = crypto_alg;
12739 mp->crypto_key_size = crypto_key_size;
12740 mp->integ_alg = integ_alg;
12741 mp->dh_group = dh_group;
12749 api_ikev2_set_sa_lifetime (vat_main_t * vam)
12751 unformat_input_t *i = vam->input;
12752 vl_api_ikev2_set_sa_lifetime_t *mp;
12755 u64 lifetime, lifetime_maxdata;
12756 u32 lifetime_jitter, handover;
12758 const char *valid_chars = "a-zA-Z0-9_";
12760 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12762 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
12763 &lifetime, &lifetime_jitter, &handover,
12764 &lifetime_maxdata))
12765 vec_add1 (name, 0);
12768 errmsg ("parse error '%U'", format_unformat_error, i);
12773 if (!vec_len (name))
12775 errmsg ("profile name must be specified");
12779 if (vec_len (name) > 64)
12781 errmsg ("profile name too long");
12785 M (IKEV2_SET_SA_LIFETIME, mp);
12787 clib_memcpy (mp->name, name, vec_len (name));
12789 mp->lifetime = lifetime;
12790 mp->lifetime_jitter = lifetime_jitter;
12791 mp->handover = handover;
12792 mp->lifetime_maxdata = lifetime_maxdata;
12800 api_ikev2_initiate_sa_init (vat_main_t * vam)
12802 unformat_input_t *i = vam->input;
12803 vl_api_ikev2_initiate_sa_init_t *mp;
12807 const char *valid_chars = "a-zA-Z0-9_";
12809 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12811 if (unformat (i, "%U", unformat_token, valid_chars, &name))
12812 vec_add1 (name, 0);
12815 errmsg ("parse error '%U'", format_unformat_error, i);
12820 if (!vec_len (name))
12822 errmsg ("profile name must be specified");
12826 if (vec_len (name) > 64)
12828 errmsg ("profile name too long");
12832 M (IKEV2_INITIATE_SA_INIT, mp);
12834 clib_memcpy (mp->name, name, vec_len (name));
12843 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
12845 unformat_input_t *i = vam->input;
12846 vl_api_ikev2_initiate_del_ike_sa_t *mp;
12851 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12853 if (unformat (i, "%lx", &ispi))
12857 errmsg ("parse error '%U'", format_unformat_error, i);
12862 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
12872 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
12874 unformat_input_t *i = vam->input;
12875 vl_api_ikev2_initiate_del_child_sa_t *mp;
12880 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12882 if (unformat (i, "%x", &ispi))
12886 errmsg ("parse error '%U'", format_unformat_error, i);
12891 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
12901 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
12903 unformat_input_t *i = vam->input;
12904 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
12909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12911 if (unformat (i, "%x", &ispi))
12915 errmsg ("parse error '%U'", format_unformat_error, i);
12920 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
12933 api_map_add_domain (vat_main_t * vam)
12935 unformat_input_t *i = vam->input;
12936 vl_api_map_add_domain_t *mp;
12938 ip4_address_t ip4_prefix;
12939 ip6_address_t ip6_prefix;
12940 ip6_address_t ip6_src;
12941 u32 num_m_args = 0;
12942 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12943 0, psid_length = 0;
12944 u8 is_translation = 0;
12946 u32 ip6_src_len = 128;
12949 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12951 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12952 &ip4_prefix, &ip4_prefix_len))
12954 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12955 &ip6_prefix, &ip6_prefix_len))
12959 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12962 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12964 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12966 else if (unformat (i, "psid-offset %d", &psid_offset))
12968 else if (unformat (i, "psid-len %d", &psid_length))
12970 else if (unformat (i, "mtu %d", &mtu))
12972 else if (unformat (i, "map-t"))
12973 is_translation = 1;
12976 clib_warning ("parse error '%U'", format_unformat_error, i);
12981 if (num_m_args < 3)
12983 errmsg ("mandatory argument(s) missing");
12987 /* Construct the API message */
12988 M (MAP_ADD_DOMAIN, mp);
12990 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12991 mp->ip4_prefix_len = ip4_prefix_len;
12993 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12994 mp->ip6_prefix_len = ip6_prefix_len;
12996 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12997 mp->ip6_src_prefix_len = ip6_src_len;
12999 mp->ea_bits_len = ea_bits_len;
13000 mp->psid_offset = psid_offset;
13001 mp->psid_length = psid_length;
13002 mp->is_translation = is_translation;
13003 mp->mtu = htons (mtu);
13008 /* Wait for a reply, return good/bad news */
13014 api_map_del_domain (vat_main_t * vam)
13016 unformat_input_t *i = vam->input;
13017 vl_api_map_del_domain_t *mp;
13019 u32 num_m_args = 0;
13023 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13025 if (unformat (i, "index %d", &index))
13029 clib_warning ("parse error '%U'", format_unformat_error, i);
13034 if (num_m_args != 1)
13036 errmsg ("mandatory argument(s) missing");
13040 /* Construct the API message */
13041 M (MAP_DEL_DOMAIN, mp);
13043 mp->index = ntohl (index);
13048 /* Wait for a reply, return good/bad news */
13054 api_map_add_del_rule (vat_main_t * vam)
13056 unformat_input_t *i = vam->input;
13057 vl_api_map_add_del_rule_t *mp;
13059 ip6_address_t ip6_dst;
13060 u32 num_m_args = 0, index, psid = 0;
13063 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13065 if (unformat (i, "index %d", &index))
13067 else if (unformat (i, "psid %d", &psid))
13069 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13071 else if (unformat (i, "del"))
13077 clib_warning ("parse error '%U'", format_unformat_error, i);
13082 /* Construct the API message */
13083 M (MAP_ADD_DEL_RULE, mp);
13085 mp->index = ntohl (index);
13086 mp->is_add = is_add;
13087 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13088 mp->psid = ntohs (psid);
13093 /* Wait for a reply, return good/bad news */
13099 api_map_domain_dump (vat_main_t * vam)
13101 vl_api_map_domain_dump_t *mp;
13102 vl_api_control_ping_t *mp_ping;
13105 /* Construct the API message */
13106 M (MAP_DOMAIN_DUMP, mp);
13111 /* Use a control ping for synchronization */
13112 M (CONTROL_PING, mp_ping);
13120 api_map_rule_dump (vat_main_t * vam)
13122 unformat_input_t *i = vam->input;
13123 vl_api_map_rule_dump_t *mp;
13124 vl_api_control_ping_t *mp_ping;
13125 u32 domain_index = ~0;
13128 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13130 if (unformat (i, "index %u", &domain_index))
13136 if (domain_index == ~0)
13138 clib_warning ("parse error: domain index expected");
13142 /* Construct the API message */
13143 M (MAP_RULE_DUMP, mp);
13145 mp->domain_index = htonl (domain_index);
13150 /* Use a control ping for synchronization */
13151 M (CONTROL_PING, mp_ping);
13158 static void vl_api_map_add_domain_reply_t_handler
13159 (vl_api_map_add_domain_reply_t * mp)
13161 vat_main_t *vam = &vat_main;
13162 i32 retval = ntohl (mp->retval);
13164 if (vam->async_mode)
13166 vam->async_errors += (retval < 0);
13170 vam->retval = retval;
13171 vam->result_ready = 1;
13175 static void vl_api_map_add_domain_reply_t_handler_json
13176 (vl_api_map_add_domain_reply_t * mp)
13178 vat_main_t *vam = &vat_main;
13179 vat_json_node_t node;
13181 vat_json_init_object (&node);
13182 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13183 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13185 vat_json_print (vam->ofp, &node);
13186 vat_json_free (&node);
13188 vam->retval = ntohl (mp->retval);
13189 vam->result_ready = 1;
13193 api_get_first_msg_id (vat_main_t * vam)
13195 vl_api_get_first_msg_id_t *mp;
13196 unformat_input_t *i = vam->input;
13201 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13203 if (unformat (i, "client %s", &name))
13211 errmsg ("missing client name");
13214 vec_add1 (name, 0);
13216 if (vec_len (name) > 63)
13218 errmsg ("client name too long");
13222 M (GET_FIRST_MSG_ID, mp);
13223 clib_memcpy (mp->name, name, vec_len (name));
13230 api_cop_interface_enable_disable (vat_main_t * vam)
13232 unformat_input_t *line_input = vam->input;
13233 vl_api_cop_interface_enable_disable_t *mp;
13234 u32 sw_if_index = ~0;
13235 u8 enable_disable = 1;
13238 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13240 if (unformat (line_input, "disable"))
13241 enable_disable = 0;
13242 if (unformat (line_input, "enable"))
13243 enable_disable = 1;
13244 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13245 vam, &sw_if_index))
13247 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13253 if (sw_if_index == ~0)
13255 errmsg ("missing interface name or sw_if_index");
13259 /* Construct the API message */
13260 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13261 mp->sw_if_index = ntohl (sw_if_index);
13262 mp->enable_disable = enable_disable;
13266 /* Wait for the reply */
13272 api_cop_whitelist_enable_disable (vat_main_t * vam)
13274 unformat_input_t *line_input = vam->input;
13275 vl_api_cop_whitelist_enable_disable_t *mp;
13276 u32 sw_if_index = ~0;
13277 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13281 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13283 if (unformat (line_input, "ip4"))
13285 else if (unformat (line_input, "ip6"))
13287 else if (unformat (line_input, "default"))
13289 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13290 vam, &sw_if_index))
13292 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13294 else if (unformat (line_input, "fib-id %d", &fib_id))
13300 if (sw_if_index == ~0)
13302 errmsg ("missing interface name or sw_if_index");
13306 /* Construct the API message */
13307 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13308 mp->sw_if_index = ntohl (sw_if_index);
13309 mp->fib_id = ntohl (fib_id);
13312 mp->default_cop = default_cop;
13316 /* Wait for the reply */
13322 api_get_node_graph (vat_main_t * vam)
13324 vl_api_get_node_graph_t *mp;
13327 M (GET_NODE_GRAPH, mp);
13331 /* Wait for the reply */
13337 /** Used for parsing LISP eids */
13338 typedef CLIB_PACKED(struct{
13339 u8 addr[16]; /**< eid address */
13340 u32 len; /**< prefix length if IP */
13341 u8 type; /**< type of eid */
13346 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13348 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13350 memset (a, 0, sizeof (a[0]));
13352 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13354 a->type = 0; /* ipv4 type */
13356 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13358 a->type = 1; /* ipv6 type */
13360 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13362 a->type = 2; /* mac type */
13369 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13378 lisp_eid_size_vat (u8 type)
13393 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13395 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13399 api_one_add_del_locator_set (vat_main_t * vam)
13401 unformat_input_t *input = vam->input;
13402 vl_api_one_add_del_locator_set_t *mp;
13404 u8 *locator_set_name = NULL;
13405 u8 locator_set_name_set = 0;
13406 vl_api_local_locator_t locator, *locators = 0;
13407 u32 sw_if_index, priority, weight;
13411 /* Parse args required to build the message */
13412 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13414 if (unformat (input, "del"))
13418 else if (unformat (input, "locator-set %s", &locator_set_name))
13420 locator_set_name_set = 1;
13422 else if (unformat (input, "sw_if_index %u p %u w %u",
13423 &sw_if_index, &priority, &weight))
13425 locator.sw_if_index = htonl (sw_if_index);
13426 locator.priority = priority;
13427 locator.weight = weight;
13428 vec_add1 (locators, locator);
13432 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13433 &sw_if_index, &priority, &weight))
13435 locator.sw_if_index = htonl (sw_if_index);
13436 locator.priority = priority;
13437 locator.weight = weight;
13438 vec_add1 (locators, locator);
13444 if (locator_set_name_set == 0)
13446 errmsg ("missing locator-set name");
13447 vec_free (locators);
13451 if (vec_len (locator_set_name) > 64)
13453 errmsg ("locator-set name too long");
13454 vec_free (locator_set_name);
13455 vec_free (locators);
13458 vec_add1 (locator_set_name, 0);
13460 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13462 /* Construct the API message */
13463 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
13465 mp->is_add = is_add;
13466 clib_memcpy (mp->locator_set_name, locator_set_name,
13467 vec_len (locator_set_name));
13468 vec_free (locator_set_name);
13470 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13472 clib_memcpy (mp->locators, locators, data_len);
13473 vec_free (locators);
13478 /* Wait for a reply... */
13483 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
13486 api_one_add_del_locator (vat_main_t * vam)
13488 unformat_input_t *input = vam->input;
13489 vl_api_one_add_del_locator_t *mp;
13490 u32 tmp_if_index = ~0;
13491 u32 sw_if_index = ~0;
13492 u8 sw_if_index_set = 0;
13493 u8 sw_if_index_if_name_set = 0;
13495 u8 priority_set = 0;
13499 u8 *locator_set_name = NULL;
13500 u8 locator_set_name_set = 0;
13503 /* Parse args required to build the message */
13504 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13506 if (unformat (input, "del"))
13510 else if (unformat (input, "locator-set %s", &locator_set_name))
13512 locator_set_name_set = 1;
13514 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13517 sw_if_index_if_name_set = 1;
13518 sw_if_index = tmp_if_index;
13520 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13522 sw_if_index_set = 1;
13523 sw_if_index = tmp_if_index;
13525 else if (unformat (input, "p %d", &priority))
13529 else if (unformat (input, "w %d", &weight))
13537 if (locator_set_name_set == 0)
13539 errmsg ("missing locator-set name");
13543 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13545 errmsg ("missing sw_if_index");
13546 vec_free (locator_set_name);
13550 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13552 errmsg ("cannot use both params interface name and sw_if_index");
13553 vec_free (locator_set_name);
13557 if (priority_set == 0)
13559 errmsg ("missing locator-set priority");
13560 vec_free (locator_set_name);
13564 if (weight_set == 0)
13566 errmsg ("missing locator-set weight");
13567 vec_free (locator_set_name);
13571 if (vec_len (locator_set_name) > 64)
13573 errmsg ("locator-set name too long");
13574 vec_free (locator_set_name);
13577 vec_add1 (locator_set_name, 0);
13579 /* Construct the API message */
13580 M (ONE_ADD_DEL_LOCATOR, mp);
13582 mp->is_add = is_add;
13583 mp->sw_if_index = ntohl (sw_if_index);
13584 mp->priority = priority;
13585 mp->weight = weight;
13586 clib_memcpy (mp->locator_set_name, locator_set_name,
13587 vec_len (locator_set_name));
13588 vec_free (locator_set_name);
13593 /* Wait for a reply... */
13598 #define api_lisp_add_del_locator api_one_add_del_locator
13601 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13603 u32 *key_id = va_arg (*args, u32 *);
13606 if (unformat (input, "%s", &s))
13608 if (!strcmp ((char *) s, "sha1"))
13609 key_id[0] = HMAC_SHA_1_96;
13610 else if (!strcmp ((char *) s, "sha256"))
13611 key_id[0] = HMAC_SHA_256_128;
13614 clib_warning ("invalid key_id: '%s'", s);
13615 key_id[0] = HMAC_NO_KEY;
13626 api_one_add_del_local_eid (vat_main_t * vam)
13628 unformat_input_t *input = vam->input;
13629 vl_api_one_add_del_local_eid_t *mp;
13632 lisp_eid_vat_t _eid, *eid = &_eid;
13633 u8 *locator_set_name = 0;
13634 u8 locator_set_name_set = 0;
13640 /* Parse args required to build the message */
13641 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13643 if (unformat (input, "del"))
13647 else if (unformat (input, "vni %d", &vni))
13651 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13655 else if (unformat (input, "locator-set %s", &locator_set_name))
13657 locator_set_name_set = 1;
13659 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13661 else if (unformat (input, "secret-key %_%v%_", &key))
13667 if (locator_set_name_set == 0)
13669 errmsg ("missing locator-set name");
13675 errmsg ("EID address not set!");
13676 vec_free (locator_set_name);
13680 if (key && (0 == key_id))
13682 errmsg ("invalid key_id!");
13686 if (vec_len (key) > 64)
13688 errmsg ("key too long");
13693 if (vec_len (locator_set_name) > 64)
13695 errmsg ("locator-set name too long");
13696 vec_free (locator_set_name);
13699 vec_add1 (locator_set_name, 0);
13701 /* Construct the API message */
13702 M (ONE_ADD_DEL_LOCAL_EID, mp);
13704 mp->is_add = is_add;
13705 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13706 mp->eid_type = eid->type;
13707 mp->prefix_len = eid->len;
13708 mp->vni = clib_host_to_net_u32 (vni);
13709 mp->key_id = clib_host_to_net_u16 (key_id);
13710 clib_memcpy (mp->locator_set_name, locator_set_name,
13711 vec_len (locator_set_name));
13712 clib_memcpy (mp->key, key, vec_len (key));
13714 vec_free (locator_set_name);
13720 /* Wait for a reply... */
13725 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
13728 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13730 u32 dp_table = 0, vni = 0;;
13731 unformat_input_t *input = vam->input;
13732 vl_api_gpe_add_del_fwd_entry_t *mp;
13734 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13735 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13736 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13737 u32 action = ~0, w;
13738 ip4_address_t rmt_rloc4, lcl_rloc4;
13739 ip6_address_t rmt_rloc6, lcl_rloc6;
13740 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13743 memset (&rloc, 0, sizeof (rloc));
13745 /* Parse args required to build the message */
13746 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13748 if (unformat (input, "del"))
13750 else if (unformat (input, "add"))
13752 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13756 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13760 else if (unformat (input, "vrf %d", &dp_table))
13762 else if (unformat (input, "bd %d", &dp_table))
13764 else if (unformat (input, "vni %d", &vni))
13766 else if (unformat (input, "w %d", &w))
13770 errmsg ("No RLOC configured for setting priority/weight!");
13773 curr_rloc->weight = w;
13775 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13776 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13780 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13782 vec_add1 (lcl_locs, rloc);
13784 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13785 vec_add1 (rmt_locs, rloc);
13786 /* weight saved in rmt loc */
13787 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13789 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13790 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13793 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13795 vec_add1 (lcl_locs, rloc);
13797 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13798 vec_add1 (rmt_locs, rloc);
13799 /* weight saved in rmt loc */
13800 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13802 else if (unformat (input, "action %d", &action))
13808 clib_warning ("parse error '%U'", format_unformat_error, input);
13815 errmsg ("remote eid addresses not set");
13819 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13821 errmsg ("eid types don't match");
13825 if (0 == rmt_locs && (u32) ~ 0 == action)
13827 errmsg ("action not set for negative mapping");
13831 /* Construct the API message */
13832 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
13833 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
13835 mp->is_add = is_add;
13836 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13837 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13838 mp->eid_type = rmt_eid->type;
13839 mp->dp_table = clib_host_to_net_u32 (dp_table);
13840 mp->vni = clib_host_to_net_u32 (vni);
13841 mp->rmt_len = rmt_eid->len;
13842 mp->lcl_len = lcl_eid->len;
13843 mp->action = action;
13845 if (0 != rmt_locs && 0 != lcl_locs)
13847 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
13848 clib_memcpy (mp->locs, lcl_locs,
13849 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
13851 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
13852 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
13853 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
13855 vec_free (lcl_locs);
13856 vec_free (rmt_locs);
13861 /* Wait for a reply... */
13867 api_one_add_del_map_server (vat_main_t * vam)
13869 unformat_input_t *input = vam->input;
13870 vl_api_one_add_del_map_server_t *mp;
13874 ip4_address_t ipv4;
13875 ip6_address_t ipv6;
13878 /* Parse args required to build the message */
13879 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13881 if (unformat (input, "del"))
13885 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13889 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13897 if (ipv4_set && ipv6_set)
13899 errmsg ("both eid v4 and v6 addresses set");
13903 if (!ipv4_set && !ipv6_set)
13905 errmsg ("eid addresses not set");
13909 /* Construct the API message */
13910 M (ONE_ADD_DEL_MAP_SERVER, mp);
13912 mp->is_add = is_add;
13916 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13921 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13927 /* Wait for a reply... */
13932 #define api_lisp_add_del_map_server api_one_add_del_map_server
13935 api_one_add_del_map_resolver (vat_main_t * vam)
13937 unformat_input_t *input = vam->input;
13938 vl_api_one_add_del_map_resolver_t *mp;
13942 ip4_address_t ipv4;
13943 ip6_address_t ipv6;
13946 /* Parse args required to build the message */
13947 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13949 if (unformat (input, "del"))
13953 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13957 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13965 if (ipv4_set && ipv6_set)
13967 errmsg ("both eid v4 and v6 addresses set");
13971 if (!ipv4_set && !ipv6_set)
13973 errmsg ("eid addresses not set");
13977 /* Construct the API message */
13978 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
13980 mp->is_add = is_add;
13984 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13989 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13995 /* Wait for a reply... */
14000 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14003 api_lisp_gpe_enable_disable (vat_main_t * vam)
14005 unformat_input_t *input = vam->input;
14006 vl_api_gpe_enable_disable_t *mp;
14011 /* Parse args required to build the message */
14012 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14014 if (unformat (input, "enable"))
14019 else if (unformat (input, "disable"))
14030 errmsg ("Value not set");
14034 /* Construct the API message */
14035 M (GPE_ENABLE_DISABLE, mp);
14042 /* Wait for a reply... */
14048 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14050 unformat_input_t *input = vam->input;
14051 vl_api_one_rloc_probe_enable_disable_t *mp;
14056 /* Parse args required to build the message */
14057 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14059 if (unformat (input, "enable"))
14064 else if (unformat (input, "disable"))
14072 errmsg ("Value not set");
14076 /* Construct the API message */
14077 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14079 mp->is_enabled = is_en;
14084 /* Wait for a reply... */
14089 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14092 api_one_map_register_enable_disable (vat_main_t * vam)
14094 unformat_input_t *input = vam->input;
14095 vl_api_one_map_register_enable_disable_t *mp;
14100 /* Parse args required to build the message */
14101 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14103 if (unformat (input, "enable"))
14108 else if (unformat (input, "disable"))
14116 errmsg ("Value not set");
14120 /* Construct the API message */
14121 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14123 mp->is_enabled = is_en;
14128 /* Wait for a reply... */
14133 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14136 api_one_enable_disable (vat_main_t * vam)
14138 unformat_input_t *input = vam->input;
14139 vl_api_one_enable_disable_t *mp;
14144 /* Parse args required to build the message */
14145 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14147 if (unformat (input, "enable"))
14152 else if (unformat (input, "disable"))
14162 errmsg ("Value not set");
14166 /* Construct the API message */
14167 M (ONE_ENABLE_DISABLE, mp);
14174 /* Wait for a reply... */
14179 #define api_lisp_enable_disable api_one_enable_disable
14182 api_show_one_map_register_state (vat_main_t * vam)
14184 vl_api_show_one_map_register_state_t *mp;
14187 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14192 /* wait for reply */
14197 #define api_show_lisp_map_register_state api_show_one_map_register_state
14200 api_show_one_rloc_probe_state (vat_main_t * vam)
14202 vl_api_show_one_rloc_probe_state_t *mp;
14205 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14210 /* wait for reply */
14215 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14218 api_show_one_map_request_mode (vat_main_t * vam)
14220 vl_api_show_one_map_request_mode_t *mp;
14223 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
14228 /* wait for reply */
14233 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
14236 api_one_map_request_mode (vat_main_t * vam)
14238 unformat_input_t *input = vam->input;
14239 vl_api_one_map_request_mode_t *mp;
14243 /* Parse args required to build the message */
14244 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14246 if (unformat (input, "dst-only"))
14248 else if (unformat (input, "src-dst"))
14252 errmsg ("parse error '%U'", format_unformat_error, input);
14257 M (ONE_MAP_REQUEST_MODE, mp);
14264 /* wait for reply */
14269 #define api_lisp_map_request_mode api_one_map_request_mode
14272 * Enable/disable ONE proxy ITR.
14274 * @param vam vpp API test context
14275 * @return return code
14278 api_one_pitr_set_locator_set (vat_main_t * vam)
14280 u8 ls_name_set = 0;
14281 unformat_input_t *input = vam->input;
14282 vl_api_one_pitr_set_locator_set_t *mp;
14287 /* Parse args required to build the message */
14288 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14290 if (unformat (input, "del"))
14292 else if (unformat (input, "locator-set %s", &ls_name))
14296 errmsg ("parse error '%U'", format_unformat_error, input);
14303 errmsg ("locator-set name not set!");
14307 M (ONE_PITR_SET_LOCATOR_SET, mp);
14309 mp->is_add = is_add;
14310 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14311 vec_free (ls_name);
14316 /* wait for reply */
14321 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
14324 api_show_one_pitr (vat_main_t * vam)
14326 vl_api_show_one_pitr_t *mp;
14329 if (!vam->json_output)
14331 print (vam->ofp, "%=20s", "lisp status:");
14334 M (SHOW_ONE_PITR, mp);
14338 /* Wait for a reply... */
14343 #define api_show_lisp_pitr api_show_one_pitr
14346 api_one_use_petr (vat_main_t * vam)
14348 unformat_input_t *input = vam->input;
14349 vl_api_one_use_petr_t *mp;
14354 memset (&ip, 0, sizeof (ip));
14356 /* Parse args required to build the message */
14357 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14359 if (unformat (input, "disable"))
14362 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
14365 ip_addr_version (&ip) = IP4;
14368 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
14371 ip_addr_version (&ip) = IP6;
14375 errmsg ("parse error '%U'", format_unformat_error, input);
14380 M (ONE_USE_PETR, mp);
14382 mp->is_add = is_add;
14385 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
14387 clib_memcpy (mp->address, &ip, 4);
14389 clib_memcpy (mp->address, &ip, 16);
14395 /* wait for reply */
14400 #define api_lisp_use_petr api_one_use_petr
14403 api_show_one_use_petr (vat_main_t * vam)
14405 vl_api_show_one_use_petr_t *mp;
14408 if (!vam->json_output)
14410 print (vam->ofp, "%=20s", "Proxy-ETR status:");
14413 M (SHOW_ONE_USE_PETR, mp);
14417 /* Wait for a reply... */
14422 #define api_show_lisp_use_petr api_show_one_use_petr
14425 * Add/delete mapping between vni and vrf
14428 api_one_eid_table_add_del_map (vat_main_t * vam)
14430 unformat_input_t *input = vam->input;
14431 vl_api_one_eid_table_add_del_map_t *mp;
14432 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
14433 u32 vni, vrf, bd_index;
14436 /* Parse args required to build the message */
14437 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14439 if (unformat (input, "del"))
14441 else if (unformat (input, "vrf %d", &vrf))
14443 else if (unformat (input, "bd_index %d", &bd_index))
14445 else if (unformat (input, "vni %d", &vni))
14451 if (!vni_set || (!vrf_set && !bd_index_set))
14453 errmsg ("missing arguments!");
14457 if (vrf_set && bd_index_set)
14459 errmsg ("error: both vrf and bd entered!");
14463 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
14465 mp->is_add = is_add;
14466 mp->vni = htonl (vni);
14467 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
14468 mp->is_l2 = bd_index_set;
14473 /* wait for reply */
14478 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
14481 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
14483 u32 *action = va_arg (*args, u32 *);
14486 if (unformat (input, "%s", &s))
14488 if (!strcmp ((char *) s, "no-action"))
14490 else if (!strcmp ((char *) s, "natively-forward"))
14492 else if (!strcmp ((char *) s, "send-map-request"))
14494 else if (!strcmp ((char *) s, "drop"))
14498 clib_warning ("invalid action: '%s'", s);
14510 * Add/del remote mapping to/from ONE control plane
14512 * @param vam vpp API test context
14513 * @return return code
14516 api_one_add_del_remote_mapping (vat_main_t * vam)
14518 unformat_input_t *input = vam->input;
14519 vl_api_one_add_del_remote_mapping_t *mp;
14521 lisp_eid_vat_t _eid, *eid = &_eid;
14522 lisp_eid_vat_t _seid, *seid = &_seid;
14523 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
14524 u32 action = ~0, p, w, data_len;
14525 ip4_address_t rloc4;
14526 ip6_address_t rloc6;
14527 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
14530 memset (&rloc, 0, sizeof (rloc));
14532 /* Parse args required to build the message */
14533 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14535 if (unformat (input, "del-all"))
14539 else if (unformat (input, "del"))
14543 else if (unformat (input, "add"))
14547 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14551 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14555 else if (unformat (input, "vni %d", &vni))
14559 else if (unformat (input, "p %d w %d", &p, &w))
14563 errmsg ("No RLOC configured for setting priority/weight!");
14566 curr_rloc->priority = p;
14567 curr_rloc->weight = w;
14569 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14572 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14573 vec_add1 (rlocs, rloc);
14574 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14576 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14579 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14580 vec_add1 (rlocs, rloc);
14581 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14583 else if (unformat (input, "action %U",
14584 unformat_negative_mapping_action, &action))
14590 clib_warning ("parse error '%U'", format_unformat_error, input);
14597 errmsg ("missing params!");
14601 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14603 errmsg ("no action set for negative map-reply!");
14607 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
14609 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
14610 mp->is_add = is_add;
14611 mp->vni = htonl (vni);
14612 mp->action = (u8) action;
14613 mp->is_src_dst = seid_set;
14614 mp->eid_len = eid->len;
14615 mp->seid_len = seid->len;
14616 mp->del_all = del_all;
14617 mp->eid_type = eid->type;
14618 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14619 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14621 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14622 clib_memcpy (mp->rlocs, rlocs, data_len);
14628 /* Wait for a reply... */
14633 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
14636 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
14637 * forwarding entries in data-plane accordingly.
14639 * @param vam vpp API test context
14640 * @return return code
14643 api_one_add_del_adjacency (vat_main_t * vam)
14645 unformat_input_t *input = vam->input;
14646 vl_api_one_add_del_adjacency_t *mp;
14648 ip4_address_t leid4, reid4;
14649 ip6_address_t leid6, reid6;
14650 u8 reid_mac[6] = { 0 };
14651 u8 leid_mac[6] = { 0 };
14652 u8 reid_type, leid_type;
14653 u32 leid_len = 0, reid_len = 0, len;
14657 leid_type = reid_type = (u8) ~ 0;
14659 /* Parse args required to build the message */
14660 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14662 if (unformat (input, "del"))
14666 else if (unformat (input, "add"))
14670 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14673 reid_type = 0; /* ipv4 */
14676 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14679 reid_type = 1; /* ipv6 */
14682 else if (unformat (input, "reid %U", unformat_ethernet_address,
14685 reid_type = 2; /* mac */
14687 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14690 leid_type = 0; /* ipv4 */
14693 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14696 leid_type = 1; /* ipv6 */
14699 else if (unformat (input, "leid %U", unformat_ethernet_address,
14702 leid_type = 2; /* mac */
14704 else if (unformat (input, "vni %d", &vni))
14710 errmsg ("parse error '%U'", format_unformat_error, input);
14715 if ((u8) ~ 0 == reid_type)
14717 errmsg ("missing params!");
14721 if (leid_type != reid_type)
14723 errmsg ("remote and local EIDs are of different types!");
14727 M (ONE_ADD_DEL_ADJACENCY, mp);
14728 mp->is_add = is_add;
14729 mp->vni = htonl (vni);
14730 mp->leid_len = leid_len;
14731 mp->reid_len = reid_len;
14732 mp->eid_type = reid_type;
14734 switch (mp->eid_type)
14737 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14738 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14741 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14742 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14745 clib_memcpy (mp->leid, leid_mac, 6);
14746 clib_memcpy (mp->reid, reid_mac, 6);
14749 errmsg ("unknown EID type %d!", mp->eid_type);
14756 /* Wait for a reply... */
14761 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
14764 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
14766 u32 *mode = va_arg (*args, u32 *);
14768 if (unformat (input, "lisp"))
14770 else if (unformat (input, "vxlan"))
14779 api_gpe_get_encap_mode (vat_main_t * vam)
14781 vl_api_gpe_get_encap_mode_t *mp;
14784 /* Construct the API message */
14785 M (GPE_GET_ENCAP_MODE, mp);
14790 /* Wait for a reply... */
14796 api_gpe_set_encap_mode (vat_main_t * vam)
14798 unformat_input_t *input = vam->input;
14799 vl_api_gpe_set_encap_mode_t *mp;
14803 /* Parse args required to build the message */
14804 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14806 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
14812 /* Construct the API message */
14813 M (GPE_SET_ENCAP_MODE, mp);
14820 /* Wait for a reply... */
14826 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14828 unformat_input_t *input = vam->input;
14829 vl_api_gpe_add_del_iface_t *mp;
14830 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14831 u32 dp_table = 0, vni = 0;
14834 /* Parse args required to build the message */
14835 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14837 if (unformat (input, "up"))
14842 else if (unformat (input, "down"))
14847 else if (unformat (input, "table_id %d", &dp_table))
14851 else if (unformat (input, "bd_id %d", &dp_table))
14856 else if (unformat (input, "vni %d", &vni))
14864 if (action_set == 0)
14866 errmsg ("Action not set");
14869 if (dp_table_set == 0 || vni_set == 0)
14871 errmsg ("vni and dp_table must be set");
14875 /* Construct the API message */
14876 M (GPE_ADD_DEL_IFACE, mp);
14878 mp->is_add = is_add;
14879 mp->dp_table = dp_table;
14886 /* Wait for a reply... */
14892 * Add/del map request itr rlocs from ONE control plane and updates
14894 * @param vam vpp API test context
14895 * @return return code
14898 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
14900 unformat_input_t *input = vam->input;
14901 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
14902 u8 *locator_set_name = 0;
14903 u8 locator_set_name_set = 0;
14907 /* Parse args required to build the message */
14908 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14910 if (unformat (input, "del"))
14914 else if (unformat (input, "%_%v%_", &locator_set_name))
14916 locator_set_name_set = 1;
14920 clib_warning ("parse error '%U'", format_unformat_error, input);
14925 if (is_add && !locator_set_name_set)
14927 errmsg ("itr-rloc is not set!");
14931 if (is_add && vec_len (locator_set_name) > 64)
14933 errmsg ("itr-rloc locator-set name too long");
14934 vec_free (locator_set_name);
14938 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
14939 mp->is_add = is_add;
14942 clib_memcpy (mp->locator_set_name, locator_set_name,
14943 vec_len (locator_set_name));
14947 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14949 vec_free (locator_set_name);
14954 /* Wait for a reply... */
14959 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
14962 api_one_locator_dump (vat_main_t * vam)
14964 unformat_input_t *input = vam->input;
14965 vl_api_one_locator_dump_t *mp;
14966 vl_api_control_ping_t *mp_ping;
14967 u8 is_index_set = 0, is_name_set = 0;
14972 /* Parse args required to build the message */
14973 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14975 if (unformat (input, "ls_name %_%v%_", &ls_name))
14979 else if (unformat (input, "ls_index %d", &ls_index))
14985 errmsg ("parse error '%U'", format_unformat_error, input);
14990 if (!is_index_set && !is_name_set)
14992 errmsg ("error: expected one of index or name!");
14996 if (is_index_set && is_name_set)
14998 errmsg ("error: only one param expected!");
15002 if (vec_len (ls_name) > 62)
15004 errmsg ("error: locator set name too long!");
15008 if (!vam->json_output)
15010 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
15013 M (ONE_LOCATOR_DUMP, mp);
15014 mp->is_index_set = is_index_set;
15017 mp->ls_index = clib_host_to_net_u32 (ls_index);
15020 vec_add1 (ls_name, 0);
15021 strncpy ((char *) mp->ls_name, (char *) ls_name,
15022 sizeof (mp->ls_name) - 1);
15028 /* Use a control ping for synchronization */
15029 M (CONTROL_PING, mp_ping);
15032 /* Wait for a reply... */
15037 #define api_lisp_locator_dump api_one_locator_dump
15040 api_one_locator_set_dump (vat_main_t * vam)
15042 vl_api_one_locator_set_dump_t *mp;
15043 vl_api_control_ping_t *mp_ping;
15044 unformat_input_t *input = vam->input;
15048 /* Parse args required to build the message */
15049 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15051 if (unformat (input, "local"))
15055 else if (unformat (input, "remote"))
15061 errmsg ("parse error '%U'", format_unformat_error, input);
15066 if (!vam->json_output)
15068 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
15071 M (ONE_LOCATOR_SET_DUMP, mp);
15073 mp->filter = filter;
15078 /* Use a control ping for synchronization */
15079 M (CONTROL_PING, mp_ping);
15082 /* Wait for a reply... */
15087 #define api_lisp_locator_set_dump api_one_locator_set_dump
15090 api_one_eid_table_map_dump (vat_main_t * vam)
15094 unformat_input_t *input = vam->input;
15095 vl_api_one_eid_table_map_dump_t *mp;
15096 vl_api_control_ping_t *mp_ping;
15099 /* Parse args required to build the message */
15100 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15102 if (unformat (input, "l2"))
15107 else if (unformat (input, "l3"))
15114 errmsg ("parse error '%U'", format_unformat_error, input);
15121 errmsg ("expected one of 'l2' or 'l3' parameter!");
15125 if (!vam->json_output)
15127 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
15130 M (ONE_EID_TABLE_MAP_DUMP, mp);
15136 /* Use a control ping for synchronization */
15137 M (CONTROL_PING, mp_ping);
15140 /* Wait for a reply... */
15145 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
15148 api_one_eid_table_vni_dump (vat_main_t * vam)
15150 vl_api_one_eid_table_vni_dump_t *mp;
15151 vl_api_control_ping_t *mp_ping;
15154 if (!vam->json_output)
15156 print (vam->ofp, "VNI");
15159 M (ONE_EID_TABLE_VNI_DUMP, mp);
15164 /* Use a control ping for synchronization */
15165 M (CONTROL_PING, mp_ping);
15168 /* Wait for a reply... */
15173 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
15176 api_one_eid_table_dump (vat_main_t * vam)
15178 unformat_input_t *i = vam->input;
15179 vl_api_one_eid_table_dump_t *mp;
15180 vl_api_control_ping_t *mp_ping;
15181 struct in_addr ip4;
15182 struct in6_addr ip6;
15184 u8 eid_type = ~0, eid_set = 0;
15185 u32 prefix_length = ~0, t, vni = 0;
15189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15191 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
15197 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
15203 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
15208 else if (unformat (i, "vni %d", &t))
15212 else if (unformat (i, "local"))
15216 else if (unformat (i, "remote"))
15222 errmsg ("parse error '%U'", format_unformat_error, i);
15227 if (!vam->json_output)
15229 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
15230 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
15233 M (ONE_EID_TABLE_DUMP, mp);
15235 mp->filter = filter;
15239 mp->vni = htonl (vni);
15240 mp->eid_type = eid_type;
15244 mp->prefix_length = prefix_length;
15245 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
15248 mp->prefix_length = prefix_length;
15249 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
15252 clib_memcpy (mp->eid, mac, sizeof (mac));
15255 errmsg ("unknown EID type %d!", eid_type);
15263 /* Use a control ping for synchronization */
15264 M (CONTROL_PING, mp_ping);
15267 /* Wait for a reply... */
15272 #define api_lisp_eid_table_dump api_one_eid_table_dump
15275 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
15277 unformat_input_t *i = vam->input;
15278 vl_api_gpe_fwd_entries_get_t *mp;
15283 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15285 if (unformat (i, "vni %d", &vni))
15291 errmsg ("parse error '%U'", format_unformat_error, i);
15298 errmsg ("vni not set!");
15302 if (!vam->json_output)
15304 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15308 M (GPE_FWD_ENTRIES_GET, mp);
15309 mp->vni = clib_host_to_net_u32 (vni);
15314 /* Wait for a reply... */
15319 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15320 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15321 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15322 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
15325 api_one_adjacencies_get (vat_main_t * vam)
15327 unformat_input_t *i = vam->input;
15328 vl_api_one_adjacencies_get_t *mp;
15333 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15335 if (unformat (i, "vni %d", &vni))
15341 errmsg ("parse error '%U'", format_unformat_error, i);
15348 errmsg ("vni not set!");
15352 if (!vam->json_output)
15354 print (vam->ofp, "%s %40s", "leid", "reid");
15357 M (ONE_ADJACENCIES_GET, mp);
15358 mp->vni = clib_host_to_net_u32 (vni);
15363 /* Wait for a reply... */
15368 #define api_lisp_adjacencies_get api_one_adjacencies_get
15371 api_one_map_server_dump (vat_main_t * vam)
15373 vl_api_one_map_server_dump_t *mp;
15374 vl_api_control_ping_t *mp_ping;
15377 if (!vam->json_output)
15379 print (vam->ofp, "%=20s", "Map server");
15382 M (ONE_MAP_SERVER_DUMP, mp);
15386 /* Use a control ping for synchronization */
15387 M (CONTROL_PING, mp_ping);
15390 /* Wait for a reply... */
15395 #define api_lisp_map_server_dump api_one_map_server_dump
15398 api_one_map_resolver_dump (vat_main_t * vam)
15400 vl_api_one_map_resolver_dump_t *mp;
15401 vl_api_control_ping_t *mp_ping;
15404 if (!vam->json_output)
15406 print (vam->ofp, "%=20s", "Map resolver");
15409 M (ONE_MAP_RESOLVER_DUMP, mp);
15413 /* Use a control ping for synchronization */
15414 M (CONTROL_PING, mp_ping);
15417 /* Wait for a reply... */
15422 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
15425 api_show_one_status (vat_main_t * vam)
15427 vl_api_show_one_status_t *mp;
15430 if (!vam->json_output)
15432 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
15435 M (SHOW_ONE_STATUS, mp);
15438 /* Wait for a reply... */
15443 #define api_show_lisp_status api_show_one_status
15446 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
15448 vl_api_gpe_fwd_entry_path_dump_t *mp;
15449 vl_api_control_ping_t *mp_ping;
15450 unformat_input_t *i = vam->input;
15451 u32 fwd_entry_index = ~0;
15454 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15456 if (unformat (i, "index %d", &fwd_entry_index))
15462 if (~0 == fwd_entry_index)
15464 errmsg ("no index specified!");
15468 if (!vam->json_output)
15470 print (vam->ofp, "first line");
15473 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
15477 /* Use a control ping for synchronization */
15478 M (CONTROL_PING, mp_ping);
15481 /* Wait for a reply... */
15487 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
15489 vl_api_one_get_map_request_itr_rlocs_t *mp;
15492 if (!vam->json_output)
15494 print (vam->ofp, "%=20s", "itr-rlocs:");
15497 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
15500 /* Wait for a reply... */
15505 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
15508 api_af_packet_create (vat_main_t * vam)
15510 unformat_input_t *i = vam->input;
15511 vl_api_af_packet_create_t *mp;
15512 u8 *host_if_name = 0;
15514 u8 random_hw_addr = 1;
15517 memset (hw_addr, 0, sizeof (hw_addr));
15519 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15521 if (unformat (i, "name %s", &host_if_name))
15522 vec_add1 (host_if_name, 0);
15523 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15524 random_hw_addr = 0;
15529 if (!vec_len (host_if_name))
15531 errmsg ("host-interface name must be specified");
15535 if (vec_len (host_if_name) > 64)
15537 errmsg ("host-interface name too long");
15541 M (AF_PACKET_CREATE, mp);
15543 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15544 clib_memcpy (mp->hw_addr, hw_addr, 6);
15545 mp->use_random_hw_addr = random_hw_addr;
15546 vec_free (host_if_name);
15554 fprintf (vam->ofp ? vam->ofp : stderr,
15555 " new sw_if_index = %d\n", vam->sw_if_index);
15562 api_af_packet_delete (vat_main_t * vam)
15564 unformat_input_t *i = vam->input;
15565 vl_api_af_packet_delete_t *mp;
15566 u8 *host_if_name = 0;
15569 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15571 if (unformat (i, "name %s", &host_if_name))
15572 vec_add1 (host_if_name, 0);
15577 if (!vec_len (host_if_name))
15579 errmsg ("host-interface name must be specified");
15583 if (vec_len (host_if_name) > 64)
15585 errmsg ("host-interface name too long");
15589 M (AF_PACKET_DELETE, mp);
15591 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15592 vec_free (host_if_name);
15600 api_policer_add_del (vat_main_t * vam)
15602 unformat_input_t *i = vam->input;
15603 vl_api_policer_add_del_t *mp;
15613 u8 color_aware = 0;
15614 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
15617 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
15618 conform_action.dscp = 0;
15619 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
15620 exceed_action.dscp = 0;
15621 violate_action.action_type = SSE2_QOS_ACTION_DROP;
15622 violate_action.dscp = 0;
15624 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15626 if (unformat (i, "del"))
15628 else if (unformat (i, "name %s", &name))
15629 vec_add1 (name, 0);
15630 else if (unformat (i, "cir %u", &cir))
15632 else if (unformat (i, "eir %u", &eir))
15634 else if (unformat (i, "cb %u", &cb))
15636 else if (unformat (i, "eb %u", &eb))
15638 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
15641 else if (unformat (i, "round_type %U", unformat_policer_round_type,
15644 else if (unformat (i, "type %U", unformat_policer_type, &type))
15646 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
15649 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
15652 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
15655 else if (unformat (i, "color-aware"))
15661 if (!vec_len (name))
15663 errmsg ("policer name must be specified");
15667 if (vec_len (name) > 64)
15669 errmsg ("policer name too long");
15673 M (POLICER_ADD_DEL, mp);
15675 clib_memcpy (mp->name, name, vec_len (name));
15677 mp->is_add = is_add;
15682 mp->rate_type = rate_type;
15683 mp->round_type = round_type;
15685 mp->conform_action_type = conform_action.action_type;
15686 mp->conform_dscp = conform_action.dscp;
15687 mp->exceed_action_type = exceed_action.action_type;
15688 mp->exceed_dscp = exceed_action.dscp;
15689 mp->violate_action_type = violate_action.action_type;
15690 mp->violate_dscp = violate_action.dscp;
15691 mp->color_aware = color_aware;
15699 api_policer_dump (vat_main_t * vam)
15701 unformat_input_t *i = vam->input;
15702 vl_api_policer_dump_t *mp;
15703 vl_api_control_ping_t *mp_ping;
15704 u8 *match_name = 0;
15705 u8 match_name_valid = 0;
15708 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15710 if (unformat (i, "name %s", &match_name))
15712 vec_add1 (match_name, 0);
15713 match_name_valid = 1;
15719 M (POLICER_DUMP, mp);
15720 mp->match_name_valid = match_name_valid;
15721 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15722 vec_free (match_name);
15726 /* Use a control ping for synchronization */
15727 M (CONTROL_PING, mp_ping);
15730 /* Wait for a reply... */
15736 api_policer_classify_set_interface (vat_main_t * vam)
15738 unformat_input_t *i = vam->input;
15739 vl_api_policer_classify_set_interface_t *mp;
15741 int sw_if_index_set;
15742 u32 ip4_table_index = ~0;
15743 u32 ip6_table_index = ~0;
15744 u32 l2_table_index = ~0;
15748 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15750 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15751 sw_if_index_set = 1;
15752 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15753 sw_if_index_set = 1;
15754 else if (unformat (i, "del"))
15756 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15758 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15760 else if (unformat (i, "l2-table %d", &l2_table_index))
15764 clib_warning ("parse error '%U'", format_unformat_error, i);
15769 if (sw_if_index_set == 0)
15771 errmsg ("missing interface name or sw_if_index");
15775 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
15777 mp->sw_if_index = ntohl (sw_if_index);
15778 mp->ip4_table_index = ntohl (ip4_table_index);
15779 mp->ip6_table_index = ntohl (ip6_table_index);
15780 mp->l2_table_index = ntohl (l2_table_index);
15781 mp->is_add = is_add;
15789 api_policer_classify_dump (vat_main_t * vam)
15791 unformat_input_t *i = vam->input;
15792 vl_api_policer_classify_dump_t *mp;
15793 vl_api_control_ping_t *mp_ping;
15794 u8 type = POLICER_CLASSIFY_N_TABLES;
15797 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15801 errmsg ("classify table type must be specified");
15805 if (!vam->json_output)
15807 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15810 M (POLICER_CLASSIFY_DUMP, mp);
15815 /* Use a control ping for synchronization */
15816 M (CONTROL_PING, mp_ping);
15819 /* Wait for a reply... */
15825 api_netmap_create (vat_main_t * vam)
15827 unformat_input_t *i = vam->input;
15828 vl_api_netmap_create_t *mp;
15831 u8 random_hw_addr = 1;
15836 memset (hw_addr, 0, sizeof (hw_addr));
15838 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15840 if (unformat (i, "name %s", &if_name))
15841 vec_add1 (if_name, 0);
15842 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15843 random_hw_addr = 0;
15844 else if (unformat (i, "pipe"))
15846 else if (unformat (i, "master"))
15848 else if (unformat (i, "slave"))
15854 if (!vec_len (if_name))
15856 errmsg ("interface name must be specified");
15860 if (vec_len (if_name) > 64)
15862 errmsg ("interface name too long");
15866 M (NETMAP_CREATE, mp);
15868 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15869 clib_memcpy (mp->hw_addr, hw_addr, 6);
15870 mp->use_random_hw_addr = random_hw_addr;
15871 mp->is_pipe = is_pipe;
15872 mp->is_master = is_master;
15873 vec_free (if_name);
15881 api_netmap_delete (vat_main_t * vam)
15883 unformat_input_t *i = vam->input;
15884 vl_api_netmap_delete_t *mp;
15888 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15890 if (unformat (i, "name %s", &if_name))
15891 vec_add1 (if_name, 0);
15896 if (!vec_len (if_name))
15898 errmsg ("interface name must be specified");
15902 if (vec_len (if_name) > 64)
15904 errmsg ("interface name too long");
15908 M (NETMAP_DELETE, mp);
15910 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15911 vec_free (if_name);
15918 static void vl_api_mpls_tunnel_details_t_handler
15919 (vl_api_mpls_tunnel_details_t * mp)
15921 vat_main_t *vam = &vat_main;
15922 i32 len = mp->mt_next_hop_n_labels;
15925 print (vam->ofp, "[%d]: via %U %d labels ",
15927 format_ip4_address, mp->mt_next_hop,
15928 ntohl (mp->mt_next_hop_sw_if_index));
15929 for (i = 0; i < len; i++)
15931 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15933 print (vam->ofp, "");
15936 static void vl_api_mpls_tunnel_details_t_handler_json
15937 (vl_api_mpls_tunnel_details_t * mp)
15939 vat_main_t *vam = &vat_main;
15940 vat_json_node_t *node = NULL;
15941 struct in_addr ip4;
15943 i32 len = mp->mt_next_hop_n_labels;
15945 if (VAT_JSON_ARRAY != vam->json_tree.type)
15947 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15948 vat_json_init_array (&vam->json_tree);
15950 node = vat_json_array_add (&vam->json_tree);
15952 vat_json_init_object (node);
15953 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15954 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15955 vat_json_object_add_ip4 (node, "next_hop", ip4);
15956 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15957 ntohl (mp->mt_next_hop_sw_if_index));
15958 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15959 vat_json_object_add_uint (node, "label_count", len);
15960 for (i = 0; i < len; i++)
15962 vat_json_object_add_uint (node, "label",
15963 ntohl (mp->mt_next_hop_out_labels[i]));
15968 api_mpls_tunnel_dump (vat_main_t * vam)
15970 vl_api_mpls_tunnel_dump_t *mp;
15971 vl_api_control_ping_t *mp_ping;
15975 /* Parse args required to build the message */
15976 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15978 if (!unformat (vam->input, "tunnel_index %d", &index))
15985 print (vam->ofp, " tunnel_index %d", index);
15987 M (MPLS_TUNNEL_DUMP, mp);
15988 mp->tunnel_index = htonl (index);
15991 /* Use a control ping for synchronization */
15992 M (CONTROL_PING, mp_ping);
15999 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
16000 #define vl_api_mpls_fib_details_t_print vl_noop_handler
16003 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
16005 vat_main_t *vam = &vat_main;
16006 int count = ntohl (mp->count);
16007 vl_api_fib_path2_t *fp;
16011 "table-id %d, label %u, ess_bit %u",
16012 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
16014 for (i = 0; i < count; i++)
16016 if (fp->afi == IP46_TYPE_IP6)
16018 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16019 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16020 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16021 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16022 format_ip6_address, fp->next_hop);
16023 else if (fp->afi == IP46_TYPE_IP4)
16025 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16026 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16027 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16028 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16029 format_ip4_address, fp->next_hop);
16034 static void vl_api_mpls_fib_details_t_handler_json
16035 (vl_api_mpls_fib_details_t * mp)
16037 vat_main_t *vam = &vat_main;
16038 int count = ntohl (mp->count);
16039 vat_json_node_t *node = NULL;
16040 struct in_addr ip4;
16041 struct in6_addr ip6;
16042 vl_api_fib_path2_t *fp;
16045 if (VAT_JSON_ARRAY != vam->json_tree.type)
16047 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16048 vat_json_init_array (&vam->json_tree);
16050 node = vat_json_array_add (&vam->json_tree);
16052 vat_json_init_object (node);
16053 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16054 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
16055 vat_json_object_add_uint (node, "label", ntohl (mp->label));
16056 vat_json_object_add_uint (node, "path_count", count);
16058 for (i = 0; i < count; i++)
16060 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16061 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16062 vat_json_object_add_uint (node, "is_local", fp->is_local);
16063 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16064 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16065 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16066 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16067 if (fp->afi == IP46_TYPE_IP4)
16069 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16070 vat_json_object_add_ip4 (node, "next_hop", ip4);
16072 else if (fp->afi == IP46_TYPE_IP6)
16074 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16075 vat_json_object_add_ip6 (node, "next_hop", ip6);
16081 api_mpls_fib_dump (vat_main_t * vam)
16083 vl_api_mpls_fib_dump_t *mp;
16084 vl_api_control_ping_t *mp_ping;
16087 M (MPLS_FIB_DUMP, mp);
16090 /* Use a control ping for synchronization */
16091 M (CONTROL_PING, mp_ping);
16098 #define vl_api_ip_fib_details_t_endian vl_noop_handler
16099 #define vl_api_ip_fib_details_t_print vl_noop_handler
16102 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
16104 vat_main_t *vam = &vat_main;
16105 int count = ntohl (mp->count);
16106 vl_api_fib_path_t *fp;
16110 "table-id %d, prefix %U/%d",
16111 ntohl (mp->table_id), format_ip4_address, mp->address,
16112 mp->address_length);
16114 for (i = 0; i < count; i++)
16116 if (fp->afi == IP46_TYPE_IP6)
16118 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16119 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16120 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16121 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16122 format_ip6_address, fp->next_hop);
16123 else if (fp->afi == IP46_TYPE_IP4)
16125 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16126 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16127 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16128 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16129 format_ip4_address, fp->next_hop);
16134 static void vl_api_ip_fib_details_t_handler_json
16135 (vl_api_ip_fib_details_t * mp)
16137 vat_main_t *vam = &vat_main;
16138 int count = ntohl (mp->count);
16139 vat_json_node_t *node = NULL;
16140 struct in_addr ip4;
16141 struct in6_addr ip6;
16142 vl_api_fib_path_t *fp;
16145 if (VAT_JSON_ARRAY != vam->json_tree.type)
16147 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16148 vat_json_init_array (&vam->json_tree);
16150 node = vat_json_array_add (&vam->json_tree);
16152 vat_json_init_object (node);
16153 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16154 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
16155 vat_json_object_add_ip4 (node, "prefix", ip4);
16156 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16157 vat_json_object_add_uint (node, "path_count", count);
16159 for (i = 0; i < count; i++)
16161 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16162 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16163 vat_json_object_add_uint (node, "is_local", fp->is_local);
16164 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16165 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16166 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16167 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16168 if (fp->afi == IP46_TYPE_IP4)
16170 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16171 vat_json_object_add_ip4 (node, "next_hop", ip4);
16173 else if (fp->afi == IP46_TYPE_IP6)
16175 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16176 vat_json_object_add_ip6 (node, "next_hop", ip6);
16182 api_ip_fib_dump (vat_main_t * vam)
16184 vl_api_ip_fib_dump_t *mp;
16185 vl_api_control_ping_t *mp_ping;
16188 M (IP_FIB_DUMP, mp);
16191 /* Use a control ping for synchronization */
16192 M (CONTROL_PING, mp_ping);
16200 api_ip_mfib_dump (vat_main_t * vam)
16202 vl_api_ip_mfib_dump_t *mp;
16203 vl_api_control_ping_t *mp_ping;
16206 M (IP_MFIB_DUMP, mp);
16209 /* Use a control ping for synchronization */
16210 M (CONTROL_PING, mp_ping);
16217 static void vl_api_ip_neighbor_details_t_handler
16218 (vl_api_ip_neighbor_details_t * mp)
16220 vat_main_t *vam = &vat_main;
16222 print (vam->ofp, "%c %U %U",
16223 (mp->is_static) ? 'S' : 'D',
16224 format_ethernet_address, &mp->mac_address,
16225 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
16229 static void vl_api_ip_neighbor_details_t_handler_json
16230 (vl_api_ip_neighbor_details_t * mp)
16233 vat_main_t *vam = &vat_main;
16234 vat_json_node_t *node;
16235 struct in_addr ip4;
16236 struct in6_addr ip6;
16238 if (VAT_JSON_ARRAY != vam->json_tree.type)
16240 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16241 vat_json_init_array (&vam->json_tree);
16243 node = vat_json_array_add (&vam->json_tree);
16245 vat_json_init_object (node);
16246 vat_json_object_add_string_copy (node, "flag",
16247 (mp->is_static) ? (u8 *) "static" : (u8 *)
16250 vat_json_object_add_string_copy (node, "link_layer",
16251 format (0, "%U", format_ethernet_address,
16252 &mp->mac_address));
16256 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
16257 vat_json_object_add_ip6 (node, "ip_address", ip6);
16261 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
16262 vat_json_object_add_ip4 (node, "ip_address", ip4);
16267 api_ip_neighbor_dump (vat_main_t * vam)
16269 unformat_input_t *i = vam->input;
16270 vl_api_ip_neighbor_dump_t *mp;
16271 vl_api_control_ping_t *mp_ping;
16273 u32 sw_if_index = ~0;
16276 /* Parse args required to build the message */
16277 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16279 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16281 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16283 else if (unformat (i, "ip6"))
16289 if (sw_if_index == ~0)
16291 errmsg ("missing interface name or sw_if_index");
16295 M (IP_NEIGHBOR_DUMP, mp);
16296 mp->is_ipv6 = (u8) is_ipv6;
16297 mp->sw_if_index = ntohl (sw_if_index);
16300 /* Use a control ping for synchronization */
16301 M (CONTROL_PING, mp_ping);
16308 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
16309 #define vl_api_ip6_fib_details_t_print vl_noop_handler
16312 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
16314 vat_main_t *vam = &vat_main;
16315 int count = ntohl (mp->count);
16316 vl_api_fib_path_t *fp;
16320 "table-id %d, prefix %U/%d",
16321 ntohl (mp->table_id), format_ip6_address, mp->address,
16322 mp->address_length);
16324 for (i = 0; i < count; i++)
16326 if (fp->afi == IP46_TYPE_IP6)
16328 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16329 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16330 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16331 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16332 format_ip6_address, fp->next_hop);
16333 else if (fp->afi == IP46_TYPE_IP4)
16335 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16336 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16337 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16338 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16339 format_ip4_address, fp->next_hop);
16344 static void vl_api_ip6_fib_details_t_handler_json
16345 (vl_api_ip6_fib_details_t * mp)
16347 vat_main_t *vam = &vat_main;
16348 int count = ntohl (mp->count);
16349 vat_json_node_t *node = NULL;
16350 struct in_addr ip4;
16351 struct in6_addr ip6;
16352 vl_api_fib_path_t *fp;
16355 if (VAT_JSON_ARRAY != vam->json_tree.type)
16357 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16358 vat_json_init_array (&vam->json_tree);
16360 node = vat_json_array_add (&vam->json_tree);
16362 vat_json_init_object (node);
16363 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16364 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
16365 vat_json_object_add_ip6 (node, "prefix", ip6);
16366 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16367 vat_json_object_add_uint (node, "path_count", count);
16369 for (i = 0; i < count; i++)
16371 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16372 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16373 vat_json_object_add_uint (node, "is_local", fp->is_local);
16374 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16375 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16376 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16377 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16378 if (fp->afi == IP46_TYPE_IP4)
16380 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16381 vat_json_object_add_ip4 (node, "next_hop", ip4);
16383 else if (fp->afi == IP46_TYPE_IP6)
16385 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16386 vat_json_object_add_ip6 (node, "next_hop", ip6);
16392 api_ip6_fib_dump (vat_main_t * vam)
16394 vl_api_ip6_fib_dump_t *mp;
16395 vl_api_control_ping_t *mp_ping;
16398 M (IP6_FIB_DUMP, mp);
16401 /* Use a control ping for synchronization */
16402 M (CONTROL_PING, mp_ping);
16410 api_ip6_mfib_dump (vat_main_t * vam)
16412 vl_api_ip6_mfib_dump_t *mp;
16413 vl_api_control_ping_t *mp_ping;
16416 M (IP6_MFIB_DUMP, mp);
16419 /* Use a control ping for synchronization */
16420 M (CONTROL_PING, mp_ping);
16428 api_classify_table_ids (vat_main_t * vam)
16430 vl_api_classify_table_ids_t *mp;
16433 /* Construct the API message */
16434 M (CLASSIFY_TABLE_IDS, mp);
16443 api_classify_table_by_interface (vat_main_t * vam)
16445 unformat_input_t *input = vam->input;
16446 vl_api_classify_table_by_interface_t *mp;
16448 u32 sw_if_index = ~0;
16450 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16452 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16454 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16459 if (sw_if_index == ~0)
16461 errmsg ("missing interface name or sw_if_index");
16465 /* Construct the API message */
16466 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
16468 mp->sw_if_index = ntohl (sw_if_index);
16476 api_classify_table_info (vat_main_t * vam)
16478 unformat_input_t *input = vam->input;
16479 vl_api_classify_table_info_t *mp;
16483 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16485 if (unformat (input, "table_id %d", &table_id))
16490 if (table_id == ~0)
16492 errmsg ("missing table id");
16496 /* Construct the API message */
16497 M (CLASSIFY_TABLE_INFO, mp);
16499 mp->table_id = ntohl (table_id);
16507 api_classify_session_dump (vat_main_t * vam)
16509 unformat_input_t *input = vam->input;
16510 vl_api_classify_session_dump_t *mp;
16511 vl_api_control_ping_t *mp_ping;
16515 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16517 if (unformat (input, "table_id %d", &table_id))
16522 if (table_id == ~0)
16524 errmsg ("missing table id");
16528 /* Construct the API message */
16529 M (CLASSIFY_SESSION_DUMP, mp);
16531 mp->table_id = ntohl (table_id);
16534 /* Use a control ping for synchronization */
16535 M (CONTROL_PING, mp_ping);
16543 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
16545 vat_main_t *vam = &vat_main;
16547 print (vam->ofp, "collector_address %U, collector_port %d, "
16548 "src_address %U, vrf_id %d, path_mtu %u, "
16549 "template_interval %u, udp_checksum %d",
16550 format_ip4_address, mp->collector_address,
16551 ntohs (mp->collector_port),
16552 format_ip4_address, mp->src_address,
16553 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
16554 ntohl (mp->template_interval), mp->udp_checksum);
16557 vam->result_ready = 1;
16561 vl_api_ipfix_exporter_details_t_handler_json
16562 (vl_api_ipfix_exporter_details_t * mp)
16564 vat_main_t *vam = &vat_main;
16565 vat_json_node_t node;
16566 struct in_addr collector_address;
16567 struct in_addr src_address;
16569 vat_json_init_object (&node);
16570 clib_memcpy (&collector_address, &mp->collector_address,
16571 sizeof (collector_address));
16572 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
16573 vat_json_object_add_uint (&node, "collector_port",
16574 ntohs (mp->collector_port));
16575 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
16576 vat_json_object_add_ip4 (&node, "src_address", src_address);
16577 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
16578 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
16579 vat_json_object_add_uint (&node, "template_interval",
16580 ntohl (mp->template_interval));
16581 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
16583 vat_json_print (vam->ofp, &node);
16584 vat_json_free (&node);
16586 vam->result_ready = 1;
16590 api_ipfix_exporter_dump (vat_main_t * vam)
16592 vl_api_ipfix_exporter_dump_t *mp;
16595 /* Construct the API message */
16596 M (IPFIX_EXPORTER_DUMP, mp);
16605 api_ipfix_classify_stream_dump (vat_main_t * vam)
16607 vl_api_ipfix_classify_stream_dump_t *mp;
16610 /* Construct the API message */
16611 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
16622 vl_api_ipfix_classify_stream_details_t_handler
16623 (vl_api_ipfix_classify_stream_details_t * mp)
16625 vat_main_t *vam = &vat_main;
16626 print (vam->ofp, "domain_id %d, src_port %d",
16627 ntohl (mp->domain_id), ntohs (mp->src_port));
16629 vam->result_ready = 1;
16633 vl_api_ipfix_classify_stream_details_t_handler_json
16634 (vl_api_ipfix_classify_stream_details_t * mp)
16636 vat_main_t *vam = &vat_main;
16637 vat_json_node_t node;
16639 vat_json_init_object (&node);
16640 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
16641 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
16643 vat_json_print (vam->ofp, &node);
16644 vat_json_free (&node);
16646 vam->result_ready = 1;
16650 api_ipfix_classify_table_dump (vat_main_t * vam)
16652 vl_api_ipfix_classify_table_dump_t *mp;
16653 vl_api_control_ping_t *mp_ping;
16656 if (!vam->json_output)
16658 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
16659 "transport_protocol");
16662 /* Construct the API message */
16663 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
16668 /* Use a control ping for synchronization */
16669 M (CONTROL_PING, mp_ping);
16677 vl_api_ipfix_classify_table_details_t_handler
16678 (vl_api_ipfix_classify_table_details_t * mp)
16680 vat_main_t *vam = &vat_main;
16681 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
16682 mp->transport_protocol);
16686 vl_api_ipfix_classify_table_details_t_handler_json
16687 (vl_api_ipfix_classify_table_details_t * mp)
16689 vat_json_node_t *node = NULL;
16690 vat_main_t *vam = &vat_main;
16692 if (VAT_JSON_ARRAY != vam->json_tree.type)
16694 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16695 vat_json_init_array (&vam->json_tree);
16698 node = vat_json_array_add (&vam->json_tree);
16699 vat_json_init_object (node);
16701 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
16702 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
16703 vat_json_object_add_uint (node, "transport_protocol",
16704 mp->transport_protocol);
16708 api_sw_interface_span_enable_disable (vat_main_t * vam)
16710 unformat_input_t *i = vam->input;
16711 vl_api_sw_interface_span_enable_disable_t *mp;
16712 u32 src_sw_if_index = ~0;
16713 u32 dst_sw_if_index = ~0;
16717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16720 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
16722 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
16726 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
16728 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16730 else if (unformat (i, "disable"))
16732 else if (unformat (i, "rx"))
16734 else if (unformat (i, "tx"))
16736 else if (unformat (i, "both"))
16742 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
16744 mp->sw_if_index_from = htonl (src_sw_if_index);
16745 mp->sw_if_index_to = htonl (dst_sw_if_index);
16754 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16757 vat_main_t *vam = &vat_main;
16758 u8 *sw_if_from_name = 0;
16759 u8 *sw_if_to_name = 0;
16760 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16761 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16762 char *states[] = { "none", "rx", "tx", "both" };
16766 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16768 if ((u32) p->value[0] == sw_if_index_from)
16770 sw_if_from_name = (u8 *)(p->key);
16774 if ((u32) p->value[0] == sw_if_index_to)
16776 sw_if_to_name = (u8 *)(p->key);
16777 if (sw_if_from_name)
16782 print (vam->ofp, "%20s => %20s (%s)",
16783 sw_if_from_name, sw_if_to_name, states[mp->state]);
16787 vl_api_sw_interface_span_details_t_handler_json
16788 (vl_api_sw_interface_span_details_t * mp)
16790 vat_main_t *vam = &vat_main;
16791 vat_json_node_t *node = NULL;
16792 u8 *sw_if_from_name = 0;
16793 u8 *sw_if_to_name = 0;
16794 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16795 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16799 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16801 if ((u32) p->value[0] == sw_if_index_from)
16803 sw_if_from_name = (u8 *)(p->key);
16807 if ((u32) p->value[0] == sw_if_index_to)
16809 sw_if_to_name = (u8 *)(p->key);
16810 if (sw_if_from_name)
16816 if (VAT_JSON_ARRAY != vam->json_tree.type)
16818 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16819 vat_json_init_array (&vam->json_tree);
16821 node = vat_json_array_add (&vam->json_tree);
16823 vat_json_init_object (node);
16824 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16825 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16826 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16827 if (0 != sw_if_to_name)
16829 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16831 vat_json_object_add_uint (node, "state", mp->state);
16835 api_sw_interface_span_dump (vat_main_t * vam)
16837 vl_api_sw_interface_span_dump_t *mp;
16838 vl_api_control_ping_t *mp_ping;
16841 M (SW_INTERFACE_SPAN_DUMP, mp);
16844 /* Use a control ping for synchronization */
16845 M (CONTROL_PING, mp_ping);
16853 api_pg_create_interface (vat_main_t * vam)
16855 unformat_input_t *input = vam->input;
16856 vl_api_pg_create_interface_t *mp;
16860 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16862 if (unformat (input, "if_id %d", &if_id))
16869 errmsg ("missing pg interface index");
16873 /* Construct the API message */
16874 M (PG_CREATE_INTERFACE, mp);
16876 mp->interface_id = ntohl (if_id);
16884 api_pg_capture (vat_main_t * vam)
16886 unformat_input_t *input = vam->input;
16887 vl_api_pg_capture_t *mp;
16892 u8 pcap_file_set = 0;
16895 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16897 if (unformat (input, "if_id %d", &if_id))
16899 else if (unformat (input, "pcap %s", &pcap_file))
16901 else if (unformat (input, "count %d", &count))
16903 else if (unformat (input, "disable"))
16910 errmsg ("missing pg interface index");
16913 if (pcap_file_set > 0)
16915 if (vec_len (pcap_file) > 255)
16917 errmsg ("pcap file name is too long");
16922 u32 name_len = vec_len (pcap_file);
16923 /* Construct the API message */
16924 M (PG_CAPTURE, mp);
16926 mp->interface_id = ntohl (if_id);
16927 mp->is_enabled = enable;
16928 mp->count = ntohl (count);
16929 mp->pcap_name_length = ntohl (name_len);
16930 if (pcap_file_set != 0)
16932 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16934 vec_free (pcap_file);
16942 api_pg_enable_disable (vat_main_t * vam)
16944 unformat_input_t *input = vam->input;
16945 vl_api_pg_enable_disable_t *mp;
16948 u8 stream_name_set = 0;
16949 u8 *stream_name = 0;
16951 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16953 if (unformat (input, "stream %s", &stream_name))
16954 stream_name_set = 1;
16955 else if (unformat (input, "disable"))
16961 if (stream_name_set > 0)
16963 if (vec_len (stream_name) > 255)
16965 errmsg ("stream name too long");
16970 u32 name_len = vec_len (stream_name);
16971 /* Construct the API message */
16972 M (PG_ENABLE_DISABLE, mp);
16974 mp->is_enabled = enable;
16975 if (stream_name_set != 0)
16977 mp->stream_name_length = ntohl (name_len);
16978 clib_memcpy (mp->stream_name, stream_name, name_len);
16980 vec_free (stream_name);
16988 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16990 unformat_input_t *input = vam->input;
16991 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16993 u16 *low_ports = 0;
16994 u16 *high_ports = 0;
16997 ip4_address_t ip4_addr;
16998 ip6_address_t ip6_addr;
17007 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17009 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
17015 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
17020 else if (unformat (input, "vrf %d", &vrf_id))
17022 else if (unformat (input, "del"))
17024 else if (unformat (input, "port %d", &tmp))
17026 if (tmp == 0 || tmp > 65535)
17028 errmsg ("port %d out of range", tmp);
17032 this_hi = this_low + 1;
17033 vec_add1 (low_ports, this_low);
17034 vec_add1 (high_ports, this_hi);
17036 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
17038 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
17040 errmsg ("incorrect range parameters");
17044 /* Note: in debug CLI +1 is added to high before
17045 passing to real fn that does "the work"
17046 (ip_source_and_port_range_check_add_del).
17047 This fn is a wrapper around the binary API fn a
17048 control plane will call, which expects this increment
17049 to have occurred. Hence letting the binary API control
17050 plane fn do the increment for consistency between VAT
17051 and other control planes.
17054 vec_add1 (low_ports, this_low);
17055 vec_add1 (high_ports, this_hi);
17061 if (prefix_set == 0)
17063 errmsg ("<address>/<mask> not specified");
17069 errmsg ("VRF ID required, not specified");
17076 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17080 if (vec_len (low_ports) == 0)
17082 errmsg ("At least one port or port range required");
17086 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
17088 mp->is_add = is_add;
17093 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
17098 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
17101 mp->mask_length = length;
17102 mp->number_of_ranges = vec_len (low_ports);
17104 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
17105 vec_free (low_ports);
17107 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
17108 vec_free (high_ports);
17110 mp->vrf_id = ntohl (vrf_id);
17118 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
17120 unformat_input_t *input = vam->input;
17121 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
17122 u32 sw_if_index = ~0;
17124 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
17125 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
17129 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17131 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17133 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17135 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
17137 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
17139 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
17141 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
17143 else if (unformat (input, "del"))
17149 if (sw_if_index == ~0)
17151 errmsg ("Interface required but not specified");
17157 errmsg ("VRF ID required but not specified");
17161 if (tcp_out_vrf_id == 0
17162 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
17165 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17169 /* Construct the API message */
17170 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
17172 mp->sw_if_index = ntohl (sw_if_index);
17173 mp->is_add = is_add;
17174 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
17175 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
17176 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
17177 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
17182 /* Wait for a reply... */
17188 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
17190 unformat_input_t *i = vam->input;
17191 vl_api_ipsec_gre_add_del_tunnel_t *mp;
17192 u32 local_sa_id = 0;
17193 u32 remote_sa_id = 0;
17194 ip4_address_t src_address;
17195 ip4_address_t dst_address;
17199 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17201 if (unformat (i, "local_sa %d", &local_sa_id))
17203 else if (unformat (i, "remote_sa %d", &remote_sa_id))
17205 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
17207 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
17209 else if (unformat (i, "del"))
17213 clib_warning ("parse error '%U'", format_unformat_error, i);
17218 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
17220 mp->local_sa_id = ntohl (local_sa_id);
17221 mp->remote_sa_id = ntohl (remote_sa_id);
17222 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
17223 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
17224 mp->is_add = is_add;
17232 api_punt (vat_main_t * vam)
17234 unformat_input_t *i = vam->input;
17242 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17244 if (unformat (i, "ip %d", &ipv))
17246 else if (unformat (i, "protocol %d", &protocol))
17248 else if (unformat (i, "port %d", &port))
17250 else if (unformat (i, "del"))
17254 clib_warning ("parse error '%U'", format_unformat_error, i);
17261 mp->is_add = (u8) is_add;
17262 mp->ipv = (u8) ipv;
17263 mp->l4_protocol = (u8) protocol;
17264 mp->l4_port = htons ((u16) port);
17271 static void vl_api_ipsec_gre_tunnel_details_t_handler
17272 (vl_api_ipsec_gre_tunnel_details_t * mp)
17274 vat_main_t *vam = &vat_main;
17276 print (vam->ofp, "%11d%15U%15U%14d%14d",
17277 ntohl (mp->sw_if_index),
17278 format_ip4_address, &mp->src_address,
17279 format_ip4_address, &mp->dst_address,
17280 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
17283 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
17284 (vl_api_ipsec_gre_tunnel_details_t * mp)
17286 vat_main_t *vam = &vat_main;
17287 vat_json_node_t *node = NULL;
17288 struct in_addr ip4;
17290 if (VAT_JSON_ARRAY != vam->json_tree.type)
17292 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17293 vat_json_init_array (&vam->json_tree);
17295 node = vat_json_array_add (&vam->json_tree);
17297 vat_json_init_object (node);
17298 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17299 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
17300 vat_json_object_add_ip4 (node, "src_address", ip4);
17301 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
17302 vat_json_object_add_ip4 (node, "dst_address", ip4);
17303 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
17304 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
17308 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
17310 unformat_input_t *i = vam->input;
17311 vl_api_ipsec_gre_tunnel_dump_t *mp;
17312 vl_api_control_ping_t *mp_ping;
17314 u8 sw_if_index_set = 0;
17317 /* Parse args required to build the message */
17318 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17320 if (unformat (i, "sw_if_index %d", &sw_if_index))
17321 sw_if_index_set = 1;
17326 if (sw_if_index_set == 0)
17331 if (!vam->json_output)
17333 print (vam->ofp, "%11s%15s%15s%14s%14s",
17334 "sw_if_index", "src_address", "dst_address",
17335 "local_sa_id", "remote_sa_id");
17338 /* Get list of gre-tunnel interfaces */
17339 M (IPSEC_GRE_TUNNEL_DUMP, mp);
17341 mp->sw_if_index = htonl (sw_if_index);
17345 /* Use a control ping for synchronization */
17346 M (CONTROL_PING, mp_ping);
17354 api_delete_subif (vat_main_t * vam)
17356 unformat_input_t *i = vam->input;
17357 vl_api_delete_subif_t *mp;
17358 u32 sw_if_index = ~0;
17361 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17363 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17365 if (unformat (i, "sw_if_index %d", &sw_if_index))
17371 if (sw_if_index == ~0)
17373 errmsg ("missing sw_if_index");
17377 /* Construct the API message */
17378 M (DELETE_SUBIF, mp);
17379 mp->sw_if_index = ntohl (sw_if_index);
17386 #define foreach_pbb_vtr_op \
17387 _("disable", L2_VTR_DISABLED) \
17388 _("pop", L2_VTR_POP_2) \
17389 _("push", L2_VTR_PUSH_2)
17392 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
17394 unformat_input_t *i = vam->input;
17395 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
17396 u32 sw_if_index = ~0, vtr_op = ~0;
17397 u16 outer_tag = ~0;
17398 u8 dmac[6], smac[6];
17399 u8 dmac_set = 0, smac_set = 0;
17405 /* Shut up coverity */
17406 memset (dmac, 0, sizeof (dmac));
17407 memset (smac, 0, sizeof (smac));
17409 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17411 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17413 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17415 else if (unformat (i, "vtr_op %d", &vtr_op))
17417 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
17420 else if (unformat (i, "translate_pbb_stag"))
17422 if (unformat (i, "%d", &tmp))
17424 vtr_op = L2_VTR_TRANSLATE_2_1;
17430 ("translate_pbb_stag operation requires outer tag definition");
17434 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
17436 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
17438 else if (unformat (i, "sid %d", &sid))
17440 else if (unformat (i, "vlanid %d", &tmp))
17444 clib_warning ("parse error '%U'", format_unformat_error, i);
17449 if ((sw_if_index == ~0) || (vtr_op == ~0))
17451 errmsg ("missing sw_if_index or vtr operation");
17454 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
17455 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
17458 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
17462 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
17463 mp->sw_if_index = ntohl (sw_if_index);
17464 mp->vtr_op = ntohl (vtr_op);
17465 mp->outer_tag = ntohs (outer_tag);
17466 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
17467 clib_memcpy (mp->b_smac, smac, sizeof (smac));
17468 mp->b_vlanid = ntohs (vlanid);
17469 mp->i_sid = ntohl (sid);
17477 api_flow_classify_set_interface (vat_main_t * vam)
17479 unformat_input_t *i = vam->input;
17480 vl_api_flow_classify_set_interface_t *mp;
17482 int sw_if_index_set;
17483 u32 ip4_table_index = ~0;
17484 u32 ip6_table_index = ~0;
17488 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17490 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17491 sw_if_index_set = 1;
17492 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17493 sw_if_index_set = 1;
17494 else if (unformat (i, "del"))
17496 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17498 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17502 clib_warning ("parse error '%U'", format_unformat_error, i);
17507 if (sw_if_index_set == 0)
17509 errmsg ("missing interface name or sw_if_index");
17513 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
17515 mp->sw_if_index = ntohl (sw_if_index);
17516 mp->ip4_table_index = ntohl (ip4_table_index);
17517 mp->ip6_table_index = ntohl (ip6_table_index);
17518 mp->is_add = is_add;
17526 api_flow_classify_dump (vat_main_t * vam)
17528 unformat_input_t *i = vam->input;
17529 vl_api_flow_classify_dump_t *mp;
17530 vl_api_control_ping_t *mp_ping;
17531 u8 type = FLOW_CLASSIFY_N_TABLES;
17534 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
17538 errmsg ("classify table type must be specified");
17542 if (!vam->json_output)
17544 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17547 M (FLOW_CLASSIFY_DUMP, mp);
17552 /* Use a control ping for synchronization */
17553 M (CONTROL_PING, mp_ping);
17556 /* Wait for a reply... */
17562 api_feature_enable_disable (vat_main_t * vam)
17564 unformat_input_t *i = vam->input;
17565 vl_api_feature_enable_disable_t *mp;
17567 u8 *feature_name = 0;
17568 u32 sw_if_index = ~0;
17572 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17574 if (unformat (i, "arc_name %s", &arc_name))
17576 else if (unformat (i, "feature_name %s", &feature_name))
17579 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17581 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17583 else if (unformat (i, "disable"))
17591 errmsg ("missing arc name");
17594 if (vec_len (arc_name) > 63)
17596 errmsg ("arc name too long");
17599 if (feature_name == 0)
17601 errmsg ("missing feature name");
17604 if (vec_len (feature_name) > 63)
17606 errmsg ("feature name too long");
17609 if (sw_if_index == ~0)
17611 errmsg ("missing interface name or sw_if_index");
17615 /* Construct the API message */
17616 M (FEATURE_ENABLE_DISABLE, mp);
17617 mp->sw_if_index = ntohl (sw_if_index);
17618 mp->enable = enable;
17619 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
17620 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
17621 vec_free (arc_name);
17622 vec_free (feature_name);
17630 api_sw_interface_tag_add_del (vat_main_t * vam)
17632 unformat_input_t *i = vam->input;
17633 vl_api_sw_interface_tag_add_del_t *mp;
17634 u32 sw_if_index = ~0;
17639 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17641 if (unformat (i, "tag %s", &tag))
17643 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17645 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17647 else if (unformat (i, "del"))
17653 if (sw_if_index == ~0)
17655 errmsg ("missing interface name or sw_if_index");
17659 if (enable && (tag == 0))
17661 errmsg ("no tag specified");
17665 /* Construct the API message */
17666 M (SW_INTERFACE_TAG_ADD_DEL, mp);
17667 mp->sw_if_index = ntohl (sw_if_index);
17668 mp->is_add = enable;
17670 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
17678 static void vl_api_l2_xconnect_details_t_handler
17679 (vl_api_l2_xconnect_details_t * mp)
17681 vat_main_t *vam = &vat_main;
17683 print (vam->ofp, "%15d%15d",
17684 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
17687 static void vl_api_l2_xconnect_details_t_handler_json
17688 (vl_api_l2_xconnect_details_t * mp)
17690 vat_main_t *vam = &vat_main;
17691 vat_json_node_t *node = NULL;
17693 if (VAT_JSON_ARRAY != vam->json_tree.type)
17695 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17696 vat_json_init_array (&vam->json_tree);
17698 node = vat_json_array_add (&vam->json_tree);
17700 vat_json_init_object (node);
17701 vat_json_object_add_uint (node, "rx_sw_if_index",
17702 ntohl (mp->rx_sw_if_index));
17703 vat_json_object_add_uint (node, "tx_sw_if_index",
17704 ntohl (mp->tx_sw_if_index));
17708 api_l2_xconnect_dump (vat_main_t * vam)
17710 vl_api_l2_xconnect_dump_t *mp;
17711 vl_api_control_ping_t *mp_ping;
17714 if (!vam->json_output)
17716 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
17719 M (L2_XCONNECT_DUMP, mp);
17723 /* Use a control ping for synchronization */
17724 M (CONTROL_PING, mp_ping);
17732 api_sw_interface_set_mtu (vat_main_t * vam)
17734 unformat_input_t *i = vam->input;
17735 vl_api_sw_interface_set_mtu_t *mp;
17736 u32 sw_if_index = ~0;
17740 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17742 if (unformat (i, "mtu %d", &mtu))
17744 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17746 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17752 if (sw_if_index == ~0)
17754 errmsg ("missing interface name or sw_if_index");
17760 errmsg ("no mtu specified");
17764 /* Construct the API message */
17765 M (SW_INTERFACE_SET_MTU, mp);
17766 mp->sw_if_index = ntohl (sw_if_index);
17767 mp->mtu = ntohs ((u16) mtu);
17776 q_or_quit (vat_main_t * vam)
17778 #if VPP_API_TEST_BUILTIN == 0
17779 longjmp (vam->jump_buf, 1);
17781 return 0; /* not so much */
17785 q (vat_main_t * vam)
17787 return q_or_quit (vam);
17791 quit (vat_main_t * vam)
17793 return q_or_quit (vam);
17797 comment (vat_main_t * vam)
17803 cmd_cmp (void *a1, void *a2)
17808 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17812 help (vat_main_t * vam)
17817 unformat_input_t *i = vam->input;
17820 if (unformat (i, "%s", &name))
17824 vec_add1 (name, 0);
17826 hs = hash_get_mem (vam->help_by_name, name);
17828 print (vam->ofp, "usage: %s %s", name, hs[0]);
17830 print (vam->ofp, "No such msg / command '%s'", name);
17835 print (vam->ofp, "Help is available for the following:");
17838 hash_foreach_pair (p, vam->function_by_name,
17840 vec_add1 (cmds, (u8 *)(p->key));
17844 vec_sort_with_function (cmds, cmd_cmp);
17846 for (j = 0; j < vec_len (cmds); j++)
17847 print (vam->ofp, "%s", cmds[j]);
17854 set (vat_main_t * vam)
17856 u8 *name = 0, *value = 0;
17857 unformat_input_t *i = vam->input;
17859 if (unformat (i, "%s", &name))
17861 /* The input buffer is a vector, not a string. */
17862 value = vec_dup (i->buffer);
17863 vec_delete (value, i->index, 0);
17864 /* Almost certainly has a trailing newline */
17865 if (value[vec_len (value) - 1] == '\n')
17866 value[vec_len (value) - 1] = 0;
17867 /* Make sure it's a proper string, one way or the other */
17868 vec_add1 (value, 0);
17869 (void) clib_macro_set_value (&vam->macro_main,
17870 (char *) name, (char *) value);
17873 errmsg ("usage: set <name> <value>");
17881 unset (vat_main_t * vam)
17885 if (unformat (vam->input, "%s", &name))
17886 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17887 errmsg ("unset: %s wasn't set", name);
17900 macro_sort_cmp (void *a1, void *a2)
17902 macro_sort_t *s1 = a1;
17903 macro_sort_t *s2 = a2;
17905 return strcmp ((char *) (s1->name), (char *) (s2->name));
17909 dump_macro_table (vat_main_t * vam)
17911 macro_sort_t *sort_me = 0, *sm;
17916 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17918 vec_add2 (sort_me, sm, 1);
17919 sm->name = (u8 *)(p->key);
17920 sm->value = (u8 *) (p->value[0]);
17924 vec_sort_with_function (sort_me, macro_sort_cmp);
17926 if (vec_len (sort_me))
17927 print (vam->ofp, "%-15s%s", "Name", "Value");
17929 print (vam->ofp, "The macro table is empty...");
17931 for (i = 0; i < vec_len (sort_me); i++)
17932 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17937 dump_node_table (vat_main_t * vam)
17940 vlib_node_t *node, *next_node;
17942 if (vec_len (vam->graph_nodes) == 0)
17944 print (vam->ofp, "Node table empty, issue get_node_graph...");
17948 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17950 node = vam->graph_nodes[i];
17951 print (vam->ofp, "[%d] %s", i, node->name);
17952 for (j = 0; j < vec_len (node->next_nodes); j++)
17954 if (node->next_nodes[j] != ~0)
17956 next_node = vam->graph_nodes[node->next_nodes[j]];
17957 print (vam->ofp, " [%d] %s", j, next_node->name);
17965 value_sort_cmp (void *a1, void *a2)
17967 name_sort_t *n1 = a1;
17968 name_sort_t *n2 = a2;
17970 if (n1->value < n2->value)
17972 if (n1->value > n2->value)
17979 dump_msg_api_table (vat_main_t * vam)
17981 api_main_t *am = &api_main;
17982 name_sort_t *nses = 0, *ns;
17987 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17989 vec_add2 (nses, ns, 1);
17990 ns->name = (u8 *)(hp->key);
17991 ns->value = (u32) hp->value[0];
17995 vec_sort_with_function (nses, value_sort_cmp);
17997 for (i = 0; i < vec_len (nses); i++)
17998 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
18004 get_msg_id (vat_main_t * vam)
18009 if (unformat (vam->input, "%s", &name_and_crc))
18011 message_index = vl_api_get_msg_index (name_and_crc);
18012 if (message_index == ~0)
18014 print (vam->ofp, " '%s' not found", name_and_crc);
18017 print (vam->ofp, " '%s' has message index %d",
18018 name_and_crc, message_index);
18021 errmsg ("name_and_crc required...");
18026 search_node_table (vat_main_t * vam)
18028 unformat_input_t *line_input = vam->input;
18031 vlib_node_t *node, *next_node;
18034 if (vam->graph_node_index_by_name == 0)
18036 print (vam->ofp, "Node table empty, issue get_node_graph...");
18040 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
18042 if (unformat (line_input, "%s", &node_to_find))
18044 vec_add1 (node_to_find, 0);
18045 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
18048 print (vam->ofp, "%s not found...", node_to_find);
18051 node = vam->graph_nodes[p[0]];
18052 print (vam->ofp, "[%d] %s", p[0], node->name);
18053 for (j = 0; j < vec_len (node->next_nodes); j++)
18055 if (node->next_nodes[j] != ~0)
18057 next_node = vam->graph_nodes[node->next_nodes[j]];
18058 print (vam->ofp, " [%d] %s", j, next_node->name);
18065 clib_warning ("parse error '%U'", format_unformat_error,
18071 vec_free (node_to_find);
18080 script (vat_main_t * vam)
18082 #if (VPP_API_TEST_BUILTIN==0)
18084 char *save_current_file;
18085 unformat_input_t save_input;
18086 jmp_buf save_jump_buf;
18087 u32 save_line_number;
18089 FILE *new_fp, *save_ifp;
18091 if (unformat (vam->input, "%s", &s))
18093 new_fp = fopen ((char *) s, "r");
18096 errmsg ("Couldn't open script file %s", s);
18103 errmsg ("Missing script name");
18107 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
18108 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
18109 save_ifp = vam->ifp;
18110 save_line_number = vam->input_line_number;
18111 save_current_file = (char *) vam->current_file;
18113 vam->input_line_number = 0;
18115 vam->current_file = s;
18118 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
18119 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
18120 vam->ifp = save_ifp;
18121 vam->input_line_number = save_line_number;
18122 vam->current_file = (u8 *) save_current_file;
18127 clib_warning ("use the exec command...");
18133 echo (vat_main_t * vam)
18135 print (vam->ofp, "%v", vam->input->buffer);
18139 /* List of API message constructors, CLI names map to api_xxx */
18140 #define foreach_vpe_api_msg \
18141 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
18142 _(sw_interface_dump,"") \
18143 _(sw_interface_set_flags, \
18144 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
18145 _(sw_interface_add_del_address, \
18146 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
18147 _(sw_interface_set_table, \
18148 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
18149 _(sw_interface_set_mpls_enable, \
18150 "<intfc> | sw_if_index [disable | dis]") \
18151 _(sw_interface_set_vpath, \
18152 "<intfc> | sw_if_index <id> enable | disable") \
18153 _(sw_interface_set_vxlan_bypass, \
18154 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
18155 _(sw_interface_set_l2_xconnect, \
18156 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18157 "enable | disable") \
18158 _(sw_interface_set_l2_bridge, \
18159 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
18160 "[shg <split-horizon-group>] [bvi]\n" \
18161 "enable | disable") \
18162 _(bridge_domain_add_del, \
18163 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
18164 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
18166 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
18168 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
18170 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
18172 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
18174 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
18176 "<vpp-if-name> | sw_if_index <id>") \
18177 _(sw_interface_tap_dump, "") \
18178 _(ip_add_del_route, \
18179 "<addr>/<mask> via <addr> [table-id <n>]\n" \
18180 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18181 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18182 "[multipath] [count <n>]") \
18183 _(ip_mroute_add_del, \
18184 "<src> <grp>/<mask> [table-id <n>]\n" \
18185 "[<intfc> | sw_if_index <id>] [local] [del]") \
18186 _(mpls_route_add_del, \
18187 "<label> <eos> via <addr> [table-id <n>]\n" \
18188 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18189 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18190 "[multipath] [count <n>]") \
18191 _(mpls_ip_bind_unbind, \
18192 "<label> <addr/len>") \
18193 _(mpls_tunnel_add_del, \
18194 " via <addr> [table-id <n>]\n" \
18195 "sw_if_index <id>] [l2] [del]") \
18196 _(proxy_arp_add_del, \
18197 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
18198 _(proxy_arp_intfc_enable_disable, \
18199 "<intfc> | sw_if_index <id> enable | disable") \
18200 _(sw_interface_set_unnumbered, \
18201 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
18202 _(ip_neighbor_add_del, \
18203 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
18204 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
18205 _(reset_vrf, "vrf <id> [ipv6]") \
18206 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
18207 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
18208 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
18209 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
18210 "[outer_vlan_id_any][inner_vlan_id_any]") \
18211 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
18212 _(reset_fib, "vrf <n> [ipv6]") \
18213 _(dhcp_proxy_config, \
18214 "svr <v46-address> src <v46-address>\n" \
18215 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
18216 _(dhcp_proxy_set_vss, \
18217 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
18218 _(dhcp_proxy_dump, "ip6") \
18219 _(dhcp_client_config, \
18220 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
18221 _(set_ip_flow_hash, \
18222 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
18223 _(sw_interface_ip6_enable_disable, \
18224 "<intfc> | sw_if_index <id> enable | disable") \
18225 _(sw_interface_ip6_set_link_local_address, \
18226 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
18227 _(ip6nd_proxy_add_del, \
18228 "<intfc> | sw_if_index <id> <ip6-address>") \
18229 _(ip6nd_proxy_dump, "") \
18230 _(sw_interface_ip6nd_ra_prefix, \
18231 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
18232 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
18233 "[nolink] [isno]") \
18234 _(sw_interface_ip6nd_ra_config, \
18235 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
18236 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
18237 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
18238 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
18239 _(l2_patch_add_del, \
18240 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18241 "enable | disable") \
18242 _(sr_localsid_add_del, \
18243 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
18244 "fib-table <num> (end.psp) sw_if_index <num>") \
18245 _(classify_add_del_table, \
18246 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
18247 " [del] [del-chain] mask <mask-value>\n" \
18248 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
18249 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
18250 _(classify_add_del_session, \
18251 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
18252 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
18253 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
18254 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
18255 _(classify_set_interface_ip_table, \
18256 "<intfc> | sw_if_index <nn> table <nn>") \
18257 _(classify_set_interface_l2_tables, \
18258 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18259 " [other-table <nn>]") \
18260 _(get_node_index, "node <node-name") \
18261 _(add_node_next, "node <node-name> next <next-node-name>") \
18262 _(l2tpv3_create_tunnel, \
18263 "client_address <ip6-addr> our_address <ip6-addr>\n" \
18264 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
18265 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
18266 _(l2tpv3_set_tunnel_cookies, \
18267 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
18268 "[new_remote_cookie <nn>]\n") \
18269 _(l2tpv3_interface_enable_disable, \
18270 "<intfc> | sw_if_index <nn> enable | disable") \
18271 _(l2tpv3_set_lookup_key, \
18272 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
18273 _(sw_if_l2tpv3_tunnel_dump, "") \
18274 _(vxlan_add_del_tunnel, \
18275 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
18276 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
18277 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
18278 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18279 _(gre_add_del_tunnel, \
18280 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
18281 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18282 _(l2_fib_clear_table, "") \
18283 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
18284 _(l2_interface_vlan_tag_rewrite, \
18285 "<intfc> | sw_if_index <nn> \n" \
18286 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
18287 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
18288 _(create_vhost_user_if, \
18289 "socket <filename> [server] [renumber <dev_instance>] " \
18290 "[mac <mac_address>]") \
18291 _(modify_vhost_user_if, \
18292 "<intfc> | sw_if_index <nn> socket <filename>\n" \
18293 "[server] [renumber <dev_instance>]") \
18294 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
18295 _(sw_interface_vhost_user_dump, "") \
18296 _(show_version, "") \
18297 _(vxlan_gpe_add_del_tunnel, \
18298 "local <addr> remote <addr> vni <nn>\n" \
18299 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
18300 "[next-ethernet] [next-nsh]\n") \
18301 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18302 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
18303 _(interface_name_renumber, \
18304 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
18305 _(input_acl_set_interface, \
18306 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18307 " [l2-table <nn>] [del]") \
18308 _(want_ip4_arp_events, "address <ip4-address> [del]") \
18309 _(want_ip6_nd_events, "address <ip6-address> [del]") \
18310 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
18311 _(ip_dump, "ipv4 | ipv6") \
18312 _(ipsec_spd_add_del, "spd_id <n> [del]") \
18313 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
18315 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
18316 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
18317 " integ_alg <alg> integ_key <hex>") \
18318 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
18319 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
18320 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
18321 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
18322 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
18323 _(ikev2_profile_add_del, "name <profile_name> [del]") \
18324 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
18325 "(auth_data 0x<data> | auth_data <data>)") \
18326 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
18327 "(id_data 0x<data> | id_data <data>) (local|remote)") \
18328 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
18329 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
18330 "(local|remote)") \
18331 _(ikev2_set_local_key, "file <absolute_file_path>") \
18332 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
18333 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18334 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18335 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
18336 _(ikev2_initiate_sa_init, "<profile_name>") \
18337 _(ikev2_initiate_del_ike_sa, "<ispi>") \
18338 _(ikev2_initiate_del_child_sa, "<ispi>") \
18339 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
18340 _(delete_loopback,"sw_if_index <nn>") \
18341 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
18342 _(map_add_domain, \
18343 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
18344 "ip6-src <ip6addr> " \
18345 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
18346 _(map_del_domain, "index <n>") \
18347 _(map_add_del_rule, \
18348 "index <n> psid <n> dst <ip6addr> [del]") \
18349 _(map_domain_dump, "") \
18350 _(map_rule_dump, "index <map-domain>") \
18351 _(want_interface_events, "enable|disable") \
18352 _(want_stats,"enable|disable") \
18353 _(get_first_msg_id, "client <name>") \
18354 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
18355 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
18356 "fib-id <nn> [ip4][ip6][default]") \
18357 _(get_node_graph, " ") \
18358 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
18359 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
18360 _(ioam_disable, "") \
18361 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
18362 " sw_if_index <sw_if_index> p <priority> " \
18363 "w <weight>] [del]") \
18364 _(one_add_del_locator, "locator-set <locator_name> " \
18365 "iface <intf> | sw_if_index <sw_if_index> " \
18366 "p <priority> w <weight> [del]") \
18367 _(one_add_del_local_eid,"vni <vni> eid " \
18368 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18369 "locator-set <locator_name> [del]" \
18370 "[key-id sha1|sha256 secret-key <secret-key>]")\
18371 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
18372 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
18373 _(one_enable_disable, "enable|disable") \
18374 _(one_map_register_enable_disable, "enable|disable") \
18375 _(one_rloc_probe_enable_disable, "enable|disable") \
18376 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18378 "rloc <locator> p <prio> " \
18379 "w <weight> [rloc <loc> ... ] " \
18380 "action <action> [del-all]") \
18381 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18383 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18384 _(one_use_petr, "ip-address> | disable") \
18385 _(one_map_request_mode, "src-dst|dst-only") \
18386 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18387 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18388 _(one_locator_set_dump, "[local | remote]") \
18389 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
18390 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18391 "[local] | [remote]") \
18392 _(one_eid_table_vni_dump, "") \
18393 _(one_eid_table_map_dump, "l2|l3") \
18394 _(one_map_resolver_dump, "") \
18395 _(one_map_server_dump, "") \
18396 _(one_adjacencies_get, "vni <vni>") \
18397 _(show_one_rloc_probe_state, "") \
18398 _(show_one_map_register_state, "") \
18399 _(show_one_status, "") \
18400 _(one_get_map_request_itr_rlocs, "") \
18401 _(show_one_pitr, "") \
18402 _(show_one_use_petr, "") \
18403 _(show_one_map_request_mode, "") \
18404 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
18405 " sw_if_index <sw_if_index> p <priority> " \
18406 "w <weight>] [del]") \
18407 _(lisp_add_del_locator, "locator-set <locator_name> " \
18408 "iface <intf> | sw_if_index <sw_if_index> " \
18409 "p <priority> w <weight> [del]") \
18410 _(lisp_add_del_local_eid,"vni <vni> eid " \
18411 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18412 "locator-set <locator_name> [del]" \
18413 "[key-id sha1|sha256 secret-key <secret-key>]") \
18414 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
18415 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
18416 _(lisp_enable_disable, "enable|disable") \
18417 _(lisp_map_register_enable_disable, "enable|disable") \
18418 _(lisp_rloc_probe_enable_disable, "enable|disable") \
18419 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18421 "rloc <locator> p <prio> " \
18422 "w <weight> [rloc <loc> ... ] " \
18423 "action <action> [del-all]") \
18424 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18426 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18427 _(lisp_use_petr, "<ip-address> | disable") \
18428 _(lisp_map_request_mode, "src-dst|dst-only") \
18429 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18430 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18431 _(lisp_locator_set_dump, "[local | remote]") \
18432 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
18433 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18434 "[local] | [remote]") \
18435 _(lisp_eid_table_vni_dump, "") \
18436 _(lisp_eid_table_map_dump, "l2|l3") \
18437 _(lisp_map_resolver_dump, "") \
18438 _(lisp_map_server_dump, "") \
18439 _(lisp_adjacencies_get, "vni <vni>") \
18440 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
18441 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
18442 _(gpe_set_encap_mode, "lisp|vxlan") \
18443 _(gpe_get_encap_mode, "") \
18444 _(lisp_gpe_add_del_iface, "up|down") \
18445 _(lisp_gpe_enable_disable, "enable|disable") \
18446 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
18447 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
18448 _(show_lisp_rloc_probe_state, "") \
18449 _(show_lisp_map_register_state, "") \
18450 _(show_lisp_status, "") \
18451 _(lisp_get_map_request_itr_rlocs, "") \
18452 _(show_lisp_pitr, "") \
18453 _(show_lisp_use_petr, "") \
18454 _(show_lisp_map_request_mode, "") \
18455 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
18456 _(af_packet_delete, "name <host interface name>") \
18457 _(policer_add_del, "name <policer name> <params> [del]") \
18458 _(policer_dump, "[name <policer name>]") \
18459 _(policer_classify_set_interface, \
18460 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18461 " [l2-table <nn>] [del]") \
18462 _(policer_classify_dump, "type [ip4|ip6|l2]") \
18463 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
18464 "[master|slave]") \
18465 _(netmap_delete, "name <interface name>") \
18466 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
18467 _(mpls_fib_dump, "") \
18468 _(classify_table_ids, "") \
18469 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
18470 _(classify_table_info, "table_id <nn>") \
18471 _(classify_session_dump, "table_id <nn>") \
18472 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
18473 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
18474 "[template_interval <nn>] [udp_checksum]") \
18475 _(ipfix_exporter_dump, "") \
18476 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
18477 _(ipfix_classify_stream_dump, "") \
18478 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
18479 _(ipfix_classify_table_dump, "") \
18480 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
18481 _(sw_interface_span_dump, "") \
18482 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
18483 _(pg_create_interface, "if_id <nn>") \
18484 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
18485 _(pg_enable_disable, "[stream <id>] disable") \
18486 _(ip_source_and_port_range_check_add_del, \
18487 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
18488 _(ip_source_and_port_range_check_interface_add_del, \
18489 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
18490 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
18491 _(ipsec_gre_add_del_tunnel, \
18492 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
18493 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
18494 _(delete_subif,"<intfc> | sw_if_index <nn>") \
18495 _(l2_interface_pbb_tag_rewrite, \
18496 "<intfc> | sw_if_index <nn> \n" \
18497 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
18498 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
18499 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
18500 _(flow_classify_set_interface, \
18501 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
18502 _(flow_classify_dump, "type [ip4|ip6]") \
18503 _(ip_fib_dump, "") \
18504 _(ip_mfib_dump, "") \
18505 _(ip6_fib_dump, "") \
18506 _(ip6_mfib_dump, "") \
18507 _(feature_enable_disable, "arc_name <arc_name> " \
18508 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
18509 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
18511 _(l2_xconnect_dump, "") \
18512 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
18513 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
18514 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
18516 /* List of command functions, CLI names map directly to functions */
18517 #define foreach_cli_function \
18518 _(comment, "usage: comment <ignore-rest-of-line>") \
18519 _(dump_interface_table, "usage: dump_interface_table") \
18520 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
18521 _(dump_ipv4_table, "usage: dump_ipv4_table") \
18522 _(dump_ipv6_table, "usage: dump_ipv6_table") \
18523 _(dump_stats_table, "usage: dump_stats_table") \
18524 _(dump_macro_table, "usage: dump_macro_table ") \
18525 _(dump_node_table, "usage: dump_node_table") \
18526 _(dump_msg_api_table, "usage: dump_msg_api_table") \
18527 _(get_msg_id, "usage: get_msg_id name_and_crc") \
18528 _(echo, "usage: echo <message>") \
18529 _(exec, "usage: exec <vpe-debug-CLI-command>") \
18530 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
18531 _(help, "usage: help") \
18532 _(q, "usage: quit") \
18533 _(quit, "usage: quit") \
18534 _(search_node_table, "usage: search_node_table <name>...") \
18535 _(set, "usage: set <variable-name> <value>") \
18536 _(script, "usage: script <file-name>") \
18537 _(unset, "usage: unset <variable-name>")
18540 static void vl_api_##n##_t_handler_uni \
18541 (vl_api_##n##_t * mp) \
18543 vat_main_t * vam = &vat_main; \
18544 if (vam->json_output) { \
18545 vl_api_##n##_t_handler_json(mp); \
18547 vl_api_##n##_t_handler(mp); \
18550 foreach_vpe_api_reply_msg;
18551 #if VPP_API_TEST_BUILTIN == 0
18552 foreach_standalone_reply_msg;
18557 vat_api_hookup (vat_main_t * vam)
18560 vl_msg_api_set_handlers(VL_API_##N, #n, \
18561 vl_api_##n##_t_handler_uni, \
18563 vl_api_##n##_t_endian, \
18564 vl_api_##n##_t_print, \
18565 sizeof(vl_api_##n##_t), 1);
18566 foreach_vpe_api_reply_msg;
18567 #if VPP_API_TEST_BUILTIN == 0
18568 foreach_standalone_reply_msg;
18572 #if (VPP_API_TEST_BUILTIN==0)
18573 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
18575 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
18577 vam->function_by_name = hash_create_string (0, sizeof (uword));
18579 vam->help_by_name = hash_create_string (0, sizeof (uword));
18582 /* API messages we can send */
18583 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18584 foreach_vpe_api_msg;
18588 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18589 foreach_vpe_api_msg;
18592 /* CLI functions */
18593 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
18594 foreach_cli_function;
18598 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18599 foreach_cli_function;
18603 #if VPP_API_TEST_BUILTIN
18604 static clib_error_t *
18605 vat_api_hookup_shim (vlib_main_t * vm)
18607 vat_api_hookup (&vat_main);
18611 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
18615 * fd.io coding-style-patch-verification: ON
18618 * eval: (c-set-style "gnu")