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 */
406 #define VHOST_USER_POLLING_MODE 0
407 #define VHOST_USER_INTERRUPT_MODE 1
408 #define VHOST_USER_ADAPTIVE_MODE 2
411 api_format_vhost_user_operation_mode (u8 * s, va_list * va)
413 int operation_mode = va_arg (*va, int);
415 switch (operation_mode)
417 case VHOST_USER_POLLING_MODE:
418 s = format (s, "%-9s", "polling");
420 case VHOST_USER_INTERRUPT_MODE:
421 s = format (s, "%-9s", "interrupt");
424 s = format (s, "%-9s", "invalid");
430 api_unformat_vhost_user_operation_mode (unformat_input_t * input,
433 u8 *operation_mode = va_arg (*args, u8 *);
436 if (unformat (input, "interrupt"))
437 *operation_mode = VHOST_USER_INTERRUPT_MODE;
438 else if (unformat (input, "polling"))
439 *operation_mode = VHOST_USER_POLLING_MODE;
447 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
449 u8 *r = va_arg (*args, u8 *);
451 if (unformat (input, "kbps"))
452 *r = SSE2_QOS_RATE_KBPS;
453 else if (unformat (input, "pps"))
454 *r = SSE2_QOS_RATE_PPS;
461 unformat_policer_round_type (unformat_input_t * input, va_list * args)
463 u8 *r = va_arg (*args, u8 *);
465 if (unformat (input, "closest"))
466 *r = SSE2_QOS_ROUND_TO_CLOSEST;
467 else if (unformat (input, "up"))
468 *r = SSE2_QOS_ROUND_TO_UP;
469 else if (unformat (input, "down"))
470 *r = SSE2_QOS_ROUND_TO_DOWN;
477 unformat_policer_type (unformat_input_t * input, va_list * args)
479 u8 *r = va_arg (*args, u8 *);
481 if (unformat (input, "1r2c"))
482 *r = SSE2_QOS_POLICER_TYPE_1R2C;
483 else if (unformat (input, "1r3c"))
484 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
485 else if (unformat (input, "2r3c-2698"))
486 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
487 else if (unformat (input, "2r3c-4115"))
488 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
489 else if (unformat (input, "2r3c-mef5cf1"))
490 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
497 unformat_dscp (unformat_input_t * input, va_list * va)
499 u8 *r = va_arg (*va, u8 *);
502 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
511 unformat_policer_action_type (unformat_input_t * input, va_list * va)
513 sse2_qos_pol_action_params_st *a
514 = va_arg (*va, sse2_qos_pol_action_params_st *);
516 if (unformat (input, "drop"))
517 a->action_type = SSE2_QOS_ACTION_DROP;
518 else if (unformat (input, "transmit"))
519 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
520 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
521 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
528 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
530 u32 *r = va_arg (*va, u32 *);
533 if (unformat (input, "ip4"))
534 tid = POLICER_CLASSIFY_TABLE_IP4;
535 else if (unformat (input, "ip6"))
536 tid = POLICER_CLASSIFY_TABLE_IP6;
537 else if (unformat (input, "l2"))
538 tid = POLICER_CLASSIFY_TABLE_L2;
547 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
549 u32 *r = va_arg (*va, u32 *);
552 if (unformat (input, "ip4"))
553 tid = FLOW_CLASSIFY_TABLE_IP4;
554 else if (unformat (input, "ip6"))
555 tid = FLOW_CLASSIFY_TABLE_IP6;
563 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
564 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
565 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
566 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
568 #if (VPP_API_TEST_BUILTIN==0)
570 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
572 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
573 mfib_itf_attribute_t attr;
576 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
578 if (unformat (input, mfib_itf_flag_long_names[attr]))
579 *iflags |= (1 << attr);
581 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
583 if (unformat (input, mfib_itf_flag_names[attr]))
584 *iflags |= (1 << attr);
587 return (old == *iflags ? 0 : 1);
591 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
593 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
594 mfib_entry_attribute_t attr;
597 FOR_EACH_MFIB_ATTRIBUTE (attr)
599 if (unformat (input, mfib_flag_long_names[attr]))
600 *eflags |= (1 << attr);
602 FOR_EACH_MFIB_ATTRIBUTE (attr)
604 if (unformat (input, mfib_flag_names[attr]))
605 *eflags |= (1 << attr);
608 return (old == *eflags ? 0 : 1);
612 format_ip4_address (u8 * s, va_list * args)
614 u8 *a = va_arg (*args, u8 *);
615 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
619 format_ip6_address (u8 * s, va_list * args)
621 ip6_address_t *a = va_arg (*args, ip6_address_t *);
622 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
624 i_max_n_zero = ARRAY_LEN (a->as_u16);
626 i_first_zero = i_max_n_zero;
628 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
630 u32 is_zero = a->as_u16[i] == 0;
631 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
637 if ((!is_zero && n_zeros > max_n_zeros)
638 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
640 i_max_n_zero = i_first_zero;
641 max_n_zeros = n_zeros;
642 i_first_zero = ARRAY_LEN (a->as_u16);
647 last_double_colon = 0;
648 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
650 if (i == i_max_n_zero && max_n_zeros > 1)
652 s = format (s, "::");
653 i += max_n_zeros - 1;
654 last_double_colon = 1;
658 s = format (s, "%s%x",
659 (last_double_colon || i == 0) ? "" : ":",
660 clib_net_to_host_u16 (a->as_u16[i]));
661 last_double_colon = 0;
668 /* Format an IP46 address. */
670 format_ip46_address (u8 * s, va_list * args)
672 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
673 ip46_type_t type = va_arg (*args, ip46_type_t);
679 is_ip4 = ip46_address_is_ip4 (ip46);
690 format (s, "%U", format_ip4_address, &ip46->ip4) :
691 format (s, "%U", format_ip6_address, &ip46->ip6);
695 format_ethernet_address (u8 * s, va_list * args)
697 u8 *a = va_arg (*args, u8 *);
699 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
700 a[0], a[1], a[2], a[3], a[4], a[5]);
705 increment_v4_address (ip4_address_t * a)
709 v = ntohl (a->as_u32) + 1;
710 a->as_u32 = ntohl (v);
714 increment_v6_address (ip6_address_t * a)
718 v0 = clib_net_to_host_u64 (a->as_u64[0]);
719 v1 = clib_net_to_host_u64 (a->as_u64[1]);
724 a->as_u64[0] = clib_net_to_host_u64 (v0);
725 a->as_u64[1] = clib_net_to_host_u64 (v1);
729 increment_mac_address (u64 * mac)
733 tmp = clib_net_to_host_u64 (tmp);
734 tmp += 1 << 16; /* skip unused (least significant) octets */
735 tmp = clib_host_to_net_u64 (tmp);
739 static void vl_api_create_loopback_reply_t_handler
740 (vl_api_create_loopback_reply_t * mp)
742 vat_main_t *vam = &vat_main;
743 i32 retval = ntohl (mp->retval);
745 vam->retval = retval;
746 vam->regenerate_interface_table = 1;
747 vam->sw_if_index = ntohl (mp->sw_if_index);
748 vam->result_ready = 1;
751 static void vl_api_create_loopback_reply_t_handler_json
752 (vl_api_create_loopback_reply_t * mp)
754 vat_main_t *vam = &vat_main;
755 vat_json_node_t node;
757 vat_json_init_object (&node);
758 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
759 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
761 vat_json_print (vam->ofp, &node);
762 vat_json_free (&node);
763 vam->retval = ntohl (mp->retval);
764 vam->result_ready = 1;
767 static void vl_api_create_loopback_instance_reply_t_handler
768 (vl_api_create_loopback_instance_reply_t * mp)
770 vat_main_t *vam = &vat_main;
771 i32 retval = ntohl (mp->retval);
773 vam->retval = retval;
774 vam->regenerate_interface_table = 1;
775 vam->sw_if_index = ntohl (mp->sw_if_index);
776 vam->result_ready = 1;
779 static void vl_api_create_loopback_instance_reply_t_handler_json
780 (vl_api_create_loopback_instance_reply_t * mp)
782 vat_main_t *vam = &vat_main;
783 vat_json_node_t node;
785 vat_json_init_object (&node);
786 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
787 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
789 vat_json_print (vam->ofp, &node);
790 vat_json_free (&node);
791 vam->retval = ntohl (mp->retval);
792 vam->result_ready = 1;
795 static void vl_api_af_packet_create_reply_t_handler
796 (vl_api_af_packet_create_reply_t * mp)
798 vat_main_t *vam = &vat_main;
799 i32 retval = ntohl (mp->retval);
801 vam->retval = retval;
802 vam->regenerate_interface_table = 1;
803 vam->sw_if_index = ntohl (mp->sw_if_index);
804 vam->result_ready = 1;
807 static void vl_api_af_packet_create_reply_t_handler_json
808 (vl_api_af_packet_create_reply_t * mp)
810 vat_main_t *vam = &vat_main;
811 vat_json_node_t node;
813 vat_json_init_object (&node);
814 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
815 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
817 vat_json_print (vam->ofp, &node);
818 vat_json_free (&node);
820 vam->retval = ntohl (mp->retval);
821 vam->result_ready = 1;
824 static void vl_api_create_vlan_subif_reply_t_handler
825 (vl_api_create_vlan_subif_reply_t * mp)
827 vat_main_t *vam = &vat_main;
828 i32 retval = ntohl (mp->retval);
830 vam->retval = retval;
831 vam->regenerate_interface_table = 1;
832 vam->sw_if_index = ntohl (mp->sw_if_index);
833 vam->result_ready = 1;
836 static void vl_api_create_vlan_subif_reply_t_handler_json
837 (vl_api_create_vlan_subif_reply_t * mp)
839 vat_main_t *vam = &vat_main;
840 vat_json_node_t node;
842 vat_json_init_object (&node);
843 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
844 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
846 vat_json_print (vam->ofp, &node);
847 vat_json_free (&node);
849 vam->retval = ntohl (mp->retval);
850 vam->result_ready = 1;
853 static void vl_api_create_subif_reply_t_handler
854 (vl_api_create_subif_reply_t * mp)
856 vat_main_t *vam = &vat_main;
857 i32 retval = ntohl (mp->retval);
859 vam->retval = retval;
860 vam->regenerate_interface_table = 1;
861 vam->sw_if_index = ntohl (mp->sw_if_index);
862 vam->result_ready = 1;
865 static void vl_api_create_subif_reply_t_handler_json
866 (vl_api_create_subif_reply_t * mp)
868 vat_main_t *vam = &vat_main;
869 vat_json_node_t node;
871 vat_json_init_object (&node);
872 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
873 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
875 vat_json_print (vam->ofp, &node);
876 vat_json_free (&node);
878 vam->retval = ntohl (mp->retval);
879 vam->result_ready = 1;
882 static void vl_api_interface_name_renumber_reply_t_handler
883 (vl_api_interface_name_renumber_reply_t * mp)
885 vat_main_t *vam = &vat_main;
886 i32 retval = ntohl (mp->retval);
888 vam->retval = retval;
889 vam->regenerate_interface_table = 1;
890 vam->result_ready = 1;
893 static void vl_api_interface_name_renumber_reply_t_handler_json
894 (vl_api_interface_name_renumber_reply_t * mp)
896 vat_main_t *vam = &vat_main;
897 vat_json_node_t node;
899 vat_json_init_object (&node);
900 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
902 vat_json_print (vam->ofp, &node);
903 vat_json_free (&node);
905 vam->retval = ntohl (mp->retval);
906 vam->result_ready = 1;
910 * Special-case: build the interface table, maintain
911 * the next loopback sw_if_index vbl.
913 static void vl_api_sw_interface_details_t_handler
914 (vl_api_sw_interface_details_t * mp)
916 vat_main_t *vam = &vat_main;
917 u8 *s = format (0, "%s%c", mp->interface_name, 0);
919 hash_set_mem (vam->sw_if_index_by_interface_name, s,
920 ntohl (mp->sw_if_index));
922 /* In sub interface case, fill the sub interface table entry */
923 if (mp->sw_if_index != mp->sup_sw_if_index)
925 sw_interface_subif_t *sub = NULL;
927 vec_add2 (vam->sw_if_subif_table, sub, 1);
929 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
930 strncpy ((char *) sub->interface_name, (char *) s,
931 vec_len (sub->interface_name));
932 sub->sw_if_index = ntohl (mp->sw_if_index);
933 sub->sub_id = ntohl (mp->sub_id);
935 sub->sub_dot1ad = mp->sub_dot1ad;
936 sub->sub_number_of_tags = mp->sub_number_of_tags;
937 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
938 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
939 sub->sub_exact_match = mp->sub_exact_match;
940 sub->sub_default = mp->sub_default;
941 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
942 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
944 /* vlan tag rewrite */
945 sub->vtr_op = ntohl (mp->vtr_op);
946 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
947 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
948 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
952 static void vl_api_sw_interface_details_t_handler_json
953 (vl_api_sw_interface_details_t * mp)
955 vat_main_t *vam = &vat_main;
956 vat_json_node_t *node = NULL;
958 if (VAT_JSON_ARRAY != vam->json_tree.type)
960 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
961 vat_json_init_array (&vam->json_tree);
963 node = vat_json_array_add (&vam->json_tree);
965 vat_json_init_object (node);
966 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
967 vat_json_object_add_uint (node, "sup_sw_if_index",
968 ntohl (mp->sup_sw_if_index));
969 vat_json_object_add_uint (node, "l2_address_length",
970 ntohl (mp->l2_address_length));
971 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
972 sizeof (mp->l2_address));
973 vat_json_object_add_string_copy (node, "interface_name",
975 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
976 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
977 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
978 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
979 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
980 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
981 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
982 vat_json_object_add_uint (node, "sub_number_of_tags",
983 mp->sub_number_of_tags);
984 vat_json_object_add_uint (node, "sub_outer_vlan_id",
985 ntohs (mp->sub_outer_vlan_id));
986 vat_json_object_add_uint (node, "sub_inner_vlan_id",
987 ntohs (mp->sub_inner_vlan_id));
988 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
989 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
990 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
991 mp->sub_outer_vlan_id_any);
992 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
993 mp->sub_inner_vlan_id_any);
994 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
995 vat_json_object_add_uint (node, "vtr_push_dot1q",
996 ntohl (mp->vtr_push_dot1q));
997 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
998 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1001 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1003 format_ethernet_address,
1005 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1007 format_ethernet_address,
1009 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1010 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1014 #if VPP_API_TEST_BUILTIN == 0
1015 static void vl_api_sw_interface_set_flags_t_handler
1016 (vl_api_sw_interface_set_flags_t * mp)
1018 vat_main_t *vam = &vat_main;
1019 if (vam->interface_event_display)
1020 errmsg ("interface flags: sw_if_index %d %s %s",
1021 ntohl (mp->sw_if_index),
1022 mp->admin_up_down ? "admin-up" : "admin-down",
1023 mp->link_up_down ? "link-up" : "link-down");
1027 static void vl_api_sw_interface_set_flags_t_handler_json
1028 (vl_api_sw_interface_set_flags_t * mp)
1030 /* JSON output not supported */
1034 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1036 vat_main_t *vam = &vat_main;
1037 i32 retval = ntohl (mp->retval);
1039 vam->retval = retval;
1040 vam->shmem_result = (u8 *) mp->reply_in_shmem;
1041 vam->result_ready = 1;
1045 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1047 vat_main_t *vam = &vat_main;
1048 vat_json_node_t node;
1049 api_main_t *am = &api_main;
1053 vat_json_init_object (&node);
1054 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1055 vat_json_object_add_uint (&node, "reply_in_shmem",
1056 ntohl (mp->reply_in_shmem));
1057 /* Toss the shared-memory original... */
1058 pthread_mutex_lock (&am->vlib_rp->mutex);
1059 oldheap = svm_push_data_heap (am->vlib_rp);
1061 reply = (u8 *) (mp->reply_in_shmem);
1064 svm_pop_heap (oldheap);
1065 pthread_mutex_unlock (&am->vlib_rp->mutex);
1067 vat_json_print (vam->ofp, &node);
1068 vat_json_free (&node);
1070 vam->retval = ntohl (mp->retval);
1071 vam->result_ready = 1;
1075 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1077 vat_main_t *vam = &vat_main;
1078 i32 retval = ntohl (mp->retval);
1080 vam->retval = retval;
1081 vam->cmd_reply = mp->reply;
1082 vam->result_ready = 1;
1086 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1088 vat_main_t *vam = &vat_main;
1089 vat_json_node_t node;
1091 vat_json_init_object (&node);
1092 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1093 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1095 vat_json_print (vam->ofp, &node);
1096 vat_json_free (&node);
1098 vam->retval = ntohl (mp->retval);
1099 vam->result_ready = 1;
1102 static void vl_api_classify_add_del_table_reply_t_handler
1103 (vl_api_classify_add_del_table_reply_t * mp)
1105 vat_main_t *vam = &vat_main;
1106 i32 retval = ntohl (mp->retval);
1107 if (vam->async_mode)
1109 vam->async_errors += (retval < 0);
1113 vam->retval = retval;
1115 ((mp->new_table_index != 0xFFFFFFFF) ||
1116 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1117 (mp->match_n_vectors != 0xFFFFFFFF)))
1119 * Note: this is just barely thread-safe, depends on
1120 * the main thread spinning waiting for an answer...
1122 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1123 ntohl (mp->new_table_index),
1124 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1125 vam->result_ready = 1;
1129 static void vl_api_classify_add_del_table_reply_t_handler_json
1130 (vl_api_classify_add_del_table_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, "new_table_index",
1138 ntohl (mp->new_table_index));
1139 vat_json_object_add_uint (&node, "skip_n_vectors",
1140 ntohl (mp->skip_n_vectors));
1141 vat_json_object_add_uint (&node, "match_n_vectors",
1142 ntohl (mp->match_n_vectors));
1144 vat_json_print (vam->ofp, &node);
1145 vat_json_free (&node);
1147 vam->retval = ntohl (mp->retval);
1148 vam->result_ready = 1;
1151 static void vl_api_get_node_index_reply_t_handler
1152 (vl_api_get_node_index_reply_t * mp)
1154 vat_main_t *vam = &vat_main;
1155 i32 retval = ntohl (mp->retval);
1156 if (vam->async_mode)
1158 vam->async_errors += (retval < 0);
1162 vam->retval = retval;
1164 errmsg ("node index %d", ntohl (mp->node_index));
1165 vam->result_ready = 1;
1169 static void vl_api_get_node_index_reply_t_handler_json
1170 (vl_api_get_node_index_reply_t * mp)
1172 vat_main_t *vam = &vat_main;
1173 vat_json_node_t node;
1175 vat_json_init_object (&node);
1176 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1177 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1179 vat_json_print (vam->ofp, &node);
1180 vat_json_free (&node);
1182 vam->retval = ntohl (mp->retval);
1183 vam->result_ready = 1;
1186 static void vl_api_get_next_index_reply_t_handler
1187 (vl_api_get_next_index_reply_t * mp)
1189 vat_main_t *vam = &vat_main;
1190 i32 retval = ntohl (mp->retval);
1191 if (vam->async_mode)
1193 vam->async_errors += (retval < 0);
1197 vam->retval = retval;
1199 errmsg ("next node index %d", ntohl (mp->next_index));
1200 vam->result_ready = 1;
1204 static void vl_api_get_next_index_reply_t_handler_json
1205 (vl_api_get_next_index_reply_t * mp)
1207 vat_main_t *vam = &vat_main;
1208 vat_json_node_t node;
1210 vat_json_init_object (&node);
1211 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1212 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1214 vat_json_print (vam->ofp, &node);
1215 vat_json_free (&node);
1217 vam->retval = ntohl (mp->retval);
1218 vam->result_ready = 1;
1221 static void vl_api_add_node_next_reply_t_handler
1222 (vl_api_add_node_next_reply_t * mp)
1224 vat_main_t *vam = &vat_main;
1225 i32 retval = ntohl (mp->retval);
1226 if (vam->async_mode)
1228 vam->async_errors += (retval < 0);
1232 vam->retval = retval;
1234 errmsg ("next index %d", ntohl (mp->next_index));
1235 vam->result_ready = 1;
1239 static void vl_api_add_node_next_reply_t_handler_json
1240 (vl_api_add_node_next_reply_t * mp)
1242 vat_main_t *vam = &vat_main;
1243 vat_json_node_t node;
1245 vat_json_init_object (&node);
1246 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1247 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1249 vat_json_print (vam->ofp, &node);
1250 vat_json_free (&node);
1252 vam->retval = ntohl (mp->retval);
1253 vam->result_ready = 1;
1256 static void vl_api_show_version_reply_t_handler
1257 (vl_api_show_version_reply_t * mp)
1259 vat_main_t *vam = &vat_main;
1260 i32 retval = ntohl (mp->retval);
1264 errmsg (" program: %s", mp->program);
1265 errmsg (" version: %s", mp->version);
1266 errmsg (" build date: %s", mp->build_date);
1267 errmsg ("build directory: %s", mp->build_directory);
1269 vam->retval = retval;
1270 vam->result_ready = 1;
1273 static void vl_api_show_version_reply_t_handler_json
1274 (vl_api_show_version_reply_t * mp)
1276 vat_main_t *vam = &vat_main;
1277 vat_json_node_t node;
1279 vat_json_init_object (&node);
1280 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1281 vat_json_object_add_string_copy (&node, "program", mp->program);
1282 vat_json_object_add_string_copy (&node, "version", mp->version);
1283 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1284 vat_json_object_add_string_copy (&node, "build_directory",
1285 mp->build_directory);
1287 vat_json_print (vam->ofp, &node);
1288 vat_json_free (&node);
1290 vam->retval = ntohl (mp->retval);
1291 vam->result_ready = 1;
1295 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1297 u32 sw_if_index = ntohl (mp->sw_if_index);
1298 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1299 mp->mac_ip ? "mac/ip binding" : "address resolution",
1300 ntohl (mp->pid), format_ip4_address, &mp->address,
1301 format_ethernet_address, mp->new_mac, sw_if_index);
1305 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1307 /* JSON output not supported */
1311 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1313 u32 sw_if_index = ntohl (mp->sw_if_index);
1314 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1315 mp->mac_ip ? "mac/ip binding" : "address resolution",
1316 ntohl (mp->pid), format_ip6_address, mp->address,
1317 format_ethernet_address, mp->new_mac, sw_if_index);
1321 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1323 /* JSON output not supported */
1327 * Special-case: build the bridge domain table, maintain
1328 * the next bd id vbl.
1330 static void vl_api_bridge_domain_details_t_handler
1331 (vl_api_bridge_domain_details_t * mp)
1333 vat_main_t *vam = &vat_main;
1334 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1336 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1337 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1339 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1340 ntohl (mp->bd_id), mp->learn, mp->forward,
1341 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1344 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG", "Interface Name");
1347 static void vl_api_bridge_domain_details_t_handler_json
1348 (vl_api_bridge_domain_details_t * mp)
1350 vat_main_t *vam = &vat_main;
1351 vat_json_node_t *node, *array = NULL;
1353 if (VAT_JSON_ARRAY != vam->json_tree.type)
1355 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1356 vat_json_init_array (&vam->json_tree);
1358 node = vat_json_array_add (&vam->json_tree);
1360 vat_json_init_object (node);
1361 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1362 vat_json_object_add_uint (node, "flood", mp->flood);
1363 vat_json_object_add_uint (node, "forward", mp->forward);
1364 vat_json_object_add_uint (node, "learn", mp->learn);
1365 vat_json_object_add_uint (node, "bvi_sw_if_index",
1366 ntohl (mp->bvi_sw_if_index));
1367 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1368 array = vat_json_object_add (node, "sw_if");
1369 vat_json_init_array (array);
1373 * Special-case: build the bridge domain sw if table.
1375 static void vl_api_bridge_domain_sw_if_details_t_handler
1376 (vl_api_bridge_domain_sw_if_details_t * mp)
1378 vat_main_t *vam = &vat_main;
1383 sw_if_index = ntohl (mp->sw_if_index);
1385 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1387 if ((u32) p->value[0] == sw_if_index)
1389 sw_if_name = (u8 *)(p->key);
1395 print (vam->ofp, "%7d %3d %s", sw_if_index,
1396 mp->shg, sw_if_name ? (char *) sw_if_name :
1397 "sw_if_index not found!");
1400 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1401 (vl_api_bridge_domain_sw_if_details_t * mp)
1403 vat_main_t *vam = &vat_main;
1404 vat_json_node_t *node = NULL;
1405 uword last_index = 0;
1407 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1408 ASSERT (vec_len (vam->json_tree.array) >= 1);
1409 last_index = vec_len (vam->json_tree.array) - 1;
1410 node = &vam->json_tree.array[last_index];
1411 node = vat_json_object_get_element (node, "sw_if");
1412 ASSERT (NULL != node);
1413 node = vat_json_array_add (node);
1415 vat_json_init_object (node);
1416 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1417 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1418 vat_json_object_add_uint (node, "shg", mp->shg);
1421 static void vl_api_control_ping_reply_t_handler
1422 (vl_api_control_ping_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_control_ping_reply_t_handler_json
1438 (vl_api_control_ping_reply_t * mp)
1440 vat_main_t *vam = &vat_main;
1441 i32 retval = ntohl (mp->retval);
1443 if (VAT_JSON_NONE != vam->json_tree.type)
1445 vat_json_print (vam->ofp, &vam->json_tree);
1446 vat_json_free (&vam->json_tree);
1447 vam->json_tree.type = VAT_JSON_NONE;
1452 vat_json_init_array (&vam->json_tree);
1453 vat_json_print (vam->ofp, &vam->json_tree);
1454 vam->json_tree.type = VAT_JSON_NONE;
1457 vam->retval = retval;
1458 vam->result_ready = 1;
1462 vl_api_bridge_domain_set_mac_age_reply_t_handler
1463 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1465 vat_main_t *vam = &vat_main;
1466 i32 retval = ntohl (mp->retval);
1467 if (vam->async_mode)
1469 vam->async_errors += (retval < 0);
1473 vam->retval = retval;
1474 vam->result_ready = 1;
1478 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1479 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1481 vat_main_t *vam = &vat_main;
1482 vat_json_node_t node;
1484 vat_json_init_object (&node);
1485 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1487 vat_json_print (vam->ofp, &node);
1488 vat_json_free (&node);
1490 vam->retval = ntohl (mp->retval);
1491 vam->result_ready = 1;
1495 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1497 vat_main_t *vam = &vat_main;
1498 i32 retval = ntohl (mp->retval);
1499 if (vam->async_mode)
1501 vam->async_errors += (retval < 0);
1505 vam->retval = retval;
1506 vam->result_ready = 1;
1510 static void vl_api_l2_flags_reply_t_handler_json
1511 (vl_api_l2_flags_reply_t * mp)
1513 vat_main_t *vam = &vat_main;
1514 vat_json_node_t node;
1516 vat_json_init_object (&node);
1517 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1518 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1519 ntohl (mp->resulting_feature_bitmap));
1521 vat_json_print (vam->ofp, &node);
1522 vat_json_free (&node);
1524 vam->retval = ntohl (mp->retval);
1525 vam->result_ready = 1;
1528 static void vl_api_bridge_flags_reply_t_handler
1529 (vl_api_bridge_flags_reply_t * mp)
1531 vat_main_t *vam = &vat_main;
1532 i32 retval = ntohl (mp->retval);
1533 if (vam->async_mode)
1535 vam->async_errors += (retval < 0);
1539 vam->retval = retval;
1540 vam->result_ready = 1;
1544 static void vl_api_bridge_flags_reply_t_handler_json
1545 (vl_api_bridge_flags_reply_t * mp)
1547 vat_main_t *vam = &vat_main;
1548 vat_json_node_t node;
1550 vat_json_init_object (&node);
1551 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1552 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1553 ntohl (mp->resulting_feature_bitmap));
1555 vat_json_print (vam->ofp, &node);
1556 vat_json_free (&node);
1558 vam->retval = ntohl (mp->retval);
1559 vam->result_ready = 1;
1562 static void vl_api_tap_connect_reply_t_handler
1563 (vl_api_tap_connect_reply_t * mp)
1565 vat_main_t *vam = &vat_main;
1566 i32 retval = ntohl (mp->retval);
1567 if (vam->async_mode)
1569 vam->async_errors += (retval < 0);
1573 vam->retval = retval;
1574 vam->sw_if_index = ntohl (mp->sw_if_index);
1575 vam->result_ready = 1;
1580 static void vl_api_tap_connect_reply_t_handler_json
1581 (vl_api_tap_connect_reply_t * mp)
1583 vat_main_t *vam = &vat_main;
1584 vat_json_node_t node;
1586 vat_json_init_object (&node);
1587 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1588 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1590 vat_json_print (vam->ofp, &node);
1591 vat_json_free (&node);
1593 vam->retval = ntohl (mp->retval);
1594 vam->result_ready = 1;
1599 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1601 vat_main_t *vam = &vat_main;
1602 i32 retval = ntohl (mp->retval);
1603 if (vam->async_mode)
1605 vam->async_errors += (retval < 0);
1609 vam->retval = retval;
1610 vam->sw_if_index = ntohl (mp->sw_if_index);
1611 vam->result_ready = 1;
1615 static void vl_api_tap_modify_reply_t_handler_json
1616 (vl_api_tap_modify_reply_t * mp)
1618 vat_main_t *vam = &vat_main;
1619 vat_json_node_t node;
1621 vat_json_init_object (&node);
1622 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1623 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1625 vat_json_print (vam->ofp, &node);
1626 vat_json_free (&node);
1628 vam->retval = ntohl (mp->retval);
1629 vam->result_ready = 1;
1633 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1635 vat_main_t *vam = &vat_main;
1636 i32 retval = ntohl (mp->retval);
1637 if (vam->async_mode)
1639 vam->async_errors += (retval < 0);
1643 vam->retval = retval;
1644 vam->result_ready = 1;
1648 static void vl_api_tap_delete_reply_t_handler_json
1649 (vl_api_tap_delete_reply_t * mp)
1651 vat_main_t *vam = &vat_main;
1652 vat_json_node_t node;
1654 vat_json_init_object (&node);
1655 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1657 vat_json_print (vam->ofp, &node);
1658 vat_json_free (&node);
1660 vam->retval = ntohl (mp->retval);
1661 vam->result_ready = 1;
1664 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1665 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1667 vat_main_t *vam = &vat_main;
1668 i32 retval = ntohl (mp->retval);
1669 if (vam->async_mode)
1671 vam->async_errors += (retval < 0);
1675 vam->retval = retval;
1676 vam->result_ready = 1;
1680 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1681 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1683 vat_main_t *vam = &vat_main;
1684 vat_json_node_t node;
1686 vat_json_init_object (&node);
1687 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1688 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1689 ntohl (mp->sw_if_index));
1691 vat_json_print (vam->ofp, &node);
1692 vat_json_free (&node);
1694 vam->retval = ntohl (mp->retval);
1695 vam->result_ready = 1;
1698 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1699 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1701 vat_main_t *vam = &vat_main;
1702 i32 retval = ntohl (mp->retval);
1703 if (vam->async_mode)
1705 vam->async_errors += (retval < 0);
1709 vam->retval = retval;
1710 vam->sw_if_index = ntohl (mp->sw_if_index);
1711 vam->result_ready = 1;
1715 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1716 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1718 vat_main_t *vam = &vat_main;
1719 vat_json_node_t node;
1721 vat_json_init_object (&node);
1722 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1723 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1725 vat_json_print (vam->ofp, &node);
1726 vat_json_free (&node);
1728 vam->retval = ntohl (mp->retval);
1729 vam->result_ready = 1;
1733 static void vl_api_one_add_del_locator_set_reply_t_handler
1734 (vl_api_one_add_del_locator_set_reply_t * mp)
1736 vat_main_t *vam = &vat_main;
1737 i32 retval = ntohl (mp->retval);
1738 if (vam->async_mode)
1740 vam->async_errors += (retval < 0);
1744 vam->retval = retval;
1745 vam->result_ready = 1;
1749 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1750 (vl_api_one_add_del_locator_set_reply_t * mp)
1752 vat_main_t *vam = &vat_main;
1753 vat_json_node_t node;
1755 vat_json_init_object (&node);
1756 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1757 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1759 vat_json_print (vam->ofp, &node);
1760 vat_json_free (&node);
1762 vam->retval = ntohl (mp->retval);
1763 vam->result_ready = 1;
1766 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1767 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1769 vat_main_t *vam = &vat_main;
1770 i32 retval = ntohl (mp->retval);
1771 if (vam->async_mode)
1773 vam->async_errors += (retval < 0);
1777 vam->retval = retval;
1778 vam->sw_if_index = ntohl (mp->sw_if_index);
1779 vam->result_ready = 1;
1783 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1784 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1786 vat_main_t *vam = &vat_main;
1787 vat_json_node_t node;
1789 vat_json_init_object (&node);
1790 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1791 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1793 vat_json_print (vam->ofp, &node);
1794 vat_json_free (&node);
1796 vam->retval = ntohl (mp->retval);
1797 vam->result_ready = 1;
1800 static void vl_api_gre_add_del_tunnel_reply_t_handler
1801 (vl_api_gre_add_del_tunnel_reply_t * mp)
1803 vat_main_t *vam = &vat_main;
1804 i32 retval = ntohl (mp->retval);
1805 if (vam->async_mode)
1807 vam->async_errors += (retval < 0);
1811 vam->retval = retval;
1812 vam->sw_if_index = ntohl (mp->sw_if_index);
1813 vam->result_ready = 1;
1817 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1818 (vl_api_gre_add_del_tunnel_reply_t * mp)
1820 vat_main_t *vam = &vat_main;
1821 vat_json_node_t node;
1823 vat_json_init_object (&node);
1824 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1825 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1827 vat_json_print (vam->ofp, &node);
1828 vat_json_free (&node);
1830 vam->retval = ntohl (mp->retval);
1831 vam->result_ready = 1;
1834 static void vl_api_create_vhost_user_if_reply_t_handler
1835 (vl_api_create_vhost_user_if_reply_t * mp)
1837 vat_main_t *vam = &vat_main;
1838 i32 retval = ntohl (mp->retval);
1839 if (vam->async_mode)
1841 vam->async_errors += (retval < 0);
1845 vam->retval = retval;
1846 vam->sw_if_index = ntohl (mp->sw_if_index);
1847 vam->result_ready = 1;
1851 static void vl_api_create_vhost_user_if_reply_t_handler_json
1852 (vl_api_create_vhost_user_if_reply_t * mp)
1854 vat_main_t *vam = &vat_main;
1855 vat_json_node_t node;
1857 vat_json_init_object (&node);
1858 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1859 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1861 vat_json_print (vam->ofp, &node);
1862 vat_json_free (&node);
1864 vam->retval = ntohl (mp->retval);
1865 vam->result_ready = 1;
1868 static void vl_api_ip_address_details_t_handler
1869 (vl_api_ip_address_details_t * mp)
1871 vat_main_t *vam = &vat_main;
1872 static ip_address_details_t empty_ip_address_details = { {0} };
1873 ip_address_details_t *address = NULL;
1874 ip_details_t *current_ip_details = NULL;
1875 ip_details_t *details = NULL;
1877 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1879 if (!details || vam->current_sw_if_index >= vec_len (details)
1880 || !details[vam->current_sw_if_index].present)
1882 errmsg ("ip address details arrived but not stored");
1883 errmsg ("ip_dump should be called first");
1887 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1889 #define addresses (current_ip_details->addr)
1891 vec_validate_init_empty (addresses, vec_len (addresses),
1892 empty_ip_address_details);
1894 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1896 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1897 address->prefix_length = mp->prefix_length;
1901 static void vl_api_ip_address_details_t_handler_json
1902 (vl_api_ip_address_details_t * mp)
1904 vat_main_t *vam = &vat_main;
1905 vat_json_node_t *node = NULL;
1906 struct in6_addr ip6;
1909 if (VAT_JSON_ARRAY != vam->json_tree.type)
1911 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1912 vat_json_init_array (&vam->json_tree);
1914 node = vat_json_array_add (&vam->json_tree);
1916 vat_json_init_object (node);
1919 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1920 vat_json_object_add_ip6 (node, "ip", ip6);
1924 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1925 vat_json_object_add_ip4 (node, "ip", ip4);
1927 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1931 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1933 vat_main_t *vam = &vat_main;
1934 static ip_details_t empty_ip_details = { 0 };
1935 ip_details_t *ip = NULL;
1936 u32 sw_if_index = ~0;
1938 sw_if_index = ntohl (mp->sw_if_index);
1940 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1941 sw_if_index, empty_ip_details);
1943 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1950 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1952 vat_main_t *vam = &vat_main;
1954 if (VAT_JSON_ARRAY != vam->json_tree.type)
1956 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1957 vat_json_init_array (&vam->json_tree);
1959 vat_json_array_add_uint (&vam->json_tree,
1960 clib_net_to_host_u32 (mp->sw_if_index));
1963 static void vl_api_map_domain_details_t_handler_json
1964 (vl_api_map_domain_details_t * mp)
1966 vat_json_node_t *node = NULL;
1967 vat_main_t *vam = &vat_main;
1968 struct in6_addr ip6;
1971 if (VAT_JSON_ARRAY != vam->json_tree.type)
1973 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1974 vat_json_init_array (&vam->json_tree);
1977 node = vat_json_array_add (&vam->json_tree);
1978 vat_json_init_object (node);
1980 vat_json_object_add_uint (node, "domain_index",
1981 clib_net_to_host_u32 (mp->domain_index));
1982 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1983 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1984 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1985 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1986 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1987 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1988 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1989 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1990 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1991 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1992 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1993 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1994 vat_json_object_add_uint (node, "flags", mp->flags);
1995 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1996 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1999 static void vl_api_map_domain_details_t_handler
2000 (vl_api_map_domain_details_t * mp)
2002 vat_main_t *vam = &vat_main;
2004 if (mp->is_translation)
2007 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2008 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2009 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2010 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2011 clib_net_to_host_u32 (mp->domain_index));
2016 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2017 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2018 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2019 format_ip6_address, mp->ip6_src,
2020 clib_net_to_host_u32 (mp->domain_index));
2022 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2023 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2024 mp->is_translation ? "map-t" : "");
2027 static void vl_api_map_rule_details_t_handler_json
2028 (vl_api_map_rule_details_t * mp)
2030 struct in6_addr ip6;
2031 vat_json_node_t *node = NULL;
2032 vat_main_t *vam = &vat_main;
2034 if (VAT_JSON_ARRAY != vam->json_tree.type)
2036 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2037 vat_json_init_array (&vam->json_tree);
2040 node = vat_json_array_add (&vam->json_tree);
2041 vat_json_init_object (node);
2043 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2044 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2045 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2049 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2051 vat_main_t *vam = &vat_main;
2052 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2053 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2057 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2059 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2060 "router_addr %U host_mac %U",
2061 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2062 format_ip4_address, &mp->host_address,
2063 format_ip4_address, &mp->router_address,
2064 format_ethernet_address, mp->host_mac);
2067 static void vl_api_dhcp_compl_event_t_handler_json
2068 (vl_api_dhcp_compl_event_t * mp)
2070 /* JSON output not supported */
2074 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2077 vat_main_t *vam = &vat_main;
2078 static u64 default_counter = 0;
2080 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2082 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2083 sw_if_index, default_counter);
2084 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2088 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2089 interface_counter_t counter)
2091 vat_main_t *vam = &vat_main;
2092 static interface_counter_t default_counter = { 0, };
2094 vec_validate_init_empty (vam->combined_interface_counters,
2095 vnet_counter_type, NULL);
2096 vec_validate_init_empty (vam->combined_interface_counters
2097 [vnet_counter_type], sw_if_index, default_counter);
2098 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2101 static void vl_api_vnet_interface_counters_t_handler
2102 (vl_api_vnet_interface_counters_t * mp)
2107 static void vl_api_vnet_interface_counters_t_handler_json
2108 (vl_api_vnet_interface_counters_t * mp)
2110 interface_counter_t counter;
2115 u32 first_sw_if_index;
2118 count = ntohl (mp->count);
2119 first_sw_if_index = ntohl (mp->first_sw_if_index);
2121 if (!mp->is_combined)
2123 v_packets = (u64 *) & mp->data;
2124 for (i = 0; i < count; i++)
2127 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2128 set_simple_interface_counter (mp->vnet_counter_type,
2129 first_sw_if_index + i, packets);
2135 v = (vlib_counter_t *) & mp->data;
2136 for (i = 0; i < count; i++)
2139 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2141 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2142 set_combined_interface_counter (mp->vnet_counter_type,
2143 first_sw_if_index + i, counter);
2150 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2152 vat_main_t *vam = &vat_main;
2155 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2157 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2166 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2168 vat_main_t *vam = &vat_main;
2171 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2173 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2181 static void vl_api_vnet_ip4_fib_counters_t_handler
2182 (vl_api_vnet_ip4_fib_counters_t * mp)
2187 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2188 (vl_api_vnet_ip4_fib_counters_t * mp)
2190 vat_main_t *vam = &vat_main;
2191 vl_api_ip4_fib_counter_t *v;
2192 ip4_fib_counter_t *counter;
2199 vrf_id = ntohl (mp->vrf_id);
2200 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2201 if (~0 == vrf_index)
2203 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2204 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2205 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2206 vec_validate (vam->ip4_fib_counters, vrf_index);
2207 vam->ip4_fib_counters[vrf_index] = NULL;
2210 vec_free (vam->ip4_fib_counters[vrf_index]);
2211 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2212 count = ntohl (mp->count);
2213 for (i = 0; i < count; i++)
2215 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2216 counter = &vam->ip4_fib_counters[vrf_index][i];
2217 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2218 counter->address = ip4;
2219 counter->address_length = v->address_length;
2220 counter->packets = clib_net_to_host_u64 (v->packets);
2221 counter->bytes = clib_net_to_host_u64 (v->bytes);
2226 static void vl_api_vnet_ip4_nbr_counters_t_handler
2227 (vl_api_vnet_ip4_nbr_counters_t * mp)
2232 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2233 (vl_api_vnet_ip4_nbr_counters_t * mp)
2235 vat_main_t *vam = &vat_main;
2236 vl_api_ip4_nbr_counter_t *v;
2237 ip4_nbr_counter_t *counter;
2242 sw_if_index = ntohl (mp->sw_if_index);
2243 count = ntohl (mp->count);
2244 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2247 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2249 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2250 for (i = 0; i < count; i++)
2252 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2253 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2254 counter->address.s_addr = v->address;
2255 counter->packets = clib_net_to_host_u64 (v->packets);
2256 counter->bytes = clib_net_to_host_u64 (v->bytes);
2257 counter->linkt = v->link_type;
2262 static void vl_api_vnet_ip6_fib_counters_t_handler
2263 (vl_api_vnet_ip6_fib_counters_t * mp)
2268 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2269 (vl_api_vnet_ip6_fib_counters_t * mp)
2271 vat_main_t *vam = &vat_main;
2272 vl_api_ip6_fib_counter_t *v;
2273 ip6_fib_counter_t *counter;
2274 struct in6_addr ip6;
2280 vrf_id = ntohl (mp->vrf_id);
2281 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2282 if (~0 == vrf_index)
2284 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2285 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2286 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2287 vec_validate (vam->ip6_fib_counters, vrf_index);
2288 vam->ip6_fib_counters[vrf_index] = NULL;
2291 vec_free (vam->ip6_fib_counters[vrf_index]);
2292 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2293 count = ntohl (mp->count);
2294 for (i = 0; i < count; i++)
2296 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2297 counter = &vam->ip6_fib_counters[vrf_index][i];
2298 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2299 counter->address = ip6;
2300 counter->address_length = v->address_length;
2301 counter->packets = clib_net_to_host_u64 (v->packets);
2302 counter->bytes = clib_net_to_host_u64 (v->bytes);
2307 static void vl_api_vnet_ip6_nbr_counters_t_handler
2308 (vl_api_vnet_ip6_nbr_counters_t * mp)
2313 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2314 (vl_api_vnet_ip6_nbr_counters_t * mp)
2316 vat_main_t *vam = &vat_main;
2317 vl_api_ip6_nbr_counter_t *v;
2318 ip6_nbr_counter_t *counter;
2319 struct in6_addr ip6;
2324 sw_if_index = ntohl (mp->sw_if_index);
2325 count = ntohl (mp->count);
2326 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2329 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2331 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2332 for (i = 0; i < count; i++)
2334 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2335 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2336 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2337 counter->address = ip6;
2338 counter->packets = clib_net_to_host_u64 (v->packets);
2339 counter->bytes = clib_net_to_host_u64 (v->bytes);
2344 static void vl_api_get_first_msg_id_reply_t_handler
2345 (vl_api_get_first_msg_id_reply_t * mp)
2347 vat_main_t *vam = &vat_main;
2348 i32 retval = ntohl (mp->retval);
2350 if (vam->async_mode)
2352 vam->async_errors += (retval < 0);
2356 vam->retval = retval;
2357 vam->result_ready = 1;
2361 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2365 static void vl_api_get_first_msg_id_reply_t_handler_json
2366 (vl_api_get_first_msg_id_reply_t * mp)
2368 vat_main_t *vam = &vat_main;
2369 vat_json_node_t node;
2371 vat_json_init_object (&node);
2372 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2373 vat_json_object_add_uint (&node, "first_msg_id",
2374 (uint) ntohs (mp->first_msg_id));
2376 vat_json_print (vam->ofp, &node);
2377 vat_json_free (&node);
2379 vam->retval = ntohl (mp->retval);
2380 vam->result_ready = 1;
2383 static void vl_api_get_node_graph_reply_t_handler
2384 (vl_api_get_node_graph_reply_t * mp)
2386 vat_main_t *vam = &vat_main;
2387 api_main_t *am = &api_main;
2388 i32 retval = ntohl (mp->retval);
2389 u8 *pvt_copy, *reply;
2394 if (vam->async_mode)
2396 vam->async_errors += (retval < 0);
2400 vam->retval = retval;
2401 vam->result_ready = 1;
2404 /* "Should never happen..." */
2408 reply = (u8 *) (mp->reply_in_shmem);
2409 pvt_copy = vec_dup (reply);
2411 /* Toss the shared-memory original... */
2412 pthread_mutex_lock (&am->vlib_rp->mutex);
2413 oldheap = svm_push_data_heap (am->vlib_rp);
2417 svm_pop_heap (oldheap);
2418 pthread_mutex_unlock (&am->vlib_rp->mutex);
2420 if (vam->graph_nodes)
2422 hash_free (vam->graph_node_index_by_name);
2424 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2426 node = vam->graph_nodes[i];
2427 vec_free (node->name);
2428 vec_free (node->next_nodes);
2431 vec_free (vam->graph_nodes);
2434 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2435 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2436 vec_free (pvt_copy);
2438 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2440 node = vam->graph_nodes[i];
2441 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2445 static void vl_api_get_node_graph_reply_t_handler_json
2446 (vl_api_get_node_graph_reply_t * mp)
2448 vat_main_t *vam = &vat_main;
2449 api_main_t *am = &api_main;
2451 vat_json_node_t node;
2454 /* $$$$ make this real? */
2455 vat_json_init_object (&node);
2456 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2457 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2459 reply = (u8 *) (mp->reply_in_shmem);
2461 /* Toss the shared-memory original... */
2462 pthread_mutex_lock (&am->vlib_rp->mutex);
2463 oldheap = svm_push_data_heap (am->vlib_rp);
2467 svm_pop_heap (oldheap);
2468 pthread_mutex_unlock (&am->vlib_rp->mutex);
2470 vat_json_print (vam->ofp, &node);
2471 vat_json_free (&node);
2473 vam->retval = ntohl (mp->retval);
2474 vam->result_ready = 1;
2478 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2480 vat_main_t *vam = &vat_main;
2485 s = format (s, "%=16d%=16d%=16d",
2486 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2490 s = format (s, "%=16U%=16d%=16d",
2491 mp->is_ipv6 ? format_ip6_address :
2493 mp->ip_address, mp->priority, mp->weight);
2496 print (vam->ofp, "%v", s);
2501 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2503 vat_main_t *vam = &vat_main;
2504 vat_json_node_t *node = NULL;
2505 struct in6_addr ip6;
2508 if (VAT_JSON_ARRAY != vam->json_tree.type)
2510 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2511 vat_json_init_array (&vam->json_tree);
2513 node = vat_json_array_add (&vam->json_tree);
2514 vat_json_init_object (node);
2516 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2517 vat_json_object_add_uint (node, "priority", mp->priority);
2518 vat_json_object_add_uint (node, "weight", mp->weight);
2521 vat_json_object_add_uint (node, "sw_if_index",
2522 clib_net_to_host_u32 (mp->sw_if_index));
2527 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2528 vat_json_object_add_ip6 (node, "address", ip6);
2532 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2533 vat_json_object_add_ip4 (node, "address", ip4);
2539 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2542 vat_main_t *vam = &vat_main;
2545 ls_name = format (0, "%s", mp->ls_name);
2547 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2553 vl_api_one_locator_set_details_t_handler_json
2554 (vl_api_one_locator_set_details_t * mp)
2556 vat_main_t *vam = &vat_main;
2557 vat_json_node_t *node = 0;
2560 ls_name = format (0, "%s", mp->ls_name);
2561 vec_add1 (ls_name, 0);
2563 if (VAT_JSON_ARRAY != vam->json_tree.type)
2565 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2566 vat_json_init_array (&vam->json_tree);
2568 node = vat_json_array_add (&vam->json_tree);
2570 vat_json_init_object (node);
2571 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2572 vat_json_object_add_uint (node, "ls_index",
2573 clib_net_to_host_u32 (mp->ls_index));
2578 format_lisp_flat_eid (u8 * s, va_list * args)
2580 u32 type = va_arg (*args, u32);
2581 u8 *eid = va_arg (*args, u8 *);
2582 u32 eid_len = va_arg (*args, u32);
2587 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2589 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2591 return format (s, "%U", format_ethernet_address, eid);
2597 format_lisp_eid_vat (u8 * s, va_list * args)
2599 u32 type = va_arg (*args, u32);
2600 u8 *eid = va_arg (*args, u8 *);
2601 u32 eid_len = va_arg (*args, u32);
2602 u8 *seid = va_arg (*args, u8 *);
2603 u32 seid_len = va_arg (*args, u32);
2604 u32 is_src_dst = va_arg (*args, u32);
2607 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2609 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2615 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2617 vat_main_t *vam = &vat_main;
2618 u8 *s = 0, *eid = 0;
2620 if (~0 == mp->locator_set_index)
2621 s = format (0, "action: %d", mp->action);
2623 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2625 eid = format (0, "%U", format_lisp_eid_vat,
2629 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2632 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2633 clib_net_to_host_u32 (mp->vni),
2635 mp->is_local ? "local" : "remote",
2636 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2637 clib_net_to_host_u16 (mp->key_id), mp->key);
2644 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2647 vat_main_t *vam = &vat_main;
2648 vat_json_node_t *node = 0;
2651 if (VAT_JSON_ARRAY != vam->json_tree.type)
2653 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2654 vat_json_init_array (&vam->json_tree);
2656 node = vat_json_array_add (&vam->json_tree);
2658 vat_json_init_object (node);
2659 if (~0 == mp->locator_set_index)
2660 vat_json_object_add_uint (node, "action", mp->action);
2662 vat_json_object_add_uint (node, "locator_set_index",
2663 clib_net_to_host_u32 (mp->locator_set_index));
2665 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2666 eid = format (0, "%U", format_lisp_eid_vat,
2670 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2672 vat_json_object_add_string_copy (node, "eid", eid);
2673 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2674 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2675 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2679 vat_json_object_add_uint (node, "key_id",
2680 clib_net_to_host_u16 (mp->key_id));
2681 vat_json_object_add_string_copy (node, "key", mp->key);
2687 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
2689 vat_main_t *vam = &vat_main;
2690 u8 *seid = 0, *deid = 0;
2691 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2693 deid = format (0, "%U", format_lisp_eid_vat,
2694 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2696 seid = format (0, "%U", format_lisp_eid_vat,
2697 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2703 format_ip_address_fcn = format_ip4_address;
2705 format_ip_address_fcn = format_ip6_address;
2708 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
2709 clib_net_to_host_u32 (mp->vni),
2711 format_ip_address_fcn, mp->lloc,
2712 format_ip_address_fcn, mp->rloc,
2713 clib_net_to_host_u32 (mp->pkt_count),
2714 clib_net_to_host_u32 (mp->bytes));
2721 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
2723 struct in6_addr ip6;
2725 vat_main_t *vam = &vat_main;
2726 vat_json_node_t *node = 0;
2727 u8 *deid = 0, *seid = 0;
2729 if (VAT_JSON_ARRAY != vam->json_tree.type)
2731 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2732 vat_json_init_array (&vam->json_tree);
2734 node = vat_json_array_add (&vam->json_tree);
2736 vat_json_init_object (node);
2737 deid = format (0, "%U", format_lisp_eid_vat,
2738 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2740 seid = format (0, "%U", format_lisp_eid_vat,
2741 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2746 vat_json_object_add_string_copy (node, "seid", seid);
2747 vat_json_object_add_string_copy (node, "deid", deid);
2748 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2752 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
2753 vat_json_object_add_ip4 (node, "lloc", ip4);
2754 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
2755 vat_json_object_add_ip4 (node, "rloc", ip4);
2759 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
2760 vat_json_object_add_ip6 (node, "lloc", ip6);
2761 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
2762 vat_json_object_add_ip6 (node, "rloc", ip6);
2764 vat_json_object_add_uint (node, "pkt_count",
2765 clib_net_to_host_u32 (mp->pkt_count));
2766 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
2773 vl_api_one_eid_table_map_details_t_handler
2774 (vl_api_one_eid_table_map_details_t * mp)
2776 vat_main_t *vam = &vat_main;
2778 u8 *line = format (0, "%=10d%=10d",
2779 clib_net_to_host_u32 (mp->vni),
2780 clib_net_to_host_u32 (mp->dp_table));
2781 print (vam->ofp, "%v", line);
2786 vl_api_one_eid_table_map_details_t_handler_json
2787 (vl_api_one_eid_table_map_details_t * mp)
2789 vat_main_t *vam = &vat_main;
2790 vat_json_node_t *node = NULL;
2792 if (VAT_JSON_ARRAY != vam->json_tree.type)
2794 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2795 vat_json_init_array (&vam->json_tree);
2797 node = vat_json_array_add (&vam->json_tree);
2798 vat_json_init_object (node);
2799 vat_json_object_add_uint (node, "dp_table",
2800 clib_net_to_host_u32 (mp->dp_table));
2801 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2805 vl_api_one_eid_table_vni_details_t_handler
2806 (vl_api_one_eid_table_vni_details_t * mp)
2808 vat_main_t *vam = &vat_main;
2810 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2811 print (vam->ofp, "%v", line);
2816 vl_api_one_eid_table_vni_details_t_handler_json
2817 (vl_api_one_eid_table_vni_details_t * mp)
2819 vat_main_t *vam = &vat_main;
2820 vat_json_node_t *node = NULL;
2822 if (VAT_JSON_ARRAY != vam->json_tree.type)
2824 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2825 vat_json_init_array (&vam->json_tree);
2827 node = vat_json_array_add (&vam->json_tree);
2828 vat_json_init_object (node);
2829 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2833 vl_api_show_one_map_register_state_reply_t_handler
2834 (vl_api_show_one_map_register_state_reply_t * mp)
2836 vat_main_t *vam = &vat_main;
2837 int retval = clib_net_to_host_u32 (mp->retval);
2839 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2841 vam->retval = retval;
2842 vam->result_ready = 1;
2846 vl_api_show_one_map_register_state_reply_t_handler_json
2847 (vl_api_show_one_map_register_state_reply_t * mp)
2849 vat_main_t *vam = &vat_main;
2850 vat_json_node_t _node, *node = &_node;
2851 int retval = clib_net_to_host_u32 (mp->retval);
2853 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2855 vat_json_init_object (node);
2856 vat_json_object_add_string_copy (node, "state", s);
2858 vat_json_print (vam->ofp, node);
2859 vat_json_free (node);
2861 vam->retval = retval;
2862 vam->result_ready = 1;
2867 vl_api_show_one_rloc_probe_state_reply_t_handler
2868 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2870 vat_main_t *vam = &vat_main;
2871 int retval = clib_net_to_host_u32 (mp->retval);
2876 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2878 vam->retval = retval;
2879 vam->result_ready = 1;
2883 vl_api_show_one_rloc_probe_state_reply_t_handler_json
2884 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2886 vat_main_t *vam = &vat_main;
2887 vat_json_node_t _node, *node = &_node;
2888 int retval = clib_net_to_host_u32 (mp->retval);
2890 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2891 vat_json_init_object (node);
2892 vat_json_object_add_string_copy (node, "state", s);
2894 vat_json_print (vam->ofp, node);
2895 vat_json_free (node);
2897 vam->retval = retval;
2898 vam->result_ready = 1;
2903 vl_api_show_one_stats_enable_disable_reply_t_handler
2904 (vl_api_show_one_stats_enable_disable_reply_t * mp)
2906 vat_main_t *vam = &vat_main;
2907 int retval = clib_net_to_host_u32 (mp->retval);
2912 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
2914 vam->retval = retval;
2915 vam->result_ready = 1;
2919 vl_api_show_one_stats_enable_disable_reply_t_handler_json
2920 (vl_api_show_one_stats_enable_disable_reply_t * mp)
2922 vat_main_t *vam = &vat_main;
2923 vat_json_node_t _node, *node = &_node;
2924 int retval = clib_net_to_host_u32 (mp->retval);
2926 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
2927 vat_json_init_object (node);
2928 vat_json_object_add_string_copy (node, "state", s);
2930 vat_json_print (vam->ofp, node);
2931 vat_json_free (node);
2933 vam->retval = retval;
2934 vam->result_ready = 1;
2939 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
2941 e->dp_table = clib_net_to_host_u32 (e->dp_table);
2942 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
2946 gpe_fwd_entries_get_reply_t_net_to_host
2947 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2951 mp->count = clib_net_to_host_u32 (mp->count);
2952 for (i = 0; i < mp->count; i++)
2954 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
2959 format_gpe_encap_mode (u8 * s, va_list * args)
2961 u32 mode = va_arg (*args, u32);
2966 return format (s, "lisp");
2968 return format (s, "vxlan");
2974 vl_api_gpe_get_encap_mode_reply_t_handler
2975 (vl_api_gpe_get_encap_mode_reply_t * mp)
2977 vat_main_t *vam = &vat_main;
2979 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
2980 vam->retval = ntohl (mp->retval);
2981 vam->result_ready = 1;
2985 vl_api_gpe_get_encap_mode_reply_t_handler_json
2986 (vl_api_gpe_get_encap_mode_reply_t * mp)
2988 vat_main_t *vam = &vat_main;
2989 vat_json_node_t node;
2991 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
2992 vec_add1 (encap_mode, 0);
2994 vat_json_init_object (&node);
2995 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
2997 vec_free (encap_mode);
2998 vat_json_print (vam->ofp, &node);
2999 vat_json_free (&node);
3001 vam->retval = ntohl (mp->retval);
3002 vam->result_ready = 1;
3006 vl_api_gpe_fwd_entry_path_details_t_handler
3007 (vl_api_gpe_fwd_entry_path_details_t * mp)
3009 vat_main_t *vam = &vat_main;
3010 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3012 if (mp->lcl_loc.is_ip4)
3013 format_ip_address_fcn = format_ip4_address;
3015 format_ip_address_fcn = format_ip6_address;
3017 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3018 format_ip_address_fcn, &mp->lcl_loc,
3019 format_ip_address_fcn, &mp->rmt_loc);
3023 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3025 struct in6_addr ip6;
3030 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3031 vat_json_object_add_ip4 (n, "address", ip4);
3035 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3036 vat_json_object_add_ip6 (n, "address", ip6);
3038 vat_json_object_add_uint (n, "weight", loc->weight);
3042 vl_api_gpe_fwd_entry_path_details_t_handler_json
3043 (vl_api_gpe_fwd_entry_path_details_t * mp)
3045 vat_main_t *vam = &vat_main;
3046 vat_json_node_t *node = NULL;
3047 vat_json_node_t *loc_node;
3049 if (VAT_JSON_ARRAY != vam->json_tree.type)
3051 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3052 vat_json_init_array (&vam->json_tree);
3054 node = vat_json_array_add (&vam->json_tree);
3055 vat_json_init_object (node);
3057 loc_node = vat_json_object_add (node, "local_locator");
3058 vat_json_init_object (loc_node);
3059 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3061 loc_node = vat_json_object_add (node, "remote_locator");
3062 vat_json_init_object (loc_node);
3063 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3067 vl_api_gpe_fwd_entries_get_reply_t_handler
3068 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3070 vat_main_t *vam = &vat_main;
3072 int retval = clib_net_to_host_u32 (mp->retval);
3073 vl_api_gpe_fwd_entry_t *e;
3078 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3080 for (i = 0; i < mp->count; i++)
3082 e = &mp->entries[i];
3083 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3084 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3085 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3089 vam->retval = retval;
3090 vam->result_ready = 1;
3094 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3095 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3098 vat_main_t *vam = &vat_main;
3099 vat_json_node_t *e = 0, root;
3101 int retval = clib_net_to_host_u32 (mp->retval);
3102 vl_api_gpe_fwd_entry_t *fwd;
3107 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3108 vat_json_init_array (&root);
3110 for (i = 0; i < mp->count; i++)
3112 e = vat_json_array_add (&root);
3113 fwd = &mp->entries[i];
3115 vat_json_init_object (e);
3116 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3117 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3119 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3120 fwd->leid_prefix_len);
3122 vat_json_object_add_string_copy (e, "leid", s);
3125 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3126 fwd->reid_prefix_len);
3128 vat_json_object_add_string_copy (e, "reid", s);
3132 vat_json_print (vam->ofp, &root);
3133 vat_json_free (&root);
3136 vam->retval = retval;
3137 vam->result_ready = 1;
3141 vl_api_one_adjacencies_get_reply_t_handler
3142 (vl_api_one_adjacencies_get_reply_t * mp)
3144 vat_main_t *vam = &vat_main;
3146 int retval = clib_net_to_host_u32 (mp->retval);
3147 vl_api_one_adjacency_t *a;
3152 n = clib_net_to_host_u32 (mp->count);
3154 for (i = 0; i < n; i++)
3156 a = &mp->adjacencies[i];
3157 print (vam->ofp, "%U %40U",
3158 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3159 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3163 vam->retval = retval;
3164 vam->result_ready = 1;
3168 vl_api_one_adjacencies_get_reply_t_handler_json
3169 (vl_api_one_adjacencies_get_reply_t * mp)
3172 vat_main_t *vam = &vat_main;
3173 vat_json_node_t *e = 0, root;
3175 int retval = clib_net_to_host_u32 (mp->retval);
3176 vl_api_one_adjacency_t *a;
3181 n = clib_net_to_host_u32 (mp->count);
3182 vat_json_init_array (&root);
3184 for (i = 0; i < n; i++)
3186 e = vat_json_array_add (&root);
3187 a = &mp->adjacencies[i];
3189 vat_json_init_object (e);
3190 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3191 a->leid_prefix_len);
3193 vat_json_object_add_string_copy (e, "leid", s);
3196 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3197 a->reid_prefix_len);
3199 vat_json_object_add_string_copy (e, "reid", s);
3203 vat_json_print (vam->ofp, &root);
3204 vat_json_free (&root);
3207 vam->retval = retval;
3208 vam->result_ready = 1;
3212 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3214 vat_main_t *vam = &vat_main;
3216 print (vam->ofp, "%=20U",
3217 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3222 vl_api_one_map_server_details_t_handler_json
3223 (vl_api_one_map_server_details_t * mp)
3225 vat_main_t *vam = &vat_main;
3226 vat_json_node_t *node = NULL;
3227 struct in6_addr ip6;
3230 if (VAT_JSON_ARRAY != vam->json_tree.type)
3232 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3233 vat_json_init_array (&vam->json_tree);
3235 node = vat_json_array_add (&vam->json_tree);
3237 vat_json_init_object (node);
3240 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3241 vat_json_object_add_ip6 (node, "map-server", ip6);
3245 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3246 vat_json_object_add_ip4 (node, "map-server", ip4);
3251 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3254 vat_main_t *vam = &vat_main;
3256 print (vam->ofp, "%=20U",
3257 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3262 vl_api_one_map_resolver_details_t_handler_json
3263 (vl_api_one_map_resolver_details_t * mp)
3265 vat_main_t *vam = &vat_main;
3266 vat_json_node_t *node = NULL;
3267 struct in6_addr ip6;
3270 if (VAT_JSON_ARRAY != vam->json_tree.type)
3272 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3273 vat_json_init_array (&vam->json_tree);
3275 node = vat_json_array_add (&vam->json_tree);
3277 vat_json_init_object (node);
3280 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3281 vat_json_object_add_ip6 (node, "map resolver", ip6);
3285 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3286 vat_json_object_add_ip4 (node, "map resolver", ip4);
3291 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3293 vat_main_t *vam = &vat_main;
3294 i32 retval = ntohl (mp->retval);
3298 print (vam->ofp, "feature: %s\ngpe: %s",
3299 mp->feature_status ? "enabled" : "disabled",
3300 mp->gpe_status ? "enabled" : "disabled");
3303 vam->retval = retval;
3304 vam->result_ready = 1;
3308 vl_api_show_one_status_reply_t_handler_json
3309 (vl_api_show_one_status_reply_t * mp)
3311 vat_main_t *vam = &vat_main;
3312 vat_json_node_t node;
3313 u8 *gpe_status = NULL;
3314 u8 *feature_status = NULL;
3316 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3317 feature_status = format (0, "%s",
3318 mp->feature_status ? "enabled" : "disabled");
3319 vec_add1 (gpe_status, 0);
3320 vec_add1 (feature_status, 0);
3322 vat_json_init_object (&node);
3323 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3324 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3326 vec_free (gpe_status);
3327 vec_free (feature_status);
3329 vat_json_print (vam->ofp, &node);
3330 vat_json_free (&node);
3332 vam->retval = ntohl (mp->retval);
3333 vam->result_ready = 1;
3337 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3338 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3340 vat_main_t *vam = &vat_main;
3341 i32 retval = ntohl (mp->retval);
3345 print (vam->ofp, "%=20s", mp->locator_set_name);
3348 vam->retval = retval;
3349 vam->result_ready = 1;
3353 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3354 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3356 vat_main_t *vam = &vat_main;
3357 vat_json_node_t *node = NULL;
3359 if (VAT_JSON_ARRAY != vam->json_tree.type)
3361 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3362 vat_json_init_array (&vam->json_tree);
3364 node = vat_json_array_add (&vam->json_tree);
3366 vat_json_init_object (node);
3367 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3369 vat_json_print (vam->ofp, node);
3370 vat_json_free (node);
3372 vam->retval = ntohl (mp->retval);
3373 vam->result_ready = 1;
3377 format_lisp_map_request_mode (u8 * s, va_list * args)
3379 u32 mode = va_arg (*args, u32);
3384 return format (0, "dst-only");
3386 return format (0, "src-dst");
3392 vl_api_show_one_map_request_mode_reply_t_handler
3393 (vl_api_show_one_map_request_mode_reply_t * mp)
3395 vat_main_t *vam = &vat_main;
3396 i32 retval = ntohl (mp->retval);
3400 u32 mode = mp->mode;
3401 print (vam->ofp, "map_request_mode: %U",
3402 format_lisp_map_request_mode, mode);
3405 vam->retval = retval;
3406 vam->result_ready = 1;
3410 vl_api_show_one_map_request_mode_reply_t_handler_json
3411 (vl_api_show_one_map_request_mode_reply_t * mp)
3413 vat_main_t *vam = &vat_main;
3414 vat_json_node_t node;
3419 s = format (0, "%U", format_lisp_map_request_mode, mode);
3422 vat_json_init_object (&node);
3423 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3424 vat_json_print (vam->ofp, &node);
3425 vat_json_free (&node);
3428 vam->retval = ntohl (mp->retval);
3429 vam->result_ready = 1;
3433 vl_api_show_one_use_petr_reply_t_handler
3434 (vl_api_show_one_use_petr_reply_t * mp)
3436 vat_main_t *vam = &vat_main;
3437 i32 retval = ntohl (mp->retval);
3441 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
3444 print (vam->ofp, "Proxy-ETR address; %U",
3445 mp->is_ip4 ? format_ip4_address : format_ip6_address,
3450 vam->retval = retval;
3451 vam->result_ready = 1;
3455 vl_api_show_one_use_petr_reply_t_handler_json
3456 (vl_api_show_one_use_petr_reply_t * mp)
3458 vat_main_t *vam = &vat_main;
3459 vat_json_node_t node;
3462 struct in6_addr ip6;
3464 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3465 vec_add1 (status, 0);
3467 vat_json_init_object (&node);
3468 vat_json_object_add_string_copy (&node, "status", status);
3473 clib_memcpy (&ip6, mp->address, sizeof (ip6));
3474 vat_json_object_add_ip6 (&node, "address", ip6);
3478 clib_memcpy (&ip4, mp->address, sizeof (ip4));
3479 vat_json_object_add_ip4 (&node, "address", ip4);
3485 vat_json_print (vam->ofp, &node);
3486 vat_json_free (&node);
3488 vam->retval = ntohl (mp->retval);
3489 vam->result_ready = 1;
3493 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3495 vat_main_t *vam = &vat_main;
3496 i32 retval = ntohl (mp->retval);
3500 print (vam->ofp, "%-20s%-16s",
3501 mp->status ? "enabled" : "disabled",
3502 mp->status ? (char *) mp->locator_set_name : "");
3505 vam->retval = retval;
3506 vam->result_ready = 1;
3510 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3512 vat_main_t *vam = &vat_main;
3513 vat_json_node_t node;
3516 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3517 vec_add1 (status, 0);
3519 vat_json_init_object (&node);
3520 vat_json_object_add_string_copy (&node, "status", status);
3523 vat_json_object_add_string_copy (&node, "locator_set",
3524 mp->locator_set_name);
3529 vat_json_print (vam->ofp, &node);
3530 vat_json_free (&node);
3532 vam->retval = ntohl (mp->retval);
3533 vam->result_ready = 1;
3537 format_policer_type (u8 * s, va_list * va)
3539 u32 i = va_arg (*va, u32);
3541 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3542 s = format (s, "1r2c");
3543 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3544 s = format (s, "1r3c");
3545 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3546 s = format (s, "2r3c-2698");
3547 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3548 s = format (s, "2r3c-4115");
3549 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3550 s = format (s, "2r3c-mef5cf1");
3552 s = format (s, "ILLEGAL");
3557 format_policer_rate_type (u8 * s, va_list * va)
3559 u32 i = va_arg (*va, u32);
3561 if (i == SSE2_QOS_RATE_KBPS)
3562 s = format (s, "kbps");
3563 else if (i == SSE2_QOS_RATE_PPS)
3564 s = format (s, "pps");
3566 s = format (s, "ILLEGAL");
3571 format_policer_round_type (u8 * s, va_list * va)
3573 u32 i = va_arg (*va, u32);
3575 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3576 s = format (s, "closest");
3577 else if (i == SSE2_QOS_ROUND_TO_UP)
3578 s = format (s, "up");
3579 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3580 s = format (s, "down");
3582 s = format (s, "ILLEGAL");
3587 format_policer_action_type (u8 * s, va_list * va)
3589 u32 i = va_arg (*va, u32);
3591 if (i == SSE2_QOS_ACTION_DROP)
3592 s = format (s, "drop");
3593 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3594 s = format (s, "transmit");
3595 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3596 s = format (s, "mark-and-transmit");
3598 s = format (s, "ILLEGAL");
3603 format_dscp (u8 * s, va_list * va)
3605 u32 i = va_arg (*va, u32);
3610 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3614 return format (s, "ILLEGAL");
3616 s = format (s, "%s", t);
3621 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3623 vat_main_t *vam = &vat_main;
3624 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3626 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3627 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3629 conform_dscp_str = format (0, "");
3631 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3632 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3634 exceed_dscp_str = format (0, "");
3636 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3637 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3639 violate_dscp_str = format (0, "");
3641 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3642 "rate type %U, round type %U, %s rate, %s color-aware, "
3643 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3644 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3645 "conform action %U%s, exceed action %U%s, violate action %U%s",
3647 format_policer_type, mp->type,
3650 clib_net_to_host_u64 (mp->cb),
3651 clib_net_to_host_u64 (mp->eb),
3652 format_policer_rate_type, mp->rate_type,
3653 format_policer_round_type, mp->round_type,
3654 mp->single_rate ? "single" : "dual",
3655 mp->color_aware ? "is" : "not",
3656 ntohl (mp->cir_tokens_per_period),
3657 ntohl (mp->pir_tokens_per_period),
3659 ntohl (mp->current_limit),
3660 ntohl (mp->current_bucket),
3661 ntohl (mp->extended_limit),
3662 ntohl (mp->extended_bucket),
3663 clib_net_to_host_u64 (mp->last_update_time),
3664 format_policer_action_type, mp->conform_action_type,
3666 format_policer_action_type, mp->exceed_action_type,
3668 format_policer_action_type, mp->violate_action_type,
3671 vec_free (conform_dscp_str);
3672 vec_free (exceed_dscp_str);
3673 vec_free (violate_dscp_str);
3676 static void vl_api_policer_details_t_handler_json
3677 (vl_api_policer_details_t * mp)
3679 vat_main_t *vam = &vat_main;
3680 vat_json_node_t *node;
3681 u8 *rate_type_str, *round_type_str, *type_str;
3682 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3684 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3686 format (0, "%U", format_policer_round_type, mp->round_type);
3687 type_str = format (0, "%U", format_policer_type, mp->type);
3688 conform_action_str = format (0, "%U", format_policer_action_type,
3689 mp->conform_action_type);
3690 exceed_action_str = format (0, "%U", format_policer_action_type,
3691 mp->exceed_action_type);
3692 violate_action_str = format (0, "%U", format_policer_action_type,
3693 mp->violate_action_type);
3695 if (VAT_JSON_ARRAY != vam->json_tree.type)
3697 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3698 vat_json_init_array (&vam->json_tree);
3700 node = vat_json_array_add (&vam->json_tree);
3702 vat_json_init_object (node);
3703 vat_json_object_add_string_copy (node, "name", mp->name);
3704 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3705 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3706 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
3707 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
3708 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3709 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3710 vat_json_object_add_string_copy (node, "type", type_str);
3711 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3712 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3713 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3714 vat_json_object_add_uint (node, "cir_tokens_per_period",
3715 ntohl (mp->cir_tokens_per_period));
3716 vat_json_object_add_uint (node, "eir_tokens_per_period",
3717 ntohl (mp->pir_tokens_per_period));
3718 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3719 vat_json_object_add_uint (node, "current_bucket",
3720 ntohl (mp->current_bucket));
3721 vat_json_object_add_uint (node, "extended_limit",
3722 ntohl (mp->extended_limit));
3723 vat_json_object_add_uint (node, "extended_bucket",
3724 ntohl (mp->extended_bucket));
3725 vat_json_object_add_uint (node, "last_update_time",
3726 ntohl (mp->last_update_time));
3727 vat_json_object_add_string_copy (node, "conform_action",
3728 conform_action_str);
3729 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3731 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3732 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3733 vec_free (dscp_str);
3735 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3736 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3738 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3739 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3740 vec_free (dscp_str);
3742 vat_json_object_add_string_copy (node, "violate_action",
3743 violate_action_str);
3744 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3746 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3747 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3748 vec_free (dscp_str);
3751 vec_free (rate_type_str);
3752 vec_free (round_type_str);
3753 vec_free (type_str);
3754 vec_free (conform_action_str);
3755 vec_free (exceed_action_str);
3756 vec_free (violate_action_str);
3760 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3763 vat_main_t *vam = &vat_main;
3764 int i, count = ntohl (mp->count);
3767 print (vam->ofp, "classify table ids (%d) : ", count);
3768 for (i = 0; i < count; i++)
3770 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3771 print (vam->ofp, (i < count - 1) ? "," : "");
3773 vam->retval = ntohl (mp->retval);
3774 vam->result_ready = 1;
3778 vl_api_classify_table_ids_reply_t_handler_json
3779 (vl_api_classify_table_ids_reply_t * mp)
3781 vat_main_t *vam = &vat_main;
3782 int i, count = ntohl (mp->count);
3786 vat_json_node_t node;
3788 vat_json_init_object (&node);
3789 for (i = 0; i < count; i++)
3791 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3793 vat_json_print (vam->ofp, &node);
3794 vat_json_free (&node);
3796 vam->retval = ntohl (mp->retval);
3797 vam->result_ready = 1;
3801 vl_api_classify_table_by_interface_reply_t_handler
3802 (vl_api_classify_table_by_interface_reply_t * mp)
3804 vat_main_t *vam = &vat_main;
3807 table_id = ntohl (mp->l2_table_id);
3809 print (vam->ofp, "l2 table id : %d", table_id);
3811 print (vam->ofp, "l2 table id : No input ACL tables configured");
3812 table_id = ntohl (mp->ip4_table_id);
3814 print (vam->ofp, "ip4 table id : %d", table_id);
3816 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3817 table_id = ntohl (mp->ip6_table_id);
3819 print (vam->ofp, "ip6 table id : %d", table_id);
3821 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3822 vam->retval = ntohl (mp->retval);
3823 vam->result_ready = 1;
3827 vl_api_classify_table_by_interface_reply_t_handler_json
3828 (vl_api_classify_table_by_interface_reply_t * mp)
3830 vat_main_t *vam = &vat_main;
3831 vat_json_node_t node;
3833 vat_json_init_object (&node);
3835 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3836 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3837 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3839 vat_json_print (vam->ofp, &node);
3840 vat_json_free (&node);
3842 vam->retval = ntohl (mp->retval);
3843 vam->result_ready = 1;
3846 static void vl_api_policer_add_del_reply_t_handler
3847 (vl_api_policer_add_del_reply_t * mp)
3849 vat_main_t *vam = &vat_main;
3850 i32 retval = ntohl (mp->retval);
3851 if (vam->async_mode)
3853 vam->async_errors += (retval < 0);
3857 vam->retval = retval;
3858 vam->result_ready = 1;
3859 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3861 * Note: this is just barely thread-safe, depends on
3862 * the main thread spinning waiting for an answer...
3864 errmsg ("policer index %d", ntohl (mp->policer_index));
3868 static void vl_api_policer_add_del_reply_t_handler_json
3869 (vl_api_policer_add_del_reply_t * mp)
3871 vat_main_t *vam = &vat_main;
3872 vat_json_node_t node;
3874 vat_json_init_object (&node);
3875 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3876 vat_json_object_add_uint (&node, "policer_index",
3877 ntohl (mp->policer_index));
3879 vat_json_print (vam->ofp, &node);
3880 vat_json_free (&node);
3882 vam->retval = ntohl (mp->retval);
3883 vam->result_ready = 1;
3886 /* Format hex dump. */
3888 format_hex_bytes (u8 * s, va_list * va)
3890 u8 *bytes = va_arg (*va, u8 *);
3891 int n_bytes = va_arg (*va, int);
3894 /* Print short or long form depending on byte count. */
3895 uword short_form = n_bytes <= 32;
3896 uword indent = format_get_indent (s);
3901 for (i = 0; i < n_bytes; i++)
3903 if (!short_form && (i % 32) == 0)
3904 s = format (s, "%08x: ", i);
3905 s = format (s, "%02x", bytes[i]);
3906 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3907 s = format (s, "\n%U", format_white_space, indent);
3914 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3917 vat_main_t *vam = &vat_main;
3918 i32 retval = ntohl (mp->retval);
3921 print (vam->ofp, "classify table info :");
3922 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3923 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3924 ntohl (mp->miss_next_index));
3925 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3926 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3927 ntohl (mp->match_n_vectors));
3928 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3929 ntohl (mp->mask_length));
3931 vam->retval = retval;
3932 vam->result_ready = 1;
3936 vl_api_classify_table_info_reply_t_handler_json
3937 (vl_api_classify_table_info_reply_t * mp)
3939 vat_main_t *vam = &vat_main;
3940 vat_json_node_t node;
3942 i32 retval = ntohl (mp->retval);
3945 vat_json_init_object (&node);
3947 vat_json_object_add_int (&node, "sessions",
3948 ntohl (mp->active_sessions));
3949 vat_json_object_add_int (&node, "nexttbl",
3950 ntohl (mp->next_table_index));
3951 vat_json_object_add_int (&node, "nextnode",
3952 ntohl (mp->miss_next_index));
3953 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3954 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3955 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3956 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3957 ntohl (mp->mask_length), 0);
3958 vat_json_object_add_string_copy (&node, "mask", s);
3960 vat_json_print (vam->ofp, &node);
3961 vat_json_free (&node);
3963 vam->retval = ntohl (mp->retval);
3964 vam->result_ready = 1;
3968 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3971 vat_main_t *vam = &vat_main;
3973 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3974 ntohl (mp->hit_next_index), ntohl (mp->advance),
3975 ntohl (mp->opaque_index));
3976 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3977 ntohl (mp->match_length));
3981 vl_api_classify_session_details_t_handler_json
3982 (vl_api_classify_session_details_t * mp)
3984 vat_main_t *vam = &vat_main;
3985 vat_json_node_t *node = NULL;
3987 if (VAT_JSON_ARRAY != vam->json_tree.type)
3989 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3990 vat_json_init_array (&vam->json_tree);
3992 node = vat_json_array_add (&vam->json_tree);
3994 vat_json_init_object (node);
3995 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3996 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3997 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3999 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4001 vat_json_object_add_string_copy (node, "match", s);
4004 static void vl_api_pg_create_interface_reply_t_handler
4005 (vl_api_pg_create_interface_reply_t * mp)
4007 vat_main_t *vam = &vat_main;
4009 vam->retval = ntohl (mp->retval);
4010 vam->result_ready = 1;
4013 static void vl_api_pg_create_interface_reply_t_handler_json
4014 (vl_api_pg_create_interface_reply_t * mp)
4016 vat_main_t *vam = &vat_main;
4017 vat_json_node_t node;
4019 i32 retval = ntohl (mp->retval);
4022 vat_json_init_object (&node);
4024 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4026 vat_json_print (vam->ofp, &node);
4027 vat_json_free (&node);
4029 vam->retval = ntohl (mp->retval);
4030 vam->result_ready = 1;
4033 static void vl_api_policer_classify_details_t_handler
4034 (vl_api_policer_classify_details_t * mp)
4036 vat_main_t *vam = &vat_main;
4038 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4039 ntohl (mp->table_index));
4042 static void vl_api_policer_classify_details_t_handler_json
4043 (vl_api_policer_classify_details_t * mp)
4045 vat_main_t *vam = &vat_main;
4046 vat_json_node_t *node;
4048 if (VAT_JSON_ARRAY != vam->json_tree.type)
4050 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4051 vat_json_init_array (&vam->json_tree);
4053 node = vat_json_array_add (&vam->json_tree);
4055 vat_json_init_object (node);
4056 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4057 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4060 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4061 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4063 vat_main_t *vam = &vat_main;
4064 i32 retval = ntohl (mp->retval);
4065 if (vam->async_mode)
4067 vam->async_errors += (retval < 0);
4071 vam->retval = retval;
4072 vam->sw_if_index = ntohl (mp->sw_if_index);
4073 vam->result_ready = 1;
4077 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4078 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4080 vat_main_t *vam = &vat_main;
4081 vat_json_node_t node;
4083 vat_json_init_object (&node);
4084 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4085 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4087 vat_json_print (vam->ofp, &node);
4088 vat_json_free (&node);
4090 vam->retval = ntohl (mp->retval);
4091 vam->result_ready = 1;
4094 static void vl_api_flow_classify_details_t_handler
4095 (vl_api_flow_classify_details_t * mp)
4097 vat_main_t *vam = &vat_main;
4099 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4100 ntohl (mp->table_index));
4103 static void vl_api_flow_classify_details_t_handler_json
4104 (vl_api_flow_classify_details_t * mp)
4106 vat_main_t *vam = &vat_main;
4107 vat_json_node_t *node;
4109 if (VAT_JSON_ARRAY != vam->json_tree.type)
4111 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4112 vat_json_init_array (&vam->json_tree);
4114 node = vat_json_array_add (&vam->json_tree);
4116 vat_json_init_object (node);
4117 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4118 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4123 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4124 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4125 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4126 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4127 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4128 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4129 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4130 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4131 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4132 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4135 * Generate boilerplate reply handlers, which
4136 * dig the return value out of the xxx_reply_t API message,
4137 * stick it into vam->retval, and set vam->result_ready
4139 * Could also do this by pointing N message decode slots at
4140 * a single function, but that could break in subtle ways.
4143 #define foreach_standard_reply_retval_handler \
4144 _(sw_interface_set_flags_reply) \
4145 _(sw_interface_add_del_address_reply) \
4146 _(sw_interface_set_table_reply) \
4147 _(sw_interface_set_mpls_enable_reply) \
4148 _(sw_interface_set_vpath_reply) \
4149 _(sw_interface_set_vxlan_bypass_reply) \
4150 _(sw_interface_set_l2_bridge_reply) \
4151 _(bridge_domain_add_del_reply) \
4152 _(sw_interface_set_l2_xconnect_reply) \
4153 _(l2fib_add_del_reply) \
4154 _(ip_add_del_route_reply) \
4155 _(ip_mroute_add_del_reply) \
4156 _(mpls_route_add_del_reply) \
4157 _(mpls_ip_bind_unbind_reply) \
4158 _(proxy_arp_add_del_reply) \
4159 _(proxy_arp_intfc_enable_disable_reply) \
4160 _(sw_interface_set_unnumbered_reply) \
4161 _(ip_neighbor_add_del_reply) \
4162 _(reset_vrf_reply) \
4163 _(oam_add_del_reply) \
4164 _(reset_fib_reply) \
4165 _(dhcp_proxy_config_reply) \
4166 _(dhcp_proxy_set_vss_reply) \
4167 _(dhcp_client_config_reply) \
4168 _(set_ip_flow_hash_reply) \
4169 _(sw_interface_ip6_enable_disable_reply) \
4170 _(sw_interface_ip6_set_link_local_address_reply) \
4171 _(ip6nd_proxy_add_del_reply) \
4172 _(sw_interface_ip6nd_ra_prefix_reply) \
4173 _(sw_interface_ip6nd_ra_config_reply) \
4174 _(set_arp_neighbor_limit_reply) \
4175 _(l2_patch_add_del_reply) \
4176 _(sr_policy_add_reply) \
4177 _(sr_policy_mod_reply) \
4178 _(sr_policy_del_reply) \
4179 _(sr_localsid_add_del_reply) \
4180 _(sr_steering_add_del_reply) \
4181 _(classify_add_del_session_reply) \
4182 _(classify_set_interface_ip_table_reply) \
4183 _(classify_set_interface_l2_tables_reply) \
4184 _(l2tpv3_set_tunnel_cookies_reply) \
4185 _(l2tpv3_interface_enable_disable_reply) \
4186 _(l2tpv3_set_lookup_key_reply) \
4187 _(l2_fib_clear_table_reply) \
4188 _(l2_interface_efp_filter_reply) \
4189 _(l2_interface_vlan_tag_rewrite_reply) \
4190 _(modify_vhost_user_if_reply) \
4191 _(delete_vhost_user_if_reply) \
4192 _(want_ip4_arp_events_reply) \
4193 _(want_ip6_nd_events_reply) \
4194 _(input_acl_set_interface_reply) \
4195 _(ipsec_spd_add_del_reply) \
4196 _(ipsec_interface_add_del_spd_reply) \
4197 _(ipsec_spd_add_del_entry_reply) \
4198 _(ipsec_sad_add_del_entry_reply) \
4199 _(ipsec_sa_set_key_reply) \
4200 _(ikev2_profile_add_del_reply) \
4201 _(ikev2_profile_set_auth_reply) \
4202 _(ikev2_profile_set_id_reply) \
4203 _(ikev2_profile_set_ts_reply) \
4204 _(ikev2_set_local_key_reply) \
4205 _(ikev2_set_responder_reply) \
4206 _(ikev2_set_ike_transforms_reply) \
4207 _(ikev2_set_esp_transforms_reply) \
4208 _(ikev2_set_sa_lifetime_reply) \
4209 _(ikev2_initiate_sa_init_reply) \
4210 _(ikev2_initiate_del_ike_sa_reply) \
4211 _(ikev2_initiate_del_child_sa_reply) \
4212 _(ikev2_initiate_rekey_child_sa_reply) \
4213 _(delete_loopback_reply) \
4214 _(bd_ip_mac_add_del_reply) \
4215 _(map_del_domain_reply) \
4216 _(map_add_del_rule_reply) \
4217 _(want_interface_events_reply) \
4218 _(want_stats_reply) \
4219 _(cop_interface_enable_disable_reply) \
4220 _(cop_whitelist_enable_disable_reply) \
4221 _(sw_interface_clear_stats_reply) \
4222 _(ioam_enable_reply) \
4223 _(ioam_disable_reply) \
4224 _(one_add_del_locator_reply) \
4225 _(one_add_del_local_eid_reply) \
4226 _(one_add_del_remote_mapping_reply) \
4227 _(one_add_del_adjacency_reply) \
4228 _(one_add_del_map_resolver_reply) \
4229 _(one_add_del_map_server_reply) \
4230 _(one_enable_disable_reply) \
4231 _(one_rloc_probe_enable_disable_reply) \
4232 _(one_map_register_enable_disable_reply) \
4233 _(one_pitr_set_locator_set_reply) \
4234 _(one_map_request_mode_reply) \
4235 _(one_add_del_map_request_itr_rlocs_reply) \
4236 _(one_eid_table_add_del_map_reply) \
4237 _(one_use_petr_reply) \
4238 _(one_stats_enable_disable_reply) \
4239 _(gpe_add_del_fwd_entry_reply) \
4240 _(gpe_enable_disable_reply) \
4241 _(gpe_set_encap_mode_reply) \
4242 _(gpe_add_del_iface_reply) \
4243 _(vxlan_gpe_add_del_tunnel_reply) \
4244 _(af_packet_delete_reply) \
4245 _(policer_classify_set_interface_reply) \
4246 _(netmap_create_reply) \
4247 _(netmap_delete_reply) \
4248 _(set_ipfix_exporter_reply) \
4249 _(set_ipfix_classify_stream_reply) \
4250 _(ipfix_classify_table_add_del_reply) \
4251 _(flow_classify_set_interface_reply) \
4252 _(sw_interface_span_enable_disable_reply) \
4253 _(pg_capture_reply) \
4254 _(pg_enable_disable_reply) \
4255 _(ip_source_and_port_range_check_add_del_reply) \
4256 _(ip_source_and_port_range_check_interface_add_del_reply)\
4257 _(delete_subif_reply) \
4258 _(l2_interface_pbb_tag_rewrite_reply) \
4260 _(feature_enable_disable_reply) \
4261 _(sw_interface_tag_add_del_reply) \
4262 _(sw_interface_set_mtu_reply)
4265 static void vl_api_##n##_t_handler \
4266 (vl_api_##n##_t * mp) \
4268 vat_main_t * vam = &vat_main; \
4269 i32 retval = ntohl(mp->retval); \
4270 if (vam->async_mode) { \
4271 vam->async_errors += (retval < 0); \
4273 vam->retval = retval; \
4274 vam->result_ready = 1; \
4277 foreach_standard_reply_retval_handler;
4281 static void vl_api_##n##_t_handler_json \
4282 (vl_api_##n##_t * mp) \
4284 vat_main_t * vam = &vat_main; \
4285 vat_json_node_t node; \
4286 vat_json_init_object(&node); \
4287 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4288 vat_json_print(vam->ofp, &node); \
4289 vam->retval = ntohl(mp->retval); \
4290 vam->result_ready = 1; \
4292 foreach_standard_reply_retval_handler;
4296 * Table of message reply handlers, must include boilerplate handlers
4300 #define foreach_vpe_api_reply_msg \
4301 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4302 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4303 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4304 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4305 _(CONTROL_PING_REPLY, control_ping_reply) \
4306 _(CLI_REPLY, cli_reply) \
4307 _(CLI_INBAND_REPLY, cli_inband_reply) \
4308 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4309 sw_interface_add_del_address_reply) \
4310 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4311 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4312 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4313 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4314 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4315 sw_interface_set_l2_xconnect_reply) \
4316 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4317 sw_interface_set_l2_bridge_reply) \
4318 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4319 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4320 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
4321 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
4322 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4323 _(L2_FLAGS_REPLY, l2_flags_reply) \
4324 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4325 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4326 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4327 _(TAP_DELETE_REPLY, tap_delete_reply) \
4328 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4329 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4330 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4331 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4332 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4333 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4334 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4335 proxy_arp_intfc_enable_disable_reply) \
4336 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4337 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4338 sw_interface_set_unnumbered_reply) \
4339 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4340 _(RESET_VRF_REPLY, reset_vrf_reply) \
4341 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4342 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4343 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4344 _(RESET_FIB_REPLY, reset_fib_reply) \
4345 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4346 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4347 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4348 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4349 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4350 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4351 sw_interface_ip6_enable_disable_reply) \
4352 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4353 sw_interface_ip6_set_link_local_address_reply) \
4354 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
4355 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
4356 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4357 sw_interface_ip6nd_ra_prefix_reply) \
4358 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4359 sw_interface_ip6nd_ra_config_reply) \
4360 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4361 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4362 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4363 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4364 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4365 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4366 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4367 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4368 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4369 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4370 classify_set_interface_ip_table_reply) \
4371 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4372 classify_set_interface_l2_tables_reply) \
4373 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4374 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4375 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4376 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4377 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4378 l2tpv3_interface_enable_disable_reply) \
4379 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4380 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4381 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4382 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4383 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4384 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4385 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4386 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4387 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4388 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4389 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4390 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4391 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4392 _(SHOW_VERSION_REPLY, show_version_reply) \
4393 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
4394 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4395 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4396 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4397 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4398 _(IP4_ARP_EVENT, ip4_arp_event) \
4399 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4400 _(IP6_ND_EVENT, ip6_nd_event) \
4401 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4402 _(IP_ADDRESS_DETAILS, ip_address_details) \
4403 _(IP_DETAILS, ip_details) \
4404 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4405 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4406 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4407 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4408 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4409 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4410 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4411 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4412 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4413 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4414 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4415 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4416 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4417 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4418 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4419 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4420 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4421 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4422 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4423 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4424 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4425 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4426 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4427 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4428 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4429 _(MAP_RULE_DETAILS, map_rule_details) \
4430 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4431 _(WANT_STATS_REPLY, want_stats_reply) \
4432 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4433 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4434 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4435 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4436 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4437 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4438 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4439 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4440 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4441 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4442 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4443 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4444 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4445 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4446 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4447 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4448 one_map_register_enable_disable_reply) \
4449 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4450 one_rloc_probe_enable_disable_reply) \
4451 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4452 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
4453 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4454 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4455 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4456 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4457 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4458 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4459 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4460 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4461 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4462 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4463 _(ONE_STATS_DETAILS, one_stats_details) \
4464 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
4465 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
4466 show_one_stats_enable_disable_reply) \
4467 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4468 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4469 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4470 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4471 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4472 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4473 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4474 gpe_fwd_entry_path_details) \
4475 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4476 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4477 one_add_del_map_request_itr_rlocs_reply) \
4478 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4479 one_get_map_request_itr_rlocs_reply) \
4480 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4481 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
4482 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4483 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4484 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4485 show_one_map_register_state_reply) \
4486 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4487 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4488 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4489 _(POLICER_DETAILS, policer_details) \
4490 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4491 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4492 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4493 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4494 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4495 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4496 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4497 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4498 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4499 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4500 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4501 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4502 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4503 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4504 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4505 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4506 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4507 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4508 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4509 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4510 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4511 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4512 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4513 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4514 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4515 ip_source_and_port_range_check_add_del_reply) \
4516 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4517 ip_source_and_port_range_check_interface_add_del_reply) \
4518 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4519 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4520 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4521 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4522 _(PUNT_REPLY, punt_reply) \
4523 _(IP_FIB_DETAILS, ip_fib_details) \
4524 _(IP6_FIB_DETAILS, ip6_fib_details) \
4525 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4526 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4527 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4528 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4529 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4530 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4532 #define foreach_standalone_reply_msg \
4533 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4534 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
4535 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4536 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4537 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4538 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
4547 #define STR_VTR_OP_CASE(op) \
4548 case L2_VTR_ ## op: \
4552 str_vtr_op (u32 vtr_op)
4556 STR_VTR_OP_CASE (DISABLED);
4557 STR_VTR_OP_CASE (PUSH_1);
4558 STR_VTR_OP_CASE (PUSH_2);
4559 STR_VTR_OP_CASE (POP_1);
4560 STR_VTR_OP_CASE (POP_2);
4561 STR_VTR_OP_CASE (TRANSLATE_1_1);
4562 STR_VTR_OP_CASE (TRANSLATE_1_2);
4563 STR_VTR_OP_CASE (TRANSLATE_2_1);
4564 STR_VTR_OP_CASE (TRANSLATE_2_2);
4571 dump_sub_interface_table (vat_main_t * vam)
4573 const sw_interface_subif_t *sub = NULL;
4575 if (vam->json_output)
4578 ("JSON output supported only for VPE API calls and dump_stats_table");
4583 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4584 "Interface", "sw_if_index",
4585 "sub id", "dot1ad", "tags", "outer id",
4586 "inner id", "exact", "default", "outer any", "inner any");
4588 vec_foreach (sub, vam->sw_if_subif_table)
4591 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4592 sub->interface_name,
4594 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4595 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4596 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4597 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4598 if (sub->vtr_op != L2_VTR_DISABLED)
4601 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4602 "tag1: %d tag2: %d ]",
4603 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4604 sub->vtr_tag1, sub->vtr_tag2);
4612 name_sort_cmp (void *a1, void *a2)
4614 name_sort_t *n1 = a1;
4615 name_sort_t *n2 = a2;
4617 return strcmp ((char *) n1->name, (char *) n2->name);
4621 dump_interface_table (vat_main_t * vam)
4624 name_sort_t *nses = 0, *ns;
4626 if (vam->json_output)
4629 ("JSON output supported only for VPE API calls and dump_stats_table");
4634 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4636 vec_add2 (nses, ns, 1);
4637 ns->name = (u8 *)(p->key);
4638 ns->value = (u32) p->value[0];
4642 vec_sort_with_function (nses, name_sort_cmp);
4644 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4645 vec_foreach (ns, nses)
4647 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4654 dump_ip_table (vat_main_t * vam, int is_ipv6)
4656 const ip_details_t *det = NULL;
4657 const ip_address_details_t *address = NULL;
4660 print (vam->ofp, "%-12s", "sw_if_index");
4662 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4669 print (vam->ofp, "%-12d", i);
4670 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4675 vec_foreach (address, det->addr)
4679 is_ipv6 ? format_ip6_address : format_ip4_address,
4680 address->ip, address->prefix_length);
4688 dump_ipv4_table (vat_main_t * vam)
4690 if (vam->json_output)
4693 ("JSON output supported only for VPE API calls and dump_stats_table");
4697 return dump_ip_table (vam, 0);
4701 dump_ipv6_table (vat_main_t * vam)
4703 if (vam->json_output)
4706 ("JSON output supported only for VPE API calls and dump_stats_table");
4710 return dump_ip_table (vam, 1);
4714 counter_type_to_str (u8 counter_type, u8 is_combined)
4718 switch (counter_type)
4720 case VNET_INTERFACE_COUNTER_DROP:
4722 case VNET_INTERFACE_COUNTER_PUNT:
4724 case VNET_INTERFACE_COUNTER_IP4:
4726 case VNET_INTERFACE_COUNTER_IP6:
4728 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4730 case VNET_INTERFACE_COUNTER_RX_MISS:
4732 case VNET_INTERFACE_COUNTER_RX_ERROR:
4734 case VNET_INTERFACE_COUNTER_TX_ERROR:
4737 return "INVALID-COUNTER-TYPE";
4742 switch (counter_type)
4744 case VNET_INTERFACE_COUNTER_RX:
4746 case VNET_INTERFACE_COUNTER_TX:
4749 return "INVALID-COUNTER-TYPE";
4755 dump_stats_table (vat_main_t * vam)
4757 vat_json_node_t node;
4758 vat_json_node_t *msg_array;
4759 vat_json_node_t *msg;
4760 vat_json_node_t *counter_array;
4761 vat_json_node_t *counter;
4762 interface_counter_t c;
4764 ip4_fib_counter_t *c4;
4765 ip6_fib_counter_t *c6;
4766 ip4_nbr_counter_t *n4;
4767 ip6_nbr_counter_t *n6;
4770 if (!vam->json_output)
4772 clib_warning ("dump_stats_table supported only in JSON format");
4776 vat_json_init_object (&node);
4778 /* interface counters */
4779 msg_array = vat_json_object_add (&node, "interface_counters");
4780 vat_json_init_array (msg_array);
4781 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4783 msg = vat_json_array_add (msg_array);
4784 vat_json_init_object (msg);
4785 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4786 (u8 *) counter_type_to_str (i, 0));
4787 vat_json_object_add_int (msg, "is_combined", 0);
4788 counter_array = vat_json_object_add (msg, "data");
4789 vat_json_init_array (counter_array);
4790 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4792 packets = vam->simple_interface_counters[i][j];
4793 vat_json_array_add_uint (counter_array, packets);
4796 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4798 msg = vat_json_array_add (msg_array);
4799 vat_json_init_object (msg);
4800 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4801 (u8 *) counter_type_to_str (i, 1));
4802 vat_json_object_add_int (msg, "is_combined", 1);
4803 counter_array = vat_json_object_add (msg, "data");
4804 vat_json_init_array (counter_array);
4805 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4807 c = vam->combined_interface_counters[i][j];
4808 counter = vat_json_array_add (counter_array);
4809 vat_json_init_object (counter);
4810 vat_json_object_add_uint (counter, "packets", c.packets);
4811 vat_json_object_add_uint (counter, "bytes", c.bytes);
4815 /* ip4 fib counters */
4816 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4817 vat_json_init_array (msg_array);
4818 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4820 msg = vat_json_array_add (msg_array);
4821 vat_json_init_object (msg);
4822 vat_json_object_add_uint (msg, "vrf_id",
4823 vam->ip4_fib_counters_vrf_id_by_index[i]);
4824 counter_array = vat_json_object_add (msg, "c");
4825 vat_json_init_array (counter_array);
4826 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4828 counter = vat_json_array_add (counter_array);
4829 vat_json_init_object (counter);
4830 c4 = &vam->ip4_fib_counters[i][j];
4831 vat_json_object_add_ip4 (counter, "address", c4->address);
4832 vat_json_object_add_uint (counter, "address_length",
4833 c4->address_length);
4834 vat_json_object_add_uint (counter, "packets", c4->packets);
4835 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4839 /* ip6 fib counters */
4840 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4841 vat_json_init_array (msg_array);
4842 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4844 msg = vat_json_array_add (msg_array);
4845 vat_json_init_object (msg);
4846 vat_json_object_add_uint (msg, "vrf_id",
4847 vam->ip6_fib_counters_vrf_id_by_index[i]);
4848 counter_array = vat_json_object_add (msg, "c");
4849 vat_json_init_array (counter_array);
4850 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4852 counter = vat_json_array_add (counter_array);
4853 vat_json_init_object (counter);
4854 c6 = &vam->ip6_fib_counters[i][j];
4855 vat_json_object_add_ip6 (counter, "address", c6->address);
4856 vat_json_object_add_uint (counter, "address_length",
4857 c6->address_length);
4858 vat_json_object_add_uint (counter, "packets", c6->packets);
4859 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4863 /* ip4 nbr counters */
4864 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4865 vat_json_init_array (msg_array);
4866 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4868 msg = vat_json_array_add (msg_array);
4869 vat_json_init_object (msg);
4870 vat_json_object_add_uint (msg, "sw_if_index", i);
4871 counter_array = vat_json_object_add (msg, "c");
4872 vat_json_init_array (counter_array);
4873 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4875 counter = vat_json_array_add (counter_array);
4876 vat_json_init_object (counter);
4877 n4 = &vam->ip4_nbr_counters[i][j];
4878 vat_json_object_add_ip4 (counter, "address", n4->address);
4879 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4880 vat_json_object_add_uint (counter, "packets", n4->packets);
4881 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4885 /* ip6 nbr counters */
4886 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4887 vat_json_init_array (msg_array);
4888 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4890 msg = vat_json_array_add (msg_array);
4891 vat_json_init_object (msg);
4892 vat_json_object_add_uint (msg, "sw_if_index", i);
4893 counter_array = vat_json_object_add (msg, "c");
4894 vat_json_init_array (counter_array);
4895 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4897 counter = vat_json_array_add (counter_array);
4898 vat_json_init_object (counter);
4899 n6 = &vam->ip6_nbr_counters[i][j];
4900 vat_json_object_add_ip6 (counter, "address", n6->address);
4901 vat_json_object_add_uint (counter, "packets", n6->packets);
4902 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4906 vat_json_print (vam->ofp, &node);
4907 vat_json_free (&node);
4913 exec (vat_main_t * vam)
4915 api_main_t *am = &api_main;
4916 vl_api_cli_request_t *mp;
4920 unformat_input_t *i = vam->input;
4922 if (vec_len (i->buffer) == 0)
4925 if (vam->exec_mode == 0 && unformat (i, "mode"))
4930 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4937 M (CLI_REQUEST, mp);
4940 * Copy cmd into shared memory.
4941 * In order for the CLI command to work, it
4942 * must be a vector ending in \n, not a C-string ending
4945 pthread_mutex_lock (&am->vlib_rp->mutex);
4946 oldheap = svm_push_data_heap (am->vlib_rp);
4948 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4949 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4951 svm_pop_heap (oldheap);
4952 pthread_mutex_unlock (&am->vlib_rp->mutex);
4954 mp->cmd_in_shmem = (u64) cmd;
4956 timeout = vat_time_now (vam) + 10.0;
4958 while (vat_time_now (vam) < timeout)
4960 if (vam->result_ready == 1)
4963 if (vam->shmem_result != NULL)
4964 print (vam->ofp, "%s", vam->shmem_result);
4965 pthread_mutex_lock (&am->vlib_rp->mutex);
4966 oldheap = svm_push_data_heap (am->vlib_rp);
4968 free_me = (u8 *) vam->shmem_result;
4971 svm_pop_heap (oldheap);
4972 pthread_mutex_unlock (&am->vlib_rp->mutex);
4980 * Future replacement of exec() that passes CLI buffers directly in
4981 * the API messages instead of an additional shared memory area.
4984 exec_inband (vat_main_t * vam)
4986 vl_api_cli_inband_t *mp;
4987 unformat_input_t *i = vam->input;
4990 if (vec_len (i->buffer) == 0)
4993 if (vam->exec_mode == 0 && unformat (i, "mode"))
4998 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5005 * In order for the CLI command to work, it
5006 * must be a vector ending in \n, not a C-string ending
5009 u32 len = vec_len (vam->input->buffer);
5010 M2 (CLI_INBAND, mp, len);
5011 clib_memcpy (mp->cmd, vam->input->buffer, len);
5012 mp->length = htonl (len);
5015 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
5020 api_create_loopback (vat_main_t * vam)
5022 unformat_input_t *i = vam->input;
5023 vl_api_create_loopback_t *mp;
5024 vl_api_create_loopback_instance_t *mp_lbi;
5027 u8 is_specified = 0;
5028 u32 user_instance = 0;
5031 memset (mac_address, 0, sizeof (mac_address));
5033 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5035 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5037 if (unformat (i, "instance %d", &user_instance))
5045 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5046 mp_lbi->is_specified = is_specified;
5048 mp_lbi->user_instance = htonl (user_instance);
5050 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5055 /* Construct the API message */
5056 M (CREATE_LOOPBACK, mp);
5058 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5067 api_delete_loopback (vat_main_t * vam)
5069 unformat_input_t *i = vam->input;
5070 vl_api_delete_loopback_t *mp;
5071 u32 sw_if_index = ~0;
5074 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5076 if (unformat (i, "sw_if_index %d", &sw_if_index))
5082 if (sw_if_index == ~0)
5084 errmsg ("missing sw_if_index");
5088 /* Construct the API message */
5089 M (DELETE_LOOPBACK, mp);
5090 mp->sw_if_index = ntohl (sw_if_index);
5098 api_want_stats (vat_main_t * vam)
5100 unformat_input_t *i = vam->input;
5101 vl_api_want_stats_t *mp;
5105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5107 if (unformat (i, "enable"))
5109 else if (unformat (i, "disable"))
5117 errmsg ("missing enable|disable");
5122 mp->enable_disable = enable;
5130 api_want_interface_events (vat_main_t * vam)
5132 unformat_input_t *i = vam->input;
5133 vl_api_want_interface_events_t *mp;
5137 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5139 if (unformat (i, "enable"))
5141 else if (unformat (i, "disable"))
5149 errmsg ("missing enable|disable");
5153 M (WANT_INTERFACE_EVENTS, mp);
5154 mp->enable_disable = enable;
5156 vam->interface_event_display = enable;
5164 /* Note: non-static, called once to set up the initial intfc table */
5166 api_sw_interface_dump (vat_main_t * vam)
5168 vl_api_sw_interface_dump_t *mp;
5169 vl_api_control_ping_t *mp_ping;
5171 name_sort_t *nses = 0, *ns;
5172 sw_interface_subif_t *sub = NULL;
5175 /* Toss the old name table */
5177 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5179 vec_add2 (nses, ns, 1);
5180 ns->name = (u8 *)(p->key);
5181 ns->value = (u32) p->value[0];
5185 hash_free (vam->sw_if_index_by_interface_name);
5187 vec_foreach (ns, nses) vec_free (ns->name);
5191 vec_foreach (sub, vam->sw_if_subif_table)
5193 vec_free (sub->interface_name);
5195 vec_free (vam->sw_if_subif_table);
5197 /* recreate the interface name hash table */
5198 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5200 /* Get list of ethernets */
5201 M (SW_INTERFACE_DUMP, mp);
5202 mp->name_filter_valid = 1;
5203 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
5206 /* and local / loopback interfaces */
5207 M (SW_INTERFACE_DUMP, mp);
5208 mp->name_filter_valid = 1;
5209 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
5212 /* and packet-generator interfaces */
5213 M (SW_INTERFACE_DUMP, mp);
5214 mp->name_filter_valid = 1;
5215 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
5218 /* and vxlan-gpe tunnel interfaces */
5219 M (SW_INTERFACE_DUMP, mp);
5220 mp->name_filter_valid = 1;
5221 strncpy ((char *) mp->name_filter, "vxlan_gpe",
5222 sizeof (mp->name_filter) - 1);
5225 /* and vxlan tunnel interfaces */
5226 M (SW_INTERFACE_DUMP, mp);
5227 mp->name_filter_valid = 1;
5228 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
5231 /* and host (af_packet) interfaces */
5232 M (SW_INTERFACE_DUMP, mp);
5233 mp->name_filter_valid = 1;
5234 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
5237 /* and l2tpv3 tunnel interfaces */
5238 M (SW_INTERFACE_DUMP, mp);
5239 mp->name_filter_valid = 1;
5240 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
5241 sizeof (mp->name_filter) - 1);
5244 /* and GRE tunnel interfaces */
5245 M (SW_INTERFACE_DUMP, mp);
5246 mp->name_filter_valid = 1;
5247 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
5250 /* and LISP-GPE interfaces */
5251 M (SW_INTERFACE_DUMP, mp);
5252 mp->name_filter_valid = 1;
5253 strncpy ((char *) mp->name_filter, "lisp_gpe",
5254 sizeof (mp->name_filter) - 1);
5257 /* and IPSEC tunnel interfaces */
5258 M (SW_INTERFACE_DUMP, mp);
5259 mp->name_filter_valid = 1;
5260 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
5263 /* Use a control ping for synchronization */
5264 M (CONTROL_PING, mp_ping);
5272 api_sw_interface_set_flags (vat_main_t * vam)
5274 unformat_input_t *i = vam->input;
5275 vl_api_sw_interface_set_flags_t *mp;
5277 u8 sw_if_index_set = 0;
5278 u8 admin_up = 0, link_up = 0;
5281 /* Parse args required to build the message */
5282 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5284 if (unformat (i, "admin-up"))
5286 else if (unformat (i, "admin-down"))
5288 else if (unformat (i, "link-up"))
5290 else if (unformat (i, "link-down"))
5293 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5294 sw_if_index_set = 1;
5295 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5296 sw_if_index_set = 1;
5301 if (sw_if_index_set == 0)
5303 errmsg ("missing interface name or sw_if_index");
5307 /* Construct the API message */
5308 M (SW_INTERFACE_SET_FLAGS, mp);
5309 mp->sw_if_index = ntohl (sw_if_index);
5310 mp->admin_up_down = admin_up;
5311 mp->link_up_down = link_up;
5316 /* Wait for a reply, return the good/bad news... */
5322 api_sw_interface_clear_stats (vat_main_t * vam)
5324 unformat_input_t *i = vam->input;
5325 vl_api_sw_interface_clear_stats_t *mp;
5327 u8 sw_if_index_set = 0;
5330 /* Parse args required to build the message */
5331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5333 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5334 sw_if_index_set = 1;
5335 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5336 sw_if_index_set = 1;
5341 /* Construct the API message */
5342 M (SW_INTERFACE_CLEAR_STATS, mp);
5344 if (sw_if_index_set == 1)
5345 mp->sw_if_index = ntohl (sw_if_index);
5347 mp->sw_if_index = ~0;
5352 /* Wait for a reply, return the good/bad news... */
5358 api_sw_interface_add_del_address (vat_main_t * vam)
5360 unformat_input_t *i = vam->input;
5361 vl_api_sw_interface_add_del_address_t *mp;
5363 u8 sw_if_index_set = 0;
5364 u8 is_add = 1, del_all = 0;
5365 u32 address_length = 0;
5366 u8 v4_address_set = 0;
5367 u8 v6_address_set = 0;
5368 ip4_address_t v4address;
5369 ip6_address_t v6address;
5372 /* Parse args required to build the message */
5373 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5375 if (unformat (i, "del-all"))
5377 else if (unformat (i, "del"))
5380 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5381 sw_if_index_set = 1;
5382 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5383 sw_if_index_set = 1;
5384 else if (unformat (i, "%U/%d",
5385 unformat_ip4_address, &v4address, &address_length))
5387 else if (unformat (i, "%U/%d",
5388 unformat_ip6_address, &v6address, &address_length))
5394 if (sw_if_index_set == 0)
5396 errmsg ("missing interface name or sw_if_index");
5399 if (v4_address_set && v6_address_set)
5401 errmsg ("both v4 and v6 addresses set");
5404 if (!v4_address_set && !v6_address_set && !del_all)
5406 errmsg ("no addresses set");
5410 /* Construct the API message */
5411 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5413 mp->sw_if_index = ntohl (sw_if_index);
5414 mp->is_add = is_add;
5415 mp->del_all = del_all;
5419 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5423 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5425 mp->address_length = address_length;
5430 /* Wait for a reply, return good/bad news */
5436 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5438 unformat_input_t *i = vam->input;
5439 vl_api_sw_interface_set_mpls_enable_t *mp;
5441 u8 sw_if_index_set = 0;
5445 /* Parse args required to build the message */
5446 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5448 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5449 sw_if_index_set = 1;
5450 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5451 sw_if_index_set = 1;
5452 else if (unformat (i, "disable"))
5454 else if (unformat (i, "dis"))
5460 if (sw_if_index_set == 0)
5462 errmsg ("missing interface name or sw_if_index");
5466 /* Construct the API message */
5467 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5469 mp->sw_if_index = ntohl (sw_if_index);
5470 mp->enable = enable;
5475 /* Wait for a reply... */
5481 api_sw_interface_set_table (vat_main_t * vam)
5483 unformat_input_t *i = vam->input;
5484 vl_api_sw_interface_set_table_t *mp;
5485 u32 sw_if_index, vrf_id = 0;
5486 u8 sw_if_index_set = 0;
5490 /* Parse args required to build the message */
5491 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5493 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5494 sw_if_index_set = 1;
5495 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5496 sw_if_index_set = 1;
5497 else if (unformat (i, "vrf %d", &vrf_id))
5499 else if (unformat (i, "ipv6"))
5505 if (sw_if_index_set == 0)
5507 errmsg ("missing interface name or sw_if_index");
5511 /* Construct the API message */
5512 M (SW_INTERFACE_SET_TABLE, mp);
5514 mp->sw_if_index = ntohl (sw_if_index);
5515 mp->is_ipv6 = is_ipv6;
5516 mp->vrf_id = ntohl (vrf_id);
5521 /* Wait for a reply... */
5526 static void vl_api_sw_interface_get_table_reply_t_handler
5527 (vl_api_sw_interface_get_table_reply_t * mp)
5529 vat_main_t *vam = &vat_main;
5531 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5533 vam->retval = ntohl (mp->retval);
5534 vam->result_ready = 1;
5538 static void vl_api_sw_interface_get_table_reply_t_handler_json
5539 (vl_api_sw_interface_get_table_reply_t * mp)
5541 vat_main_t *vam = &vat_main;
5542 vat_json_node_t node;
5544 vat_json_init_object (&node);
5545 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5546 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5548 vat_json_print (vam->ofp, &node);
5549 vat_json_free (&node);
5551 vam->retval = ntohl (mp->retval);
5552 vam->result_ready = 1;
5556 api_sw_interface_get_table (vat_main_t * vam)
5558 unformat_input_t *i = vam->input;
5559 vl_api_sw_interface_get_table_t *mp;
5561 u8 sw_if_index_set = 0;
5565 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5567 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5568 sw_if_index_set = 1;
5569 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5570 sw_if_index_set = 1;
5571 else if (unformat (i, "ipv6"))
5577 if (sw_if_index_set == 0)
5579 errmsg ("missing interface name or sw_if_index");
5583 M (SW_INTERFACE_GET_TABLE, mp);
5584 mp->sw_if_index = htonl (sw_if_index);
5585 mp->is_ipv6 = is_ipv6;
5593 api_sw_interface_set_vpath (vat_main_t * vam)
5595 unformat_input_t *i = vam->input;
5596 vl_api_sw_interface_set_vpath_t *mp;
5597 u32 sw_if_index = 0;
5598 u8 sw_if_index_set = 0;
5602 /* Parse args required to build the message */
5603 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5605 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5606 sw_if_index_set = 1;
5607 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5608 sw_if_index_set = 1;
5609 else if (unformat (i, "enable"))
5611 else if (unformat (i, "disable"))
5617 if (sw_if_index_set == 0)
5619 errmsg ("missing interface name or sw_if_index");
5623 /* Construct the API message */
5624 M (SW_INTERFACE_SET_VPATH, mp);
5626 mp->sw_if_index = ntohl (sw_if_index);
5627 mp->enable = is_enable;
5632 /* Wait for a reply... */
5638 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5640 unformat_input_t *i = vam->input;
5641 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5642 u32 sw_if_index = 0;
5643 u8 sw_if_index_set = 0;
5648 /* Parse args required to build the message */
5649 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5651 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5652 sw_if_index_set = 1;
5653 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5654 sw_if_index_set = 1;
5655 else if (unformat (i, "enable"))
5657 else if (unformat (i, "disable"))
5659 else if (unformat (i, "ip4"))
5661 else if (unformat (i, "ip6"))
5667 if (sw_if_index_set == 0)
5669 errmsg ("missing interface name or sw_if_index");
5673 /* Construct the API message */
5674 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5676 mp->sw_if_index = ntohl (sw_if_index);
5677 mp->enable = is_enable;
5678 mp->is_ipv6 = is_ipv6;
5683 /* Wait for a reply... */
5689 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5691 unformat_input_t *i = vam->input;
5692 vl_api_sw_interface_set_l2_xconnect_t *mp;
5694 u8 rx_sw_if_index_set = 0;
5696 u8 tx_sw_if_index_set = 0;
5700 /* Parse args required to build the message */
5701 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5703 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5704 rx_sw_if_index_set = 1;
5705 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5706 tx_sw_if_index_set = 1;
5707 else if (unformat (i, "rx"))
5709 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5711 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5713 rx_sw_if_index_set = 1;
5718 else if (unformat (i, "tx"))
5720 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5722 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5724 tx_sw_if_index_set = 1;
5729 else if (unformat (i, "enable"))
5731 else if (unformat (i, "disable"))
5737 if (rx_sw_if_index_set == 0)
5739 errmsg ("missing rx interface name or rx_sw_if_index");
5743 if (enable && (tx_sw_if_index_set == 0))
5745 errmsg ("missing tx interface name or tx_sw_if_index");
5749 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5751 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5752 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5753 mp->enable = enable;
5761 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5763 unformat_input_t *i = vam->input;
5764 vl_api_sw_interface_set_l2_bridge_t *mp;
5766 u8 rx_sw_if_index_set = 0;
5774 /* Parse args required to build the message */
5775 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5777 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5778 rx_sw_if_index_set = 1;
5779 else if (unformat (i, "bd_id %d", &bd_id))
5783 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5784 rx_sw_if_index_set = 1;
5785 else if (unformat (i, "shg %d", &shg))
5787 else if (unformat (i, "bvi"))
5789 else if (unformat (i, "enable"))
5791 else if (unformat (i, "disable"))
5797 if (rx_sw_if_index_set == 0)
5799 errmsg ("missing rx interface name or sw_if_index");
5803 if (enable && (bd_id_set == 0))
5805 errmsg ("missing bridge domain");
5809 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
5811 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5812 mp->bd_id = ntohl (bd_id);
5815 mp->enable = enable;
5823 api_bridge_domain_dump (vat_main_t * vam)
5825 unformat_input_t *i = vam->input;
5826 vl_api_bridge_domain_dump_t *mp;
5827 vl_api_control_ping_t *mp_ping;
5831 /* Parse args required to build the message */
5832 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5834 if (unformat (i, "bd_id %d", &bd_id))
5840 M (BRIDGE_DOMAIN_DUMP, mp);
5841 mp->bd_id = ntohl (bd_id);
5844 /* Use a control ping for synchronization */
5845 M (CONTROL_PING, mp_ping);
5853 api_bridge_domain_add_del (vat_main_t * vam)
5855 unformat_input_t *i = vam->input;
5856 vl_api_bridge_domain_add_del_t *mp;
5859 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5863 /* Parse args required to build the message */
5864 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5866 if (unformat (i, "bd_id %d", &bd_id))
5868 else if (unformat (i, "flood %d", &flood))
5870 else if (unformat (i, "uu-flood %d", &uu_flood))
5872 else if (unformat (i, "forward %d", &forward))
5874 else if (unformat (i, "learn %d", &learn))
5876 else if (unformat (i, "arp-term %d", &arp_term))
5878 else if (unformat (i, "mac-age %d", &mac_age))
5880 else if (unformat (i, "del"))
5883 flood = uu_flood = forward = learn = 0;
5891 errmsg ("missing bridge domain");
5897 errmsg ("mac age must be less than 256 ");
5901 M (BRIDGE_DOMAIN_ADD_DEL, mp);
5903 mp->bd_id = ntohl (bd_id);
5905 mp->uu_flood = uu_flood;
5906 mp->forward = forward;
5908 mp->arp_term = arp_term;
5909 mp->is_add = is_add;
5910 mp->mac_age = (u8) mac_age;
5918 api_l2fib_add_del (vat_main_t * vam)
5920 unformat_input_t *i = vam->input;
5921 vl_api_l2fib_add_del_t *mp;
5927 u32 sw_if_index = ~0;
5928 u8 sw_if_index_set = 0;
5937 /* Parse args required to build the message */
5938 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5940 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5942 else if (unformat (i, "bd_id %d", &bd_id))
5944 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5945 sw_if_index_set = 1;
5946 else if (unformat (i, "sw_if"))
5948 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5951 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5952 sw_if_index_set = 1;
5957 else if (unformat (i, "static"))
5959 else if (unformat (i, "filter"))
5964 else if (unformat (i, "bvi"))
5969 else if (unformat (i, "del"))
5971 else if (unformat (i, "count %d", &count))
5979 errmsg ("missing mac address");
5985 errmsg ("missing bridge domain");
5989 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5991 errmsg ("missing interface name or sw_if_index");
5997 /* Turn on async mode */
5998 vam->async_mode = 1;
5999 vam->async_errors = 0;
6000 before = vat_time_now (vam);
6003 for (j = 0; j < count; j++)
6005 M (L2FIB_ADD_DEL, mp);
6008 mp->bd_id = ntohl (bd_id);
6009 mp->is_add = is_add;
6013 mp->sw_if_index = ntohl (sw_if_index);
6014 mp->static_mac = static_mac;
6015 mp->filter_mac = filter_mac;
6016 mp->bvi_mac = bvi_mac;
6018 increment_mac_address (&mac);
6025 vl_api_control_ping_t *mp_ping;
6028 /* Shut off async mode */
6029 vam->async_mode = 0;
6031 M (CONTROL_PING, mp_ping);
6034 timeout = vat_time_now (vam) + 1.0;
6035 while (vat_time_now (vam) < timeout)
6036 if (vam->result_ready == 1)
6041 if (vam->retval == -99)
6044 if (vam->async_errors > 0)
6046 errmsg ("%d asynchronous errors", vam->async_errors);
6049 vam->async_errors = 0;
6050 after = vat_time_now (vam);
6052 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6053 count, after - before, count / (after - before));
6059 /* Wait for a reply... */
6063 /* Return the good/bad news */
6064 return (vam->retval);
6068 api_bridge_domain_set_mac_age (vat_main_t * vam)
6070 unformat_input_t *i = vam->input;
6071 vl_api_bridge_domain_set_mac_age_t *mp;
6076 /* Parse args required to build the message */
6077 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6079 if (unformat (i, "bd_id %d", &bd_id));
6080 else if (unformat (i, "mac-age %d", &mac_age));
6087 errmsg ("missing bridge domain");
6093 errmsg ("mac age must be less than 256 ");
6097 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6099 mp->bd_id = htonl (bd_id);
6100 mp->mac_age = (u8) mac_age;
6108 api_l2_flags (vat_main_t * vam)
6110 unformat_input_t *i = vam->input;
6111 vl_api_l2_flags_t *mp;
6113 u32 feature_bitmap = 0;
6114 u8 sw_if_index_set = 0;
6117 /* Parse args required to build the message */
6118 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6120 if (unformat (i, "sw_if_index %d", &sw_if_index))
6121 sw_if_index_set = 1;
6122 else if (unformat (i, "sw_if"))
6124 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6127 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6128 sw_if_index_set = 1;
6133 else if (unformat (i, "learn"))
6134 feature_bitmap |= L2INPUT_FEAT_LEARN;
6135 else if (unformat (i, "forward"))
6136 feature_bitmap |= L2INPUT_FEAT_FWD;
6137 else if (unformat (i, "flood"))
6138 feature_bitmap |= L2INPUT_FEAT_FLOOD;
6139 else if (unformat (i, "uu-flood"))
6140 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
6145 if (sw_if_index_set == 0)
6147 errmsg ("missing interface name or sw_if_index");
6153 mp->sw_if_index = ntohl (sw_if_index);
6154 mp->feature_bitmap = ntohl (feature_bitmap);
6162 api_bridge_flags (vat_main_t * vam)
6164 unformat_input_t *i = vam->input;
6165 vl_api_bridge_flags_t *mp;
6172 /* Parse args required to build the message */
6173 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6175 if (unformat (i, "bd_id %d", &bd_id))
6177 else if (unformat (i, "learn"))
6179 else if (unformat (i, "forward"))
6181 else if (unformat (i, "flood"))
6183 else if (unformat (i, "uu-flood"))
6184 flags |= L2_UU_FLOOD;
6185 else if (unformat (i, "arp-term"))
6186 flags |= L2_ARP_TERM;
6187 else if (unformat (i, "off"))
6189 else if (unformat (i, "disable"))
6197 errmsg ("missing bridge domain");
6201 M (BRIDGE_FLAGS, mp);
6203 mp->bd_id = ntohl (bd_id);
6204 mp->feature_bitmap = ntohl (flags);
6205 mp->is_set = is_set;
6213 api_bd_ip_mac_add_del (vat_main_t * vam)
6215 unformat_input_t *i = vam->input;
6216 vl_api_bd_ip_mac_add_del_t *mp;
6223 ip4_address_t v4addr;
6224 ip6_address_t v6addr;
6229 /* Parse args required to build the message */
6230 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6232 if (unformat (i, "bd_id %d", &bd_id))
6236 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6240 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6245 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6249 else if (unformat (i, "del"))
6257 errmsg ("missing bridge domain");
6260 else if (ip_set == 0)
6262 errmsg ("missing IP address");
6265 else if (mac_set == 0)
6267 errmsg ("missing MAC address");
6271 M (BD_IP_MAC_ADD_DEL, mp);
6273 mp->bd_id = ntohl (bd_id);
6274 mp->is_ipv6 = is_ipv6;
6275 mp->is_add = is_add;
6277 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6279 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6280 clib_memcpy (mp->mac_address, macaddr, 6);
6287 api_tap_connect (vat_main_t * vam)
6289 unformat_input_t *i = vam->input;
6290 vl_api_tap_connect_t *mp;
6296 ip4_address_t ip4_address;
6298 int ip4_address_set = 0;
6299 ip6_address_t ip6_address;
6301 int ip6_address_set = 0;
6304 memset (mac_address, 0, sizeof (mac_address));
6306 /* Parse args required to build the message */
6307 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6309 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6313 else if (unformat (i, "random-mac"))
6315 else if (unformat (i, "tapname %s", &tap_name))
6317 else if (unformat (i, "tag %s", &tag))
6319 else if (unformat (i, "address %U/%d",
6320 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6321 ip4_address_set = 1;
6322 else if (unformat (i, "address %U/%d",
6323 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6324 ip6_address_set = 1;
6331 errmsg ("missing tap name");
6334 if (vec_len (tap_name) > 63)
6336 errmsg ("tap name too long");
6339 vec_add1 (tap_name, 0);
6341 if (vec_len (tag) > 63)
6343 errmsg ("tag too long");
6347 /* Construct the API message */
6348 M (TAP_CONNECT, mp);
6350 mp->use_random_mac = random_mac;
6351 clib_memcpy (mp->mac_address, mac_address, 6);
6352 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6354 clib_memcpy (mp->tag, tag, vec_len (tag));
6356 if (ip4_address_set)
6358 mp->ip4_address_set = 1;
6359 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6360 mp->ip4_mask_width = ip4_mask_width;
6362 if (ip6_address_set)
6364 mp->ip6_address_set = 1;
6365 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6366 mp->ip6_mask_width = ip6_mask_width;
6369 vec_free (tap_name);
6375 /* Wait for a reply... */
6381 api_tap_modify (vat_main_t * vam)
6383 unformat_input_t *i = vam->input;
6384 vl_api_tap_modify_t *mp;
6389 u32 sw_if_index = ~0;
6390 u8 sw_if_index_set = 0;
6393 memset (mac_address, 0, sizeof (mac_address));
6395 /* Parse args required to build the message */
6396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6398 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6399 sw_if_index_set = 1;
6400 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6401 sw_if_index_set = 1;
6402 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6406 else if (unformat (i, "random-mac"))
6408 else if (unformat (i, "tapname %s", &tap_name))
6414 if (sw_if_index_set == 0)
6416 errmsg ("missing vpp interface name");
6421 errmsg ("missing tap name");
6424 if (vec_len (tap_name) > 63)
6426 errmsg ("tap name too long");
6428 vec_add1 (tap_name, 0);
6430 /* Construct the API message */
6433 mp->use_random_mac = random_mac;
6434 mp->sw_if_index = ntohl (sw_if_index);
6435 clib_memcpy (mp->mac_address, mac_address, 6);
6436 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6437 vec_free (tap_name);
6442 /* Wait for a reply... */
6448 api_tap_delete (vat_main_t * vam)
6450 unformat_input_t *i = vam->input;
6451 vl_api_tap_delete_t *mp;
6452 u32 sw_if_index = ~0;
6453 u8 sw_if_index_set = 0;
6456 /* Parse args required to build the message */
6457 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6459 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6460 sw_if_index_set = 1;
6461 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6462 sw_if_index_set = 1;
6467 if (sw_if_index_set == 0)
6469 errmsg ("missing vpp interface name");
6473 /* Construct the API message */
6476 mp->sw_if_index = ntohl (sw_if_index);
6481 /* Wait for a reply... */
6487 api_ip_add_del_route (vat_main_t * vam)
6489 unformat_input_t *i = vam->input;
6490 vl_api_ip_add_del_route_t *mp;
6491 u32 sw_if_index = ~0, vrf_id = 0;
6493 u8 is_local = 0, is_drop = 0;
6494 u8 is_unreach = 0, is_prohibit = 0;
6495 u8 create_vrf_if_needed = 0;
6497 u32 next_hop_weight = 1;
6499 u8 is_multipath = 0;
6501 u8 address_length_set = 0;
6502 u32 next_hop_table_id = 0;
6503 u32 resolve_attempts = 0;
6504 u32 dst_address_length = 0;
6505 u8 next_hop_set = 0;
6506 ip4_address_t v4_dst_address, v4_next_hop_address;
6507 ip6_address_t v6_dst_address, v6_next_hop_address;
6511 u32 random_add_del = 0;
6512 u32 *random_vector = 0;
6514 u32 random_seed = 0xdeaddabe;
6515 u32 classify_table_index = ~0;
6517 u8 resolve_host = 0, resolve_attached = 0;
6518 mpls_label_t *next_hop_out_label_stack = NULL;
6519 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6520 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6522 /* Parse args required to build the message */
6523 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6525 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6527 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6529 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6534 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6539 else if (unformat (i, "/%d", &dst_address_length))
6541 address_length_set = 1;
6544 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6545 &v4_next_hop_address))
6549 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6550 &v6_next_hop_address))
6554 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6556 else if (unformat (i, "weight %d", &next_hop_weight))
6558 else if (unformat (i, "drop"))
6562 else if (unformat (i, "null-send-unreach"))
6566 else if (unformat (i, "null-send-prohibit"))
6570 else if (unformat (i, "local"))
6574 else if (unformat (i, "classify %d", &classify_table_index))
6578 else if (unformat (i, "del"))
6580 else if (unformat (i, "add"))
6582 else if (unformat (i, "not-last"))
6584 else if (unformat (i, "resolve-via-host"))
6586 else if (unformat (i, "resolve-via-attached"))
6587 resolve_attached = 1;
6588 else if (unformat (i, "multipath"))
6590 else if (unformat (i, "vrf %d", &vrf_id))
6592 else if (unformat (i, "create-vrf"))
6593 create_vrf_if_needed = 1;
6594 else if (unformat (i, "count %d", &count))
6596 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6598 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6600 else if (unformat (i, "out-label %d", &next_hop_out_label))
6601 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6602 else if (unformat (i, "via-label %d", &next_hop_via_label))
6604 else if (unformat (i, "random"))
6606 else if (unformat (i, "seed %d", &random_seed))
6610 clib_warning ("parse error '%U'", format_unformat_error, i);
6615 if (!next_hop_set && !is_drop && !is_local &&
6616 !is_classify && !is_unreach && !is_prohibit &&
6617 MPLS_LABEL_INVALID == next_hop_via_label)
6620 ("next hop / local / drop / unreach / prohibit / classify not set");
6624 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6626 errmsg ("next hop and next-hop via label set");
6629 if (address_set == 0)
6631 errmsg ("missing addresses");
6635 if (address_length_set == 0)
6637 errmsg ("missing address length");
6641 /* Generate a pile of unique, random routes */
6644 u32 this_random_address;
6645 random_hash = hash_create (count, sizeof (uword));
6647 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6648 for (j = 0; j <= count; j++)
6652 this_random_address = random_u32 (&random_seed);
6653 this_random_address =
6654 clib_host_to_net_u32 (this_random_address);
6656 while (hash_get (random_hash, this_random_address));
6657 vec_add1 (random_vector, this_random_address);
6658 hash_set (random_hash, this_random_address, 1);
6660 hash_free (random_hash);
6661 v4_dst_address.as_u32 = random_vector[0];
6666 /* Turn on async mode */
6667 vam->async_mode = 1;
6668 vam->async_errors = 0;
6669 before = vat_time_now (vam);
6672 for (j = 0; j < count; j++)
6674 /* Construct the API message */
6675 M2 (IP_ADD_DEL_ROUTE, mp,
6676 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6678 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6679 mp->table_id = ntohl (vrf_id);
6680 mp->create_vrf_if_needed = create_vrf_if_needed;
6682 mp->is_add = is_add;
6683 mp->is_drop = is_drop;
6684 mp->is_unreach = is_unreach;
6685 mp->is_prohibit = is_prohibit;
6686 mp->is_ipv6 = is_ipv6;
6687 mp->is_local = is_local;
6688 mp->is_classify = is_classify;
6689 mp->is_multipath = is_multipath;
6690 mp->is_resolve_host = resolve_host;
6691 mp->is_resolve_attached = resolve_attached;
6692 mp->not_last = not_last;
6693 mp->next_hop_weight = next_hop_weight;
6694 mp->dst_address_length = dst_address_length;
6695 mp->next_hop_table_id = ntohl (next_hop_table_id);
6696 mp->classify_table_index = ntohl (classify_table_index);
6697 mp->next_hop_via_label = ntohl (next_hop_via_label);
6698 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6699 if (0 != mp->next_hop_n_out_labels)
6701 memcpy (mp->next_hop_out_label_stack,
6702 next_hop_out_label_stack,
6703 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6704 vec_free (next_hop_out_label_stack);
6709 clib_memcpy (mp->dst_address, &v6_dst_address,
6710 sizeof (v6_dst_address));
6712 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6713 sizeof (v6_next_hop_address));
6714 increment_v6_address (&v6_dst_address);
6718 clib_memcpy (mp->dst_address, &v4_dst_address,
6719 sizeof (v4_dst_address));
6721 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6722 sizeof (v4_next_hop_address));
6724 v4_dst_address.as_u32 = random_vector[j + 1];
6726 increment_v4_address (&v4_dst_address);
6730 /* If we receive SIGTERM, stop now... */
6735 /* When testing multiple add/del ops, use a control-ping to sync */
6738 vl_api_control_ping_t *mp_ping;
6742 /* Shut off async mode */
6743 vam->async_mode = 0;
6745 M (CONTROL_PING, mp_ping);
6748 timeout = vat_time_now (vam) + 1.0;
6749 while (vat_time_now (vam) < timeout)
6750 if (vam->result_ready == 1)
6755 if (vam->retval == -99)
6758 if (vam->async_errors > 0)
6760 errmsg ("%d asynchronous errors", vam->async_errors);
6763 vam->async_errors = 0;
6764 after = vat_time_now (vam);
6766 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6770 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6771 count, after - before, count / (after - before));
6777 /* Wait for a reply... */
6782 /* Return the good/bad news */
6783 return (vam->retval);
6787 api_ip_mroute_add_del (vat_main_t * vam)
6789 unformat_input_t *i = vam->input;
6790 vl_api_ip_mroute_add_del_t *mp;
6791 u32 sw_if_index = ~0, vrf_id = 0;
6794 u8 create_vrf_if_needed = 0;
6797 u32 grp_address_length = 0;
6798 ip4_address_t v4_grp_address, v4_src_address;
6799 ip6_address_t v6_grp_address, v6_src_address;
6800 mfib_itf_flags_t iflags = 0;
6801 mfib_entry_flags_t eflags = 0;
6804 /* Parse args required to build the message */
6805 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6807 if (unformat (i, "sw_if_index %d", &sw_if_index))
6809 else if (unformat (i, "%U %U",
6810 unformat_ip4_address, &v4_src_address,
6811 unformat_ip4_address, &v4_grp_address))
6813 grp_address_length = 64;
6817 else if (unformat (i, "%U %U",
6818 unformat_ip6_address, &v6_src_address,
6819 unformat_ip6_address, &v6_grp_address))
6821 grp_address_length = 256;
6825 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
6827 memset (&v4_src_address, 0, sizeof (v4_src_address));
6828 grp_address_length = 32;
6832 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
6834 memset (&v6_src_address, 0, sizeof (v6_src_address));
6835 grp_address_length = 128;
6839 else if (unformat (i, "/%d", &grp_address_length))
6841 else if (unformat (i, "local"))
6845 else if (unformat (i, "del"))
6847 else if (unformat (i, "add"))
6849 else if (unformat (i, "vrf %d", &vrf_id))
6851 else if (unformat (i, "create-vrf"))
6852 create_vrf_if_needed = 1;
6853 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
6855 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
6859 clib_warning ("parse error '%U'", format_unformat_error, i);
6864 if (address_set == 0)
6866 errmsg ("missing addresses\n");
6870 /* Construct the API message */
6871 M (IP_MROUTE_ADD_DEL, mp);
6873 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6874 mp->table_id = ntohl (vrf_id);
6875 mp->create_vrf_if_needed = create_vrf_if_needed;
6877 mp->is_add = is_add;
6878 mp->is_ipv6 = is_ipv6;
6879 mp->is_local = is_local;
6880 mp->itf_flags = ntohl (iflags);
6881 mp->entry_flags = ntohl (eflags);
6882 mp->grp_address_length = grp_address_length;
6883 mp->grp_address_length = ntohs (mp->grp_address_length);
6887 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
6888 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
6892 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
6893 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
6899 /* Wait for a reply... */
6905 api_mpls_route_add_del (vat_main_t * vam)
6907 unformat_input_t *i = vam->input;
6908 vl_api_mpls_route_add_del_t *mp;
6909 u32 sw_if_index = ~0, table_id = 0;
6910 u8 create_table_if_needed = 0;
6912 u32 next_hop_weight = 1;
6913 u8 is_multipath = 0;
6914 u32 next_hop_table_id = 0;
6915 u8 next_hop_set = 0;
6916 ip4_address_t v4_next_hop_address = {
6919 ip6_address_t v6_next_hop_address = { {0} };
6923 u32 classify_table_index = ~0;
6925 u8 resolve_host = 0, resolve_attached = 0;
6926 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6927 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6928 mpls_label_t *next_hop_out_label_stack = NULL;
6929 mpls_label_t local_label = MPLS_LABEL_INVALID;
6931 u8 next_hop_proto_is_ip4 = 1;
6933 /* Parse args required to build the message */
6934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6936 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6938 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6940 else if (unformat (i, "%d", &local_label))
6942 else if (unformat (i, "eos"))
6944 else if (unformat (i, "non-eos"))
6946 else if (unformat (i, "via %U", unformat_ip4_address,
6947 &v4_next_hop_address))
6950 next_hop_proto_is_ip4 = 1;
6952 else if (unformat (i, "via %U", unformat_ip6_address,
6953 &v6_next_hop_address))
6956 next_hop_proto_is_ip4 = 0;
6958 else if (unformat (i, "weight %d", &next_hop_weight))
6960 else if (unformat (i, "create-table"))
6961 create_table_if_needed = 1;
6962 else if (unformat (i, "classify %d", &classify_table_index))
6966 else if (unformat (i, "del"))
6968 else if (unformat (i, "add"))
6970 else if (unformat (i, "resolve-via-host"))
6972 else if (unformat (i, "resolve-via-attached"))
6973 resolve_attached = 1;
6974 else if (unformat (i, "multipath"))
6976 else if (unformat (i, "count %d", &count))
6978 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6981 next_hop_proto_is_ip4 = 1;
6983 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6986 next_hop_proto_is_ip4 = 0;
6988 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6990 else if (unformat (i, "via-label %d", &next_hop_via_label))
6992 else if (unformat (i, "out-label %d", &next_hop_out_label))
6993 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6996 clib_warning ("parse error '%U'", format_unformat_error, i);
7001 if (!next_hop_set && !is_classify)
7003 errmsg ("next hop / classify not set");
7007 if (MPLS_LABEL_INVALID == local_label)
7009 errmsg ("missing label");
7015 /* Turn on async mode */
7016 vam->async_mode = 1;
7017 vam->async_errors = 0;
7018 before = vat_time_now (vam);
7021 for (j = 0; j < count; j++)
7023 /* Construct the API message */
7024 M2 (MPLS_ROUTE_ADD_DEL, mp,
7025 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7027 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
7028 mp->mr_table_id = ntohl (table_id);
7029 mp->mr_create_table_if_needed = create_table_if_needed;
7031 mp->mr_is_add = is_add;
7032 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7033 mp->mr_is_classify = is_classify;
7034 mp->mr_is_multipath = is_multipath;
7035 mp->mr_is_resolve_host = resolve_host;
7036 mp->mr_is_resolve_attached = resolve_attached;
7037 mp->mr_next_hop_weight = next_hop_weight;
7038 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
7039 mp->mr_classify_table_index = ntohl (classify_table_index);
7040 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
7041 mp->mr_label = ntohl (local_label);
7042 mp->mr_eos = is_eos;
7044 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7045 if (0 != mp->mr_next_hop_n_out_labels)
7047 memcpy (mp->mr_next_hop_out_label_stack,
7048 next_hop_out_label_stack,
7049 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7050 vec_free (next_hop_out_label_stack);
7055 if (next_hop_proto_is_ip4)
7057 clib_memcpy (mp->mr_next_hop,
7058 &v4_next_hop_address,
7059 sizeof (v4_next_hop_address));
7063 clib_memcpy (mp->mr_next_hop,
7064 &v6_next_hop_address,
7065 sizeof (v6_next_hop_address));
7072 /* If we receive SIGTERM, stop now... */
7077 /* When testing multiple add/del ops, use a control-ping to sync */
7080 vl_api_control_ping_t *mp_ping;
7084 /* Shut off async mode */
7085 vam->async_mode = 0;
7087 M (CONTROL_PING, mp_ping);
7090 timeout = vat_time_now (vam) + 1.0;
7091 while (vat_time_now (vam) < timeout)
7092 if (vam->result_ready == 1)
7097 if (vam->retval == -99)
7100 if (vam->async_errors > 0)
7102 errmsg ("%d asynchronous errors", vam->async_errors);
7105 vam->async_errors = 0;
7106 after = vat_time_now (vam);
7108 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7112 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7113 count, after - before, count / (after - before));
7119 /* Wait for a reply... */
7124 /* Return the good/bad news */
7125 return (vam->retval);
7129 api_mpls_ip_bind_unbind (vat_main_t * vam)
7131 unformat_input_t *i = vam->input;
7132 vl_api_mpls_ip_bind_unbind_t *mp;
7133 u32 ip_table_id = 0;
7134 u8 create_table_if_needed = 0;
7137 ip4_address_t v4_address;
7138 ip6_address_t v6_address;
7141 mpls_label_t local_label = MPLS_LABEL_INVALID;
7144 /* Parse args required to build the message */
7145 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7147 if (unformat (i, "%U/%d", unformat_ip4_address,
7148 &v4_address, &address_length))
7153 else if (unformat (i, "%U/%d", unformat_ip6_address,
7154 &v6_address, &address_length))
7159 else if (unformat (i, "%d", &local_label))
7161 else if (unformat (i, "create-table"))
7162 create_table_if_needed = 1;
7163 else if (unformat (i, "table-id %d", &ip_table_id))
7165 else if (unformat (i, "unbind"))
7167 else if (unformat (i, "bind"))
7171 clib_warning ("parse error '%U'", format_unformat_error, i);
7178 errmsg ("IP addres not set");
7182 if (MPLS_LABEL_INVALID == local_label)
7184 errmsg ("missing label");
7188 /* Construct the API message */
7189 M (MPLS_IP_BIND_UNBIND, mp);
7191 mp->mb_create_table_if_needed = create_table_if_needed;
7192 mp->mb_is_bind = is_bind;
7193 mp->mb_is_ip4 = is_ip4;
7194 mp->mb_ip_table_id = ntohl (ip_table_id);
7195 mp->mb_mpls_table_id = 0;
7196 mp->mb_label = ntohl (local_label);
7197 mp->mb_address_length = address_length;
7200 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7202 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7207 /* Wait for a reply... */
7213 api_proxy_arp_add_del (vat_main_t * vam)
7215 unformat_input_t *i = vam->input;
7216 vl_api_proxy_arp_add_del_t *mp;
7219 ip4_address_t lo, hi;
7223 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7225 if (unformat (i, "vrf %d", &vrf_id))
7227 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7228 unformat_ip4_address, &hi))
7230 else if (unformat (i, "del"))
7234 clib_warning ("parse error '%U'", format_unformat_error, i);
7241 errmsg ("address range not set");
7245 M (PROXY_ARP_ADD_DEL, mp);
7247 mp->vrf_id = ntohl (vrf_id);
7248 mp->is_add = is_add;
7249 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7250 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7258 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7260 unformat_input_t *i = vam->input;
7261 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7264 u8 sw_if_index_set = 0;
7267 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7269 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7270 sw_if_index_set = 1;
7271 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7272 sw_if_index_set = 1;
7273 else if (unformat (i, "enable"))
7275 else if (unformat (i, "disable"))
7279 clib_warning ("parse error '%U'", format_unformat_error, i);
7284 if (sw_if_index_set == 0)
7286 errmsg ("missing interface name or sw_if_index");
7290 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7292 mp->sw_if_index = ntohl (sw_if_index);
7293 mp->enable_disable = enable;
7301 api_mpls_tunnel_add_del (vat_main_t * vam)
7303 unformat_input_t *i = vam->input;
7304 vl_api_mpls_tunnel_add_del_t *mp;
7308 u32 sw_if_index = ~0;
7309 u32 next_hop_sw_if_index = ~0;
7310 u32 next_hop_proto_is_ip4 = 1;
7312 u32 next_hop_table_id = 0;
7313 ip4_address_t v4_next_hop_address = {
7316 ip6_address_t v6_next_hop_address = { {0} };
7317 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7320 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7322 if (unformat (i, "add"))
7324 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7326 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7328 else if (unformat (i, "via %U",
7329 unformat_ip4_address, &v4_next_hop_address))
7331 next_hop_proto_is_ip4 = 1;
7333 else if (unformat (i, "via %U",
7334 unformat_ip6_address, &v6_next_hop_address))
7336 next_hop_proto_is_ip4 = 0;
7338 else if (unformat (i, "l2-only"))
7340 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7342 else if (unformat (i, "out-label %d", &next_hop_out_label))
7343 vec_add1 (labels, ntohl (next_hop_out_label));
7346 clib_warning ("parse error '%U'", format_unformat_error, i);
7351 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7353 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7354 mp->mt_sw_if_index = ntohl (sw_if_index);
7355 mp->mt_is_add = is_add;
7356 mp->mt_l2_only = l2_only;
7357 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7358 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7360 mp->mt_next_hop_n_out_labels = vec_len (labels);
7362 if (0 != mp->mt_next_hop_n_out_labels)
7364 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7365 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7369 if (next_hop_proto_is_ip4)
7371 clib_memcpy (mp->mt_next_hop,
7372 &v4_next_hop_address, sizeof (v4_next_hop_address));
7376 clib_memcpy (mp->mt_next_hop,
7377 &v6_next_hop_address, sizeof (v6_next_hop_address));
7386 api_sw_interface_set_unnumbered (vat_main_t * vam)
7388 unformat_input_t *i = vam->input;
7389 vl_api_sw_interface_set_unnumbered_t *mp;
7391 u32 unnum_sw_index = ~0;
7393 u8 sw_if_index_set = 0;
7396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7398 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7399 sw_if_index_set = 1;
7400 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7401 sw_if_index_set = 1;
7402 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7404 else if (unformat (i, "del"))
7408 clib_warning ("parse error '%U'", format_unformat_error, i);
7413 if (sw_if_index_set == 0)
7415 errmsg ("missing interface name or sw_if_index");
7419 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7421 mp->sw_if_index = ntohl (sw_if_index);
7422 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7423 mp->is_add = is_add;
7431 api_ip_neighbor_add_del (vat_main_t * vam)
7433 unformat_input_t *i = vam->input;
7434 vl_api_ip_neighbor_add_del_t *mp;
7436 u8 sw_if_index_set = 0;
7439 u8 is_no_fib_entry = 0;
7442 u8 v4_address_set = 0;
7443 u8 v6_address_set = 0;
7444 ip4_address_t v4address;
7445 ip6_address_t v6address;
7448 memset (mac_address, 0, sizeof (mac_address));
7450 /* Parse args required to build the message */
7451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7453 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7457 else if (unformat (i, "del"))
7460 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7461 sw_if_index_set = 1;
7462 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7463 sw_if_index_set = 1;
7464 else if (unformat (i, "is_static"))
7466 else if (unformat (i, "no-fib-entry"))
7467 is_no_fib_entry = 1;
7468 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7470 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7474 clib_warning ("parse error '%U'", format_unformat_error, i);
7479 if (sw_if_index_set == 0)
7481 errmsg ("missing interface name or sw_if_index");
7484 if (v4_address_set && v6_address_set)
7486 errmsg ("both v4 and v6 addresses set");
7489 if (!v4_address_set && !v6_address_set)
7491 errmsg ("no address set");
7495 /* Construct the API message */
7496 M (IP_NEIGHBOR_ADD_DEL, mp);
7498 mp->sw_if_index = ntohl (sw_if_index);
7499 mp->is_add = is_add;
7500 mp->is_static = is_static;
7501 mp->is_no_adj_fib = is_no_fib_entry;
7503 clib_memcpy (mp->mac_address, mac_address, 6);
7507 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7511 /* mp->is_ipv6 = 0; via memset in M macro above */
7512 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7518 /* Wait for a reply, return good/bad news */
7524 api_reset_vrf (vat_main_t * vam)
7526 unformat_input_t *i = vam->input;
7527 vl_api_reset_vrf_t *mp;
7533 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7535 if (unformat (i, "vrf %d", &vrf_id))
7537 else if (unformat (i, "ipv6"))
7541 clib_warning ("parse error '%U'", format_unformat_error, i);
7546 if (vrf_id_set == 0)
7548 errmsg ("missing vrf id");
7554 mp->vrf_id = ntohl (vrf_id);
7555 mp->is_ipv6 = is_ipv6;
7563 api_create_vlan_subif (vat_main_t * vam)
7565 unformat_input_t *i = vam->input;
7566 vl_api_create_vlan_subif_t *mp;
7568 u8 sw_if_index_set = 0;
7573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7575 if (unformat (i, "sw_if_index %d", &sw_if_index))
7576 sw_if_index_set = 1;
7578 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7579 sw_if_index_set = 1;
7580 else if (unformat (i, "vlan %d", &vlan_id))
7584 clib_warning ("parse error '%U'", format_unformat_error, i);
7589 if (sw_if_index_set == 0)
7591 errmsg ("missing interface name or sw_if_index");
7595 if (vlan_id_set == 0)
7597 errmsg ("missing vlan_id");
7600 M (CREATE_VLAN_SUBIF, mp);
7602 mp->sw_if_index = ntohl (sw_if_index);
7603 mp->vlan_id = ntohl (vlan_id);
7610 #define foreach_create_subif_bit \
7617 _(outer_vlan_id_any) \
7618 _(inner_vlan_id_any)
7621 api_create_subif (vat_main_t * vam)
7623 unformat_input_t *i = vam->input;
7624 vl_api_create_subif_t *mp;
7626 u8 sw_if_index_set = 0;
7633 u32 exact_match = 0;
7634 u32 default_sub = 0;
7635 u32 outer_vlan_id_any = 0;
7636 u32 inner_vlan_id_any = 0;
7638 u16 outer_vlan_id = 0;
7639 u16 inner_vlan_id = 0;
7642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7644 if (unformat (i, "sw_if_index %d", &sw_if_index))
7645 sw_if_index_set = 1;
7647 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7648 sw_if_index_set = 1;
7649 else if (unformat (i, "sub_id %d", &sub_id))
7651 else if (unformat (i, "outer_vlan_id %d", &tmp))
7652 outer_vlan_id = tmp;
7653 else if (unformat (i, "inner_vlan_id %d", &tmp))
7654 inner_vlan_id = tmp;
7656 #define _(a) else if (unformat (i, #a)) a = 1 ;
7657 foreach_create_subif_bit
7661 clib_warning ("parse error '%U'", format_unformat_error, i);
7666 if (sw_if_index_set == 0)
7668 errmsg ("missing interface name or sw_if_index");
7672 if (sub_id_set == 0)
7674 errmsg ("missing sub_id");
7677 M (CREATE_SUBIF, mp);
7679 mp->sw_if_index = ntohl (sw_if_index);
7680 mp->sub_id = ntohl (sub_id);
7682 #define _(a) mp->a = a;
7683 foreach_create_subif_bit;
7686 mp->outer_vlan_id = ntohs (outer_vlan_id);
7687 mp->inner_vlan_id = ntohs (inner_vlan_id);
7695 api_oam_add_del (vat_main_t * vam)
7697 unformat_input_t *i = vam->input;
7698 vl_api_oam_add_del_t *mp;
7701 ip4_address_t src, dst;
7706 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7708 if (unformat (i, "vrf %d", &vrf_id))
7710 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7712 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7714 else if (unformat (i, "del"))
7718 clib_warning ("parse error '%U'", format_unformat_error, i);
7725 errmsg ("missing src addr");
7731 errmsg ("missing dst addr");
7735 M (OAM_ADD_DEL, mp);
7737 mp->vrf_id = ntohl (vrf_id);
7738 mp->is_add = is_add;
7739 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7740 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7748 api_reset_fib (vat_main_t * vam)
7750 unformat_input_t *i = vam->input;
7751 vl_api_reset_fib_t *mp;
7757 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7759 if (unformat (i, "vrf %d", &vrf_id))
7761 else if (unformat (i, "ipv6"))
7765 clib_warning ("parse error '%U'", format_unformat_error, i);
7770 if (vrf_id_set == 0)
7772 errmsg ("missing vrf id");
7778 mp->vrf_id = ntohl (vrf_id);
7779 mp->is_ipv6 = is_ipv6;
7787 api_dhcp_proxy_config (vat_main_t * vam)
7789 unformat_input_t *i = vam->input;
7790 vl_api_dhcp_proxy_config_t *mp;
7792 u32 server_vrf_id = 0;
7794 u8 v4_address_set = 0;
7795 u8 v6_address_set = 0;
7796 ip4_address_t v4address;
7797 ip6_address_t v6address;
7798 u8 v4_src_address_set = 0;
7799 u8 v6_src_address_set = 0;
7800 ip4_address_t v4srcaddress;
7801 ip6_address_t v6srcaddress;
7804 /* Parse args required to build the message */
7805 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7807 if (unformat (i, "del"))
7809 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7811 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7813 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7815 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7817 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7818 v4_src_address_set = 1;
7819 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7820 v6_src_address_set = 1;
7825 if (v4_address_set && v6_address_set)
7827 errmsg ("both v4 and v6 server addresses set");
7830 if (!v4_address_set && !v6_address_set)
7832 errmsg ("no server addresses set");
7836 if (v4_src_address_set && v6_src_address_set)
7838 errmsg ("both v4 and v6 src addresses set");
7841 if (!v4_src_address_set && !v6_src_address_set)
7843 errmsg ("no src addresses set");
7847 if (!(v4_src_address_set && v4_address_set) &&
7848 !(v6_src_address_set && v6_address_set))
7850 errmsg ("no matching server and src addresses set");
7854 /* Construct the API message */
7855 M (DHCP_PROXY_CONFIG, mp);
7857 mp->is_add = is_add;
7858 mp->rx_vrf_id = ntohl (rx_vrf_id);
7859 mp->server_vrf_id = ntohl (server_vrf_id);
7863 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7864 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7868 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7869 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7875 /* Wait for a reply, return good/bad news */
7880 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
7881 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
7884 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
7886 vat_main_t *vam = &vat_main;
7887 u32 i, count = mp->count;
7888 vl_api_dhcp_server_t *s;
7892 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7893 ntohl (mp->rx_vrf_id),
7894 format_ip6_address, mp->dhcp_src_address,
7895 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7898 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7899 ntohl (mp->rx_vrf_id),
7900 format_ip4_address, mp->dhcp_src_address,
7901 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7903 for (i = 0; i < count; i++)
7905 s = &mp->servers[i];
7909 " Server Table-ID %d, Server Address %U",
7910 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
7913 " Server Table-ID %d, Server Address %U",
7914 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
7918 static void vl_api_dhcp_proxy_details_t_handler_json
7919 (vl_api_dhcp_proxy_details_t * mp)
7921 vat_main_t *vam = &vat_main;
7922 vat_json_node_t *node = NULL;
7923 u32 i, count = mp->count;
7925 struct in6_addr ip6;
7926 vl_api_dhcp_server_t *s;
7928 if (VAT_JSON_ARRAY != vam->json_tree.type)
7930 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7931 vat_json_init_array (&vam->json_tree);
7933 node = vat_json_array_add (&vam->json_tree);
7935 vat_json_init_object (node);
7936 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
7937 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
7938 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
7942 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
7943 vat_json_object_add_ip6 (node, "src_address", ip6);
7947 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
7948 vat_json_object_add_ip4 (node, "src_address", ip4);
7951 for (i = 0; i < count; i++)
7953 s = &mp->servers[i];
7955 vat_json_object_add_uint (node, "server-table-id",
7956 ntohl (s->server_vrf_id));
7960 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
7961 vat_json_object_add_ip4 (node, "src_address", ip4);
7965 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
7966 vat_json_object_add_ip6 (node, "server_address", ip6);
7972 api_dhcp_proxy_dump (vat_main_t * vam)
7974 unformat_input_t *i = vam->input;
7975 vl_api_control_ping_t *mp_ping;
7976 vl_api_dhcp_proxy_dump_t *mp;
7980 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7982 if (unformat (i, "ipv6"))
7986 clib_warning ("parse error '%U'", format_unformat_error, i);
7991 M (DHCP_PROXY_DUMP, mp);
7993 mp->is_ip6 = is_ipv6;
7996 /* Use a control ping for synchronization */
7997 M (CONTROL_PING, mp_ping);
8005 api_dhcp_proxy_set_vss (vat_main_t * vam)
8007 unformat_input_t *i = vam->input;
8008 vl_api_dhcp_proxy_set_vss_t *mp;
8019 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8021 if (unformat (i, "tbl_id %d", &tbl_id))
8023 if (unformat (i, "fib_id %d", &fib_id))
8025 if (unformat (i, "oui %d", &oui))
8027 else if (unformat (i, "ipv6"))
8029 else if (unformat (i, "del"))
8033 clib_warning ("parse error '%U'", format_unformat_error, i);
8038 if (tbl_id_set == 0)
8040 errmsg ("missing tbl id");
8044 if (fib_id_set == 0)
8046 errmsg ("missing fib id");
8051 errmsg ("missing oui");
8055 M (DHCP_PROXY_SET_VSS, mp);
8056 mp->tbl_id = ntohl (tbl_id);
8057 mp->fib_id = ntohl (fib_id);
8058 mp->oui = ntohl (oui);
8059 mp->is_ipv6 = is_ipv6;
8060 mp->is_add = is_add;
8068 api_dhcp_client_config (vat_main_t * vam)
8070 unformat_input_t *i = vam->input;
8071 vl_api_dhcp_client_config_t *mp;
8073 u8 sw_if_index_set = 0;
8076 u8 disable_event = 0;
8079 /* Parse args required to build the message */
8080 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8082 if (unformat (i, "del"))
8085 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8086 sw_if_index_set = 1;
8087 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8088 sw_if_index_set = 1;
8089 else if (unformat (i, "hostname %s", &hostname))
8091 else if (unformat (i, "disable_event"))
8097 if (sw_if_index_set == 0)
8099 errmsg ("missing interface name or sw_if_index");
8103 if (vec_len (hostname) > 63)
8105 errmsg ("hostname too long");
8107 vec_add1 (hostname, 0);
8109 /* Construct the API message */
8110 M (DHCP_CLIENT_CONFIG, mp);
8112 mp->sw_if_index = htonl (sw_if_index);
8113 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
8114 vec_free (hostname);
8115 mp->is_add = is_add;
8116 mp->want_dhcp_event = disable_event ? 0 : 1;
8117 mp->pid = htonl (getpid ());
8122 /* Wait for a reply, return good/bad news */
8128 api_set_ip_flow_hash (vat_main_t * vam)
8130 unformat_input_t *i = vam->input;
8131 vl_api_set_ip_flow_hash_t *mp;
8143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8145 if (unformat (i, "vrf %d", &vrf_id))
8147 else if (unformat (i, "ipv6"))
8149 else if (unformat (i, "src"))
8151 else if (unformat (i, "dst"))
8153 else if (unformat (i, "sport"))
8155 else if (unformat (i, "dport"))
8157 else if (unformat (i, "proto"))
8159 else if (unformat (i, "reverse"))
8164 clib_warning ("parse error '%U'", format_unformat_error, i);
8169 if (vrf_id_set == 0)
8171 errmsg ("missing vrf id");
8175 M (SET_IP_FLOW_HASH, mp);
8181 mp->reverse = reverse;
8182 mp->vrf_id = ntohl (vrf_id);
8183 mp->is_ipv6 = is_ipv6;
8191 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8193 unformat_input_t *i = vam->input;
8194 vl_api_sw_interface_ip6_enable_disable_t *mp;
8196 u8 sw_if_index_set = 0;
8200 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8202 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8203 sw_if_index_set = 1;
8204 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8205 sw_if_index_set = 1;
8206 else if (unformat (i, "enable"))
8208 else if (unformat (i, "disable"))
8212 clib_warning ("parse error '%U'", format_unformat_error, i);
8217 if (sw_if_index_set == 0)
8219 errmsg ("missing interface name or sw_if_index");
8223 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8225 mp->sw_if_index = ntohl (sw_if_index);
8226 mp->enable = enable;
8234 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8236 unformat_input_t *i = vam->input;
8237 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8239 u8 sw_if_index_set = 0;
8240 u8 v6_address_set = 0;
8241 ip6_address_t v6address;
8244 /* Parse args required to build the message */
8245 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8247 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8248 sw_if_index_set = 1;
8249 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8250 sw_if_index_set = 1;
8251 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8257 if (sw_if_index_set == 0)
8259 errmsg ("missing interface name or sw_if_index");
8262 if (!v6_address_set)
8264 errmsg ("no address set");
8268 /* Construct the API message */
8269 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8271 mp->sw_if_index = ntohl (sw_if_index);
8272 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8277 /* Wait for a reply, return good/bad news */
8283 api_ip6nd_proxy_add_del (vat_main_t * vam)
8285 unformat_input_t *i = vam->input;
8286 vl_api_ip6nd_proxy_add_del_t *mp;
8287 u32 sw_if_index = ~0;
8288 u8 v6_address_set = 0;
8289 ip6_address_t v6address;
8293 /* Parse args required to build the message */
8294 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8296 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8298 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8300 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8302 if (unformat (i, "del"))
8306 clib_warning ("parse error '%U'", format_unformat_error, i);
8311 if (sw_if_index == ~0)
8313 errmsg ("missing interface name or sw_if_index");
8316 if (!v6_address_set)
8318 errmsg ("no address set");
8322 /* Construct the API message */
8323 M (IP6ND_PROXY_ADD_DEL, mp);
8325 mp->is_del = is_del;
8326 mp->sw_if_index = ntohl (sw_if_index);
8327 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8332 /* Wait for a reply, return good/bad news */
8338 api_ip6nd_proxy_dump (vat_main_t * vam)
8340 vl_api_ip6nd_proxy_dump_t *mp;
8341 vl_api_control_ping_t *mp_ping;
8344 M (IP6ND_PROXY_DUMP, mp);
8348 /* Use a control ping for synchronization */
8349 M (CONTROL_PING, mp_ping);
8356 static void vl_api_ip6nd_proxy_details_t_handler
8357 (vl_api_ip6nd_proxy_details_t * mp)
8359 vat_main_t *vam = &vat_main;
8361 print (vam->ofp, "host %U sw_if_index %d",
8362 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
8365 static void vl_api_ip6nd_proxy_details_t_handler_json
8366 (vl_api_ip6nd_proxy_details_t * mp)
8368 vat_main_t *vam = &vat_main;
8369 struct in6_addr ip6;
8370 vat_json_node_t *node = NULL;
8372 if (VAT_JSON_ARRAY != vam->json_tree.type)
8374 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8375 vat_json_init_array (&vam->json_tree);
8377 node = vat_json_array_add (&vam->json_tree);
8379 vat_json_init_object (node);
8380 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
8382 clib_memcpy (&ip6, mp->address, sizeof (ip6));
8383 vat_json_object_add_ip6 (node, "host", ip6);
8387 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8389 unformat_input_t *i = vam->input;
8390 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8392 u8 sw_if_index_set = 0;
8393 u32 address_length = 0;
8394 u8 v6_address_set = 0;
8395 ip6_address_t v6address;
8397 u8 no_advertise = 0;
8399 u8 no_autoconfig = 0;
8402 u32 val_lifetime = 0;
8403 u32 pref_lifetime = 0;
8406 /* Parse args required to build the message */
8407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8409 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8410 sw_if_index_set = 1;
8411 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8412 sw_if_index_set = 1;
8413 else if (unformat (i, "%U/%d",
8414 unformat_ip6_address, &v6address, &address_length))
8416 else if (unformat (i, "val_life %d", &val_lifetime))
8418 else if (unformat (i, "pref_life %d", &pref_lifetime))
8420 else if (unformat (i, "def"))
8422 else if (unformat (i, "noadv"))
8424 else if (unformat (i, "offl"))
8426 else if (unformat (i, "noauto"))
8428 else if (unformat (i, "nolink"))
8430 else if (unformat (i, "isno"))
8434 clib_warning ("parse error '%U'", format_unformat_error, i);
8439 if (sw_if_index_set == 0)
8441 errmsg ("missing interface name or sw_if_index");
8444 if (!v6_address_set)
8446 errmsg ("no address set");
8450 /* Construct the API message */
8451 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8453 mp->sw_if_index = ntohl (sw_if_index);
8454 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8455 mp->address_length = address_length;
8456 mp->use_default = use_default;
8457 mp->no_advertise = no_advertise;
8458 mp->off_link = off_link;
8459 mp->no_autoconfig = no_autoconfig;
8460 mp->no_onlink = no_onlink;
8462 mp->val_lifetime = ntohl (val_lifetime);
8463 mp->pref_lifetime = ntohl (pref_lifetime);
8468 /* Wait for a reply, return good/bad news */
8474 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8476 unformat_input_t *i = vam->input;
8477 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8479 u8 sw_if_index_set = 0;
8484 u8 send_unicast = 0;
8487 u8 default_router = 0;
8488 u32 max_interval = 0;
8489 u32 min_interval = 0;
8491 u32 initial_count = 0;
8492 u32 initial_interval = 0;
8496 /* Parse args required to build the message */
8497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8499 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8500 sw_if_index_set = 1;
8501 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8502 sw_if_index_set = 1;
8503 else if (unformat (i, "maxint %d", &max_interval))
8505 else if (unformat (i, "minint %d", &min_interval))
8507 else if (unformat (i, "life %d", &lifetime))
8509 else if (unformat (i, "count %d", &initial_count))
8511 else if (unformat (i, "interval %d", &initial_interval))
8513 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8515 else if (unformat (i, "managed"))
8517 else if (unformat (i, "other"))
8519 else if (unformat (i, "ll"))
8521 else if (unformat (i, "send"))
8523 else if (unformat (i, "cease"))
8525 else if (unformat (i, "isno"))
8527 else if (unformat (i, "def"))
8531 clib_warning ("parse error '%U'", format_unformat_error, i);
8536 if (sw_if_index_set == 0)
8538 errmsg ("missing interface name or sw_if_index");
8542 /* Construct the API message */
8543 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8545 mp->sw_if_index = ntohl (sw_if_index);
8546 mp->max_interval = ntohl (max_interval);
8547 mp->min_interval = ntohl (min_interval);
8548 mp->lifetime = ntohl (lifetime);
8549 mp->initial_count = ntohl (initial_count);
8550 mp->initial_interval = ntohl (initial_interval);
8551 mp->suppress = suppress;
8552 mp->managed = managed;
8554 mp->ll_option = ll_option;
8555 mp->send_unicast = send_unicast;
8558 mp->default_router = default_router;
8563 /* Wait for a reply, return good/bad news */
8569 api_set_arp_neighbor_limit (vat_main_t * vam)
8571 unformat_input_t *i = vam->input;
8572 vl_api_set_arp_neighbor_limit_t *mp;
8578 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8580 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8582 else if (unformat (i, "ipv6"))
8586 clib_warning ("parse error '%U'", format_unformat_error, i);
8593 errmsg ("missing limit value");
8597 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8599 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8600 mp->is_ipv6 = is_ipv6;
8608 api_l2_patch_add_del (vat_main_t * vam)
8610 unformat_input_t *i = vam->input;
8611 vl_api_l2_patch_add_del_t *mp;
8613 u8 rx_sw_if_index_set = 0;
8615 u8 tx_sw_if_index_set = 0;
8619 /* Parse args required to build the message */
8620 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8622 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8623 rx_sw_if_index_set = 1;
8624 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8625 tx_sw_if_index_set = 1;
8626 else if (unformat (i, "rx"))
8628 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8630 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8632 rx_sw_if_index_set = 1;
8637 else if (unformat (i, "tx"))
8639 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8641 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8643 tx_sw_if_index_set = 1;
8648 else if (unformat (i, "del"))
8654 if (rx_sw_if_index_set == 0)
8656 errmsg ("missing rx interface name or rx_sw_if_index");
8660 if (tx_sw_if_index_set == 0)
8662 errmsg ("missing tx interface name or tx_sw_if_index");
8666 M (L2_PATCH_ADD_DEL, mp);
8668 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8669 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8670 mp->is_add = is_add;
8678 u8 localsid_addr[16];
8687 api_sr_localsid_add_del (vat_main_t * vam)
8689 unformat_input_t *i = vam->input;
8690 vl_api_sr_localsid_add_del_t *mp;
8693 ip6_address_t localsid;
8697 u32 fib_table = ~(u32) 0;
8698 ip6_address_t next_hop;
8700 bool nexthop_set = 0;
8704 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8706 if (unformat (i, "del"))
8708 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
8709 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
8711 else if (unformat (i, "behavior %u", &behavior));
8712 else if (unformat (i, "sw_if_index %u", &sw_if_index));
8713 else if (unformat (i, "fib-table %u", &fib_table));
8714 else if (unformat (i, "end.psp %u", &behavior));
8719 M (SR_LOCALSID_ADD_DEL, mp);
8721 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
8723 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
8724 mp->behavior = behavior;
8725 mp->sw_if_index = ntohl (sw_if_index);
8726 mp->fib_table = ntohl (fib_table);
8727 mp->end_psp = end_psp;
8728 mp->is_del = is_del;
8736 api_ioam_enable (vat_main_t * vam)
8738 unformat_input_t *input = vam->input;
8739 vl_api_ioam_enable_t *mp;
8741 int has_trace_option = 0;
8742 int has_pot_option = 0;
8743 int has_seqno_option = 0;
8744 int has_analyse_option = 0;
8747 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8749 if (unformat (input, "trace"))
8750 has_trace_option = 1;
8751 else if (unformat (input, "pot"))
8753 else if (unformat (input, "seqno"))
8754 has_seqno_option = 1;
8755 else if (unformat (input, "analyse"))
8756 has_analyse_option = 1;
8760 M (IOAM_ENABLE, mp);
8761 mp->id = htons (id);
8762 mp->seqno = has_seqno_option;
8763 mp->analyse = has_analyse_option;
8764 mp->pot_enable = has_pot_option;
8765 mp->trace_enable = has_trace_option;
8774 api_ioam_disable (vat_main_t * vam)
8776 vl_api_ioam_disable_t *mp;
8779 M (IOAM_DISABLE, mp);
8785 #define foreach_tcp_proto_field \
8789 #define foreach_udp_proto_field \
8793 #define foreach_ip4_proto_field \
8805 u16 src_port, dst_port;
8808 #if VPP_API_TEST_BUILTIN == 0
8810 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8812 u8 **maskp = va_arg (*args, u8 **);
8814 u8 found_something = 0;
8817 #define _(a) u8 a=0;
8818 foreach_tcp_proto_field;
8821 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8824 #define _(a) else if (unformat (input, #a)) a=1;
8825 foreach_tcp_proto_field
8831 #define _(a) found_something += a;
8832 foreach_tcp_proto_field;
8835 if (found_something == 0)
8838 vec_validate (mask, sizeof (*tcp) - 1);
8840 tcp = (tcp_header_t *) mask;
8842 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8843 foreach_tcp_proto_field;
8851 unformat_udp_mask (unformat_input_t * input, va_list * args)
8853 u8 **maskp = va_arg (*args, u8 **);
8855 u8 found_something = 0;
8858 #define _(a) u8 a=0;
8859 foreach_udp_proto_field;
8862 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8865 #define _(a) else if (unformat (input, #a)) a=1;
8866 foreach_udp_proto_field
8872 #define _(a) found_something += a;
8873 foreach_udp_proto_field;
8876 if (found_something == 0)
8879 vec_validate (mask, sizeof (*udp) - 1);
8881 udp = (udp_header_t *) mask;
8883 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8884 foreach_udp_proto_field;
8892 unformat_l4_mask (unformat_input_t * input, va_list * args)
8894 u8 **maskp = va_arg (*args, u8 **);
8895 u16 src_port = 0, dst_port = 0;
8896 tcpudp_header_t *tcpudp;
8898 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8900 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8902 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8904 else if (unformat (input, "src_port"))
8906 else if (unformat (input, "dst_port"))
8912 if (!src_port && !dst_port)
8916 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8918 tcpudp = (tcpudp_header_t *) mask;
8919 tcpudp->src_port = src_port;
8920 tcpudp->dst_port = dst_port;
8928 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8930 u8 **maskp = va_arg (*args, u8 **);
8932 u8 found_something = 0;
8935 #define _(a) u8 a=0;
8936 foreach_ip4_proto_field;
8942 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8944 if (unformat (input, "version"))
8946 else if (unformat (input, "hdr_length"))
8948 else if (unformat (input, "src"))
8950 else if (unformat (input, "dst"))
8952 else if (unformat (input, "proto"))
8955 #define _(a) else if (unformat (input, #a)) a=1;
8956 foreach_ip4_proto_field
8962 #define _(a) found_something += a;
8963 foreach_ip4_proto_field;
8966 if (found_something == 0)
8969 vec_validate (mask, sizeof (*ip) - 1);
8971 ip = (ip4_header_t *) mask;
8973 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8974 foreach_ip4_proto_field;
8977 ip->ip_version_and_header_length = 0;
8980 ip->ip_version_and_header_length |= 0xF0;
8983 ip->ip_version_and_header_length |= 0x0F;
8989 #define foreach_ip6_proto_field \
8997 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8999 u8 **maskp = va_arg (*args, u8 **);
9001 u8 found_something = 0;
9003 u32 ip_version_traffic_class_and_flow_label;
9005 #define _(a) u8 a=0;
9006 foreach_ip6_proto_field;
9009 u8 traffic_class = 0;
9012 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9014 if (unformat (input, "version"))
9016 else if (unformat (input, "traffic-class"))
9018 else if (unformat (input, "flow-label"))
9020 else if (unformat (input, "src"))
9022 else if (unformat (input, "dst"))
9024 else if (unformat (input, "proto"))
9027 #define _(a) else if (unformat (input, #a)) a=1;
9028 foreach_ip6_proto_field
9034 #define _(a) found_something += a;
9035 foreach_ip6_proto_field;
9038 if (found_something == 0)
9041 vec_validate (mask, sizeof (*ip) - 1);
9043 ip = (ip6_header_t *) mask;
9045 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9046 foreach_ip6_proto_field;
9049 ip_version_traffic_class_and_flow_label = 0;
9052 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9055 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9058 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9060 ip->ip_version_traffic_class_and_flow_label =
9061 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9068 unformat_l3_mask (unformat_input_t * input, va_list * args)
9070 u8 **maskp = va_arg (*args, u8 **);
9072 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9074 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9076 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9085 unformat_l2_mask (unformat_input_t * input, va_list * args)
9087 u8 **maskp = va_arg (*args, u8 **);
9102 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9104 if (unformat (input, "src"))
9106 else if (unformat (input, "dst"))
9108 else if (unformat (input, "proto"))
9110 else if (unformat (input, "tag1"))
9112 else if (unformat (input, "tag2"))
9114 else if (unformat (input, "ignore-tag1"))
9116 else if (unformat (input, "ignore-tag2"))
9118 else if (unformat (input, "cos1"))
9120 else if (unformat (input, "cos2"))
9122 else if (unformat (input, "dot1q"))
9124 else if (unformat (input, "dot1ad"))
9129 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9130 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9133 if (tag1 || ignore_tag1 || cos1 || dot1q)
9135 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9138 vec_validate (mask, len - 1);
9141 memset (mask, 0xff, 6);
9144 memset (mask + 6, 0xff, 6);
9148 /* inner vlan tag */
9157 mask[21] = mask[20] = 0xff;
9178 mask[16] = mask[17] = 0xff;
9188 mask[12] = mask[13] = 0xff;
9195 unformat_classify_mask (unformat_input_t * input, va_list * args)
9197 u8 **maskp = va_arg (*args, u8 **);
9198 u32 *skipp = va_arg (*args, u32 *);
9199 u32 *matchp = va_arg (*args, u32 *);
9207 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9209 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9211 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9213 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9215 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9229 if (mask || l2 || l3 || l4)
9233 /* "With a free Ethernet header in every package" */
9235 vec_validate (l2, 13);
9239 vec_append (mask, l3);
9244 vec_append (mask, l4);
9249 /* Scan forward looking for the first significant mask octet */
9250 for (i = 0; i < vec_len (mask); i++)
9254 /* compute (skip, match) params */
9255 *skipp = i / sizeof (u32x4);
9256 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9258 /* Pad mask to an even multiple of the vector size */
9259 while (vec_len (mask) % sizeof (u32x4))
9262 match = vec_len (mask) / sizeof (u32x4);
9264 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9266 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9267 if (*tmp || *(tmp + 1))
9272 clib_warning ("BUG: match 0");
9274 _vec_len (mask) = match * sizeof (u32x4);
9284 #endif /* VPP_API_TEST_BUILTIN */
9286 #define foreach_l2_next \
9288 _(ethernet, ETHERNET_INPUT) \
9293 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9295 u32 *miss_next_indexp = va_arg (*args, u32 *);
9300 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9304 if (unformat (input, "%d", &tmp))
9313 *miss_next_indexp = next_index;
9317 #define foreach_ip_next \
9323 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9325 u32 *miss_next_indexp = va_arg (*args, u32 *);
9330 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9334 if (unformat (input, "%d", &tmp))
9343 *miss_next_indexp = next_index;
9347 #define foreach_acl_next \
9351 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9353 u32 *miss_next_indexp = va_arg (*args, u32 *);
9358 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9362 if (unformat (input, "permit"))
9367 else if (unformat (input, "%d", &tmp))
9376 *miss_next_indexp = next_index;
9381 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9383 u32 *r = va_arg (*args, u32 *);
9385 if (unformat (input, "conform-color"))
9386 *r = POLICE_CONFORM;
9387 else if (unformat (input, "exceed-color"))
9396 api_classify_add_del_table (vat_main_t * vam)
9398 unformat_input_t *i = vam->input;
9399 vl_api_classify_add_del_table_t *mp;
9406 u32 table_index = ~0;
9407 u32 next_table_index = ~0;
9408 u32 miss_next_index = ~0;
9409 u32 memory_size = 32 << 20;
9411 u32 current_data_flag = 0;
9412 int current_data_offset = 0;
9415 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9417 if (unformat (i, "del"))
9419 else if (unformat (i, "del-chain"))
9424 else if (unformat (i, "buckets %d", &nbuckets))
9426 else if (unformat (i, "memory_size %d", &memory_size))
9428 else if (unformat (i, "skip %d", &skip))
9430 else if (unformat (i, "match %d", &match))
9432 else if (unformat (i, "table %d", &table_index))
9434 else if (unformat (i, "mask %U", unformat_classify_mask,
9435 &mask, &skip, &match))
9437 else if (unformat (i, "next-table %d", &next_table_index))
9439 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9442 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9445 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9448 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9450 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9456 if (is_add && mask == 0)
9458 errmsg ("Mask required");
9462 if (is_add && skip == ~0)
9464 errmsg ("skip count required");
9468 if (is_add && match == ~0)
9470 errmsg ("match count required");
9474 if (!is_add && table_index == ~0)
9476 errmsg ("table index required for delete");
9480 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9482 mp->is_add = is_add;
9483 mp->del_chain = del_chain;
9484 mp->table_index = ntohl (table_index);
9485 mp->nbuckets = ntohl (nbuckets);
9486 mp->memory_size = ntohl (memory_size);
9487 mp->skip_n_vectors = ntohl (skip);
9488 mp->match_n_vectors = ntohl (match);
9489 mp->next_table_index = ntohl (next_table_index);
9490 mp->miss_next_index = ntohl (miss_next_index);
9491 mp->current_data_flag = ntohl (current_data_flag);
9492 mp->current_data_offset = ntohl (current_data_offset);
9493 clib_memcpy (mp->mask, mask, vec_len (mask));
9502 #if VPP_API_TEST_BUILTIN == 0
9504 unformat_l4_match (unformat_input_t * input, va_list * args)
9506 u8 **matchp = va_arg (*args, u8 **);
9508 u8 *proto_header = 0;
9514 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9516 if (unformat (input, "src_port %d", &src_port))
9518 else if (unformat (input, "dst_port %d", &dst_port))
9524 h.src_port = clib_host_to_net_u16 (src_port);
9525 h.dst_port = clib_host_to_net_u16 (dst_port);
9526 vec_validate (proto_header, sizeof (h) - 1);
9527 memcpy (proto_header, &h, sizeof (h));
9529 *matchp = proto_header;
9535 unformat_ip4_match (unformat_input_t * input, va_list * args)
9537 u8 **matchp = va_arg (*args, u8 **);
9544 int src = 0, dst = 0;
9545 ip4_address_t src_val, dst_val;
9552 int fragment_id = 0;
9553 u32 fragment_id_val;
9559 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9561 if (unformat (input, "version %d", &version_val))
9563 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9565 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9567 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9569 else if (unformat (input, "proto %d", &proto_val))
9571 else if (unformat (input, "tos %d", &tos_val))
9573 else if (unformat (input, "length %d", &length_val))
9575 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9577 else if (unformat (input, "ttl %d", &ttl_val))
9579 else if (unformat (input, "checksum %d", &checksum_val))
9585 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9586 + ttl + checksum == 0)
9590 * Aligned because we use the real comparison functions
9592 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9594 ip = (ip4_header_t *) match;
9596 /* These are realistically matched in practice */
9598 ip->src_address.as_u32 = src_val.as_u32;
9601 ip->dst_address.as_u32 = dst_val.as_u32;
9604 ip->protocol = proto_val;
9607 /* These are not, but they're included for completeness */
9609 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9612 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9618 ip->length = clib_host_to_net_u16 (length_val);
9624 ip->checksum = clib_host_to_net_u16 (checksum_val);
9631 unformat_ip6_match (unformat_input_t * input, va_list * args)
9633 u8 **matchp = va_arg (*args, u8 **);
9638 u8 traffic_class = 0;
9639 u32 traffic_class_val = 0;
9642 int src = 0, dst = 0;
9643 ip6_address_t src_val, dst_val;
9646 int payload_length = 0;
9647 u32 payload_length_val;
9650 u32 ip_version_traffic_class_and_flow_label;
9652 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9654 if (unformat (input, "version %d", &version_val))
9656 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9658 else if (unformat (input, "flow_label %d", &flow_label_val))
9660 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9662 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9664 else if (unformat (input, "proto %d", &proto_val))
9666 else if (unformat (input, "payload_length %d", &payload_length_val))
9668 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9674 if (version + traffic_class + flow_label + src + dst + proto +
9675 payload_length + hop_limit == 0)
9679 * Aligned because we use the real comparison functions
9681 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9683 ip = (ip6_header_t *) match;
9686 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9689 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9692 ip->protocol = proto_val;
9694 ip_version_traffic_class_and_flow_label = 0;
9697 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9700 ip_version_traffic_class_and_flow_label |=
9701 (traffic_class_val & 0xFF) << 20;
9704 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9706 ip->ip_version_traffic_class_and_flow_label =
9707 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9710 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9713 ip->hop_limit = hop_limit_val;
9720 unformat_l3_match (unformat_input_t * input, va_list * args)
9722 u8 **matchp = va_arg (*args, u8 **);
9724 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9726 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9728 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9737 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9739 u8 *tagp = va_arg (*args, u8 *);
9742 if (unformat (input, "%d", &tag))
9744 tagp[0] = (tag >> 8) & 0x0F;
9745 tagp[1] = tag & 0xFF;
9753 unformat_l2_match (unformat_input_t * input, va_list * args)
9755 u8 **matchp = va_arg (*args, u8 **);
9775 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9777 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9780 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9782 else if (unformat (input, "proto %U",
9783 unformat_ethernet_type_host_byte_order, &proto_val))
9785 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9787 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9789 else if (unformat (input, "ignore-tag1"))
9791 else if (unformat (input, "ignore-tag2"))
9793 else if (unformat (input, "cos1 %d", &cos1_val))
9795 else if (unformat (input, "cos2 %d", &cos2_val))
9800 if ((src + dst + proto + tag1 + tag2 +
9801 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9804 if (tag1 || ignore_tag1 || cos1)
9806 if (tag2 || ignore_tag2 || cos2)
9809 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9812 clib_memcpy (match, dst_val, 6);
9815 clib_memcpy (match + 6, src_val, 6);
9819 /* inner vlan tag */
9820 match[19] = tag2_val[1];
9821 match[18] = tag2_val[0];
9823 match[18] |= (cos2_val & 0x7) << 5;
9826 match[21] = proto_val & 0xff;
9827 match[20] = proto_val >> 8;
9831 match[15] = tag1_val[1];
9832 match[14] = tag1_val[0];
9835 match[14] |= (cos1_val & 0x7) << 5;
9841 match[15] = tag1_val[1];
9842 match[14] = tag1_val[0];
9845 match[17] = proto_val & 0xff;
9846 match[16] = proto_val >> 8;
9849 match[14] |= (cos1_val & 0x7) << 5;
9855 match[18] |= (cos2_val & 0x7) << 5;
9857 match[14] |= (cos1_val & 0x7) << 5;
9860 match[13] = proto_val & 0xff;
9861 match[12] = proto_val >> 8;
9870 api_unformat_classify_match (unformat_input_t * input, va_list * args)
9872 u8 **matchp = va_arg (*args, u8 **);
9873 u32 skip_n_vectors = va_arg (*args, u32);
9874 u32 match_n_vectors = va_arg (*args, u32);
9881 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9883 if (unformat (input, "hex %U", unformat_hex_string, &match))
9885 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9887 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9889 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9903 if (match || l2 || l3 || l4)
9907 /* "Win a free Ethernet header in every packet" */
9909 vec_validate_aligned (l2, 13, sizeof (u32x4));
9913 vec_append_aligned (match, l3, sizeof (u32x4));
9918 vec_append_aligned (match, l4, sizeof (u32x4));
9923 /* Make sure the vector is big enough even if key is all 0's */
9924 vec_validate_aligned
9925 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9928 /* Set size, include skipped vectors */
9929 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9940 api_classify_add_del_session (vat_main_t * vam)
9942 unformat_input_t *i = vam->input;
9943 vl_api_classify_add_del_session_t *mp;
9945 u32 table_index = ~0;
9946 u32 hit_next_index = ~0;
9947 u32 opaque_index = ~0;
9950 u32 skip_n_vectors = 0;
9951 u32 match_n_vectors = 0;
9957 * Warning: you have to supply skip_n and match_n
9958 * because the API client cant simply look at the classify
9962 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9964 if (unformat (i, "del"))
9966 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
9969 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9972 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
9975 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9977 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9979 else if (unformat (i, "opaque-index %d", &opaque_index))
9981 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9983 else if (unformat (i, "match_n %d", &match_n_vectors))
9985 else if (unformat (i, "match %U", api_unformat_classify_match,
9986 &match, skip_n_vectors, match_n_vectors))
9988 else if (unformat (i, "advance %d", &advance))
9990 else if (unformat (i, "table-index %d", &table_index))
9992 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9994 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9996 else if (unformat (i, "action %d", &action))
9998 else if (unformat (i, "metadata %d", &metadata))
10004 if (table_index == ~0)
10006 errmsg ("Table index required");
10010 if (is_add && match == 0)
10012 errmsg ("Match value required");
10016 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10018 mp->is_add = is_add;
10019 mp->table_index = ntohl (table_index);
10020 mp->hit_next_index = ntohl (hit_next_index);
10021 mp->opaque_index = ntohl (opaque_index);
10022 mp->advance = ntohl (advance);
10023 mp->action = action;
10024 mp->metadata = ntohl (metadata);
10025 clib_memcpy (mp->match, match, vec_len (match));
10034 api_classify_set_interface_ip_table (vat_main_t * vam)
10036 unformat_input_t *i = vam->input;
10037 vl_api_classify_set_interface_ip_table_t *mp;
10039 int sw_if_index_set;
10040 u32 table_index = ~0;
10044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10046 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10047 sw_if_index_set = 1;
10048 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10049 sw_if_index_set = 1;
10050 else if (unformat (i, "table %d", &table_index))
10054 clib_warning ("parse error '%U'", format_unformat_error, i);
10059 if (sw_if_index_set == 0)
10061 errmsg ("missing interface name or sw_if_index");
10066 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10068 mp->sw_if_index = ntohl (sw_if_index);
10069 mp->table_index = ntohl (table_index);
10070 mp->is_ipv6 = is_ipv6;
10078 api_classify_set_interface_l2_tables (vat_main_t * vam)
10080 unformat_input_t *i = vam->input;
10081 vl_api_classify_set_interface_l2_tables_t *mp;
10083 int sw_if_index_set;
10084 u32 ip4_table_index = ~0;
10085 u32 ip6_table_index = ~0;
10086 u32 other_table_index = ~0;
10090 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10092 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10093 sw_if_index_set = 1;
10094 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10095 sw_if_index_set = 1;
10096 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10098 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10100 else if (unformat (i, "other-table %d", &other_table_index))
10102 else if (unformat (i, "is-input %d", &is_input))
10106 clib_warning ("parse error '%U'", format_unformat_error, i);
10111 if (sw_if_index_set == 0)
10113 errmsg ("missing interface name or sw_if_index");
10118 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10120 mp->sw_if_index = ntohl (sw_if_index);
10121 mp->ip4_table_index = ntohl (ip4_table_index);
10122 mp->ip6_table_index = ntohl (ip6_table_index);
10123 mp->other_table_index = ntohl (other_table_index);
10124 mp->is_input = (u8) is_input;
10132 api_set_ipfix_exporter (vat_main_t * vam)
10134 unformat_input_t *i = vam->input;
10135 vl_api_set_ipfix_exporter_t *mp;
10136 ip4_address_t collector_address;
10137 u8 collector_address_set = 0;
10138 u32 collector_port = ~0;
10139 ip4_address_t src_address;
10140 u8 src_address_set = 0;
10143 u32 template_interval = ~0;
10144 u8 udp_checksum = 0;
10147 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10149 if (unformat (i, "collector_address %U", unformat_ip4_address,
10150 &collector_address))
10151 collector_address_set = 1;
10152 else if (unformat (i, "collector_port %d", &collector_port))
10154 else if (unformat (i, "src_address %U", unformat_ip4_address,
10156 src_address_set = 1;
10157 else if (unformat (i, "vrf_id %d", &vrf_id))
10159 else if (unformat (i, "path_mtu %d", &path_mtu))
10161 else if (unformat (i, "template_interval %d", &template_interval))
10163 else if (unformat (i, "udp_checksum"))
10169 if (collector_address_set == 0)
10171 errmsg ("collector_address required");
10175 if (src_address_set == 0)
10177 errmsg ("src_address required");
10181 M (SET_IPFIX_EXPORTER, mp);
10183 memcpy (mp->collector_address, collector_address.data,
10184 sizeof (collector_address.data));
10185 mp->collector_port = htons ((u16) collector_port);
10186 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10187 mp->vrf_id = htonl (vrf_id);
10188 mp->path_mtu = htonl (path_mtu);
10189 mp->template_interval = htonl (template_interval);
10190 mp->udp_checksum = udp_checksum;
10198 api_set_ipfix_classify_stream (vat_main_t * vam)
10200 unformat_input_t *i = vam->input;
10201 vl_api_set_ipfix_classify_stream_t *mp;
10203 u32 src_port = UDP_DST_PORT_ipfix;
10206 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10208 if (unformat (i, "domain %d", &domain_id))
10210 else if (unformat (i, "src_port %d", &src_port))
10214 errmsg ("unknown input `%U'", format_unformat_error, i);
10219 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10221 mp->domain_id = htonl (domain_id);
10222 mp->src_port = htons ((u16) src_port);
10230 api_ipfix_classify_table_add_del (vat_main_t * vam)
10232 unformat_input_t *i = vam->input;
10233 vl_api_ipfix_classify_table_add_del_t *mp;
10235 u32 classify_table_index = ~0;
10237 u8 transport_protocol = 255;
10240 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10242 if (unformat (i, "add"))
10244 else if (unformat (i, "del"))
10246 else if (unformat (i, "table %d", &classify_table_index))
10248 else if (unformat (i, "ip4"))
10250 else if (unformat (i, "ip6"))
10252 else if (unformat (i, "tcp"))
10253 transport_protocol = 6;
10254 else if (unformat (i, "udp"))
10255 transport_protocol = 17;
10258 errmsg ("unknown input `%U'", format_unformat_error, i);
10265 errmsg ("expecting: add|del");
10268 if (classify_table_index == ~0)
10270 errmsg ("classifier table not specified");
10273 if (ip_version == 0)
10275 errmsg ("IP version not specified");
10279 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10281 mp->is_add = is_add;
10282 mp->table_id = htonl (classify_table_index);
10283 mp->ip_version = ip_version;
10284 mp->transport_protocol = transport_protocol;
10292 api_get_node_index (vat_main_t * vam)
10294 unformat_input_t *i = vam->input;
10295 vl_api_get_node_index_t *mp;
10299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10301 if (unformat (i, "node %s", &name))
10308 errmsg ("node name required");
10311 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10313 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10317 M (GET_NODE_INDEX, mp);
10318 clib_memcpy (mp->node_name, name, vec_len (name));
10327 api_get_next_index (vat_main_t * vam)
10329 unformat_input_t *i = vam->input;
10330 vl_api_get_next_index_t *mp;
10331 u8 *node_name = 0, *next_node_name = 0;
10334 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10336 if (unformat (i, "node-name %s", &node_name))
10338 else if (unformat (i, "next-node-name %s", &next_node_name))
10342 if (node_name == 0)
10344 errmsg ("node name required");
10347 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10349 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10353 if (next_node_name == 0)
10355 errmsg ("next node name required");
10358 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10360 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10364 M (GET_NEXT_INDEX, mp);
10365 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10366 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10367 vec_free (node_name);
10368 vec_free (next_node_name);
10376 api_add_node_next (vat_main_t * vam)
10378 unformat_input_t *i = vam->input;
10379 vl_api_add_node_next_t *mp;
10384 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10386 if (unformat (i, "node %s", &name))
10388 else if (unformat (i, "next %s", &next))
10395 errmsg ("node name required");
10398 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10400 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10405 errmsg ("next node required");
10408 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10410 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10414 M (ADD_NODE_NEXT, mp);
10415 clib_memcpy (mp->node_name, name, vec_len (name));
10416 clib_memcpy (mp->next_name, next, vec_len (next));
10426 api_l2tpv3_create_tunnel (vat_main_t * vam)
10428 unformat_input_t *i = vam->input;
10429 ip6_address_t client_address, our_address;
10430 int client_address_set = 0;
10431 int our_address_set = 0;
10432 u32 local_session_id = 0;
10433 u32 remote_session_id = 0;
10434 u64 local_cookie = 0;
10435 u64 remote_cookie = 0;
10436 u8 l2_sublayer_present = 0;
10437 vl_api_l2tpv3_create_tunnel_t *mp;
10440 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10442 if (unformat (i, "client_address %U", unformat_ip6_address,
10444 client_address_set = 1;
10445 else if (unformat (i, "our_address %U", unformat_ip6_address,
10447 our_address_set = 1;
10448 else if (unformat (i, "local_session_id %d", &local_session_id))
10450 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10452 else if (unformat (i, "local_cookie %lld", &local_cookie))
10454 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10456 else if (unformat (i, "l2-sublayer-present"))
10457 l2_sublayer_present = 1;
10462 if (client_address_set == 0)
10464 errmsg ("client_address required");
10468 if (our_address_set == 0)
10470 errmsg ("our_address required");
10474 M (L2TPV3_CREATE_TUNNEL, mp);
10476 clib_memcpy (mp->client_address, client_address.as_u8,
10477 sizeof (mp->client_address));
10479 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10481 mp->local_session_id = ntohl (local_session_id);
10482 mp->remote_session_id = ntohl (remote_session_id);
10483 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10484 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10485 mp->l2_sublayer_present = l2_sublayer_present;
10494 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10496 unformat_input_t *i = vam->input;
10498 u8 sw_if_index_set = 0;
10499 u64 new_local_cookie = 0;
10500 u64 new_remote_cookie = 0;
10501 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10504 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10506 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10507 sw_if_index_set = 1;
10508 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10509 sw_if_index_set = 1;
10510 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10512 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10518 if (sw_if_index_set == 0)
10520 errmsg ("missing interface name or sw_if_index");
10524 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10526 mp->sw_if_index = ntohl (sw_if_index);
10527 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10528 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10536 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10538 unformat_input_t *i = vam->input;
10539 vl_api_l2tpv3_interface_enable_disable_t *mp;
10541 u8 sw_if_index_set = 0;
10542 u8 enable_disable = 1;
10545 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10547 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10548 sw_if_index_set = 1;
10549 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10550 sw_if_index_set = 1;
10551 else if (unformat (i, "enable"))
10552 enable_disable = 1;
10553 else if (unformat (i, "disable"))
10554 enable_disable = 0;
10559 if (sw_if_index_set == 0)
10561 errmsg ("missing interface name or sw_if_index");
10565 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10567 mp->sw_if_index = ntohl (sw_if_index);
10568 mp->enable_disable = enable_disable;
10576 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10578 unformat_input_t *i = vam->input;
10579 vl_api_l2tpv3_set_lookup_key_t *mp;
10583 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10585 if (unformat (i, "lookup_v6_src"))
10586 key = L2T_LOOKUP_SRC_ADDRESS;
10587 else if (unformat (i, "lookup_v6_dst"))
10588 key = L2T_LOOKUP_DST_ADDRESS;
10589 else if (unformat (i, "lookup_session_id"))
10590 key = L2T_LOOKUP_SESSION_ID;
10595 if (key == (u8) ~ 0)
10597 errmsg ("l2tp session lookup key unset");
10601 M (L2TPV3_SET_LOOKUP_KEY, mp);
10610 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10611 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10613 vat_main_t *vam = &vat_main;
10615 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10616 format_ip6_address, mp->our_address,
10617 format_ip6_address, mp->client_address,
10618 clib_net_to_host_u32 (mp->sw_if_index));
10621 " local cookies %016llx %016llx remote cookie %016llx",
10622 clib_net_to_host_u64 (mp->local_cookie[0]),
10623 clib_net_to_host_u64 (mp->local_cookie[1]),
10624 clib_net_to_host_u64 (mp->remote_cookie));
10626 print (vam->ofp, " local session-id %d remote session-id %d",
10627 clib_net_to_host_u32 (mp->local_session_id),
10628 clib_net_to_host_u32 (mp->remote_session_id));
10630 print (vam->ofp, " l2 specific sublayer %s\n",
10631 mp->l2_sublayer_present ? "preset" : "absent");
10635 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10636 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10638 vat_main_t *vam = &vat_main;
10639 vat_json_node_t *node = NULL;
10640 struct in6_addr addr;
10642 if (VAT_JSON_ARRAY != vam->json_tree.type)
10644 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10645 vat_json_init_array (&vam->json_tree);
10647 node = vat_json_array_add (&vam->json_tree);
10649 vat_json_init_object (node);
10651 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10652 vat_json_object_add_ip6 (node, "our_address", addr);
10653 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10654 vat_json_object_add_ip6 (node, "client_address", addr);
10656 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10657 vat_json_init_array (lc);
10658 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10659 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10660 vat_json_object_add_uint (node, "remote_cookie",
10661 clib_net_to_host_u64 (mp->remote_cookie));
10663 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10664 vat_json_object_add_uint (node, "local_session_id",
10665 clib_net_to_host_u32 (mp->local_session_id));
10666 vat_json_object_add_uint (node, "remote_session_id",
10667 clib_net_to_host_u32 (mp->remote_session_id));
10668 vat_json_object_add_string_copy (node, "l2_sublayer",
10669 mp->l2_sublayer_present ? (u8 *) "present"
10670 : (u8 *) "absent");
10674 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10676 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10677 vl_api_control_ping_t *mp_ping;
10680 /* Get list of l2tpv3-tunnel interfaces */
10681 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10684 /* Use a control ping for synchronization */
10685 M (CONTROL_PING, mp_ping);
10693 static void vl_api_sw_interface_tap_details_t_handler
10694 (vl_api_sw_interface_tap_details_t * mp)
10696 vat_main_t *vam = &vat_main;
10698 print (vam->ofp, "%-16s %d",
10699 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10702 static void vl_api_sw_interface_tap_details_t_handler_json
10703 (vl_api_sw_interface_tap_details_t * mp)
10705 vat_main_t *vam = &vat_main;
10706 vat_json_node_t *node = NULL;
10708 if (VAT_JSON_ARRAY != vam->json_tree.type)
10710 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10711 vat_json_init_array (&vam->json_tree);
10713 node = vat_json_array_add (&vam->json_tree);
10715 vat_json_init_object (node);
10716 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10717 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10721 api_sw_interface_tap_dump (vat_main_t * vam)
10723 vl_api_sw_interface_tap_dump_t *mp;
10724 vl_api_control_ping_t *mp_ping;
10727 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10728 /* Get list of tap interfaces */
10729 M (SW_INTERFACE_TAP_DUMP, mp);
10732 /* Use a control ping for synchronization */
10733 M (CONTROL_PING, mp_ping);
10740 static uword unformat_vxlan_decap_next
10741 (unformat_input_t * input, va_list * args)
10743 u32 *result = va_arg (*args, u32 *);
10746 if (unformat (input, "l2"))
10747 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10748 else if (unformat (input, "%d", &tmp))
10756 api_vxlan_add_del_tunnel (vat_main_t * vam)
10758 unformat_input_t *line_input = vam->input;
10759 vl_api_vxlan_add_del_tunnel_t *mp;
10760 ip46_address_t src, dst;
10762 u8 ipv4_set = 0, ipv6_set = 0;
10766 u32 mcast_sw_if_index = ~0;
10767 u32 encap_vrf_id = 0;
10768 u32 decap_next_index = ~0;
10772 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10773 memset (&src, 0, sizeof src);
10774 memset (&dst, 0, sizeof dst);
10776 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10778 if (unformat (line_input, "del"))
10781 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10787 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10793 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10799 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10804 else if (unformat (line_input, "group %U %U",
10805 unformat_ip4_address, &dst.ip4,
10806 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10808 grp_set = dst_set = 1;
10811 else if (unformat (line_input, "group %U",
10812 unformat_ip4_address, &dst.ip4))
10814 grp_set = dst_set = 1;
10817 else if (unformat (line_input, "group %U %U",
10818 unformat_ip6_address, &dst.ip6,
10819 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10821 grp_set = dst_set = 1;
10824 else if (unformat (line_input, "group %U",
10825 unformat_ip6_address, &dst.ip6))
10827 grp_set = dst_set = 1;
10831 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10833 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10835 else if (unformat (line_input, "decap-next %U",
10836 unformat_vxlan_decap_next, &decap_next_index))
10838 else if (unformat (line_input, "vni %d", &vni))
10842 errmsg ("parse error '%U'", format_unformat_error, line_input);
10849 errmsg ("tunnel src address not specified");
10854 errmsg ("tunnel dst address not specified");
10858 if (grp_set && !ip46_address_is_multicast (&dst))
10860 errmsg ("tunnel group address not multicast");
10863 if (grp_set && mcast_sw_if_index == ~0)
10865 errmsg ("tunnel nonexistent multicast device");
10868 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10870 errmsg ("tunnel dst address must be unicast");
10875 if (ipv4_set && ipv6_set)
10877 errmsg ("both IPv4 and IPv6 addresses specified");
10881 if ((vni == 0) || (vni >> 24))
10883 errmsg ("vni not specified or out of range");
10887 M (VXLAN_ADD_DEL_TUNNEL, mp);
10891 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10892 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10896 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10897 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10899 mp->encap_vrf_id = ntohl (encap_vrf_id);
10900 mp->decap_next_index = ntohl (decap_next_index);
10901 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10902 mp->vni = ntohl (vni);
10903 mp->is_add = is_add;
10904 mp->is_ipv6 = ipv6_set;
10911 static void vl_api_vxlan_tunnel_details_t_handler
10912 (vl_api_vxlan_tunnel_details_t * mp)
10914 vat_main_t *vam = &vat_main;
10915 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
10916 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
10918 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10919 ntohl (mp->sw_if_index),
10920 format_ip46_address, &src, IP46_TYPE_ANY,
10921 format_ip46_address, &dst, IP46_TYPE_ANY,
10922 ntohl (mp->encap_vrf_id),
10923 ntohl (mp->decap_next_index), ntohl (mp->vni),
10924 ntohl (mp->mcast_sw_if_index));
10927 static void vl_api_vxlan_tunnel_details_t_handler_json
10928 (vl_api_vxlan_tunnel_details_t * mp)
10930 vat_main_t *vam = &vat_main;
10931 vat_json_node_t *node = NULL;
10933 if (VAT_JSON_ARRAY != vam->json_tree.type)
10935 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10936 vat_json_init_array (&vam->json_tree);
10938 node = vat_json_array_add (&vam->json_tree);
10940 vat_json_init_object (node);
10941 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10944 struct in6_addr ip6;
10946 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10947 vat_json_object_add_ip6 (node, "src_address", ip6);
10948 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10949 vat_json_object_add_ip6 (node, "dst_address", ip6);
10953 struct in_addr ip4;
10955 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10956 vat_json_object_add_ip4 (node, "src_address", ip4);
10957 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10958 vat_json_object_add_ip4 (node, "dst_address", ip4);
10960 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10961 vat_json_object_add_uint (node, "decap_next_index",
10962 ntohl (mp->decap_next_index));
10963 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10964 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10965 vat_json_object_add_uint (node, "mcast_sw_if_index",
10966 ntohl (mp->mcast_sw_if_index));
10970 api_vxlan_tunnel_dump (vat_main_t * vam)
10972 unformat_input_t *i = vam->input;
10973 vl_api_vxlan_tunnel_dump_t *mp;
10974 vl_api_control_ping_t *mp_ping;
10976 u8 sw_if_index_set = 0;
10979 /* Parse args required to build the message */
10980 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10982 if (unformat (i, "sw_if_index %d", &sw_if_index))
10983 sw_if_index_set = 1;
10988 if (sw_if_index_set == 0)
10993 if (!vam->json_output)
10995 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10996 "sw_if_index", "src_address", "dst_address",
10997 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11000 /* Get list of vxlan-tunnel interfaces */
11001 M (VXLAN_TUNNEL_DUMP, mp);
11003 mp->sw_if_index = htonl (sw_if_index);
11007 /* Use a control ping for synchronization */
11008 M (CONTROL_PING, mp_ping);
11016 api_gre_add_del_tunnel (vat_main_t * vam)
11018 unformat_input_t *line_input = vam->input;
11019 vl_api_gre_add_del_tunnel_t *mp;
11020 ip4_address_t src4, dst4;
11021 ip6_address_t src6, dst6;
11028 u32 outer_fib_id = 0;
11031 memset (&src4, 0, sizeof src4);
11032 memset (&dst4, 0, sizeof dst4);
11033 memset (&src6, 0, sizeof src6);
11034 memset (&dst6, 0, sizeof dst6);
11036 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11038 if (unformat (line_input, "del"))
11040 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
11045 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
11050 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
11055 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
11060 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
11062 else if (unformat (line_input, "teb"))
11066 errmsg ("parse error '%U'", format_unformat_error, line_input);
11073 errmsg ("tunnel src address not specified");
11078 errmsg ("tunnel dst address not specified");
11081 if (ipv4_set && ipv6_set)
11083 errmsg ("both IPv4 and IPv6 addresses specified");
11088 M (GRE_ADD_DEL_TUNNEL, mp);
11092 clib_memcpy (&mp->src_address, &src4, 4);
11093 clib_memcpy (&mp->dst_address, &dst4, 4);
11097 clib_memcpy (&mp->src_address, &src6, 16);
11098 clib_memcpy (&mp->dst_address, &dst6, 16);
11100 mp->outer_fib_id = ntohl (outer_fib_id);
11101 mp->is_add = is_add;
11103 mp->is_ipv6 = ipv6_set;
11110 static void vl_api_gre_tunnel_details_t_handler
11111 (vl_api_gre_tunnel_details_t * mp)
11113 vat_main_t *vam = &vat_main;
11114 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
11115 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
11117 print (vam->ofp, "%11d%24U%24U%6d%14d",
11118 ntohl (mp->sw_if_index),
11119 format_ip46_address, &src, IP46_TYPE_ANY,
11120 format_ip46_address, &dst, IP46_TYPE_ANY,
11121 mp->teb, ntohl (mp->outer_fib_id));
11124 static void vl_api_gre_tunnel_details_t_handler_json
11125 (vl_api_gre_tunnel_details_t * mp)
11127 vat_main_t *vam = &vat_main;
11128 vat_json_node_t *node = NULL;
11129 struct in_addr ip4;
11130 struct in6_addr ip6;
11132 if (VAT_JSON_ARRAY != vam->json_tree.type)
11134 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11135 vat_json_init_array (&vam->json_tree);
11137 node = vat_json_array_add (&vam->json_tree);
11139 vat_json_init_object (node);
11140 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11143 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11144 vat_json_object_add_ip4 (node, "src_address", ip4);
11145 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11146 vat_json_object_add_ip4 (node, "dst_address", ip4);
11150 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
11151 vat_json_object_add_ip6 (node, "src_address", ip6);
11152 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
11153 vat_json_object_add_ip6 (node, "dst_address", ip6);
11155 vat_json_object_add_uint (node, "teb", mp->teb);
11156 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11157 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
11161 api_gre_tunnel_dump (vat_main_t * vam)
11163 unformat_input_t *i = vam->input;
11164 vl_api_gre_tunnel_dump_t *mp;
11165 vl_api_control_ping_t *mp_ping;
11167 u8 sw_if_index_set = 0;
11170 /* Parse args required to build the message */
11171 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11173 if (unformat (i, "sw_if_index %d", &sw_if_index))
11174 sw_if_index_set = 1;
11179 if (sw_if_index_set == 0)
11184 if (!vam->json_output)
11186 print (vam->ofp, "%11s%24s%24s%6s%14s",
11187 "sw_if_index", "src_address", "dst_address", "teb",
11191 /* Get list of gre-tunnel interfaces */
11192 M (GRE_TUNNEL_DUMP, mp);
11194 mp->sw_if_index = htonl (sw_if_index);
11198 /* Use a control ping for synchronization */
11199 M (CONTROL_PING, mp_ping);
11207 api_l2_fib_clear_table (vat_main_t * vam)
11209 // unformat_input_t * i = vam->input;
11210 vl_api_l2_fib_clear_table_t *mp;
11213 M (L2_FIB_CLEAR_TABLE, mp);
11221 api_l2_interface_efp_filter (vat_main_t * vam)
11223 unformat_input_t *i = vam->input;
11224 vl_api_l2_interface_efp_filter_t *mp;
11227 u8 sw_if_index_set = 0;
11230 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11232 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11233 sw_if_index_set = 1;
11234 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11235 sw_if_index_set = 1;
11236 else if (unformat (i, "enable"))
11238 else if (unformat (i, "disable"))
11242 clib_warning ("parse error '%U'", format_unformat_error, i);
11247 if (sw_if_index_set == 0)
11249 errmsg ("missing sw_if_index");
11253 M (L2_INTERFACE_EFP_FILTER, mp);
11255 mp->sw_if_index = ntohl (sw_if_index);
11256 mp->enable_disable = enable;
11263 #define foreach_vtr_op \
11264 _("disable", L2_VTR_DISABLED) \
11265 _("push-1", L2_VTR_PUSH_1) \
11266 _("push-2", L2_VTR_PUSH_2) \
11267 _("pop-1", L2_VTR_POP_1) \
11268 _("pop-2", L2_VTR_POP_2) \
11269 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11270 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11271 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11272 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11275 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11277 unformat_input_t *i = vam->input;
11278 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11280 u8 sw_if_index_set = 0;
11283 u32 push_dot1q = 1;
11288 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11290 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11291 sw_if_index_set = 1;
11292 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11293 sw_if_index_set = 1;
11294 else if (unformat (i, "vtr_op %d", &vtr_op))
11296 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11299 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11301 else if (unformat (i, "tag1 %d", &tag1))
11303 else if (unformat (i, "tag2 %d", &tag2))
11307 clib_warning ("parse error '%U'", format_unformat_error, i);
11312 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11314 errmsg ("missing vtr operation or sw_if_index");
11318 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11319 mp->sw_if_index = ntohl (sw_if_index);
11320 mp->vtr_op = ntohl (vtr_op);
11321 mp->push_dot1q = ntohl (push_dot1q);
11322 mp->tag1 = ntohl (tag1);
11323 mp->tag2 = ntohl (tag2);
11331 api_create_vhost_user_if (vat_main_t * vam)
11333 unformat_input_t *i = vam->input;
11334 vl_api_create_vhost_user_if_t *mp;
11337 u8 file_name_set = 0;
11338 u32 custom_dev_instance = ~0;
11340 u8 use_custom_mac = 0;
11343 u8 operation_mode = VHOST_USER_POLLING_MODE;
11345 /* Shut up coverity */
11346 memset (hwaddr, 0, sizeof (hwaddr));
11348 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11350 if (unformat (i, "socket %s", &file_name))
11354 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11356 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11357 use_custom_mac = 1;
11358 else if (unformat (i, "server"))
11360 else if (unformat (i, "tag %s", &tag))
11362 else if (unformat (i, "mode %U",
11363 api_unformat_vhost_user_operation_mode,
11370 if (file_name_set == 0)
11372 errmsg ("missing socket file name");
11376 if (vec_len (file_name) > 255)
11378 errmsg ("socket file name too long");
11381 vec_add1 (file_name, 0);
11383 M (CREATE_VHOST_USER_IF, mp);
11385 mp->operation_mode = operation_mode;
11386 mp->is_server = is_server;
11387 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11388 vec_free (file_name);
11389 if (custom_dev_instance != ~0)
11392 mp->custom_dev_instance = ntohl (custom_dev_instance);
11394 mp->use_custom_mac = use_custom_mac;
11395 clib_memcpy (mp->mac_address, hwaddr, 6);
11397 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11406 api_modify_vhost_user_if (vat_main_t * vam)
11408 unformat_input_t *i = vam->input;
11409 vl_api_modify_vhost_user_if_t *mp;
11412 u8 file_name_set = 0;
11413 u32 custom_dev_instance = ~0;
11414 u8 sw_if_index_set = 0;
11415 u32 sw_if_index = (u32) ~ 0;
11417 u8 operation_mode = VHOST_USER_POLLING_MODE;
11419 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11421 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11422 sw_if_index_set = 1;
11423 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11424 sw_if_index_set = 1;
11425 else if (unformat (i, "socket %s", &file_name))
11429 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11431 else if (unformat (i, "server"))
11433 else if (unformat (i, "mode %U",
11434 api_unformat_vhost_user_operation_mode,
11441 if (sw_if_index_set == 0)
11443 errmsg ("missing sw_if_index or interface name");
11447 if (file_name_set == 0)
11449 errmsg ("missing socket file name");
11453 if (vec_len (file_name) > 255)
11455 errmsg ("socket file name too long");
11458 vec_add1 (file_name, 0);
11460 M (MODIFY_VHOST_USER_IF, mp);
11462 mp->operation_mode = operation_mode;
11463 mp->sw_if_index = ntohl (sw_if_index);
11464 mp->is_server = is_server;
11465 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11466 vec_free (file_name);
11467 if (custom_dev_instance != ~0)
11470 mp->custom_dev_instance = ntohl (custom_dev_instance);
11479 api_delete_vhost_user_if (vat_main_t * vam)
11481 unformat_input_t *i = vam->input;
11482 vl_api_delete_vhost_user_if_t *mp;
11483 u32 sw_if_index = ~0;
11484 u8 sw_if_index_set = 0;
11487 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11489 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11490 sw_if_index_set = 1;
11491 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11492 sw_if_index_set = 1;
11497 if (sw_if_index_set == 0)
11499 errmsg ("missing sw_if_index or interface name");
11504 M (DELETE_VHOST_USER_IF, mp);
11506 mp->sw_if_index = ntohl (sw_if_index);
11513 static void vl_api_sw_interface_vhost_user_details_t_handler
11514 (vl_api_sw_interface_vhost_user_details_t * mp)
11516 vat_main_t *vam = &vat_main;
11518 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %U %s",
11519 (char *) mp->interface_name,
11520 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11521 clib_net_to_host_u64 (mp->features), mp->is_server,
11522 ntohl (mp->num_regions), api_format_vhost_user_operation_mode,
11523 mp->operation_mode, (char *) mp->sock_filename);
11524 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11527 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11528 (vl_api_sw_interface_vhost_user_details_t * mp)
11530 vat_main_t *vam = &vat_main;
11531 vat_json_node_t *node = NULL;
11533 if (VAT_JSON_ARRAY != vam->json_tree.type)
11535 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11536 vat_json_init_array (&vam->json_tree);
11538 node = vat_json_array_add (&vam->json_tree);
11540 vat_json_init_object (node);
11541 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11542 vat_json_object_add_string_copy (node, "interface_name",
11543 mp->interface_name);
11544 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11545 ntohl (mp->virtio_net_hdr_sz));
11546 vat_json_object_add_uint (node, "features",
11547 clib_net_to_host_u64 (mp->features));
11548 vat_json_object_add_uint (node, "is_server", mp->is_server);
11549 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11550 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11551 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11552 vat_json_object_add_uint (node, "mode", mp->operation_mode);
11556 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11558 vl_api_sw_interface_vhost_user_dump_t *mp;
11559 vl_api_control_ping_t *mp_ping;
11562 "Interface name idx hdr_sz features server regions mode"
11565 /* Get list of vhost-user interfaces */
11566 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11569 /* Use a control ping for synchronization */
11570 M (CONTROL_PING, mp_ping);
11578 api_show_version (vat_main_t * vam)
11580 vl_api_show_version_t *mp;
11583 M (SHOW_VERSION, mp);
11592 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11594 unformat_input_t *line_input = vam->input;
11595 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11596 ip4_address_t local4, remote4;
11597 ip6_address_t local6, remote6;
11599 u8 ipv4_set = 0, ipv6_set = 0;
11602 u32 encap_vrf_id = 0;
11603 u32 decap_vrf_id = 0;
11609 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11611 if (unformat (line_input, "del"))
11613 else if (unformat (line_input, "local %U",
11614 unformat_ip4_address, &local4))
11619 else if (unformat (line_input, "remote %U",
11620 unformat_ip4_address, &remote4))
11625 else if (unformat (line_input, "local %U",
11626 unformat_ip6_address, &local6))
11631 else if (unformat (line_input, "remote %U",
11632 unformat_ip6_address, &remote6))
11637 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11639 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11641 else if (unformat (line_input, "vni %d", &vni))
11643 else if (unformat (line_input, "next-ip4"))
11645 else if (unformat (line_input, "next-ip6"))
11647 else if (unformat (line_input, "next-ethernet"))
11649 else if (unformat (line_input, "next-nsh"))
11653 errmsg ("parse error '%U'", format_unformat_error, line_input);
11658 if (local_set == 0)
11660 errmsg ("tunnel local address not specified");
11663 if (remote_set == 0)
11665 errmsg ("tunnel remote address not specified");
11668 if (ipv4_set && ipv6_set)
11670 errmsg ("both IPv4 and IPv6 addresses specified");
11676 errmsg ("vni not specified");
11680 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11685 clib_memcpy (&mp->local, &local6, sizeof (local6));
11686 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11690 clib_memcpy (&mp->local, &local4, sizeof (local4));
11691 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11694 mp->encap_vrf_id = ntohl (encap_vrf_id);
11695 mp->decap_vrf_id = ntohl (decap_vrf_id);
11696 mp->protocol = protocol;
11697 mp->vni = ntohl (vni);
11698 mp->is_add = is_add;
11699 mp->is_ipv6 = ipv6_set;
11706 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11707 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11709 vat_main_t *vam = &vat_main;
11711 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11712 ntohl (mp->sw_if_index),
11713 format_ip46_address, &(mp->local[0]),
11714 format_ip46_address, &(mp->remote[0]),
11716 ntohl (mp->protocol),
11717 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11720 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11721 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11723 vat_main_t *vam = &vat_main;
11724 vat_json_node_t *node = NULL;
11725 struct in_addr ip4;
11726 struct in6_addr ip6;
11728 if (VAT_JSON_ARRAY != vam->json_tree.type)
11730 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11731 vat_json_init_array (&vam->json_tree);
11733 node = vat_json_array_add (&vam->json_tree);
11735 vat_json_init_object (node);
11736 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11739 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11740 vat_json_object_add_ip6 (node, "local", ip6);
11741 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11742 vat_json_object_add_ip6 (node, "remote", ip6);
11746 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11747 vat_json_object_add_ip4 (node, "local", ip4);
11748 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11749 vat_json_object_add_ip4 (node, "remote", ip4);
11751 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11752 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11753 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11754 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11755 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11759 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11761 unformat_input_t *i = vam->input;
11762 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11763 vl_api_control_ping_t *mp_ping;
11765 u8 sw_if_index_set = 0;
11768 /* Parse args required to build the message */
11769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11771 if (unformat (i, "sw_if_index %d", &sw_if_index))
11772 sw_if_index_set = 1;
11777 if (sw_if_index_set == 0)
11782 if (!vam->json_output)
11784 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11785 "sw_if_index", "local", "remote", "vni",
11786 "protocol", "encap_vrf_id", "decap_vrf_id");
11789 /* Get list of vxlan-tunnel interfaces */
11790 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11792 mp->sw_if_index = htonl (sw_if_index);
11796 /* Use a control ping for synchronization */
11797 M (CONTROL_PING, mp_ping);
11805 format_l2_fib_mac_address (u8 * s, va_list * args)
11807 u8 *a = va_arg (*args, u8 *);
11809 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11810 a[2], a[3], a[4], a[5], a[6], a[7]);
11813 static void vl_api_l2_fib_table_entry_t_handler
11814 (vl_api_l2_fib_table_entry_t * mp)
11816 vat_main_t *vam = &vat_main;
11818 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11820 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11821 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11825 static void vl_api_l2_fib_table_entry_t_handler_json
11826 (vl_api_l2_fib_table_entry_t * mp)
11828 vat_main_t *vam = &vat_main;
11829 vat_json_node_t *node = NULL;
11831 if (VAT_JSON_ARRAY != vam->json_tree.type)
11833 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11834 vat_json_init_array (&vam->json_tree);
11836 node = vat_json_array_add (&vam->json_tree);
11838 vat_json_init_object (node);
11839 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11840 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11841 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11842 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11843 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11844 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11848 api_l2_fib_table_dump (vat_main_t * vam)
11850 unformat_input_t *i = vam->input;
11851 vl_api_l2_fib_table_dump_t *mp;
11852 vl_api_control_ping_t *mp_ping;
11857 /* Parse args required to build the message */
11858 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11860 if (unformat (i, "bd_id %d", &bd_id))
11866 if (bd_id_set == 0)
11868 errmsg ("missing bridge domain");
11872 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11874 /* Get list of l2 fib entries */
11875 M (L2_FIB_TABLE_DUMP, mp);
11877 mp->bd_id = ntohl (bd_id);
11880 /* Use a control ping for synchronization */
11881 M (CONTROL_PING, mp_ping);
11890 api_interface_name_renumber (vat_main_t * vam)
11892 unformat_input_t *line_input = vam->input;
11893 vl_api_interface_name_renumber_t *mp;
11894 u32 sw_if_index = ~0;
11895 u32 new_show_dev_instance = ~0;
11898 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11900 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11903 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11905 else if (unformat (line_input, "new_show_dev_instance %d",
11906 &new_show_dev_instance))
11912 if (sw_if_index == ~0)
11914 errmsg ("missing interface name or sw_if_index");
11918 if (new_show_dev_instance == ~0)
11920 errmsg ("missing new_show_dev_instance");
11924 M (INTERFACE_NAME_RENUMBER, mp);
11926 mp->sw_if_index = ntohl (sw_if_index);
11927 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11935 api_want_ip4_arp_events (vat_main_t * vam)
11937 unformat_input_t *line_input = vam->input;
11938 vl_api_want_ip4_arp_events_t *mp;
11939 ip4_address_t address;
11940 int address_set = 0;
11941 u32 enable_disable = 1;
11944 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11946 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11948 else if (unformat (line_input, "del"))
11949 enable_disable = 0;
11954 if (address_set == 0)
11956 errmsg ("missing addresses");
11960 M (WANT_IP4_ARP_EVENTS, mp);
11961 mp->enable_disable = enable_disable;
11962 mp->pid = htonl (getpid ());
11963 mp->address = address.as_u32;
11971 api_want_ip6_nd_events (vat_main_t * vam)
11973 unformat_input_t *line_input = vam->input;
11974 vl_api_want_ip6_nd_events_t *mp;
11975 ip6_address_t address;
11976 int address_set = 0;
11977 u32 enable_disable = 1;
11980 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11982 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11984 else if (unformat (line_input, "del"))
11985 enable_disable = 0;
11990 if (address_set == 0)
11992 errmsg ("missing addresses");
11996 M (WANT_IP6_ND_EVENTS, mp);
11997 mp->enable_disable = enable_disable;
11998 mp->pid = htonl (getpid ());
11999 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
12007 api_input_acl_set_interface (vat_main_t * vam)
12009 unformat_input_t *i = vam->input;
12010 vl_api_input_acl_set_interface_t *mp;
12012 int sw_if_index_set;
12013 u32 ip4_table_index = ~0;
12014 u32 ip6_table_index = ~0;
12015 u32 l2_table_index = ~0;
12019 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12021 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12022 sw_if_index_set = 1;
12023 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12024 sw_if_index_set = 1;
12025 else if (unformat (i, "del"))
12027 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12029 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12031 else if (unformat (i, "l2-table %d", &l2_table_index))
12035 clib_warning ("parse error '%U'", format_unformat_error, i);
12040 if (sw_if_index_set == 0)
12042 errmsg ("missing interface name or sw_if_index");
12046 M (INPUT_ACL_SET_INTERFACE, mp);
12048 mp->sw_if_index = ntohl (sw_if_index);
12049 mp->ip4_table_index = ntohl (ip4_table_index);
12050 mp->ip6_table_index = ntohl (ip6_table_index);
12051 mp->l2_table_index = ntohl (l2_table_index);
12052 mp->is_add = is_add;
12060 api_ip_address_dump (vat_main_t * vam)
12062 unformat_input_t *i = vam->input;
12063 vl_api_ip_address_dump_t *mp;
12064 vl_api_control_ping_t *mp_ping;
12065 u32 sw_if_index = ~0;
12066 u8 sw_if_index_set = 0;
12071 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12073 if (unformat (i, "sw_if_index %d", &sw_if_index))
12074 sw_if_index_set = 1;
12076 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12077 sw_if_index_set = 1;
12078 else if (unformat (i, "ipv4"))
12080 else if (unformat (i, "ipv6"))
12086 if (ipv4_set && ipv6_set)
12088 errmsg ("ipv4 and ipv6 flags cannot be both set");
12092 if ((!ipv4_set) && (!ipv6_set))
12094 errmsg ("no ipv4 nor ipv6 flag set");
12098 if (sw_if_index_set == 0)
12100 errmsg ("missing interface name or sw_if_index");
12104 vam->current_sw_if_index = sw_if_index;
12105 vam->is_ipv6 = ipv6_set;
12107 M (IP_ADDRESS_DUMP, mp);
12108 mp->sw_if_index = ntohl (sw_if_index);
12109 mp->is_ipv6 = ipv6_set;
12112 /* Use a control ping for synchronization */
12113 M (CONTROL_PING, mp_ping);
12121 api_ip_dump (vat_main_t * vam)
12123 vl_api_ip_dump_t *mp;
12124 vl_api_control_ping_t *mp_ping;
12125 unformat_input_t *in = vam->input;
12132 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
12134 if (unformat (in, "ipv4"))
12136 else if (unformat (in, "ipv6"))
12142 if (ipv4_set && ipv6_set)
12144 errmsg ("ipv4 and ipv6 flags cannot be both set");
12148 if ((!ipv4_set) && (!ipv6_set))
12150 errmsg ("no ipv4 nor ipv6 flag set");
12154 is_ipv6 = ipv6_set;
12155 vam->is_ipv6 = is_ipv6;
12157 /* free old data */
12158 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12160 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12162 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12165 mp->is_ipv6 = ipv6_set;
12168 /* Use a control ping for synchronization */
12169 M (CONTROL_PING, mp_ping);
12177 api_ipsec_spd_add_del (vat_main_t * vam)
12179 unformat_input_t *i = vam->input;
12180 vl_api_ipsec_spd_add_del_t *mp;
12185 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12187 if (unformat (i, "spd_id %d", &spd_id))
12189 else if (unformat (i, "del"))
12193 clib_warning ("parse error '%U'", format_unformat_error, i);
12199 errmsg ("spd_id must be set");
12203 M (IPSEC_SPD_ADD_DEL, mp);
12205 mp->spd_id = ntohl (spd_id);
12206 mp->is_add = is_add;
12214 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12216 unformat_input_t *i = vam->input;
12217 vl_api_ipsec_interface_add_del_spd_t *mp;
12219 u8 sw_if_index_set = 0;
12220 u32 spd_id = (u32) ~ 0;
12224 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12226 if (unformat (i, "del"))
12228 else if (unformat (i, "spd_id %d", &spd_id))
12231 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12232 sw_if_index_set = 1;
12233 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12234 sw_if_index_set = 1;
12237 clib_warning ("parse error '%U'", format_unformat_error, i);
12243 if (spd_id == (u32) ~ 0)
12245 errmsg ("spd_id must be set");
12249 if (sw_if_index_set == 0)
12251 errmsg ("missing interface name or sw_if_index");
12255 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12257 mp->spd_id = ntohl (spd_id);
12258 mp->sw_if_index = ntohl (sw_if_index);
12259 mp->is_add = is_add;
12267 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12269 unformat_input_t *i = vam->input;
12270 vl_api_ipsec_spd_add_del_entry_t *mp;
12271 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12272 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12274 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12275 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12276 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12277 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12280 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12281 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12282 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12283 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12284 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12285 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12287 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12289 if (unformat (i, "del"))
12291 if (unformat (i, "outbound"))
12293 if (unformat (i, "inbound"))
12295 else if (unformat (i, "spd_id %d", &spd_id))
12297 else if (unformat (i, "sa_id %d", &sa_id))
12299 else if (unformat (i, "priority %d", &priority))
12301 else if (unformat (i, "protocol %d", &protocol))
12303 else if (unformat (i, "lport_start %d", &lport_start))
12305 else if (unformat (i, "lport_stop %d", &lport_stop))
12307 else if (unformat (i, "rport_start %d", &rport_start))
12309 else if (unformat (i, "rport_stop %d", &rport_stop))
12313 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12319 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12326 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12332 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12339 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12345 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12352 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12358 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12364 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12366 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12368 clib_warning ("unsupported action: 'resolve'");
12374 clib_warning ("parse error '%U'", format_unformat_error, i);
12380 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12382 mp->spd_id = ntohl (spd_id);
12383 mp->priority = ntohl (priority);
12384 mp->is_outbound = is_outbound;
12386 mp->is_ipv6 = is_ipv6;
12387 if (is_ipv6 || is_ip_any)
12389 clib_memcpy (mp->remote_address_start, &raddr6_start,
12390 sizeof (ip6_address_t));
12391 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12392 sizeof (ip6_address_t));
12393 clib_memcpy (mp->local_address_start, &laddr6_start,
12394 sizeof (ip6_address_t));
12395 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12396 sizeof (ip6_address_t));
12400 clib_memcpy (mp->remote_address_start, &raddr4_start,
12401 sizeof (ip4_address_t));
12402 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12403 sizeof (ip4_address_t));
12404 clib_memcpy (mp->local_address_start, &laddr4_start,
12405 sizeof (ip4_address_t));
12406 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12407 sizeof (ip4_address_t));
12409 mp->protocol = (u8) protocol;
12410 mp->local_port_start = ntohs ((u16) lport_start);
12411 mp->local_port_stop = ntohs ((u16) lport_stop);
12412 mp->remote_port_start = ntohs ((u16) rport_start);
12413 mp->remote_port_stop = ntohs ((u16) rport_stop);
12414 mp->policy = (u8) policy;
12415 mp->sa_id = ntohl (sa_id);
12416 mp->is_add = is_add;
12417 mp->is_ip_any = is_ip_any;
12424 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12426 unformat_input_t *i = vam->input;
12427 vl_api_ipsec_sad_add_del_entry_t *mp;
12428 u32 sad_id = 0, spi = 0;
12429 u8 *ck = 0, *ik = 0;
12432 u8 protocol = IPSEC_PROTOCOL_AH;
12433 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12434 u32 crypto_alg = 0, integ_alg = 0;
12435 ip4_address_t tun_src4;
12436 ip4_address_t tun_dst4;
12437 ip6_address_t tun_src6;
12438 ip6_address_t tun_dst6;
12441 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12443 if (unformat (i, "del"))
12445 else if (unformat (i, "sad_id %d", &sad_id))
12447 else if (unformat (i, "spi %d", &spi))
12449 else if (unformat (i, "esp"))
12450 protocol = IPSEC_PROTOCOL_ESP;
12451 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12454 is_tunnel_ipv6 = 0;
12456 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12459 is_tunnel_ipv6 = 0;
12461 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12464 is_tunnel_ipv6 = 1;
12466 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12469 is_tunnel_ipv6 = 1;
12473 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12475 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12476 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12478 clib_warning ("unsupported crypto-alg: '%U'",
12479 format_ipsec_crypto_alg, crypto_alg);
12483 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12487 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12489 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12490 integ_alg >= IPSEC_INTEG_N_ALG)
12492 clib_warning ("unsupported integ-alg: '%U'",
12493 format_ipsec_integ_alg, integ_alg);
12497 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12501 clib_warning ("parse error '%U'", format_unformat_error, i);
12507 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12509 mp->sad_id = ntohl (sad_id);
12510 mp->is_add = is_add;
12511 mp->protocol = protocol;
12512 mp->spi = ntohl (spi);
12513 mp->is_tunnel = is_tunnel;
12514 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12515 mp->crypto_algorithm = crypto_alg;
12516 mp->integrity_algorithm = integ_alg;
12517 mp->crypto_key_length = vec_len (ck);
12518 mp->integrity_key_length = vec_len (ik);
12520 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12521 mp->crypto_key_length = sizeof (mp->crypto_key);
12523 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12524 mp->integrity_key_length = sizeof (mp->integrity_key);
12527 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12529 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12533 if (is_tunnel_ipv6)
12535 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12536 sizeof (ip6_address_t));
12537 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12538 sizeof (ip6_address_t));
12542 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12543 sizeof (ip4_address_t));
12544 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12545 sizeof (ip4_address_t));
12555 api_ipsec_sa_set_key (vat_main_t * vam)
12557 unformat_input_t *i = vam->input;
12558 vl_api_ipsec_sa_set_key_t *mp;
12560 u8 *ck = 0, *ik = 0;
12563 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12565 if (unformat (i, "sa_id %d", &sa_id))
12567 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12569 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12573 clib_warning ("parse error '%U'", format_unformat_error, i);
12578 M (IPSEC_SA_SET_KEY, mp);
12580 mp->sa_id = ntohl (sa_id);
12581 mp->crypto_key_length = vec_len (ck);
12582 mp->integrity_key_length = vec_len (ik);
12584 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12585 mp->crypto_key_length = sizeof (mp->crypto_key);
12587 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12588 mp->integrity_key_length = sizeof (mp->integrity_key);
12591 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12593 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12601 api_ikev2_profile_add_del (vat_main_t * vam)
12603 unformat_input_t *i = vam->input;
12604 vl_api_ikev2_profile_add_del_t *mp;
12609 const char *valid_chars = "a-zA-Z0-9_";
12611 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12613 if (unformat (i, "del"))
12615 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12616 vec_add1 (name, 0);
12619 errmsg ("parse error '%U'", format_unformat_error, i);
12624 if (!vec_len (name))
12626 errmsg ("profile name must be specified");
12630 if (vec_len (name) > 64)
12632 errmsg ("profile name too long");
12636 M (IKEV2_PROFILE_ADD_DEL, mp);
12638 clib_memcpy (mp->name, name, vec_len (name));
12639 mp->is_add = is_add;
12648 api_ikev2_profile_set_auth (vat_main_t * vam)
12650 unformat_input_t *i = vam->input;
12651 vl_api_ikev2_profile_set_auth_t *mp;
12654 u32 auth_method = 0;
12658 const char *valid_chars = "a-zA-Z0-9_";
12660 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12662 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12663 vec_add1 (name, 0);
12664 else if (unformat (i, "auth_method %U",
12665 unformat_ikev2_auth_method, &auth_method))
12667 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12669 else if (unformat (i, "auth_data %v", &data))
12673 errmsg ("parse error '%U'", format_unformat_error, i);
12678 if (!vec_len (name))
12680 errmsg ("profile name must be specified");
12684 if (vec_len (name) > 64)
12686 errmsg ("profile name too long");
12690 if (!vec_len (data))
12692 errmsg ("auth_data must be specified");
12698 errmsg ("auth_method must be specified");
12702 M (IKEV2_PROFILE_SET_AUTH, mp);
12704 mp->is_hex = is_hex;
12705 mp->auth_method = (u8) auth_method;
12706 mp->data_len = vec_len (data);
12707 clib_memcpy (mp->name, name, vec_len (name));
12708 clib_memcpy (mp->data, data, vec_len (data));
12718 api_ikev2_profile_set_id (vat_main_t * vam)
12720 unformat_input_t *i = vam->input;
12721 vl_api_ikev2_profile_set_id_t *mp;
12729 const char *valid_chars = "a-zA-Z0-9_";
12731 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12733 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12734 vec_add1 (name, 0);
12735 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12737 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12739 data = vec_new (u8, 4);
12740 clib_memcpy (data, ip4.as_u8, 4);
12742 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12744 else if (unformat (i, "id_data %v", &data))
12746 else if (unformat (i, "local"))
12748 else if (unformat (i, "remote"))
12752 errmsg ("parse error '%U'", format_unformat_error, i);
12757 if (!vec_len (name))
12759 errmsg ("profile name must be specified");
12763 if (vec_len (name) > 64)
12765 errmsg ("profile name too long");
12769 if (!vec_len (data))
12771 errmsg ("id_data must be specified");
12777 errmsg ("id_type must be specified");
12781 M (IKEV2_PROFILE_SET_ID, mp);
12783 mp->is_local = is_local;
12784 mp->id_type = (u8) id_type;
12785 mp->data_len = vec_len (data);
12786 clib_memcpy (mp->name, name, vec_len (name));
12787 clib_memcpy (mp->data, data, vec_len (data));
12797 api_ikev2_profile_set_ts (vat_main_t * vam)
12799 unformat_input_t *i = vam->input;
12800 vl_api_ikev2_profile_set_ts_t *mp;
12803 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12804 ip4_address_t start_addr, end_addr;
12806 const char *valid_chars = "a-zA-Z0-9_";
12809 start_addr.as_u32 = 0;
12810 end_addr.as_u32 = (u32) ~ 0;
12812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12814 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12815 vec_add1 (name, 0);
12816 else if (unformat (i, "protocol %d", &proto))
12818 else if (unformat (i, "start_port %d", &start_port))
12820 else if (unformat (i, "end_port %d", &end_port))
12823 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12825 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12827 else if (unformat (i, "local"))
12829 else if (unformat (i, "remote"))
12833 errmsg ("parse error '%U'", format_unformat_error, i);
12838 if (!vec_len (name))
12840 errmsg ("profile name must be specified");
12844 if (vec_len (name) > 64)
12846 errmsg ("profile name too long");
12850 M (IKEV2_PROFILE_SET_TS, mp);
12852 mp->is_local = is_local;
12853 mp->proto = (u8) proto;
12854 mp->start_port = (u16) start_port;
12855 mp->end_port = (u16) end_port;
12856 mp->start_addr = start_addr.as_u32;
12857 mp->end_addr = end_addr.as_u32;
12858 clib_memcpy (mp->name, name, vec_len (name));
12867 api_ikev2_set_local_key (vat_main_t * vam)
12869 unformat_input_t *i = vam->input;
12870 vl_api_ikev2_set_local_key_t *mp;
12874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12876 if (unformat (i, "file %v", &file))
12877 vec_add1 (file, 0);
12880 errmsg ("parse error '%U'", format_unformat_error, i);
12885 if (!vec_len (file))
12887 errmsg ("RSA key file must be specified");
12891 if (vec_len (file) > 256)
12893 errmsg ("file name too long");
12897 M (IKEV2_SET_LOCAL_KEY, mp);
12899 clib_memcpy (mp->key_file, file, vec_len (file));
12908 api_ikev2_set_responder (vat_main_t * vam)
12910 unformat_input_t *i = vam->input;
12911 vl_api_ikev2_set_responder_t *mp;
12914 u32 sw_if_index = ~0;
12915 ip4_address_t address;
12917 const char *valid_chars = "a-zA-Z0-9_";
12919 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12922 (i, "%U interface %d address %U", unformat_token, valid_chars,
12923 &name, &sw_if_index, unformat_ip4_address, &address))
12924 vec_add1 (name, 0);
12927 errmsg ("parse error '%U'", format_unformat_error, i);
12932 if (!vec_len (name))
12934 errmsg ("profile name must be specified");
12938 if (vec_len (name) > 64)
12940 errmsg ("profile name too long");
12944 M (IKEV2_SET_RESPONDER, mp);
12946 clib_memcpy (mp->name, name, vec_len (name));
12949 mp->sw_if_index = sw_if_index;
12950 clib_memcpy (mp->address, &address, sizeof (address));
12958 api_ikev2_set_ike_transforms (vat_main_t * vam)
12960 unformat_input_t *i = vam->input;
12961 vl_api_ikev2_set_ike_transforms_t *mp;
12964 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12966 const char *valid_chars = "a-zA-Z0-9_";
12968 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12970 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12971 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12972 vec_add1 (name, 0);
12975 errmsg ("parse error '%U'", format_unformat_error, i);
12980 if (!vec_len (name))
12982 errmsg ("profile name must be specified");
12986 if (vec_len (name) > 64)
12988 errmsg ("profile name too long");
12992 M (IKEV2_SET_IKE_TRANSFORMS, mp);
12994 clib_memcpy (mp->name, name, vec_len (name));
12996 mp->crypto_alg = crypto_alg;
12997 mp->crypto_key_size = crypto_key_size;
12998 mp->integ_alg = integ_alg;
12999 mp->dh_group = dh_group;
13008 api_ikev2_set_esp_transforms (vat_main_t * vam)
13010 unformat_input_t *i = vam->input;
13011 vl_api_ikev2_set_esp_transforms_t *mp;
13014 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13016 const char *valid_chars = "a-zA-Z0-9_";
13018 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13020 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13021 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13022 vec_add1 (name, 0);
13025 errmsg ("parse error '%U'", format_unformat_error, i);
13030 if (!vec_len (name))
13032 errmsg ("profile name must be specified");
13036 if (vec_len (name) > 64)
13038 errmsg ("profile name too long");
13042 M (IKEV2_SET_ESP_TRANSFORMS, mp);
13044 clib_memcpy (mp->name, name, vec_len (name));
13046 mp->crypto_alg = crypto_alg;
13047 mp->crypto_key_size = crypto_key_size;
13048 mp->integ_alg = integ_alg;
13049 mp->dh_group = dh_group;
13057 api_ikev2_set_sa_lifetime (vat_main_t * vam)
13059 unformat_input_t *i = vam->input;
13060 vl_api_ikev2_set_sa_lifetime_t *mp;
13063 u64 lifetime, lifetime_maxdata;
13064 u32 lifetime_jitter, handover;
13066 const char *valid_chars = "a-zA-Z0-9_";
13068 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13070 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
13071 &lifetime, &lifetime_jitter, &handover,
13072 &lifetime_maxdata))
13073 vec_add1 (name, 0);
13076 errmsg ("parse error '%U'", format_unformat_error, i);
13081 if (!vec_len (name))
13083 errmsg ("profile name must be specified");
13087 if (vec_len (name) > 64)
13089 errmsg ("profile name too long");
13093 M (IKEV2_SET_SA_LIFETIME, mp);
13095 clib_memcpy (mp->name, name, vec_len (name));
13097 mp->lifetime = lifetime;
13098 mp->lifetime_jitter = lifetime_jitter;
13099 mp->handover = handover;
13100 mp->lifetime_maxdata = lifetime_maxdata;
13108 api_ikev2_initiate_sa_init (vat_main_t * vam)
13110 unformat_input_t *i = vam->input;
13111 vl_api_ikev2_initiate_sa_init_t *mp;
13115 const char *valid_chars = "a-zA-Z0-9_";
13117 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13119 if (unformat (i, "%U", unformat_token, valid_chars, &name))
13120 vec_add1 (name, 0);
13123 errmsg ("parse error '%U'", format_unformat_error, i);
13128 if (!vec_len (name))
13130 errmsg ("profile name must be specified");
13134 if (vec_len (name) > 64)
13136 errmsg ("profile name too long");
13140 M (IKEV2_INITIATE_SA_INIT, mp);
13142 clib_memcpy (mp->name, name, vec_len (name));
13151 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
13153 unformat_input_t *i = vam->input;
13154 vl_api_ikev2_initiate_del_ike_sa_t *mp;
13159 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13161 if (unformat (i, "%lx", &ispi))
13165 errmsg ("parse error '%U'", format_unformat_error, i);
13170 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
13180 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13182 unformat_input_t *i = vam->input;
13183 vl_api_ikev2_initiate_del_child_sa_t *mp;
13188 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13190 if (unformat (i, "%x", &ispi))
13194 errmsg ("parse error '%U'", format_unformat_error, i);
13199 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13209 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13211 unformat_input_t *i = vam->input;
13212 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13217 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13219 if (unformat (i, "%x", &ispi))
13223 errmsg ("parse error '%U'", format_unformat_error, i);
13228 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
13241 api_map_add_domain (vat_main_t * vam)
13243 unformat_input_t *i = vam->input;
13244 vl_api_map_add_domain_t *mp;
13246 ip4_address_t ip4_prefix;
13247 ip6_address_t ip6_prefix;
13248 ip6_address_t ip6_src;
13249 u32 num_m_args = 0;
13250 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
13251 0, psid_length = 0;
13252 u8 is_translation = 0;
13254 u32 ip6_src_len = 128;
13257 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13259 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
13260 &ip4_prefix, &ip4_prefix_len))
13262 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
13263 &ip6_prefix, &ip6_prefix_len))
13267 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
13270 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
13272 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
13274 else if (unformat (i, "psid-offset %d", &psid_offset))
13276 else if (unformat (i, "psid-len %d", &psid_length))
13278 else if (unformat (i, "mtu %d", &mtu))
13280 else if (unformat (i, "map-t"))
13281 is_translation = 1;
13284 clib_warning ("parse error '%U'", format_unformat_error, i);
13289 if (num_m_args < 3)
13291 errmsg ("mandatory argument(s) missing");
13295 /* Construct the API message */
13296 M (MAP_ADD_DOMAIN, mp);
13298 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
13299 mp->ip4_prefix_len = ip4_prefix_len;
13301 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
13302 mp->ip6_prefix_len = ip6_prefix_len;
13304 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
13305 mp->ip6_src_prefix_len = ip6_src_len;
13307 mp->ea_bits_len = ea_bits_len;
13308 mp->psid_offset = psid_offset;
13309 mp->psid_length = psid_length;
13310 mp->is_translation = is_translation;
13311 mp->mtu = htons (mtu);
13316 /* Wait for a reply, return good/bad news */
13322 api_map_del_domain (vat_main_t * vam)
13324 unformat_input_t *i = vam->input;
13325 vl_api_map_del_domain_t *mp;
13327 u32 num_m_args = 0;
13331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13333 if (unformat (i, "index %d", &index))
13337 clib_warning ("parse error '%U'", format_unformat_error, i);
13342 if (num_m_args != 1)
13344 errmsg ("mandatory argument(s) missing");
13348 /* Construct the API message */
13349 M (MAP_DEL_DOMAIN, mp);
13351 mp->index = ntohl (index);
13356 /* Wait for a reply, return good/bad news */
13362 api_map_add_del_rule (vat_main_t * vam)
13364 unformat_input_t *i = vam->input;
13365 vl_api_map_add_del_rule_t *mp;
13367 ip6_address_t ip6_dst;
13368 u32 num_m_args = 0, index, psid = 0;
13371 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13373 if (unformat (i, "index %d", &index))
13375 else if (unformat (i, "psid %d", &psid))
13377 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13379 else if (unformat (i, "del"))
13385 clib_warning ("parse error '%U'", format_unformat_error, i);
13390 /* Construct the API message */
13391 M (MAP_ADD_DEL_RULE, mp);
13393 mp->index = ntohl (index);
13394 mp->is_add = is_add;
13395 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13396 mp->psid = ntohs (psid);
13401 /* Wait for a reply, return good/bad news */
13407 api_map_domain_dump (vat_main_t * vam)
13409 vl_api_map_domain_dump_t *mp;
13410 vl_api_control_ping_t *mp_ping;
13413 /* Construct the API message */
13414 M (MAP_DOMAIN_DUMP, mp);
13419 /* Use a control ping for synchronization */
13420 M (CONTROL_PING, mp_ping);
13428 api_map_rule_dump (vat_main_t * vam)
13430 unformat_input_t *i = vam->input;
13431 vl_api_map_rule_dump_t *mp;
13432 vl_api_control_ping_t *mp_ping;
13433 u32 domain_index = ~0;
13436 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13438 if (unformat (i, "index %u", &domain_index))
13444 if (domain_index == ~0)
13446 clib_warning ("parse error: domain index expected");
13450 /* Construct the API message */
13451 M (MAP_RULE_DUMP, mp);
13453 mp->domain_index = htonl (domain_index);
13458 /* Use a control ping for synchronization */
13459 M (CONTROL_PING, mp_ping);
13466 static void vl_api_map_add_domain_reply_t_handler
13467 (vl_api_map_add_domain_reply_t * mp)
13469 vat_main_t *vam = &vat_main;
13470 i32 retval = ntohl (mp->retval);
13472 if (vam->async_mode)
13474 vam->async_errors += (retval < 0);
13478 vam->retval = retval;
13479 vam->result_ready = 1;
13483 static void vl_api_map_add_domain_reply_t_handler_json
13484 (vl_api_map_add_domain_reply_t * mp)
13486 vat_main_t *vam = &vat_main;
13487 vat_json_node_t node;
13489 vat_json_init_object (&node);
13490 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13491 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13493 vat_json_print (vam->ofp, &node);
13494 vat_json_free (&node);
13496 vam->retval = ntohl (mp->retval);
13497 vam->result_ready = 1;
13501 api_get_first_msg_id (vat_main_t * vam)
13503 vl_api_get_first_msg_id_t *mp;
13504 unformat_input_t *i = vam->input;
13509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13511 if (unformat (i, "client %s", &name))
13519 errmsg ("missing client name");
13522 vec_add1 (name, 0);
13524 if (vec_len (name) > 63)
13526 errmsg ("client name too long");
13530 M (GET_FIRST_MSG_ID, mp);
13531 clib_memcpy (mp->name, name, vec_len (name));
13538 api_cop_interface_enable_disable (vat_main_t * vam)
13540 unformat_input_t *line_input = vam->input;
13541 vl_api_cop_interface_enable_disable_t *mp;
13542 u32 sw_if_index = ~0;
13543 u8 enable_disable = 1;
13546 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13548 if (unformat (line_input, "disable"))
13549 enable_disable = 0;
13550 if (unformat (line_input, "enable"))
13551 enable_disable = 1;
13552 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13553 vam, &sw_if_index))
13555 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13561 if (sw_if_index == ~0)
13563 errmsg ("missing interface name or sw_if_index");
13567 /* Construct the API message */
13568 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13569 mp->sw_if_index = ntohl (sw_if_index);
13570 mp->enable_disable = enable_disable;
13574 /* Wait for the reply */
13580 api_cop_whitelist_enable_disable (vat_main_t * vam)
13582 unformat_input_t *line_input = vam->input;
13583 vl_api_cop_whitelist_enable_disable_t *mp;
13584 u32 sw_if_index = ~0;
13585 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13589 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13591 if (unformat (line_input, "ip4"))
13593 else if (unformat (line_input, "ip6"))
13595 else if (unformat (line_input, "default"))
13597 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13598 vam, &sw_if_index))
13600 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13602 else if (unformat (line_input, "fib-id %d", &fib_id))
13608 if (sw_if_index == ~0)
13610 errmsg ("missing interface name or sw_if_index");
13614 /* Construct the API message */
13615 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13616 mp->sw_if_index = ntohl (sw_if_index);
13617 mp->fib_id = ntohl (fib_id);
13620 mp->default_cop = default_cop;
13624 /* Wait for the reply */
13630 api_get_node_graph (vat_main_t * vam)
13632 vl_api_get_node_graph_t *mp;
13635 M (GET_NODE_GRAPH, mp);
13639 /* Wait for the reply */
13645 /** Used for parsing LISP eids */
13646 typedef CLIB_PACKED(struct{
13647 u8 addr[16]; /**< eid address */
13648 u32 len; /**< prefix length if IP */
13649 u8 type; /**< type of eid */
13654 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13656 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13658 memset (a, 0, sizeof (a[0]));
13660 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13662 a->type = 0; /* ipv4 type */
13664 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13666 a->type = 1; /* ipv6 type */
13668 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13670 a->type = 2; /* mac type */
13677 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13686 lisp_eid_size_vat (u8 type)
13701 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13703 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13707 api_one_add_del_locator_set (vat_main_t * vam)
13709 unformat_input_t *input = vam->input;
13710 vl_api_one_add_del_locator_set_t *mp;
13712 u8 *locator_set_name = NULL;
13713 u8 locator_set_name_set = 0;
13714 vl_api_local_locator_t locator, *locators = 0;
13715 u32 sw_if_index, priority, weight;
13719 /* Parse args required to build the message */
13720 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13722 if (unformat (input, "del"))
13726 else if (unformat (input, "locator-set %s", &locator_set_name))
13728 locator_set_name_set = 1;
13730 else if (unformat (input, "sw_if_index %u p %u w %u",
13731 &sw_if_index, &priority, &weight))
13733 locator.sw_if_index = htonl (sw_if_index);
13734 locator.priority = priority;
13735 locator.weight = weight;
13736 vec_add1 (locators, locator);
13740 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13741 &sw_if_index, &priority, &weight))
13743 locator.sw_if_index = htonl (sw_if_index);
13744 locator.priority = priority;
13745 locator.weight = weight;
13746 vec_add1 (locators, locator);
13752 if (locator_set_name_set == 0)
13754 errmsg ("missing locator-set name");
13755 vec_free (locators);
13759 if (vec_len (locator_set_name) > 64)
13761 errmsg ("locator-set name too long");
13762 vec_free (locator_set_name);
13763 vec_free (locators);
13766 vec_add1 (locator_set_name, 0);
13768 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13770 /* Construct the API message */
13771 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
13773 mp->is_add = is_add;
13774 clib_memcpy (mp->locator_set_name, locator_set_name,
13775 vec_len (locator_set_name));
13776 vec_free (locator_set_name);
13778 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13780 clib_memcpy (mp->locators, locators, data_len);
13781 vec_free (locators);
13786 /* Wait for a reply... */
13791 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
13794 api_one_add_del_locator (vat_main_t * vam)
13796 unformat_input_t *input = vam->input;
13797 vl_api_one_add_del_locator_t *mp;
13798 u32 tmp_if_index = ~0;
13799 u32 sw_if_index = ~0;
13800 u8 sw_if_index_set = 0;
13801 u8 sw_if_index_if_name_set = 0;
13803 u8 priority_set = 0;
13807 u8 *locator_set_name = NULL;
13808 u8 locator_set_name_set = 0;
13811 /* Parse args required to build the message */
13812 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13814 if (unformat (input, "del"))
13818 else if (unformat (input, "locator-set %s", &locator_set_name))
13820 locator_set_name_set = 1;
13822 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13825 sw_if_index_if_name_set = 1;
13826 sw_if_index = tmp_if_index;
13828 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13830 sw_if_index_set = 1;
13831 sw_if_index = tmp_if_index;
13833 else if (unformat (input, "p %d", &priority))
13837 else if (unformat (input, "w %d", &weight))
13845 if (locator_set_name_set == 0)
13847 errmsg ("missing locator-set name");
13851 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13853 errmsg ("missing sw_if_index");
13854 vec_free (locator_set_name);
13858 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13860 errmsg ("cannot use both params interface name and sw_if_index");
13861 vec_free (locator_set_name);
13865 if (priority_set == 0)
13867 errmsg ("missing locator-set priority");
13868 vec_free (locator_set_name);
13872 if (weight_set == 0)
13874 errmsg ("missing locator-set weight");
13875 vec_free (locator_set_name);
13879 if (vec_len (locator_set_name) > 64)
13881 errmsg ("locator-set name too long");
13882 vec_free (locator_set_name);
13885 vec_add1 (locator_set_name, 0);
13887 /* Construct the API message */
13888 M (ONE_ADD_DEL_LOCATOR, mp);
13890 mp->is_add = is_add;
13891 mp->sw_if_index = ntohl (sw_if_index);
13892 mp->priority = priority;
13893 mp->weight = weight;
13894 clib_memcpy (mp->locator_set_name, locator_set_name,
13895 vec_len (locator_set_name));
13896 vec_free (locator_set_name);
13901 /* Wait for a reply... */
13906 #define api_lisp_add_del_locator api_one_add_del_locator
13909 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13911 u32 *key_id = va_arg (*args, u32 *);
13914 if (unformat (input, "%s", &s))
13916 if (!strcmp ((char *) s, "sha1"))
13917 key_id[0] = HMAC_SHA_1_96;
13918 else if (!strcmp ((char *) s, "sha256"))
13919 key_id[0] = HMAC_SHA_256_128;
13922 clib_warning ("invalid key_id: '%s'", s);
13923 key_id[0] = HMAC_NO_KEY;
13934 api_one_add_del_local_eid (vat_main_t * vam)
13936 unformat_input_t *input = vam->input;
13937 vl_api_one_add_del_local_eid_t *mp;
13940 lisp_eid_vat_t _eid, *eid = &_eid;
13941 u8 *locator_set_name = 0;
13942 u8 locator_set_name_set = 0;
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, "vni %d", &vni))
13959 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13963 else if (unformat (input, "locator-set %s", &locator_set_name))
13965 locator_set_name_set = 1;
13967 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13969 else if (unformat (input, "secret-key %_%v%_", &key))
13975 if (locator_set_name_set == 0)
13977 errmsg ("missing locator-set name");
13983 errmsg ("EID address not set!");
13984 vec_free (locator_set_name);
13988 if (key && (0 == key_id))
13990 errmsg ("invalid key_id!");
13994 if (vec_len (key) > 64)
13996 errmsg ("key too long");
14001 if (vec_len (locator_set_name) > 64)
14003 errmsg ("locator-set name too long");
14004 vec_free (locator_set_name);
14007 vec_add1 (locator_set_name, 0);
14009 /* Construct the API message */
14010 M (ONE_ADD_DEL_LOCAL_EID, mp);
14012 mp->is_add = is_add;
14013 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14014 mp->eid_type = eid->type;
14015 mp->prefix_len = eid->len;
14016 mp->vni = clib_host_to_net_u32 (vni);
14017 mp->key_id = clib_host_to_net_u16 (key_id);
14018 clib_memcpy (mp->locator_set_name, locator_set_name,
14019 vec_len (locator_set_name));
14020 clib_memcpy (mp->key, key, vec_len (key));
14022 vec_free (locator_set_name);
14028 /* Wait for a reply... */
14033 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14036 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14038 u32 dp_table = 0, vni = 0;;
14039 unformat_input_t *input = vam->input;
14040 vl_api_gpe_add_del_fwd_entry_t *mp;
14042 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14043 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14044 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14045 u32 action = ~0, w;
14046 ip4_address_t rmt_rloc4, lcl_rloc4;
14047 ip6_address_t rmt_rloc6, lcl_rloc6;
14048 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14051 memset (&rloc, 0, sizeof (rloc));
14053 /* Parse args required to build the message */
14054 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14056 if (unformat (input, "del"))
14058 else if (unformat (input, "add"))
14060 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14064 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14068 else if (unformat (input, "vrf %d", &dp_table))
14070 else if (unformat (input, "bd %d", &dp_table))
14072 else if (unformat (input, "vni %d", &vni))
14074 else if (unformat (input, "w %d", &w))
14078 errmsg ("No RLOC configured for setting priority/weight!");
14081 curr_rloc->weight = w;
14083 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14084 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14088 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
14090 vec_add1 (lcl_locs, rloc);
14092 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
14093 vec_add1 (rmt_locs, rloc);
14094 /* weight saved in rmt loc */
14095 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14097 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14098 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14101 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
14103 vec_add1 (lcl_locs, rloc);
14105 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
14106 vec_add1 (rmt_locs, rloc);
14107 /* weight saved in rmt loc */
14108 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14110 else if (unformat (input, "action %d", &action))
14116 clib_warning ("parse error '%U'", format_unformat_error, input);
14123 errmsg ("remote eid addresses not set");
14127 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14129 errmsg ("eid types don't match");
14133 if (0 == rmt_locs && (u32) ~ 0 == action)
14135 errmsg ("action not set for negative mapping");
14139 /* Construct the API message */
14140 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14141 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14143 mp->is_add = is_add;
14144 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14145 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14146 mp->eid_type = rmt_eid->type;
14147 mp->dp_table = clib_host_to_net_u32 (dp_table);
14148 mp->vni = clib_host_to_net_u32 (vni);
14149 mp->rmt_len = rmt_eid->len;
14150 mp->lcl_len = lcl_eid->len;
14151 mp->action = action;
14153 if (0 != rmt_locs && 0 != lcl_locs)
14155 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14156 clib_memcpy (mp->locs, lcl_locs,
14157 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14159 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14160 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14161 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14163 vec_free (lcl_locs);
14164 vec_free (rmt_locs);
14169 /* Wait for a reply... */
14175 api_one_add_del_map_server (vat_main_t * vam)
14177 unformat_input_t *input = vam->input;
14178 vl_api_one_add_del_map_server_t *mp;
14182 ip4_address_t ipv4;
14183 ip6_address_t ipv6;
14186 /* Parse args required to build the message */
14187 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14189 if (unformat (input, "del"))
14193 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14197 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14205 if (ipv4_set && ipv6_set)
14207 errmsg ("both eid v4 and v6 addresses set");
14211 if (!ipv4_set && !ipv6_set)
14213 errmsg ("eid addresses not set");
14217 /* Construct the API message */
14218 M (ONE_ADD_DEL_MAP_SERVER, mp);
14220 mp->is_add = is_add;
14224 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14229 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14235 /* Wait for a reply... */
14240 #define api_lisp_add_del_map_server api_one_add_del_map_server
14243 api_one_add_del_map_resolver (vat_main_t * vam)
14245 unformat_input_t *input = vam->input;
14246 vl_api_one_add_del_map_resolver_t *mp;
14250 ip4_address_t ipv4;
14251 ip6_address_t ipv6;
14254 /* Parse args required to build the message */
14255 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14257 if (unformat (input, "del"))
14261 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14265 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14273 if (ipv4_set && ipv6_set)
14275 errmsg ("both eid v4 and v6 addresses set");
14279 if (!ipv4_set && !ipv6_set)
14281 errmsg ("eid addresses not set");
14285 /* Construct the API message */
14286 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14288 mp->is_add = is_add;
14292 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14297 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14303 /* Wait for a reply... */
14308 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14311 api_lisp_gpe_enable_disable (vat_main_t * vam)
14313 unformat_input_t *input = vam->input;
14314 vl_api_gpe_enable_disable_t *mp;
14319 /* Parse args required to build the message */
14320 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14322 if (unformat (input, "enable"))
14327 else if (unformat (input, "disable"))
14338 errmsg ("Value not set");
14342 /* Construct the API message */
14343 M (GPE_ENABLE_DISABLE, mp);
14350 /* Wait for a reply... */
14356 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14358 unformat_input_t *input = vam->input;
14359 vl_api_one_rloc_probe_enable_disable_t *mp;
14364 /* Parse args required to build the message */
14365 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14367 if (unformat (input, "enable"))
14372 else if (unformat (input, "disable"))
14380 errmsg ("Value not set");
14384 /* Construct the API message */
14385 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14387 mp->is_enabled = is_en;
14392 /* Wait for a reply... */
14397 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14400 api_one_map_register_enable_disable (vat_main_t * vam)
14402 unformat_input_t *input = vam->input;
14403 vl_api_one_map_register_enable_disable_t *mp;
14408 /* Parse args required to build the message */
14409 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14411 if (unformat (input, "enable"))
14416 else if (unformat (input, "disable"))
14424 errmsg ("Value not set");
14428 /* Construct the API message */
14429 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14431 mp->is_enabled = is_en;
14436 /* Wait for a reply... */
14441 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14444 api_one_enable_disable (vat_main_t * vam)
14446 unformat_input_t *input = vam->input;
14447 vl_api_one_enable_disable_t *mp;
14452 /* Parse args required to build the message */
14453 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14455 if (unformat (input, "enable"))
14460 else if (unformat (input, "disable"))
14470 errmsg ("Value not set");
14474 /* Construct the API message */
14475 M (ONE_ENABLE_DISABLE, mp);
14482 /* Wait for a reply... */
14487 #define api_lisp_enable_disable api_one_enable_disable
14490 api_show_one_map_register_state (vat_main_t * vam)
14492 vl_api_show_one_map_register_state_t *mp;
14495 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14500 /* wait for reply */
14505 #define api_show_lisp_map_register_state api_show_one_map_register_state
14508 api_show_one_rloc_probe_state (vat_main_t * vam)
14510 vl_api_show_one_rloc_probe_state_t *mp;
14513 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14518 /* wait for reply */
14523 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14526 api_one_stats_enable_disable (vat_main_t * vam)
14528 vl_api_one_stats_enable_disable_t *mp;
14529 unformat_input_t *input = vam->input;
14534 /* Parse args required to build the message */
14535 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14537 if (unformat (input, "enable"))
14542 else if (unformat (input, "disable"))
14552 errmsg ("Value not set");
14556 M (ONE_STATS_ENABLE_DISABLE, mp);
14562 /* wait for reply */
14568 api_show_one_stats_enable_disable (vat_main_t * vam)
14570 vl_api_show_one_stats_enable_disable_t *mp;
14573 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
14578 /* wait for reply */
14584 api_show_one_map_request_mode (vat_main_t * vam)
14586 vl_api_show_one_map_request_mode_t *mp;
14589 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
14594 /* wait for reply */
14599 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
14602 api_one_map_request_mode (vat_main_t * vam)
14604 unformat_input_t *input = vam->input;
14605 vl_api_one_map_request_mode_t *mp;
14609 /* Parse args required to build the message */
14610 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14612 if (unformat (input, "dst-only"))
14614 else if (unformat (input, "src-dst"))
14618 errmsg ("parse error '%U'", format_unformat_error, input);
14623 M (ONE_MAP_REQUEST_MODE, mp);
14630 /* wait for reply */
14635 #define api_lisp_map_request_mode api_one_map_request_mode
14638 * Enable/disable ONE proxy ITR.
14640 * @param vam vpp API test context
14641 * @return return code
14644 api_one_pitr_set_locator_set (vat_main_t * vam)
14646 u8 ls_name_set = 0;
14647 unformat_input_t *input = vam->input;
14648 vl_api_one_pitr_set_locator_set_t *mp;
14653 /* Parse args required to build the message */
14654 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14656 if (unformat (input, "del"))
14658 else if (unformat (input, "locator-set %s", &ls_name))
14662 errmsg ("parse error '%U'", format_unformat_error, input);
14669 errmsg ("locator-set name not set!");
14673 M (ONE_PITR_SET_LOCATOR_SET, mp);
14675 mp->is_add = is_add;
14676 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14677 vec_free (ls_name);
14682 /* wait for reply */
14687 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
14690 api_show_one_pitr (vat_main_t * vam)
14692 vl_api_show_one_pitr_t *mp;
14695 if (!vam->json_output)
14697 print (vam->ofp, "%=20s", "lisp status:");
14700 M (SHOW_ONE_PITR, mp);
14704 /* Wait for a reply... */
14709 #define api_show_lisp_pitr api_show_one_pitr
14712 api_one_use_petr (vat_main_t * vam)
14714 unformat_input_t *input = vam->input;
14715 vl_api_one_use_petr_t *mp;
14720 memset (&ip, 0, sizeof (ip));
14722 /* Parse args required to build the message */
14723 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14725 if (unformat (input, "disable"))
14728 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
14731 ip_addr_version (&ip) = IP4;
14734 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
14737 ip_addr_version (&ip) = IP6;
14741 errmsg ("parse error '%U'", format_unformat_error, input);
14746 M (ONE_USE_PETR, mp);
14748 mp->is_add = is_add;
14751 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
14753 clib_memcpy (mp->address, &ip, 4);
14755 clib_memcpy (mp->address, &ip, 16);
14761 /* wait for reply */
14766 #define api_lisp_use_petr api_one_use_petr
14769 api_show_one_use_petr (vat_main_t * vam)
14771 vl_api_show_one_use_petr_t *mp;
14774 if (!vam->json_output)
14776 print (vam->ofp, "%=20s", "Proxy-ETR status:");
14779 M (SHOW_ONE_USE_PETR, mp);
14783 /* Wait for a reply... */
14788 #define api_show_lisp_use_petr api_show_one_use_petr
14791 * Add/delete mapping between vni and vrf
14794 api_one_eid_table_add_del_map (vat_main_t * vam)
14796 unformat_input_t *input = vam->input;
14797 vl_api_one_eid_table_add_del_map_t *mp;
14798 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
14799 u32 vni, vrf, bd_index;
14802 /* Parse args required to build the message */
14803 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14805 if (unformat (input, "del"))
14807 else if (unformat (input, "vrf %d", &vrf))
14809 else if (unformat (input, "bd_index %d", &bd_index))
14811 else if (unformat (input, "vni %d", &vni))
14817 if (!vni_set || (!vrf_set && !bd_index_set))
14819 errmsg ("missing arguments!");
14823 if (vrf_set && bd_index_set)
14825 errmsg ("error: both vrf and bd entered!");
14829 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
14831 mp->is_add = is_add;
14832 mp->vni = htonl (vni);
14833 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
14834 mp->is_l2 = bd_index_set;
14839 /* wait for reply */
14844 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
14847 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
14849 u32 *action = va_arg (*args, u32 *);
14852 if (unformat (input, "%s", &s))
14854 if (!strcmp ((char *) s, "no-action"))
14856 else if (!strcmp ((char *) s, "natively-forward"))
14858 else if (!strcmp ((char *) s, "send-map-request"))
14860 else if (!strcmp ((char *) s, "drop"))
14864 clib_warning ("invalid action: '%s'", s);
14876 * Add/del remote mapping to/from ONE control plane
14878 * @param vam vpp API test context
14879 * @return return code
14882 api_one_add_del_remote_mapping (vat_main_t * vam)
14884 unformat_input_t *input = vam->input;
14885 vl_api_one_add_del_remote_mapping_t *mp;
14887 lisp_eid_vat_t _eid, *eid = &_eid;
14888 lisp_eid_vat_t _seid, *seid = &_seid;
14889 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
14890 u32 action = ~0, p, w, data_len;
14891 ip4_address_t rloc4;
14892 ip6_address_t rloc6;
14893 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
14896 memset (&rloc, 0, sizeof (rloc));
14898 /* Parse args required to build the message */
14899 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14901 if (unformat (input, "del-all"))
14905 else if (unformat (input, "del"))
14909 else if (unformat (input, "add"))
14913 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14917 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14921 else if (unformat (input, "vni %d", &vni))
14925 else if (unformat (input, "p %d w %d", &p, &w))
14929 errmsg ("No RLOC configured for setting priority/weight!");
14932 curr_rloc->priority = p;
14933 curr_rloc->weight = w;
14935 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14938 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14939 vec_add1 (rlocs, rloc);
14940 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14942 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14945 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14946 vec_add1 (rlocs, rloc);
14947 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14949 else if (unformat (input, "action %U",
14950 unformat_negative_mapping_action, &action))
14956 clib_warning ("parse error '%U'", format_unformat_error, input);
14963 errmsg ("missing params!");
14967 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14969 errmsg ("no action set for negative map-reply!");
14973 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
14975 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
14976 mp->is_add = is_add;
14977 mp->vni = htonl (vni);
14978 mp->action = (u8) action;
14979 mp->is_src_dst = seid_set;
14980 mp->eid_len = eid->len;
14981 mp->seid_len = seid->len;
14982 mp->del_all = del_all;
14983 mp->eid_type = eid->type;
14984 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14985 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14987 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14988 clib_memcpy (mp->rlocs, rlocs, data_len);
14994 /* Wait for a reply... */
14999 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15002 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15003 * forwarding entries in data-plane accordingly.
15005 * @param vam vpp API test context
15006 * @return return code
15009 api_one_add_del_adjacency (vat_main_t * vam)
15011 unformat_input_t *input = vam->input;
15012 vl_api_one_add_del_adjacency_t *mp;
15014 ip4_address_t leid4, reid4;
15015 ip6_address_t leid6, reid6;
15016 u8 reid_mac[6] = { 0 };
15017 u8 leid_mac[6] = { 0 };
15018 u8 reid_type, leid_type;
15019 u32 leid_len = 0, reid_len = 0, len;
15023 leid_type = reid_type = (u8) ~ 0;
15025 /* Parse args required to build the message */
15026 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15028 if (unformat (input, "del"))
15032 else if (unformat (input, "add"))
15036 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
15039 reid_type = 0; /* ipv4 */
15042 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
15045 reid_type = 1; /* ipv6 */
15048 else if (unformat (input, "reid %U", unformat_ethernet_address,
15051 reid_type = 2; /* mac */
15053 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
15056 leid_type = 0; /* ipv4 */
15059 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
15062 leid_type = 1; /* ipv6 */
15065 else if (unformat (input, "leid %U", unformat_ethernet_address,
15068 leid_type = 2; /* mac */
15070 else if (unformat (input, "vni %d", &vni))
15076 errmsg ("parse error '%U'", format_unformat_error, input);
15081 if ((u8) ~ 0 == reid_type)
15083 errmsg ("missing params!");
15087 if (leid_type != reid_type)
15089 errmsg ("remote and local EIDs are of different types!");
15093 M (ONE_ADD_DEL_ADJACENCY, mp);
15094 mp->is_add = is_add;
15095 mp->vni = htonl (vni);
15096 mp->leid_len = leid_len;
15097 mp->reid_len = reid_len;
15098 mp->eid_type = reid_type;
15100 switch (mp->eid_type)
15103 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
15104 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
15107 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
15108 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
15111 clib_memcpy (mp->leid, leid_mac, 6);
15112 clib_memcpy (mp->reid, reid_mac, 6);
15115 errmsg ("unknown EID type %d!", mp->eid_type);
15122 /* Wait for a reply... */
15127 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
15130 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
15132 u32 *mode = va_arg (*args, u32 *);
15134 if (unformat (input, "lisp"))
15136 else if (unformat (input, "vxlan"))
15145 api_gpe_get_encap_mode (vat_main_t * vam)
15147 vl_api_gpe_get_encap_mode_t *mp;
15150 /* Construct the API message */
15151 M (GPE_GET_ENCAP_MODE, mp);
15156 /* Wait for a reply... */
15162 api_gpe_set_encap_mode (vat_main_t * vam)
15164 unformat_input_t *input = vam->input;
15165 vl_api_gpe_set_encap_mode_t *mp;
15169 /* Parse args required to build the message */
15170 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15172 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
15178 /* Construct the API message */
15179 M (GPE_SET_ENCAP_MODE, mp);
15186 /* Wait for a reply... */
15192 api_lisp_gpe_add_del_iface (vat_main_t * vam)
15194 unformat_input_t *input = vam->input;
15195 vl_api_gpe_add_del_iface_t *mp;
15196 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
15197 u32 dp_table = 0, vni = 0;
15200 /* Parse args required to build the message */
15201 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15203 if (unformat (input, "up"))
15208 else if (unformat (input, "down"))
15213 else if (unformat (input, "table_id %d", &dp_table))
15217 else if (unformat (input, "bd_id %d", &dp_table))
15222 else if (unformat (input, "vni %d", &vni))
15230 if (action_set == 0)
15232 errmsg ("Action not set");
15235 if (dp_table_set == 0 || vni_set == 0)
15237 errmsg ("vni and dp_table must be set");
15241 /* Construct the API message */
15242 M (GPE_ADD_DEL_IFACE, mp);
15244 mp->is_add = is_add;
15245 mp->dp_table = dp_table;
15252 /* Wait for a reply... */
15258 * Add/del map request itr rlocs from ONE control plane and updates
15260 * @param vam vpp API test context
15261 * @return return code
15264 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
15266 unformat_input_t *input = vam->input;
15267 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
15268 u8 *locator_set_name = 0;
15269 u8 locator_set_name_set = 0;
15273 /* Parse args required to build the message */
15274 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15276 if (unformat (input, "del"))
15280 else if (unformat (input, "%_%v%_", &locator_set_name))
15282 locator_set_name_set = 1;
15286 clib_warning ("parse error '%U'", format_unformat_error, input);
15291 if (is_add && !locator_set_name_set)
15293 errmsg ("itr-rloc is not set!");
15297 if (is_add && vec_len (locator_set_name) > 64)
15299 errmsg ("itr-rloc locator-set name too long");
15300 vec_free (locator_set_name);
15304 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
15305 mp->is_add = is_add;
15308 clib_memcpy (mp->locator_set_name, locator_set_name,
15309 vec_len (locator_set_name));
15313 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
15315 vec_free (locator_set_name);
15320 /* Wait for a reply... */
15325 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
15328 api_one_locator_dump (vat_main_t * vam)
15330 unformat_input_t *input = vam->input;
15331 vl_api_one_locator_dump_t *mp;
15332 vl_api_control_ping_t *mp_ping;
15333 u8 is_index_set = 0, is_name_set = 0;
15338 /* Parse args required to build the message */
15339 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15341 if (unformat (input, "ls_name %_%v%_", &ls_name))
15345 else if (unformat (input, "ls_index %d", &ls_index))
15351 errmsg ("parse error '%U'", format_unformat_error, input);
15356 if (!is_index_set && !is_name_set)
15358 errmsg ("error: expected one of index or name!");
15362 if (is_index_set && is_name_set)
15364 errmsg ("error: only one param expected!");
15368 if (vec_len (ls_name) > 62)
15370 errmsg ("error: locator set name too long!");
15374 if (!vam->json_output)
15376 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
15379 M (ONE_LOCATOR_DUMP, mp);
15380 mp->is_index_set = is_index_set;
15383 mp->ls_index = clib_host_to_net_u32 (ls_index);
15386 vec_add1 (ls_name, 0);
15387 strncpy ((char *) mp->ls_name, (char *) ls_name,
15388 sizeof (mp->ls_name) - 1);
15394 /* Use a control ping for synchronization */
15395 M (CONTROL_PING, mp_ping);
15398 /* Wait for a reply... */
15403 #define api_lisp_locator_dump api_one_locator_dump
15406 api_one_locator_set_dump (vat_main_t * vam)
15408 vl_api_one_locator_set_dump_t *mp;
15409 vl_api_control_ping_t *mp_ping;
15410 unformat_input_t *input = vam->input;
15414 /* Parse args required to build the message */
15415 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15417 if (unformat (input, "local"))
15421 else if (unformat (input, "remote"))
15427 errmsg ("parse error '%U'", format_unformat_error, input);
15432 if (!vam->json_output)
15434 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
15437 M (ONE_LOCATOR_SET_DUMP, mp);
15439 mp->filter = filter;
15444 /* Use a control ping for synchronization */
15445 M (CONTROL_PING, mp_ping);
15448 /* Wait for a reply... */
15453 #define api_lisp_locator_set_dump api_one_locator_set_dump
15456 api_one_eid_table_map_dump (vat_main_t * vam)
15460 unformat_input_t *input = vam->input;
15461 vl_api_one_eid_table_map_dump_t *mp;
15462 vl_api_control_ping_t *mp_ping;
15465 /* Parse args required to build the message */
15466 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15468 if (unformat (input, "l2"))
15473 else if (unformat (input, "l3"))
15480 errmsg ("parse error '%U'", format_unformat_error, input);
15487 errmsg ("expected one of 'l2' or 'l3' parameter!");
15491 if (!vam->json_output)
15493 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
15496 M (ONE_EID_TABLE_MAP_DUMP, mp);
15502 /* Use a control ping for synchronization */
15503 M (CONTROL_PING, mp_ping);
15506 /* Wait for a reply... */
15511 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
15514 api_one_eid_table_vni_dump (vat_main_t * vam)
15516 vl_api_one_eid_table_vni_dump_t *mp;
15517 vl_api_control_ping_t *mp_ping;
15520 if (!vam->json_output)
15522 print (vam->ofp, "VNI");
15525 M (ONE_EID_TABLE_VNI_DUMP, mp);
15530 /* Use a control ping for synchronization */
15531 M (CONTROL_PING, mp_ping);
15534 /* Wait for a reply... */
15539 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
15542 api_one_eid_table_dump (vat_main_t * vam)
15544 unformat_input_t *i = vam->input;
15545 vl_api_one_eid_table_dump_t *mp;
15546 vl_api_control_ping_t *mp_ping;
15547 struct in_addr ip4;
15548 struct in6_addr ip6;
15550 u8 eid_type = ~0, eid_set = 0;
15551 u32 prefix_length = ~0, t, vni = 0;
15555 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15557 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
15563 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
15569 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
15574 else if (unformat (i, "vni %d", &t))
15578 else if (unformat (i, "local"))
15582 else if (unformat (i, "remote"))
15588 errmsg ("parse error '%U'", format_unformat_error, i);
15593 if (!vam->json_output)
15595 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
15596 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
15599 M (ONE_EID_TABLE_DUMP, mp);
15601 mp->filter = filter;
15605 mp->vni = htonl (vni);
15606 mp->eid_type = eid_type;
15610 mp->prefix_length = prefix_length;
15611 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
15614 mp->prefix_length = prefix_length;
15615 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
15618 clib_memcpy (mp->eid, mac, sizeof (mac));
15621 errmsg ("unknown EID type %d!", eid_type);
15629 /* Use a control ping for synchronization */
15630 M (CONTROL_PING, mp_ping);
15633 /* Wait for a reply... */
15638 #define api_lisp_eid_table_dump api_one_eid_table_dump
15641 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
15643 unformat_input_t *i = vam->input;
15644 vl_api_gpe_fwd_entries_get_t *mp;
15649 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15651 if (unformat (i, "vni %d", &vni))
15657 errmsg ("parse error '%U'", format_unformat_error, i);
15664 errmsg ("vni not set!");
15668 if (!vam->json_output)
15670 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15674 M (GPE_FWD_ENTRIES_GET, mp);
15675 mp->vni = clib_host_to_net_u32 (vni);
15680 /* Wait for a reply... */
15685 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15686 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15687 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15688 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
15691 api_one_adjacencies_get (vat_main_t * vam)
15693 unformat_input_t *i = vam->input;
15694 vl_api_one_adjacencies_get_t *mp;
15699 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15701 if (unformat (i, "vni %d", &vni))
15707 errmsg ("parse error '%U'", format_unformat_error, i);
15714 errmsg ("vni not set!");
15718 if (!vam->json_output)
15720 print (vam->ofp, "%s %40s", "leid", "reid");
15723 M (ONE_ADJACENCIES_GET, mp);
15724 mp->vni = clib_host_to_net_u32 (vni);
15729 /* Wait for a reply... */
15734 #define api_lisp_adjacencies_get api_one_adjacencies_get
15737 api_one_map_server_dump (vat_main_t * vam)
15739 vl_api_one_map_server_dump_t *mp;
15740 vl_api_control_ping_t *mp_ping;
15743 if (!vam->json_output)
15745 print (vam->ofp, "%=20s", "Map server");
15748 M (ONE_MAP_SERVER_DUMP, mp);
15752 /* Use a control ping for synchronization */
15753 M (CONTROL_PING, mp_ping);
15756 /* Wait for a reply... */
15761 #define api_lisp_map_server_dump api_one_map_server_dump
15764 api_one_map_resolver_dump (vat_main_t * vam)
15766 vl_api_one_map_resolver_dump_t *mp;
15767 vl_api_control_ping_t *mp_ping;
15770 if (!vam->json_output)
15772 print (vam->ofp, "%=20s", "Map resolver");
15775 M (ONE_MAP_RESOLVER_DUMP, mp);
15779 /* Use a control ping for synchronization */
15780 M (CONTROL_PING, mp_ping);
15783 /* Wait for a reply... */
15788 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
15791 api_one_stats_dump (vat_main_t * vam)
15793 vl_api_one_stats_dump_t *mp;
15794 vl_api_control_ping_t *mp_ping;
15797 M (ONE_STATS_DUMP, mp);
15801 /* Use a control ping for synchronization */
15802 M (CONTROL_PING, mp_ping);
15805 /* Wait for a reply... */
15811 api_show_one_status (vat_main_t * vam)
15813 vl_api_show_one_status_t *mp;
15816 if (!vam->json_output)
15818 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
15821 M (SHOW_ONE_STATUS, mp);
15824 /* Wait for a reply... */
15829 #define api_show_lisp_status api_show_one_status
15832 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
15834 vl_api_gpe_fwd_entry_path_dump_t *mp;
15835 vl_api_control_ping_t *mp_ping;
15836 unformat_input_t *i = vam->input;
15837 u32 fwd_entry_index = ~0;
15840 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15842 if (unformat (i, "index %d", &fwd_entry_index))
15848 if (~0 == fwd_entry_index)
15850 errmsg ("no index specified!");
15854 if (!vam->json_output)
15856 print (vam->ofp, "first line");
15859 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
15863 /* Use a control ping for synchronization */
15864 M (CONTROL_PING, mp_ping);
15867 /* Wait for a reply... */
15873 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
15875 vl_api_one_get_map_request_itr_rlocs_t *mp;
15878 if (!vam->json_output)
15880 print (vam->ofp, "%=20s", "itr-rlocs:");
15883 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
15886 /* Wait for a reply... */
15891 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
15894 api_af_packet_create (vat_main_t * vam)
15896 unformat_input_t *i = vam->input;
15897 vl_api_af_packet_create_t *mp;
15898 u8 *host_if_name = 0;
15900 u8 random_hw_addr = 1;
15903 memset (hw_addr, 0, sizeof (hw_addr));
15905 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15907 if (unformat (i, "name %s", &host_if_name))
15908 vec_add1 (host_if_name, 0);
15909 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15910 random_hw_addr = 0;
15915 if (!vec_len (host_if_name))
15917 errmsg ("host-interface name must be specified");
15921 if (vec_len (host_if_name) > 64)
15923 errmsg ("host-interface name too long");
15927 M (AF_PACKET_CREATE, mp);
15929 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15930 clib_memcpy (mp->hw_addr, hw_addr, 6);
15931 mp->use_random_hw_addr = random_hw_addr;
15932 vec_free (host_if_name);
15940 fprintf (vam->ofp ? vam->ofp : stderr,
15941 " new sw_if_index = %d\n", vam->sw_if_index);
15948 api_af_packet_delete (vat_main_t * vam)
15950 unformat_input_t *i = vam->input;
15951 vl_api_af_packet_delete_t *mp;
15952 u8 *host_if_name = 0;
15955 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15957 if (unformat (i, "name %s", &host_if_name))
15958 vec_add1 (host_if_name, 0);
15963 if (!vec_len (host_if_name))
15965 errmsg ("host-interface name must be specified");
15969 if (vec_len (host_if_name) > 64)
15971 errmsg ("host-interface name too long");
15975 M (AF_PACKET_DELETE, mp);
15977 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15978 vec_free (host_if_name);
15986 api_policer_add_del (vat_main_t * vam)
15988 unformat_input_t *i = vam->input;
15989 vl_api_policer_add_del_t *mp;
15999 u8 color_aware = 0;
16000 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
16003 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
16004 conform_action.dscp = 0;
16005 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
16006 exceed_action.dscp = 0;
16007 violate_action.action_type = SSE2_QOS_ACTION_DROP;
16008 violate_action.dscp = 0;
16010 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16012 if (unformat (i, "del"))
16014 else if (unformat (i, "name %s", &name))
16015 vec_add1 (name, 0);
16016 else if (unformat (i, "cir %u", &cir))
16018 else if (unformat (i, "eir %u", &eir))
16020 else if (unformat (i, "cb %u", &cb))
16022 else if (unformat (i, "eb %u", &eb))
16024 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
16027 else if (unformat (i, "round_type %U", unformat_policer_round_type,
16030 else if (unformat (i, "type %U", unformat_policer_type, &type))
16032 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
16035 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
16038 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
16041 else if (unformat (i, "color-aware"))
16047 if (!vec_len (name))
16049 errmsg ("policer name must be specified");
16053 if (vec_len (name) > 64)
16055 errmsg ("policer name too long");
16059 M (POLICER_ADD_DEL, mp);
16061 clib_memcpy (mp->name, name, vec_len (name));
16063 mp->is_add = is_add;
16068 mp->rate_type = rate_type;
16069 mp->round_type = round_type;
16071 mp->conform_action_type = conform_action.action_type;
16072 mp->conform_dscp = conform_action.dscp;
16073 mp->exceed_action_type = exceed_action.action_type;
16074 mp->exceed_dscp = exceed_action.dscp;
16075 mp->violate_action_type = violate_action.action_type;
16076 mp->violate_dscp = violate_action.dscp;
16077 mp->color_aware = color_aware;
16085 api_policer_dump (vat_main_t * vam)
16087 unformat_input_t *i = vam->input;
16088 vl_api_policer_dump_t *mp;
16089 vl_api_control_ping_t *mp_ping;
16090 u8 *match_name = 0;
16091 u8 match_name_valid = 0;
16094 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16096 if (unformat (i, "name %s", &match_name))
16098 vec_add1 (match_name, 0);
16099 match_name_valid = 1;
16105 M (POLICER_DUMP, mp);
16106 mp->match_name_valid = match_name_valid;
16107 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
16108 vec_free (match_name);
16112 /* Use a control ping for synchronization */
16113 M (CONTROL_PING, mp_ping);
16116 /* Wait for a reply... */
16122 api_policer_classify_set_interface (vat_main_t * vam)
16124 unformat_input_t *i = vam->input;
16125 vl_api_policer_classify_set_interface_t *mp;
16127 int sw_if_index_set;
16128 u32 ip4_table_index = ~0;
16129 u32 ip6_table_index = ~0;
16130 u32 l2_table_index = ~0;
16134 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16136 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16137 sw_if_index_set = 1;
16138 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16139 sw_if_index_set = 1;
16140 else if (unformat (i, "del"))
16142 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16144 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16146 else if (unformat (i, "l2-table %d", &l2_table_index))
16150 clib_warning ("parse error '%U'", format_unformat_error, i);
16155 if (sw_if_index_set == 0)
16157 errmsg ("missing interface name or sw_if_index");
16161 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
16163 mp->sw_if_index = ntohl (sw_if_index);
16164 mp->ip4_table_index = ntohl (ip4_table_index);
16165 mp->ip6_table_index = ntohl (ip6_table_index);
16166 mp->l2_table_index = ntohl (l2_table_index);
16167 mp->is_add = is_add;
16175 api_policer_classify_dump (vat_main_t * vam)
16177 unformat_input_t *i = vam->input;
16178 vl_api_policer_classify_dump_t *mp;
16179 vl_api_control_ping_t *mp_ping;
16180 u8 type = POLICER_CLASSIFY_N_TABLES;
16183 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
16187 errmsg ("classify table type must be specified");
16191 if (!vam->json_output)
16193 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
16196 M (POLICER_CLASSIFY_DUMP, mp);
16201 /* Use a control ping for synchronization */
16202 M (CONTROL_PING, mp_ping);
16205 /* Wait for a reply... */
16211 api_netmap_create (vat_main_t * vam)
16213 unformat_input_t *i = vam->input;
16214 vl_api_netmap_create_t *mp;
16217 u8 random_hw_addr = 1;
16222 memset (hw_addr, 0, sizeof (hw_addr));
16224 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16226 if (unformat (i, "name %s", &if_name))
16227 vec_add1 (if_name, 0);
16228 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16229 random_hw_addr = 0;
16230 else if (unformat (i, "pipe"))
16232 else if (unformat (i, "master"))
16234 else if (unformat (i, "slave"))
16240 if (!vec_len (if_name))
16242 errmsg ("interface name must be specified");
16246 if (vec_len (if_name) > 64)
16248 errmsg ("interface name too long");
16252 M (NETMAP_CREATE, mp);
16254 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16255 clib_memcpy (mp->hw_addr, hw_addr, 6);
16256 mp->use_random_hw_addr = random_hw_addr;
16257 mp->is_pipe = is_pipe;
16258 mp->is_master = is_master;
16259 vec_free (if_name);
16267 api_netmap_delete (vat_main_t * vam)
16269 unformat_input_t *i = vam->input;
16270 vl_api_netmap_delete_t *mp;
16274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16276 if (unformat (i, "name %s", &if_name))
16277 vec_add1 (if_name, 0);
16282 if (!vec_len (if_name))
16284 errmsg ("interface name must be specified");
16288 if (vec_len (if_name) > 64)
16290 errmsg ("interface name too long");
16294 M (NETMAP_DELETE, mp);
16296 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16297 vec_free (if_name);
16304 static void vl_api_mpls_tunnel_details_t_handler
16305 (vl_api_mpls_tunnel_details_t * mp)
16307 vat_main_t *vam = &vat_main;
16308 i32 len = mp->mt_next_hop_n_labels;
16311 print (vam->ofp, "[%d]: via %U %d labels ",
16313 format_ip4_address, mp->mt_next_hop,
16314 ntohl (mp->mt_next_hop_sw_if_index));
16315 for (i = 0; i < len; i++)
16317 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
16319 print (vam->ofp, "");
16322 static void vl_api_mpls_tunnel_details_t_handler_json
16323 (vl_api_mpls_tunnel_details_t * mp)
16325 vat_main_t *vam = &vat_main;
16326 vat_json_node_t *node = NULL;
16327 struct in_addr ip4;
16329 i32 len = mp->mt_next_hop_n_labels;
16331 if (VAT_JSON_ARRAY != vam->json_tree.type)
16333 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16334 vat_json_init_array (&vam->json_tree);
16336 node = vat_json_array_add (&vam->json_tree);
16338 vat_json_init_object (node);
16339 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
16340 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
16341 vat_json_object_add_ip4 (node, "next_hop", ip4);
16342 vat_json_object_add_uint (node, "next_hop_sw_if_index",
16343 ntohl (mp->mt_next_hop_sw_if_index));
16344 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
16345 vat_json_object_add_uint (node, "label_count", len);
16346 for (i = 0; i < len; i++)
16348 vat_json_object_add_uint (node, "label",
16349 ntohl (mp->mt_next_hop_out_labels[i]));
16354 api_mpls_tunnel_dump (vat_main_t * vam)
16356 vl_api_mpls_tunnel_dump_t *mp;
16357 vl_api_control_ping_t *mp_ping;
16361 /* Parse args required to build the message */
16362 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
16364 if (!unformat (vam->input, "tunnel_index %d", &index))
16371 print (vam->ofp, " tunnel_index %d", index);
16373 M (MPLS_TUNNEL_DUMP, mp);
16374 mp->tunnel_index = htonl (index);
16377 /* Use a control ping for synchronization */
16378 M (CONTROL_PING, mp_ping);
16385 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
16386 #define vl_api_mpls_fib_details_t_print vl_noop_handler
16389 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
16391 vat_main_t *vam = &vat_main;
16392 int count = ntohl (mp->count);
16393 vl_api_fib_path2_t *fp;
16397 "table-id %d, label %u, ess_bit %u",
16398 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
16400 for (i = 0; i < count; i++)
16402 if (fp->afi == IP46_TYPE_IP6)
16404 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16405 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16406 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16407 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16408 format_ip6_address, fp->next_hop);
16409 else if (fp->afi == IP46_TYPE_IP4)
16411 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16412 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16413 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16414 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16415 format_ip4_address, fp->next_hop);
16420 static void vl_api_mpls_fib_details_t_handler_json
16421 (vl_api_mpls_fib_details_t * mp)
16423 vat_main_t *vam = &vat_main;
16424 int count = ntohl (mp->count);
16425 vat_json_node_t *node = NULL;
16426 struct in_addr ip4;
16427 struct in6_addr ip6;
16428 vl_api_fib_path2_t *fp;
16431 if (VAT_JSON_ARRAY != vam->json_tree.type)
16433 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16434 vat_json_init_array (&vam->json_tree);
16436 node = vat_json_array_add (&vam->json_tree);
16438 vat_json_init_object (node);
16439 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16440 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
16441 vat_json_object_add_uint (node, "label", ntohl (mp->label));
16442 vat_json_object_add_uint (node, "path_count", count);
16444 for (i = 0; i < count; i++)
16446 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16447 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16448 vat_json_object_add_uint (node, "is_local", fp->is_local);
16449 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16450 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16451 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16452 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16453 if (fp->afi == IP46_TYPE_IP4)
16455 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16456 vat_json_object_add_ip4 (node, "next_hop", ip4);
16458 else if (fp->afi == IP46_TYPE_IP6)
16460 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16461 vat_json_object_add_ip6 (node, "next_hop", ip6);
16467 api_mpls_fib_dump (vat_main_t * vam)
16469 vl_api_mpls_fib_dump_t *mp;
16470 vl_api_control_ping_t *mp_ping;
16473 M (MPLS_FIB_DUMP, mp);
16476 /* Use a control ping for synchronization */
16477 M (CONTROL_PING, mp_ping);
16484 #define vl_api_ip_fib_details_t_endian vl_noop_handler
16485 #define vl_api_ip_fib_details_t_print vl_noop_handler
16488 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
16490 vat_main_t *vam = &vat_main;
16491 int count = ntohl (mp->count);
16492 vl_api_fib_path_t *fp;
16496 "table-id %d, prefix %U/%d",
16497 ntohl (mp->table_id), format_ip4_address, mp->address,
16498 mp->address_length);
16500 for (i = 0; i < count; i++)
16502 if (fp->afi == IP46_TYPE_IP6)
16504 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16505 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16506 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16507 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16508 format_ip6_address, fp->next_hop);
16509 else if (fp->afi == IP46_TYPE_IP4)
16511 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16512 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16513 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16514 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16515 format_ip4_address, fp->next_hop);
16520 static void vl_api_ip_fib_details_t_handler_json
16521 (vl_api_ip_fib_details_t * mp)
16523 vat_main_t *vam = &vat_main;
16524 int count = ntohl (mp->count);
16525 vat_json_node_t *node = NULL;
16526 struct in_addr ip4;
16527 struct in6_addr ip6;
16528 vl_api_fib_path_t *fp;
16531 if (VAT_JSON_ARRAY != vam->json_tree.type)
16533 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16534 vat_json_init_array (&vam->json_tree);
16536 node = vat_json_array_add (&vam->json_tree);
16538 vat_json_init_object (node);
16539 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16540 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
16541 vat_json_object_add_ip4 (node, "prefix", ip4);
16542 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16543 vat_json_object_add_uint (node, "path_count", count);
16545 for (i = 0; i < count; i++)
16547 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16548 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16549 vat_json_object_add_uint (node, "is_local", fp->is_local);
16550 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16551 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16552 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16553 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16554 if (fp->afi == IP46_TYPE_IP4)
16556 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16557 vat_json_object_add_ip4 (node, "next_hop", ip4);
16559 else if (fp->afi == IP46_TYPE_IP6)
16561 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16562 vat_json_object_add_ip6 (node, "next_hop", ip6);
16568 api_ip_fib_dump (vat_main_t * vam)
16570 vl_api_ip_fib_dump_t *mp;
16571 vl_api_control_ping_t *mp_ping;
16574 M (IP_FIB_DUMP, mp);
16577 /* Use a control ping for synchronization */
16578 M (CONTROL_PING, mp_ping);
16586 api_ip_mfib_dump (vat_main_t * vam)
16588 vl_api_ip_mfib_dump_t *mp;
16589 vl_api_control_ping_t *mp_ping;
16592 M (IP_MFIB_DUMP, mp);
16595 /* Use a control ping for synchronization */
16596 M (CONTROL_PING, mp_ping);
16603 static void vl_api_ip_neighbor_details_t_handler
16604 (vl_api_ip_neighbor_details_t * mp)
16606 vat_main_t *vam = &vat_main;
16608 print (vam->ofp, "%c %U %U",
16609 (mp->is_static) ? 'S' : 'D',
16610 format_ethernet_address, &mp->mac_address,
16611 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
16615 static void vl_api_ip_neighbor_details_t_handler_json
16616 (vl_api_ip_neighbor_details_t * mp)
16619 vat_main_t *vam = &vat_main;
16620 vat_json_node_t *node;
16621 struct in_addr ip4;
16622 struct in6_addr ip6;
16624 if (VAT_JSON_ARRAY != vam->json_tree.type)
16626 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16627 vat_json_init_array (&vam->json_tree);
16629 node = vat_json_array_add (&vam->json_tree);
16631 vat_json_init_object (node);
16632 vat_json_object_add_string_copy (node, "flag",
16633 (mp->is_static) ? (u8 *) "static" : (u8 *)
16636 vat_json_object_add_string_copy (node, "link_layer",
16637 format (0, "%U", format_ethernet_address,
16638 &mp->mac_address));
16642 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
16643 vat_json_object_add_ip6 (node, "ip_address", ip6);
16647 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
16648 vat_json_object_add_ip4 (node, "ip_address", ip4);
16653 api_ip_neighbor_dump (vat_main_t * vam)
16655 unformat_input_t *i = vam->input;
16656 vl_api_ip_neighbor_dump_t *mp;
16657 vl_api_control_ping_t *mp_ping;
16659 u32 sw_if_index = ~0;
16662 /* Parse args required to build the message */
16663 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16665 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16667 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16669 else if (unformat (i, "ip6"))
16675 if (sw_if_index == ~0)
16677 errmsg ("missing interface name or sw_if_index");
16681 M (IP_NEIGHBOR_DUMP, mp);
16682 mp->is_ipv6 = (u8) is_ipv6;
16683 mp->sw_if_index = ntohl (sw_if_index);
16686 /* Use a control ping for synchronization */
16687 M (CONTROL_PING, mp_ping);
16694 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
16695 #define vl_api_ip6_fib_details_t_print vl_noop_handler
16698 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
16700 vat_main_t *vam = &vat_main;
16701 int count = ntohl (mp->count);
16702 vl_api_fib_path_t *fp;
16706 "table-id %d, prefix %U/%d",
16707 ntohl (mp->table_id), format_ip6_address, mp->address,
16708 mp->address_length);
16710 for (i = 0; i < count; i++)
16712 if (fp->afi == IP46_TYPE_IP6)
16714 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16715 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16716 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16717 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16718 format_ip6_address, fp->next_hop);
16719 else if (fp->afi == IP46_TYPE_IP4)
16721 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16722 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16723 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16724 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16725 format_ip4_address, fp->next_hop);
16730 static void vl_api_ip6_fib_details_t_handler_json
16731 (vl_api_ip6_fib_details_t * mp)
16733 vat_main_t *vam = &vat_main;
16734 int count = ntohl (mp->count);
16735 vat_json_node_t *node = NULL;
16736 struct in_addr ip4;
16737 struct in6_addr ip6;
16738 vl_api_fib_path_t *fp;
16741 if (VAT_JSON_ARRAY != vam->json_tree.type)
16743 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16744 vat_json_init_array (&vam->json_tree);
16746 node = vat_json_array_add (&vam->json_tree);
16748 vat_json_init_object (node);
16749 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16750 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
16751 vat_json_object_add_ip6 (node, "prefix", ip6);
16752 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16753 vat_json_object_add_uint (node, "path_count", count);
16755 for (i = 0; i < count; i++)
16757 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16758 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16759 vat_json_object_add_uint (node, "is_local", fp->is_local);
16760 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16761 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16762 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16763 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16764 if (fp->afi == IP46_TYPE_IP4)
16766 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16767 vat_json_object_add_ip4 (node, "next_hop", ip4);
16769 else if (fp->afi == IP46_TYPE_IP6)
16771 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16772 vat_json_object_add_ip6 (node, "next_hop", ip6);
16778 api_ip6_fib_dump (vat_main_t * vam)
16780 vl_api_ip6_fib_dump_t *mp;
16781 vl_api_control_ping_t *mp_ping;
16784 M (IP6_FIB_DUMP, mp);
16787 /* Use a control ping for synchronization */
16788 M (CONTROL_PING, mp_ping);
16796 api_ip6_mfib_dump (vat_main_t * vam)
16798 vl_api_ip6_mfib_dump_t *mp;
16799 vl_api_control_ping_t *mp_ping;
16802 M (IP6_MFIB_DUMP, mp);
16805 /* Use a control ping for synchronization */
16806 M (CONTROL_PING, mp_ping);
16814 api_classify_table_ids (vat_main_t * vam)
16816 vl_api_classify_table_ids_t *mp;
16819 /* Construct the API message */
16820 M (CLASSIFY_TABLE_IDS, mp);
16829 api_classify_table_by_interface (vat_main_t * vam)
16831 unformat_input_t *input = vam->input;
16832 vl_api_classify_table_by_interface_t *mp;
16834 u32 sw_if_index = ~0;
16836 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16838 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16840 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16845 if (sw_if_index == ~0)
16847 errmsg ("missing interface name or sw_if_index");
16851 /* Construct the API message */
16852 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
16854 mp->sw_if_index = ntohl (sw_if_index);
16862 api_classify_table_info (vat_main_t * vam)
16864 unformat_input_t *input = vam->input;
16865 vl_api_classify_table_info_t *mp;
16869 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16871 if (unformat (input, "table_id %d", &table_id))
16876 if (table_id == ~0)
16878 errmsg ("missing table id");
16882 /* Construct the API message */
16883 M (CLASSIFY_TABLE_INFO, mp);
16885 mp->table_id = ntohl (table_id);
16893 api_classify_session_dump (vat_main_t * vam)
16895 unformat_input_t *input = vam->input;
16896 vl_api_classify_session_dump_t *mp;
16897 vl_api_control_ping_t *mp_ping;
16901 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16903 if (unformat (input, "table_id %d", &table_id))
16908 if (table_id == ~0)
16910 errmsg ("missing table id");
16914 /* Construct the API message */
16915 M (CLASSIFY_SESSION_DUMP, mp);
16917 mp->table_id = ntohl (table_id);
16920 /* Use a control ping for synchronization */
16921 M (CONTROL_PING, mp_ping);
16929 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
16931 vat_main_t *vam = &vat_main;
16933 print (vam->ofp, "collector_address %U, collector_port %d, "
16934 "src_address %U, vrf_id %d, path_mtu %u, "
16935 "template_interval %u, udp_checksum %d",
16936 format_ip4_address, mp->collector_address,
16937 ntohs (mp->collector_port),
16938 format_ip4_address, mp->src_address,
16939 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
16940 ntohl (mp->template_interval), mp->udp_checksum);
16943 vam->result_ready = 1;
16947 vl_api_ipfix_exporter_details_t_handler_json
16948 (vl_api_ipfix_exporter_details_t * mp)
16950 vat_main_t *vam = &vat_main;
16951 vat_json_node_t node;
16952 struct in_addr collector_address;
16953 struct in_addr src_address;
16955 vat_json_init_object (&node);
16956 clib_memcpy (&collector_address, &mp->collector_address,
16957 sizeof (collector_address));
16958 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
16959 vat_json_object_add_uint (&node, "collector_port",
16960 ntohs (mp->collector_port));
16961 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
16962 vat_json_object_add_ip4 (&node, "src_address", src_address);
16963 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
16964 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
16965 vat_json_object_add_uint (&node, "template_interval",
16966 ntohl (mp->template_interval));
16967 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
16969 vat_json_print (vam->ofp, &node);
16970 vat_json_free (&node);
16972 vam->result_ready = 1;
16976 api_ipfix_exporter_dump (vat_main_t * vam)
16978 vl_api_ipfix_exporter_dump_t *mp;
16981 /* Construct the API message */
16982 M (IPFIX_EXPORTER_DUMP, mp);
16991 api_ipfix_classify_stream_dump (vat_main_t * vam)
16993 vl_api_ipfix_classify_stream_dump_t *mp;
16996 /* Construct the API message */
16997 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
17008 vl_api_ipfix_classify_stream_details_t_handler
17009 (vl_api_ipfix_classify_stream_details_t * mp)
17011 vat_main_t *vam = &vat_main;
17012 print (vam->ofp, "domain_id %d, src_port %d",
17013 ntohl (mp->domain_id), ntohs (mp->src_port));
17015 vam->result_ready = 1;
17019 vl_api_ipfix_classify_stream_details_t_handler_json
17020 (vl_api_ipfix_classify_stream_details_t * mp)
17022 vat_main_t *vam = &vat_main;
17023 vat_json_node_t node;
17025 vat_json_init_object (&node);
17026 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
17027 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
17029 vat_json_print (vam->ofp, &node);
17030 vat_json_free (&node);
17032 vam->result_ready = 1;
17036 api_ipfix_classify_table_dump (vat_main_t * vam)
17038 vl_api_ipfix_classify_table_dump_t *mp;
17039 vl_api_control_ping_t *mp_ping;
17042 if (!vam->json_output)
17044 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
17045 "transport_protocol");
17048 /* Construct the API message */
17049 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
17054 /* Use a control ping for synchronization */
17055 M (CONTROL_PING, mp_ping);
17063 vl_api_ipfix_classify_table_details_t_handler
17064 (vl_api_ipfix_classify_table_details_t * mp)
17066 vat_main_t *vam = &vat_main;
17067 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
17068 mp->transport_protocol);
17072 vl_api_ipfix_classify_table_details_t_handler_json
17073 (vl_api_ipfix_classify_table_details_t * mp)
17075 vat_json_node_t *node = NULL;
17076 vat_main_t *vam = &vat_main;
17078 if (VAT_JSON_ARRAY != vam->json_tree.type)
17080 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17081 vat_json_init_array (&vam->json_tree);
17084 node = vat_json_array_add (&vam->json_tree);
17085 vat_json_init_object (node);
17087 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
17088 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
17089 vat_json_object_add_uint (node, "transport_protocol",
17090 mp->transport_protocol);
17094 api_sw_interface_span_enable_disable (vat_main_t * vam)
17096 unformat_input_t *i = vam->input;
17097 vl_api_sw_interface_span_enable_disable_t *mp;
17098 u32 src_sw_if_index = ~0;
17099 u32 dst_sw_if_index = ~0;
17103 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17106 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
17108 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
17112 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
17114 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
17116 else if (unformat (i, "disable"))
17118 else if (unformat (i, "rx"))
17120 else if (unformat (i, "tx"))
17122 else if (unformat (i, "both"))
17128 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
17130 mp->sw_if_index_from = htonl (src_sw_if_index);
17131 mp->sw_if_index_to = htonl (dst_sw_if_index);
17140 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
17143 vat_main_t *vam = &vat_main;
17144 u8 *sw_if_from_name = 0;
17145 u8 *sw_if_to_name = 0;
17146 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17147 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17148 char *states[] = { "none", "rx", "tx", "both" };
17152 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17154 if ((u32) p->value[0] == sw_if_index_from)
17156 sw_if_from_name = (u8 *)(p->key);
17160 if ((u32) p->value[0] == sw_if_index_to)
17162 sw_if_to_name = (u8 *)(p->key);
17163 if (sw_if_from_name)
17168 print (vam->ofp, "%20s => %20s (%s)",
17169 sw_if_from_name, sw_if_to_name, states[mp->state]);
17173 vl_api_sw_interface_span_details_t_handler_json
17174 (vl_api_sw_interface_span_details_t * mp)
17176 vat_main_t *vam = &vat_main;
17177 vat_json_node_t *node = NULL;
17178 u8 *sw_if_from_name = 0;
17179 u8 *sw_if_to_name = 0;
17180 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17181 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17185 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17187 if ((u32) p->value[0] == sw_if_index_from)
17189 sw_if_from_name = (u8 *)(p->key);
17193 if ((u32) p->value[0] == sw_if_index_to)
17195 sw_if_to_name = (u8 *)(p->key);
17196 if (sw_if_from_name)
17202 if (VAT_JSON_ARRAY != vam->json_tree.type)
17204 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17205 vat_json_init_array (&vam->json_tree);
17207 node = vat_json_array_add (&vam->json_tree);
17209 vat_json_init_object (node);
17210 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
17211 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
17212 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
17213 if (0 != sw_if_to_name)
17215 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
17217 vat_json_object_add_uint (node, "state", mp->state);
17221 api_sw_interface_span_dump (vat_main_t * vam)
17223 vl_api_sw_interface_span_dump_t *mp;
17224 vl_api_control_ping_t *mp_ping;
17227 M (SW_INTERFACE_SPAN_DUMP, mp);
17230 /* Use a control ping for synchronization */
17231 M (CONTROL_PING, mp_ping);
17239 api_pg_create_interface (vat_main_t * vam)
17241 unformat_input_t *input = vam->input;
17242 vl_api_pg_create_interface_t *mp;
17246 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17248 if (unformat (input, "if_id %d", &if_id))
17255 errmsg ("missing pg interface index");
17259 /* Construct the API message */
17260 M (PG_CREATE_INTERFACE, mp);
17262 mp->interface_id = ntohl (if_id);
17270 api_pg_capture (vat_main_t * vam)
17272 unformat_input_t *input = vam->input;
17273 vl_api_pg_capture_t *mp;
17278 u8 pcap_file_set = 0;
17281 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17283 if (unformat (input, "if_id %d", &if_id))
17285 else if (unformat (input, "pcap %s", &pcap_file))
17287 else if (unformat (input, "count %d", &count))
17289 else if (unformat (input, "disable"))
17296 errmsg ("missing pg interface index");
17299 if (pcap_file_set > 0)
17301 if (vec_len (pcap_file) > 255)
17303 errmsg ("pcap file name is too long");
17308 u32 name_len = vec_len (pcap_file);
17309 /* Construct the API message */
17310 M (PG_CAPTURE, mp);
17312 mp->interface_id = ntohl (if_id);
17313 mp->is_enabled = enable;
17314 mp->count = ntohl (count);
17315 mp->pcap_name_length = ntohl (name_len);
17316 if (pcap_file_set != 0)
17318 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
17320 vec_free (pcap_file);
17328 api_pg_enable_disable (vat_main_t * vam)
17330 unformat_input_t *input = vam->input;
17331 vl_api_pg_enable_disable_t *mp;
17334 u8 stream_name_set = 0;
17335 u8 *stream_name = 0;
17337 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17339 if (unformat (input, "stream %s", &stream_name))
17340 stream_name_set = 1;
17341 else if (unformat (input, "disable"))
17347 if (stream_name_set > 0)
17349 if (vec_len (stream_name) > 255)
17351 errmsg ("stream name too long");
17356 u32 name_len = vec_len (stream_name);
17357 /* Construct the API message */
17358 M (PG_ENABLE_DISABLE, mp);
17360 mp->is_enabled = enable;
17361 if (stream_name_set != 0)
17363 mp->stream_name_length = ntohl (name_len);
17364 clib_memcpy (mp->stream_name, stream_name, name_len);
17366 vec_free (stream_name);
17374 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
17376 unformat_input_t *input = vam->input;
17377 vl_api_ip_source_and_port_range_check_add_del_t *mp;
17379 u16 *low_ports = 0;
17380 u16 *high_ports = 0;
17383 ip4_address_t ip4_addr;
17384 ip6_address_t ip6_addr;
17393 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17395 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
17401 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
17406 else if (unformat (input, "vrf %d", &vrf_id))
17408 else if (unformat (input, "del"))
17410 else if (unformat (input, "port %d", &tmp))
17412 if (tmp == 0 || tmp > 65535)
17414 errmsg ("port %d out of range", tmp);
17418 this_hi = this_low + 1;
17419 vec_add1 (low_ports, this_low);
17420 vec_add1 (high_ports, this_hi);
17422 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
17424 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
17426 errmsg ("incorrect range parameters");
17430 /* Note: in debug CLI +1 is added to high before
17431 passing to real fn that does "the work"
17432 (ip_source_and_port_range_check_add_del).
17433 This fn is a wrapper around the binary API fn a
17434 control plane will call, which expects this increment
17435 to have occurred. Hence letting the binary API control
17436 plane fn do the increment for consistency between VAT
17437 and other control planes.
17440 vec_add1 (low_ports, this_low);
17441 vec_add1 (high_ports, this_hi);
17447 if (prefix_set == 0)
17449 errmsg ("<address>/<mask> not specified");
17455 errmsg ("VRF ID required, not specified");
17462 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17466 if (vec_len (low_ports) == 0)
17468 errmsg ("At least one port or port range required");
17472 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
17474 mp->is_add = is_add;
17479 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
17484 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
17487 mp->mask_length = length;
17488 mp->number_of_ranges = vec_len (low_ports);
17490 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
17491 vec_free (low_ports);
17493 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
17494 vec_free (high_ports);
17496 mp->vrf_id = ntohl (vrf_id);
17504 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
17506 unformat_input_t *input = vam->input;
17507 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
17508 u32 sw_if_index = ~0;
17510 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
17511 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
17515 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17517 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17519 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17521 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
17523 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
17525 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
17527 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
17529 else if (unformat (input, "del"))
17535 if (sw_if_index == ~0)
17537 errmsg ("Interface required but not specified");
17543 errmsg ("VRF ID required but not specified");
17547 if (tcp_out_vrf_id == 0
17548 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
17551 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17555 /* Construct the API message */
17556 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
17558 mp->sw_if_index = ntohl (sw_if_index);
17559 mp->is_add = is_add;
17560 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
17561 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
17562 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
17563 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
17568 /* Wait for a reply... */
17574 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
17576 unformat_input_t *i = vam->input;
17577 vl_api_ipsec_gre_add_del_tunnel_t *mp;
17578 u32 local_sa_id = 0;
17579 u32 remote_sa_id = 0;
17580 ip4_address_t src_address;
17581 ip4_address_t dst_address;
17585 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17587 if (unformat (i, "local_sa %d", &local_sa_id))
17589 else if (unformat (i, "remote_sa %d", &remote_sa_id))
17591 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
17593 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
17595 else if (unformat (i, "del"))
17599 clib_warning ("parse error '%U'", format_unformat_error, i);
17604 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
17606 mp->local_sa_id = ntohl (local_sa_id);
17607 mp->remote_sa_id = ntohl (remote_sa_id);
17608 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
17609 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
17610 mp->is_add = is_add;
17618 api_punt (vat_main_t * vam)
17620 unformat_input_t *i = vam->input;
17628 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17630 if (unformat (i, "ip %d", &ipv))
17632 else if (unformat (i, "protocol %d", &protocol))
17634 else if (unformat (i, "port %d", &port))
17636 else if (unformat (i, "del"))
17640 clib_warning ("parse error '%U'", format_unformat_error, i);
17647 mp->is_add = (u8) is_add;
17648 mp->ipv = (u8) ipv;
17649 mp->l4_protocol = (u8) protocol;
17650 mp->l4_port = htons ((u16) port);
17657 static void vl_api_ipsec_gre_tunnel_details_t_handler
17658 (vl_api_ipsec_gre_tunnel_details_t * mp)
17660 vat_main_t *vam = &vat_main;
17662 print (vam->ofp, "%11d%15U%15U%14d%14d",
17663 ntohl (mp->sw_if_index),
17664 format_ip4_address, &mp->src_address,
17665 format_ip4_address, &mp->dst_address,
17666 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
17669 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
17670 (vl_api_ipsec_gre_tunnel_details_t * mp)
17672 vat_main_t *vam = &vat_main;
17673 vat_json_node_t *node = NULL;
17674 struct in_addr ip4;
17676 if (VAT_JSON_ARRAY != vam->json_tree.type)
17678 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17679 vat_json_init_array (&vam->json_tree);
17681 node = vat_json_array_add (&vam->json_tree);
17683 vat_json_init_object (node);
17684 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17685 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
17686 vat_json_object_add_ip4 (node, "src_address", ip4);
17687 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
17688 vat_json_object_add_ip4 (node, "dst_address", ip4);
17689 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
17690 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
17694 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
17696 unformat_input_t *i = vam->input;
17697 vl_api_ipsec_gre_tunnel_dump_t *mp;
17698 vl_api_control_ping_t *mp_ping;
17700 u8 sw_if_index_set = 0;
17703 /* Parse args required to build the message */
17704 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17706 if (unformat (i, "sw_if_index %d", &sw_if_index))
17707 sw_if_index_set = 1;
17712 if (sw_if_index_set == 0)
17717 if (!vam->json_output)
17719 print (vam->ofp, "%11s%15s%15s%14s%14s",
17720 "sw_if_index", "src_address", "dst_address",
17721 "local_sa_id", "remote_sa_id");
17724 /* Get list of gre-tunnel interfaces */
17725 M (IPSEC_GRE_TUNNEL_DUMP, mp);
17727 mp->sw_if_index = htonl (sw_if_index);
17731 /* Use a control ping for synchronization */
17732 M (CONTROL_PING, mp_ping);
17740 api_delete_subif (vat_main_t * vam)
17742 unformat_input_t *i = vam->input;
17743 vl_api_delete_subif_t *mp;
17744 u32 sw_if_index = ~0;
17747 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17749 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17751 if (unformat (i, "sw_if_index %d", &sw_if_index))
17757 if (sw_if_index == ~0)
17759 errmsg ("missing sw_if_index");
17763 /* Construct the API message */
17764 M (DELETE_SUBIF, mp);
17765 mp->sw_if_index = ntohl (sw_if_index);
17772 #define foreach_pbb_vtr_op \
17773 _("disable", L2_VTR_DISABLED) \
17774 _("pop", L2_VTR_POP_2) \
17775 _("push", L2_VTR_PUSH_2)
17778 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
17780 unformat_input_t *i = vam->input;
17781 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
17782 u32 sw_if_index = ~0, vtr_op = ~0;
17783 u16 outer_tag = ~0;
17784 u8 dmac[6], smac[6];
17785 u8 dmac_set = 0, smac_set = 0;
17791 /* Shut up coverity */
17792 memset (dmac, 0, sizeof (dmac));
17793 memset (smac, 0, sizeof (smac));
17795 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17797 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17799 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17801 else if (unformat (i, "vtr_op %d", &vtr_op))
17803 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
17806 else if (unformat (i, "translate_pbb_stag"))
17808 if (unformat (i, "%d", &tmp))
17810 vtr_op = L2_VTR_TRANSLATE_2_1;
17816 ("translate_pbb_stag operation requires outer tag definition");
17820 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
17822 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
17824 else if (unformat (i, "sid %d", &sid))
17826 else if (unformat (i, "vlanid %d", &tmp))
17830 clib_warning ("parse error '%U'", format_unformat_error, i);
17835 if ((sw_if_index == ~0) || (vtr_op == ~0))
17837 errmsg ("missing sw_if_index or vtr operation");
17840 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
17841 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
17844 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
17848 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
17849 mp->sw_if_index = ntohl (sw_if_index);
17850 mp->vtr_op = ntohl (vtr_op);
17851 mp->outer_tag = ntohs (outer_tag);
17852 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
17853 clib_memcpy (mp->b_smac, smac, sizeof (smac));
17854 mp->b_vlanid = ntohs (vlanid);
17855 mp->i_sid = ntohl (sid);
17863 api_flow_classify_set_interface (vat_main_t * vam)
17865 unformat_input_t *i = vam->input;
17866 vl_api_flow_classify_set_interface_t *mp;
17868 int sw_if_index_set;
17869 u32 ip4_table_index = ~0;
17870 u32 ip6_table_index = ~0;
17874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17876 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17877 sw_if_index_set = 1;
17878 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17879 sw_if_index_set = 1;
17880 else if (unformat (i, "del"))
17882 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17884 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17888 clib_warning ("parse error '%U'", format_unformat_error, i);
17893 if (sw_if_index_set == 0)
17895 errmsg ("missing interface name or sw_if_index");
17899 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
17901 mp->sw_if_index = ntohl (sw_if_index);
17902 mp->ip4_table_index = ntohl (ip4_table_index);
17903 mp->ip6_table_index = ntohl (ip6_table_index);
17904 mp->is_add = is_add;
17912 api_flow_classify_dump (vat_main_t * vam)
17914 unformat_input_t *i = vam->input;
17915 vl_api_flow_classify_dump_t *mp;
17916 vl_api_control_ping_t *mp_ping;
17917 u8 type = FLOW_CLASSIFY_N_TABLES;
17920 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
17924 errmsg ("classify table type must be specified");
17928 if (!vam->json_output)
17930 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17933 M (FLOW_CLASSIFY_DUMP, mp);
17938 /* Use a control ping for synchronization */
17939 M (CONTROL_PING, mp_ping);
17942 /* Wait for a reply... */
17948 api_feature_enable_disable (vat_main_t * vam)
17950 unformat_input_t *i = vam->input;
17951 vl_api_feature_enable_disable_t *mp;
17953 u8 *feature_name = 0;
17954 u32 sw_if_index = ~0;
17958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17960 if (unformat (i, "arc_name %s", &arc_name))
17962 else if (unformat (i, "feature_name %s", &feature_name))
17965 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17967 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17969 else if (unformat (i, "disable"))
17977 errmsg ("missing arc name");
17980 if (vec_len (arc_name) > 63)
17982 errmsg ("arc name too long");
17985 if (feature_name == 0)
17987 errmsg ("missing feature name");
17990 if (vec_len (feature_name) > 63)
17992 errmsg ("feature name too long");
17995 if (sw_if_index == ~0)
17997 errmsg ("missing interface name or sw_if_index");
18001 /* Construct the API message */
18002 M (FEATURE_ENABLE_DISABLE, mp);
18003 mp->sw_if_index = ntohl (sw_if_index);
18004 mp->enable = enable;
18005 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
18006 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
18007 vec_free (arc_name);
18008 vec_free (feature_name);
18016 api_sw_interface_tag_add_del (vat_main_t * vam)
18018 unformat_input_t *i = vam->input;
18019 vl_api_sw_interface_tag_add_del_t *mp;
18020 u32 sw_if_index = ~0;
18025 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18027 if (unformat (i, "tag %s", &tag))
18029 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18031 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18033 else if (unformat (i, "del"))
18039 if (sw_if_index == ~0)
18041 errmsg ("missing interface name or sw_if_index");
18045 if (enable && (tag == 0))
18047 errmsg ("no tag specified");
18051 /* Construct the API message */
18052 M (SW_INTERFACE_TAG_ADD_DEL, mp);
18053 mp->sw_if_index = ntohl (sw_if_index);
18054 mp->is_add = enable;
18056 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
18064 static void vl_api_l2_xconnect_details_t_handler
18065 (vl_api_l2_xconnect_details_t * mp)
18067 vat_main_t *vam = &vat_main;
18069 print (vam->ofp, "%15d%15d",
18070 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
18073 static void vl_api_l2_xconnect_details_t_handler_json
18074 (vl_api_l2_xconnect_details_t * mp)
18076 vat_main_t *vam = &vat_main;
18077 vat_json_node_t *node = NULL;
18079 if (VAT_JSON_ARRAY != vam->json_tree.type)
18081 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18082 vat_json_init_array (&vam->json_tree);
18084 node = vat_json_array_add (&vam->json_tree);
18086 vat_json_init_object (node);
18087 vat_json_object_add_uint (node, "rx_sw_if_index",
18088 ntohl (mp->rx_sw_if_index));
18089 vat_json_object_add_uint (node, "tx_sw_if_index",
18090 ntohl (mp->tx_sw_if_index));
18094 api_l2_xconnect_dump (vat_main_t * vam)
18096 vl_api_l2_xconnect_dump_t *mp;
18097 vl_api_control_ping_t *mp_ping;
18100 if (!vam->json_output)
18102 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
18105 M (L2_XCONNECT_DUMP, mp);
18109 /* Use a control ping for synchronization */
18110 M (CONTROL_PING, mp_ping);
18118 api_sw_interface_set_mtu (vat_main_t * vam)
18120 unformat_input_t *i = vam->input;
18121 vl_api_sw_interface_set_mtu_t *mp;
18122 u32 sw_if_index = ~0;
18126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18128 if (unformat (i, "mtu %d", &mtu))
18130 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18132 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18138 if (sw_if_index == ~0)
18140 errmsg ("missing interface name or sw_if_index");
18146 errmsg ("no mtu specified");
18150 /* Construct the API message */
18151 M (SW_INTERFACE_SET_MTU, mp);
18152 mp->sw_if_index = ntohl (sw_if_index);
18153 mp->mtu = ntohs ((u16) mtu);
18162 q_or_quit (vat_main_t * vam)
18164 #if VPP_API_TEST_BUILTIN == 0
18165 longjmp (vam->jump_buf, 1);
18167 return 0; /* not so much */
18171 q (vat_main_t * vam)
18173 return q_or_quit (vam);
18177 quit (vat_main_t * vam)
18179 return q_or_quit (vam);
18183 comment (vat_main_t * vam)
18189 cmd_cmp (void *a1, void *a2)
18194 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
18198 help (vat_main_t * vam)
18203 unformat_input_t *i = vam->input;
18206 if (unformat (i, "%s", &name))
18210 vec_add1 (name, 0);
18212 hs = hash_get_mem (vam->help_by_name, name);
18214 print (vam->ofp, "usage: %s %s", name, hs[0]);
18216 print (vam->ofp, "No such msg / command '%s'", name);
18221 print (vam->ofp, "Help is available for the following:");
18224 hash_foreach_pair (p, vam->function_by_name,
18226 vec_add1 (cmds, (u8 *)(p->key));
18230 vec_sort_with_function (cmds, cmd_cmp);
18232 for (j = 0; j < vec_len (cmds); j++)
18233 print (vam->ofp, "%s", cmds[j]);
18240 set (vat_main_t * vam)
18242 u8 *name = 0, *value = 0;
18243 unformat_input_t *i = vam->input;
18245 if (unformat (i, "%s", &name))
18247 /* The input buffer is a vector, not a string. */
18248 value = vec_dup (i->buffer);
18249 vec_delete (value, i->index, 0);
18250 /* Almost certainly has a trailing newline */
18251 if (value[vec_len (value) - 1] == '\n')
18252 value[vec_len (value) - 1] = 0;
18253 /* Make sure it's a proper string, one way or the other */
18254 vec_add1 (value, 0);
18255 (void) clib_macro_set_value (&vam->macro_main,
18256 (char *) name, (char *) value);
18259 errmsg ("usage: set <name> <value>");
18267 unset (vat_main_t * vam)
18271 if (unformat (vam->input, "%s", &name))
18272 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
18273 errmsg ("unset: %s wasn't set", name);
18286 macro_sort_cmp (void *a1, void *a2)
18288 macro_sort_t *s1 = a1;
18289 macro_sort_t *s2 = a2;
18291 return strcmp ((char *) (s1->name), (char *) (s2->name));
18295 dump_macro_table (vat_main_t * vam)
18297 macro_sort_t *sort_me = 0, *sm;
18302 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
18304 vec_add2 (sort_me, sm, 1);
18305 sm->name = (u8 *)(p->key);
18306 sm->value = (u8 *) (p->value[0]);
18310 vec_sort_with_function (sort_me, macro_sort_cmp);
18312 if (vec_len (sort_me))
18313 print (vam->ofp, "%-15s%s", "Name", "Value");
18315 print (vam->ofp, "The macro table is empty...");
18317 for (i = 0; i < vec_len (sort_me); i++)
18318 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
18323 dump_node_table (vat_main_t * vam)
18326 vlib_node_t *node, *next_node;
18328 if (vec_len (vam->graph_nodes) == 0)
18330 print (vam->ofp, "Node table empty, issue get_node_graph...");
18334 for (i = 0; i < vec_len (vam->graph_nodes); i++)
18336 node = vam->graph_nodes[i];
18337 print (vam->ofp, "[%d] %s", i, node->name);
18338 for (j = 0; j < vec_len (node->next_nodes); j++)
18340 if (node->next_nodes[j] != ~0)
18342 next_node = vam->graph_nodes[node->next_nodes[j]];
18343 print (vam->ofp, " [%d] %s", j, next_node->name);
18351 value_sort_cmp (void *a1, void *a2)
18353 name_sort_t *n1 = a1;
18354 name_sort_t *n2 = a2;
18356 if (n1->value < n2->value)
18358 if (n1->value > n2->value)
18365 dump_msg_api_table (vat_main_t * vam)
18367 api_main_t *am = &api_main;
18368 name_sort_t *nses = 0, *ns;
18373 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
18375 vec_add2 (nses, ns, 1);
18376 ns->name = (u8 *)(hp->key);
18377 ns->value = (u32) hp->value[0];
18381 vec_sort_with_function (nses, value_sort_cmp);
18383 for (i = 0; i < vec_len (nses); i++)
18384 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
18390 get_msg_id (vat_main_t * vam)
18395 if (unformat (vam->input, "%s", &name_and_crc))
18397 message_index = vl_api_get_msg_index (name_and_crc);
18398 if (message_index == ~0)
18400 print (vam->ofp, " '%s' not found", name_and_crc);
18403 print (vam->ofp, " '%s' has message index %d",
18404 name_and_crc, message_index);
18407 errmsg ("name_and_crc required...");
18412 search_node_table (vat_main_t * vam)
18414 unformat_input_t *line_input = vam->input;
18417 vlib_node_t *node, *next_node;
18420 if (vam->graph_node_index_by_name == 0)
18422 print (vam->ofp, "Node table empty, issue get_node_graph...");
18426 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
18428 if (unformat (line_input, "%s", &node_to_find))
18430 vec_add1 (node_to_find, 0);
18431 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
18434 print (vam->ofp, "%s not found...", node_to_find);
18437 node = vam->graph_nodes[p[0]];
18438 print (vam->ofp, "[%d] %s", p[0], node->name);
18439 for (j = 0; j < vec_len (node->next_nodes); j++)
18441 if (node->next_nodes[j] != ~0)
18443 next_node = vam->graph_nodes[node->next_nodes[j]];
18444 print (vam->ofp, " [%d] %s", j, next_node->name);
18451 clib_warning ("parse error '%U'", format_unformat_error,
18457 vec_free (node_to_find);
18466 script (vat_main_t * vam)
18468 #if (VPP_API_TEST_BUILTIN==0)
18470 char *save_current_file;
18471 unformat_input_t save_input;
18472 jmp_buf save_jump_buf;
18473 u32 save_line_number;
18475 FILE *new_fp, *save_ifp;
18477 if (unformat (vam->input, "%s", &s))
18479 new_fp = fopen ((char *) s, "r");
18482 errmsg ("Couldn't open script file %s", s);
18489 errmsg ("Missing script name");
18493 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
18494 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
18495 save_ifp = vam->ifp;
18496 save_line_number = vam->input_line_number;
18497 save_current_file = (char *) vam->current_file;
18499 vam->input_line_number = 0;
18501 vam->current_file = s;
18504 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
18505 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
18506 vam->ifp = save_ifp;
18507 vam->input_line_number = save_line_number;
18508 vam->current_file = (u8 *) save_current_file;
18513 clib_warning ("use the exec command...");
18519 echo (vat_main_t * vam)
18521 print (vam->ofp, "%v", vam->input->buffer);
18525 /* List of API message constructors, CLI names map to api_xxx */
18526 #define foreach_vpe_api_msg \
18527 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
18528 _(sw_interface_dump,"") \
18529 _(sw_interface_set_flags, \
18530 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
18531 _(sw_interface_add_del_address, \
18532 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
18533 _(sw_interface_set_table, \
18534 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
18535 _(sw_interface_set_mpls_enable, \
18536 "<intfc> | sw_if_index [disable | dis]") \
18537 _(sw_interface_set_vpath, \
18538 "<intfc> | sw_if_index <id> enable | disable") \
18539 _(sw_interface_set_vxlan_bypass, \
18540 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
18541 _(sw_interface_set_l2_xconnect, \
18542 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18543 "enable | disable") \
18544 _(sw_interface_set_l2_bridge, \
18545 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
18546 "[shg <split-horizon-group>] [bvi]\n" \
18547 "enable | disable") \
18548 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255\n")\
18549 _(bridge_domain_add_del, \
18550 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [mac-age 0-255] [del]\n") \
18551 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
18553 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
18555 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
18557 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
18559 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
18561 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
18563 "<vpp-if-name> | sw_if_index <id>") \
18564 _(sw_interface_tap_dump, "") \
18565 _(ip_add_del_route, \
18566 "<addr>/<mask> via <addr> [table-id <n>]\n" \
18567 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18568 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18569 "[multipath] [count <n>]") \
18570 _(ip_mroute_add_del, \
18571 "<src> <grp>/<mask> [table-id <n>]\n" \
18572 "[<intfc> | sw_if_index <id>] [local] [del]") \
18573 _(mpls_route_add_del, \
18574 "<label> <eos> via <addr> [table-id <n>]\n" \
18575 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18576 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18577 "[multipath] [count <n>]") \
18578 _(mpls_ip_bind_unbind, \
18579 "<label> <addr/len>") \
18580 _(mpls_tunnel_add_del, \
18581 " via <addr> [table-id <n>]\n" \
18582 "sw_if_index <id>] [l2] [del]") \
18583 _(proxy_arp_add_del, \
18584 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
18585 _(proxy_arp_intfc_enable_disable, \
18586 "<intfc> | sw_if_index <id> enable | disable") \
18587 _(sw_interface_set_unnumbered, \
18588 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
18589 _(ip_neighbor_add_del, \
18590 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
18591 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
18592 _(reset_vrf, "vrf <id> [ipv6]") \
18593 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
18594 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
18595 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
18596 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
18597 "[outer_vlan_id_any][inner_vlan_id_any]") \
18598 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
18599 _(reset_fib, "vrf <n> [ipv6]") \
18600 _(dhcp_proxy_config, \
18601 "svr <v46-address> src <v46-address>\n" \
18602 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
18603 _(dhcp_proxy_set_vss, \
18604 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
18605 _(dhcp_proxy_dump, "ip6") \
18606 _(dhcp_client_config, \
18607 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
18608 _(set_ip_flow_hash, \
18609 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
18610 _(sw_interface_ip6_enable_disable, \
18611 "<intfc> | sw_if_index <id> enable | disable") \
18612 _(sw_interface_ip6_set_link_local_address, \
18613 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
18614 _(ip6nd_proxy_add_del, \
18615 "<intfc> | sw_if_index <id> <ip6-address>") \
18616 _(ip6nd_proxy_dump, "") \
18617 _(sw_interface_ip6nd_ra_prefix, \
18618 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
18619 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
18620 "[nolink] [isno]") \
18621 _(sw_interface_ip6nd_ra_config, \
18622 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
18623 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
18624 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
18625 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
18626 _(l2_patch_add_del, \
18627 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18628 "enable | disable") \
18629 _(sr_localsid_add_del, \
18630 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
18631 "fib-table <num> (end.psp) sw_if_index <num>") \
18632 _(classify_add_del_table, \
18633 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
18634 " [del] [del-chain] mask <mask-value>\n" \
18635 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
18636 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
18637 _(classify_add_del_session, \
18638 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
18639 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
18640 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
18641 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
18642 _(classify_set_interface_ip_table, \
18643 "<intfc> | sw_if_index <nn> table <nn>") \
18644 _(classify_set_interface_l2_tables, \
18645 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18646 " [other-table <nn>]") \
18647 _(get_node_index, "node <node-name") \
18648 _(add_node_next, "node <node-name> next <next-node-name>") \
18649 _(l2tpv3_create_tunnel, \
18650 "client_address <ip6-addr> our_address <ip6-addr>\n" \
18651 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
18652 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
18653 _(l2tpv3_set_tunnel_cookies, \
18654 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
18655 "[new_remote_cookie <nn>]\n") \
18656 _(l2tpv3_interface_enable_disable, \
18657 "<intfc> | sw_if_index <nn> enable | disable") \
18658 _(l2tpv3_set_lookup_key, \
18659 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
18660 _(sw_if_l2tpv3_tunnel_dump, "") \
18661 _(vxlan_add_del_tunnel, \
18662 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
18663 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
18664 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
18665 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18666 _(gre_add_del_tunnel, \
18667 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
18668 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18669 _(l2_fib_clear_table, "") \
18670 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
18671 _(l2_interface_vlan_tag_rewrite, \
18672 "<intfc> | sw_if_index <nn> \n" \
18673 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
18674 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
18675 _(create_vhost_user_if, \
18676 "socket <filename> [server] [renumber <dev_instance>] " \
18677 "[mac <mac_address>] " \
18678 "[mode <interrupt | polling>]") \
18679 _(modify_vhost_user_if, \
18680 "<intfc> | sw_if_index <nn> socket <filename>\n" \
18681 "[server] [renumber <dev_instance>] " \
18682 "[mode <interrupt | polling>]") \
18683 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
18684 _(sw_interface_vhost_user_dump, "") \
18685 _(show_version, "") \
18686 _(vxlan_gpe_add_del_tunnel, \
18687 "local <addr> remote <addr> vni <nn>\n" \
18688 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
18689 "[next-ethernet] [next-nsh]\n") \
18690 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18691 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
18692 _(interface_name_renumber, \
18693 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
18694 _(input_acl_set_interface, \
18695 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18696 " [l2-table <nn>] [del]") \
18697 _(want_ip4_arp_events, "address <ip4-address> [del]") \
18698 _(want_ip6_nd_events, "address <ip6-address> [del]") \
18699 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
18700 _(ip_dump, "ipv4 | ipv6") \
18701 _(ipsec_spd_add_del, "spd_id <n> [del]") \
18702 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
18704 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
18705 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
18706 " integ_alg <alg> integ_key <hex>") \
18707 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
18708 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
18709 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
18710 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
18711 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
18712 _(ikev2_profile_add_del, "name <profile_name> [del]") \
18713 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
18714 "(auth_data 0x<data> | auth_data <data>)") \
18715 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
18716 "(id_data 0x<data> | id_data <data>) (local|remote)") \
18717 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
18718 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
18719 "(local|remote)") \
18720 _(ikev2_set_local_key, "file <absolute_file_path>") \
18721 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
18722 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18723 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18724 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
18725 _(ikev2_initiate_sa_init, "<profile_name>") \
18726 _(ikev2_initiate_del_ike_sa, "<ispi>") \
18727 _(ikev2_initiate_del_child_sa, "<ispi>") \
18728 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
18729 _(delete_loopback,"sw_if_index <nn>") \
18730 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
18731 _(map_add_domain, \
18732 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
18733 "ip6-src <ip6addr> " \
18734 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
18735 _(map_del_domain, "index <n>") \
18736 _(map_add_del_rule, \
18737 "index <n> psid <n> dst <ip6addr> [del]") \
18738 _(map_domain_dump, "") \
18739 _(map_rule_dump, "index <map-domain>") \
18740 _(want_interface_events, "enable|disable") \
18741 _(want_stats,"enable|disable") \
18742 _(get_first_msg_id, "client <name>") \
18743 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
18744 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
18745 "fib-id <nn> [ip4][ip6][default]") \
18746 _(get_node_graph, " ") \
18747 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
18748 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
18749 _(ioam_disable, "") \
18750 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
18751 " sw_if_index <sw_if_index> p <priority> " \
18752 "w <weight>] [del]") \
18753 _(one_add_del_locator, "locator-set <locator_name> " \
18754 "iface <intf> | sw_if_index <sw_if_index> " \
18755 "p <priority> w <weight> [del]") \
18756 _(one_add_del_local_eid,"vni <vni> eid " \
18757 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18758 "locator-set <locator_name> [del]" \
18759 "[key-id sha1|sha256 secret-key <secret-key>]")\
18760 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
18761 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
18762 _(one_enable_disable, "enable|disable") \
18763 _(one_map_register_enable_disable, "enable|disable") \
18764 _(one_rloc_probe_enable_disable, "enable|disable") \
18765 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18767 "rloc <locator> p <prio> " \
18768 "w <weight> [rloc <loc> ... ] " \
18769 "action <action> [del-all]") \
18770 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18772 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18773 _(one_use_petr, "ip-address> | disable") \
18774 _(one_map_request_mode, "src-dst|dst-only") \
18775 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18776 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18777 _(one_locator_set_dump, "[local | remote]") \
18778 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
18779 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18780 "[local] | [remote]") \
18781 _(one_stats_enable_disable, "enable|disalbe") \
18782 _(show_one_stats_enable_disable, "") \
18783 _(one_eid_table_vni_dump, "") \
18784 _(one_eid_table_map_dump, "l2|l3") \
18785 _(one_map_resolver_dump, "") \
18786 _(one_map_server_dump, "") \
18787 _(one_adjacencies_get, "vni <vni>") \
18788 _(show_one_rloc_probe_state, "") \
18789 _(show_one_map_register_state, "") \
18790 _(show_one_status, "") \
18791 _(one_stats_dump, "") \
18792 _(one_get_map_request_itr_rlocs, "") \
18793 _(show_one_pitr, "") \
18794 _(show_one_use_petr, "") \
18795 _(show_one_map_request_mode, "") \
18796 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
18797 " sw_if_index <sw_if_index> p <priority> " \
18798 "w <weight>] [del]") \
18799 _(lisp_add_del_locator, "locator-set <locator_name> " \
18800 "iface <intf> | sw_if_index <sw_if_index> " \
18801 "p <priority> w <weight> [del]") \
18802 _(lisp_add_del_local_eid,"vni <vni> eid " \
18803 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18804 "locator-set <locator_name> [del]" \
18805 "[key-id sha1|sha256 secret-key <secret-key>]") \
18806 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
18807 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
18808 _(lisp_enable_disable, "enable|disable") \
18809 _(lisp_map_register_enable_disable, "enable|disable") \
18810 _(lisp_rloc_probe_enable_disable, "enable|disable") \
18811 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18813 "rloc <locator> p <prio> " \
18814 "w <weight> [rloc <loc> ... ] " \
18815 "action <action> [del-all]") \
18816 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18818 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18819 _(lisp_use_petr, "<ip-address> | disable") \
18820 _(lisp_map_request_mode, "src-dst|dst-only") \
18821 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18822 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18823 _(lisp_locator_set_dump, "[local | remote]") \
18824 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
18825 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18826 "[local] | [remote]") \
18827 _(lisp_eid_table_vni_dump, "") \
18828 _(lisp_eid_table_map_dump, "l2|l3") \
18829 _(lisp_map_resolver_dump, "") \
18830 _(lisp_map_server_dump, "") \
18831 _(lisp_adjacencies_get, "vni <vni>") \
18832 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
18833 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
18834 _(gpe_set_encap_mode, "lisp|vxlan") \
18835 _(gpe_get_encap_mode, "") \
18836 _(lisp_gpe_add_del_iface, "up|down") \
18837 _(lisp_gpe_enable_disable, "enable|disable") \
18838 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
18839 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
18840 _(show_lisp_rloc_probe_state, "") \
18841 _(show_lisp_map_register_state, "") \
18842 _(show_lisp_status, "") \
18843 _(lisp_get_map_request_itr_rlocs, "") \
18844 _(show_lisp_pitr, "") \
18845 _(show_lisp_use_petr, "") \
18846 _(show_lisp_map_request_mode, "") \
18847 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
18848 _(af_packet_delete, "name <host interface name>") \
18849 _(policer_add_del, "name <policer name> <params> [del]") \
18850 _(policer_dump, "[name <policer name>]") \
18851 _(policer_classify_set_interface, \
18852 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18853 " [l2-table <nn>] [del]") \
18854 _(policer_classify_dump, "type [ip4|ip6|l2]") \
18855 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
18856 "[master|slave]") \
18857 _(netmap_delete, "name <interface name>") \
18858 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
18859 _(mpls_fib_dump, "") \
18860 _(classify_table_ids, "") \
18861 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
18862 _(classify_table_info, "table_id <nn>") \
18863 _(classify_session_dump, "table_id <nn>") \
18864 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
18865 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
18866 "[template_interval <nn>] [udp_checksum]") \
18867 _(ipfix_exporter_dump, "") \
18868 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
18869 _(ipfix_classify_stream_dump, "") \
18870 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
18871 _(ipfix_classify_table_dump, "") \
18872 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
18873 _(sw_interface_span_dump, "") \
18874 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
18875 _(pg_create_interface, "if_id <nn>") \
18876 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
18877 _(pg_enable_disable, "[stream <id>] disable") \
18878 _(ip_source_and_port_range_check_add_del, \
18879 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
18880 _(ip_source_and_port_range_check_interface_add_del, \
18881 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
18882 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
18883 _(ipsec_gre_add_del_tunnel, \
18884 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
18885 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
18886 _(delete_subif,"<intfc> | sw_if_index <nn>") \
18887 _(l2_interface_pbb_tag_rewrite, \
18888 "<intfc> | sw_if_index <nn> \n" \
18889 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
18890 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
18891 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
18892 _(flow_classify_set_interface, \
18893 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
18894 _(flow_classify_dump, "type [ip4|ip6]") \
18895 _(ip_fib_dump, "") \
18896 _(ip_mfib_dump, "") \
18897 _(ip6_fib_dump, "") \
18898 _(ip6_mfib_dump, "") \
18899 _(feature_enable_disable, "arc_name <arc_name> " \
18900 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
18901 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
18903 _(l2_xconnect_dump, "") \
18904 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
18905 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
18906 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
18908 /* List of command functions, CLI names map directly to functions */
18909 #define foreach_cli_function \
18910 _(comment, "usage: comment <ignore-rest-of-line>") \
18911 _(dump_interface_table, "usage: dump_interface_table") \
18912 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
18913 _(dump_ipv4_table, "usage: dump_ipv4_table") \
18914 _(dump_ipv6_table, "usage: dump_ipv6_table") \
18915 _(dump_stats_table, "usage: dump_stats_table") \
18916 _(dump_macro_table, "usage: dump_macro_table ") \
18917 _(dump_node_table, "usage: dump_node_table") \
18918 _(dump_msg_api_table, "usage: dump_msg_api_table") \
18919 _(get_msg_id, "usage: get_msg_id name_and_crc") \
18920 _(echo, "usage: echo <message>") \
18921 _(exec, "usage: exec <vpe-debug-CLI-command>") \
18922 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
18923 _(help, "usage: help") \
18924 _(q, "usage: quit") \
18925 _(quit, "usage: quit") \
18926 _(search_node_table, "usage: search_node_table <name>...") \
18927 _(set, "usage: set <variable-name> <value>") \
18928 _(script, "usage: script <file-name>") \
18929 _(unset, "usage: unset <variable-name>")
18932 static void vl_api_##n##_t_handler_uni \
18933 (vl_api_##n##_t * mp) \
18935 vat_main_t * vam = &vat_main; \
18936 if (vam->json_output) { \
18937 vl_api_##n##_t_handler_json(mp); \
18939 vl_api_##n##_t_handler(mp); \
18942 foreach_vpe_api_reply_msg;
18943 #if VPP_API_TEST_BUILTIN == 0
18944 foreach_standalone_reply_msg;
18949 vat_api_hookup (vat_main_t * vam)
18952 vl_msg_api_set_handlers(VL_API_##N, #n, \
18953 vl_api_##n##_t_handler_uni, \
18955 vl_api_##n##_t_endian, \
18956 vl_api_##n##_t_print, \
18957 sizeof(vl_api_##n##_t), 1);
18958 foreach_vpe_api_reply_msg;
18959 #if VPP_API_TEST_BUILTIN == 0
18960 foreach_standalone_reply_msg;
18964 #if (VPP_API_TEST_BUILTIN==0)
18965 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
18967 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
18969 vam->function_by_name = hash_create_string (0, sizeof (uword));
18971 vam->help_by_name = hash_create_string (0, sizeof (uword));
18974 /* API messages we can send */
18975 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18976 foreach_vpe_api_msg;
18980 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18981 foreach_vpe_api_msg;
18984 /* CLI functions */
18985 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
18986 foreach_cli_function;
18990 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18991 foreach_cli_function;
18995 #if VPP_API_TEST_BUILTIN
18996 static clib_error_t *
18997 vat_api_hookup_shim (vlib_main_t * vm)
18999 vat_api_hookup (&vat_main);
19003 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
19007 * fd.io coding-style-patch-verification: ON
19010 * eval: (c-set-style "gnu")