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, dst;
10676 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10677 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10679 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10680 ntohl (mp->sw_if_index),
10681 format_ip46_address, &src, IP46_TYPE_ANY,
10682 format_ip46_address, &dst, IP46_TYPE_ANY,
10683 ntohl (mp->encap_vrf_id),
10684 ntohl (mp->decap_next_index), ntohl (mp->vni),
10685 ntohl (mp->mcast_sw_if_index));
10688 static void vl_api_vxlan_tunnel_details_t_handler_json
10689 (vl_api_vxlan_tunnel_details_t * mp)
10691 vat_main_t *vam = &vat_main;
10692 vat_json_node_t *node = NULL;
10694 if (VAT_JSON_ARRAY != vam->json_tree.type)
10696 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10697 vat_json_init_array (&vam->json_tree);
10699 node = vat_json_array_add (&vam->json_tree);
10701 vat_json_init_object (node);
10702 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10705 struct in6_addr ip6;
10707 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10708 vat_json_object_add_ip6 (node, "src_address", ip6);
10709 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10710 vat_json_object_add_ip6 (node, "dst_address", ip6);
10714 struct in_addr ip4;
10716 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10717 vat_json_object_add_ip4 (node, "src_address", ip4);
10718 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10719 vat_json_object_add_ip4 (node, "dst_address", ip4);
10721 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10722 vat_json_object_add_uint (node, "decap_next_index",
10723 ntohl (mp->decap_next_index));
10724 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10725 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10726 vat_json_object_add_uint (node, "mcast_sw_if_index",
10727 ntohl (mp->mcast_sw_if_index));
10731 api_vxlan_tunnel_dump (vat_main_t * vam)
10733 unformat_input_t *i = vam->input;
10734 vl_api_vxlan_tunnel_dump_t *mp;
10735 vl_api_control_ping_t *mp_ping;
10737 u8 sw_if_index_set = 0;
10740 /* Parse args required to build the message */
10741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10743 if (unformat (i, "sw_if_index %d", &sw_if_index))
10744 sw_if_index_set = 1;
10749 if (sw_if_index_set == 0)
10754 if (!vam->json_output)
10756 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10757 "sw_if_index", "src_address", "dst_address",
10758 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10761 /* Get list of vxlan-tunnel interfaces */
10762 M (VXLAN_TUNNEL_DUMP, mp);
10764 mp->sw_if_index = htonl (sw_if_index);
10768 /* Use a control ping for synchronization */
10769 M (CONTROL_PING, mp_ping);
10777 api_gre_add_del_tunnel (vat_main_t * vam)
10779 unformat_input_t *line_input = vam->input;
10780 vl_api_gre_add_del_tunnel_t *mp;
10781 ip4_address_t src4, dst4;
10786 u32 outer_fib_id = 0;
10789 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10791 if (unformat (line_input, "del"))
10793 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10795 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10797 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10799 else if (unformat (line_input, "teb"))
10803 errmsg ("parse error '%U'", format_unformat_error, line_input);
10810 errmsg ("tunnel src address not specified");
10815 errmsg ("tunnel dst address not specified");
10820 M (GRE_ADD_DEL_TUNNEL, mp);
10822 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10823 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10824 mp->outer_fib_id = ntohl (outer_fib_id);
10825 mp->is_add = is_add;
10833 static void vl_api_gre_tunnel_details_t_handler
10834 (vl_api_gre_tunnel_details_t * mp)
10836 vat_main_t *vam = &vat_main;
10838 print (vam->ofp, "%11d%15U%15U%6d%14d",
10839 ntohl (mp->sw_if_index),
10840 format_ip4_address, &mp->src_address,
10841 format_ip4_address, &mp->dst_address,
10842 mp->teb, ntohl (mp->outer_fib_id));
10845 static void vl_api_gre_tunnel_details_t_handler_json
10846 (vl_api_gre_tunnel_details_t * mp)
10848 vat_main_t *vam = &vat_main;
10849 vat_json_node_t *node = NULL;
10850 struct in_addr ip4;
10852 if (VAT_JSON_ARRAY != vam->json_tree.type)
10854 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10855 vat_json_init_array (&vam->json_tree);
10857 node = vat_json_array_add (&vam->json_tree);
10859 vat_json_init_object (node);
10860 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10861 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10862 vat_json_object_add_ip4 (node, "src_address", ip4);
10863 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10864 vat_json_object_add_ip4 (node, "dst_address", ip4);
10865 vat_json_object_add_uint (node, "teb", mp->teb);
10866 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10870 api_gre_tunnel_dump (vat_main_t * vam)
10872 unformat_input_t *i = vam->input;
10873 vl_api_gre_tunnel_dump_t *mp;
10874 vl_api_control_ping_t *mp_ping;
10876 u8 sw_if_index_set = 0;
10879 /* Parse args required to build the message */
10880 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10882 if (unformat (i, "sw_if_index %d", &sw_if_index))
10883 sw_if_index_set = 1;
10888 if (sw_if_index_set == 0)
10893 if (!vam->json_output)
10895 print (vam->ofp, "%11s%15s%15s%6s%14s",
10896 "sw_if_index", "src_address", "dst_address", "teb",
10900 /* Get list of gre-tunnel interfaces */
10901 M (GRE_TUNNEL_DUMP, mp);
10903 mp->sw_if_index = htonl (sw_if_index);
10907 /* Use a control ping for synchronization */
10908 M (CONTROL_PING, mp_ping);
10916 api_l2_fib_clear_table (vat_main_t * vam)
10918 // unformat_input_t * i = vam->input;
10919 vl_api_l2_fib_clear_table_t *mp;
10922 M (L2_FIB_CLEAR_TABLE, mp);
10930 api_l2_interface_efp_filter (vat_main_t * vam)
10932 unformat_input_t *i = vam->input;
10933 vl_api_l2_interface_efp_filter_t *mp;
10936 u8 sw_if_index_set = 0;
10939 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10941 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10942 sw_if_index_set = 1;
10943 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10944 sw_if_index_set = 1;
10945 else if (unformat (i, "enable"))
10947 else if (unformat (i, "disable"))
10951 clib_warning ("parse error '%U'", format_unformat_error, i);
10956 if (sw_if_index_set == 0)
10958 errmsg ("missing sw_if_index");
10962 M (L2_INTERFACE_EFP_FILTER, mp);
10964 mp->sw_if_index = ntohl (sw_if_index);
10965 mp->enable_disable = enable;
10972 #define foreach_vtr_op \
10973 _("disable", L2_VTR_DISABLED) \
10974 _("push-1", L2_VTR_PUSH_1) \
10975 _("push-2", L2_VTR_PUSH_2) \
10976 _("pop-1", L2_VTR_POP_1) \
10977 _("pop-2", L2_VTR_POP_2) \
10978 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10979 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10980 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10981 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10984 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10986 unformat_input_t *i = vam->input;
10987 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10989 u8 sw_if_index_set = 0;
10992 u32 push_dot1q = 1;
10997 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10999 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11000 sw_if_index_set = 1;
11001 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11002 sw_if_index_set = 1;
11003 else if (unformat (i, "vtr_op %d", &vtr_op))
11005 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11008 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11010 else if (unformat (i, "tag1 %d", &tag1))
11012 else if (unformat (i, "tag2 %d", &tag2))
11016 clib_warning ("parse error '%U'", format_unformat_error, i);
11021 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11023 errmsg ("missing vtr operation or sw_if_index");
11027 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11028 mp->sw_if_index = ntohl (sw_if_index);
11029 mp->vtr_op = ntohl (vtr_op);
11030 mp->push_dot1q = ntohl (push_dot1q);
11031 mp->tag1 = ntohl (tag1);
11032 mp->tag2 = ntohl (tag2);
11040 api_create_vhost_user_if (vat_main_t * vam)
11042 unformat_input_t *i = vam->input;
11043 vl_api_create_vhost_user_if_t *mp;
11046 u8 file_name_set = 0;
11047 u32 custom_dev_instance = ~0;
11049 u8 use_custom_mac = 0;
11053 /* Shut up coverity */
11054 memset (hwaddr, 0, sizeof (hwaddr));
11056 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11058 if (unformat (i, "socket %s", &file_name))
11062 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11064 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11065 use_custom_mac = 1;
11066 else if (unformat (i, "server"))
11068 else if (unformat (i, "tag %s", &tag))
11074 if (file_name_set == 0)
11076 errmsg ("missing socket file name");
11080 if (vec_len (file_name) > 255)
11082 errmsg ("socket file name too long");
11085 vec_add1 (file_name, 0);
11087 M (CREATE_VHOST_USER_IF, mp);
11089 mp->is_server = is_server;
11090 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11091 vec_free (file_name);
11092 if (custom_dev_instance != ~0)
11095 mp->custom_dev_instance = ntohl (custom_dev_instance);
11097 mp->use_custom_mac = use_custom_mac;
11098 clib_memcpy (mp->mac_address, hwaddr, 6);
11100 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11109 api_modify_vhost_user_if (vat_main_t * vam)
11111 unformat_input_t *i = vam->input;
11112 vl_api_modify_vhost_user_if_t *mp;
11115 u8 file_name_set = 0;
11116 u32 custom_dev_instance = ~0;
11117 u8 sw_if_index_set = 0;
11118 u32 sw_if_index = (u32) ~ 0;
11121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11123 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11124 sw_if_index_set = 1;
11125 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11126 sw_if_index_set = 1;
11127 else if (unformat (i, "socket %s", &file_name))
11131 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11133 else if (unformat (i, "server"))
11139 if (sw_if_index_set == 0)
11141 errmsg ("missing sw_if_index or interface name");
11145 if (file_name_set == 0)
11147 errmsg ("missing socket file name");
11151 if (vec_len (file_name) > 255)
11153 errmsg ("socket file name too long");
11156 vec_add1 (file_name, 0);
11158 M (MODIFY_VHOST_USER_IF, mp);
11160 mp->sw_if_index = ntohl (sw_if_index);
11161 mp->is_server = is_server;
11162 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11163 vec_free (file_name);
11164 if (custom_dev_instance != ~0)
11167 mp->custom_dev_instance = ntohl (custom_dev_instance);
11176 api_delete_vhost_user_if (vat_main_t * vam)
11178 unformat_input_t *i = vam->input;
11179 vl_api_delete_vhost_user_if_t *mp;
11180 u32 sw_if_index = ~0;
11181 u8 sw_if_index_set = 0;
11184 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11186 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11187 sw_if_index_set = 1;
11188 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11189 sw_if_index_set = 1;
11194 if (sw_if_index_set == 0)
11196 errmsg ("missing sw_if_index or interface name");
11201 M (DELETE_VHOST_USER_IF, mp);
11203 mp->sw_if_index = ntohl (sw_if_index);
11210 static void vl_api_sw_interface_vhost_user_details_t_handler
11211 (vl_api_sw_interface_vhost_user_details_t * mp)
11213 vat_main_t *vam = &vat_main;
11215 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11216 (char *) mp->interface_name,
11217 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11218 clib_net_to_host_u64 (mp->features), mp->is_server,
11219 ntohl (mp->num_regions), (char *) mp->sock_filename);
11220 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11223 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11224 (vl_api_sw_interface_vhost_user_details_t * mp)
11226 vat_main_t *vam = &vat_main;
11227 vat_json_node_t *node = NULL;
11229 if (VAT_JSON_ARRAY != vam->json_tree.type)
11231 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11232 vat_json_init_array (&vam->json_tree);
11234 node = vat_json_array_add (&vam->json_tree);
11236 vat_json_init_object (node);
11237 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11238 vat_json_object_add_string_copy (node, "interface_name",
11239 mp->interface_name);
11240 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11241 ntohl (mp->virtio_net_hdr_sz));
11242 vat_json_object_add_uint (node, "features",
11243 clib_net_to_host_u64 (mp->features));
11244 vat_json_object_add_uint (node, "is_server", mp->is_server);
11245 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11246 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11247 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11251 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11253 vl_api_sw_interface_vhost_user_dump_t *mp;
11254 vl_api_control_ping_t *mp_ping;
11257 "Interface name idx hdr_sz features server regions filename");
11259 /* Get list of vhost-user interfaces */
11260 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11263 /* Use a control ping for synchronization */
11264 M (CONTROL_PING, mp_ping);
11272 api_show_version (vat_main_t * vam)
11274 vl_api_show_version_t *mp;
11277 M (SHOW_VERSION, mp);
11286 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11288 unformat_input_t *line_input = vam->input;
11289 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11290 ip4_address_t local4, remote4;
11291 ip6_address_t local6, remote6;
11293 u8 ipv4_set = 0, ipv6_set = 0;
11296 u32 encap_vrf_id = 0;
11297 u32 decap_vrf_id = 0;
11303 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11305 if (unformat (line_input, "del"))
11307 else if (unformat (line_input, "local %U",
11308 unformat_ip4_address, &local4))
11313 else if (unformat (line_input, "remote %U",
11314 unformat_ip4_address, &remote4))
11319 else if (unformat (line_input, "local %U",
11320 unformat_ip6_address, &local6))
11325 else if (unformat (line_input, "remote %U",
11326 unformat_ip6_address, &remote6))
11331 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11333 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11335 else if (unformat (line_input, "vni %d", &vni))
11337 else if (unformat (line_input, "next-ip4"))
11339 else if (unformat (line_input, "next-ip6"))
11341 else if (unformat (line_input, "next-ethernet"))
11343 else if (unformat (line_input, "next-nsh"))
11347 errmsg ("parse error '%U'", format_unformat_error, line_input);
11352 if (local_set == 0)
11354 errmsg ("tunnel local address not specified");
11357 if (remote_set == 0)
11359 errmsg ("tunnel remote address not specified");
11362 if (ipv4_set && ipv6_set)
11364 errmsg ("both IPv4 and IPv6 addresses specified");
11370 errmsg ("vni not specified");
11374 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11379 clib_memcpy (&mp->local, &local6, sizeof (local6));
11380 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11384 clib_memcpy (&mp->local, &local4, sizeof (local4));
11385 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11388 mp->encap_vrf_id = ntohl (encap_vrf_id);
11389 mp->decap_vrf_id = ntohl (decap_vrf_id);
11390 mp->protocol = protocol;
11391 mp->vni = ntohl (vni);
11392 mp->is_add = is_add;
11393 mp->is_ipv6 = ipv6_set;
11400 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11401 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11403 vat_main_t *vam = &vat_main;
11405 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11406 ntohl (mp->sw_if_index),
11407 format_ip46_address, &(mp->local[0]),
11408 format_ip46_address, &(mp->remote[0]),
11410 ntohl (mp->protocol),
11411 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11414 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11415 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11417 vat_main_t *vam = &vat_main;
11418 vat_json_node_t *node = NULL;
11419 struct in_addr ip4;
11420 struct in6_addr ip6;
11422 if (VAT_JSON_ARRAY != vam->json_tree.type)
11424 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11425 vat_json_init_array (&vam->json_tree);
11427 node = vat_json_array_add (&vam->json_tree);
11429 vat_json_init_object (node);
11430 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11433 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11434 vat_json_object_add_ip6 (node, "local", ip6);
11435 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11436 vat_json_object_add_ip6 (node, "remote", ip6);
11440 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11441 vat_json_object_add_ip4 (node, "local", ip4);
11442 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11443 vat_json_object_add_ip4 (node, "remote", ip4);
11445 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11446 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11447 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11448 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11449 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11453 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11455 unformat_input_t *i = vam->input;
11456 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11457 vl_api_control_ping_t *mp_ping;
11459 u8 sw_if_index_set = 0;
11462 /* Parse args required to build the message */
11463 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11465 if (unformat (i, "sw_if_index %d", &sw_if_index))
11466 sw_if_index_set = 1;
11471 if (sw_if_index_set == 0)
11476 if (!vam->json_output)
11478 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11479 "sw_if_index", "local", "remote", "vni",
11480 "protocol", "encap_vrf_id", "decap_vrf_id");
11483 /* Get list of vxlan-tunnel interfaces */
11484 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11486 mp->sw_if_index = htonl (sw_if_index);
11490 /* Use a control ping for synchronization */
11491 M (CONTROL_PING, mp_ping);
11499 format_l2_fib_mac_address (u8 * s, va_list * args)
11501 u8 *a = va_arg (*args, u8 *);
11503 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11504 a[2], a[3], a[4], a[5], a[6], a[7]);
11507 static void vl_api_l2_fib_table_entry_t_handler
11508 (vl_api_l2_fib_table_entry_t * mp)
11510 vat_main_t *vam = &vat_main;
11512 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11514 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11515 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11519 static void vl_api_l2_fib_table_entry_t_handler_json
11520 (vl_api_l2_fib_table_entry_t * mp)
11522 vat_main_t *vam = &vat_main;
11523 vat_json_node_t *node = NULL;
11525 if (VAT_JSON_ARRAY != vam->json_tree.type)
11527 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11528 vat_json_init_array (&vam->json_tree);
11530 node = vat_json_array_add (&vam->json_tree);
11532 vat_json_init_object (node);
11533 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11534 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11535 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11536 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11537 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11538 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11542 api_l2_fib_table_dump (vat_main_t * vam)
11544 unformat_input_t *i = vam->input;
11545 vl_api_l2_fib_table_dump_t *mp;
11546 vl_api_control_ping_t *mp_ping;
11551 /* Parse args required to build the message */
11552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11554 if (unformat (i, "bd_id %d", &bd_id))
11560 if (bd_id_set == 0)
11562 errmsg ("missing bridge domain");
11566 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11568 /* Get list of l2 fib entries */
11569 M (L2_FIB_TABLE_DUMP, mp);
11571 mp->bd_id = ntohl (bd_id);
11574 /* Use a control ping for synchronization */
11575 M (CONTROL_PING, mp_ping);
11584 api_interface_name_renumber (vat_main_t * vam)
11586 unformat_input_t *line_input = vam->input;
11587 vl_api_interface_name_renumber_t *mp;
11588 u32 sw_if_index = ~0;
11589 u32 new_show_dev_instance = ~0;
11592 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11594 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11597 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11599 else if (unformat (line_input, "new_show_dev_instance %d",
11600 &new_show_dev_instance))
11606 if (sw_if_index == ~0)
11608 errmsg ("missing interface name or sw_if_index");
11612 if (new_show_dev_instance == ~0)
11614 errmsg ("missing new_show_dev_instance");
11618 M (INTERFACE_NAME_RENUMBER, mp);
11620 mp->sw_if_index = ntohl (sw_if_index);
11621 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11629 api_want_ip4_arp_events (vat_main_t * vam)
11631 unformat_input_t *line_input = vam->input;
11632 vl_api_want_ip4_arp_events_t *mp;
11633 ip4_address_t address;
11634 int address_set = 0;
11635 u32 enable_disable = 1;
11638 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11640 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11642 else if (unformat (line_input, "del"))
11643 enable_disable = 0;
11648 if (address_set == 0)
11650 errmsg ("missing addresses");
11654 M (WANT_IP4_ARP_EVENTS, mp);
11655 mp->enable_disable = enable_disable;
11656 mp->pid = getpid ();
11657 mp->address = address.as_u32;
11665 api_want_ip6_nd_events (vat_main_t * vam)
11667 unformat_input_t *line_input = vam->input;
11668 vl_api_want_ip6_nd_events_t *mp;
11669 ip6_address_t address;
11670 int address_set = 0;
11671 u32 enable_disable = 1;
11674 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11676 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11678 else if (unformat (line_input, "del"))
11679 enable_disable = 0;
11684 if (address_set == 0)
11686 errmsg ("missing addresses");
11690 M (WANT_IP6_ND_EVENTS, mp);
11691 mp->enable_disable = enable_disable;
11692 mp->pid = getpid ();
11693 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11701 api_input_acl_set_interface (vat_main_t * vam)
11703 unformat_input_t *i = vam->input;
11704 vl_api_input_acl_set_interface_t *mp;
11706 int sw_if_index_set;
11707 u32 ip4_table_index = ~0;
11708 u32 ip6_table_index = ~0;
11709 u32 l2_table_index = ~0;
11713 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11715 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11716 sw_if_index_set = 1;
11717 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11718 sw_if_index_set = 1;
11719 else if (unformat (i, "del"))
11721 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11723 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11725 else if (unformat (i, "l2-table %d", &l2_table_index))
11729 clib_warning ("parse error '%U'", format_unformat_error, i);
11734 if (sw_if_index_set == 0)
11736 errmsg ("missing interface name or sw_if_index");
11740 M (INPUT_ACL_SET_INTERFACE, mp);
11742 mp->sw_if_index = ntohl (sw_if_index);
11743 mp->ip4_table_index = ntohl (ip4_table_index);
11744 mp->ip6_table_index = ntohl (ip6_table_index);
11745 mp->l2_table_index = ntohl (l2_table_index);
11746 mp->is_add = is_add;
11754 api_ip_address_dump (vat_main_t * vam)
11756 unformat_input_t *i = vam->input;
11757 vl_api_ip_address_dump_t *mp;
11758 vl_api_control_ping_t *mp_ping;
11759 u32 sw_if_index = ~0;
11760 u8 sw_if_index_set = 0;
11765 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11767 if (unformat (i, "sw_if_index %d", &sw_if_index))
11768 sw_if_index_set = 1;
11770 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11771 sw_if_index_set = 1;
11772 else if (unformat (i, "ipv4"))
11774 else if (unformat (i, "ipv6"))
11780 if (ipv4_set && ipv6_set)
11782 errmsg ("ipv4 and ipv6 flags cannot be both set");
11786 if ((!ipv4_set) && (!ipv6_set))
11788 errmsg ("no ipv4 nor ipv6 flag set");
11792 if (sw_if_index_set == 0)
11794 errmsg ("missing interface name or sw_if_index");
11798 vam->current_sw_if_index = sw_if_index;
11799 vam->is_ipv6 = ipv6_set;
11801 M (IP_ADDRESS_DUMP, mp);
11802 mp->sw_if_index = ntohl (sw_if_index);
11803 mp->is_ipv6 = ipv6_set;
11806 /* Use a control ping for synchronization */
11807 M (CONTROL_PING, mp_ping);
11815 api_ip_dump (vat_main_t * vam)
11817 vl_api_ip_dump_t *mp;
11818 vl_api_control_ping_t *mp_ping;
11819 unformat_input_t *in = vam->input;
11826 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11828 if (unformat (in, "ipv4"))
11830 else if (unformat (in, "ipv6"))
11836 if (ipv4_set && ipv6_set)
11838 errmsg ("ipv4 and ipv6 flags cannot be both set");
11842 if ((!ipv4_set) && (!ipv6_set))
11844 errmsg ("no ipv4 nor ipv6 flag set");
11848 is_ipv6 = ipv6_set;
11849 vam->is_ipv6 = is_ipv6;
11851 /* free old data */
11852 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11854 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11856 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11859 mp->is_ipv6 = ipv6_set;
11862 /* Use a control ping for synchronization */
11863 M (CONTROL_PING, mp_ping);
11871 api_ipsec_spd_add_del (vat_main_t * vam)
11873 unformat_input_t *i = vam->input;
11874 vl_api_ipsec_spd_add_del_t *mp;
11879 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11881 if (unformat (i, "spd_id %d", &spd_id))
11883 else if (unformat (i, "del"))
11887 clib_warning ("parse error '%U'", format_unformat_error, i);
11893 errmsg ("spd_id must be set");
11897 M (IPSEC_SPD_ADD_DEL, mp);
11899 mp->spd_id = ntohl (spd_id);
11900 mp->is_add = is_add;
11908 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11910 unformat_input_t *i = vam->input;
11911 vl_api_ipsec_interface_add_del_spd_t *mp;
11913 u8 sw_if_index_set = 0;
11914 u32 spd_id = (u32) ~ 0;
11918 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11920 if (unformat (i, "del"))
11922 else if (unformat (i, "spd_id %d", &spd_id))
11925 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11926 sw_if_index_set = 1;
11927 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11928 sw_if_index_set = 1;
11931 clib_warning ("parse error '%U'", format_unformat_error, i);
11937 if (spd_id == (u32) ~ 0)
11939 errmsg ("spd_id must be set");
11943 if (sw_if_index_set == 0)
11945 errmsg ("missing interface name or sw_if_index");
11949 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
11951 mp->spd_id = ntohl (spd_id);
11952 mp->sw_if_index = ntohl (sw_if_index);
11953 mp->is_add = is_add;
11961 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11963 unformat_input_t *i = vam->input;
11964 vl_api_ipsec_spd_add_del_entry_t *mp;
11965 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11966 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11968 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11969 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11970 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11971 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11974 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11975 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11976 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11977 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11978 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11979 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11981 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11983 if (unformat (i, "del"))
11985 if (unformat (i, "outbound"))
11987 if (unformat (i, "inbound"))
11989 else if (unformat (i, "spd_id %d", &spd_id))
11991 else if (unformat (i, "sa_id %d", &sa_id))
11993 else if (unformat (i, "priority %d", &priority))
11995 else if (unformat (i, "protocol %d", &protocol))
11997 else if (unformat (i, "lport_start %d", &lport_start))
11999 else if (unformat (i, "lport_stop %d", &lport_stop))
12001 else if (unformat (i, "rport_start %d", &rport_start))
12003 else if (unformat (i, "rport_stop %d", &rport_stop))
12007 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12013 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12020 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12026 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12033 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12039 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12046 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12052 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12058 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12060 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12062 clib_warning ("unsupported action: 'resolve'");
12068 clib_warning ("parse error '%U'", format_unformat_error, i);
12074 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12076 mp->spd_id = ntohl (spd_id);
12077 mp->priority = ntohl (priority);
12078 mp->is_outbound = is_outbound;
12080 mp->is_ipv6 = is_ipv6;
12081 if (is_ipv6 || is_ip_any)
12083 clib_memcpy (mp->remote_address_start, &raddr6_start,
12084 sizeof (ip6_address_t));
12085 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12086 sizeof (ip6_address_t));
12087 clib_memcpy (mp->local_address_start, &laddr6_start,
12088 sizeof (ip6_address_t));
12089 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12090 sizeof (ip6_address_t));
12094 clib_memcpy (mp->remote_address_start, &raddr4_start,
12095 sizeof (ip4_address_t));
12096 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12097 sizeof (ip4_address_t));
12098 clib_memcpy (mp->local_address_start, &laddr4_start,
12099 sizeof (ip4_address_t));
12100 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12101 sizeof (ip4_address_t));
12103 mp->protocol = (u8) protocol;
12104 mp->local_port_start = ntohs ((u16) lport_start);
12105 mp->local_port_stop = ntohs ((u16) lport_stop);
12106 mp->remote_port_start = ntohs ((u16) rport_start);
12107 mp->remote_port_stop = ntohs ((u16) rport_stop);
12108 mp->policy = (u8) policy;
12109 mp->sa_id = ntohl (sa_id);
12110 mp->is_add = is_add;
12111 mp->is_ip_any = is_ip_any;
12118 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12120 unformat_input_t *i = vam->input;
12121 vl_api_ipsec_sad_add_del_entry_t *mp;
12122 u32 sad_id = 0, spi = 0;
12123 u8 *ck = 0, *ik = 0;
12126 u8 protocol = IPSEC_PROTOCOL_AH;
12127 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12128 u32 crypto_alg = 0, integ_alg = 0;
12129 ip4_address_t tun_src4;
12130 ip4_address_t tun_dst4;
12131 ip6_address_t tun_src6;
12132 ip6_address_t tun_dst6;
12135 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12137 if (unformat (i, "del"))
12139 else if (unformat (i, "sad_id %d", &sad_id))
12141 else if (unformat (i, "spi %d", &spi))
12143 else if (unformat (i, "esp"))
12144 protocol = IPSEC_PROTOCOL_ESP;
12145 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12148 is_tunnel_ipv6 = 0;
12150 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12153 is_tunnel_ipv6 = 0;
12155 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12158 is_tunnel_ipv6 = 1;
12160 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12163 is_tunnel_ipv6 = 1;
12167 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12169 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12170 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12172 clib_warning ("unsupported crypto-alg: '%U'",
12173 format_ipsec_crypto_alg, crypto_alg);
12177 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12181 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12183 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12184 integ_alg >= IPSEC_INTEG_N_ALG)
12186 clib_warning ("unsupported integ-alg: '%U'",
12187 format_ipsec_integ_alg, integ_alg);
12191 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12195 clib_warning ("parse error '%U'", format_unformat_error, i);
12201 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12203 mp->sad_id = ntohl (sad_id);
12204 mp->is_add = is_add;
12205 mp->protocol = protocol;
12206 mp->spi = ntohl (spi);
12207 mp->is_tunnel = is_tunnel;
12208 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12209 mp->crypto_algorithm = crypto_alg;
12210 mp->integrity_algorithm = integ_alg;
12211 mp->crypto_key_length = vec_len (ck);
12212 mp->integrity_key_length = vec_len (ik);
12214 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12215 mp->crypto_key_length = sizeof (mp->crypto_key);
12217 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12218 mp->integrity_key_length = sizeof (mp->integrity_key);
12221 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12223 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12227 if (is_tunnel_ipv6)
12229 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12230 sizeof (ip6_address_t));
12231 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12232 sizeof (ip6_address_t));
12236 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12237 sizeof (ip4_address_t));
12238 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12239 sizeof (ip4_address_t));
12249 api_ipsec_sa_set_key (vat_main_t * vam)
12251 unformat_input_t *i = vam->input;
12252 vl_api_ipsec_sa_set_key_t *mp;
12254 u8 *ck = 0, *ik = 0;
12257 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12259 if (unformat (i, "sa_id %d", &sa_id))
12261 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12263 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12267 clib_warning ("parse error '%U'", format_unformat_error, i);
12272 M (IPSEC_SA_SET_KEY, mp);
12274 mp->sa_id = ntohl (sa_id);
12275 mp->crypto_key_length = vec_len (ck);
12276 mp->integrity_key_length = vec_len (ik);
12278 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12279 mp->crypto_key_length = sizeof (mp->crypto_key);
12281 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12282 mp->integrity_key_length = sizeof (mp->integrity_key);
12285 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12287 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12295 api_ikev2_profile_add_del (vat_main_t * vam)
12297 unformat_input_t *i = vam->input;
12298 vl_api_ikev2_profile_add_del_t *mp;
12303 const char *valid_chars = "a-zA-Z0-9_";
12305 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12307 if (unformat (i, "del"))
12309 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12310 vec_add1 (name, 0);
12313 errmsg ("parse error '%U'", format_unformat_error, i);
12318 if (!vec_len (name))
12320 errmsg ("profile name must be specified");
12324 if (vec_len (name) > 64)
12326 errmsg ("profile name too long");
12330 M (IKEV2_PROFILE_ADD_DEL, mp);
12332 clib_memcpy (mp->name, name, vec_len (name));
12333 mp->is_add = is_add;
12342 api_ikev2_profile_set_auth (vat_main_t * vam)
12344 unformat_input_t *i = vam->input;
12345 vl_api_ikev2_profile_set_auth_t *mp;
12348 u32 auth_method = 0;
12352 const char *valid_chars = "a-zA-Z0-9_";
12354 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12356 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12357 vec_add1 (name, 0);
12358 else if (unformat (i, "auth_method %U",
12359 unformat_ikev2_auth_method, &auth_method))
12361 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12363 else if (unformat (i, "auth_data %v", &data))
12367 errmsg ("parse error '%U'", format_unformat_error, i);
12372 if (!vec_len (name))
12374 errmsg ("profile name must be specified");
12378 if (vec_len (name) > 64)
12380 errmsg ("profile name too long");
12384 if (!vec_len (data))
12386 errmsg ("auth_data must be specified");
12392 errmsg ("auth_method must be specified");
12396 M (IKEV2_PROFILE_SET_AUTH, mp);
12398 mp->is_hex = is_hex;
12399 mp->auth_method = (u8) auth_method;
12400 mp->data_len = vec_len (data);
12401 clib_memcpy (mp->name, name, vec_len (name));
12402 clib_memcpy (mp->data, data, vec_len (data));
12412 api_ikev2_profile_set_id (vat_main_t * vam)
12414 unformat_input_t *i = vam->input;
12415 vl_api_ikev2_profile_set_id_t *mp;
12423 const char *valid_chars = "a-zA-Z0-9_";
12425 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12427 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12428 vec_add1 (name, 0);
12429 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12431 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12433 data = vec_new (u8, 4);
12434 clib_memcpy (data, ip4.as_u8, 4);
12436 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12438 else if (unformat (i, "id_data %v", &data))
12440 else if (unformat (i, "local"))
12442 else if (unformat (i, "remote"))
12446 errmsg ("parse error '%U'", format_unformat_error, i);
12451 if (!vec_len (name))
12453 errmsg ("profile name must be specified");
12457 if (vec_len (name) > 64)
12459 errmsg ("profile name too long");
12463 if (!vec_len (data))
12465 errmsg ("id_data must be specified");
12471 errmsg ("id_type must be specified");
12475 M (IKEV2_PROFILE_SET_ID, mp);
12477 mp->is_local = is_local;
12478 mp->id_type = (u8) id_type;
12479 mp->data_len = vec_len (data);
12480 clib_memcpy (mp->name, name, vec_len (name));
12481 clib_memcpy (mp->data, data, vec_len (data));
12491 api_ikev2_profile_set_ts (vat_main_t * vam)
12493 unformat_input_t *i = vam->input;
12494 vl_api_ikev2_profile_set_ts_t *mp;
12497 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12498 ip4_address_t start_addr, end_addr;
12500 const char *valid_chars = "a-zA-Z0-9_";
12503 start_addr.as_u32 = 0;
12504 end_addr.as_u32 = (u32) ~ 0;
12506 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12508 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12509 vec_add1 (name, 0);
12510 else if (unformat (i, "protocol %d", &proto))
12512 else if (unformat (i, "start_port %d", &start_port))
12514 else if (unformat (i, "end_port %d", &end_port))
12517 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12519 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12521 else if (unformat (i, "local"))
12523 else if (unformat (i, "remote"))
12527 errmsg ("parse error '%U'", format_unformat_error, i);
12532 if (!vec_len (name))
12534 errmsg ("profile name must be specified");
12538 if (vec_len (name) > 64)
12540 errmsg ("profile name too long");
12544 M (IKEV2_PROFILE_SET_TS, mp);
12546 mp->is_local = is_local;
12547 mp->proto = (u8) proto;
12548 mp->start_port = (u16) start_port;
12549 mp->end_port = (u16) end_port;
12550 mp->start_addr = start_addr.as_u32;
12551 mp->end_addr = end_addr.as_u32;
12552 clib_memcpy (mp->name, name, vec_len (name));
12561 api_ikev2_set_local_key (vat_main_t * vam)
12563 unformat_input_t *i = vam->input;
12564 vl_api_ikev2_set_local_key_t *mp;
12568 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12570 if (unformat (i, "file %v", &file))
12571 vec_add1 (file, 0);
12574 errmsg ("parse error '%U'", format_unformat_error, i);
12579 if (!vec_len (file))
12581 errmsg ("RSA key file must be specified");
12585 if (vec_len (file) > 256)
12587 errmsg ("file name too long");
12591 M (IKEV2_SET_LOCAL_KEY, mp);
12593 clib_memcpy (mp->key_file, file, vec_len (file));
12602 api_ikev2_set_responder (vat_main_t * vam)
12604 unformat_input_t *i = vam->input;
12605 vl_api_ikev2_set_responder_t *mp;
12608 u32 sw_if_index = ~0;
12609 ip4_address_t address;
12611 const char *valid_chars = "a-zA-Z0-9_";
12613 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12616 (i, "%U interface %d address %U", unformat_token, valid_chars,
12617 &name, &sw_if_index, unformat_ip4_address, &address))
12618 vec_add1 (name, 0);
12621 errmsg ("parse error '%U'", format_unformat_error, i);
12626 if (!vec_len (name))
12628 errmsg ("profile name must be specified");
12632 if (vec_len (name) > 64)
12634 errmsg ("profile name too long");
12638 M (IKEV2_SET_RESPONDER, mp);
12640 clib_memcpy (mp->name, name, vec_len (name));
12643 mp->sw_if_index = sw_if_index;
12644 clib_memcpy (mp->address, &address, sizeof (address));
12652 api_ikev2_set_ike_transforms (vat_main_t * vam)
12654 unformat_input_t *i = vam->input;
12655 vl_api_ikev2_set_ike_transforms_t *mp;
12658 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12660 const char *valid_chars = "a-zA-Z0-9_";
12662 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12664 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12665 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12666 vec_add1 (name, 0);
12669 errmsg ("parse error '%U'", format_unformat_error, i);
12674 if (!vec_len (name))
12676 errmsg ("profile name must be specified");
12680 if (vec_len (name) > 64)
12682 errmsg ("profile name too long");
12686 M (IKEV2_SET_IKE_TRANSFORMS, mp);
12688 clib_memcpy (mp->name, name, vec_len (name));
12690 mp->crypto_alg = crypto_alg;
12691 mp->crypto_key_size = crypto_key_size;
12692 mp->integ_alg = integ_alg;
12693 mp->dh_group = dh_group;
12702 api_ikev2_set_esp_transforms (vat_main_t * vam)
12704 unformat_input_t *i = vam->input;
12705 vl_api_ikev2_set_esp_transforms_t *mp;
12708 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12710 const char *valid_chars = "a-zA-Z0-9_";
12712 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12714 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12715 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12716 vec_add1 (name, 0);
12719 errmsg ("parse error '%U'", format_unformat_error, i);
12724 if (!vec_len (name))
12726 errmsg ("profile name must be specified");
12730 if (vec_len (name) > 64)
12732 errmsg ("profile name too long");
12736 M (IKEV2_SET_ESP_TRANSFORMS, mp);
12738 clib_memcpy (mp->name, name, vec_len (name));
12740 mp->crypto_alg = crypto_alg;
12741 mp->crypto_key_size = crypto_key_size;
12742 mp->integ_alg = integ_alg;
12743 mp->dh_group = dh_group;
12751 api_ikev2_set_sa_lifetime (vat_main_t * vam)
12753 unformat_input_t *i = vam->input;
12754 vl_api_ikev2_set_sa_lifetime_t *mp;
12757 u64 lifetime, lifetime_maxdata;
12758 u32 lifetime_jitter, handover;
12760 const char *valid_chars = "a-zA-Z0-9_";
12762 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12764 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
12765 &lifetime, &lifetime_jitter, &handover,
12766 &lifetime_maxdata))
12767 vec_add1 (name, 0);
12770 errmsg ("parse error '%U'", format_unformat_error, i);
12775 if (!vec_len (name))
12777 errmsg ("profile name must be specified");
12781 if (vec_len (name) > 64)
12783 errmsg ("profile name too long");
12787 M (IKEV2_SET_SA_LIFETIME, mp);
12789 clib_memcpy (mp->name, name, vec_len (name));
12791 mp->lifetime = lifetime;
12792 mp->lifetime_jitter = lifetime_jitter;
12793 mp->handover = handover;
12794 mp->lifetime_maxdata = lifetime_maxdata;
12802 api_ikev2_initiate_sa_init (vat_main_t * vam)
12804 unformat_input_t *i = vam->input;
12805 vl_api_ikev2_initiate_sa_init_t *mp;
12809 const char *valid_chars = "a-zA-Z0-9_";
12811 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12813 if (unformat (i, "%U", unformat_token, valid_chars, &name))
12814 vec_add1 (name, 0);
12817 errmsg ("parse error '%U'", format_unformat_error, i);
12822 if (!vec_len (name))
12824 errmsg ("profile name must be specified");
12828 if (vec_len (name) > 64)
12830 errmsg ("profile name too long");
12834 M (IKEV2_INITIATE_SA_INIT, mp);
12836 clib_memcpy (mp->name, name, vec_len (name));
12845 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
12847 unformat_input_t *i = vam->input;
12848 vl_api_ikev2_initiate_del_ike_sa_t *mp;
12853 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12855 if (unformat (i, "%lx", &ispi))
12859 errmsg ("parse error '%U'", format_unformat_error, i);
12864 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
12874 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
12876 unformat_input_t *i = vam->input;
12877 vl_api_ikev2_initiate_del_child_sa_t *mp;
12882 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12884 if (unformat (i, "%x", &ispi))
12888 errmsg ("parse error '%U'", format_unformat_error, i);
12893 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
12903 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
12905 unformat_input_t *i = vam->input;
12906 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
12911 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12913 if (unformat (i, "%x", &ispi))
12917 errmsg ("parse error '%U'", format_unformat_error, i);
12922 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
12935 api_map_add_domain (vat_main_t * vam)
12937 unformat_input_t *i = vam->input;
12938 vl_api_map_add_domain_t *mp;
12940 ip4_address_t ip4_prefix;
12941 ip6_address_t ip6_prefix;
12942 ip6_address_t ip6_src;
12943 u32 num_m_args = 0;
12944 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12945 0, psid_length = 0;
12946 u8 is_translation = 0;
12948 u32 ip6_src_len = 128;
12951 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12953 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12954 &ip4_prefix, &ip4_prefix_len))
12956 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12957 &ip6_prefix, &ip6_prefix_len))
12961 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12964 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12966 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12968 else if (unformat (i, "psid-offset %d", &psid_offset))
12970 else if (unformat (i, "psid-len %d", &psid_length))
12972 else if (unformat (i, "mtu %d", &mtu))
12974 else if (unformat (i, "map-t"))
12975 is_translation = 1;
12978 clib_warning ("parse error '%U'", format_unformat_error, i);
12983 if (num_m_args < 3)
12985 errmsg ("mandatory argument(s) missing");
12989 /* Construct the API message */
12990 M (MAP_ADD_DOMAIN, mp);
12992 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12993 mp->ip4_prefix_len = ip4_prefix_len;
12995 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12996 mp->ip6_prefix_len = ip6_prefix_len;
12998 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12999 mp->ip6_src_prefix_len = ip6_src_len;
13001 mp->ea_bits_len = ea_bits_len;
13002 mp->psid_offset = psid_offset;
13003 mp->psid_length = psid_length;
13004 mp->is_translation = is_translation;
13005 mp->mtu = htons (mtu);
13010 /* Wait for a reply, return good/bad news */
13016 api_map_del_domain (vat_main_t * vam)
13018 unformat_input_t *i = vam->input;
13019 vl_api_map_del_domain_t *mp;
13021 u32 num_m_args = 0;
13025 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13027 if (unformat (i, "index %d", &index))
13031 clib_warning ("parse error '%U'", format_unformat_error, i);
13036 if (num_m_args != 1)
13038 errmsg ("mandatory argument(s) missing");
13042 /* Construct the API message */
13043 M (MAP_DEL_DOMAIN, mp);
13045 mp->index = ntohl (index);
13050 /* Wait for a reply, return good/bad news */
13056 api_map_add_del_rule (vat_main_t * vam)
13058 unformat_input_t *i = vam->input;
13059 vl_api_map_add_del_rule_t *mp;
13061 ip6_address_t ip6_dst;
13062 u32 num_m_args = 0, index, psid = 0;
13065 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13067 if (unformat (i, "index %d", &index))
13069 else if (unformat (i, "psid %d", &psid))
13071 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13073 else if (unformat (i, "del"))
13079 clib_warning ("parse error '%U'", format_unformat_error, i);
13084 /* Construct the API message */
13085 M (MAP_ADD_DEL_RULE, mp);
13087 mp->index = ntohl (index);
13088 mp->is_add = is_add;
13089 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13090 mp->psid = ntohs (psid);
13095 /* Wait for a reply, return good/bad news */
13101 api_map_domain_dump (vat_main_t * vam)
13103 vl_api_map_domain_dump_t *mp;
13104 vl_api_control_ping_t *mp_ping;
13107 /* Construct the API message */
13108 M (MAP_DOMAIN_DUMP, mp);
13113 /* Use a control ping for synchronization */
13114 M (CONTROL_PING, mp_ping);
13122 api_map_rule_dump (vat_main_t * vam)
13124 unformat_input_t *i = vam->input;
13125 vl_api_map_rule_dump_t *mp;
13126 vl_api_control_ping_t *mp_ping;
13127 u32 domain_index = ~0;
13130 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13132 if (unformat (i, "index %u", &domain_index))
13138 if (domain_index == ~0)
13140 clib_warning ("parse error: domain index expected");
13144 /* Construct the API message */
13145 M (MAP_RULE_DUMP, mp);
13147 mp->domain_index = htonl (domain_index);
13152 /* Use a control ping for synchronization */
13153 M (CONTROL_PING, mp_ping);
13160 static void vl_api_map_add_domain_reply_t_handler
13161 (vl_api_map_add_domain_reply_t * mp)
13163 vat_main_t *vam = &vat_main;
13164 i32 retval = ntohl (mp->retval);
13166 if (vam->async_mode)
13168 vam->async_errors += (retval < 0);
13172 vam->retval = retval;
13173 vam->result_ready = 1;
13177 static void vl_api_map_add_domain_reply_t_handler_json
13178 (vl_api_map_add_domain_reply_t * mp)
13180 vat_main_t *vam = &vat_main;
13181 vat_json_node_t node;
13183 vat_json_init_object (&node);
13184 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13185 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13187 vat_json_print (vam->ofp, &node);
13188 vat_json_free (&node);
13190 vam->retval = ntohl (mp->retval);
13191 vam->result_ready = 1;
13195 api_get_first_msg_id (vat_main_t * vam)
13197 vl_api_get_first_msg_id_t *mp;
13198 unformat_input_t *i = vam->input;
13203 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13205 if (unformat (i, "client %s", &name))
13213 errmsg ("missing client name");
13216 vec_add1 (name, 0);
13218 if (vec_len (name) > 63)
13220 errmsg ("client name too long");
13224 M (GET_FIRST_MSG_ID, mp);
13225 clib_memcpy (mp->name, name, vec_len (name));
13232 api_cop_interface_enable_disable (vat_main_t * vam)
13234 unformat_input_t *line_input = vam->input;
13235 vl_api_cop_interface_enable_disable_t *mp;
13236 u32 sw_if_index = ~0;
13237 u8 enable_disable = 1;
13240 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13242 if (unformat (line_input, "disable"))
13243 enable_disable = 0;
13244 if (unformat (line_input, "enable"))
13245 enable_disable = 1;
13246 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13247 vam, &sw_if_index))
13249 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13255 if (sw_if_index == ~0)
13257 errmsg ("missing interface name or sw_if_index");
13261 /* Construct the API message */
13262 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13263 mp->sw_if_index = ntohl (sw_if_index);
13264 mp->enable_disable = enable_disable;
13268 /* Wait for the reply */
13274 api_cop_whitelist_enable_disable (vat_main_t * vam)
13276 unformat_input_t *line_input = vam->input;
13277 vl_api_cop_whitelist_enable_disable_t *mp;
13278 u32 sw_if_index = ~0;
13279 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13283 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13285 if (unformat (line_input, "ip4"))
13287 else if (unformat (line_input, "ip6"))
13289 else if (unformat (line_input, "default"))
13291 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13292 vam, &sw_if_index))
13294 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13296 else if (unformat (line_input, "fib-id %d", &fib_id))
13302 if (sw_if_index == ~0)
13304 errmsg ("missing interface name or sw_if_index");
13308 /* Construct the API message */
13309 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13310 mp->sw_if_index = ntohl (sw_if_index);
13311 mp->fib_id = ntohl (fib_id);
13314 mp->default_cop = default_cop;
13318 /* Wait for the reply */
13324 api_get_node_graph (vat_main_t * vam)
13326 vl_api_get_node_graph_t *mp;
13329 M (GET_NODE_GRAPH, mp);
13333 /* Wait for the reply */
13339 /** Used for parsing LISP eids */
13340 typedef CLIB_PACKED(struct{
13341 u8 addr[16]; /**< eid address */
13342 u32 len; /**< prefix length if IP */
13343 u8 type; /**< type of eid */
13348 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13350 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13352 memset (a, 0, sizeof (a[0]));
13354 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13356 a->type = 0; /* ipv4 type */
13358 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13360 a->type = 1; /* ipv6 type */
13362 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13364 a->type = 2; /* mac type */
13371 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13380 lisp_eid_size_vat (u8 type)
13395 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13397 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13401 api_one_add_del_locator_set (vat_main_t * vam)
13403 unformat_input_t *input = vam->input;
13404 vl_api_one_add_del_locator_set_t *mp;
13406 u8 *locator_set_name = NULL;
13407 u8 locator_set_name_set = 0;
13408 vl_api_local_locator_t locator, *locators = 0;
13409 u32 sw_if_index, priority, weight;
13413 /* Parse args required to build the message */
13414 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13416 if (unformat (input, "del"))
13420 else if (unformat (input, "locator-set %s", &locator_set_name))
13422 locator_set_name_set = 1;
13424 else if (unformat (input, "sw_if_index %u p %u w %u",
13425 &sw_if_index, &priority, &weight))
13427 locator.sw_if_index = htonl (sw_if_index);
13428 locator.priority = priority;
13429 locator.weight = weight;
13430 vec_add1 (locators, locator);
13434 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13435 &sw_if_index, &priority, &weight))
13437 locator.sw_if_index = htonl (sw_if_index);
13438 locator.priority = priority;
13439 locator.weight = weight;
13440 vec_add1 (locators, locator);
13446 if (locator_set_name_set == 0)
13448 errmsg ("missing locator-set name");
13449 vec_free (locators);
13453 if (vec_len (locator_set_name) > 64)
13455 errmsg ("locator-set name too long");
13456 vec_free (locator_set_name);
13457 vec_free (locators);
13460 vec_add1 (locator_set_name, 0);
13462 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13464 /* Construct the API message */
13465 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
13467 mp->is_add = is_add;
13468 clib_memcpy (mp->locator_set_name, locator_set_name,
13469 vec_len (locator_set_name));
13470 vec_free (locator_set_name);
13472 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13474 clib_memcpy (mp->locators, locators, data_len);
13475 vec_free (locators);
13480 /* Wait for a reply... */
13485 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
13488 api_one_add_del_locator (vat_main_t * vam)
13490 unformat_input_t *input = vam->input;
13491 vl_api_one_add_del_locator_t *mp;
13492 u32 tmp_if_index = ~0;
13493 u32 sw_if_index = ~0;
13494 u8 sw_if_index_set = 0;
13495 u8 sw_if_index_if_name_set = 0;
13497 u8 priority_set = 0;
13501 u8 *locator_set_name = NULL;
13502 u8 locator_set_name_set = 0;
13505 /* Parse args required to build the message */
13506 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13508 if (unformat (input, "del"))
13512 else if (unformat (input, "locator-set %s", &locator_set_name))
13514 locator_set_name_set = 1;
13516 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13519 sw_if_index_if_name_set = 1;
13520 sw_if_index = tmp_if_index;
13522 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13524 sw_if_index_set = 1;
13525 sw_if_index = tmp_if_index;
13527 else if (unformat (input, "p %d", &priority))
13531 else if (unformat (input, "w %d", &weight))
13539 if (locator_set_name_set == 0)
13541 errmsg ("missing locator-set name");
13545 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13547 errmsg ("missing sw_if_index");
13548 vec_free (locator_set_name);
13552 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13554 errmsg ("cannot use both params interface name and sw_if_index");
13555 vec_free (locator_set_name);
13559 if (priority_set == 0)
13561 errmsg ("missing locator-set priority");
13562 vec_free (locator_set_name);
13566 if (weight_set == 0)
13568 errmsg ("missing locator-set weight");
13569 vec_free (locator_set_name);
13573 if (vec_len (locator_set_name) > 64)
13575 errmsg ("locator-set name too long");
13576 vec_free (locator_set_name);
13579 vec_add1 (locator_set_name, 0);
13581 /* Construct the API message */
13582 M (ONE_ADD_DEL_LOCATOR, mp);
13584 mp->is_add = is_add;
13585 mp->sw_if_index = ntohl (sw_if_index);
13586 mp->priority = priority;
13587 mp->weight = weight;
13588 clib_memcpy (mp->locator_set_name, locator_set_name,
13589 vec_len (locator_set_name));
13590 vec_free (locator_set_name);
13595 /* Wait for a reply... */
13600 #define api_lisp_add_del_locator api_one_add_del_locator
13603 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13605 u32 *key_id = va_arg (*args, u32 *);
13608 if (unformat (input, "%s", &s))
13610 if (!strcmp ((char *) s, "sha1"))
13611 key_id[0] = HMAC_SHA_1_96;
13612 else if (!strcmp ((char *) s, "sha256"))
13613 key_id[0] = HMAC_SHA_256_128;
13616 clib_warning ("invalid key_id: '%s'", s);
13617 key_id[0] = HMAC_NO_KEY;
13628 api_one_add_del_local_eid (vat_main_t * vam)
13630 unformat_input_t *input = vam->input;
13631 vl_api_one_add_del_local_eid_t *mp;
13634 lisp_eid_vat_t _eid, *eid = &_eid;
13635 u8 *locator_set_name = 0;
13636 u8 locator_set_name_set = 0;
13642 /* Parse args required to build the message */
13643 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13645 if (unformat (input, "del"))
13649 else if (unformat (input, "vni %d", &vni))
13653 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13657 else if (unformat (input, "locator-set %s", &locator_set_name))
13659 locator_set_name_set = 1;
13661 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13663 else if (unformat (input, "secret-key %_%v%_", &key))
13669 if (locator_set_name_set == 0)
13671 errmsg ("missing locator-set name");
13677 errmsg ("EID address not set!");
13678 vec_free (locator_set_name);
13682 if (key && (0 == key_id))
13684 errmsg ("invalid key_id!");
13688 if (vec_len (key) > 64)
13690 errmsg ("key too long");
13695 if (vec_len (locator_set_name) > 64)
13697 errmsg ("locator-set name too long");
13698 vec_free (locator_set_name);
13701 vec_add1 (locator_set_name, 0);
13703 /* Construct the API message */
13704 M (ONE_ADD_DEL_LOCAL_EID, mp);
13706 mp->is_add = is_add;
13707 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13708 mp->eid_type = eid->type;
13709 mp->prefix_len = eid->len;
13710 mp->vni = clib_host_to_net_u32 (vni);
13711 mp->key_id = clib_host_to_net_u16 (key_id);
13712 clib_memcpy (mp->locator_set_name, locator_set_name,
13713 vec_len (locator_set_name));
13714 clib_memcpy (mp->key, key, vec_len (key));
13716 vec_free (locator_set_name);
13722 /* Wait for a reply... */
13727 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
13730 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13732 u32 dp_table = 0, vni = 0;;
13733 unformat_input_t *input = vam->input;
13734 vl_api_gpe_add_del_fwd_entry_t *mp;
13736 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13737 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13738 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13739 u32 action = ~0, w;
13740 ip4_address_t rmt_rloc4, lcl_rloc4;
13741 ip6_address_t rmt_rloc6, lcl_rloc6;
13742 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13745 memset (&rloc, 0, sizeof (rloc));
13747 /* Parse args required to build the message */
13748 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13750 if (unformat (input, "del"))
13752 else if (unformat (input, "add"))
13754 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13758 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13762 else if (unformat (input, "vrf %d", &dp_table))
13764 else if (unformat (input, "bd %d", &dp_table))
13766 else if (unformat (input, "vni %d", &vni))
13768 else if (unformat (input, "w %d", &w))
13772 errmsg ("No RLOC configured for setting priority/weight!");
13775 curr_rloc->weight = w;
13777 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13778 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13782 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13784 vec_add1 (lcl_locs, rloc);
13786 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13787 vec_add1 (rmt_locs, rloc);
13788 /* weight saved in rmt loc */
13789 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13791 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13792 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13795 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13797 vec_add1 (lcl_locs, rloc);
13799 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13800 vec_add1 (rmt_locs, rloc);
13801 /* weight saved in rmt loc */
13802 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13804 else if (unformat (input, "action %d", &action))
13810 clib_warning ("parse error '%U'", format_unformat_error, input);
13817 errmsg ("remote eid addresses not set");
13821 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13823 errmsg ("eid types don't match");
13827 if (0 == rmt_locs && (u32) ~ 0 == action)
13829 errmsg ("action not set for negative mapping");
13833 /* Construct the API message */
13834 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
13835 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
13837 mp->is_add = is_add;
13838 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13839 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13840 mp->eid_type = rmt_eid->type;
13841 mp->dp_table = clib_host_to_net_u32 (dp_table);
13842 mp->vni = clib_host_to_net_u32 (vni);
13843 mp->rmt_len = rmt_eid->len;
13844 mp->lcl_len = lcl_eid->len;
13845 mp->action = action;
13847 if (0 != rmt_locs && 0 != lcl_locs)
13849 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
13850 clib_memcpy (mp->locs, lcl_locs,
13851 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
13853 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
13854 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
13855 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
13857 vec_free (lcl_locs);
13858 vec_free (rmt_locs);
13863 /* Wait for a reply... */
13869 api_one_add_del_map_server (vat_main_t * vam)
13871 unformat_input_t *input = vam->input;
13872 vl_api_one_add_del_map_server_t *mp;
13876 ip4_address_t ipv4;
13877 ip6_address_t ipv6;
13880 /* Parse args required to build the message */
13881 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13883 if (unformat (input, "del"))
13887 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13891 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13899 if (ipv4_set && ipv6_set)
13901 errmsg ("both eid v4 and v6 addresses set");
13905 if (!ipv4_set && !ipv6_set)
13907 errmsg ("eid addresses not set");
13911 /* Construct the API message */
13912 M (ONE_ADD_DEL_MAP_SERVER, mp);
13914 mp->is_add = is_add;
13918 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13923 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13929 /* Wait for a reply... */
13934 #define api_lisp_add_del_map_server api_one_add_del_map_server
13937 api_one_add_del_map_resolver (vat_main_t * vam)
13939 unformat_input_t *input = vam->input;
13940 vl_api_one_add_del_map_resolver_t *mp;
13944 ip4_address_t ipv4;
13945 ip6_address_t ipv6;
13948 /* Parse args required to build the message */
13949 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13951 if (unformat (input, "del"))
13955 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13959 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13967 if (ipv4_set && ipv6_set)
13969 errmsg ("both eid v4 and v6 addresses set");
13973 if (!ipv4_set && !ipv6_set)
13975 errmsg ("eid addresses not set");
13979 /* Construct the API message */
13980 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
13982 mp->is_add = is_add;
13986 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13991 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13997 /* Wait for a reply... */
14002 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14005 api_lisp_gpe_enable_disable (vat_main_t * vam)
14007 unformat_input_t *input = vam->input;
14008 vl_api_gpe_enable_disable_t *mp;
14013 /* Parse args required to build the message */
14014 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14016 if (unformat (input, "enable"))
14021 else if (unformat (input, "disable"))
14032 errmsg ("Value not set");
14036 /* Construct the API message */
14037 M (GPE_ENABLE_DISABLE, mp);
14044 /* Wait for a reply... */
14050 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14052 unformat_input_t *input = vam->input;
14053 vl_api_one_rloc_probe_enable_disable_t *mp;
14058 /* Parse args required to build the message */
14059 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14061 if (unformat (input, "enable"))
14066 else if (unformat (input, "disable"))
14074 errmsg ("Value not set");
14078 /* Construct the API message */
14079 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14081 mp->is_enabled = is_en;
14086 /* Wait for a reply... */
14091 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14094 api_one_map_register_enable_disable (vat_main_t * vam)
14096 unformat_input_t *input = vam->input;
14097 vl_api_one_map_register_enable_disable_t *mp;
14102 /* Parse args required to build the message */
14103 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14105 if (unformat (input, "enable"))
14110 else if (unformat (input, "disable"))
14118 errmsg ("Value not set");
14122 /* Construct the API message */
14123 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14125 mp->is_enabled = is_en;
14130 /* Wait for a reply... */
14135 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14138 api_one_enable_disable (vat_main_t * vam)
14140 unformat_input_t *input = vam->input;
14141 vl_api_one_enable_disable_t *mp;
14146 /* Parse args required to build the message */
14147 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14149 if (unformat (input, "enable"))
14154 else if (unformat (input, "disable"))
14164 errmsg ("Value not set");
14168 /* Construct the API message */
14169 M (ONE_ENABLE_DISABLE, mp);
14176 /* Wait for a reply... */
14181 #define api_lisp_enable_disable api_one_enable_disable
14184 api_show_one_map_register_state (vat_main_t * vam)
14186 vl_api_show_one_map_register_state_t *mp;
14189 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14194 /* wait for reply */
14199 #define api_show_lisp_map_register_state api_show_one_map_register_state
14202 api_show_one_rloc_probe_state (vat_main_t * vam)
14204 vl_api_show_one_rloc_probe_state_t *mp;
14207 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14212 /* wait for reply */
14217 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14220 api_show_one_map_request_mode (vat_main_t * vam)
14222 vl_api_show_one_map_request_mode_t *mp;
14225 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
14230 /* wait for reply */
14235 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
14238 api_one_map_request_mode (vat_main_t * vam)
14240 unformat_input_t *input = vam->input;
14241 vl_api_one_map_request_mode_t *mp;
14245 /* Parse args required to build the message */
14246 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14248 if (unformat (input, "dst-only"))
14250 else if (unformat (input, "src-dst"))
14254 errmsg ("parse error '%U'", format_unformat_error, input);
14259 M (ONE_MAP_REQUEST_MODE, mp);
14266 /* wait for reply */
14271 #define api_lisp_map_request_mode api_one_map_request_mode
14274 * Enable/disable ONE proxy ITR.
14276 * @param vam vpp API test context
14277 * @return return code
14280 api_one_pitr_set_locator_set (vat_main_t * vam)
14282 u8 ls_name_set = 0;
14283 unformat_input_t *input = vam->input;
14284 vl_api_one_pitr_set_locator_set_t *mp;
14289 /* Parse args required to build the message */
14290 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14292 if (unformat (input, "del"))
14294 else if (unformat (input, "locator-set %s", &ls_name))
14298 errmsg ("parse error '%U'", format_unformat_error, input);
14305 errmsg ("locator-set name not set!");
14309 M (ONE_PITR_SET_LOCATOR_SET, mp);
14311 mp->is_add = is_add;
14312 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14313 vec_free (ls_name);
14318 /* wait for reply */
14323 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
14326 api_show_one_pitr (vat_main_t * vam)
14328 vl_api_show_one_pitr_t *mp;
14331 if (!vam->json_output)
14333 print (vam->ofp, "%=20s", "lisp status:");
14336 M (SHOW_ONE_PITR, mp);
14340 /* Wait for a reply... */
14345 #define api_show_lisp_pitr api_show_one_pitr
14348 api_one_use_petr (vat_main_t * vam)
14350 unformat_input_t *input = vam->input;
14351 vl_api_one_use_petr_t *mp;
14356 memset (&ip, 0, sizeof (ip));
14358 /* Parse args required to build the message */
14359 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14361 if (unformat (input, "disable"))
14364 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
14367 ip_addr_version (&ip) = IP4;
14370 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
14373 ip_addr_version (&ip) = IP6;
14377 errmsg ("parse error '%U'", format_unformat_error, input);
14382 M (ONE_USE_PETR, mp);
14384 mp->is_add = is_add;
14387 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
14389 clib_memcpy (mp->address, &ip, 4);
14391 clib_memcpy (mp->address, &ip, 16);
14397 /* wait for reply */
14402 #define api_lisp_use_petr api_one_use_petr
14405 api_show_one_use_petr (vat_main_t * vam)
14407 vl_api_show_one_use_petr_t *mp;
14410 if (!vam->json_output)
14412 print (vam->ofp, "%=20s", "Proxy-ETR status:");
14415 M (SHOW_ONE_USE_PETR, mp);
14419 /* Wait for a reply... */
14424 #define api_show_lisp_use_petr api_show_one_use_petr
14427 * Add/delete mapping between vni and vrf
14430 api_one_eid_table_add_del_map (vat_main_t * vam)
14432 unformat_input_t *input = vam->input;
14433 vl_api_one_eid_table_add_del_map_t *mp;
14434 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
14435 u32 vni, vrf, bd_index;
14438 /* Parse args required to build the message */
14439 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14441 if (unformat (input, "del"))
14443 else if (unformat (input, "vrf %d", &vrf))
14445 else if (unformat (input, "bd_index %d", &bd_index))
14447 else if (unformat (input, "vni %d", &vni))
14453 if (!vni_set || (!vrf_set && !bd_index_set))
14455 errmsg ("missing arguments!");
14459 if (vrf_set && bd_index_set)
14461 errmsg ("error: both vrf and bd entered!");
14465 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
14467 mp->is_add = is_add;
14468 mp->vni = htonl (vni);
14469 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
14470 mp->is_l2 = bd_index_set;
14475 /* wait for reply */
14480 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
14483 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
14485 u32 *action = va_arg (*args, u32 *);
14488 if (unformat (input, "%s", &s))
14490 if (!strcmp ((char *) s, "no-action"))
14492 else if (!strcmp ((char *) s, "natively-forward"))
14494 else if (!strcmp ((char *) s, "send-map-request"))
14496 else if (!strcmp ((char *) s, "drop"))
14500 clib_warning ("invalid action: '%s'", s);
14512 * Add/del remote mapping to/from ONE control plane
14514 * @param vam vpp API test context
14515 * @return return code
14518 api_one_add_del_remote_mapping (vat_main_t * vam)
14520 unformat_input_t *input = vam->input;
14521 vl_api_one_add_del_remote_mapping_t *mp;
14523 lisp_eid_vat_t _eid, *eid = &_eid;
14524 lisp_eid_vat_t _seid, *seid = &_seid;
14525 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
14526 u32 action = ~0, p, w, data_len;
14527 ip4_address_t rloc4;
14528 ip6_address_t rloc6;
14529 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
14532 memset (&rloc, 0, sizeof (rloc));
14534 /* Parse args required to build the message */
14535 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14537 if (unformat (input, "del-all"))
14541 else if (unformat (input, "del"))
14545 else if (unformat (input, "add"))
14549 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14553 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14557 else if (unformat (input, "vni %d", &vni))
14561 else if (unformat (input, "p %d w %d", &p, &w))
14565 errmsg ("No RLOC configured for setting priority/weight!");
14568 curr_rloc->priority = p;
14569 curr_rloc->weight = w;
14571 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14574 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14575 vec_add1 (rlocs, rloc);
14576 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14578 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14581 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14582 vec_add1 (rlocs, rloc);
14583 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14585 else if (unformat (input, "action %U",
14586 unformat_negative_mapping_action, &action))
14592 clib_warning ("parse error '%U'", format_unformat_error, input);
14599 errmsg ("missing params!");
14603 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14605 errmsg ("no action set for negative map-reply!");
14609 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
14611 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
14612 mp->is_add = is_add;
14613 mp->vni = htonl (vni);
14614 mp->action = (u8) action;
14615 mp->is_src_dst = seid_set;
14616 mp->eid_len = eid->len;
14617 mp->seid_len = seid->len;
14618 mp->del_all = del_all;
14619 mp->eid_type = eid->type;
14620 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14621 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14623 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14624 clib_memcpy (mp->rlocs, rlocs, data_len);
14630 /* Wait for a reply... */
14635 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
14638 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
14639 * forwarding entries in data-plane accordingly.
14641 * @param vam vpp API test context
14642 * @return return code
14645 api_one_add_del_adjacency (vat_main_t * vam)
14647 unformat_input_t *input = vam->input;
14648 vl_api_one_add_del_adjacency_t *mp;
14650 ip4_address_t leid4, reid4;
14651 ip6_address_t leid6, reid6;
14652 u8 reid_mac[6] = { 0 };
14653 u8 leid_mac[6] = { 0 };
14654 u8 reid_type, leid_type;
14655 u32 leid_len = 0, reid_len = 0, len;
14659 leid_type = reid_type = (u8) ~ 0;
14661 /* Parse args required to build the message */
14662 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14664 if (unformat (input, "del"))
14668 else if (unformat (input, "add"))
14672 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14675 reid_type = 0; /* ipv4 */
14678 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14681 reid_type = 1; /* ipv6 */
14684 else if (unformat (input, "reid %U", unformat_ethernet_address,
14687 reid_type = 2; /* mac */
14689 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14692 leid_type = 0; /* ipv4 */
14695 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14698 leid_type = 1; /* ipv6 */
14701 else if (unformat (input, "leid %U", unformat_ethernet_address,
14704 leid_type = 2; /* mac */
14706 else if (unformat (input, "vni %d", &vni))
14712 errmsg ("parse error '%U'", format_unformat_error, input);
14717 if ((u8) ~ 0 == reid_type)
14719 errmsg ("missing params!");
14723 if (leid_type != reid_type)
14725 errmsg ("remote and local EIDs are of different types!");
14729 M (ONE_ADD_DEL_ADJACENCY, mp);
14730 mp->is_add = is_add;
14731 mp->vni = htonl (vni);
14732 mp->leid_len = leid_len;
14733 mp->reid_len = reid_len;
14734 mp->eid_type = reid_type;
14736 switch (mp->eid_type)
14739 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14740 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14743 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14744 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14747 clib_memcpy (mp->leid, leid_mac, 6);
14748 clib_memcpy (mp->reid, reid_mac, 6);
14751 errmsg ("unknown EID type %d!", mp->eid_type);
14758 /* Wait for a reply... */
14763 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
14766 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
14768 u32 *mode = va_arg (*args, u32 *);
14770 if (unformat (input, "lisp"))
14772 else if (unformat (input, "vxlan"))
14781 api_gpe_get_encap_mode (vat_main_t * vam)
14783 vl_api_gpe_get_encap_mode_t *mp;
14786 /* Construct the API message */
14787 M (GPE_GET_ENCAP_MODE, mp);
14792 /* Wait for a reply... */
14798 api_gpe_set_encap_mode (vat_main_t * vam)
14800 unformat_input_t *input = vam->input;
14801 vl_api_gpe_set_encap_mode_t *mp;
14805 /* Parse args required to build the message */
14806 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14808 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
14814 /* Construct the API message */
14815 M (GPE_SET_ENCAP_MODE, mp);
14822 /* Wait for a reply... */
14828 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14830 unformat_input_t *input = vam->input;
14831 vl_api_gpe_add_del_iface_t *mp;
14832 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14833 u32 dp_table = 0, vni = 0;
14836 /* Parse args required to build the message */
14837 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14839 if (unformat (input, "up"))
14844 else if (unformat (input, "down"))
14849 else if (unformat (input, "table_id %d", &dp_table))
14853 else if (unformat (input, "bd_id %d", &dp_table))
14858 else if (unformat (input, "vni %d", &vni))
14866 if (action_set == 0)
14868 errmsg ("Action not set");
14871 if (dp_table_set == 0 || vni_set == 0)
14873 errmsg ("vni and dp_table must be set");
14877 /* Construct the API message */
14878 M (GPE_ADD_DEL_IFACE, mp);
14880 mp->is_add = is_add;
14881 mp->dp_table = dp_table;
14888 /* Wait for a reply... */
14894 * Add/del map request itr rlocs from ONE control plane and updates
14896 * @param vam vpp API test context
14897 * @return return code
14900 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
14902 unformat_input_t *input = vam->input;
14903 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
14904 u8 *locator_set_name = 0;
14905 u8 locator_set_name_set = 0;
14909 /* Parse args required to build the message */
14910 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14912 if (unformat (input, "del"))
14916 else if (unformat (input, "%_%v%_", &locator_set_name))
14918 locator_set_name_set = 1;
14922 clib_warning ("parse error '%U'", format_unformat_error, input);
14927 if (is_add && !locator_set_name_set)
14929 errmsg ("itr-rloc is not set!");
14933 if (is_add && vec_len (locator_set_name) > 64)
14935 errmsg ("itr-rloc locator-set name too long");
14936 vec_free (locator_set_name);
14940 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
14941 mp->is_add = is_add;
14944 clib_memcpy (mp->locator_set_name, locator_set_name,
14945 vec_len (locator_set_name));
14949 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14951 vec_free (locator_set_name);
14956 /* Wait for a reply... */
14961 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
14964 api_one_locator_dump (vat_main_t * vam)
14966 unformat_input_t *input = vam->input;
14967 vl_api_one_locator_dump_t *mp;
14968 vl_api_control_ping_t *mp_ping;
14969 u8 is_index_set = 0, is_name_set = 0;
14974 /* Parse args required to build the message */
14975 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14977 if (unformat (input, "ls_name %_%v%_", &ls_name))
14981 else if (unformat (input, "ls_index %d", &ls_index))
14987 errmsg ("parse error '%U'", format_unformat_error, input);
14992 if (!is_index_set && !is_name_set)
14994 errmsg ("error: expected one of index or name!");
14998 if (is_index_set && is_name_set)
15000 errmsg ("error: only one param expected!");
15004 if (vec_len (ls_name) > 62)
15006 errmsg ("error: locator set name too long!");
15010 if (!vam->json_output)
15012 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
15015 M (ONE_LOCATOR_DUMP, mp);
15016 mp->is_index_set = is_index_set;
15019 mp->ls_index = clib_host_to_net_u32 (ls_index);
15022 vec_add1 (ls_name, 0);
15023 strncpy ((char *) mp->ls_name, (char *) ls_name,
15024 sizeof (mp->ls_name) - 1);
15030 /* Use a control ping for synchronization */
15031 M (CONTROL_PING, mp_ping);
15034 /* Wait for a reply... */
15039 #define api_lisp_locator_dump api_one_locator_dump
15042 api_one_locator_set_dump (vat_main_t * vam)
15044 vl_api_one_locator_set_dump_t *mp;
15045 vl_api_control_ping_t *mp_ping;
15046 unformat_input_t *input = vam->input;
15050 /* Parse args required to build the message */
15051 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15053 if (unformat (input, "local"))
15057 else if (unformat (input, "remote"))
15063 errmsg ("parse error '%U'", format_unformat_error, input);
15068 if (!vam->json_output)
15070 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
15073 M (ONE_LOCATOR_SET_DUMP, mp);
15075 mp->filter = filter;
15080 /* Use a control ping for synchronization */
15081 M (CONTROL_PING, mp_ping);
15084 /* Wait for a reply... */
15089 #define api_lisp_locator_set_dump api_one_locator_set_dump
15092 api_one_eid_table_map_dump (vat_main_t * vam)
15096 unformat_input_t *input = vam->input;
15097 vl_api_one_eid_table_map_dump_t *mp;
15098 vl_api_control_ping_t *mp_ping;
15101 /* Parse args required to build the message */
15102 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15104 if (unformat (input, "l2"))
15109 else if (unformat (input, "l3"))
15116 errmsg ("parse error '%U'", format_unformat_error, input);
15123 errmsg ("expected one of 'l2' or 'l3' parameter!");
15127 if (!vam->json_output)
15129 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
15132 M (ONE_EID_TABLE_MAP_DUMP, mp);
15138 /* Use a control ping for synchronization */
15139 M (CONTROL_PING, mp_ping);
15142 /* Wait for a reply... */
15147 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
15150 api_one_eid_table_vni_dump (vat_main_t * vam)
15152 vl_api_one_eid_table_vni_dump_t *mp;
15153 vl_api_control_ping_t *mp_ping;
15156 if (!vam->json_output)
15158 print (vam->ofp, "VNI");
15161 M (ONE_EID_TABLE_VNI_DUMP, mp);
15166 /* Use a control ping for synchronization */
15167 M (CONTROL_PING, mp_ping);
15170 /* Wait for a reply... */
15175 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
15178 api_one_eid_table_dump (vat_main_t * vam)
15180 unformat_input_t *i = vam->input;
15181 vl_api_one_eid_table_dump_t *mp;
15182 vl_api_control_ping_t *mp_ping;
15183 struct in_addr ip4;
15184 struct in6_addr ip6;
15186 u8 eid_type = ~0, eid_set = 0;
15187 u32 prefix_length = ~0, t, vni = 0;
15191 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15193 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
15199 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
15205 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
15210 else if (unformat (i, "vni %d", &t))
15214 else if (unformat (i, "local"))
15218 else if (unformat (i, "remote"))
15224 errmsg ("parse error '%U'", format_unformat_error, i);
15229 if (!vam->json_output)
15231 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
15232 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
15235 M (ONE_EID_TABLE_DUMP, mp);
15237 mp->filter = filter;
15241 mp->vni = htonl (vni);
15242 mp->eid_type = eid_type;
15246 mp->prefix_length = prefix_length;
15247 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
15250 mp->prefix_length = prefix_length;
15251 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
15254 clib_memcpy (mp->eid, mac, sizeof (mac));
15257 errmsg ("unknown EID type %d!", eid_type);
15265 /* Use a control ping for synchronization */
15266 M (CONTROL_PING, mp_ping);
15269 /* Wait for a reply... */
15274 #define api_lisp_eid_table_dump api_one_eid_table_dump
15277 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
15279 unformat_input_t *i = vam->input;
15280 vl_api_gpe_fwd_entries_get_t *mp;
15285 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15287 if (unformat (i, "vni %d", &vni))
15293 errmsg ("parse error '%U'", format_unformat_error, i);
15300 errmsg ("vni not set!");
15304 if (!vam->json_output)
15306 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15310 M (GPE_FWD_ENTRIES_GET, mp);
15311 mp->vni = clib_host_to_net_u32 (vni);
15316 /* Wait for a reply... */
15321 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15322 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15323 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15324 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
15327 api_one_adjacencies_get (vat_main_t * vam)
15329 unformat_input_t *i = vam->input;
15330 vl_api_one_adjacencies_get_t *mp;
15335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15337 if (unformat (i, "vni %d", &vni))
15343 errmsg ("parse error '%U'", format_unformat_error, i);
15350 errmsg ("vni not set!");
15354 if (!vam->json_output)
15356 print (vam->ofp, "%s %40s", "leid", "reid");
15359 M (ONE_ADJACENCIES_GET, mp);
15360 mp->vni = clib_host_to_net_u32 (vni);
15365 /* Wait for a reply... */
15370 #define api_lisp_adjacencies_get api_one_adjacencies_get
15373 api_one_map_server_dump (vat_main_t * vam)
15375 vl_api_one_map_server_dump_t *mp;
15376 vl_api_control_ping_t *mp_ping;
15379 if (!vam->json_output)
15381 print (vam->ofp, "%=20s", "Map server");
15384 M (ONE_MAP_SERVER_DUMP, mp);
15388 /* Use a control ping for synchronization */
15389 M (CONTROL_PING, mp_ping);
15392 /* Wait for a reply... */
15397 #define api_lisp_map_server_dump api_one_map_server_dump
15400 api_one_map_resolver_dump (vat_main_t * vam)
15402 vl_api_one_map_resolver_dump_t *mp;
15403 vl_api_control_ping_t *mp_ping;
15406 if (!vam->json_output)
15408 print (vam->ofp, "%=20s", "Map resolver");
15411 M (ONE_MAP_RESOLVER_DUMP, mp);
15415 /* Use a control ping for synchronization */
15416 M (CONTROL_PING, mp_ping);
15419 /* Wait for a reply... */
15424 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
15427 api_show_one_status (vat_main_t * vam)
15429 vl_api_show_one_status_t *mp;
15432 if (!vam->json_output)
15434 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
15437 M (SHOW_ONE_STATUS, mp);
15440 /* Wait for a reply... */
15445 #define api_show_lisp_status api_show_one_status
15448 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
15450 vl_api_gpe_fwd_entry_path_dump_t *mp;
15451 vl_api_control_ping_t *mp_ping;
15452 unformat_input_t *i = vam->input;
15453 u32 fwd_entry_index = ~0;
15456 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15458 if (unformat (i, "index %d", &fwd_entry_index))
15464 if (~0 == fwd_entry_index)
15466 errmsg ("no index specified!");
15470 if (!vam->json_output)
15472 print (vam->ofp, "first line");
15475 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
15479 /* Use a control ping for synchronization */
15480 M (CONTROL_PING, mp_ping);
15483 /* Wait for a reply... */
15489 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
15491 vl_api_one_get_map_request_itr_rlocs_t *mp;
15494 if (!vam->json_output)
15496 print (vam->ofp, "%=20s", "itr-rlocs:");
15499 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
15502 /* Wait for a reply... */
15507 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
15510 api_af_packet_create (vat_main_t * vam)
15512 unformat_input_t *i = vam->input;
15513 vl_api_af_packet_create_t *mp;
15514 u8 *host_if_name = 0;
15516 u8 random_hw_addr = 1;
15519 memset (hw_addr, 0, sizeof (hw_addr));
15521 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15523 if (unformat (i, "name %s", &host_if_name))
15524 vec_add1 (host_if_name, 0);
15525 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15526 random_hw_addr = 0;
15531 if (!vec_len (host_if_name))
15533 errmsg ("host-interface name must be specified");
15537 if (vec_len (host_if_name) > 64)
15539 errmsg ("host-interface name too long");
15543 M (AF_PACKET_CREATE, mp);
15545 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15546 clib_memcpy (mp->hw_addr, hw_addr, 6);
15547 mp->use_random_hw_addr = random_hw_addr;
15548 vec_free (host_if_name);
15556 fprintf (vam->ofp ? vam->ofp : stderr,
15557 " new sw_if_index = %d\n", vam->sw_if_index);
15564 api_af_packet_delete (vat_main_t * vam)
15566 unformat_input_t *i = vam->input;
15567 vl_api_af_packet_delete_t *mp;
15568 u8 *host_if_name = 0;
15571 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15573 if (unformat (i, "name %s", &host_if_name))
15574 vec_add1 (host_if_name, 0);
15579 if (!vec_len (host_if_name))
15581 errmsg ("host-interface name must be specified");
15585 if (vec_len (host_if_name) > 64)
15587 errmsg ("host-interface name too long");
15591 M (AF_PACKET_DELETE, mp);
15593 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15594 vec_free (host_if_name);
15602 api_policer_add_del (vat_main_t * vam)
15604 unformat_input_t *i = vam->input;
15605 vl_api_policer_add_del_t *mp;
15615 u8 color_aware = 0;
15616 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
15619 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
15620 conform_action.dscp = 0;
15621 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
15622 exceed_action.dscp = 0;
15623 violate_action.action_type = SSE2_QOS_ACTION_DROP;
15624 violate_action.dscp = 0;
15626 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15628 if (unformat (i, "del"))
15630 else if (unformat (i, "name %s", &name))
15631 vec_add1 (name, 0);
15632 else if (unformat (i, "cir %u", &cir))
15634 else if (unformat (i, "eir %u", &eir))
15636 else if (unformat (i, "cb %u", &cb))
15638 else if (unformat (i, "eb %u", &eb))
15640 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
15643 else if (unformat (i, "round_type %U", unformat_policer_round_type,
15646 else if (unformat (i, "type %U", unformat_policer_type, &type))
15648 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
15651 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
15654 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
15657 else if (unformat (i, "color-aware"))
15663 if (!vec_len (name))
15665 errmsg ("policer name must be specified");
15669 if (vec_len (name) > 64)
15671 errmsg ("policer name too long");
15675 M (POLICER_ADD_DEL, mp);
15677 clib_memcpy (mp->name, name, vec_len (name));
15679 mp->is_add = is_add;
15684 mp->rate_type = rate_type;
15685 mp->round_type = round_type;
15687 mp->conform_action_type = conform_action.action_type;
15688 mp->conform_dscp = conform_action.dscp;
15689 mp->exceed_action_type = exceed_action.action_type;
15690 mp->exceed_dscp = exceed_action.dscp;
15691 mp->violate_action_type = violate_action.action_type;
15692 mp->violate_dscp = violate_action.dscp;
15693 mp->color_aware = color_aware;
15701 api_policer_dump (vat_main_t * vam)
15703 unformat_input_t *i = vam->input;
15704 vl_api_policer_dump_t *mp;
15705 vl_api_control_ping_t *mp_ping;
15706 u8 *match_name = 0;
15707 u8 match_name_valid = 0;
15710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15712 if (unformat (i, "name %s", &match_name))
15714 vec_add1 (match_name, 0);
15715 match_name_valid = 1;
15721 M (POLICER_DUMP, mp);
15722 mp->match_name_valid = match_name_valid;
15723 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15724 vec_free (match_name);
15728 /* Use a control ping for synchronization */
15729 M (CONTROL_PING, mp_ping);
15732 /* Wait for a reply... */
15738 api_policer_classify_set_interface (vat_main_t * vam)
15740 unformat_input_t *i = vam->input;
15741 vl_api_policer_classify_set_interface_t *mp;
15743 int sw_if_index_set;
15744 u32 ip4_table_index = ~0;
15745 u32 ip6_table_index = ~0;
15746 u32 l2_table_index = ~0;
15750 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15752 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15753 sw_if_index_set = 1;
15754 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15755 sw_if_index_set = 1;
15756 else if (unformat (i, "del"))
15758 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15760 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15762 else if (unformat (i, "l2-table %d", &l2_table_index))
15766 clib_warning ("parse error '%U'", format_unformat_error, i);
15771 if (sw_if_index_set == 0)
15773 errmsg ("missing interface name or sw_if_index");
15777 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
15779 mp->sw_if_index = ntohl (sw_if_index);
15780 mp->ip4_table_index = ntohl (ip4_table_index);
15781 mp->ip6_table_index = ntohl (ip6_table_index);
15782 mp->l2_table_index = ntohl (l2_table_index);
15783 mp->is_add = is_add;
15791 api_policer_classify_dump (vat_main_t * vam)
15793 unformat_input_t *i = vam->input;
15794 vl_api_policer_classify_dump_t *mp;
15795 vl_api_control_ping_t *mp_ping;
15796 u8 type = POLICER_CLASSIFY_N_TABLES;
15799 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15803 errmsg ("classify table type must be specified");
15807 if (!vam->json_output)
15809 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15812 M (POLICER_CLASSIFY_DUMP, mp);
15817 /* Use a control ping for synchronization */
15818 M (CONTROL_PING, mp_ping);
15821 /* Wait for a reply... */
15827 api_netmap_create (vat_main_t * vam)
15829 unformat_input_t *i = vam->input;
15830 vl_api_netmap_create_t *mp;
15833 u8 random_hw_addr = 1;
15838 memset (hw_addr, 0, sizeof (hw_addr));
15840 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15842 if (unformat (i, "name %s", &if_name))
15843 vec_add1 (if_name, 0);
15844 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15845 random_hw_addr = 0;
15846 else if (unformat (i, "pipe"))
15848 else if (unformat (i, "master"))
15850 else if (unformat (i, "slave"))
15856 if (!vec_len (if_name))
15858 errmsg ("interface name must be specified");
15862 if (vec_len (if_name) > 64)
15864 errmsg ("interface name too long");
15868 M (NETMAP_CREATE, mp);
15870 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15871 clib_memcpy (mp->hw_addr, hw_addr, 6);
15872 mp->use_random_hw_addr = random_hw_addr;
15873 mp->is_pipe = is_pipe;
15874 mp->is_master = is_master;
15875 vec_free (if_name);
15883 api_netmap_delete (vat_main_t * vam)
15885 unformat_input_t *i = vam->input;
15886 vl_api_netmap_delete_t *mp;
15890 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15892 if (unformat (i, "name %s", &if_name))
15893 vec_add1 (if_name, 0);
15898 if (!vec_len (if_name))
15900 errmsg ("interface name must be specified");
15904 if (vec_len (if_name) > 64)
15906 errmsg ("interface name too long");
15910 M (NETMAP_DELETE, mp);
15912 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15913 vec_free (if_name);
15920 static void vl_api_mpls_tunnel_details_t_handler
15921 (vl_api_mpls_tunnel_details_t * mp)
15923 vat_main_t *vam = &vat_main;
15924 i32 len = mp->mt_next_hop_n_labels;
15927 print (vam->ofp, "[%d]: via %U %d labels ",
15929 format_ip4_address, mp->mt_next_hop,
15930 ntohl (mp->mt_next_hop_sw_if_index));
15931 for (i = 0; i < len; i++)
15933 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15935 print (vam->ofp, "");
15938 static void vl_api_mpls_tunnel_details_t_handler_json
15939 (vl_api_mpls_tunnel_details_t * mp)
15941 vat_main_t *vam = &vat_main;
15942 vat_json_node_t *node = NULL;
15943 struct in_addr ip4;
15945 i32 len = mp->mt_next_hop_n_labels;
15947 if (VAT_JSON_ARRAY != vam->json_tree.type)
15949 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15950 vat_json_init_array (&vam->json_tree);
15952 node = vat_json_array_add (&vam->json_tree);
15954 vat_json_init_object (node);
15955 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15956 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15957 vat_json_object_add_ip4 (node, "next_hop", ip4);
15958 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15959 ntohl (mp->mt_next_hop_sw_if_index));
15960 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15961 vat_json_object_add_uint (node, "label_count", len);
15962 for (i = 0; i < len; i++)
15964 vat_json_object_add_uint (node, "label",
15965 ntohl (mp->mt_next_hop_out_labels[i]));
15970 api_mpls_tunnel_dump (vat_main_t * vam)
15972 vl_api_mpls_tunnel_dump_t *mp;
15973 vl_api_control_ping_t *mp_ping;
15977 /* Parse args required to build the message */
15978 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15980 if (!unformat (vam->input, "tunnel_index %d", &index))
15987 print (vam->ofp, " tunnel_index %d", index);
15989 M (MPLS_TUNNEL_DUMP, mp);
15990 mp->tunnel_index = htonl (index);
15993 /* Use a control ping for synchronization */
15994 M (CONTROL_PING, mp_ping);
16001 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
16002 #define vl_api_mpls_fib_details_t_print vl_noop_handler
16005 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
16007 vat_main_t *vam = &vat_main;
16008 int count = ntohl (mp->count);
16009 vl_api_fib_path2_t *fp;
16013 "table-id %d, label %u, ess_bit %u",
16014 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
16016 for (i = 0; i < count; i++)
16018 if (fp->afi == IP46_TYPE_IP6)
16020 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16021 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16022 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16023 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16024 format_ip6_address, fp->next_hop);
16025 else if (fp->afi == IP46_TYPE_IP4)
16027 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16028 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16029 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16030 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16031 format_ip4_address, fp->next_hop);
16036 static void vl_api_mpls_fib_details_t_handler_json
16037 (vl_api_mpls_fib_details_t * mp)
16039 vat_main_t *vam = &vat_main;
16040 int count = ntohl (mp->count);
16041 vat_json_node_t *node = NULL;
16042 struct in_addr ip4;
16043 struct in6_addr ip6;
16044 vl_api_fib_path2_t *fp;
16047 if (VAT_JSON_ARRAY != vam->json_tree.type)
16049 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16050 vat_json_init_array (&vam->json_tree);
16052 node = vat_json_array_add (&vam->json_tree);
16054 vat_json_init_object (node);
16055 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16056 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
16057 vat_json_object_add_uint (node, "label", ntohl (mp->label));
16058 vat_json_object_add_uint (node, "path_count", count);
16060 for (i = 0; i < count; i++)
16062 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16063 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16064 vat_json_object_add_uint (node, "is_local", fp->is_local);
16065 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16066 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16067 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16068 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16069 if (fp->afi == IP46_TYPE_IP4)
16071 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16072 vat_json_object_add_ip4 (node, "next_hop", ip4);
16074 else if (fp->afi == IP46_TYPE_IP6)
16076 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16077 vat_json_object_add_ip6 (node, "next_hop", ip6);
16083 api_mpls_fib_dump (vat_main_t * vam)
16085 vl_api_mpls_fib_dump_t *mp;
16086 vl_api_control_ping_t *mp_ping;
16089 M (MPLS_FIB_DUMP, mp);
16092 /* Use a control ping for synchronization */
16093 M (CONTROL_PING, mp_ping);
16100 #define vl_api_ip_fib_details_t_endian vl_noop_handler
16101 #define vl_api_ip_fib_details_t_print vl_noop_handler
16104 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
16106 vat_main_t *vam = &vat_main;
16107 int count = ntohl (mp->count);
16108 vl_api_fib_path_t *fp;
16112 "table-id %d, prefix %U/%d",
16113 ntohl (mp->table_id), format_ip4_address, mp->address,
16114 mp->address_length);
16116 for (i = 0; i < count; i++)
16118 if (fp->afi == IP46_TYPE_IP6)
16120 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16121 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16122 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16123 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16124 format_ip6_address, fp->next_hop);
16125 else if (fp->afi == IP46_TYPE_IP4)
16127 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16128 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16129 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16130 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16131 format_ip4_address, fp->next_hop);
16136 static void vl_api_ip_fib_details_t_handler_json
16137 (vl_api_ip_fib_details_t * mp)
16139 vat_main_t *vam = &vat_main;
16140 int count = ntohl (mp->count);
16141 vat_json_node_t *node = NULL;
16142 struct in_addr ip4;
16143 struct in6_addr ip6;
16144 vl_api_fib_path_t *fp;
16147 if (VAT_JSON_ARRAY != vam->json_tree.type)
16149 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16150 vat_json_init_array (&vam->json_tree);
16152 node = vat_json_array_add (&vam->json_tree);
16154 vat_json_init_object (node);
16155 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16156 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
16157 vat_json_object_add_ip4 (node, "prefix", ip4);
16158 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16159 vat_json_object_add_uint (node, "path_count", count);
16161 for (i = 0; i < count; i++)
16163 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16164 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16165 vat_json_object_add_uint (node, "is_local", fp->is_local);
16166 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16167 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16168 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16169 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16170 if (fp->afi == IP46_TYPE_IP4)
16172 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16173 vat_json_object_add_ip4 (node, "next_hop", ip4);
16175 else if (fp->afi == IP46_TYPE_IP6)
16177 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16178 vat_json_object_add_ip6 (node, "next_hop", ip6);
16184 api_ip_fib_dump (vat_main_t * vam)
16186 vl_api_ip_fib_dump_t *mp;
16187 vl_api_control_ping_t *mp_ping;
16190 M (IP_FIB_DUMP, mp);
16193 /* Use a control ping for synchronization */
16194 M (CONTROL_PING, mp_ping);
16202 api_ip_mfib_dump (vat_main_t * vam)
16204 vl_api_ip_mfib_dump_t *mp;
16205 vl_api_control_ping_t *mp_ping;
16208 M (IP_MFIB_DUMP, mp);
16211 /* Use a control ping for synchronization */
16212 M (CONTROL_PING, mp_ping);
16219 static void vl_api_ip_neighbor_details_t_handler
16220 (vl_api_ip_neighbor_details_t * mp)
16222 vat_main_t *vam = &vat_main;
16224 print (vam->ofp, "%c %U %U",
16225 (mp->is_static) ? 'S' : 'D',
16226 format_ethernet_address, &mp->mac_address,
16227 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
16231 static void vl_api_ip_neighbor_details_t_handler_json
16232 (vl_api_ip_neighbor_details_t * mp)
16235 vat_main_t *vam = &vat_main;
16236 vat_json_node_t *node;
16237 struct in_addr ip4;
16238 struct in6_addr ip6;
16240 if (VAT_JSON_ARRAY != vam->json_tree.type)
16242 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16243 vat_json_init_array (&vam->json_tree);
16245 node = vat_json_array_add (&vam->json_tree);
16247 vat_json_init_object (node);
16248 vat_json_object_add_string_copy (node, "flag",
16249 (mp->is_static) ? (u8 *) "static" : (u8 *)
16252 vat_json_object_add_string_copy (node, "link_layer",
16253 format (0, "%U", format_ethernet_address,
16254 &mp->mac_address));
16258 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
16259 vat_json_object_add_ip6 (node, "ip_address", ip6);
16263 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
16264 vat_json_object_add_ip4 (node, "ip_address", ip4);
16269 api_ip_neighbor_dump (vat_main_t * vam)
16271 unformat_input_t *i = vam->input;
16272 vl_api_ip_neighbor_dump_t *mp;
16273 vl_api_control_ping_t *mp_ping;
16275 u32 sw_if_index = ~0;
16278 /* Parse args required to build the message */
16279 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16281 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16283 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16285 else if (unformat (i, "ip6"))
16291 if (sw_if_index == ~0)
16293 errmsg ("missing interface name or sw_if_index");
16297 M (IP_NEIGHBOR_DUMP, mp);
16298 mp->is_ipv6 = (u8) is_ipv6;
16299 mp->sw_if_index = ntohl (sw_if_index);
16302 /* Use a control ping for synchronization */
16303 M (CONTROL_PING, mp_ping);
16310 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
16311 #define vl_api_ip6_fib_details_t_print vl_noop_handler
16314 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
16316 vat_main_t *vam = &vat_main;
16317 int count = ntohl (mp->count);
16318 vl_api_fib_path_t *fp;
16322 "table-id %d, prefix %U/%d",
16323 ntohl (mp->table_id), format_ip6_address, mp->address,
16324 mp->address_length);
16326 for (i = 0; i < count; i++)
16328 if (fp->afi == IP46_TYPE_IP6)
16330 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16331 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16332 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16333 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16334 format_ip6_address, fp->next_hop);
16335 else if (fp->afi == IP46_TYPE_IP4)
16337 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16338 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16339 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16340 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16341 format_ip4_address, fp->next_hop);
16346 static void vl_api_ip6_fib_details_t_handler_json
16347 (vl_api_ip6_fib_details_t * mp)
16349 vat_main_t *vam = &vat_main;
16350 int count = ntohl (mp->count);
16351 vat_json_node_t *node = NULL;
16352 struct in_addr ip4;
16353 struct in6_addr ip6;
16354 vl_api_fib_path_t *fp;
16357 if (VAT_JSON_ARRAY != vam->json_tree.type)
16359 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16360 vat_json_init_array (&vam->json_tree);
16362 node = vat_json_array_add (&vam->json_tree);
16364 vat_json_init_object (node);
16365 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16366 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
16367 vat_json_object_add_ip6 (node, "prefix", ip6);
16368 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16369 vat_json_object_add_uint (node, "path_count", count);
16371 for (i = 0; i < count; i++)
16373 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16374 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16375 vat_json_object_add_uint (node, "is_local", fp->is_local);
16376 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16377 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16378 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16379 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16380 if (fp->afi == IP46_TYPE_IP4)
16382 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16383 vat_json_object_add_ip4 (node, "next_hop", ip4);
16385 else if (fp->afi == IP46_TYPE_IP6)
16387 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16388 vat_json_object_add_ip6 (node, "next_hop", ip6);
16394 api_ip6_fib_dump (vat_main_t * vam)
16396 vl_api_ip6_fib_dump_t *mp;
16397 vl_api_control_ping_t *mp_ping;
16400 M (IP6_FIB_DUMP, mp);
16403 /* Use a control ping for synchronization */
16404 M (CONTROL_PING, mp_ping);
16412 api_ip6_mfib_dump (vat_main_t * vam)
16414 vl_api_ip6_mfib_dump_t *mp;
16415 vl_api_control_ping_t *mp_ping;
16418 M (IP6_MFIB_DUMP, mp);
16421 /* Use a control ping for synchronization */
16422 M (CONTROL_PING, mp_ping);
16430 api_classify_table_ids (vat_main_t * vam)
16432 vl_api_classify_table_ids_t *mp;
16435 /* Construct the API message */
16436 M (CLASSIFY_TABLE_IDS, mp);
16445 api_classify_table_by_interface (vat_main_t * vam)
16447 unformat_input_t *input = vam->input;
16448 vl_api_classify_table_by_interface_t *mp;
16450 u32 sw_if_index = ~0;
16452 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16454 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16456 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16461 if (sw_if_index == ~0)
16463 errmsg ("missing interface name or sw_if_index");
16467 /* Construct the API message */
16468 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
16470 mp->sw_if_index = ntohl (sw_if_index);
16478 api_classify_table_info (vat_main_t * vam)
16480 unformat_input_t *input = vam->input;
16481 vl_api_classify_table_info_t *mp;
16485 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16487 if (unformat (input, "table_id %d", &table_id))
16492 if (table_id == ~0)
16494 errmsg ("missing table id");
16498 /* Construct the API message */
16499 M (CLASSIFY_TABLE_INFO, mp);
16501 mp->table_id = ntohl (table_id);
16509 api_classify_session_dump (vat_main_t * vam)
16511 unformat_input_t *input = vam->input;
16512 vl_api_classify_session_dump_t *mp;
16513 vl_api_control_ping_t *mp_ping;
16517 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16519 if (unformat (input, "table_id %d", &table_id))
16524 if (table_id == ~0)
16526 errmsg ("missing table id");
16530 /* Construct the API message */
16531 M (CLASSIFY_SESSION_DUMP, mp);
16533 mp->table_id = ntohl (table_id);
16536 /* Use a control ping for synchronization */
16537 M (CONTROL_PING, mp_ping);
16545 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
16547 vat_main_t *vam = &vat_main;
16549 print (vam->ofp, "collector_address %U, collector_port %d, "
16550 "src_address %U, vrf_id %d, path_mtu %u, "
16551 "template_interval %u, udp_checksum %d",
16552 format_ip4_address, mp->collector_address,
16553 ntohs (mp->collector_port),
16554 format_ip4_address, mp->src_address,
16555 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
16556 ntohl (mp->template_interval), mp->udp_checksum);
16559 vam->result_ready = 1;
16563 vl_api_ipfix_exporter_details_t_handler_json
16564 (vl_api_ipfix_exporter_details_t * mp)
16566 vat_main_t *vam = &vat_main;
16567 vat_json_node_t node;
16568 struct in_addr collector_address;
16569 struct in_addr src_address;
16571 vat_json_init_object (&node);
16572 clib_memcpy (&collector_address, &mp->collector_address,
16573 sizeof (collector_address));
16574 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
16575 vat_json_object_add_uint (&node, "collector_port",
16576 ntohs (mp->collector_port));
16577 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
16578 vat_json_object_add_ip4 (&node, "src_address", src_address);
16579 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
16580 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
16581 vat_json_object_add_uint (&node, "template_interval",
16582 ntohl (mp->template_interval));
16583 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
16585 vat_json_print (vam->ofp, &node);
16586 vat_json_free (&node);
16588 vam->result_ready = 1;
16592 api_ipfix_exporter_dump (vat_main_t * vam)
16594 vl_api_ipfix_exporter_dump_t *mp;
16597 /* Construct the API message */
16598 M (IPFIX_EXPORTER_DUMP, mp);
16607 api_ipfix_classify_stream_dump (vat_main_t * vam)
16609 vl_api_ipfix_classify_stream_dump_t *mp;
16612 /* Construct the API message */
16613 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
16624 vl_api_ipfix_classify_stream_details_t_handler
16625 (vl_api_ipfix_classify_stream_details_t * mp)
16627 vat_main_t *vam = &vat_main;
16628 print (vam->ofp, "domain_id %d, src_port %d",
16629 ntohl (mp->domain_id), ntohs (mp->src_port));
16631 vam->result_ready = 1;
16635 vl_api_ipfix_classify_stream_details_t_handler_json
16636 (vl_api_ipfix_classify_stream_details_t * mp)
16638 vat_main_t *vam = &vat_main;
16639 vat_json_node_t node;
16641 vat_json_init_object (&node);
16642 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
16643 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
16645 vat_json_print (vam->ofp, &node);
16646 vat_json_free (&node);
16648 vam->result_ready = 1;
16652 api_ipfix_classify_table_dump (vat_main_t * vam)
16654 vl_api_ipfix_classify_table_dump_t *mp;
16655 vl_api_control_ping_t *mp_ping;
16658 if (!vam->json_output)
16660 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
16661 "transport_protocol");
16664 /* Construct the API message */
16665 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
16670 /* Use a control ping for synchronization */
16671 M (CONTROL_PING, mp_ping);
16679 vl_api_ipfix_classify_table_details_t_handler
16680 (vl_api_ipfix_classify_table_details_t * mp)
16682 vat_main_t *vam = &vat_main;
16683 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
16684 mp->transport_protocol);
16688 vl_api_ipfix_classify_table_details_t_handler_json
16689 (vl_api_ipfix_classify_table_details_t * mp)
16691 vat_json_node_t *node = NULL;
16692 vat_main_t *vam = &vat_main;
16694 if (VAT_JSON_ARRAY != vam->json_tree.type)
16696 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16697 vat_json_init_array (&vam->json_tree);
16700 node = vat_json_array_add (&vam->json_tree);
16701 vat_json_init_object (node);
16703 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
16704 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
16705 vat_json_object_add_uint (node, "transport_protocol",
16706 mp->transport_protocol);
16710 api_sw_interface_span_enable_disable (vat_main_t * vam)
16712 unformat_input_t *i = vam->input;
16713 vl_api_sw_interface_span_enable_disable_t *mp;
16714 u32 src_sw_if_index = ~0;
16715 u32 dst_sw_if_index = ~0;
16719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16722 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
16724 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
16728 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
16730 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16732 else if (unformat (i, "disable"))
16734 else if (unformat (i, "rx"))
16736 else if (unformat (i, "tx"))
16738 else if (unformat (i, "both"))
16744 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
16746 mp->sw_if_index_from = htonl (src_sw_if_index);
16747 mp->sw_if_index_to = htonl (dst_sw_if_index);
16756 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16759 vat_main_t *vam = &vat_main;
16760 u8 *sw_if_from_name = 0;
16761 u8 *sw_if_to_name = 0;
16762 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16763 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16764 char *states[] = { "none", "rx", "tx", "both" };
16768 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16770 if ((u32) p->value[0] == sw_if_index_from)
16772 sw_if_from_name = (u8 *)(p->key);
16776 if ((u32) p->value[0] == sw_if_index_to)
16778 sw_if_to_name = (u8 *)(p->key);
16779 if (sw_if_from_name)
16784 print (vam->ofp, "%20s => %20s (%s)",
16785 sw_if_from_name, sw_if_to_name, states[mp->state]);
16789 vl_api_sw_interface_span_details_t_handler_json
16790 (vl_api_sw_interface_span_details_t * mp)
16792 vat_main_t *vam = &vat_main;
16793 vat_json_node_t *node = NULL;
16794 u8 *sw_if_from_name = 0;
16795 u8 *sw_if_to_name = 0;
16796 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16797 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16801 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16803 if ((u32) p->value[0] == sw_if_index_from)
16805 sw_if_from_name = (u8 *)(p->key);
16809 if ((u32) p->value[0] == sw_if_index_to)
16811 sw_if_to_name = (u8 *)(p->key);
16812 if (sw_if_from_name)
16818 if (VAT_JSON_ARRAY != vam->json_tree.type)
16820 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16821 vat_json_init_array (&vam->json_tree);
16823 node = vat_json_array_add (&vam->json_tree);
16825 vat_json_init_object (node);
16826 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16827 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16828 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16829 if (0 != sw_if_to_name)
16831 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16833 vat_json_object_add_uint (node, "state", mp->state);
16837 api_sw_interface_span_dump (vat_main_t * vam)
16839 vl_api_sw_interface_span_dump_t *mp;
16840 vl_api_control_ping_t *mp_ping;
16843 M (SW_INTERFACE_SPAN_DUMP, mp);
16846 /* Use a control ping for synchronization */
16847 M (CONTROL_PING, mp_ping);
16855 api_pg_create_interface (vat_main_t * vam)
16857 unformat_input_t *input = vam->input;
16858 vl_api_pg_create_interface_t *mp;
16862 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16864 if (unformat (input, "if_id %d", &if_id))
16871 errmsg ("missing pg interface index");
16875 /* Construct the API message */
16876 M (PG_CREATE_INTERFACE, mp);
16878 mp->interface_id = ntohl (if_id);
16886 api_pg_capture (vat_main_t * vam)
16888 unformat_input_t *input = vam->input;
16889 vl_api_pg_capture_t *mp;
16894 u8 pcap_file_set = 0;
16897 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16899 if (unformat (input, "if_id %d", &if_id))
16901 else if (unformat (input, "pcap %s", &pcap_file))
16903 else if (unformat (input, "count %d", &count))
16905 else if (unformat (input, "disable"))
16912 errmsg ("missing pg interface index");
16915 if (pcap_file_set > 0)
16917 if (vec_len (pcap_file) > 255)
16919 errmsg ("pcap file name is too long");
16924 u32 name_len = vec_len (pcap_file);
16925 /* Construct the API message */
16926 M (PG_CAPTURE, mp);
16928 mp->interface_id = ntohl (if_id);
16929 mp->is_enabled = enable;
16930 mp->count = ntohl (count);
16931 mp->pcap_name_length = ntohl (name_len);
16932 if (pcap_file_set != 0)
16934 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16936 vec_free (pcap_file);
16944 api_pg_enable_disable (vat_main_t * vam)
16946 unformat_input_t *input = vam->input;
16947 vl_api_pg_enable_disable_t *mp;
16950 u8 stream_name_set = 0;
16951 u8 *stream_name = 0;
16953 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16955 if (unformat (input, "stream %s", &stream_name))
16956 stream_name_set = 1;
16957 else if (unformat (input, "disable"))
16963 if (stream_name_set > 0)
16965 if (vec_len (stream_name) > 255)
16967 errmsg ("stream name too long");
16972 u32 name_len = vec_len (stream_name);
16973 /* Construct the API message */
16974 M (PG_ENABLE_DISABLE, mp);
16976 mp->is_enabled = enable;
16977 if (stream_name_set != 0)
16979 mp->stream_name_length = ntohl (name_len);
16980 clib_memcpy (mp->stream_name, stream_name, name_len);
16982 vec_free (stream_name);
16990 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16992 unformat_input_t *input = vam->input;
16993 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16995 u16 *low_ports = 0;
16996 u16 *high_ports = 0;
16999 ip4_address_t ip4_addr;
17000 ip6_address_t ip6_addr;
17009 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17011 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
17017 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
17022 else if (unformat (input, "vrf %d", &vrf_id))
17024 else if (unformat (input, "del"))
17026 else if (unformat (input, "port %d", &tmp))
17028 if (tmp == 0 || tmp > 65535)
17030 errmsg ("port %d out of range", tmp);
17034 this_hi = this_low + 1;
17035 vec_add1 (low_ports, this_low);
17036 vec_add1 (high_ports, this_hi);
17038 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
17040 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
17042 errmsg ("incorrect range parameters");
17046 /* Note: in debug CLI +1 is added to high before
17047 passing to real fn that does "the work"
17048 (ip_source_and_port_range_check_add_del).
17049 This fn is a wrapper around the binary API fn a
17050 control plane will call, which expects this increment
17051 to have occurred. Hence letting the binary API control
17052 plane fn do the increment for consistency between VAT
17053 and other control planes.
17056 vec_add1 (low_ports, this_low);
17057 vec_add1 (high_ports, this_hi);
17063 if (prefix_set == 0)
17065 errmsg ("<address>/<mask> not specified");
17071 errmsg ("VRF ID required, not specified");
17078 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17082 if (vec_len (low_ports) == 0)
17084 errmsg ("At least one port or port range required");
17088 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
17090 mp->is_add = is_add;
17095 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
17100 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
17103 mp->mask_length = length;
17104 mp->number_of_ranges = vec_len (low_ports);
17106 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
17107 vec_free (low_ports);
17109 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
17110 vec_free (high_ports);
17112 mp->vrf_id = ntohl (vrf_id);
17120 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
17122 unformat_input_t *input = vam->input;
17123 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
17124 u32 sw_if_index = ~0;
17126 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
17127 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
17131 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17133 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17135 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17137 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
17139 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
17141 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
17143 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
17145 else if (unformat (input, "del"))
17151 if (sw_if_index == ~0)
17153 errmsg ("Interface required but not specified");
17159 errmsg ("VRF ID required but not specified");
17163 if (tcp_out_vrf_id == 0
17164 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
17167 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17171 /* Construct the API message */
17172 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
17174 mp->sw_if_index = ntohl (sw_if_index);
17175 mp->is_add = is_add;
17176 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
17177 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
17178 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
17179 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
17184 /* Wait for a reply... */
17190 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
17192 unformat_input_t *i = vam->input;
17193 vl_api_ipsec_gre_add_del_tunnel_t *mp;
17194 u32 local_sa_id = 0;
17195 u32 remote_sa_id = 0;
17196 ip4_address_t src_address;
17197 ip4_address_t dst_address;
17201 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17203 if (unformat (i, "local_sa %d", &local_sa_id))
17205 else if (unformat (i, "remote_sa %d", &remote_sa_id))
17207 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
17209 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
17211 else if (unformat (i, "del"))
17215 clib_warning ("parse error '%U'", format_unformat_error, i);
17220 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
17222 mp->local_sa_id = ntohl (local_sa_id);
17223 mp->remote_sa_id = ntohl (remote_sa_id);
17224 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
17225 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
17226 mp->is_add = is_add;
17234 api_punt (vat_main_t * vam)
17236 unformat_input_t *i = vam->input;
17244 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17246 if (unformat (i, "ip %d", &ipv))
17248 else if (unformat (i, "protocol %d", &protocol))
17250 else if (unformat (i, "port %d", &port))
17252 else if (unformat (i, "del"))
17256 clib_warning ("parse error '%U'", format_unformat_error, i);
17263 mp->is_add = (u8) is_add;
17264 mp->ipv = (u8) ipv;
17265 mp->l4_protocol = (u8) protocol;
17266 mp->l4_port = htons ((u16) port);
17273 static void vl_api_ipsec_gre_tunnel_details_t_handler
17274 (vl_api_ipsec_gre_tunnel_details_t * mp)
17276 vat_main_t *vam = &vat_main;
17278 print (vam->ofp, "%11d%15U%15U%14d%14d",
17279 ntohl (mp->sw_if_index),
17280 format_ip4_address, &mp->src_address,
17281 format_ip4_address, &mp->dst_address,
17282 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
17285 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
17286 (vl_api_ipsec_gre_tunnel_details_t * mp)
17288 vat_main_t *vam = &vat_main;
17289 vat_json_node_t *node = NULL;
17290 struct in_addr ip4;
17292 if (VAT_JSON_ARRAY != vam->json_tree.type)
17294 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17295 vat_json_init_array (&vam->json_tree);
17297 node = vat_json_array_add (&vam->json_tree);
17299 vat_json_init_object (node);
17300 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17301 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
17302 vat_json_object_add_ip4 (node, "src_address", ip4);
17303 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
17304 vat_json_object_add_ip4 (node, "dst_address", ip4);
17305 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
17306 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
17310 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
17312 unformat_input_t *i = vam->input;
17313 vl_api_ipsec_gre_tunnel_dump_t *mp;
17314 vl_api_control_ping_t *mp_ping;
17316 u8 sw_if_index_set = 0;
17319 /* Parse args required to build the message */
17320 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17322 if (unformat (i, "sw_if_index %d", &sw_if_index))
17323 sw_if_index_set = 1;
17328 if (sw_if_index_set == 0)
17333 if (!vam->json_output)
17335 print (vam->ofp, "%11s%15s%15s%14s%14s",
17336 "sw_if_index", "src_address", "dst_address",
17337 "local_sa_id", "remote_sa_id");
17340 /* Get list of gre-tunnel interfaces */
17341 M (IPSEC_GRE_TUNNEL_DUMP, mp);
17343 mp->sw_if_index = htonl (sw_if_index);
17347 /* Use a control ping for synchronization */
17348 M (CONTROL_PING, mp_ping);
17356 api_delete_subif (vat_main_t * vam)
17358 unformat_input_t *i = vam->input;
17359 vl_api_delete_subif_t *mp;
17360 u32 sw_if_index = ~0;
17363 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17365 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17367 if (unformat (i, "sw_if_index %d", &sw_if_index))
17373 if (sw_if_index == ~0)
17375 errmsg ("missing sw_if_index");
17379 /* Construct the API message */
17380 M (DELETE_SUBIF, mp);
17381 mp->sw_if_index = ntohl (sw_if_index);
17388 #define foreach_pbb_vtr_op \
17389 _("disable", L2_VTR_DISABLED) \
17390 _("pop", L2_VTR_POP_2) \
17391 _("push", L2_VTR_PUSH_2)
17394 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
17396 unformat_input_t *i = vam->input;
17397 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
17398 u32 sw_if_index = ~0, vtr_op = ~0;
17399 u16 outer_tag = ~0;
17400 u8 dmac[6], smac[6];
17401 u8 dmac_set = 0, smac_set = 0;
17407 /* Shut up coverity */
17408 memset (dmac, 0, sizeof (dmac));
17409 memset (smac, 0, sizeof (smac));
17411 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17413 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17415 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17417 else if (unformat (i, "vtr_op %d", &vtr_op))
17419 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
17422 else if (unformat (i, "translate_pbb_stag"))
17424 if (unformat (i, "%d", &tmp))
17426 vtr_op = L2_VTR_TRANSLATE_2_1;
17432 ("translate_pbb_stag operation requires outer tag definition");
17436 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
17438 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
17440 else if (unformat (i, "sid %d", &sid))
17442 else if (unformat (i, "vlanid %d", &tmp))
17446 clib_warning ("parse error '%U'", format_unformat_error, i);
17451 if ((sw_if_index == ~0) || (vtr_op == ~0))
17453 errmsg ("missing sw_if_index or vtr operation");
17456 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
17457 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
17460 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
17464 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
17465 mp->sw_if_index = ntohl (sw_if_index);
17466 mp->vtr_op = ntohl (vtr_op);
17467 mp->outer_tag = ntohs (outer_tag);
17468 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
17469 clib_memcpy (mp->b_smac, smac, sizeof (smac));
17470 mp->b_vlanid = ntohs (vlanid);
17471 mp->i_sid = ntohl (sid);
17479 api_flow_classify_set_interface (vat_main_t * vam)
17481 unformat_input_t *i = vam->input;
17482 vl_api_flow_classify_set_interface_t *mp;
17484 int sw_if_index_set;
17485 u32 ip4_table_index = ~0;
17486 u32 ip6_table_index = ~0;
17490 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17492 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17493 sw_if_index_set = 1;
17494 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17495 sw_if_index_set = 1;
17496 else if (unformat (i, "del"))
17498 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17500 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17504 clib_warning ("parse error '%U'", format_unformat_error, i);
17509 if (sw_if_index_set == 0)
17511 errmsg ("missing interface name or sw_if_index");
17515 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
17517 mp->sw_if_index = ntohl (sw_if_index);
17518 mp->ip4_table_index = ntohl (ip4_table_index);
17519 mp->ip6_table_index = ntohl (ip6_table_index);
17520 mp->is_add = is_add;
17528 api_flow_classify_dump (vat_main_t * vam)
17530 unformat_input_t *i = vam->input;
17531 vl_api_flow_classify_dump_t *mp;
17532 vl_api_control_ping_t *mp_ping;
17533 u8 type = FLOW_CLASSIFY_N_TABLES;
17536 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
17540 errmsg ("classify table type must be specified");
17544 if (!vam->json_output)
17546 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17549 M (FLOW_CLASSIFY_DUMP, mp);
17554 /* Use a control ping for synchronization */
17555 M (CONTROL_PING, mp_ping);
17558 /* Wait for a reply... */
17564 api_feature_enable_disable (vat_main_t * vam)
17566 unformat_input_t *i = vam->input;
17567 vl_api_feature_enable_disable_t *mp;
17569 u8 *feature_name = 0;
17570 u32 sw_if_index = ~0;
17574 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17576 if (unformat (i, "arc_name %s", &arc_name))
17578 else if (unformat (i, "feature_name %s", &feature_name))
17581 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17583 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17585 else if (unformat (i, "disable"))
17593 errmsg ("missing arc name");
17596 if (vec_len (arc_name) > 63)
17598 errmsg ("arc name too long");
17601 if (feature_name == 0)
17603 errmsg ("missing feature name");
17606 if (vec_len (feature_name) > 63)
17608 errmsg ("feature name too long");
17611 if (sw_if_index == ~0)
17613 errmsg ("missing interface name or sw_if_index");
17617 /* Construct the API message */
17618 M (FEATURE_ENABLE_DISABLE, mp);
17619 mp->sw_if_index = ntohl (sw_if_index);
17620 mp->enable = enable;
17621 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
17622 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
17623 vec_free (arc_name);
17624 vec_free (feature_name);
17632 api_sw_interface_tag_add_del (vat_main_t * vam)
17634 unformat_input_t *i = vam->input;
17635 vl_api_sw_interface_tag_add_del_t *mp;
17636 u32 sw_if_index = ~0;
17641 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17643 if (unformat (i, "tag %s", &tag))
17645 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17647 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17649 else if (unformat (i, "del"))
17655 if (sw_if_index == ~0)
17657 errmsg ("missing interface name or sw_if_index");
17661 if (enable && (tag == 0))
17663 errmsg ("no tag specified");
17667 /* Construct the API message */
17668 M (SW_INTERFACE_TAG_ADD_DEL, mp);
17669 mp->sw_if_index = ntohl (sw_if_index);
17670 mp->is_add = enable;
17672 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
17680 static void vl_api_l2_xconnect_details_t_handler
17681 (vl_api_l2_xconnect_details_t * mp)
17683 vat_main_t *vam = &vat_main;
17685 print (vam->ofp, "%15d%15d",
17686 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
17689 static void vl_api_l2_xconnect_details_t_handler_json
17690 (vl_api_l2_xconnect_details_t * mp)
17692 vat_main_t *vam = &vat_main;
17693 vat_json_node_t *node = NULL;
17695 if (VAT_JSON_ARRAY != vam->json_tree.type)
17697 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17698 vat_json_init_array (&vam->json_tree);
17700 node = vat_json_array_add (&vam->json_tree);
17702 vat_json_init_object (node);
17703 vat_json_object_add_uint (node, "rx_sw_if_index",
17704 ntohl (mp->rx_sw_if_index));
17705 vat_json_object_add_uint (node, "tx_sw_if_index",
17706 ntohl (mp->tx_sw_if_index));
17710 api_l2_xconnect_dump (vat_main_t * vam)
17712 vl_api_l2_xconnect_dump_t *mp;
17713 vl_api_control_ping_t *mp_ping;
17716 if (!vam->json_output)
17718 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
17721 M (L2_XCONNECT_DUMP, mp);
17725 /* Use a control ping for synchronization */
17726 M (CONTROL_PING, mp_ping);
17734 api_sw_interface_set_mtu (vat_main_t * vam)
17736 unformat_input_t *i = vam->input;
17737 vl_api_sw_interface_set_mtu_t *mp;
17738 u32 sw_if_index = ~0;
17742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17744 if (unformat (i, "mtu %d", &mtu))
17746 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17748 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17754 if (sw_if_index == ~0)
17756 errmsg ("missing interface name or sw_if_index");
17762 errmsg ("no mtu specified");
17766 /* Construct the API message */
17767 M (SW_INTERFACE_SET_MTU, mp);
17768 mp->sw_if_index = ntohl (sw_if_index);
17769 mp->mtu = ntohs ((u16) mtu);
17778 q_or_quit (vat_main_t * vam)
17780 #if VPP_API_TEST_BUILTIN == 0
17781 longjmp (vam->jump_buf, 1);
17783 return 0; /* not so much */
17787 q (vat_main_t * vam)
17789 return q_or_quit (vam);
17793 quit (vat_main_t * vam)
17795 return q_or_quit (vam);
17799 comment (vat_main_t * vam)
17805 cmd_cmp (void *a1, void *a2)
17810 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17814 help (vat_main_t * vam)
17819 unformat_input_t *i = vam->input;
17822 if (unformat (i, "%s", &name))
17826 vec_add1 (name, 0);
17828 hs = hash_get_mem (vam->help_by_name, name);
17830 print (vam->ofp, "usage: %s %s", name, hs[0]);
17832 print (vam->ofp, "No such msg / command '%s'", name);
17837 print (vam->ofp, "Help is available for the following:");
17840 hash_foreach_pair (p, vam->function_by_name,
17842 vec_add1 (cmds, (u8 *)(p->key));
17846 vec_sort_with_function (cmds, cmd_cmp);
17848 for (j = 0; j < vec_len (cmds); j++)
17849 print (vam->ofp, "%s", cmds[j]);
17856 set (vat_main_t * vam)
17858 u8 *name = 0, *value = 0;
17859 unformat_input_t *i = vam->input;
17861 if (unformat (i, "%s", &name))
17863 /* The input buffer is a vector, not a string. */
17864 value = vec_dup (i->buffer);
17865 vec_delete (value, i->index, 0);
17866 /* Almost certainly has a trailing newline */
17867 if (value[vec_len (value) - 1] == '\n')
17868 value[vec_len (value) - 1] = 0;
17869 /* Make sure it's a proper string, one way or the other */
17870 vec_add1 (value, 0);
17871 (void) clib_macro_set_value (&vam->macro_main,
17872 (char *) name, (char *) value);
17875 errmsg ("usage: set <name> <value>");
17883 unset (vat_main_t * vam)
17887 if (unformat (vam->input, "%s", &name))
17888 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17889 errmsg ("unset: %s wasn't set", name);
17902 macro_sort_cmp (void *a1, void *a2)
17904 macro_sort_t *s1 = a1;
17905 macro_sort_t *s2 = a2;
17907 return strcmp ((char *) (s1->name), (char *) (s2->name));
17911 dump_macro_table (vat_main_t * vam)
17913 macro_sort_t *sort_me = 0, *sm;
17918 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17920 vec_add2 (sort_me, sm, 1);
17921 sm->name = (u8 *)(p->key);
17922 sm->value = (u8 *) (p->value[0]);
17926 vec_sort_with_function (sort_me, macro_sort_cmp);
17928 if (vec_len (sort_me))
17929 print (vam->ofp, "%-15s%s", "Name", "Value");
17931 print (vam->ofp, "The macro table is empty...");
17933 for (i = 0; i < vec_len (sort_me); i++)
17934 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17939 dump_node_table (vat_main_t * vam)
17942 vlib_node_t *node, *next_node;
17944 if (vec_len (vam->graph_nodes) == 0)
17946 print (vam->ofp, "Node table empty, issue get_node_graph...");
17950 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17952 node = vam->graph_nodes[i];
17953 print (vam->ofp, "[%d] %s", i, node->name);
17954 for (j = 0; j < vec_len (node->next_nodes); j++)
17956 if (node->next_nodes[j] != ~0)
17958 next_node = vam->graph_nodes[node->next_nodes[j]];
17959 print (vam->ofp, " [%d] %s", j, next_node->name);
17967 value_sort_cmp (void *a1, void *a2)
17969 name_sort_t *n1 = a1;
17970 name_sort_t *n2 = a2;
17972 if (n1->value < n2->value)
17974 if (n1->value > n2->value)
17981 dump_msg_api_table (vat_main_t * vam)
17983 api_main_t *am = &api_main;
17984 name_sort_t *nses = 0, *ns;
17989 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17991 vec_add2 (nses, ns, 1);
17992 ns->name = (u8 *)(hp->key);
17993 ns->value = (u32) hp->value[0];
17997 vec_sort_with_function (nses, value_sort_cmp);
17999 for (i = 0; i < vec_len (nses); i++)
18000 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
18006 get_msg_id (vat_main_t * vam)
18011 if (unformat (vam->input, "%s", &name_and_crc))
18013 message_index = vl_api_get_msg_index (name_and_crc);
18014 if (message_index == ~0)
18016 print (vam->ofp, " '%s' not found", name_and_crc);
18019 print (vam->ofp, " '%s' has message index %d",
18020 name_and_crc, message_index);
18023 errmsg ("name_and_crc required...");
18028 search_node_table (vat_main_t * vam)
18030 unformat_input_t *line_input = vam->input;
18033 vlib_node_t *node, *next_node;
18036 if (vam->graph_node_index_by_name == 0)
18038 print (vam->ofp, "Node table empty, issue get_node_graph...");
18042 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
18044 if (unformat (line_input, "%s", &node_to_find))
18046 vec_add1 (node_to_find, 0);
18047 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
18050 print (vam->ofp, "%s not found...", node_to_find);
18053 node = vam->graph_nodes[p[0]];
18054 print (vam->ofp, "[%d] %s", p[0], node->name);
18055 for (j = 0; j < vec_len (node->next_nodes); j++)
18057 if (node->next_nodes[j] != ~0)
18059 next_node = vam->graph_nodes[node->next_nodes[j]];
18060 print (vam->ofp, " [%d] %s", j, next_node->name);
18067 clib_warning ("parse error '%U'", format_unformat_error,
18073 vec_free (node_to_find);
18082 script (vat_main_t * vam)
18084 #if (VPP_API_TEST_BUILTIN==0)
18086 char *save_current_file;
18087 unformat_input_t save_input;
18088 jmp_buf save_jump_buf;
18089 u32 save_line_number;
18091 FILE *new_fp, *save_ifp;
18093 if (unformat (vam->input, "%s", &s))
18095 new_fp = fopen ((char *) s, "r");
18098 errmsg ("Couldn't open script file %s", s);
18105 errmsg ("Missing script name");
18109 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
18110 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
18111 save_ifp = vam->ifp;
18112 save_line_number = vam->input_line_number;
18113 save_current_file = (char *) vam->current_file;
18115 vam->input_line_number = 0;
18117 vam->current_file = s;
18120 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
18121 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
18122 vam->ifp = save_ifp;
18123 vam->input_line_number = save_line_number;
18124 vam->current_file = (u8 *) save_current_file;
18129 clib_warning ("use the exec command...");
18135 echo (vat_main_t * vam)
18137 print (vam->ofp, "%v", vam->input->buffer);
18141 /* List of API message constructors, CLI names map to api_xxx */
18142 #define foreach_vpe_api_msg \
18143 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
18144 _(sw_interface_dump,"") \
18145 _(sw_interface_set_flags, \
18146 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
18147 _(sw_interface_add_del_address, \
18148 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
18149 _(sw_interface_set_table, \
18150 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
18151 _(sw_interface_set_mpls_enable, \
18152 "<intfc> | sw_if_index [disable | dis]") \
18153 _(sw_interface_set_vpath, \
18154 "<intfc> | sw_if_index <id> enable | disable") \
18155 _(sw_interface_set_vxlan_bypass, \
18156 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
18157 _(sw_interface_set_l2_xconnect, \
18158 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18159 "enable | disable") \
18160 _(sw_interface_set_l2_bridge, \
18161 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
18162 "[shg <split-horizon-group>] [bvi]\n" \
18163 "enable | disable") \
18164 _(bridge_domain_add_del, \
18165 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
18166 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
18168 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
18170 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
18172 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
18174 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
18176 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
18178 "<vpp-if-name> | sw_if_index <id>") \
18179 _(sw_interface_tap_dump, "") \
18180 _(ip_add_del_route, \
18181 "<addr>/<mask> via <addr> [table-id <n>]\n" \
18182 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18183 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18184 "[multipath] [count <n>]") \
18185 _(ip_mroute_add_del, \
18186 "<src> <grp>/<mask> [table-id <n>]\n" \
18187 "[<intfc> | sw_if_index <id>] [local] [del]") \
18188 _(mpls_route_add_del, \
18189 "<label> <eos> via <addr> [table-id <n>]\n" \
18190 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18191 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18192 "[multipath] [count <n>]") \
18193 _(mpls_ip_bind_unbind, \
18194 "<label> <addr/len>") \
18195 _(mpls_tunnel_add_del, \
18196 " via <addr> [table-id <n>]\n" \
18197 "sw_if_index <id>] [l2] [del]") \
18198 _(proxy_arp_add_del, \
18199 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
18200 _(proxy_arp_intfc_enable_disable, \
18201 "<intfc> | sw_if_index <id> enable | disable") \
18202 _(sw_interface_set_unnumbered, \
18203 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
18204 _(ip_neighbor_add_del, \
18205 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
18206 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
18207 _(reset_vrf, "vrf <id> [ipv6]") \
18208 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
18209 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
18210 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
18211 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
18212 "[outer_vlan_id_any][inner_vlan_id_any]") \
18213 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
18214 _(reset_fib, "vrf <n> [ipv6]") \
18215 _(dhcp_proxy_config, \
18216 "svr <v46-address> src <v46-address>\n" \
18217 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
18218 _(dhcp_proxy_set_vss, \
18219 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
18220 _(dhcp_proxy_dump, "ip6") \
18221 _(dhcp_client_config, \
18222 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
18223 _(set_ip_flow_hash, \
18224 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
18225 _(sw_interface_ip6_enable_disable, \
18226 "<intfc> | sw_if_index <id> enable | disable") \
18227 _(sw_interface_ip6_set_link_local_address, \
18228 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
18229 _(ip6nd_proxy_add_del, \
18230 "<intfc> | sw_if_index <id> <ip6-address>") \
18231 _(ip6nd_proxy_dump, "") \
18232 _(sw_interface_ip6nd_ra_prefix, \
18233 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
18234 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
18235 "[nolink] [isno]") \
18236 _(sw_interface_ip6nd_ra_config, \
18237 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
18238 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
18239 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
18240 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
18241 _(l2_patch_add_del, \
18242 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18243 "enable | disable") \
18244 _(sr_localsid_add_del, \
18245 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
18246 "fib-table <num> (end.psp) sw_if_index <num>") \
18247 _(classify_add_del_table, \
18248 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
18249 " [del] [del-chain] mask <mask-value>\n" \
18250 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
18251 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
18252 _(classify_add_del_session, \
18253 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
18254 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
18255 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
18256 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
18257 _(classify_set_interface_ip_table, \
18258 "<intfc> | sw_if_index <nn> table <nn>") \
18259 _(classify_set_interface_l2_tables, \
18260 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18261 " [other-table <nn>]") \
18262 _(get_node_index, "node <node-name") \
18263 _(add_node_next, "node <node-name> next <next-node-name>") \
18264 _(l2tpv3_create_tunnel, \
18265 "client_address <ip6-addr> our_address <ip6-addr>\n" \
18266 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
18267 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
18268 _(l2tpv3_set_tunnel_cookies, \
18269 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
18270 "[new_remote_cookie <nn>]\n") \
18271 _(l2tpv3_interface_enable_disable, \
18272 "<intfc> | sw_if_index <nn> enable | disable") \
18273 _(l2tpv3_set_lookup_key, \
18274 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
18275 _(sw_if_l2tpv3_tunnel_dump, "") \
18276 _(vxlan_add_del_tunnel, \
18277 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
18278 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
18279 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
18280 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18281 _(gre_add_del_tunnel, \
18282 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
18283 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18284 _(l2_fib_clear_table, "") \
18285 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
18286 _(l2_interface_vlan_tag_rewrite, \
18287 "<intfc> | sw_if_index <nn> \n" \
18288 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
18289 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
18290 _(create_vhost_user_if, \
18291 "socket <filename> [server] [renumber <dev_instance>] " \
18292 "[mac <mac_address>]") \
18293 _(modify_vhost_user_if, \
18294 "<intfc> | sw_if_index <nn> socket <filename>\n" \
18295 "[server] [renumber <dev_instance>]") \
18296 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
18297 _(sw_interface_vhost_user_dump, "") \
18298 _(show_version, "") \
18299 _(vxlan_gpe_add_del_tunnel, \
18300 "local <addr> remote <addr> vni <nn>\n" \
18301 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
18302 "[next-ethernet] [next-nsh]\n") \
18303 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18304 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
18305 _(interface_name_renumber, \
18306 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
18307 _(input_acl_set_interface, \
18308 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18309 " [l2-table <nn>] [del]") \
18310 _(want_ip4_arp_events, "address <ip4-address> [del]") \
18311 _(want_ip6_nd_events, "address <ip6-address> [del]") \
18312 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
18313 _(ip_dump, "ipv4 | ipv6") \
18314 _(ipsec_spd_add_del, "spd_id <n> [del]") \
18315 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
18317 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
18318 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
18319 " integ_alg <alg> integ_key <hex>") \
18320 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
18321 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
18322 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
18323 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
18324 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
18325 _(ikev2_profile_add_del, "name <profile_name> [del]") \
18326 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
18327 "(auth_data 0x<data> | auth_data <data>)") \
18328 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
18329 "(id_data 0x<data> | id_data <data>) (local|remote)") \
18330 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
18331 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
18332 "(local|remote)") \
18333 _(ikev2_set_local_key, "file <absolute_file_path>") \
18334 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
18335 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18336 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18337 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
18338 _(ikev2_initiate_sa_init, "<profile_name>") \
18339 _(ikev2_initiate_del_ike_sa, "<ispi>") \
18340 _(ikev2_initiate_del_child_sa, "<ispi>") \
18341 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
18342 _(delete_loopback,"sw_if_index <nn>") \
18343 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
18344 _(map_add_domain, \
18345 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
18346 "ip6-src <ip6addr> " \
18347 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
18348 _(map_del_domain, "index <n>") \
18349 _(map_add_del_rule, \
18350 "index <n> psid <n> dst <ip6addr> [del]") \
18351 _(map_domain_dump, "") \
18352 _(map_rule_dump, "index <map-domain>") \
18353 _(want_interface_events, "enable|disable") \
18354 _(want_stats,"enable|disable") \
18355 _(get_first_msg_id, "client <name>") \
18356 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
18357 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
18358 "fib-id <nn> [ip4][ip6][default]") \
18359 _(get_node_graph, " ") \
18360 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
18361 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
18362 _(ioam_disable, "") \
18363 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
18364 " sw_if_index <sw_if_index> p <priority> " \
18365 "w <weight>] [del]") \
18366 _(one_add_del_locator, "locator-set <locator_name> " \
18367 "iface <intf> | sw_if_index <sw_if_index> " \
18368 "p <priority> w <weight> [del]") \
18369 _(one_add_del_local_eid,"vni <vni> eid " \
18370 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18371 "locator-set <locator_name> [del]" \
18372 "[key-id sha1|sha256 secret-key <secret-key>]")\
18373 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
18374 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
18375 _(one_enable_disable, "enable|disable") \
18376 _(one_map_register_enable_disable, "enable|disable") \
18377 _(one_rloc_probe_enable_disable, "enable|disable") \
18378 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18380 "rloc <locator> p <prio> " \
18381 "w <weight> [rloc <loc> ... ] " \
18382 "action <action> [del-all]") \
18383 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18385 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18386 _(one_use_petr, "ip-address> | disable") \
18387 _(one_map_request_mode, "src-dst|dst-only") \
18388 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18389 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18390 _(one_locator_set_dump, "[local | remote]") \
18391 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
18392 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18393 "[local] | [remote]") \
18394 _(one_eid_table_vni_dump, "") \
18395 _(one_eid_table_map_dump, "l2|l3") \
18396 _(one_map_resolver_dump, "") \
18397 _(one_map_server_dump, "") \
18398 _(one_adjacencies_get, "vni <vni>") \
18399 _(show_one_rloc_probe_state, "") \
18400 _(show_one_map_register_state, "") \
18401 _(show_one_status, "") \
18402 _(one_get_map_request_itr_rlocs, "") \
18403 _(show_one_pitr, "") \
18404 _(show_one_use_petr, "") \
18405 _(show_one_map_request_mode, "") \
18406 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
18407 " sw_if_index <sw_if_index> p <priority> " \
18408 "w <weight>] [del]") \
18409 _(lisp_add_del_locator, "locator-set <locator_name> " \
18410 "iface <intf> | sw_if_index <sw_if_index> " \
18411 "p <priority> w <weight> [del]") \
18412 _(lisp_add_del_local_eid,"vni <vni> eid " \
18413 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18414 "locator-set <locator_name> [del]" \
18415 "[key-id sha1|sha256 secret-key <secret-key>]") \
18416 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
18417 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
18418 _(lisp_enable_disable, "enable|disable") \
18419 _(lisp_map_register_enable_disable, "enable|disable") \
18420 _(lisp_rloc_probe_enable_disable, "enable|disable") \
18421 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18423 "rloc <locator> p <prio> " \
18424 "w <weight> [rloc <loc> ... ] " \
18425 "action <action> [del-all]") \
18426 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18428 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18429 _(lisp_use_petr, "<ip-address> | disable") \
18430 _(lisp_map_request_mode, "src-dst|dst-only") \
18431 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18432 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18433 _(lisp_locator_set_dump, "[local | remote]") \
18434 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
18435 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18436 "[local] | [remote]") \
18437 _(lisp_eid_table_vni_dump, "") \
18438 _(lisp_eid_table_map_dump, "l2|l3") \
18439 _(lisp_map_resolver_dump, "") \
18440 _(lisp_map_server_dump, "") \
18441 _(lisp_adjacencies_get, "vni <vni>") \
18442 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
18443 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
18444 _(gpe_set_encap_mode, "lisp|vxlan") \
18445 _(gpe_get_encap_mode, "") \
18446 _(lisp_gpe_add_del_iface, "up|down") \
18447 _(lisp_gpe_enable_disable, "enable|disable") \
18448 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
18449 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
18450 _(show_lisp_rloc_probe_state, "") \
18451 _(show_lisp_map_register_state, "") \
18452 _(show_lisp_status, "") \
18453 _(lisp_get_map_request_itr_rlocs, "") \
18454 _(show_lisp_pitr, "") \
18455 _(show_lisp_use_petr, "") \
18456 _(show_lisp_map_request_mode, "") \
18457 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
18458 _(af_packet_delete, "name <host interface name>") \
18459 _(policer_add_del, "name <policer name> <params> [del]") \
18460 _(policer_dump, "[name <policer name>]") \
18461 _(policer_classify_set_interface, \
18462 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18463 " [l2-table <nn>] [del]") \
18464 _(policer_classify_dump, "type [ip4|ip6|l2]") \
18465 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
18466 "[master|slave]") \
18467 _(netmap_delete, "name <interface name>") \
18468 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
18469 _(mpls_fib_dump, "") \
18470 _(classify_table_ids, "") \
18471 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
18472 _(classify_table_info, "table_id <nn>") \
18473 _(classify_session_dump, "table_id <nn>") \
18474 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
18475 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
18476 "[template_interval <nn>] [udp_checksum]") \
18477 _(ipfix_exporter_dump, "") \
18478 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
18479 _(ipfix_classify_stream_dump, "") \
18480 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
18481 _(ipfix_classify_table_dump, "") \
18482 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
18483 _(sw_interface_span_dump, "") \
18484 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
18485 _(pg_create_interface, "if_id <nn>") \
18486 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
18487 _(pg_enable_disable, "[stream <id>] disable") \
18488 _(ip_source_and_port_range_check_add_del, \
18489 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
18490 _(ip_source_and_port_range_check_interface_add_del, \
18491 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
18492 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
18493 _(ipsec_gre_add_del_tunnel, \
18494 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
18495 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
18496 _(delete_subif,"<intfc> | sw_if_index <nn>") \
18497 _(l2_interface_pbb_tag_rewrite, \
18498 "<intfc> | sw_if_index <nn> \n" \
18499 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
18500 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
18501 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
18502 _(flow_classify_set_interface, \
18503 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
18504 _(flow_classify_dump, "type [ip4|ip6]") \
18505 _(ip_fib_dump, "") \
18506 _(ip_mfib_dump, "") \
18507 _(ip6_fib_dump, "") \
18508 _(ip6_mfib_dump, "") \
18509 _(feature_enable_disable, "arc_name <arc_name> " \
18510 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
18511 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
18513 _(l2_xconnect_dump, "") \
18514 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
18515 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
18516 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
18518 /* List of command functions, CLI names map directly to functions */
18519 #define foreach_cli_function \
18520 _(comment, "usage: comment <ignore-rest-of-line>") \
18521 _(dump_interface_table, "usage: dump_interface_table") \
18522 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
18523 _(dump_ipv4_table, "usage: dump_ipv4_table") \
18524 _(dump_ipv6_table, "usage: dump_ipv6_table") \
18525 _(dump_stats_table, "usage: dump_stats_table") \
18526 _(dump_macro_table, "usage: dump_macro_table ") \
18527 _(dump_node_table, "usage: dump_node_table") \
18528 _(dump_msg_api_table, "usage: dump_msg_api_table") \
18529 _(get_msg_id, "usage: get_msg_id name_and_crc") \
18530 _(echo, "usage: echo <message>") \
18531 _(exec, "usage: exec <vpe-debug-CLI-command>") \
18532 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
18533 _(help, "usage: help") \
18534 _(q, "usage: quit") \
18535 _(quit, "usage: quit") \
18536 _(search_node_table, "usage: search_node_table <name>...") \
18537 _(set, "usage: set <variable-name> <value>") \
18538 _(script, "usage: script <file-name>") \
18539 _(unset, "usage: unset <variable-name>")
18542 static void vl_api_##n##_t_handler_uni \
18543 (vl_api_##n##_t * mp) \
18545 vat_main_t * vam = &vat_main; \
18546 if (vam->json_output) { \
18547 vl_api_##n##_t_handler_json(mp); \
18549 vl_api_##n##_t_handler(mp); \
18552 foreach_vpe_api_reply_msg;
18553 #if VPP_API_TEST_BUILTIN == 0
18554 foreach_standalone_reply_msg;
18559 vat_api_hookup (vat_main_t * vam)
18562 vl_msg_api_set_handlers(VL_API_##N, #n, \
18563 vl_api_##n##_t_handler_uni, \
18565 vl_api_##n##_t_endian, \
18566 vl_api_##n##_t_print, \
18567 sizeof(vl_api_##n##_t), 1);
18568 foreach_vpe_api_reply_msg;
18569 #if VPP_API_TEST_BUILTIN == 0
18570 foreach_standalone_reply_msg;
18574 #if (VPP_API_TEST_BUILTIN==0)
18575 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
18577 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
18579 vam->function_by_name = hash_create_string (0, sizeof (uword));
18581 vam->help_by_name = hash_create_string (0, sizeof (uword));
18584 /* API messages we can send */
18585 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18586 foreach_vpe_api_msg;
18590 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18591 foreach_vpe_api_msg;
18594 /* CLI functions */
18595 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
18596 foreach_cli_function;
18600 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18601 foreach_cli_function;
18605 #if VPP_API_TEST_BUILTIN
18606 static clib_error_t *
18607 vat_api_hookup_shim (vlib_main_t * vm)
18609 vat_api_hookup (&vat_main);
18613 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
18617 * fd.io coding-style-patch-verification: ON
18620 * eval: (c-set-style "gnu")