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 = uword_to_pointer (mp->reply_in_shmem, u8 *);
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 = uword_to_pointer (mp->reply_in_shmem, u8 *);
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 = uword_to_pointer (mp->reply_in_shmem, u8 *);
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 = uword_to_pointer (mp->reply_in_shmem, u8 *);
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 _(l2fib_flush_int_reply) \
4155 _(l2fib_flush_bd_reply) \
4156 _(ip_add_del_route_reply) \
4157 _(ip_mroute_add_del_reply) \
4158 _(mpls_route_add_del_reply) \
4159 _(mpls_ip_bind_unbind_reply) \
4160 _(proxy_arp_add_del_reply) \
4161 _(proxy_arp_intfc_enable_disable_reply) \
4162 _(sw_interface_set_unnumbered_reply) \
4163 _(ip_neighbor_add_del_reply) \
4164 _(reset_vrf_reply) \
4165 _(oam_add_del_reply) \
4166 _(reset_fib_reply) \
4167 _(dhcp_proxy_config_reply) \
4168 _(dhcp_proxy_set_vss_reply) \
4169 _(dhcp_client_config_reply) \
4170 _(set_ip_flow_hash_reply) \
4171 _(sw_interface_ip6_enable_disable_reply) \
4172 _(sw_interface_ip6_set_link_local_address_reply) \
4173 _(ip6nd_proxy_add_del_reply) \
4174 _(sw_interface_ip6nd_ra_prefix_reply) \
4175 _(sw_interface_ip6nd_ra_config_reply) \
4176 _(set_arp_neighbor_limit_reply) \
4177 _(l2_patch_add_del_reply) \
4178 _(sr_policy_add_reply) \
4179 _(sr_policy_mod_reply) \
4180 _(sr_policy_del_reply) \
4181 _(sr_localsid_add_del_reply) \
4182 _(sr_steering_add_del_reply) \
4183 _(classify_add_del_session_reply) \
4184 _(classify_set_interface_ip_table_reply) \
4185 _(classify_set_interface_l2_tables_reply) \
4186 _(l2tpv3_set_tunnel_cookies_reply) \
4187 _(l2tpv3_interface_enable_disable_reply) \
4188 _(l2tpv3_set_lookup_key_reply) \
4189 _(l2_fib_clear_table_reply) \
4190 _(l2_interface_efp_filter_reply) \
4191 _(l2_interface_vlan_tag_rewrite_reply) \
4192 _(modify_vhost_user_if_reply) \
4193 _(delete_vhost_user_if_reply) \
4194 _(want_ip4_arp_events_reply) \
4195 _(want_ip6_nd_events_reply) \
4196 _(input_acl_set_interface_reply) \
4197 _(ipsec_spd_add_del_reply) \
4198 _(ipsec_interface_add_del_spd_reply) \
4199 _(ipsec_spd_add_del_entry_reply) \
4200 _(ipsec_sad_add_del_entry_reply) \
4201 _(ipsec_sa_set_key_reply) \
4202 _(ipsec_tunnel_if_add_del_reply) \
4203 _(ikev2_profile_add_del_reply) \
4204 _(ikev2_profile_set_auth_reply) \
4205 _(ikev2_profile_set_id_reply) \
4206 _(ikev2_profile_set_ts_reply) \
4207 _(ikev2_set_local_key_reply) \
4208 _(ikev2_set_responder_reply) \
4209 _(ikev2_set_ike_transforms_reply) \
4210 _(ikev2_set_esp_transforms_reply) \
4211 _(ikev2_set_sa_lifetime_reply) \
4212 _(ikev2_initiate_sa_init_reply) \
4213 _(ikev2_initiate_del_ike_sa_reply) \
4214 _(ikev2_initiate_del_child_sa_reply) \
4215 _(ikev2_initiate_rekey_child_sa_reply) \
4216 _(delete_loopback_reply) \
4217 _(bd_ip_mac_add_del_reply) \
4218 _(map_del_domain_reply) \
4219 _(map_add_del_rule_reply) \
4220 _(want_interface_events_reply) \
4221 _(want_stats_reply) \
4222 _(cop_interface_enable_disable_reply) \
4223 _(cop_whitelist_enable_disable_reply) \
4224 _(sw_interface_clear_stats_reply) \
4225 _(ioam_enable_reply) \
4226 _(ioam_disable_reply) \
4227 _(one_add_del_locator_reply) \
4228 _(one_add_del_local_eid_reply) \
4229 _(one_add_del_remote_mapping_reply) \
4230 _(one_add_del_adjacency_reply) \
4231 _(one_add_del_map_resolver_reply) \
4232 _(one_add_del_map_server_reply) \
4233 _(one_enable_disable_reply) \
4234 _(one_rloc_probe_enable_disable_reply) \
4235 _(one_map_register_enable_disable_reply) \
4236 _(one_pitr_set_locator_set_reply) \
4237 _(one_map_request_mode_reply) \
4238 _(one_add_del_map_request_itr_rlocs_reply) \
4239 _(one_eid_table_add_del_map_reply) \
4240 _(one_use_petr_reply) \
4241 _(one_stats_enable_disable_reply) \
4242 _(one_stats_flush_reply) \
4243 _(gpe_add_del_fwd_entry_reply) \
4244 _(gpe_enable_disable_reply) \
4245 _(gpe_set_encap_mode_reply) \
4246 _(gpe_add_del_iface_reply) \
4247 _(vxlan_gpe_add_del_tunnel_reply) \
4248 _(af_packet_delete_reply) \
4249 _(policer_classify_set_interface_reply) \
4250 _(netmap_create_reply) \
4251 _(netmap_delete_reply) \
4252 _(set_ipfix_exporter_reply) \
4253 _(set_ipfix_classify_stream_reply) \
4254 _(ipfix_classify_table_add_del_reply) \
4255 _(flow_classify_set_interface_reply) \
4256 _(sw_interface_span_enable_disable_reply) \
4257 _(pg_capture_reply) \
4258 _(pg_enable_disable_reply) \
4259 _(ip_source_and_port_range_check_add_del_reply) \
4260 _(ip_source_and_port_range_check_interface_add_del_reply)\
4261 _(delete_subif_reply) \
4262 _(l2_interface_pbb_tag_rewrite_reply) \
4264 _(feature_enable_disable_reply) \
4265 _(sw_interface_tag_add_del_reply) \
4266 _(sw_interface_set_mtu_reply)
4269 static void vl_api_##n##_t_handler \
4270 (vl_api_##n##_t * mp) \
4272 vat_main_t * vam = &vat_main; \
4273 i32 retval = ntohl(mp->retval); \
4274 if (vam->async_mode) { \
4275 vam->async_errors += (retval < 0); \
4277 vam->retval = retval; \
4278 vam->result_ready = 1; \
4281 foreach_standard_reply_retval_handler;
4285 static void vl_api_##n##_t_handler_json \
4286 (vl_api_##n##_t * mp) \
4288 vat_main_t * vam = &vat_main; \
4289 vat_json_node_t node; \
4290 vat_json_init_object(&node); \
4291 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4292 vat_json_print(vam->ofp, &node); \
4293 vam->retval = ntohl(mp->retval); \
4294 vam->result_ready = 1; \
4296 foreach_standard_reply_retval_handler;
4300 * Table of message reply handlers, must include boilerplate handlers
4304 #define foreach_vpe_api_reply_msg \
4305 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4306 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4307 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4308 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4309 _(CONTROL_PING_REPLY, control_ping_reply) \
4310 _(CLI_REPLY, cli_reply) \
4311 _(CLI_INBAND_REPLY, cli_inband_reply) \
4312 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4313 sw_interface_add_del_address_reply) \
4314 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4315 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4316 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4317 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4318 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4319 sw_interface_set_l2_xconnect_reply) \
4320 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4321 sw_interface_set_l2_bridge_reply) \
4322 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4323 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4324 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
4325 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
4326 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4327 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
4328 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
4329 _(L2_FLAGS_REPLY, l2_flags_reply) \
4330 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4331 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4332 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4333 _(TAP_DELETE_REPLY, tap_delete_reply) \
4334 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4335 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4336 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4337 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4338 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4339 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4340 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4341 proxy_arp_intfc_enable_disable_reply) \
4342 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4343 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4344 sw_interface_set_unnumbered_reply) \
4345 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4346 _(RESET_VRF_REPLY, reset_vrf_reply) \
4347 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4348 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4349 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4350 _(RESET_FIB_REPLY, reset_fib_reply) \
4351 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4352 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4353 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4354 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4355 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4356 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4357 sw_interface_ip6_enable_disable_reply) \
4358 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4359 sw_interface_ip6_set_link_local_address_reply) \
4360 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
4361 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
4362 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4363 sw_interface_ip6nd_ra_prefix_reply) \
4364 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4365 sw_interface_ip6nd_ra_config_reply) \
4366 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4367 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4368 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4369 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4370 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4371 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4372 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4373 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4374 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4375 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4376 classify_set_interface_ip_table_reply) \
4377 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4378 classify_set_interface_l2_tables_reply) \
4379 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4380 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4381 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4382 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4383 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4384 l2tpv3_interface_enable_disable_reply) \
4385 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4386 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4387 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4388 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4389 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4390 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4391 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4392 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4393 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4394 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4395 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4396 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4397 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4398 _(SHOW_VERSION_REPLY, show_version_reply) \
4399 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
4400 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4401 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4402 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4403 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4404 _(IP4_ARP_EVENT, ip4_arp_event) \
4405 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4406 _(IP6_ND_EVENT, ip6_nd_event) \
4407 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4408 _(IP_ADDRESS_DETAILS, ip_address_details) \
4409 _(IP_DETAILS, ip_details) \
4410 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4411 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4412 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4413 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4414 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4415 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
4416 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4417 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4418 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4419 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4420 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4421 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4422 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4423 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4424 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4425 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4426 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4427 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4428 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4429 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4430 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4431 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4432 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4433 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4434 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4435 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4436 _(MAP_RULE_DETAILS, map_rule_details) \
4437 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4438 _(WANT_STATS_REPLY, want_stats_reply) \
4439 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4440 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4441 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4442 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4443 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4444 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4445 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4446 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4447 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4448 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4449 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4450 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4451 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4452 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4453 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4454 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4455 one_map_register_enable_disable_reply) \
4456 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4457 one_rloc_probe_enable_disable_reply) \
4458 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4459 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
4460 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4461 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4462 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4463 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4464 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4465 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4466 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4467 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4468 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4469 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4470 _(ONE_STATS_DETAILS, one_stats_details) \
4471 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
4472 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
4473 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
4474 show_one_stats_enable_disable_reply) \
4475 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4476 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4477 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4478 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4479 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4480 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4481 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4482 gpe_fwd_entry_path_details) \
4483 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4484 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4485 one_add_del_map_request_itr_rlocs_reply) \
4486 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4487 one_get_map_request_itr_rlocs_reply) \
4488 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4489 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
4490 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4491 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4492 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4493 show_one_map_register_state_reply) \
4494 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4495 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4496 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4497 _(POLICER_DETAILS, policer_details) \
4498 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4499 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4500 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4501 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4502 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4503 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4504 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4505 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4506 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4507 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4508 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4509 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4510 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4511 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4512 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4513 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4514 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4515 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4516 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4517 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4518 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4519 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4520 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4521 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4522 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4523 ip_source_and_port_range_check_add_del_reply) \
4524 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4525 ip_source_and_port_range_check_interface_add_del_reply) \
4526 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4527 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4528 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4529 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4530 _(PUNT_REPLY, punt_reply) \
4531 _(IP_FIB_DETAILS, ip_fib_details) \
4532 _(IP6_FIB_DETAILS, ip6_fib_details) \
4533 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4534 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4535 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4536 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4537 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4538 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4540 #define foreach_standalone_reply_msg \
4541 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4542 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
4543 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4544 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4545 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4546 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
4555 #define STR_VTR_OP_CASE(op) \
4556 case L2_VTR_ ## op: \
4560 str_vtr_op (u32 vtr_op)
4564 STR_VTR_OP_CASE (DISABLED);
4565 STR_VTR_OP_CASE (PUSH_1);
4566 STR_VTR_OP_CASE (PUSH_2);
4567 STR_VTR_OP_CASE (POP_1);
4568 STR_VTR_OP_CASE (POP_2);
4569 STR_VTR_OP_CASE (TRANSLATE_1_1);
4570 STR_VTR_OP_CASE (TRANSLATE_1_2);
4571 STR_VTR_OP_CASE (TRANSLATE_2_1);
4572 STR_VTR_OP_CASE (TRANSLATE_2_2);
4579 dump_sub_interface_table (vat_main_t * vam)
4581 const sw_interface_subif_t *sub = NULL;
4583 if (vam->json_output)
4586 ("JSON output supported only for VPE API calls and dump_stats_table");
4591 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4592 "Interface", "sw_if_index",
4593 "sub id", "dot1ad", "tags", "outer id",
4594 "inner id", "exact", "default", "outer any", "inner any");
4596 vec_foreach (sub, vam->sw_if_subif_table)
4599 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4600 sub->interface_name,
4602 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4603 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4604 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4605 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4606 if (sub->vtr_op != L2_VTR_DISABLED)
4609 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4610 "tag1: %d tag2: %d ]",
4611 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4612 sub->vtr_tag1, sub->vtr_tag2);
4620 name_sort_cmp (void *a1, void *a2)
4622 name_sort_t *n1 = a1;
4623 name_sort_t *n2 = a2;
4625 return strcmp ((char *) n1->name, (char *) n2->name);
4629 dump_interface_table (vat_main_t * vam)
4632 name_sort_t *nses = 0, *ns;
4634 if (vam->json_output)
4637 ("JSON output supported only for VPE API calls and dump_stats_table");
4642 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4644 vec_add2 (nses, ns, 1);
4645 ns->name = (u8 *)(p->key);
4646 ns->value = (u32) p->value[0];
4650 vec_sort_with_function (nses, name_sort_cmp);
4652 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4653 vec_foreach (ns, nses)
4655 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4662 dump_ip_table (vat_main_t * vam, int is_ipv6)
4664 const ip_details_t *det = NULL;
4665 const ip_address_details_t *address = NULL;
4668 print (vam->ofp, "%-12s", "sw_if_index");
4670 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4677 print (vam->ofp, "%-12d", i);
4678 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4683 vec_foreach (address, det->addr)
4687 is_ipv6 ? format_ip6_address : format_ip4_address,
4688 address->ip, address->prefix_length);
4696 dump_ipv4_table (vat_main_t * vam)
4698 if (vam->json_output)
4701 ("JSON output supported only for VPE API calls and dump_stats_table");
4705 return dump_ip_table (vam, 0);
4709 dump_ipv6_table (vat_main_t * vam)
4711 if (vam->json_output)
4714 ("JSON output supported only for VPE API calls and dump_stats_table");
4718 return dump_ip_table (vam, 1);
4722 counter_type_to_str (u8 counter_type, u8 is_combined)
4726 switch (counter_type)
4728 case VNET_INTERFACE_COUNTER_DROP:
4730 case VNET_INTERFACE_COUNTER_PUNT:
4732 case VNET_INTERFACE_COUNTER_IP4:
4734 case VNET_INTERFACE_COUNTER_IP6:
4736 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4738 case VNET_INTERFACE_COUNTER_RX_MISS:
4740 case VNET_INTERFACE_COUNTER_RX_ERROR:
4742 case VNET_INTERFACE_COUNTER_TX_ERROR:
4745 return "INVALID-COUNTER-TYPE";
4750 switch (counter_type)
4752 case VNET_INTERFACE_COUNTER_RX:
4754 case VNET_INTERFACE_COUNTER_TX:
4757 return "INVALID-COUNTER-TYPE";
4763 dump_stats_table (vat_main_t * vam)
4765 vat_json_node_t node;
4766 vat_json_node_t *msg_array;
4767 vat_json_node_t *msg;
4768 vat_json_node_t *counter_array;
4769 vat_json_node_t *counter;
4770 interface_counter_t c;
4772 ip4_fib_counter_t *c4;
4773 ip6_fib_counter_t *c6;
4774 ip4_nbr_counter_t *n4;
4775 ip6_nbr_counter_t *n6;
4778 if (!vam->json_output)
4780 clib_warning ("dump_stats_table supported only in JSON format");
4784 vat_json_init_object (&node);
4786 /* interface counters */
4787 msg_array = vat_json_object_add (&node, "interface_counters");
4788 vat_json_init_array (msg_array);
4789 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4791 msg = vat_json_array_add (msg_array);
4792 vat_json_init_object (msg);
4793 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4794 (u8 *) counter_type_to_str (i, 0));
4795 vat_json_object_add_int (msg, "is_combined", 0);
4796 counter_array = vat_json_object_add (msg, "data");
4797 vat_json_init_array (counter_array);
4798 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4800 packets = vam->simple_interface_counters[i][j];
4801 vat_json_array_add_uint (counter_array, packets);
4804 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4806 msg = vat_json_array_add (msg_array);
4807 vat_json_init_object (msg);
4808 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4809 (u8 *) counter_type_to_str (i, 1));
4810 vat_json_object_add_int (msg, "is_combined", 1);
4811 counter_array = vat_json_object_add (msg, "data");
4812 vat_json_init_array (counter_array);
4813 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4815 c = vam->combined_interface_counters[i][j];
4816 counter = vat_json_array_add (counter_array);
4817 vat_json_init_object (counter);
4818 vat_json_object_add_uint (counter, "packets", c.packets);
4819 vat_json_object_add_uint (counter, "bytes", c.bytes);
4823 /* ip4 fib counters */
4824 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4825 vat_json_init_array (msg_array);
4826 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4828 msg = vat_json_array_add (msg_array);
4829 vat_json_init_object (msg);
4830 vat_json_object_add_uint (msg, "vrf_id",
4831 vam->ip4_fib_counters_vrf_id_by_index[i]);
4832 counter_array = vat_json_object_add (msg, "c");
4833 vat_json_init_array (counter_array);
4834 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4836 counter = vat_json_array_add (counter_array);
4837 vat_json_init_object (counter);
4838 c4 = &vam->ip4_fib_counters[i][j];
4839 vat_json_object_add_ip4 (counter, "address", c4->address);
4840 vat_json_object_add_uint (counter, "address_length",
4841 c4->address_length);
4842 vat_json_object_add_uint (counter, "packets", c4->packets);
4843 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4847 /* ip6 fib counters */
4848 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4849 vat_json_init_array (msg_array);
4850 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4852 msg = vat_json_array_add (msg_array);
4853 vat_json_init_object (msg);
4854 vat_json_object_add_uint (msg, "vrf_id",
4855 vam->ip6_fib_counters_vrf_id_by_index[i]);
4856 counter_array = vat_json_object_add (msg, "c");
4857 vat_json_init_array (counter_array);
4858 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4860 counter = vat_json_array_add (counter_array);
4861 vat_json_init_object (counter);
4862 c6 = &vam->ip6_fib_counters[i][j];
4863 vat_json_object_add_ip6 (counter, "address", c6->address);
4864 vat_json_object_add_uint (counter, "address_length",
4865 c6->address_length);
4866 vat_json_object_add_uint (counter, "packets", c6->packets);
4867 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4871 /* ip4 nbr counters */
4872 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4873 vat_json_init_array (msg_array);
4874 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4876 msg = vat_json_array_add (msg_array);
4877 vat_json_init_object (msg);
4878 vat_json_object_add_uint (msg, "sw_if_index", i);
4879 counter_array = vat_json_object_add (msg, "c");
4880 vat_json_init_array (counter_array);
4881 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4883 counter = vat_json_array_add (counter_array);
4884 vat_json_init_object (counter);
4885 n4 = &vam->ip4_nbr_counters[i][j];
4886 vat_json_object_add_ip4 (counter, "address", n4->address);
4887 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4888 vat_json_object_add_uint (counter, "packets", n4->packets);
4889 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4893 /* ip6 nbr counters */
4894 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4895 vat_json_init_array (msg_array);
4896 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4898 msg = vat_json_array_add (msg_array);
4899 vat_json_init_object (msg);
4900 vat_json_object_add_uint (msg, "sw_if_index", i);
4901 counter_array = vat_json_object_add (msg, "c");
4902 vat_json_init_array (counter_array);
4903 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4905 counter = vat_json_array_add (counter_array);
4906 vat_json_init_object (counter);
4907 n6 = &vam->ip6_nbr_counters[i][j];
4908 vat_json_object_add_ip6 (counter, "address", n6->address);
4909 vat_json_object_add_uint (counter, "packets", n6->packets);
4910 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4914 vat_json_print (vam->ofp, &node);
4915 vat_json_free (&node);
4921 exec (vat_main_t * vam)
4923 api_main_t *am = &api_main;
4924 vl_api_cli_request_t *mp;
4928 unformat_input_t *i = vam->input;
4930 if (vec_len (i->buffer) == 0)
4933 if (vam->exec_mode == 0 && unformat (i, "mode"))
4938 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4945 M (CLI_REQUEST, mp);
4948 * Copy cmd into shared memory.
4949 * In order for the CLI command to work, it
4950 * must be a vector ending in \n, not a C-string ending
4953 pthread_mutex_lock (&am->vlib_rp->mutex);
4954 oldheap = svm_push_data_heap (am->vlib_rp);
4956 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4957 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4959 svm_pop_heap (oldheap);
4960 pthread_mutex_unlock (&am->vlib_rp->mutex);
4962 mp->cmd_in_shmem = pointer_to_uword (cmd);
4964 timeout = vat_time_now (vam) + 10.0;
4966 while (vat_time_now (vam) < timeout)
4968 if (vam->result_ready == 1)
4971 if (vam->shmem_result != NULL)
4972 print (vam->ofp, "%s", vam->shmem_result);
4973 pthread_mutex_lock (&am->vlib_rp->mutex);
4974 oldheap = svm_push_data_heap (am->vlib_rp);
4976 free_me = (u8 *) vam->shmem_result;
4979 svm_pop_heap (oldheap);
4980 pthread_mutex_unlock (&am->vlib_rp->mutex);
4988 * Future replacement of exec() that passes CLI buffers directly in
4989 * the API messages instead of an additional shared memory area.
4992 exec_inband (vat_main_t * vam)
4994 vl_api_cli_inband_t *mp;
4995 unformat_input_t *i = vam->input;
4998 if (vec_len (i->buffer) == 0)
5001 if (vam->exec_mode == 0 && unformat (i, "mode"))
5006 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5013 * In order for the CLI command to work, it
5014 * must be a vector ending in \n, not a C-string ending
5017 u32 len = vec_len (vam->input->buffer);
5018 M2 (CLI_INBAND, mp, len);
5019 clib_memcpy (mp->cmd, vam->input->buffer, len);
5020 mp->length = htonl (len);
5023 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
5028 api_create_loopback (vat_main_t * vam)
5030 unformat_input_t *i = vam->input;
5031 vl_api_create_loopback_t *mp;
5032 vl_api_create_loopback_instance_t *mp_lbi;
5035 u8 is_specified = 0;
5036 u32 user_instance = 0;
5039 memset (mac_address, 0, sizeof (mac_address));
5041 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5043 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5045 if (unformat (i, "instance %d", &user_instance))
5053 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5054 mp_lbi->is_specified = is_specified;
5056 mp_lbi->user_instance = htonl (user_instance);
5058 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5063 /* Construct the API message */
5064 M (CREATE_LOOPBACK, mp);
5066 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5075 api_delete_loopback (vat_main_t * vam)
5077 unformat_input_t *i = vam->input;
5078 vl_api_delete_loopback_t *mp;
5079 u32 sw_if_index = ~0;
5082 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5084 if (unformat (i, "sw_if_index %d", &sw_if_index))
5090 if (sw_if_index == ~0)
5092 errmsg ("missing sw_if_index");
5096 /* Construct the API message */
5097 M (DELETE_LOOPBACK, mp);
5098 mp->sw_if_index = ntohl (sw_if_index);
5106 api_want_stats (vat_main_t * vam)
5108 unformat_input_t *i = vam->input;
5109 vl_api_want_stats_t *mp;
5113 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5115 if (unformat (i, "enable"))
5117 else if (unformat (i, "disable"))
5125 errmsg ("missing enable|disable");
5130 mp->enable_disable = enable;
5138 api_want_interface_events (vat_main_t * vam)
5140 unformat_input_t *i = vam->input;
5141 vl_api_want_interface_events_t *mp;
5145 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5147 if (unformat (i, "enable"))
5149 else if (unformat (i, "disable"))
5157 errmsg ("missing enable|disable");
5161 M (WANT_INTERFACE_EVENTS, mp);
5162 mp->enable_disable = enable;
5164 vam->interface_event_display = enable;
5172 /* Note: non-static, called once to set up the initial intfc table */
5174 api_sw_interface_dump (vat_main_t * vam)
5176 vl_api_sw_interface_dump_t *mp;
5177 vl_api_control_ping_t *mp_ping;
5179 name_sort_t *nses = 0, *ns;
5180 sw_interface_subif_t *sub = NULL;
5183 /* Toss the old name table */
5185 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5187 vec_add2 (nses, ns, 1);
5188 ns->name = (u8 *)(p->key);
5189 ns->value = (u32) p->value[0];
5193 hash_free (vam->sw_if_index_by_interface_name);
5195 vec_foreach (ns, nses) vec_free (ns->name);
5199 vec_foreach (sub, vam->sw_if_subif_table)
5201 vec_free (sub->interface_name);
5203 vec_free (vam->sw_if_subif_table);
5205 /* recreate the interface name hash table */
5206 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5208 /* Get list of ethernets */
5209 M (SW_INTERFACE_DUMP, mp);
5210 mp->name_filter_valid = 1;
5211 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
5214 /* and local / loopback interfaces */
5215 M (SW_INTERFACE_DUMP, mp);
5216 mp->name_filter_valid = 1;
5217 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
5220 /* and packet-generator interfaces */
5221 M (SW_INTERFACE_DUMP, mp);
5222 mp->name_filter_valid = 1;
5223 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
5226 /* and vxlan-gpe tunnel interfaces */
5227 M (SW_INTERFACE_DUMP, mp);
5228 mp->name_filter_valid = 1;
5229 strncpy ((char *) mp->name_filter, "vxlan_gpe",
5230 sizeof (mp->name_filter) - 1);
5233 /* and vxlan tunnel interfaces */
5234 M (SW_INTERFACE_DUMP, mp);
5235 mp->name_filter_valid = 1;
5236 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
5239 /* and host (af_packet) interfaces */
5240 M (SW_INTERFACE_DUMP, mp);
5241 mp->name_filter_valid = 1;
5242 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
5245 /* and l2tpv3 tunnel interfaces */
5246 M (SW_INTERFACE_DUMP, mp);
5247 mp->name_filter_valid = 1;
5248 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
5249 sizeof (mp->name_filter) - 1);
5252 /* and GRE tunnel interfaces */
5253 M (SW_INTERFACE_DUMP, mp);
5254 mp->name_filter_valid = 1;
5255 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
5258 /* and LISP-GPE interfaces */
5259 M (SW_INTERFACE_DUMP, mp);
5260 mp->name_filter_valid = 1;
5261 strncpy ((char *) mp->name_filter, "lisp_gpe",
5262 sizeof (mp->name_filter) - 1);
5265 /* and IPSEC tunnel interfaces */
5266 M (SW_INTERFACE_DUMP, mp);
5267 mp->name_filter_valid = 1;
5268 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
5271 /* Use a control ping for synchronization */
5272 M (CONTROL_PING, mp_ping);
5280 api_sw_interface_set_flags (vat_main_t * vam)
5282 unformat_input_t *i = vam->input;
5283 vl_api_sw_interface_set_flags_t *mp;
5285 u8 sw_if_index_set = 0;
5286 u8 admin_up = 0, link_up = 0;
5289 /* Parse args required to build the message */
5290 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5292 if (unformat (i, "admin-up"))
5294 else if (unformat (i, "admin-down"))
5296 else if (unformat (i, "link-up"))
5298 else if (unformat (i, "link-down"))
5301 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5302 sw_if_index_set = 1;
5303 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5304 sw_if_index_set = 1;
5309 if (sw_if_index_set == 0)
5311 errmsg ("missing interface name or sw_if_index");
5315 /* Construct the API message */
5316 M (SW_INTERFACE_SET_FLAGS, mp);
5317 mp->sw_if_index = ntohl (sw_if_index);
5318 mp->admin_up_down = admin_up;
5319 mp->link_up_down = link_up;
5324 /* Wait for a reply, return the good/bad news... */
5330 api_sw_interface_clear_stats (vat_main_t * vam)
5332 unformat_input_t *i = vam->input;
5333 vl_api_sw_interface_clear_stats_t *mp;
5335 u8 sw_if_index_set = 0;
5338 /* Parse args required to build the message */
5339 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5341 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5342 sw_if_index_set = 1;
5343 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5344 sw_if_index_set = 1;
5349 /* Construct the API message */
5350 M (SW_INTERFACE_CLEAR_STATS, mp);
5352 if (sw_if_index_set == 1)
5353 mp->sw_if_index = ntohl (sw_if_index);
5355 mp->sw_if_index = ~0;
5360 /* Wait for a reply, return the good/bad news... */
5366 api_sw_interface_add_del_address (vat_main_t * vam)
5368 unformat_input_t *i = vam->input;
5369 vl_api_sw_interface_add_del_address_t *mp;
5371 u8 sw_if_index_set = 0;
5372 u8 is_add = 1, del_all = 0;
5373 u32 address_length = 0;
5374 u8 v4_address_set = 0;
5375 u8 v6_address_set = 0;
5376 ip4_address_t v4address;
5377 ip6_address_t v6address;
5380 /* Parse args required to build the message */
5381 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5383 if (unformat (i, "del-all"))
5385 else if (unformat (i, "del"))
5388 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5389 sw_if_index_set = 1;
5390 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5391 sw_if_index_set = 1;
5392 else if (unformat (i, "%U/%d",
5393 unformat_ip4_address, &v4address, &address_length))
5395 else if (unformat (i, "%U/%d",
5396 unformat_ip6_address, &v6address, &address_length))
5402 if (sw_if_index_set == 0)
5404 errmsg ("missing interface name or sw_if_index");
5407 if (v4_address_set && v6_address_set)
5409 errmsg ("both v4 and v6 addresses set");
5412 if (!v4_address_set && !v6_address_set && !del_all)
5414 errmsg ("no addresses set");
5418 /* Construct the API message */
5419 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5421 mp->sw_if_index = ntohl (sw_if_index);
5422 mp->is_add = is_add;
5423 mp->del_all = del_all;
5427 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5431 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5433 mp->address_length = address_length;
5438 /* Wait for a reply, return good/bad news */
5444 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5446 unformat_input_t *i = vam->input;
5447 vl_api_sw_interface_set_mpls_enable_t *mp;
5449 u8 sw_if_index_set = 0;
5453 /* Parse args required to build the message */
5454 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5456 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5457 sw_if_index_set = 1;
5458 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5459 sw_if_index_set = 1;
5460 else if (unformat (i, "disable"))
5462 else if (unformat (i, "dis"))
5468 if (sw_if_index_set == 0)
5470 errmsg ("missing interface name or sw_if_index");
5474 /* Construct the API message */
5475 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5477 mp->sw_if_index = ntohl (sw_if_index);
5478 mp->enable = enable;
5483 /* Wait for a reply... */
5489 api_sw_interface_set_table (vat_main_t * vam)
5491 unformat_input_t *i = vam->input;
5492 vl_api_sw_interface_set_table_t *mp;
5493 u32 sw_if_index, vrf_id = 0;
5494 u8 sw_if_index_set = 0;
5498 /* Parse args required to build the message */
5499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5501 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5502 sw_if_index_set = 1;
5503 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5504 sw_if_index_set = 1;
5505 else if (unformat (i, "vrf %d", &vrf_id))
5507 else if (unformat (i, "ipv6"))
5513 if (sw_if_index_set == 0)
5515 errmsg ("missing interface name or sw_if_index");
5519 /* Construct the API message */
5520 M (SW_INTERFACE_SET_TABLE, mp);
5522 mp->sw_if_index = ntohl (sw_if_index);
5523 mp->is_ipv6 = is_ipv6;
5524 mp->vrf_id = ntohl (vrf_id);
5529 /* Wait for a reply... */
5534 static void vl_api_sw_interface_get_table_reply_t_handler
5535 (vl_api_sw_interface_get_table_reply_t * mp)
5537 vat_main_t *vam = &vat_main;
5539 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5541 vam->retval = ntohl (mp->retval);
5542 vam->result_ready = 1;
5546 static void vl_api_sw_interface_get_table_reply_t_handler_json
5547 (vl_api_sw_interface_get_table_reply_t * mp)
5549 vat_main_t *vam = &vat_main;
5550 vat_json_node_t node;
5552 vat_json_init_object (&node);
5553 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5554 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5556 vat_json_print (vam->ofp, &node);
5557 vat_json_free (&node);
5559 vam->retval = ntohl (mp->retval);
5560 vam->result_ready = 1;
5564 api_sw_interface_get_table (vat_main_t * vam)
5566 unformat_input_t *i = vam->input;
5567 vl_api_sw_interface_get_table_t *mp;
5569 u8 sw_if_index_set = 0;
5573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5575 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5576 sw_if_index_set = 1;
5577 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5578 sw_if_index_set = 1;
5579 else if (unformat (i, "ipv6"))
5585 if (sw_if_index_set == 0)
5587 errmsg ("missing interface name or sw_if_index");
5591 M (SW_INTERFACE_GET_TABLE, mp);
5592 mp->sw_if_index = htonl (sw_if_index);
5593 mp->is_ipv6 = is_ipv6;
5601 api_sw_interface_set_vpath (vat_main_t * vam)
5603 unformat_input_t *i = vam->input;
5604 vl_api_sw_interface_set_vpath_t *mp;
5605 u32 sw_if_index = 0;
5606 u8 sw_if_index_set = 0;
5610 /* Parse args required to build the message */
5611 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5613 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5614 sw_if_index_set = 1;
5615 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5616 sw_if_index_set = 1;
5617 else if (unformat (i, "enable"))
5619 else if (unformat (i, "disable"))
5625 if (sw_if_index_set == 0)
5627 errmsg ("missing interface name or sw_if_index");
5631 /* Construct the API message */
5632 M (SW_INTERFACE_SET_VPATH, mp);
5634 mp->sw_if_index = ntohl (sw_if_index);
5635 mp->enable = is_enable;
5640 /* Wait for a reply... */
5646 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5648 unformat_input_t *i = vam->input;
5649 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5650 u32 sw_if_index = 0;
5651 u8 sw_if_index_set = 0;
5656 /* Parse args required to build the message */
5657 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5659 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5660 sw_if_index_set = 1;
5661 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5662 sw_if_index_set = 1;
5663 else if (unformat (i, "enable"))
5665 else if (unformat (i, "disable"))
5667 else if (unformat (i, "ip4"))
5669 else if (unformat (i, "ip6"))
5675 if (sw_if_index_set == 0)
5677 errmsg ("missing interface name or sw_if_index");
5681 /* Construct the API message */
5682 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5684 mp->sw_if_index = ntohl (sw_if_index);
5685 mp->enable = is_enable;
5686 mp->is_ipv6 = is_ipv6;
5691 /* Wait for a reply... */
5697 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5699 unformat_input_t *i = vam->input;
5700 vl_api_sw_interface_set_l2_xconnect_t *mp;
5702 u8 rx_sw_if_index_set = 0;
5704 u8 tx_sw_if_index_set = 0;
5708 /* Parse args required to build the message */
5709 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5711 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5712 rx_sw_if_index_set = 1;
5713 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5714 tx_sw_if_index_set = 1;
5715 else if (unformat (i, "rx"))
5717 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5719 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5721 rx_sw_if_index_set = 1;
5726 else if (unformat (i, "tx"))
5728 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5730 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5732 tx_sw_if_index_set = 1;
5737 else if (unformat (i, "enable"))
5739 else if (unformat (i, "disable"))
5745 if (rx_sw_if_index_set == 0)
5747 errmsg ("missing rx interface name or rx_sw_if_index");
5751 if (enable && (tx_sw_if_index_set == 0))
5753 errmsg ("missing tx interface name or tx_sw_if_index");
5757 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5759 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5760 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5761 mp->enable = enable;
5769 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5771 unformat_input_t *i = vam->input;
5772 vl_api_sw_interface_set_l2_bridge_t *mp;
5774 u8 rx_sw_if_index_set = 0;
5782 /* Parse args required to build the message */
5783 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5785 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5786 rx_sw_if_index_set = 1;
5787 else if (unformat (i, "bd_id %d", &bd_id))
5791 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5792 rx_sw_if_index_set = 1;
5793 else if (unformat (i, "shg %d", &shg))
5795 else if (unformat (i, "bvi"))
5797 else if (unformat (i, "enable"))
5799 else if (unformat (i, "disable"))
5805 if (rx_sw_if_index_set == 0)
5807 errmsg ("missing rx interface name or sw_if_index");
5811 if (enable && (bd_id_set == 0))
5813 errmsg ("missing bridge domain");
5817 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
5819 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5820 mp->bd_id = ntohl (bd_id);
5823 mp->enable = enable;
5831 api_bridge_domain_dump (vat_main_t * vam)
5833 unformat_input_t *i = vam->input;
5834 vl_api_bridge_domain_dump_t *mp;
5835 vl_api_control_ping_t *mp_ping;
5839 /* Parse args required to build the message */
5840 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5842 if (unformat (i, "bd_id %d", &bd_id))
5848 M (BRIDGE_DOMAIN_DUMP, mp);
5849 mp->bd_id = ntohl (bd_id);
5852 /* Use a control ping for synchronization */
5853 M (CONTROL_PING, mp_ping);
5861 api_bridge_domain_add_del (vat_main_t * vam)
5863 unformat_input_t *i = vam->input;
5864 vl_api_bridge_domain_add_del_t *mp;
5867 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5871 /* Parse args required to build the message */
5872 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5874 if (unformat (i, "bd_id %d", &bd_id))
5876 else if (unformat (i, "flood %d", &flood))
5878 else if (unformat (i, "uu-flood %d", &uu_flood))
5880 else if (unformat (i, "forward %d", &forward))
5882 else if (unformat (i, "learn %d", &learn))
5884 else if (unformat (i, "arp-term %d", &arp_term))
5886 else if (unformat (i, "mac-age %d", &mac_age))
5888 else if (unformat (i, "del"))
5891 flood = uu_flood = forward = learn = 0;
5899 errmsg ("missing bridge domain");
5905 errmsg ("mac age must be less than 256 ");
5909 M (BRIDGE_DOMAIN_ADD_DEL, mp);
5911 mp->bd_id = ntohl (bd_id);
5913 mp->uu_flood = uu_flood;
5914 mp->forward = forward;
5916 mp->arp_term = arp_term;
5917 mp->is_add = is_add;
5918 mp->mac_age = (u8) mac_age;
5926 api_l2fib_flush_bd (vat_main_t * vam)
5928 unformat_input_t *i = vam->input;
5929 vl_api_l2fib_flush_bd_t *mp;
5933 /* Parse args required to build the message */
5934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5936 if (unformat (i, "bd_id %d", &bd_id));
5943 errmsg ("missing bridge domain");
5947 M (L2FIB_FLUSH_BD, mp);
5949 mp->bd_id = htonl (bd_id);
5957 api_l2fib_flush_int (vat_main_t * vam)
5959 unformat_input_t *i = vam->input;
5960 vl_api_l2fib_flush_int_t *mp;
5961 u32 sw_if_index = ~0;
5964 /* Parse args required to build the message */
5965 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5967 if (unformat (i, "sw_if_index %d", &sw_if_index));
5969 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
5974 if (sw_if_index == ~0)
5976 errmsg ("missing interface name or sw_if_index");
5980 M (L2FIB_FLUSH_INT, mp);
5982 mp->sw_if_index = ntohl (sw_if_index);
5990 api_l2fib_add_del (vat_main_t * vam)
5992 unformat_input_t *i = vam->input;
5993 vl_api_l2fib_add_del_t *mp;
5999 u32 sw_if_index = ~0;
6000 u8 sw_if_index_set = 0;
6009 /* Parse args required to build the message */
6010 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6012 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6014 else if (unformat (i, "bd_id %d", &bd_id))
6016 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6017 sw_if_index_set = 1;
6018 else if (unformat (i, "sw_if"))
6020 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6023 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6024 sw_if_index_set = 1;
6029 else if (unformat (i, "static"))
6031 else if (unformat (i, "filter"))
6036 else if (unformat (i, "bvi"))
6041 else if (unformat (i, "del"))
6043 else if (unformat (i, "count %d", &count))
6051 errmsg ("missing mac address");
6057 errmsg ("missing bridge domain");
6061 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6063 errmsg ("missing interface name or sw_if_index");
6069 /* Turn on async mode */
6070 vam->async_mode = 1;
6071 vam->async_errors = 0;
6072 before = vat_time_now (vam);
6075 for (j = 0; j < count; j++)
6077 M (L2FIB_ADD_DEL, mp);
6080 mp->bd_id = ntohl (bd_id);
6081 mp->is_add = is_add;
6085 mp->sw_if_index = ntohl (sw_if_index);
6086 mp->static_mac = static_mac;
6087 mp->filter_mac = filter_mac;
6088 mp->bvi_mac = bvi_mac;
6090 increment_mac_address (&mac);
6097 vl_api_control_ping_t *mp_ping;
6100 /* Shut off async mode */
6101 vam->async_mode = 0;
6103 M (CONTROL_PING, mp_ping);
6106 timeout = vat_time_now (vam) + 1.0;
6107 while (vat_time_now (vam) < timeout)
6108 if (vam->result_ready == 1)
6113 if (vam->retval == -99)
6116 if (vam->async_errors > 0)
6118 errmsg ("%d asynchronous errors", vam->async_errors);
6121 vam->async_errors = 0;
6122 after = vat_time_now (vam);
6124 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6125 count, after - before, count / (after - before));
6131 /* Wait for a reply... */
6135 /* Return the good/bad news */
6136 return (vam->retval);
6140 api_bridge_domain_set_mac_age (vat_main_t * vam)
6142 unformat_input_t *i = vam->input;
6143 vl_api_bridge_domain_set_mac_age_t *mp;
6148 /* Parse args required to build the message */
6149 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6151 if (unformat (i, "bd_id %d", &bd_id));
6152 else if (unformat (i, "mac-age %d", &mac_age));
6159 errmsg ("missing bridge domain");
6165 errmsg ("mac age must be less than 256 ");
6169 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6171 mp->bd_id = htonl (bd_id);
6172 mp->mac_age = (u8) mac_age;
6180 api_l2_flags (vat_main_t * vam)
6182 unformat_input_t *i = vam->input;
6183 vl_api_l2_flags_t *mp;
6185 u32 feature_bitmap = 0;
6186 u8 sw_if_index_set = 0;
6189 /* Parse args required to build the message */
6190 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6192 if (unformat (i, "sw_if_index %d", &sw_if_index))
6193 sw_if_index_set = 1;
6194 else if (unformat (i, "sw_if"))
6196 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6199 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6200 sw_if_index_set = 1;
6205 else if (unformat (i, "learn"))
6206 feature_bitmap |= L2INPUT_FEAT_LEARN;
6207 else if (unformat (i, "forward"))
6208 feature_bitmap |= L2INPUT_FEAT_FWD;
6209 else if (unformat (i, "flood"))
6210 feature_bitmap |= L2INPUT_FEAT_FLOOD;
6211 else if (unformat (i, "uu-flood"))
6212 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
6217 if (sw_if_index_set == 0)
6219 errmsg ("missing interface name or sw_if_index");
6225 mp->sw_if_index = ntohl (sw_if_index);
6226 mp->feature_bitmap = ntohl (feature_bitmap);
6234 api_bridge_flags (vat_main_t * vam)
6236 unformat_input_t *i = vam->input;
6237 vl_api_bridge_flags_t *mp;
6244 /* Parse args required to build the message */
6245 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6247 if (unformat (i, "bd_id %d", &bd_id))
6249 else if (unformat (i, "learn"))
6251 else if (unformat (i, "forward"))
6253 else if (unformat (i, "flood"))
6255 else if (unformat (i, "uu-flood"))
6256 flags |= L2_UU_FLOOD;
6257 else if (unformat (i, "arp-term"))
6258 flags |= L2_ARP_TERM;
6259 else if (unformat (i, "off"))
6261 else if (unformat (i, "disable"))
6269 errmsg ("missing bridge domain");
6273 M (BRIDGE_FLAGS, mp);
6275 mp->bd_id = ntohl (bd_id);
6276 mp->feature_bitmap = ntohl (flags);
6277 mp->is_set = is_set;
6285 api_bd_ip_mac_add_del (vat_main_t * vam)
6287 unformat_input_t *i = vam->input;
6288 vl_api_bd_ip_mac_add_del_t *mp;
6295 ip4_address_t v4addr;
6296 ip6_address_t v6addr;
6301 /* Parse args required to build the message */
6302 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6304 if (unformat (i, "bd_id %d", &bd_id))
6308 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6312 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6317 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6321 else if (unformat (i, "del"))
6329 errmsg ("missing bridge domain");
6332 else if (ip_set == 0)
6334 errmsg ("missing IP address");
6337 else if (mac_set == 0)
6339 errmsg ("missing MAC address");
6343 M (BD_IP_MAC_ADD_DEL, mp);
6345 mp->bd_id = ntohl (bd_id);
6346 mp->is_ipv6 = is_ipv6;
6347 mp->is_add = is_add;
6349 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6351 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6352 clib_memcpy (mp->mac_address, macaddr, 6);
6359 api_tap_connect (vat_main_t * vam)
6361 unformat_input_t *i = vam->input;
6362 vl_api_tap_connect_t *mp;
6368 ip4_address_t ip4_address;
6370 int ip4_address_set = 0;
6371 ip6_address_t ip6_address;
6373 int ip6_address_set = 0;
6376 memset (mac_address, 0, sizeof (mac_address));
6378 /* Parse args required to build the message */
6379 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6381 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6385 else if (unformat (i, "random-mac"))
6387 else if (unformat (i, "tapname %s", &tap_name))
6389 else if (unformat (i, "tag %s", &tag))
6391 else if (unformat (i, "address %U/%d",
6392 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6393 ip4_address_set = 1;
6394 else if (unformat (i, "address %U/%d",
6395 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6396 ip6_address_set = 1;
6403 errmsg ("missing tap name");
6406 if (vec_len (tap_name) > 63)
6408 errmsg ("tap name too long");
6411 vec_add1 (tap_name, 0);
6413 if (vec_len (tag) > 63)
6415 errmsg ("tag too long");
6419 /* Construct the API message */
6420 M (TAP_CONNECT, mp);
6422 mp->use_random_mac = random_mac;
6423 clib_memcpy (mp->mac_address, mac_address, 6);
6424 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6426 clib_memcpy (mp->tag, tag, vec_len (tag));
6428 if (ip4_address_set)
6430 mp->ip4_address_set = 1;
6431 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6432 mp->ip4_mask_width = ip4_mask_width;
6434 if (ip6_address_set)
6436 mp->ip6_address_set = 1;
6437 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6438 mp->ip6_mask_width = ip6_mask_width;
6441 vec_free (tap_name);
6447 /* Wait for a reply... */
6453 api_tap_modify (vat_main_t * vam)
6455 unformat_input_t *i = vam->input;
6456 vl_api_tap_modify_t *mp;
6461 u32 sw_if_index = ~0;
6462 u8 sw_if_index_set = 0;
6465 memset (mac_address, 0, sizeof (mac_address));
6467 /* Parse args required to build the message */
6468 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6470 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6471 sw_if_index_set = 1;
6472 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6473 sw_if_index_set = 1;
6474 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6478 else if (unformat (i, "random-mac"))
6480 else if (unformat (i, "tapname %s", &tap_name))
6486 if (sw_if_index_set == 0)
6488 errmsg ("missing vpp interface name");
6493 errmsg ("missing tap name");
6496 if (vec_len (tap_name) > 63)
6498 errmsg ("tap name too long");
6500 vec_add1 (tap_name, 0);
6502 /* Construct the API message */
6505 mp->use_random_mac = random_mac;
6506 mp->sw_if_index = ntohl (sw_if_index);
6507 clib_memcpy (mp->mac_address, mac_address, 6);
6508 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6509 vec_free (tap_name);
6514 /* Wait for a reply... */
6520 api_tap_delete (vat_main_t * vam)
6522 unformat_input_t *i = vam->input;
6523 vl_api_tap_delete_t *mp;
6524 u32 sw_if_index = ~0;
6525 u8 sw_if_index_set = 0;
6528 /* Parse args required to build the message */
6529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6531 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6532 sw_if_index_set = 1;
6533 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6534 sw_if_index_set = 1;
6539 if (sw_if_index_set == 0)
6541 errmsg ("missing vpp interface name");
6545 /* Construct the API message */
6548 mp->sw_if_index = ntohl (sw_if_index);
6553 /* Wait for a reply... */
6559 api_ip_add_del_route (vat_main_t * vam)
6561 unformat_input_t *i = vam->input;
6562 vl_api_ip_add_del_route_t *mp;
6563 u32 sw_if_index = ~0, vrf_id = 0;
6565 u8 is_local = 0, is_drop = 0;
6566 u8 is_unreach = 0, is_prohibit = 0;
6567 u8 create_vrf_if_needed = 0;
6569 u32 next_hop_weight = 1;
6571 u8 is_multipath = 0;
6573 u8 address_length_set = 0;
6574 u32 next_hop_table_id = 0;
6575 u32 resolve_attempts = 0;
6576 u32 dst_address_length = 0;
6577 u8 next_hop_set = 0;
6578 ip4_address_t v4_dst_address, v4_next_hop_address;
6579 ip6_address_t v6_dst_address, v6_next_hop_address;
6583 u32 random_add_del = 0;
6584 u32 *random_vector = 0;
6586 u32 random_seed = 0xdeaddabe;
6587 u32 classify_table_index = ~0;
6589 u8 resolve_host = 0, resolve_attached = 0;
6590 mpls_label_t *next_hop_out_label_stack = NULL;
6591 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6592 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6594 /* Parse args required to build the message */
6595 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6597 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6599 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6601 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6606 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6611 else if (unformat (i, "/%d", &dst_address_length))
6613 address_length_set = 1;
6616 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6617 &v4_next_hop_address))
6621 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6622 &v6_next_hop_address))
6626 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6628 else if (unformat (i, "weight %d", &next_hop_weight))
6630 else if (unformat (i, "drop"))
6634 else if (unformat (i, "null-send-unreach"))
6638 else if (unformat (i, "null-send-prohibit"))
6642 else if (unformat (i, "local"))
6646 else if (unformat (i, "classify %d", &classify_table_index))
6650 else if (unformat (i, "del"))
6652 else if (unformat (i, "add"))
6654 else if (unformat (i, "not-last"))
6656 else if (unformat (i, "resolve-via-host"))
6658 else if (unformat (i, "resolve-via-attached"))
6659 resolve_attached = 1;
6660 else if (unformat (i, "multipath"))
6662 else if (unformat (i, "vrf %d", &vrf_id))
6664 else if (unformat (i, "create-vrf"))
6665 create_vrf_if_needed = 1;
6666 else if (unformat (i, "count %d", &count))
6668 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6670 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6672 else if (unformat (i, "out-label %d", &next_hop_out_label))
6673 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6674 else if (unformat (i, "via-label %d", &next_hop_via_label))
6676 else if (unformat (i, "random"))
6678 else if (unformat (i, "seed %d", &random_seed))
6682 clib_warning ("parse error '%U'", format_unformat_error, i);
6687 if (!next_hop_set && !is_drop && !is_local &&
6688 !is_classify && !is_unreach && !is_prohibit &&
6689 MPLS_LABEL_INVALID == next_hop_via_label)
6692 ("next hop / local / drop / unreach / prohibit / classify not set");
6696 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6698 errmsg ("next hop and next-hop via label set");
6701 if (address_set == 0)
6703 errmsg ("missing addresses");
6707 if (address_length_set == 0)
6709 errmsg ("missing address length");
6713 /* Generate a pile of unique, random routes */
6716 u32 this_random_address;
6717 random_hash = hash_create (count, sizeof (uword));
6719 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6720 for (j = 0; j <= count; j++)
6724 this_random_address = random_u32 (&random_seed);
6725 this_random_address =
6726 clib_host_to_net_u32 (this_random_address);
6728 while (hash_get (random_hash, this_random_address));
6729 vec_add1 (random_vector, this_random_address);
6730 hash_set (random_hash, this_random_address, 1);
6732 hash_free (random_hash);
6733 v4_dst_address.as_u32 = random_vector[0];
6738 /* Turn on async mode */
6739 vam->async_mode = 1;
6740 vam->async_errors = 0;
6741 before = vat_time_now (vam);
6744 for (j = 0; j < count; j++)
6746 /* Construct the API message */
6747 M2 (IP_ADD_DEL_ROUTE, mp,
6748 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6750 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6751 mp->table_id = ntohl (vrf_id);
6752 mp->create_vrf_if_needed = create_vrf_if_needed;
6754 mp->is_add = is_add;
6755 mp->is_drop = is_drop;
6756 mp->is_unreach = is_unreach;
6757 mp->is_prohibit = is_prohibit;
6758 mp->is_ipv6 = is_ipv6;
6759 mp->is_local = is_local;
6760 mp->is_classify = is_classify;
6761 mp->is_multipath = is_multipath;
6762 mp->is_resolve_host = resolve_host;
6763 mp->is_resolve_attached = resolve_attached;
6764 mp->not_last = not_last;
6765 mp->next_hop_weight = next_hop_weight;
6766 mp->dst_address_length = dst_address_length;
6767 mp->next_hop_table_id = ntohl (next_hop_table_id);
6768 mp->classify_table_index = ntohl (classify_table_index);
6769 mp->next_hop_via_label = ntohl (next_hop_via_label);
6770 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6771 if (0 != mp->next_hop_n_out_labels)
6773 memcpy (mp->next_hop_out_label_stack,
6774 next_hop_out_label_stack,
6775 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6776 vec_free (next_hop_out_label_stack);
6781 clib_memcpy (mp->dst_address, &v6_dst_address,
6782 sizeof (v6_dst_address));
6784 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6785 sizeof (v6_next_hop_address));
6786 increment_v6_address (&v6_dst_address);
6790 clib_memcpy (mp->dst_address, &v4_dst_address,
6791 sizeof (v4_dst_address));
6793 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6794 sizeof (v4_next_hop_address));
6796 v4_dst_address.as_u32 = random_vector[j + 1];
6798 increment_v4_address (&v4_dst_address);
6802 /* If we receive SIGTERM, stop now... */
6807 /* When testing multiple add/del ops, use a control-ping to sync */
6810 vl_api_control_ping_t *mp_ping;
6814 /* Shut off async mode */
6815 vam->async_mode = 0;
6817 M (CONTROL_PING, mp_ping);
6820 timeout = vat_time_now (vam) + 1.0;
6821 while (vat_time_now (vam) < timeout)
6822 if (vam->result_ready == 1)
6827 if (vam->retval == -99)
6830 if (vam->async_errors > 0)
6832 errmsg ("%d asynchronous errors", vam->async_errors);
6835 vam->async_errors = 0;
6836 after = vat_time_now (vam);
6838 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6842 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6843 count, after - before, count / (after - before));
6849 /* Wait for a reply... */
6854 /* Return the good/bad news */
6855 return (vam->retval);
6859 api_ip_mroute_add_del (vat_main_t * vam)
6861 unformat_input_t *i = vam->input;
6862 vl_api_ip_mroute_add_del_t *mp;
6863 u32 sw_if_index = ~0, vrf_id = 0;
6866 u8 create_vrf_if_needed = 0;
6869 u32 grp_address_length = 0;
6870 ip4_address_t v4_grp_address, v4_src_address;
6871 ip6_address_t v6_grp_address, v6_src_address;
6872 mfib_itf_flags_t iflags = 0;
6873 mfib_entry_flags_t eflags = 0;
6876 /* Parse args required to build the message */
6877 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6879 if (unformat (i, "sw_if_index %d", &sw_if_index))
6881 else if (unformat (i, "%U %U",
6882 unformat_ip4_address, &v4_src_address,
6883 unformat_ip4_address, &v4_grp_address))
6885 grp_address_length = 64;
6889 else if (unformat (i, "%U %U",
6890 unformat_ip6_address, &v6_src_address,
6891 unformat_ip6_address, &v6_grp_address))
6893 grp_address_length = 256;
6897 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
6899 memset (&v4_src_address, 0, sizeof (v4_src_address));
6900 grp_address_length = 32;
6904 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
6906 memset (&v6_src_address, 0, sizeof (v6_src_address));
6907 grp_address_length = 128;
6911 else if (unformat (i, "/%d", &grp_address_length))
6913 else if (unformat (i, "local"))
6917 else if (unformat (i, "del"))
6919 else if (unformat (i, "add"))
6921 else if (unformat (i, "vrf %d", &vrf_id))
6923 else if (unformat (i, "create-vrf"))
6924 create_vrf_if_needed = 1;
6925 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
6927 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
6931 clib_warning ("parse error '%U'", format_unformat_error, i);
6936 if (address_set == 0)
6938 errmsg ("missing addresses\n");
6942 /* Construct the API message */
6943 M (IP_MROUTE_ADD_DEL, mp);
6945 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6946 mp->table_id = ntohl (vrf_id);
6947 mp->create_vrf_if_needed = create_vrf_if_needed;
6949 mp->is_add = is_add;
6950 mp->is_ipv6 = is_ipv6;
6951 mp->is_local = is_local;
6952 mp->itf_flags = ntohl (iflags);
6953 mp->entry_flags = ntohl (eflags);
6954 mp->grp_address_length = grp_address_length;
6955 mp->grp_address_length = ntohs (mp->grp_address_length);
6959 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
6960 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
6964 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
6965 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
6971 /* Wait for a reply... */
6977 api_mpls_route_add_del (vat_main_t * vam)
6979 unformat_input_t *i = vam->input;
6980 vl_api_mpls_route_add_del_t *mp;
6981 u32 sw_if_index = ~0, table_id = 0;
6982 u8 create_table_if_needed = 0;
6984 u32 next_hop_weight = 1;
6985 u8 is_multipath = 0;
6986 u32 next_hop_table_id = 0;
6987 u8 next_hop_set = 0;
6988 ip4_address_t v4_next_hop_address = {
6991 ip6_address_t v6_next_hop_address = { {0} };
6995 u32 classify_table_index = ~0;
6997 u8 resolve_host = 0, resolve_attached = 0;
6998 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6999 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7000 mpls_label_t *next_hop_out_label_stack = NULL;
7001 mpls_label_t local_label = MPLS_LABEL_INVALID;
7003 u8 next_hop_proto_is_ip4 = 1;
7005 /* Parse args required to build the message */
7006 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7008 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7010 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7012 else if (unformat (i, "%d", &local_label))
7014 else if (unformat (i, "eos"))
7016 else if (unformat (i, "non-eos"))
7018 else if (unformat (i, "via %U", unformat_ip4_address,
7019 &v4_next_hop_address))
7022 next_hop_proto_is_ip4 = 1;
7024 else if (unformat (i, "via %U", unformat_ip6_address,
7025 &v6_next_hop_address))
7028 next_hop_proto_is_ip4 = 0;
7030 else if (unformat (i, "weight %d", &next_hop_weight))
7032 else if (unformat (i, "create-table"))
7033 create_table_if_needed = 1;
7034 else if (unformat (i, "classify %d", &classify_table_index))
7038 else if (unformat (i, "del"))
7040 else if (unformat (i, "add"))
7042 else if (unformat (i, "resolve-via-host"))
7044 else if (unformat (i, "resolve-via-attached"))
7045 resolve_attached = 1;
7046 else if (unformat (i, "multipath"))
7048 else if (unformat (i, "count %d", &count))
7050 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
7053 next_hop_proto_is_ip4 = 1;
7055 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
7058 next_hop_proto_is_ip4 = 0;
7060 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7062 else if (unformat (i, "via-label %d", &next_hop_via_label))
7064 else if (unformat (i, "out-label %d", &next_hop_out_label))
7065 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7068 clib_warning ("parse error '%U'", format_unformat_error, i);
7073 if (!next_hop_set && !is_classify)
7075 errmsg ("next hop / classify not set");
7079 if (MPLS_LABEL_INVALID == local_label)
7081 errmsg ("missing label");
7087 /* Turn on async mode */
7088 vam->async_mode = 1;
7089 vam->async_errors = 0;
7090 before = vat_time_now (vam);
7093 for (j = 0; j < count; j++)
7095 /* Construct the API message */
7096 M2 (MPLS_ROUTE_ADD_DEL, mp,
7097 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7099 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
7100 mp->mr_table_id = ntohl (table_id);
7101 mp->mr_create_table_if_needed = create_table_if_needed;
7103 mp->mr_is_add = is_add;
7104 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7105 mp->mr_is_classify = is_classify;
7106 mp->mr_is_multipath = is_multipath;
7107 mp->mr_is_resolve_host = resolve_host;
7108 mp->mr_is_resolve_attached = resolve_attached;
7109 mp->mr_next_hop_weight = next_hop_weight;
7110 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
7111 mp->mr_classify_table_index = ntohl (classify_table_index);
7112 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
7113 mp->mr_label = ntohl (local_label);
7114 mp->mr_eos = is_eos;
7116 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7117 if (0 != mp->mr_next_hop_n_out_labels)
7119 memcpy (mp->mr_next_hop_out_label_stack,
7120 next_hop_out_label_stack,
7121 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7122 vec_free (next_hop_out_label_stack);
7127 if (next_hop_proto_is_ip4)
7129 clib_memcpy (mp->mr_next_hop,
7130 &v4_next_hop_address,
7131 sizeof (v4_next_hop_address));
7135 clib_memcpy (mp->mr_next_hop,
7136 &v6_next_hop_address,
7137 sizeof (v6_next_hop_address));
7144 /* If we receive SIGTERM, stop now... */
7149 /* When testing multiple add/del ops, use a control-ping to sync */
7152 vl_api_control_ping_t *mp_ping;
7156 /* Shut off async mode */
7157 vam->async_mode = 0;
7159 M (CONTROL_PING, mp_ping);
7162 timeout = vat_time_now (vam) + 1.0;
7163 while (vat_time_now (vam) < timeout)
7164 if (vam->result_ready == 1)
7169 if (vam->retval == -99)
7172 if (vam->async_errors > 0)
7174 errmsg ("%d asynchronous errors", vam->async_errors);
7177 vam->async_errors = 0;
7178 after = vat_time_now (vam);
7180 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7184 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7185 count, after - before, count / (after - before));
7191 /* Wait for a reply... */
7196 /* Return the good/bad news */
7197 return (vam->retval);
7201 api_mpls_ip_bind_unbind (vat_main_t * vam)
7203 unformat_input_t *i = vam->input;
7204 vl_api_mpls_ip_bind_unbind_t *mp;
7205 u32 ip_table_id = 0;
7206 u8 create_table_if_needed = 0;
7209 ip4_address_t v4_address;
7210 ip6_address_t v6_address;
7213 mpls_label_t local_label = MPLS_LABEL_INVALID;
7216 /* Parse args required to build the message */
7217 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7219 if (unformat (i, "%U/%d", unformat_ip4_address,
7220 &v4_address, &address_length))
7225 else if (unformat (i, "%U/%d", unformat_ip6_address,
7226 &v6_address, &address_length))
7231 else if (unformat (i, "%d", &local_label))
7233 else if (unformat (i, "create-table"))
7234 create_table_if_needed = 1;
7235 else if (unformat (i, "table-id %d", &ip_table_id))
7237 else if (unformat (i, "unbind"))
7239 else if (unformat (i, "bind"))
7243 clib_warning ("parse error '%U'", format_unformat_error, i);
7250 errmsg ("IP addres not set");
7254 if (MPLS_LABEL_INVALID == local_label)
7256 errmsg ("missing label");
7260 /* Construct the API message */
7261 M (MPLS_IP_BIND_UNBIND, mp);
7263 mp->mb_create_table_if_needed = create_table_if_needed;
7264 mp->mb_is_bind = is_bind;
7265 mp->mb_is_ip4 = is_ip4;
7266 mp->mb_ip_table_id = ntohl (ip_table_id);
7267 mp->mb_mpls_table_id = 0;
7268 mp->mb_label = ntohl (local_label);
7269 mp->mb_address_length = address_length;
7272 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7274 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7279 /* Wait for a reply... */
7285 api_proxy_arp_add_del (vat_main_t * vam)
7287 unformat_input_t *i = vam->input;
7288 vl_api_proxy_arp_add_del_t *mp;
7291 ip4_address_t lo, hi;
7295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7297 if (unformat (i, "vrf %d", &vrf_id))
7299 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7300 unformat_ip4_address, &hi))
7302 else if (unformat (i, "del"))
7306 clib_warning ("parse error '%U'", format_unformat_error, i);
7313 errmsg ("address range not set");
7317 M (PROXY_ARP_ADD_DEL, mp);
7319 mp->vrf_id = ntohl (vrf_id);
7320 mp->is_add = is_add;
7321 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7322 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7330 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7332 unformat_input_t *i = vam->input;
7333 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7336 u8 sw_if_index_set = 0;
7339 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7341 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7342 sw_if_index_set = 1;
7343 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7344 sw_if_index_set = 1;
7345 else if (unformat (i, "enable"))
7347 else if (unformat (i, "disable"))
7351 clib_warning ("parse error '%U'", format_unformat_error, i);
7356 if (sw_if_index_set == 0)
7358 errmsg ("missing interface name or sw_if_index");
7362 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7364 mp->sw_if_index = ntohl (sw_if_index);
7365 mp->enable_disable = enable;
7373 api_mpls_tunnel_add_del (vat_main_t * vam)
7375 unformat_input_t *i = vam->input;
7376 vl_api_mpls_tunnel_add_del_t *mp;
7380 u32 sw_if_index = ~0;
7381 u32 next_hop_sw_if_index = ~0;
7382 u32 next_hop_proto_is_ip4 = 1;
7384 u32 next_hop_table_id = 0;
7385 ip4_address_t v4_next_hop_address = {
7388 ip6_address_t v6_next_hop_address = { {0} };
7389 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7392 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7394 if (unformat (i, "add"))
7396 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7398 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7400 else if (unformat (i, "via %U",
7401 unformat_ip4_address, &v4_next_hop_address))
7403 next_hop_proto_is_ip4 = 1;
7405 else if (unformat (i, "via %U",
7406 unformat_ip6_address, &v6_next_hop_address))
7408 next_hop_proto_is_ip4 = 0;
7410 else if (unformat (i, "l2-only"))
7412 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7414 else if (unformat (i, "out-label %d", &next_hop_out_label))
7415 vec_add1 (labels, ntohl (next_hop_out_label));
7418 clib_warning ("parse error '%U'", format_unformat_error, i);
7423 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7425 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7426 mp->mt_sw_if_index = ntohl (sw_if_index);
7427 mp->mt_is_add = is_add;
7428 mp->mt_l2_only = l2_only;
7429 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7430 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7432 mp->mt_next_hop_n_out_labels = vec_len (labels);
7434 if (0 != mp->mt_next_hop_n_out_labels)
7436 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7437 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7441 if (next_hop_proto_is_ip4)
7443 clib_memcpy (mp->mt_next_hop,
7444 &v4_next_hop_address, sizeof (v4_next_hop_address));
7448 clib_memcpy (mp->mt_next_hop,
7449 &v6_next_hop_address, sizeof (v6_next_hop_address));
7458 api_sw_interface_set_unnumbered (vat_main_t * vam)
7460 unformat_input_t *i = vam->input;
7461 vl_api_sw_interface_set_unnumbered_t *mp;
7463 u32 unnum_sw_index = ~0;
7465 u8 sw_if_index_set = 0;
7468 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7470 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7471 sw_if_index_set = 1;
7472 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7473 sw_if_index_set = 1;
7474 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7476 else if (unformat (i, "del"))
7480 clib_warning ("parse error '%U'", format_unformat_error, i);
7485 if (sw_if_index_set == 0)
7487 errmsg ("missing interface name or sw_if_index");
7491 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7493 mp->sw_if_index = ntohl (sw_if_index);
7494 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7495 mp->is_add = is_add;
7503 api_ip_neighbor_add_del (vat_main_t * vam)
7505 unformat_input_t *i = vam->input;
7506 vl_api_ip_neighbor_add_del_t *mp;
7508 u8 sw_if_index_set = 0;
7511 u8 is_no_fib_entry = 0;
7514 u8 v4_address_set = 0;
7515 u8 v6_address_set = 0;
7516 ip4_address_t v4address;
7517 ip6_address_t v6address;
7520 memset (mac_address, 0, sizeof (mac_address));
7522 /* Parse args required to build the message */
7523 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7525 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7529 else if (unformat (i, "del"))
7532 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7533 sw_if_index_set = 1;
7534 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7535 sw_if_index_set = 1;
7536 else if (unformat (i, "is_static"))
7538 else if (unformat (i, "no-fib-entry"))
7539 is_no_fib_entry = 1;
7540 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7542 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7546 clib_warning ("parse error '%U'", format_unformat_error, i);
7551 if (sw_if_index_set == 0)
7553 errmsg ("missing interface name or sw_if_index");
7556 if (v4_address_set && v6_address_set)
7558 errmsg ("both v4 and v6 addresses set");
7561 if (!v4_address_set && !v6_address_set)
7563 errmsg ("no address set");
7567 /* Construct the API message */
7568 M (IP_NEIGHBOR_ADD_DEL, mp);
7570 mp->sw_if_index = ntohl (sw_if_index);
7571 mp->is_add = is_add;
7572 mp->is_static = is_static;
7573 mp->is_no_adj_fib = is_no_fib_entry;
7575 clib_memcpy (mp->mac_address, mac_address, 6);
7579 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7583 /* mp->is_ipv6 = 0; via memset in M macro above */
7584 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7590 /* Wait for a reply, return good/bad news */
7596 api_reset_vrf (vat_main_t * vam)
7598 unformat_input_t *i = vam->input;
7599 vl_api_reset_vrf_t *mp;
7605 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7607 if (unformat (i, "vrf %d", &vrf_id))
7609 else if (unformat (i, "ipv6"))
7613 clib_warning ("parse error '%U'", format_unformat_error, i);
7618 if (vrf_id_set == 0)
7620 errmsg ("missing vrf id");
7626 mp->vrf_id = ntohl (vrf_id);
7627 mp->is_ipv6 = is_ipv6;
7635 api_create_vlan_subif (vat_main_t * vam)
7637 unformat_input_t *i = vam->input;
7638 vl_api_create_vlan_subif_t *mp;
7640 u8 sw_if_index_set = 0;
7645 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7647 if (unformat (i, "sw_if_index %d", &sw_if_index))
7648 sw_if_index_set = 1;
7650 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7651 sw_if_index_set = 1;
7652 else if (unformat (i, "vlan %d", &vlan_id))
7656 clib_warning ("parse error '%U'", format_unformat_error, i);
7661 if (sw_if_index_set == 0)
7663 errmsg ("missing interface name or sw_if_index");
7667 if (vlan_id_set == 0)
7669 errmsg ("missing vlan_id");
7672 M (CREATE_VLAN_SUBIF, mp);
7674 mp->sw_if_index = ntohl (sw_if_index);
7675 mp->vlan_id = ntohl (vlan_id);
7682 #define foreach_create_subif_bit \
7689 _(outer_vlan_id_any) \
7690 _(inner_vlan_id_any)
7693 api_create_subif (vat_main_t * vam)
7695 unformat_input_t *i = vam->input;
7696 vl_api_create_subif_t *mp;
7698 u8 sw_if_index_set = 0;
7705 u32 exact_match = 0;
7706 u32 default_sub = 0;
7707 u32 outer_vlan_id_any = 0;
7708 u32 inner_vlan_id_any = 0;
7710 u16 outer_vlan_id = 0;
7711 u16 inner_vlan_id = 0;
7714 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7716 if (unformat (i, "sw_if_index %d", &sw_if_index))
7717 sw_if_index_set = 1;
7719 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7720 sw_if_index_set = 1;
7721 else if (unformat (i, "sub_id %d", &sub_id))
7723 else if (unformat (i, "outer_vlan_id %d", &tmp))
7724 outer_vlan_id = tmp;
7725 else if (unformat (i, "inner_vlan_id %d", &tmp))
7726 inner_vlan_id = tmp;
7728 #define _(a) else if (unformat (i, #a)) a = 1 ;
7729 foreach_create_subif_bit
7733 clib_warning ("parse error '%U'", format_unformat_error, i);
7738 if (sw_if_index_set == 0)
7740 errmsg ("missing interface name or sw_if_index");
7744 if (sub_id_set == 0)
7746 errmsg ("missing sub_id");
7749 M (CREATE_SUBIF, mp);
7751 mp->sw_if_index = ntohl (sw_if_index);
7752 mp->sub_id = ntohl (sub_id);
7754 #define _(a) mp->a = a;
7755 foreach_create_subif_bit;
7758 mp->outer_vlan_id = ntohs (outer_vlan_id);
7759 mp->inner_vlan_id = ntohs (inner_vlan_id);
7767 api_oam_add_del (vat_main_t * vam)
7769 unformat_input_t *i = vam->input;
7770 vl_api_oam_add_del_t *mp;
7773 ip4_address_t src, dst;
7778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7780 if (unformat (i, "vrf %d", &vrf_id))
7782 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7784 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7786 else if (unformat (i, "del"))
7790 clib_warning ("parse error '%U'", format_unformat_error, i);
7797 errmsg ("missing src addr");
7803 errmsg ("missing dst addr");
7807 M (OAM_ADD_DEL, mp);
7809 mp->vrf_id = ntohl (vrf_id);
7810 mp->is_add = is_add;
7811 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7812 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7820 api_reset_fib (vat_main_t * vam)
7822 unformat_input_t *i = vam->input;
7823 vl_api_reset_fib_t *mp;
7829 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7831 if (unformat (i, "vrf %d", &vrf_id))
7833 else if (unformat (i, "ipv6"))
7837 clib_warning ("parse error '%U'", format_unformat_error, i);
7842 if (vrf_id_set == 0)
7844 errmsg ("missing vrf id");
7850 mp->vrf_id = ntohl (vrf_id);
7851 mp->is_ipv6 = is_ipv6;
7859 api_dhcp_proxy_config (vat_main_t * vam)
7861 unformat_input_t *i = vam->input;
7862 vl_api_dhcp_proxy_config_t *mp;
7864 u32 server_vrf_id = 0;
7866 u8 v4_address_set = 0;
7867 u8 v6_address_set = 0;
7868 ip4_address_t v4address;
7869 ip6_address_t v6address;
7870 u8 v4_src_address_set = 0;
7871 u8 v6_src_address_set = 0;
7872 ip4_address_t v4srcaddress;
7873 ip6_address_t v6srcaddress;
7876 /* Parse args required to build the message */
7877 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7879 if (unformat (i, "del"))
7881 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7883 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7885 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7887 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7889 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7890 v4_src_address_set = 1;
7891 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7892 v6_src_address_set = 1;
7897 if (v4_address_set && v6_address_set)
7899 errmsg ("both v4 and v6 server addresses set");
7902 if (!v4_address_set && !v6_address_set)
7904 errmsg ("no server addresses set");
7908 if (v4_src_address_set && v6_src_address_set)
7910 errmsg ("both v4 and v6 src addresses set");
7913 if (!v4_src_address_set && !v6_src_address_set)
7915 errmsg ("no src addresses set");
7919 if (!(v4_src_address_set && v4_address_set) &&
7920 !(v6_src_address_set && v6_address_set))
7922 errmsg ("no matching server and src addresses set");
7926 /* Construct the API message */
7927 M (DHCP_PROXY_CONFIG, mp);
7929 mp->is_add = is_add;
7930 mp->rx_vrf_id = ntohl (rx_vrf_id);
7931 mp->server_vrf_id = ntohl (server_vrf_id);
7935 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7936 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7940 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7941 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7947 /* Wait for a reply, return good/bad news */
7952 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
7953 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
7956 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
7958 vat_main_t *vam = &vat_main;
7959 u32 i, count = mp->count;
7960 vl_api_dhcp_server_t *s;
7964 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7965 ntohl (mp->rx_vrf_id),
7966 format_ip6_address, mp->dhcp_src_address,
7967 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7970 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7971 ntohl (mp->rx_vrf_id),
7972 format_ip4_address, mp->dhcp_src_address,
7973 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7975 for (i = 0; i < count; i++)
7977 s = &mp->servers[i];
7981 " Server Table-ID %d, Server Address %U",
7982 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
7985 " Server Table-ID %d, Server Address %U",
7986 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
7990 static void vl_api_dhcp_proxy_details_t_handler_json
7991 (vl_api_dhcp_proxy_details_t * mp)
7993 vat_main_t *vam = &vat_main;
7994 vat_json_node_t *node = NULL;
7995 u32 i, count = mp->count;
7997 struct in6_addr ip6;
7998 vl_api_dhcp_server_t *s;
8000 if (VAT_JSON_ARRAY != vam->json_tree.type)
8002 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8003 vat_json_init_array (&vam->json_tree);
8005 node = vat_json_array_add (&vam->json_tree);
8007 vat_json_init_object (node);
8008 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
8009 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
8010 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
8014 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
8015 vat_json_object_add_ip6 (node, "src_address", ip6);
8019 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
8020 vat_json_object_add_ip4 (node, "src_address", ip4);
8023 for (i = 0; i < count; i++)
8025 s = &mp->servers[i];
8027 vat_json_object_add_uint (node, "server-table-id",
8028 ntohl (s->server_vrf_id));
8032 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
8033 vat_json_object_add_ip4 (node, "src_address", ip4);
8037 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
8038 vat_json_object_add_ip6 (node, "server_address", ip6);
8044 api_dhcp_proxy_dump (vat_main_t * vam)
8046 unformat_input_t *i = vam->input;
8047 vl_api_control_ping_t *mp_ping;
8048 vl_api_dhcp_proxy_dump_t *mp;
8052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8054 if (unformat (i, "ipv6"))
8058 clib_warning ("parse error '%U'", format_unformat_error, i);
8063 M (DHCP_PROXY_DUMP, mp);
8065 mp->is_ip6 = is_ipv6;
8068 /* Use a control ping for synchronization */
8069 M (CONTROL_PING, mp_ping);
8077 api_dhcp_proxy_set_vss (vat_main_t * vam)
8079 unformat_input_t *i = vam->input;
8080 vl_api_dhcp_proxy_set_vss_t *mp;
8091 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8093 if (unformat (i, "tbl_id %d", &tbl_id))
8095 if (unformat (i, "fib_id %d", &fib_id))
8097 if (unformat (i, "oui %d", &oui))
8099 else if (unformat (i, "ipv6"))
8101 else if (unformat (i, "del"))
8105 clib_warning ("parse error '%U'", format_unformat_error, i);
8110 if (tbl_id_set == 0)
8112 errmsg ("missing tbl id");
8116 if (fib_id_set == 0)
8118 errmsg ("missing fib id");
8123 errmsg ("missing oui");
8127 M (DHCP_PROXY_SET_VSS, mp);
8128 mp->tbl_id = ntohl (tbl_id);
8129 mp->fib_id = ntohl (fib_id);
8130 mp->oui = ntohl (oui);
8131 mp->is_ipv6 = is_ipv6;
8132 mp->is_add = is_add;
8140 api_dhcp_client_config (vat_main_t * vam)
8142 unformat_input_t *i = vam->input;
8143 vl_api_dhcp_client_config_t *mp;
8145 u8 sw_if_index_set = 0;
8148 u8 disable_event = 0;
8151 /* Parse args required to build the message */
8152 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8154 if (unformat (i, "del"))
8157 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8158 sw_if_index_set = 1;
8159 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8160 sw_if_index_set = 1;
8161 else if (unformat (i, "hostname %s", &hostname))
8163 else if (unformat (i, "disable_event"))
8169 if (sw_if_index_set == 0)
8171 errmsg ("missing interface name or sw_if_index");
8175 if (vec_len (hostname) > 63)
8177 errmsg ("hostname too long");
8179 vec_add1 (hostname, 0);
8181 /* Construct the API message */
8182 M (DHCP_CLIENT_CONFIG, mp);
8184 mp->sw_if_index = htonl (sw_if_index);
8185 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
8186 vec_free (hostname);
8187 mp->is_add = is_add;
8188 mp->want_dhcp_event = disable_event ? 0 : 1;
8189 mp->pid = htonl (getpid ());
8194 /* Wait for a reply, return good/bad news */
8200 api_set_ip_flow_hash (vat_main_t * vam)
8202 unformat_input_t *i = vam->input;
8203 vl_api_set_ip_flow_hash_t *mp;
8215 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8217 if (unformat (i, "vrf %d", &vrf_id))
8219 else if (unformat (i, "ipv6"))
8221 else if (unformat (i, "src"))
8223 else if (unformat (i, "dst"))
8225 else if (unformat (i, "sport"))
8227 else if (unformat (i, "dport"))
8229 else if (unformat (i, "proto"))
8231 else if (unformat (i, "reverse"))
8236 clib_warning ("parse error '%U'", format_unformat_error, i);
8241 if (vrf_id_set == 0)
8243 errmsg ("missing vrf id");
8247 M (SET_IP_FLOW_HASH, mp);
8253 mp->reverse = reverse;
8254 mp->vrf_id = ntohl (vrf_id);
8255 mp->is_ipv6 = is_ipv6;
8263 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8265 unformat_input_t *i = vam->input;
8266 vl_api_sw_interface_ip6_enable_disable_t *mp;
8268 u8 sw_if_index_set = 0;
8272 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8274 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8275 sw_if_index_set = 1;
8276 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8277 sw_if_index_set = 1;
8278 else if (unformat (i, "enable"))
8280 else if (unformat (i, "disable"))
8284 clib_warning ("parse error '%U'", format_unformat_error, i);
8289 if (sw_if_index_set == 0)
8291 errmsg ("missing interface name or sw_if_index");
8295 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8297 mp->sw_if_index = ntohl (sw_if_index);
8298 mp->enable = enable;
8306 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8308 unformat_input_t *i = vam->input;
8309 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8311 u8 sw_if_index_set = 0;
8312 u8 v6_address_set = 0;
8313 ip6_address_t v6address;
8316 /* Parse args required to build the message */
8317 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8319 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8320 sw_if_index_set = 1;
8321 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8322 sw_if_index_set = 1;
8323 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8329 if (sw_if_index_set == 0)
8331 errmsg ("missing interface name or sw_if_index");
8334 if (!v6_address_set)
8336 errmsg ("no address set");
8340 /* Construct the API message */
8341 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8343 mp->sw_if_index = ntohl (sw_if_index);
8344 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8349 /* Wait for a reply, return good/bad news */
8355 api_ip6nd_proxy_add_del (vat_main_t * vam)
8357 unformat_input_t *i = vam->input;
8358 vl_api_ip6nd_proxy_add_del_t *mp;
8359 u32 sw_if_index = ~0;
8360 u8 v6_address_set = 0;
8361 ip6_address_t v6address;
8365 /* Parse args required to build the message */
8366 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8368 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8370 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8372 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8374 if (unformat (i, "del"))
8378 clib_warning ("parse error '%U'", format_unformat_error, i);
8383 if (sw_if_index == ~0)
8385 errmsg ("missing interface name or sw_if_index");
8388 if (!v6_address_set)
8390 errmsg ("no address set");
8394 /* Construct the API message */
8395 M (IP6ND_PROXY_ADD_DEL, mp);
8397 mp->is_del = is_del;
8398 mp->sw_if_index = ntohl (sw_if_index);
8399 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8404 /* Wait for a reply, return good/bad news */
8410 api_ip6nd_proxy_dump (vat_main_t * vam)
8412 vl_api_ip6nd_proxy_dump_t *mp;
8413 vl_api_control_ping_t *mp_ping;
8416 M (IP6ND_PROXY_DUMP, mp);
8420 /* Use a control ping for synchronization */
8421 M (CONTROL_PING, mp_ping);
8428 static void vl_api_ip6nd_proxy_details_t_handler
8429 (vl_api_ip6nd_proxy_details_t * mp)
8431 vat_main_t *vam = &vat_main;
8433 print (vam->ofp, "host %U sw_if_index %d",
8434 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
8437 static void vl_api_ip6nd_proxy_details_t_handler_json
8438 (vl_api_ip6nd_proxy_details_t * mp)
8440 vat_main_t *vam = &vat_main;
8441 struct in6_addr ip6;
8442 vat_json_node_t *node = NULL;
8444 if (VAT_JSON_ARRAY != vam->json_tree.type)
8446 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8447 vat_json_init_array (&vam->json_tree);
8449 node = vat_json_array_add (&vam->json_tree);
8451 vat_json_init_object (node);
8452 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
8454 clib_memcpy (&ip6, mp->address, sizeof (ip6));
8455 vat_json_object_add_ip6 (node, "host", ip6);
8459 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8461 unformat_input_t *i = vam->input;
8462 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8464 u8 sw_if_index_set = 0;
8465 u32 address_length = 0;
8466 u8 v6_address_set = 0;
8467 ip6_address_t v6address;
8469 u8 no_advertise = 0;
8471 u8 no_autoconfig = 0;
8474 u32 val_lifetime = 0;
8475 u32 pref_lifetime = 0;
8478 /* Parse args required to build the message */
8479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8481 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8482 sw_if_index_set = 1;
8483 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8484 sw_if_index_set = 1;
8485 else if (unformat (i, "%U/%d",
8486 unformat_ip6_address, &v6address, &address_length))
8488 else if (unformat (i, "val_life %d", &val_lifetime))
8490 else if (unformat (i, "pref_life %d", &pref_lifetime))
8492 else if (unformat (i, "def"))
8494 else if (unformat (i, "noadv"))
8496 else if (unformat (i, "offl"))
8498 else if (unformat (i, "noauto"))
8500 else if (unformat (i, "nolink"))
8502 else if (unformat (i, "isno"))
8506 clib_warning ("parse error '%U'", format_unformat_error, i);
8511 if (sw_if_index_set == 0)
8513 errmsg ("missing interface name or sw_if_index");
8516 if (!v6_address_set)
8518 errmsg ("no address set");
8522 /* Construct the API message */
8523 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8525 mp->sw_if_index = ntohl (sw_if_index);
8526 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8527 mp->address_length = address_length;
8528 mp->use_default = use_default;
8529 mp->no_advertise = no_advertise;
8530 mp->off_link = off_link;
8531 mp->no_autoconfig = no_autoconfig;
8532 mp->no_onlink = no_onlink;
8534 mp->val_lifetime = ntohl (val_lifetime);
8535 mp->pref_lifetime = ntohl (pref_lifetime);
8540 /* Wait for a reply, return good/bad news */
8546 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8548 unformat_input_t *i = vam->input;
8549 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8551 u8 sw_if_index_set = 0;
8556 u8 send_unicast = 0;
8559 u8 default_router = 0;
8560 u32 max_interval = 0;
8561 u32 min_interval = 0;
8563 u32 initial_count = 0;
8564 u32 initial_interval = 0;
8568 /* Parse args required to build the message */
8569 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8571 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8572 sw_if_index_set = 1;
8573 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8574 sw_if_index_set = 1;
8575 else if (unformat (i, "maxint %d", &max_interval))
8577 else if (unformat (i, "minint %d", &min_interval))
8579 else if (unformat (i, "life %d", &lifetime))
8581 else if (unformat (i, "count %d", &initial_count))
8583 else if (unformat (i, "interval %d", &initial_interval))
8585 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8587 else if (unformat (i, "managed"))
8589 else if (unformat (i, "other"))
8591 else if (unformat (i, "ll"))
8593 else if (unformat (i, "send"))
8595 else if (unformat (i, "cease"))
8597 else if (unformat (i, "isno"))
8599 else if (unformat (i, "def"))
8603 clib_warning ("parse error '%U'", format_unformat_error, i);
8608 if (sw_if_index_set == 0)
8610 errmsg ("missing interface name or sw_if_index");
8614 /* Construct the API message */
8615 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8617 mp->sw_if_index = ntohl (sw_if_index);
8618 mp->max_interval = ntohl (max_interval);
8619 mp->min_interval = ntohl (min_interval);
8620 mp->lifetime = ntohl (lifetime);
8621 mp->initial_count = ntohl (initial_count);
8622 mp->initial_interval = ntohl (initial_interval);
8623 mp->suppress = suppress;
8624 mp->managed = managed;
8626 mp->ll_option = ll_option;
8627 mp->send_unicast = send_unicast;
8630 mp->default_router = default_router;
8635 /* Wait for a reply, return good/bad news */
8641 api_set_arp_neighbor_limit (vat_main_t * vam)
8643 unformat_input_t *i = vam->input;
8644 vl_api_set_arp_neighbor_limit_t *mp;
8650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8652 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8654 else if (unformat (i, "ipv6"))
8658 clib_warning ("parse error '%U'", format_unformat_error, i);
8665 errmsg ("missing limit value");
8669 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8671 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8672 mp->is_ipv6 = is_ipv6;
8680 api_l2_patch_add_del (vat_main_t * vam)
8682 unformat_input_t *i = vam->input;
8683 vl_api_l2_patch_add_del_t *mp;
8685 u8 rx_sw_if_index_set = 0;
8687 u8 tx_sw_if_index_set = 0;
8691 /* Parse args required to build the message */
8692 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8694 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8695 rx_sw_if_index_set = 1;
8696 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8697 tx_sw_if_index_set = 1;
8698 else if (unformat (i, "rx"))
8700 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8702 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8704 rx_sw_if_index_set = 1;
8709 else if (unformat (i, "tx"))
8711 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8713 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8715 tx_sw_if_index_set = 1;
8720 else if (unformat (i, "del"))
8726 if (rx_sw_if_index_set == 0)
8728 errmsg ("missing rx interface name or rx_sw_if_index");
8732 if (tx_sw_if_index_set == 0)
8734 errmsg ("missing tx interface name or tx_sw_if_index");
8738 M (L2_PATCH_ADD_DEL, mp);
8740 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8741 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8742 mp->is_add = is_add;
8750 u8 localsid_addr[16];
8759 api_sr_localsid_add_del (vat_main_t * vam)
8761 unformat_input_t *i = vam->input;
8762 vl_api_sr_localsid_add_del_t *mp;
8765 ip6_address_t localsid;
8769 u32 fib_table = ~(u32) 0;
8770 ip6_address_t next_hop;
8772 bool nexthop_set = 0;
8776 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8778 if (unformat (i, "del"))
8780 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
8781 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
8783 else if (unformat (i, "behavior %u", &behavior));
8784 else if (unformat (i, "sw_if_index %u", &sw_if_index));
8785 else if (unformat (i, "fib-table %u", &fib_table));
8786 else if (unformat (i, "end.psp %u", &behavior));
8791 M (SR_LOCALSID_ADD_DEL, mp);
8793 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
8795 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
8796 mp->behavior = behavior;
8797 mp->sw_if_index = ntohl (sw_if_index);
8798 mp->fib_table = ntohl (fib_table);
8799 mp->end_psp = end_psp;
8800 mp->is_del = is_del;
8808 api_ioam_enable (vat_main_t * vam)
8810 unformat_input_t *input = vam->input;
8811 vl_api_ioam_enable_t *mp;
8813 int has_trace_option = 0;
8814 int has_pot_option = 0;
8815 int has_seqno_option = 0;
8816 int has_analyse_option = 0;
8819 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8821 if (unformat (input, "trace"))
8822 has_trace_option = 1;
8823 else if (unformat (input, "pot"))
8825 else if (unformat (input, "seqno"))
8826 has_seqno_option = 1;
8827 else if (unformat (input, "analyse"))
8828 has_analyse_option = 1;
8832 M (IOAM_ENABLE, mp);
8833 mp->id = htons (id);
8834 mp->seqno = has_seqno_option;
8835 mp->analyse = has_analyse_option;
8836 mp->pot_enable = has_pot_option;
8837 mp->trace_enable = has_trace_option;
8846 api_ioam_disable (vat_main_t * vam)
8848 vl_api_ioam_disable_t *mp;
8851 M (IOAM_DISABLE, mp);
8857 #define foreach_tcp_proto_field \
8861 #define foreach_udp_proto_field \
8865 #define foreach_ip4_proto_field \
8877 u16 src_port, dst_port;
8880 #if VPP_API_TEST_BUILTIN == 0
8882 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8884 u8 **maskp = va_arg (*args, u8 **);
8886 u8 found_something = 0;
8889 #define _(a) u8 a=0;
8890 foreach_tcp_proto_field;
8893 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8896 #define _(a) else if (unformat (input, #a)) a=1;
8897 foreach_tcp_proto_field
8903 #define _(a) found_something += a;
8904 foreach_tcp_proto_field;
8907 if (found_something == 0)
8910 vec_validate (mask, sizeof (*tcp) - 1);
8912 tcp = (tcp_header_t *) mask;
8914 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8915 foreach_tcp_proto_field;
8923 unformat_udp_mask (unformat_input_t * input, va_list * args)
8925 u8 **maskp = va_arg (*args, u8 **);
8927 u8 found_something = 0;
8930 #define _(a) u8 a=0;
8931 foreach_udp_proto_field;
8934 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8937 #define _(a) else if (unformat (input, #a)) a=1;
8938 foreach_udp_proto_field
8944 #define _(a) found_something += a;
8945 foreach_udp_proto_field;
8948 if (found_something == 0)
8951 vec_validate (mask, sizeof (*udp) - 1);
8953 udp = (udp_header_t *) mask;
8955 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8956 foreach_udp_proto_field;
8964 unformat_l4_mask (unformat_input_t * input, va_list * args)
8966 u8 **maskp = va_arg (*args, u8 **);
8967 u16 src_port = 0, dst_port = 0;
8968 tcpudp_header_t *tcpudp;
8970 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8972 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8974 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8976 else if (unformat (input, "src_port"))
8978 else if (unformat (input, "dst_port"))
8984 if (!src_port && !dst_port)
8988 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8990 tcpudp = (tcpudp_header_t *) mask;
8991 tcpudp->src_port = src_port;
8992 tcpudp->dst_port = dst_port;
9000 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9002 u8 **maskp = va_arg (*args, u8 **);
9004 u8 found_something = 0;
9007 #define _(a) u8 a=0;
9008 foreach_ip4_proto_field;
9014 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9016 if (unformat (input, "version"))
9018 else if (unformat (input, "hdr_length"))
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_ip4_proto_field
9034 #define _(a) found_something += a;
9035 foreach_ip4_proto_field;
9038 if (found_something == 0)
9041 vec_validate (mask, sizeof (*ip) - 1);
9043 ip = (ip4_header_t *) mask;
9045 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9046 foreach_ip4_proto_field;
9049 ip->ip_version_and_header_length = 0;
9052 ip->ip_version_and_header_length |= 0xF0;
9055 ip->ip_version_and_header_length |= 0x0F;
9061 #define foreach_ip6_proto_field \
9069 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9071 u8 **maskp = va_arg (*args, u8 **);
9073 u8 found_something = 0;
9075 u32 ip_version_traffic_class_and_flow_label;
9077 #define _(a) u8 a=0;
9078 foreach_ip6_proto_field;
9081 u8 traffic_class = 0;
9084 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9086 if (unformat (input, "version"))
9088 else if (unformat (input, "traffic-class"))
9090 else if (unformat (input, "flow-label"))
9092 else if (unformat (input, "src"))
9094 else if (unformat (input, "dst"))
9096 else if (unformat (input, "proto"))
9099 #define _(a) else if (unformat (input, #a)) a=1;
9100 foreach_ip6_proto_field
9106 #define _(a) found_something += a;
9107 foreach_ip6_proto_field;
9110 if (found_something == 0)
9113 vec_validate (mask, sizeof (*ip) - 1);
9115 ip = (ip6_header_t *) mask;
9117 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9118 foreach_ip6_proto_field;
9121 ip_version_traffic_class_and_flow_label = 0;
9124 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9127 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9130 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9132 ip->ip_version_traffic_class_and_flow_label =
9133 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9140 unformat_l3_mask (unformat_input_t * input, va_list * args)
9142 u8 **maskp = va_arg (*args, u8 **);
9144 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9146 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9148 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9157 unformat_l2_mask (unformat_input_t * input, va_list * args)
9159 u8 **maskp = va_arg (*args, u8 **);
9174 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9176 if (unformat (input, "src"))
9178 else if (unformat (input, "dst"))
9180 else if (unformat (input, "proto"))
9182 else if (unformat (input, "tag1"))
9184 else if (unformat (input, "tag2"))
9186 else if (unformat (input, "ignore-tag1"))
9188 else if (unformat (input, "ignore-tag2"))
9190 else if (unformat (input, "cos1"))
9192 else if (unformat (input, "cos2"))
9194 else if (unformat (input, "dot1q"))
9196 else if (unformat (input, "dot1ad"))
9201 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9202 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9205 if (tag1 || ignore_tag1 || cos1 || dot1q)
9207 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9210 vec_validate (mask, len - 1);
9213 memset (mask, 0xff, 6);
9216 memset (mask + 6, 0xff, 6);
9220 /* inner vlan tag */
9229 mask[21] = mask[20] = 0xff;
9250 mask[16] = mask[17] = 0xff;
9260 mask[12] = mask[13] = 0xff;
9267 unformat_classify_mask (unformat_input_t * input, va_list * args)
9269 u8 **maskp = va_arg (*args, u8 **);
9270 u32 *skipp = va_arg (*args, u32 *);
9271 u32 *matchp = va_arg (*args, u32 *);
9279 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9281 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9283 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9285 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9287 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9301 if (mask || l2 || l3 || l4)
9305 /* "With a free Ethernet header in every package" */
9307 vec_validate (l2, 13);
9311 vec_append (mask, l3);
9316 vec_append (mask, l4);
9321 /* Scan forward looking for the first significant mask octet */
9322 for (i = 0; i < vec_len (mask); i++)
9326 /* compute (skip, match) params */
9327 *skipp = i / sizeof (u32x4);
9328 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9330 /* Pad mask to an even multiple of the vector size */
9331 while (vec_len (mask) % sizeof (u32x4))
9334 match = vec_len (mask) / sizeof (u32x4);
9336 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9338 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9339 if (*tmp || *(tmp + 1))
9344 clib_warning ("BUG: match 0");
9346 _vec_len (mask) = match * sizeof (u32x4);
9356 #endif /* VPP_API_TEST_BUILTIN */
9358 #define foreach_l2_next \
9360 _(ethernet, ETHERNET_INPUT) \
9365 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9367 u32 *miss_next_indexp = va_arg (*args, u32 *);
9372 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9376 if (unformat (input, "%d", &tmp))
9385 *miss_next_indexp = next_index;
9389 #define foreach_ip_next \
9395 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9397 u32 *miss_next_indexp = va_arg (*args, u32 *);
9402 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9406 if (unformat (input, "%d", &tmp))
9415 *miss_next_indexp = next_index;
9419 #define foreach_acl_next \
9423 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9425 u32 *miss_next_indexp = va_arg (*args, u32 *);
9430 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9434 if (unformat (input, "permit"))
9439 else if (unformat (input, "%d", &tmp))
9448 *miss_next_indexp = next_index;
9453 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9455 u32 *r = va_arg (*args, u32 *);
9457 if (unformat (input, "conform-color"))
9458 *r = POLICE_CONFORM;
9459 else if (unformat (input, "exceed-color"))
9468 api_classify_add_del_table (vat_main_t * vam)
9470 unformat_input_t *i = vam->input;
9471 vl_api_classify_add_del_table_t *mp;
9478 u32 table_index = ~0;
9479 u32 next_table_index = ~0;
9480 u32 miss_next_index = ~0;
9481 u32 memory_size = 32 << 20;
9483 u32 current_data_flag = 0;
9484 int current_data_offset = 0;
9487 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9489 if (unformat (i, "del"))
9491 else if (unformat (i, "del-chain"))
9496 else if (unformat (i, "buckets %d", &nbuckets))
9498 else if (unformat (i, "memory_size %d", &memory_size))
9500 else if (unformat (i, "skip %d", &skip))
9502 else if (unformat (i, "match %d", &match))
9504 else if (unformat (i, "table %d", &table_index))
9506 else if (unformat (i, "mask %U", unformat_classify_mask,
9507 &mask, &skip, &match))
9509 else if (unformat (i, "next-table %d", &next_table_index))
9511 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9514 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9517 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9520 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9522 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9528 if (is_add && mask == 0)
9530 errmsg ("Mask required");
9534 if (is_add && skip == ~0)
9536 errmsg ("skip count required");
9540 if (is_add && match == ~0)
9542 errmsg ("match count required");
9546 if (!is_add && table_index == ~0)
9548 errmsg ("table index required for delete");
9552 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9554 mp->is_add = is_add;
9555 mp->del_chain = del_chain;
9556 mp->table_index = ntohl (table_index);
9557 mp->nbuckets = ntohl (nbuckets);
9558 mp->memory_size = ntohl (memory_size);
9559 mp->skip_n_vectors = ntohl (skip);
9560 mp->match_n_vectors = ntohl (match);
9561 mp->next_table_index = ntohl (next_table_index);
9562 mp->miss_next_index = ntohl (miss_next_index);
9563 mp->current_data_flag = ntohl (current_data_flag);
9564 mp->current_data_offset = ntohl (current_data_offset);
9565 clib_memcpy (mp->mask, mask, vec_len (mask));
9574 #if VPP_API_TEST_BUILTIN == 0
9576 unformat_l4_match (unformat_input_t * input, va_list * args)
9578 u8 **matchp = va_arg (*args, u8 **);
9580 u8 *proto_header = 0;
9586 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9588 if (unformat (input, "src_port %d", &src_port))
9590 else if (unformat (input, "dst_port %d", &dst_port))
9596 h.src_port = clib_host_to_net_u16 (src_port);
9597 h.dst_port = clib_host_to_net_u16 (dst_port);
9598 vec_validate (proto_header, sizeof (h) - 1);
9599 memcpy (proto_header, &h, sizeof (h));
9601 *matchp = proto_header;
9607 unformat_ip4_match (unformat_input_t * input, va_list * args)
9609 u8 **matchp = va_arg (*args, u8 **);
9616 int src = 0, dst = 0;
9617 ip4_address_t src_val, dst_val;
9624 int fragment_id = 0;
9625 u32 fragment_id_val;
9631 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9633 if (unformat (input, "version %d", &version_val))
9635 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9637 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9639 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9641 else if (unformat (input, "proto %d", &proto_val))
9643 else if (unformat (input, "tos %d", &tos_val))
9645 else if (unformat (input, "length %d", &length_val))
9647 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9649 else if (unformat (input, "ttl %d", &ttl_val))
9651 else if (unformat (input, "checksum %d", &checksum_val))
9657 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9658 + ttl + checksum == 0)
9662 * Aligned because we use the real comparison functions
9664 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9666 ip = (ip4_header_t *) match;
9668 /* These are realistically matched in practice */
9670 ip->src_address.as_u32 = src_val.as_u32;
9673 ip->dst_address.as_u32 = dst_val.as_u32;
9676 ip->protocol = proto_val;
9679 /* These are not, but they're included for completeness */
9681 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9684 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9690 ip->length = clib_host_to_net_u16 (length_val);
9696 ip->checksum = clib_host_to_net_u16 (checksum_val);
9703 unformat_ip6_match (unformat_input_t * input, va_list * args)
9705 u8 **matchp = va_arg (*args, u8 **);
9710 u8 traffic_class = 0;
9711 u32 traffic_class_val = 0;
9714 int src = 0, dst = 0;
9715 ip6_address_t src_val, dst_val;
9718 int payload_length = 0;
9719 u32 payload_length_val;
9722 u32 ip_version_traffic_class_and_flow_label;
9724 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9726 if (unformat (input, "version %d", &version_val))
9728 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9730 else if (unformat (input, "flow_label %d", &flow_label_val))
9732 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9734 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9736 else if (unformat (input, "proto %d", &proto_val))
9738 else if (unformat (input, "payload_length %d", &payload_length_val))
9740 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9746 if (version + traffic_class + flow_label + src + dst + proto +
9747 payload_length + hop_limit == 0)
9751 * Aligned because we use the real comparison functions
9753 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9755 ip = (ip6_header_t *) match;
9758 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9761 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9764 ip->protocol = proto_val;
9766 ip_version_traffic_class_and_flow_label = 0;
9769 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9772 ip_version_traffic_class_and_flow_label |=
9773 (traffic_class_val & 0xFF) << 20;
9776 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9778 ip->ip_version_traffic_class_and_flow_label =
9779 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9782 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9785 ip->hop_limit = hop_limit_val;
9792 unformat_l3_match (unformat_input_t * input, va_list * args)
9794 u8 **matchp = va_arg (*args, u8 **);
9796 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9798 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9800 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9809 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9811 u8 *tagp = va_arg (*args, u8 *);
9814 if (unformat (input, "%d", &tag))
9816 tagp[0] = (tag >> 8) & 0x0F;
9817 tagp[1] = tag & 0xFF;
9825 unformat_l2_match (unformat_input_t * input, va_list * args)
9827 u8 **matchp = va_arg (*args, u8 **);
9847 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9849 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9852 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9854 else if (unformat (input, "proto %U",
9855 unformat_ethernet_type_host_byte_order, &proto_val))
9857 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9859 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9861 else if (unformat (input, "ignore-tag1"))
9863 else if (unformat (input, "ignore-tag2"))
9865 else if (unformat (input, "cos1 %d", &cos1_val))
9867 else if (unformat (input, "cos2 %d", &cos2_val))
9872 if ((src + dst + proto + tag1 + tag2 +
9873 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9876 if (tag1 || ignore_tag1 || cos1)
9878 if (tag2 || ignore_tag2 || cos2)
9881 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9884 clib_memcpy (match, dst_val, 6);
9887 clib_memcpy (match + 6, src_val, 6);
9891 /* inner vlan tag */
9892 match[19] = tag2_val[1];
9893 match[18] = tag2_val[0];
9895 match[18] |= (cos2_val & 0x7) << 5;
9898 match[21] = proto_val & 0xff;
9899 match[20] = proto_val >> 8;
9903 match[15] = tag1_val[1];
9904 match[14] = tag1_val[0];
9907 match[14] |= (cos1_val & 0x7) << 5;
9913 match[15] = tag1_val[1];
9914 match[14] = tag1_val[0];
9917 match[17] = proto_val & 0xff;
9918 match[16] = proto_val >> 8;
9921 match[14] |= (cos1_val & 0x7) << 5;
9927 match[18] |= (cos2_val & 0x7) << 5;
9929 match[14] |= (cos1_val & 0x7) << 5;
9932 match[13] = proto_val & 0xff;
9933 match[12] = proto_val >> 8;
9942 api_unformat_classify_match (unformat_input_t * input, va_list * args)
9944 u8 **matchp = va_arg (*args, u8 **);
9945 u32 skip_n_vectors = va_arg (*args, u32);
9946 u32 match_n_vectors = va_arg (*args, u32);
9953 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9955 if (unformat (input, "hex %U", unformat_hex_string, &match))
9957 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9959 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9961 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9975 if (match || l2 || l3 || l4)
9979 /* "Win a free Ethernet header in every packet" */
9981 vec_validate_aligned (l2, 13, sizeof (u32x4));
9985 vec_append_aligned (match, l3, sizeof (u32x4));
9990 vec_append_aligned (match, l4, sizeof (u32x4));
9995 /* Make sure the vector is big enough even if key is all 0's */
9996 vec_validate_aligned
9997 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10000 /* Set size, include skipped vectors */
10001 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10012 api_classify_add_del_session (vat_main_t * vam)
10014 unformat_input_t *i = vam->input;
10015 vl_api_classify_add_del_session_t *mp;
10017 u32 table_index = ~0;
10018 u32 hit_next_index = ~0;
10019 u32 opaque_index = ~0;
10022 u32 skip_n_vectors = 0;
10023 u32 match_n_vectors = 0;
10029 * Warning: you have to supply skip_n and match_n
10030 * because the API client cant simply look at the classify
10034 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10036 if (unformat (i, "del"))
10038 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10041 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10044 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10047 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10049 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10051 else if (unformat (i, "opaque-index %d", &opaque_index))
10053 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10055 else if (unformat (i, "match_n %d", &match_n_vectors))
10057 else if (unformat (i, "match %U", api_unformat_classify_match,
10058 &match, skip_n_vectors, match_n_vectors))
10060 else if (unformat (i, "advance %d", &advance))
10062 else if (unformat (i, "table-index %d", &table_index))
10064 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10066 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10068 else if (unformat (i, "action %d", &action))
10070 else if (unformat (i, "metadata %d", &metadata))
10076 if (table_index == ~0)
10078 errmsg ("Table index required");
10082 if (is_add && match == 0)
10084 errmsg ("Match value required");
10088 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10090 mp->is_add = is_add;
10091 mp->table_index = ntohl (table_index);
10092 mp->hit_next_index = ntohl (hit_next_index);
10093 mp->opaque_index = ntohl (opaque_index);
10094 mp->advance = ntohl (advance);
10095 mp->action = action;
10096 mp->metadata = ntohl (metadata);
10097 clib_memcpy (mp->match, match, vec_len (match));
10106 api_classify_set_interface_ip_table (vat_main_t * vam)
10108 unformat_input_t *i = vam->input;
10109 vl_api_classify_set_interface_ip_table_t *mp;
10111 int sw_if_index_set;
10112 u32 table_index = ~0;
10116 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10118 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10119 sw_if_index_set = 1;
10120 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10121 sw_if_index_set = 1;
10122 else if (unformat (i, "table %d", &table_index))
10126 clib_warning ("parse error '%U'", format_unformat_error, i);
10131 if (sw_if_index_set == 0)
10133 errmsg ("missing interface name or sw_if_index");
10138 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10140 mp->sw_if_index = ntohl (sw_if_index);
10141 mp->table_index = ntohl (table_index);
10142 mp->is_ipv6 = is_ipv6;
10150 api_classify_set_interface_l2_tables (vat_main_t * vam)
10152 unformat_input_t *i = vam->input;
10153 vl_api_classify_set_interface_l2_tables_t *mp;
10155 int sw_if_index_set;
10156 u32 ip4_table_index = ~0;
10157 u32 ip6_table_index = ~0;
10158 u32 other_table_index = ~0;
10162 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10164 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10165 sw_if_index_set = 1;
10166 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10167 sw_if_index_set = 1;
10168 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10170 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10172 else if (unformat (i, "other-table %d", &other_table_index))
10174 else if (unformat (i, "is-input %d", &is_input))
10178 clib_warning ("parse error '%U'", format_unformat_error, i);
10183 if (sw_if_index_set == 0)
10185 errmsg ("missing interface name or sw_if_index");
10190 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10192 mp->sw_if_index = ntohl (sw_if_index);
10193 mp->ip4_table_index = ntohl (ip4_table_index);
10194 mp->ip6_table_index = ntohl (ip6_table_index);
10195 mp->other_table_index = ntohl (other_table_index);
10196 mp->is_input = (u8) is_input;
10204 api_set_ipfix_exporter (vat_main_t * vam)
10206 unformat_input_t *i = vam->input;
10207 vl_api_set_ipfix_exporter_t *mp;
10208 ip4_address_t collector_address;
10209 u8 collector_address_set = 0;
10210 u32 collector_port = ~0;
10211 ip4_address_t src_address;
10212 u8 src_address_set = 0;
10215 u32 template_interval = ~0;
10216 u8 udp_checksum = 0;
10219 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10221 if (unformat (i, "collector_address %U", unformat_ip4_address,
10222 &collector_address))
10223 collector_address_set = 1;
10224 else if (unformat (i, "collector_port %d", &collector_port))
10226 else if (unformat (i, "src_address %U", unformat_ip4_address,
10228 src_address_set = 1;
10229 else if (unformat (i, "vrf_id %d", &vrf_id))
10231 else if (unformat (i, "path_mtu %d", &path_mtu))
10233 else if (unformat (i, "template_interval %d", &template_interval))
10235 else if (unformat (i, "udp_checksum"))
10241 if (collector_address_set == 0)
10243 errmsg ("collector_address required");
10247 if (src_address_set == 0)
10249 errmsg ("src_address required");
10253 M (SET_IPFIX_EXPORTER, mp);
10255 memcpy (mp->collector_address, collector_address.data,
10256 sizeof (collector_address.data));
10257 mp->collector_port = htons ((u16) collector_port);
10258 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10259 mp->vrf_id = htonl (vrf_id);
10260 mp->path_mtu = htonl (path_mtu);
10261 mp->template_interval = htonl (template_interval);
10262 mp->udp_checksum = udp_checksum;
10270 api_set_ipfix_classify_stream (vat_main_t * vam)
10272 unformat_input_t *i = vam->input;
10273 vl_api_set_ipfix_classify_stream_t *mp;
10275 u32 src_port = UDP_DST_PORT_ipfix;
10278 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10280 if (unformat (i, "domain %d", &domain_id))
10282 else if (unformat (i, "src_port %d", &src_port))
10286 errmsg ("unknown input `%U'", format_unformat_error, i);
10291 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10293 mp->domain_id = htonl (domain_id);
10294 mp->src_port = htons ((u16) src_port);
10302 api_ipfix_classify_table_add_del (vat_main_t * vam)
10304 unformat_input_t *i = vam->input;
10305 vl_api_ipfix_classify_table_add_del_t *mp;
10307 u32 classify_table_index = ~0;
10309 u8 transport_protocol = 255;
10312 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10314 if (unformat (i, "add"))
10316 else if (unformat (i, "del"))
10318 else if (unformat (i, "table %d", &classify_table_index))
10320 else if (unformat (i, "ip4"))
10322 else if (unformat (i, "ip6"))
10324 else if (unformat (i, "tcp"))
10325 transport_protocol = 6;
10326 else if (unformat (i, "udp"))
10327 transport_protocol = 17;
10330 errmsg ("unknown input `%U'", format_unformat_error, i);
10337 errmsg ("expecting: add|del");
10340 if (classify_table_index == ~0)
10342 errmsg ("classifier table not specified");
10345 if (ip_version == 0)
10347 errmsg ("IP version not specified");
10351 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10353 mp->is_add = is_add;
10354 mp->table_id = htonl (classify_table_index);
10355 mp->ip_version = ip_version;
10356 mp->transport_protocol = transport_protocol;
10364 api_get_node_index (vat_main_t * vam)
10366 unformat_input_t *i = vam->input;
10367 vl_api_get_node_index_t *mp;
10371 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10373 if (unformat (i, "node %s", &name))
10380 errmsg ("node name required");
10383 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10385 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10389 M (GET_NODE_INDEX, mp);
10390 clib_memcpy (mp->node_name, name, vec_len (name));
10399 api_get_next_index (vat_main_t * vam)
10401 unformat_input_t *i = vam->input;
10402 vl_api_get_next_index_t *mp;
10403 u8 *node_name = 0, *next_node_name = 0;
10406 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10408 if (unformat (i, "node-name %s", &node_name))
10410 else if (unformat (i, "next-node-name %s", &next_node_name))
10414 if (node_name == 0)
10416 errmsg ("node name required");
10419 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10421 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10425 if (next_node_name == 0)
10427 errmsg ("next node name required");
10430 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10432 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10436 M (GET_NEXT_INDEX, mp);
10437 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10438 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10439 vec_free (node_name);
10440 vec_free (next_node_name);
10448 api_add_node_next (vat_main_t * vam)
10450 unformat_input_t *i = vam->input;
10451 vl_api_add_node_next_t *mp;
10456 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10458 if (unformat (i, "node %s", &name))
10460 else if (unformat (i, "next %s", &next))
10467 errmsg ("node name required");
10470 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10472 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10477 errmsg ("next node required");
10480 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10482 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10486 M (ADD_NODE_NEXT, mp);
10487 clib_memcpy (mp->node_name, name, vec_len (name));
10488 clib_memcpy (mp->next_name, next, vec_len (next));
10498 api_l2tpv3_create_tunnel (vat_main_t * vam)
10500 unformat_input_t *i = vam->input;
10501 ip6_address_t client_address, our_address;
10502 int client_address_set = 0;
10503 int our_address_set = 0;
10504 u32 local_session_id = 0;
10505 u32 remote_session_id = 0;
10506 u64 local_cookie = 0;
10507 u64 remote_cookie = 0;
10508 u8 l2_sublayer_present = 0;
10509 vl_api_l2tpv3_create_tunnel_t *mp;
10512 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10514 if (unformat (i, "client_address %U", unformat_ip6_address,
10516 client_address_set = 1;
10517 else if (unformat (i, "our_address %U", unformat_ip6_address,
10519 our_address_set = 1;
10520 else if (unformat (i, "local_session_id %d", &local_session_id))
10522 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10524 else if (unformat (i, "local_cookie %lld", &local_cookie))
10526 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10528 else if (unformat (i, "l2-sublayer-present"))
10529 l2_sublayer_present = 1;
10534 if (client_address_set == 0)
10536 errmsg ("client_address required");
10540 if (our_address_set == 0)
10542 errmsg ("our_address required");
10546 M (L2TPV3_CREATE_TUNNEL, mp);
10548 clib_memcpy (mp->client_address, client_address.as_u8,
10549 sizeof (mp->client_address));
10551 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10553 mp->local_session_id = ntohl (local_session_id);
10554 mp->remote_session_id = ntohl (remote_session_id);
10555 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10556 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10557 mp->l2_sublayer_present = l2_sublayer_present;
10566 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10568 unformat_input_t *i = vam->input;
10570 u8 sw_if_index_set = 0;
10571 u64 new_local_cookie = 0;
10572 u64 new_remote_cookie = 0;
10573 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10578 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10579 sw_if_index_set = 1;
10580 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10581 sw_if_index_set = 1;
10582 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10584 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10590 if (sw_if_index_set == 0)
10592 errmsg ("missing interface name or sw_if_index");
10596 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10598 mp->sw_if_index = ntohl (sw_if_index);
10599 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10600 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10608 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10610 unformat_input_t *i = vam->input;
10611 vl_api_l2tpv3_interface_enable_disable_t *mp;
10613 u8 sw_if_index_set = 0;
10614 u8 enable_disable = 1;
10617 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10619 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10620 sw_if_index_set = 1;
10621 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10622 sw_if_index_set = 1;
10623 else if (unformat (i, "enable"))
10624 enable_disable = 1;
10625 else if (unformat (i, "disable"))
10626 enable_disable = 0;
10631 if (sw_if_index_set == 0)
10633 errmsg ("missing interface name or sw_if_index");
10637 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10639 mp->sw_if_index = ntohl (sw_if_index);
10640 mp->enable_disable = enable_disable;
10648 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10650 unformat_input_t *i = vam->input;
10651 vl_api_l2tpv3_set_lookup_key_t *mp;
10655 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10657 if (unformat (i, "lookup_v6_src"))
10658 key = L2T_LOOKUP_SRC_ADDRESS;
10659 else if (unformat (i, "lookup_v6_dst"))
10660 key = L2T_LOOKUP_DST_ADDRESS;
10661 else if (unformat (i, "lookup_session_id"))
10662 key = L2T_LOOKUP_SESSION_ID;
10667 if (key == (u8) ~ 0)
10669 errmsg ("l2tp session lookup key unset");
10673 M (L2TPV3_SET_LOOKUP_KEY, mp);
10682 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10683 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10685 vat_main_t *vam = &vat_main;
10687 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10688 format_ip6_address, mp->our_address,
10689 format_ip6_address, mp->client_address,
10690 clib_net_to_host_u32 (mp->sw_if_index));
10693 " local cookies %016llx %016llx remote cookie %016llx",
10694 clib_net_to_host_u64 (mp->local_cookie[0]),
10695 clib_net_to_host_u64 (mp->local_cookie[1]),
10696 clib_net_to_host_u64 (mp->remote_cookie));
10698 print (vam->ofp, " local session-id %d remote session-id %d",
10699 clib_net_to_host_u32 (mp->local_session_id),
10700 clib_net_to_host_u32 (mp->remote_session_id));
10702 print (vam->ofp, " l2 specific sublayer %s\n",
10703 mp->l2_sublayer_present ? "preset" : "absent");
10707 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10708 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10710 vat_main_t *vam = &vat_main;
10711 vat_json_node_t *node = NULL;
10712 struct in6_addr addr;
10714 if (VAT_JSON_ARRAY != vam->json_tree.type)
10716 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10717 vat_json_init_array (&vam->json_tree);
10719 node = vat_json_array_add (&vam->json_tree);
10721 vat_json_init_object (node);
10723 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10724 vat_json_object_add_ip6 (node, "our_address", addr);
10725 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10726 vat_json_object_add_ip6 (node, "client_address", addr);
10728 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10729 vat_json_init_array (lc);
10730 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10731 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10732 vat_json_object_add_uint (node, "remote_cookie",
10733 clib_net_to_host_u64 (mp->remote_cookie));
10735 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10736 vat_json_object_add_uint (node, "local_session_id",
10737 clib_net_to_host_u32 (mp->local_session_id));
10738 vat_json_object_add_uint (node, "remote_session_id",
10739 clib_net_to_host_u32 (mp->remote_session_id));
10740 vat_json_object_add_string_copy (node, "l2_sublayer",
10741 mp->l2_sublayer_present ? (u8 *) "present"
10742 : (u8 *) "absent");
10746 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10748 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10749 vl_api_control_ping_t *mp_ping;
10752 /* Get list of l2tpv3-tunnel interfaces */
10753 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10756 /* Use a control ping for synchronization */
10757 M (CONTROL_PING, mp_ping);
10765 static void vl_api_sw_interface_tap_details_t_handler
10766 (vl_api_sw_interface_tap_details_t * mp)
10768 vat_main_t *vam = &vat_main;
10770 print (vam->ofp, "%-16s %d",
10771 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10774 static void vl_api_sw_interface_tap_details_t_handler_json
10775 (vl_api_sw_interface_tap_details_t * mp)
10777 vat_main_t *vam = &vat_main;
10778 vat_json_node_t *node = NULL;
10780 if (VAT_JSON_ARRAY != vam->json_tree.type)
10782 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10783 vat_json_init_array (&vam->json_tree);
10785 node = vat_json_array_add (&vam->json_tree);
10787 vat_json_init_object (node);
10788 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10789 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10793 api_sw_interface_tap_dump (vat_main_t * vam)
10795 vl_api_sw_interface_tap_dump_t *mp;
10796 vl_api_control_ping_t *mp_ping;
10799 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10800 /* Get list of tap interfaces */
10801 M (SW_INTERFACE_TAP_DUMP, mp);
10804 /* Use a control ping for synchronization */
10805 M (CONTROL_PING, mp_ping);
10812 static uword unformat_vxlan_decap_next
10813 (unformat_input_t * input, va_list * args)
10815 u32 *result = va_arg (*args, u32 *);
10818 if (unformat (input, "l2"))
10819 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10820 else if (unformat (input, "%d", &tmp))
10828 api_vxlan_add_del_tunnel (vat_main_t * vam)
10830 unformat_input_t *line_input = vam->input;
10831 vl_api_vxlan_add_del_tunnel_t *mp;
10832 ip46_address_t src, dst;
10834 u8 ipv4_set = 0, ipv6_set = 0;
10838 u32 mcast_sw_if_index = ~0;
10839 u32 encap_vrf_id = 0;
10840 u32 decap_next_index = ~0;
10844 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10845 memset (&src, 0, sizeof src);
10846 memset (&dst, 0, sizeof dst);
10848 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10850 if (unformat (line_input, "del"))
10853 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10859 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10865 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10871 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10876 else if (unformat (line_input, "group %U %U",
10877 unformat_ip4_address, &dst.ip4,
10878 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10880 grp_set = dst_set = 1;
10883 else if (unformat (line_input, "group %U",
10884 unformat_ip4_address, &dst.ip4))
10886 grp_set = dst_set = 1;
10889 else if (unformat (line_input, "group %U %U",
10890 unformat_ip6_address, &dst.ip6,
10891 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10893 grp_set = dst_set = 1;
10896 else if (unformat (line_input, "group %U",
10897 unformat_ip6_address, &dst.ip6))
10899 grp_set = dst_set = 1;
10903 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10905 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10907 else if (unformat (line_input, "decap-next %U",
10908 unformat_vxlan_decap_next, &decap_next_index))
10910 else if (unformat (line_input, "vni %d", &vni))
10914 errmsg ("parse error '%U'", format_unformat_error, line_input);
10921 errmsg ("tunnel src address not specified");
10926 errmsg ("tunnel dst address not specified");
10930 if (grp_set && !ip46_address_is_multicast (&dst))
10932 errmsg ("tunnel group address not multicast");
10935 if (grp_set && mcast_sw_if_index == ~0)
10937 errmsg ("tunnel nonexistent multicast device");
10940 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10942 errmsg ("tunnel dst address must be unicast");
10947 if (ipv4_set && ipv6_set)
10949 errmsg ("both IPv4 and IPv6 addresses specified");
10953 if ((vni == 0) || (vni >> 24))
10955 errmsg ("vni not specified or out of range");
10959 M (VXLAN_ADD_DEL_TUNNEL, mp);
10963 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10964 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10968 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10969 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10971 mp->encap_vrf_id = ntohl (encap_vrf_id);
10972 mp->decap_next_index = ntohl (decap_next_index);
10973 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10974 mp->vni = ntohl (vni);
10975 mp->is_add = is_add;
10976 mp->is_ipv6 = ipv6_set;
10983 static void vl_api_vxlan_tunnel_details_t_handler
10984 (vl_api_vxlan_tunnel_details_t * mp)
10986 vat_main_t *vam = &vat_main;
10987 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
10988 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
10990 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10991 ntohl (mp->sw_if_index),
10992 format_ip46_address, &src, IP46_TYPE_ANY,
10993 format_ip46_address, &dst, IP46_TYPE_ANY,
10994 ntohl (mp->encap_vrf_id),
10995 ntohl (mp->decap_next_index), ntohl (mp->vni),
10996 ntohl (mp->mcast_sw_if_index));
10999 static void vl_api_vxlan_tunnel_details_t_handler_json
11000 (vl_api_vxlan_tunnel_details_t * mp)
11002 vat_main_t *vam = &vat_main;
11003 vat_json_node_t *node = NULL;
11005 if (VAT_JSON_ARRAY != vam->json_tree.type)
11007 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11008 vat_json_init_array (&vam->json_tree);
11010 node = vat_json_array_add (&vam->json_tree);
11012 vat_json_init_object (node);
11013 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11016 struct in6_addr ip6;
11018 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
11019 vat_json_object_add_ip6 (node, "src_address", ip6);
11020 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
11021 vat_json_object_add_ip6 (node, "dst_address", ip6);
11025 struct in_addr ip4;
11027 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
11028 vat_json_object_add_ip4 (node, "src_address", ip4);
11029 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
11030 vat_json_object_add_ip4 (node, "dst_address", ip4);
11032 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11033 vat_json_object_add_uint (node, "decap_next_index",
11034 ntohl (mp->decap_next_index));
11035 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11036 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11037 vat_json_object_add_uint (node, "mcast_sw_if_index",
11038 ntohl (mp->mcast_sw_if_index));
11042 api_vxlan_tunnel_dump (vat_main_t * vam)
11044 unformat_input_t *i = vam->input;
11045 vl_api_vxlan_tunnel_dump_t *mp;
11046 vl_api_control_ping_t *mp_ping;
11048 u8 sw_if_index_set = 0;
11051 /* Parse args required to build the message */
11052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11054 if (unformat (i, "sw_if_index %d", &sw_if_index))
11055 sw_if_index_set = 1;
11060 if (sw_if_index_set == 0)
11065 if (!vam->json_output)
11067 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
11068 "sw_if_index", "src_address", "dst_address",
11069 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11072 /* Get list of vxlan-tunnel interfaces */
11073 M (VXLAN_TUNNEL_DUMP, mp);
11075 mp->sw_if_index = htonl (sw_if_index);
11079 /* Use a control ping for synchronization */
11080 M (CONTROL_PING, mp_ping);
11088 api_gre_add_del_tunnel (vat_main_t * vam)
11090 unformat_input_t *line_input = vam->input;
11091 vl_api_gre_add_del_tunnel_t *mp;
11092 ip4_address_t src4, dst4;
11093 ip6_address_t src6, dst6;
11100 u32 outer_fib_id = 0;
11103 memset (&src4, 0, sizeof src4);
11104 memset (&dst4, 0, sizeof dst4);
11105 memset (&src6, 0, sizeof src6);
11106 memset (&dst6, 0, sizeof dst6);
11108 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11110 if (unformat (line_input, "del"))
11112 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
11117 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
11122 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
11127 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
11132 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
11134 else if (unformat (line_input, "teb"))
11138 errmsg ("parse error '%U'", format_unformat_error, line_input);
11145 errmsg ("tunnel src address not specified");
11150 errmsg ("tunnel dst address not specified");
11153 if (ipv4_set && ipv6_set)
11155 errmsg ("both IPv4 and IPv6 addresses specified");
11160 M (GRE_ADD_DEL_TUNNEL, mp);
11164 clib_memcpy (&mp->src_address, &src4, 4);
11165 clib_memcpy (&mp->dst_address, &dst4, 4);
11169 clib_memcpy (&mp->src_address, &src6, 16);
11170 clib_memcpy (&mp->dst_address, &dst6, 16);
11172 mp->outer_fib_id = ntohl (outer_fib_id);
11173 mp->is_add = is_add;
11175 mp->is_ipv6 = ipv6_set;
11182 static void vl_api_gre_tunnel_details_t_handler
11183 (vl_api_gre_tunnel_details_t * mp)
11185 vat_main_t *vam = &vat_main;
11186 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
11187 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
11189 print (vam->ofp, "%11d%24U%24U%6d%14d",
11190 ntohl (mp->sw_if_index),
11191 format_ip46_address, &src, IP46_TYPE_ANY,
11192 format_ip46_address, &dst, IP46_TYPE_ANY,
11193 mp->teb, ntohl (mp->outer_fib_id));
11196 static void vl_api_gre_tunnel_details_t_handler_json
11197 (vl_api_gre_tunnel_details_t * mp)
11199 vat_main_t *vam = &vat_main;
11200 vat_json_node_t *node = NULL;
11201 struct in_addr ip4;
11202 struct in6_addr ip6;
11204 if (VAT_JSON_ARRAY != vam->json_tree.type)
11206 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11207 vat_json_init_array (&vam->json_tree);
11209 node = vat_json_array_add (&vam->json_tree);
11211 vat_json_init_object (node);
11212 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11215 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11216 vat_json_object_add_ip4 (node, "src_address", ip4);
11217 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11218 vat_json_object_add_ip4 (node, "dst_address", ip4);
11222 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
11223 vat_json_object_add_ip6 (node, "src_address", ip6);
11224 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
11225 vat_json_object_add_ip6 (node, "dst_address", ip6);
11227 vat_json_object_add_uint (node, "teb", mp->teb);
11228 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11229 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
11233 api_gre_tunnel_dump (vat_main_t * vam)
11235 unformat_input_t *i = vam->input;
11236 vl_api_gre_tunnel_dump_t *mp;
11237 vl_api_control_ping_t *mp_ping;
11239 u8 sw_if_index_set = 0;
11242 /* Parse args required to build the message */
11243 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11245 if (unformat (i, "sw_if_index %d", &sw_if_index))
11246 sw_if_index_set = 1;
11251 if (sw_if_index_set == 0)
11256 if (!vam->json_output)
11258 print (vam->ofp, "%11s%24s%24s%6s%14s",
11259 "sw_if_index", "src_address", "dst_address", "teb",
11263 /* Get list of gre-tunnel interfaces */
11264 M (GRE_TUNNEL_DUMP, mp);
11266 mp->sw_if_index = htonl (sw_if_index);
11270 /* Use a control ping for synchronization */
11271 M (CONTROL_PING, mp_ping);
11279 api_l2_fib_clear_table (vat_main_t * vam)
11281 // unformat_input_t * i = vam->input;
11282 vl_api_l2_fib_clear_table_t *mp;
11285 M (L2_FIB_CLEAR_TABLE, mp);
11293 api_l2_interface_efp_filter (vat_main_t * vam)
11295 unformat_input_t *i = vam->input;
11296 vl_api_l2_interface_efp_filter_t *mp;
11299 u8 sw_if_index_set = 0;
11302 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11304 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11305 sw_if_index_set = 1;
11306 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11307 sw_if_index_set = 1;
11308 else if (unformat (i, "enable"))
11310 else if (unformat (i, "disable"))
11314 clib_warning ("parse error '%U'", format_unformat_error, i);
11319 if (sw_if_index_set == 0)
11321 errmsg ("missing sw_if_index");
11325 M (L2_INTERFACE_EFP_FILTER, mp);
11327 mp->sw_if_index = ntohl (sw_if_index);
11328 mp->enable_disable = enable;
11335 #define foreach_vtr_op \
11336 _("disable", L2_VTR_DISABLED) \
11337 _("push-1", L2_VTR_PUSH_1) \
11338 _("push-2", L2_VTR_PUSH_2) \
11339 _("pop-1", L2_VTR_POP_1) \
11340 _("pop-2", L2_VTR_POP_2) \
11341 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11342 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11343 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11344 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11347 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11349 unformat_input_t *i = vam->input;
11350 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11352 u8 sw_if_index_set = 0;
11355 u32 push_dot1q = 1;
11360 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11362 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11363 sw_if_index_set = 1;
11364 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11365 sw_if_index_set = 1;
11366 else if (unformat (i, "vtr_op %d", &vtr_op))
11368 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11371 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11373 else if (unformat (i, "tag1 %d", &tag1))
11375 else if (unformat (i, "tag2 %d", &tag2))
11379 clib_warning ("parse error '%U'", format_unformat_error, i);
11384 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11386 errmsg ("missing vtr operation or sw_if_index");
11390 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11391 mp->sw_if_index = ntohl (sw_if_index);
11392 mp->vtr_op = ntohl (vtr_op);
11393 mp->push_dot1q = ntohl (push_dot1q);
11394 mp->tag1 = ntohl (tag1);
11395 mp->tag2 = ntohl (tag2);
11403 api_create_vhost_user_if (vat_main_t * vam)
11405 unformat_input_t *i = vam->input;
11406 vl_api_create_vhost_user_if_t *mp;
11409 u8 file_name_set = 0;
11410 u32 custom_dev_instance = ~0;
11412 u8 use_custom_mac = 0;
11415 u8 operation_mode = VHOST_USER_POLLING_MODE;
11417 /* Shut up coverity */
11418 memset (hwaddr, 0, sizeof (hwaddr));
11420 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11422 if (unformat (i, "socket %s", &file_name))
11426 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11428 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11429 use_custom_mac = 1;
11430 else if (unformat (i, "server"))
11432 else if (unformat (i, "tag %s", &tag))
11434 else if (unformat (i, "mode %U",
11435 api_unformat_vhost_user_operation_mode,
11442 if (file_name_set == 0)
11444 errmsg ("missing socket file name");
11448 if (vec_len (file_name) > 255)
11450 errmsg ("socket file name too long");
11453 vec_add1 (file_name, 0);
11455 M (CREATE_VHOST_USER_IF, mp);
11457 mp->operation_mode = operation_mode;
11458 mp->is_server = is_server;
11459 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11460 vec_free (file_name);
11461 if (custom_dev_instance != ~0)
11464 mp->custom_dev_instance = ntohl (custom_dev_instance);
11466 mp->use_custom_mac = use_custom_mac;
11467 clib_memcpy (mp->mac_address, hwaddr, 6);
11469 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11478 api_modify_vhost_user_if (vat_main_t * vam)
11480 unformat_input_t *i = vam->input;
11481 vl_api_modify_vhost_user_if_t *mp;
11484 u8 file_name_set = 0;
11485 u32 custom_dev_instance = ~0;
11486 u8 sw_if_index_set = 0;
11487 u32 sw_if_index = (u32) ~ 0;
11489 u8 operation_mode = VHOST_USER_POLLING_MODE;
11491 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11493 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11494 sw_if_index_set = 1;
11495 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11496 sw_if_index_set = 1;
11497 else if (unformat (i, "socket %s", &file_name))
11501 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11503 else if (unformat (i, "server"))
11505 else if (unformat (i, "mode %U",
11506 api_unformat_vhost_user_operation_mode,
11513 if (sw_if_index_set == 0)
11515 errmsg ("missing sw_if_index or interface name");
11519 if (file_name_set == 0)
11521 errmsg ("missing socket file name");
11525 if (vec_len (file_name) > 255)
11527 errmsg ("socket file name too long");
11530 vec_add1 (file_name, 0);
11532 M (MODIFY_VHOST_USER_IF, mp);
11534 mp->operation_mode = operation_mode;
11535 mp->sw_if_index = ntohl (sw_if_index);
11536 mp->is_server = is_server;
11537 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11538 vec_free (file_name);
11539 if (custom_dev_instance != ~0)
11542 mp->custom_dev_instance = ntohl (custom_dev_instance);
11551 api_delete_vhost_user_if (vat_main_t * vam)
11553 unformat_input_t *i = vam->input;
11554 vl_api_delete_vhost_user_if_t *mp;
11555 u32 sw_if_index = ~0;
11556 u8 sw_if_index_set = 0;
11559 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11561 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11562 sw_if_index_set = 1;
11563 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11564 sw_if_index_set = 1;
11569 if (sw_if_index_set == 0)
11571 errmsg ("missing sw_if_index or interface name");
11576 M (DELETE_VHOST_USER_IF, mp);
11578 mp->sw_if_index = ntohl (sw_if_index);
11585 static void vl_api_sw_interface_vhost_user_details_t_handler
11586 (vl_api_sw_interface_vhost_user_details_t * mp)
11588 vat_main_t *vam = &vat_main;
11590 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %U %s",
11591 (char *) mp->interface_name,
11592 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11593 clib_net_to_host_u64 (mp->features), mp->is_server,
11594 ntohl (mp->num_regions), api_format_vhost_user_operation_mode,
11595 mp->operation_mode, (char *) mp->sock_filename);
11596 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11599 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11600 (vl_api_sw_interface_vhost_user_details_t * mp)
11602 vat_main_t *vam = &vat_main;
11603 vat_json_node_t *node = NULL;
11605 if (VAT_JSON_ARRAY != vam->json_tree.type)
11607 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11608 vat_json_init_array (&vam->json_tree);
11610 node = vat_json_array_add (&vam->json_tree);
11612 vat_json_init_object (node);
11613 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11614 vat_json_object_add_string_copy (node, "interface_name",
11615 mp->interface_name);
11616 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11617 ntohl (mp->virtio_net_hdr_sz));
11618 vat_json_object_add_uint (node, "features",
11619 clib_net_to_host_u64 (mp->features));
11620 vat_json_object_add_uint (node, "is_server", mp->is_server);
11621 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11622 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11623 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11624 vat_json_object_add_uint (node, "mode", mp->operation_mode);
11628 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11630 vl_api_sw_interface_vhost_user_dump_t *mp;
11631 vl_api_control_ping_t *mp_ping;
11634 "Interface name idx hdr_sz features server regions mode"
11637 /* Get list of vhost-user interfaces */
11638 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11641 /* Use a control ping for synchronization */
11642 M (CONTROL_PING, mp_ping);
11650 api_show_version (vat_main_t * vam)
11652 vl_api_show_version_t *mp;
11655 M (SHOW_VERSION, mp);
11664 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11666 unformat_input_t *line_input = vam->input;
11667 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11668 ip4_address_t local4, remote4;
11669 ip6_address_t local6, remote6;
11671 u8 ipv4_set = 0, ipv6_set = 0;
11674 u32 encap_vrf_id = 0;
11675 u32 decap_vrf_id = 0;
11681 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11683 if (unformat (line_input, "del"))
11685 else if (unformat (line_input, "local %U",
11686 unformat_ip4_address, &local4))
11691 else if (unformat (line_input, "remote %U",
11692 unformat_ip4_address, &remote4))
11697 else if (unformat (line_input, "local %U",
11698 unformat_ip6_address, &local6))
11703 else if (unformat (line_input, "remote %U",
11704 unformat_ip6_address, &remote6))
11709 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11711 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11713 else if (unformat (line_input, "vni %d", &vni))
11715 else if (unformat (line_input, "next-ip4"))
11717 else if (unformat (line_input, "next-ip6"))
11719 else if (unformat (line_input, "next-ethernet"))
11721 else if (unformat (line_input, "next-nsh"))
11725 errmsg ("parse error '%U'", format_unformat_error, line_input);
11730 if (local_set == 0)
11732 errmsg ("tunnel local address not specified");
11735 if (remote_set == 0)
11737 errmsg ("tunnel remote address not specified");
11740 if (ipv4_set && ipv6_set)
11742 errmsg ("both IPv4 and IPv6 addresses specified");
11748 errmsg ("vni not specified");
11752 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11757 clib_memcpy (&mp->local, &local6, sizeof (local6));
11758 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11762 clib_memcpy (&mp->local, &local4, sizeof (local4));
11763 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11766 mp->encap_vrf_id = ntohl (encap_vrf_id);
11767 mp->decap_vrf_id = ntohl (decap_vrf_id);
11768 mp->protocol = protocol;
11769 mp->vni = ntohl (vni);
11770 mp->is_add = is_add;
11771 mp->is_ipv6 = ipv6_set;
11778 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11779 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11781 vat_main_t *vam = &vat_main;
11783 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11784 ntohl (mp->sw_if_index),
11785 format_ip46_address, &(mp->local[0]),
11786 format_ip46_address, &(mp->remote[0]),
11788 ntohl (mp->protocol),
11789 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11792 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11793 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11795 vat_main_t *vam = &vat_main;
11796 vat_json_node_t *node = NULL;
11797 struct in_addr ip4;
11798 struct in6_addr ip6;
11800 if (VAT_JSON_ARRAY != vam->json_tree.type)
11802 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11803 vat_json_init_array (&vam->json_tree);
11805 node = vat_json_array_add (&vam->json_tree);
11807 vat_json_init_object (node);
11808 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11811 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11812 vat_json_object_add_ip6 (node, "local", ip6);
11813 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11814 vat_json_object_add_ip6 (node, "remote", ip6);
11818 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11819 vat_json_object_add_ip4 (node, "local", ip4);
11820 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11821 vat_json_object_add_ip4 (node, "remote", ip4);
11823 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11824 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11825 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11826 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11827 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11831 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11833 unformat_input_t *i = vam->input;
11834 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11835 vl_api_control_ping_t *mp_ping;
11837 u8 sw_if_index_set = 0;
11840 /* Parse args required to build the message */
11841 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11843 if (unformat (i, "sw_if_index %d", &sw_if_index))
11844 sw_if_index_set = 1;
11849 if (sw_if_index_set == 0)
11854 if (!vam->json_output)
11856 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11857 "sw_if_index", "local", "remote", "vni",
11858 "protocol", "encap_vrf_id", "decap_vrf_id");
11861 /* Get list of vxlan-tunnel interfaces */
11862 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11864 mp->sw_if_index = htonl (sw_if_index);
11868 /* Use a control ping for synchronization */
11869 M (CONTROL_PING, mp_ping);
11877 format_l2_fib_mac_address (u8 * s, va_list * args)
11879 u8 *a = va_arg (*args, u8 *);
11881 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11882 a[2], a[3], a[4], a[5], a[6], a[7]);
11885 static void vl_api_l2_fib_table_entry_t_handler
11886 (vl_api_l2_fib_table_entry_t * mp)
11888 vat_main_t *vam = &vat_main;
11890 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11892 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11893 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11897 static void vl_api_l2_fib_table_entry_t_handler_json
11898 (vl_api_l2_fib_table_entry_t * mp)
11900 vat_main_t *vam = &vat_main;
11901 vat_json_node_t *node = NULL;
11903 if (VAT_JSON_ARRAY != vam->json_tree.type)
11905 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11906 vat_json_init_array (&vam->json_tree);
11908 node = vat_json_array_add (&vam->json_tree);
11910 vat_json_init_object (node);
11911 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11912 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11913 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11914 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11915 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11916 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11920 api_l2_fib_table_dump (vat_main_t * vam)
11922 unformat_input_t *i = vam->input;
11923 vl_api_l2_fib_table_dump_t *mp;
11924 vl_api_control_ping_t *mp_ping;
11929 /* Parse args required to build the message */
11930 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11932 if (unformat (i, "bd_id %d", &bd_id))
11938 if (bd_id_set == 0)
11940 errmsg ("missing bridge domain");
11944 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11946 /* Get list of l2 fib entries */
11947 M (L2_FIB_TABLE_DUMP, mp);
11949 mp->bd_id = ntohl (bd_id);
11952 /* Use a control ping for synchronization */
11953 M (CONTROL_PING, mp_ping);
11962 api_interface_name_renumber (vat_main_t * vam)
11964 unformat_input_t *line_input = vam->input;
11965 vl_api_interface_name_renumber_t *mp;
11966 u32 sw_if_index = ~0;
11967 u32 new_show_dev_instance = ~0;
11970 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11972 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11975 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11977 else if (unformat (line_input, "new_show_dev_instance %d",
11978 &new_show_dev_instance))
11984 if (sw_if_index == ~0)
11986 errmsg ("missing interface name or sw_if_index");
11990 if (new_show_dev_instance == ~0)
11992 errmsg ("missing new_show_dev_instance");
11996 M (INTERFACE_NAME_RENUMBER, mp);
11998 mp->sw_if_index = ntohl (sw_if_index);
11999 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
12007 api_want_ip4_arp_events (vat_main_t * vam)
12009 unformat_input_t *line_input = vam->input;
12010 vl_api_want_ip4_arp_events_t *mp;
12011 ip4_address_t address;
12012 int address_set = 0;
12013 u32 enable_disable = 1;
12016 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12018 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
12020 else if (unformat (line_input, "del"))
12021 enable_disable = 0;
12026 if (address_set == 0)
12028 errmsg ("missing addresses");
12032 M (WANT_IP4_ARP_EVENTS, mp);
12033 mp->enable_disable = enable_disable;
12034 mp->pid = htonl (getpid ());
12035 mp->address = address.as_u32;
12043 api_want_ip6_nd_events (vat_main_t * vam)
12045 unformat_input_t *line_input = vam->input;
12046 vl_api_want_ip6_nd_events_t *mp;
12047 ip6_address_t address;
12048 int address_set = 0;
12049 u32 enable_disable = 1;
12052 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12054 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
12056 else if (unformat (line_input, "del"))
12057 enable_disable = 0;
12062 if (address_set == 0)
12064 errmsg ("missing addresses");
12068 M (WANT_IP6_ND_EVENTS, mp);
12069 mp->enable_disable = enable_disable;
12070 mp->pid = htonl (getpid ());
12071 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
12079 api_input_acl_set_interface (vat_main_t * vam)
12081 unformat_input_t *i = vam->input;
12082 vl_api_input_acl_set_interface_t *mp;
12084 int sw_if_index_set;
12085 u32 ip4_table_index = ~0;
12086 u32 ip6_table_index = ~0;
12087 u32 l2_table_index = ~0;
12091 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12093 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12094 sw_if_index_set = 1;
12095 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12096 sw_if_index_set = 1;
12097 else if (unformat (i, "del"))
12099 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12101 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12103 else if (unformat (i, "l2-table %d", &l2_table_index))
12107 clib_warning ("parse error '%U'", format_unformat_error, i);
12112 if (sw_if_index_set == 0)
12114 errmsg ("missing interface name or sw_if_index");
12118 M (INPUT_ACL_SET_INTERFACE, mp);
12120 mp->sw_if_index = ntohl (sw_if_index);
12121 mp->ip4_table_index = ntohl (ip4_table_index);
12122 mp->ip6_table_index = ntohl (ip6_table_index);
12123 mp->l2_table_index = ntohl (l2_table_index);
12124 mp->is_add = is_add;
12132 api_ip_address_dump (vat_main_t * vam)
12134 unformat_input_t *i = vam->input;
12135 vl_api_ip_address_dump_t *mp;
12136 vl_api_control_ping_t *mp_ping;
12137 u32 sw_if_index = ~0;
12138 u8 sw_if_index_set = 0;
12143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12145 if (unformat (i, "sw_if_index %d", &sw_if_index))
12146 sw_if_index_set = 1;
12148 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12149 sw_if_index_set = 1;
12150 else if (unformat (i, "ipv4"))
12152 else if (unformat (i, "ipv6"))
12158 if (ipv4_set && ipv6_set)
12160 errmsg ("ipv4 and ipv6 flags cannot be both set");
12164 if ((!ipv4_set) && (!ipv6_set))
12166 errmsg ("no ipv4 nor ipv6 flag set");
12170 if (sw_if_index_set == 0)
12172 errmsg ("missing interface name or sw_if_index");
12176 vam->current_sw_if_index = sw_if_index;
12177 vam->is_ipv6 = ipv6_set;
12179 M (IP_ADDRESS_DUMP, mp);
12180 mp->sw_if_index = ntohl (sw_if_index);
12181 mp->is_ipv6 = ipv6_set;
12184 /* Use a control ping for synchronization */
12185 M (CONTROL_PING, mp_ping);
12193 api_ip_dump (vat_main_t * vam)
12195 vl_api_ip_dump_t *mp;
12196 vl_api_control_ping_t *mp_ping;
12197 unformat_input_t *in = vam->input;
12204 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
12206 if (unformat (in, "ipv4"))
12208 else if (unformat (in, "ipv6"))
12214 if (ipv4_set && ipv6_set)
12216 errmsg ("ipv4 and ipv6 flags cannot be both set");
12220 if ((!ipv4_set) && (!ipv6_set))
12222 errmsg ("no ipv4 nor ipv6 flag set");
12226 is_ipv6 = ipv6_set;
12227 vam->is_ipv6 = is_ipv6;
12229 /* free old data */
12230 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12232 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12234 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12237 mp->is_ipv6 = ipv6_set;
12240 /* Use a control ping for synchronization */
12241 M (CONTROL_PING, mp_ping);
12249 api_ipsec_spd_add_del (vat_main_t * vam)
12251 unformat_input_t *i = vam->input;
12252 vl_api_ipsec_spd_add_del_t *mp;
12257 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12259 if (unformat (i, "spd_id %d", &spd_id))
12261 else if (unformat (i, "del"))
12265 clib_warning ("parse error '%U'", format_unformat_error, i);
12271 errmsg ("spd_id must be set");
12275 M (IPSEC_SPD_ADD_DEL, mp);
12277 mp->spd_id = ntohl (spd_id);
12278 mp->is_add = is_add;
12286 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12288 unformat_input_t *i = vam->input;
12289 vl_api_ipsec_interface_add_del_spd_t *mp;
12291 u8 sw_if_index_set = 0;
12292 u32 spd_id = (u32) ~ 0;
12296 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12298 if (unformat (i, "del"))
12300 else if (unformat (i, "spd_id %d", &spd_id))
12303 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12304 sw_if_index_set = 1;
12305 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12306 sw_if_index_set = 1;
12309 clib_warning ("parse error '%U'", format_unformat_error, i);
12315 if (spd_id == (u32) ~ 0)
12317 errmsg ("spd_id must be set");
12321 if (sw_if_index_set == 0)
12323 errmsg ("missing interface name or sw_if_index");
12327 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12329 mp->spd_id = ntohl (spd_id);
12330 mp->sw_if_index = ntohl (sw_if_index);
12331 mp->is_add = is_add;
12339 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12341 unformat_input_t *i = vam->input;
12342 vl_api_ipsec_spd_add_del_entry_t *mp;
12343 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12344 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12346 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12347 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12348 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12349 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12352 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12353 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12354 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12355 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12356 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12357 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12359 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12361 if (unformat (i, "del"))
12363 if (unformat (i, "outbound"))
12365 if (unformat (i, "inbound"))
12367 else if (unformat (i, "spd_id %d", &spd_id))
12369 else if (unformat (i, "sa_id %d", &sa_id))
12371 else if (unformat (i, "priority %d", &priority))
12373 else if (unformat (i, "protocol %d", &protocol))
12375 else if (unformat (i, "lport_start %d", &lport_start))
12377 else if (unformat (i, "lport_stop %d", &lport_stop))
12379 else if (unformat (i, "rport_start %d", &rport_start))
12381 else if (unformat (i, "rport_stop %d", &rport_stop))
12385 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12391 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12398 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12404 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12411 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12417 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12424 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12430 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12436 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12438 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12440 clib_warning ("unsupported action: 'resolve'");
12446 clib_warning ("parse error '%U'", format_unformat_error, i);
12452 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12454 mp->spd_id = ntohl (spd_id);
12455 mp->priority = ntohl (priority);
12456 mp->is_outbound = is_outbound;
12458 mp->is_ipv6 = is_ipv6;
12459 if (is_ipv6 || is_ip_any)
12461 clib_memcpy (mp->remote_address_start, &raddr6_start,
12462 sizeof (ip6_address_t));
12463 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12464 sizeof (ip6_address_t));
12465 clib_memcpy (mp->local_address_start, &laddr6_start,
12466 sizeof (ip6_address_t));
12467 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12468 sizeof (ip6_address_t));
12472 clib_memcpy (mp->remote_address_start, &raddr4_start,
12473 sizeof (ip4_address_t));
12474 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12475 sizeof (ip4_address_t));
12476 clib_memcpy (mp->local_address_start, &laddr4_start,
12477 sizeof (ip4_address_t));
12478 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12479 sizeof (ip4_address_t));
12481 mp->protocol = (u8) protocol;
12482 mp->local_port_start = ntohs ((u16) lport_start);
12483 mp->local_port_stop = ntohs ((u16) lport_stop);
12484 mp->remote_port_start = ntohs ((u16) rport_start);
12485 mp->remote_port_stop = ntohs ((u16) rport_stop);
12486 mp->policy = (u8) policy;
12487 mp->sa_id = ntohl (sa_id);
12488 mp->is_add = is_add;
12489 mp->is_ip_any = is_ip_any;
12496 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12498 unformat_input_t *i = vam->input;
12499 vl_api_ipsec_sad_add_del_entry_t *mp;
12500 u32 sad_id = 0, spi = 0;
12501 u8 *ck = 0, *ik = 0;
12504 u8 protocol = IPSEC_PROTOCOL_AH;
12505 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12506 u32 crypto_alg = 0, integ_alg = 0;
12507 ip4_address_t tun_src4;
12508 ip4_address_t tun_dst4;
12509 ip6_address_t tun_src6;
12510 ip6_address_t tun_dst6;
12513 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12515 if (unformat (i, "del"))
12517 else if (unformat (i, "sad_id %d", &sad_id))
12519 else if (unformat (i, "spi %d", &spi))
12521 else if (unformat (i, "esp"))
12522 protocol = IPSEC_PROTOCOL_ESP;
12523 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12526 is_tunnel_ipv6 = 0;
12528 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12531 is_tunnel_ipv6 = 0;
12533 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12536 is_tunnel_ipv6 = 1;
12538 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12541 is_tunnel_ipv6 = 1;
12545 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12547 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12548 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12550 clib_warning ("unsupported crypto-alg: '%U'",
12551 format_ipsec_crypto_alg, crypto_alg);
12555 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12559 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12561 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12562 integ_alg >= IPSEC_INTEG_N_ALG)
12564 clib_warning ("unsupported integ-alg: '%U'",
12565 format_ipsec_integ_alg, integ_alg);
12569 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12573 clib_warning ("parse error '%U'", format_unformat_error, i);
12579 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12581 mp->sad_id = ntohl (sad_id);
12582 mp->is_add = is_add;
12583 mp->protocol = protocol;
12584 mp->spi = ntohl (spi);
12585 mp->is_tunnel = is_tunnel;
12586 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12587 mp->crypto_algorithm = crypto_alg;
12588 mp->integrity_algorithm = integ_alg;
12589 mp->crypto_key_length = vec_len (ck);
12590 mp->integrity_key_length = vec_len (ik);
12592 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12593 mp->crypto_key_length = sizeof (mp->crypto_key);
12595 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12596 mp->integrity_key_length = sizeof (mp->integrity_key);
12599 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12601 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12605 if (is_tunnel_ipv6)
12607 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12608 sizeof (ip6_address_t));
12609 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12610 sizeof (ip6_address_t));
12614 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12615 sizeof (ip4_address_t));
12616 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12617 sizeof (ip4_address_t));
12627 api_ipsec_sa_set_key (vat_main_t * vam)
12629 unformat_input_t *i = vam->input;
12630 vl_api_ipsec_sa_set_key_t *mp;
12632 u8 *ck = 0, *ik = 0;
12635 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12637 if (unformat (i, "sa_id %d", &sa_id))
12639 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12641 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12645 clib_warning ("parse error '%U'", format_unformat_error, i);
12650 M (IPSEC_SA_SET_KEY, mp);
12652 mp->sa_id = ntohl (sa_id);
12653 mp->crypto_key_length = vec_len (ck);
12654 mp->integrity_key_length = vec_len (ik);
12656 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12657 mp->crypto_key_length = sizeof (mp->crypto_key);
12659 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12660 mp->integrity_key_length = sizeof (mp->integrity_key);
12663 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12665 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12673 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
12675 unformat_input_t *i = vam->input;
12676 vl_api_ipsec_tunnel_if_add_del_t *mp;
12677 u32 local_spi = 0, remote_spi = 0;
12678 u32 crypto_alg = 0, integ_alg = 0;
12679 u8 *lck = NULL, *rck = NULL;
12680 u8 *lik = NULL, *rik = NULL;
12681 ip4_address_t local_ip = { {0} };
12682 ip4_address_t remote_ip = { {0} };
12685 u8 anti_replay = 0;
12688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12690 if (unformat (i, "del"))
12692 else if (unformat (i, "esn"))
12694 else if (unformat (i, "anti_replay"))
12696 else if (unformat (i, "local_spi %d", &local_spi))
12698 else if (unformat (i, "remote_spi %d", &remote_spi))
12700 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
12702 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
12704 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
12707 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
12709 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
12711 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
12715 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12717 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12718 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12720 errmsg ("unsupported crypto-alg: '%U'\n",
12721 format_ipsec_crypto_alg, crypto_alg);
12727 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12729 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12730 integ_alg >= IPSEC_INTEG_N_ALG)
12732 errmsg ("unsupported integ-alg: '%U'\n",
12733 format_ipsec_integ_alg, integ_alg);
12739 errmsg ("parse error '%U'\n", format_unformat_error, i);
12744 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
12746 mp->is_add = is_add;
12748 mp->anti_replay = anti_replay;
12750 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
12751 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
12753 mp->local_spi = htonl (local_spi);
12754 mp->remote_spi = htonl (remote_spi);
12755 mp->crypto_alg = (u8) crypto_alg;
12757 mp->local_crypto_key_len = 0;
12760 mp->local_crypto_key_len = vec_len (lck);
12761 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
12762 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
12763 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
12766 mp->remote_crypto_key_len = 0;
12769 mp->remote_crypto_key_len = vec_len (rck);
12770 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
12771 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
12772 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
12775 mp->integ_alg = (u8) integ_alg;
12777 mp->local_integ_key_len = 0;
12780 mp->local_integ_key_len = vec_len (lik);
12781 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
12782 mp->local_integ_key_len = sizeof (mp->local_integ_key);
12783 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
12786 mp->remote_integ_key_len = 0;
12789 mp->remote_integ_key_len = vec_len (rik);
12790 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
12791 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
12792 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
12801 api_ikev2_profile_add_del (vat_main_t * vam)
12803 unformat_input_t *i = vam->input;
12804 vl_api_ikev2_profile_add_del_t *mp;
12809 const char *valid_chars = "a-zA-Z0-9_";
12811 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12813 if (unformat (i, "del"))
12815 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12816 vec_add1 (name, 0);
12819 errmsg ("parse error '%U'", format_unformat_error, i);
12824 if (!vec_len (name))
12826 errmsg ("profile name must be specified");
12830 if (vec_len (name) > 64)
12832 errmsg ("profile name too long");
12836 M (IKEV2_PROFILE_ADD_DEL, mp);
12838 clib_memcpy (mp->name, name, vec_len (name));
12839 mp->is_add = is_add;
12848 api_ikev2_profile_set_auth (vat_main_t * vam)
12850 unformat_input_t *i = vam->input;
12851 vl_api_ikev2_profile_set_auth_t *mp;
12854 u32 auth_method = 0;
12858 const char *valid_chars = "a-zA-Z0-9_";
12860 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12862 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12863 vec_add1 (name, 0);
12864 else if (unformat (i, "auth_method %U",
12865 unformat_ikev2_auth_method, &auth_method))
12867 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12869 else if (unformat (i, "auth_data %v", &data))
12873 errmsg ("parse error '%U'", format_unformat_error, i);
12878 if (!vec_len (name))
12880 errmsg ("profile name must be specified");
12884 if (vec_len (name) > 64)
12886 errmsg ("profile name too long");
12890 if (!vec_len (data))
12892 errmsg ("auth_data must be specified");
12898 errmsg ("auth_method must be specified");
12902 M (IKEV2_PROFILE_SET_AUTH, mp);
12904 mp->is_hex = is_hex;
12905 mp->auth_method = (u8) auth_method;
12906 mp->data_len = vec_len (data);
12907 clib_memcpy (mp->name, name, vec_len (name));
12908 clib_memcpy (mp->data, data, vec_len (data));
12918 api_ikev2_profile_set_id (vat_main_t * vam)
12920 unformat_input_t *i = vam->input;
12921 vl_api_ikev2_profile_set_id_t *mp;
12929 const char *valid_chars = "a-zA-Z0-9_";
12931 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12933 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12934 vec_add1 (name, 0);
12935 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12937 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12939 data = vec_new (u8, 4);
12940 clib_memcpy (data, ip4.as_u8, 4);
12942 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12944 else if (unformat (i, "id_data %v", &data))
12946 else if (unformat (i, "local"))
12948 else if (unformat (i, "remote"))
12952 errmsg ("parse error '%U'", format_unformat_error, i);
12957 if (!vec_len (name))
12959 errmsg ("profile name must be specified");
12963 if (vec_len (name) > 64)
12965 errmsg ("profile name too long");
12969 if (!vec_len (data))
12971 errmsg ("id_data must be specified");
12977 errmsg ("id_type must be specified");
12981 M (IKEV2_PROFILE_SET_ID, mp);
12983 mp->is_local = is_local;
12984 mp->id_type = (u8) id_type;
12985 mp->data_len = vec_len (data);
12986 clib_memcpy (mp->name, name, vec_len (name));
12987 clib_memcpy (mp->data, data, vec_len (data));
12997 api_ikev2_profile_set_ts (vat_main_t * vam)
12999 unformat_input_t *i = vam->input;
13000 vl_api_ikev2_profile_set_ts_t *mp;
13003 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
13004 ip4_address_t start_addr, end_addr;
13006 const char *valid_chars = "a-zA-Z0-9_";
13009 start_addr.as_u32 = 0;
13010 end_addr.as_u32 = (u32) ~ 0;
13012 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13014 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13015 vec_add1 (name, 0);
13016 else if (unformat (i, "protocol %d", &proto))
13018 else if (unformat (i, "start_port %d", &start_port))
13020 else if (unformat (i, "end_port %d", &end_port))
13023 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
13025 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
13027 else if (unformat (i, "local"))
13029 else if (unformat (i, "remote"))
13033 errmsg ("parse error '%U'", format_unformat_error, i);
13038 if (!vec_len (name))
13040 errmsg ("profile name must be specified");
13044 if (vec_len (name) > 64)
13046 errmsg ("profile name too long");
13050 M (IKEV2_PROFILE_SET_TS, mp);
13052 mp->is_local = is_local;
13053 mp->proto = (u8) proto;
13054 mp->start_port = (u16) start_port;
13055 mp->end_port = (u16) end_port;
13056 mp->start_addr = start_addr.as_u32;
13057 mp->end_addr = end_addr.as_u32;
13058 clib_memcpy (mp->name, name, vec_len (name));
13067 api_ikev2_set_local_key (vat_main_t * vam)
13069 unformat_input_t *i = vam->input;
13070 vl_api_ikev2_set_local_key_t *mp;
13074 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13076 if (unformat (i, "file %v", &file))
13077 vec_add1 (file, 0);
13080 errmsg ("parse error '%U'", format_unformat_error, i);
13085 if (!vec_len (file))
13087 errmsg ("RSA key file must be specified");
13091 if (vec_len (file) > 256)
13093 errmsg ("file name too long");
13097 M (IKEV2_SET_LOCAL_KEY, mp);
13099 clib_memcpy (mp->key_file, file, vec_len (file));
13108 api_ikev2_set_responder (vat_main_t * vam)
13110 unformat_input_t *i = vam->input;
13111 vl_api_ikev2_set_responder_t *mp;
13114 u32 sw_if_index = ~0;
13115 ip4_address_t address;
13117 const char *valid_chars = "a-zA-Z0-9_";
13119 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13122 (i, "%U interface %d address %U", unformat_token, valid_chars,
13123 &name, &sw_if_index, unformat_ip4_address, &address))
13124 vec_add1 (name, 0);
13127 errmsg ("parse error '%U'", format_unformat_error, i);
13132 if (!vec_len (name))
13134 errmsg ("profile name must be specified");
13138 if (vec_len (name) > 64)
13140 errmsg ("profile name too long");
13144 M (IKEV2_SET_RESPONDER, mp);
13146 clib_memcpy (mp->name, name, vec_len (name));
13149 mp->sw_if_index = sw_if_index;
13150 clib_memcpy (mp->address, &address, sizeof (address));
13158 api_ikev2_set_ike_transforms (vat_main_t * vam)
13160 unformat_input_t *i = vam->input;
13161 vl_api_ikev2_set_ike_transforms_t *mp;
13164 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13166 const char *valid_chars = "a-zA-Z0-9_";
13168 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13170 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13171 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13172 vec_add1 (name, 0);
13175 errmsg ("parse error '%U'", format_unformat_error, i);
13180 if (!vec_len (name))
13182 errmsg ("profile name must be specified");
13186 if (vec_len (name) > 64)
13188 errmsg ("profile name too long");
13192 M (IKEV2_SET_IKE_TRANSFORMS, mp);
13194 clib_memcpy (mp->name, name, vec_len (name));
13196 mp->crypto_alg = crypto_alg;
13197 mp->crypto_key_size = crypto_key_size;
13198 mp->integ_alg = integ_alg;
13199 mp->dh_group = dh_group;
13208 api_ikev2_set_esp_transforms (vat_main_t * vam)
13210 unformat_input_t *i = vam->input;
13211 vl_api_ikev2_set_esp_transforms_t *mp;
13214 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13216 const char *valid_chars = "a-zA-Z0-9_";
13218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13220 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13221 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13222 vec_add1 (name, 0);
13225 errmsg ("parse error '%U'", format_unformat_error, i);
13230 if (!vec_len (name))
13232 errmsg ("profile name must be specified");
13236 if (vec_len (name) > 64)
13238 errmsg ("profile name too long");
13242 M (IKEV2_SET_ESP_TRANSFORMS, mp);
13244 clib_memcpy (mp->name, name, vec_len (name));
13246 mp->crypto_alg = crypto_alg;
13247 mp->crypto_key_size = crypto_key_size;
13248 mp->integ_alg = integ_alg;
13249 mp->dh_group = dh_group;
13257 api_ikev2_set_sa_lifetime (vat_main_t * vam)
13259 unformat_input_t *i = vam->input;
13260 vl_api_ikev2_set_sa_lifetime_t *mp;
13263 u64 lifetime, lifetime_maxdata;
13264 u32 lifetime_jitter, handover;
13266 const char *valid_chars = "a-zA-Z0-9_";
13268 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13270 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
13271 &lifetime, &lifetime_jitter, &handover,
13272 &lifetime_maxdata))
13273 vec_add1 (name, 0);
13276 errmsg ("parse error '%U'", format_unformat_error, i);
13281 if (!vec_len (name))
13283 errmsg ("profile name must be specified");
13287 if (vec_len (name) > 64)
13289 errmsg ("profile name too long");
13293 M (IKEV2_SET_SA_LIFETIME, mp);
13295 clib_memcpy (mp->name, name, vec_len (name));
13297 mp->lifetime = lifetime;
13298 mp->lifetime_jitter = lifetime_jitter;
13299 mp->handover = handover;
13300 mp->lifetime_maxdata = lifetime_maxdata;
13308 api_ikev2_initiate_sa_init (vat_main_t * vam)
13310 unformat_input_t *i = vam->input;
13311 vl_api_ikev2_initiate_sa_init_t *mp;
13315 const char *valid_chars = "a-zA-Z0-9_";
13317 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13319 if (unformat (i, "%U", unformat_token, valid_chars, &name))
13320 vec_add1 (name, 0);
13323 errmsg ("parse error '%U'", format_unformat_error, i);
13328 if (!vec_len (name))
13330 errmsg ("profile name must be specified");
13334 if (vec_len (name) > 64)
13336 errmsg ("profile name too long");
13340 M (IKEV2_INITIATE_SA_INIT, mp);
13342 clib_memcpy (mp->name, name, vec_len (name));
13351 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
13353 unformat_input_t *i = vam->input;
13354 vl_api_ikev2_initiate_del_ike_sa_t *mp;
13359 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13361 if (unformat (i, "%lx", &ispi))
13365 errmsg ("parse error '%U'", format_unformat_error, i);
13370 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
13380 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13382 unformat_input_t *i = vam->input;
13383 vl_api_ikev2_initiate_del_child_sa_t *mp;
13388 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13390 if (unformat (i, "%x", &ispi))
13394 errmsg ("parse error '%U'", format_unformat_error, i);
13399 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13409 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13411 unformat_input_t *i = vam->input;
13412 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13417 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13419 if (unformat (i, "%x", &ispi))
13423 errmsg ("parse error '%U'", format_unformat_error, i);
13428 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
13441 api_map_add_domain (vat_main_t * vam)
13443 unformat_input_t *i = vam->input;
13444 vl_api_map_add_domain_t *mp;
13446 ip4_address_t ip4_prefix;
13447 ip6_address_t ip6_prefix;
13448 ip6_address_t ip6_src;
13449 u32 num_m_args = 0;
13450 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
13451 0, psid_length = 0;
13452 u8 is_translation = 0;
13454 u32 ip6_src_len = 128;
13457 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13459 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
13460 &ip4_prefix, &ip4_prefix_len))
13462 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
13463 &ip6_prefix, &ip6_prefix_len))
13467 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
13470 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
13472 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
13474 else if (unformat (i, "psid-offset %d", &psid_offset))
13476 else if (unformat (i, "psid-len %d", &psid_length))
13478 else if (unformat (i, "mtu %d", &mtu))
13480 else if (unformat (i, "map-t"))
13481 is_translation = 1;
13484 clib_warning ("parse error '%U'", format_unformat_error, i);
13489 if (num_m_args < 3)
13491 errmsg ("mandatory argument(s) missing");
13495 /* Construct the API message */
13496 M (MAP_ADD_DOMAIN, mp);
13498 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
13499 mp->ip4_prefix_len = ip4_prefix_len;
13501 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
13502 mp->ip6_prefix_len = ip6_prefix_len;
13504 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
13505 mp->ip6_src_prefix_len = ip6_src_len;
13507 mp->ea_bits_len = ea_bits_len;
13508 mp->psid_offset = psid_offset;
13509 mp->psid_length = psid_length;
13510 mp->is_translation = is_translation;
13511 mp->mtu = htons (mtu);
13516 /* Wait for a reply, return good/bad news */
13522 api_map_del_domain (vat_main_t * vam)
13524 unformat_input_t *i = vam->input;
13525 vl_api_map_del_domain_t *mp;
13527 u32 num_m_args = 0;
13531 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13533 if (unformat (i, "index %d", &index))
13537 clib_warning ("parse error '%U'", format_unformat_error, i);
13542 if (num_m_args != 1)
13544 errmsg ("mandatory argument(s) missing");
13548 /* Construct the API message */
13549 M (MAP_DEL_DOMAIN, mp);
13551 mp->index = ntohl (index);
13556 /* Wait for a reply, return good/bad news */
13562 api_map_add_del_rule (vat_main_t * vam)
13564 unformat_input_t *i = vam->input;
13565 vl_api_map_add_del_rule_t *mp;
13567 ip6_address_t ip6_dst;
13568 u32 num_m_args = 0, index, psid = 0;
13571 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13573 if (unformat (i, "index %d", &index))
13575 else if (unformat (i, "psid %d", &psid))
13577 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13579 else if (unformat (i, "del"))
13585 clib_warning ("parse error '%U'", format_unformat_error, i);
13590 /* Construct the API message */
13591 M (MAP_ADD_DEL_RULE, mp);
13593 mp->index = ntohl (index);
13594 mp->is_add = is_add;
13595 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13596 mp->psid = ntohs (psid);
13601 /* Wait for a reply, return good/bad news */
13607 api_map_domain_dump (vat_main_t * vam)
13609 vl_api_map_domain_dump_t *mp;
13610 vl_api_control_ping_t *mp_ping;
13613 /* Construct the API message */
13614 M (MAP_DOMAIN_DUMP, mp);
13619 /* Use a control ping for synchronization */
13620 M (CONTROL_PING, mp_ping);
13628 api_map_rule_dump (vat_main_t * vam)
13630 unformat_input_t *i = vam->input;
13631 vl_api_map_rule_dump_t *mp;
13632 vl_api_control_ping_t *mp_ping;
13633 u32 domain_index = ~0;
13636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13638 if (unformat (i, "index %u", &domain_index))
13644 if (domain_index == ~0)
13646 clib_warning ("parse error: domain index expected");
13650 /* Construct the API message */
13651 M (MAP_RULE_DUMP, mp);
13653 mp->domain_index = htonl (domain_index);
13658 /* Use a control ping for synchronization */
13659 M (CONTROL_PING, mp_ping);
13666 static void vl_api_map_add_domain_reply_t_handler
13667 (vl_api_map_add_domain_reply_t * mp)
13669 vat_main_t *vam = &vat_main;
13670 i32 retval = ntohl (mp->retval);
13672 if (vam->async_mode)
13674 vam->async_errors += (retval < 0);
13678 vam->retval = retval;
13679 vam->result_ready = 1;
13683 static void vl_api_map_add_domain_reply_t_handler_json
13684 (vl_api_map_add_domain_reply_t * mp)
13686 vat_main_t *vam = &vat_main;
13687 vat_json_node_t node;
13689 vat_json_init_object (&node);
13690 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13691 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13693 vat_json_print (vam->ofp, &node);
13694 vat_json_free (&node);
13696 vam->retval = ntohl (mp->retval);
13697 vam->result_ready = 1;
13701 api_get_first_msg_id (vat_main_t * vam)
13703 vl_api_get_first_msg_id_t *mp;
13704 unformat_input_t *i = vam->input;
13709 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13711 if (unformat (i, "client %s", &name))
13719 errmsg ("missing client name");
13722 vec_add1 (name, 0);
13724 if (vec_len (name) > 63)
13726 errmsg ("client name too long");
13730 M (GET_FIRST_MSG_ID, mp);
13731 clib_memcpy (mp->name, name, vec_len (name));
13738 api_cop_interface_enable_disable (vat_main_t * vam)
13740 unformat_input_t *line_input = vam->input;
13741 vl_api_cop_interface_enable_disable_t *mp;
13742 u32 sw_if_index = ~0;
13743 u8 enable_disable = 1;
13746 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13748 if (unformat (line_input, "disable"))
13749 enable_disable = 0;
13750 if (unformat (line_input, "enable"))
13751 enable_disable = 1;
13752 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13753 vam, &sw_if_index))
13755 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13761 if (sw_if_index == ~0)
13763 errmsg ("missing interface name or sw_if_index");
13767 /* Construct the API message */
13768 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13769 mp->sw_if_index = ntohl (sw_if_index);
13770 mp->enable_disable = enable_disable;
13774 /* Wait for the reply */
13780 api_cop_whitelist_enable_disable (vat_main_t * vam)
13782 unformat_input_t *line_input = vam->input;
13783 vl_api_cop_whitelist_enable_disable_t *mp;
13784 u32 sw_if_index = ~0;
13785 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13789 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13791 if (unformat (line_input, "ip4"))
13793 else if (unformat (line_input, "ip6"))
13795 else if (unformat (line_input, "default"))
13797 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13798 vam, &sw_if_index))
13800 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13802 else if (unformat (line_input, "fib-id %d", &fib_id))
13808 if (sw_if_index == ~0)
13810 errmsg ("missing interface name or sw_if_index");
13814 /* Construct the API message */
13815 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13816 mp->sw_if_index = ntohl (sw_if_index);
13817 mp->fib_id = ntohl (fib_id);
13820 mp->default_cop = default_cop;
13824 /* Wait for the reply */
13830 api_get_node_graph (vat_main_t * vam)
13832 vl_api_get_node_graph_t *mp;
13835 M (GET_NODE_GRAPH, mp);
13839 /* Wait for the reply */
13845 /** Used for parsing LISP eids */
13846 typedef CLIB_PACKED(struct{
13847 u8 addr[16]; /**< eid address */
13848 u32 len; /**< prefix length if IP */
13849 u8 type; /**< type of eid */
13854 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13856 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13858 memset (a, 0, sizeof (a[0]));
13860 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13862 a->type = 0; /* ipv4 type */
13864 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13866 a->type = 1; /* ipv6 type */
13868 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13870 a->type = 2; /* mac type */
13877 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13886 lisp_eid_size_vat (u8 type)
13901 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13903 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13907 api_one_add_del_locator_set (vat_main_t * vam)
13909 unformat_input_t *input = vam->input;
13910 vl_api_one_add_del_locator_set_t *mp;
13912 u8 *locator_set_name = NULL;
13913 u8 locator_set_name_set = 0;
13914 vl_api_local_locator_t locator, *locators = 0;
13915 u32 sw_if_index, priority, weight;
13919 /* Parse args required to build the message */
13920 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13922 if (unformat (input, "del"))
13926 else if (unformat (input, "locator-set %s", &locator_set_name))
13928 locator_set_name_set = 1;
13930 else if (unformat (input, "sw_if_index %u p %u w %u",
13931 &sw_if_index, &priority, &weight))
13933 locator.sw_if_index = htonl (sw_if_index);
13934 locator.priority = priority;
13935 locator.weight = weight;
13936 vec_add1 (locators, locator);
13940 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13941 &sw_if_index, &priority, &weight))
13943 locator.sw_if_index = htonl (sw_if_index);
13944 locator.priority = priority;
13945 locator.weight = weight;
13946 vec_add1 (locators, locator);
13952 if (locator_set_name_set == 0)
13954 errmsg ("missing locator-set name");
13955 vec_free (locators);
13959 if (vec_len (locator_set_name) > 64)
13961 errmsg ("locator-set name too long");
13962 vec_free (locator_set_name);
13963 vec_free (locators);
13966 vec_add1 (locator_set_name, 0);
13968 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13970 /* Construct the API message */
13971 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
13973 mp->is_add = is_add;
13974 clib_memcpy (mp->locator_set_name, locator_set_name,
13975 vec_len (locator_set_name));
13976 vec_free (locator_set_name);
13978 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13980 clib_memcpy (mp->locators, locators, data_len);
13981 vec_free (locators);
13986 /* Wait for a reply... */
13991 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
13994 api_one_add_del_locator (vat_main_t * vam)
13996 unformat_input_t *input = vam->input;
13997 vl_api_one_add_del_locator_t *mp;
13998 u32 tmp_if_index = ~0;
13999 u32 sw_if_index = ~0;
14000 u8 sw_if_index_set = 0;
14001 u8 sw_if_index_if_name_set = 0;
14003 u8 priority_set = 0;
14007 u8 *locator_set_name = NULL;
14008 u8 locator_set_name_set = 0;
14011 /* Parse args required to build the message */
14012 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14014 if (unformat (input, "del"))
14018 else if (unformat (input, "locator-set %s", &locator_set_name))
14020 locator_set_name_set = 1;
14022 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14025 sw_if_index_if_name_set = 1;
14026 sw_if_index = tmp_if_index;
14028 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14030 sw_if_index_set = 1;
14031 sw_if_index = tmp_if_index;
14033 else if (unformat (input, "p %d", &priority))
14037 else if (unformat (input, "w %d", &weight))
14045 if (locator_set_name_set == 0)
14047 errmsg ("missing locator-set name");
14051 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14053 errmsg ("missing sw_if_index");
14054 vec_free (locator_set_name);
14058 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14060 errmsg ("cannot use both params interface name and sw_if_index");
14061 vec_free (locator_set_name);
14065 if (priority_set == 0)
14067 errmsg ("missing locator-set priority");
14068 vec_free (locator_set_name);
14072 if (weight_set == 0)
14074 errmsg ("missing locator-set weight");
14075 vec_free (locator_set_name);
14079 if (vec_len (locator_set_name) > 64)
14081 errmsg ("locator-set name too long");
14082 vec_free (locator_set_name);
14085 vec_add1 (locator_set_name, 0);
14087 /* Construct the API message */
14088 M (ONE_ADD_DEL_LOCATOR, mp);
14090 mp->is_add = is_add;
14091 mp->sw_if_index = ntohl (sw_if_index);
14092 mp->priority = priority;
14093 mp->weight = weight;
14094 clib_memcpy (mp->locator_set_name, locator_set_name,
14095 vec_len (locator_set_name));
14096 vec_free (locator_set_name);
14101 /* Wait for a reply... */
14106 #define api_lisp_add_del_locator api_one_add_del_locator
14109 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14111 u32 *key_id = va_arg (*args, u32 *);
14114 if (unformat (input, "%s", &s))
14116 if (!strcmp ((char *) s, "sha1"))
14117 key_id[0] = HMAC_SHA_1_96;
14118 else if (!strcmp ((char *) s, "sha256"))
14119 key_id[0] = HMAC_SHA_256_128;
14122 clib_warning ("invalid key_id: '%s'", s);
14123 key_id[0] = HMAC_NO_KEY;
14134 api_one_add_del_local_eid (vat_main_t * vam)
14136 unformat_input_t *input = vam->input;
14137 vl_api_one_add_del_local_eid_t *mp;
14140 lisp_eid_vat_t _eid, *eid = &_eid;
14141 u8 *locator_set_name = 0;
14142 u8 locator_set_name_set = 0;
14148 /* Parse args required to build the message */
14149 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14151 if (unformat (input, "del"))
14155 else if (unformat (input, "vni %d", &vni))
14159 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14163 else if (unformat (input, "locator-set %s", &locator_set_name))
14165 locator_set_name_set = 1;
14167 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14169 else if (unformat (input, "secret-key %_%v%_", &key))
14175 if (locator_set_name_set == 0)
14177 errmsg ("missing locator-set name");
14183 errmsg ("EID address not set!");
14184 vec_free (locator_set_name);
14188 if (key && (0 == key_id))
14190 errmsg ("invalid key_id!");
14194 if (vec_len (key) > 64)
14196 errmsg ("key too long");
14201 if (vec_len (locator_set_name) > 64)
14203 errmsg ("locator-set name too long");
14204 vec_free (locator_set_name);
14207 vec_add1 (locator_set_name, 0);
14209 /* Construct the API message */
14210 M (ONE_ADD_DEL_LOCAL_EID, mp);
14212 mp->is_add = is_add;
14213 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14214 mp->eid_type = eid->type;
14215 mp->prefix_len = eid->len;
14216 mp->vni = clib_host_to_net_u32 (vni);
14217 mp->key_id = clib_host_to_net_u16 (key_id);
14218 clib_memcpy (mp->locator_set_name, locator_set_name,
14219 vec_len (locator_set_name));
14220 clib_memcpy (mp->key, key, vec_len (key));
14222 vec_free (locator_set_name);
14228 /* Wait for a reply... */
14233 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14236 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14238 u32 dp_table = 0, vni = 0;;
14239 unformat_input_t *input = vam->input;
14240 vl_api_gpe_add_del_fwd_entry_t *mp;
14242 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14243 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14244 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14245 u32 action = ~0, w;
14246 ip4_address_t rmt_rloc4, lcl_rloc4;
14247 ip6_address_t rmt_rloc6, lcl_rloc6;
14248 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14251 memset (&rloc, 0, sizeof (rloc));
14253 /* Parse args required to build the message */
14254 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14256 if (unformat (input, "del"))
14258 else if (unformat (input, "add"))
14260 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14264 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14268 else if (unformat (input, "vrf %d", &dp_table))
14270 else if (unformat (input, "bd %d", &dp_table))
14272 else if (unformat (input, "vni %d", &vni))
14274 else if (unformat (input, "w %d", &w))
14278 errmsg ("No RLOC configured for setting priority/weight!");
14281 curr_rloc->weight = w;
14283 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14284 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14288 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
14290 vec_add1 (lcl_locs, rloc);
14292 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
14293 vec_add1 (rmt_locs, rloc);
14294 /* weight saved in rmt loc */
14295 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14297 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14298 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14301 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
14303 vec_add1 (lcl_locs, rloc);
14305 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
14306 vec_add1 (rmt_locs, rloc);
14307 /* weight saved in rmt loc */
14308 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14310 else if (unformat (input, "action %d", &action))
14316 clib_warning ("parse error '%U'", format_unformat_error, input);
14323 errmsg ("remote eid addresses not set");
14327 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14329 errmsg ("eid types don't match");
14333 if (0 == rmt_locs && (u32) ~ 0 == action)
14335 errmsg ("action not set for negative mapping");
14339 /* Construct the API message */
14340 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14341 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14343 mp->is_add = is_add;
14344 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14345 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14346 mp->eid_type = rmt_eid->type;
14347 mp->dp_table = clib_host_to_net_u32 (dp_table);
14348 mp->vni = clib_host_to_net_u32 (vni);
14349 mp->rmt_len = rmt_eid->len;
14350 mp->lcl_len = lcl_eid->len;
14351 mp->action = action;
14353 if (0 != rmt_locs && 0 != lcl_locs)
14355 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14356 clib_memcpy (mp->locs, lcl_locs,
14357 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14359 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14360 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14361 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14363 vec_free (lcl_locs);
14364 vec_free (rmt_locs);
14369 /* Wait for a reply... */
14375 api_one_add_del_map_server (vat_main_t * vam)
14377 unformat_input_t *input = vam->input;
14378 vl_api_one_add_del_map_server_t *mp;
14382 ip4_address_t ipv4;
14383 ip6_address_t ipv6;
14386 /* Parse args required to build the message */
14387 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14389 if (unformat (input, "del"))
14393 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14397 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14405 if (ipv4_set && ipv6_set)
14407 errmsg ("both eid v4 and v6 addresses set");
14411 if (!ipv4_set && !ipv6_set)
14413 errmsg ("eid addresses not set");
14417 /* Construct the API message */
14418 M (ONE_ADD_DEL_MAP_SERVER, mp);
14420 mp->is_add = is_add;
14424 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14429 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14435 /* Wait for a reply... */
14440 #define api_lisp_add_del_map_server api_one_add_del_map_server
14443 api_one_add_del_map_resolver (vat_main_t * vam)
14445 unformat_input_t *input = vam->input;
14446 vl_api_one_add_del_map_resolver_t *mp;
14450 ip4_address_t ipv4;
14451 ip6_address_t ipv6;
14454 /* Parse args required to build the message */
14455 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14457 if (unformat (input, "del"))
14461 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14465 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14473 if (ipv4_set && ipv6_set)
14475 errmsg ("both eid v4 and v6 addresses set");
14479 if (!ipv4_set && !ipv6_set)
14481 errmsg ("eid addresses not set");
14485 /* Construct the API message */
14486 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14488 mp->is_add = is_add;
14492 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14497 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14503 /* Wait for a reply... */
14508 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14511 api_lisp_gpe_enable_disable (vat_main_t * vam)
14513 unformat_input_t *input = vam->input;
14514 vl_api_gpe_enable_disable_t *mp;
14519 /* Parse args required to build the message */
14520 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14522 if (unformat (input, "enable"))
14527 else if (unformat (input, "disable"))
14538 errmsg ("Value not set");
14542 /* Construct the API message */
14543 M (GPE_ENABLE_DISABLE, mp);
14550 /* Wait for a reply... */
14556 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14558 unformat_input_t *input = vam->input;
14559 vl_api_one_rloc_probe_enable_disable_t *mp;
14564 /* Parse args required to build the message */
14565 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14567 if (unformat (input, "enable"))
14572 else if (unformat (input, "disable"))
14580 errmsg ("Value not set");
14584 /* Construct the API message */
14585 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14587 mp->is_enabled = is_en;
14592 /* Wait for a reply... */
14597 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14600 api_one_map_register_enable_disable (vat_main_t * vam)
14602 unformat_input_t *input = vam->input;
14603 vl_api_one_map_register_enable_disable_t *mp;
14608 /* Parse args required to build the message */
14609 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14611 if (unformat (input, "enable"))
14616 else if (unformat (input, "disable"))
14624 errmsg ("Value not set");
14628 /* Construct the API message */
14629 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14631 mp->is_enabled = is_en;
14636 /* Wait for a reply... */
14641 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14644 api_one_enable_disable (vat_main_t * vam)
14646 unformat_input_t *input = vam->input;
14647 vl_api_one_enable_disable_t *mp;
14652 /* Parse args required to build the message */
14653 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14655 if (unformat (input, "enable"))
14660 else if (unformat (input, "disable"))
14670 errmsg ("Value not set");
14674 /* Construct the API message */
14675 M (ONE_ENABLE_DISABLE, mp);
14682 /* Wait for a reply... */
14687 #define api_lisp_enable_disable api_one_enable_disable
14690 api_show_one_map_register_state (vat_main_t * vam)
14692 vl_api_show_one_map_register_state_t *mp;
14695 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14700 /* wait for reply */
14705 #define api_show_lisp_map_register_state api_show_one_map_register_state
14708 api_show_one_rloc_probe_state (vat_main_t * vam)
14710 vl_api_show_one_rloc_probe_state_t *mp;
14713 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14718 /* wait for reply */
14723 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14726 api_one_stats_enable_disable (vat_main_t * vam)
14728 vl_api_one_stats_enable_disable_t *mp;
14729 unformat_input_t *input = vam->input;
14734 /* Parse args required to build the message */
14735 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14737 if (unformat (input, "enable"))
14742 else if (unformat (input, "disable"))
14752 errmsg ("Value not set");
14756 M (ONE_STATS_ENABLE_DISABLE, mp);
14762 /* wait for reply */
14768 api_show_one_stats_enable_disable (vat_main_t * vam)
14770 vl_api_show_one_stats_enable_disable_t *mp;
14773 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
14778 /* wait for reply */
14784 api_show_one_map_request_mode (vat_main_t * vam)
14786 vl_api_show_one_map_request_mode_t *mp;
14789 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
14794 /* wait for reply */
14799 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
14802 api_one_map_request_mode (vat_main_t * vam)
14804 unformat_input_t *input = vam->input;
14805 vl_api_one_map_request_mode_t *mp;
14809 /* Parse args required to build the message */
14810 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14812 if (unformat (input, "dst-only"))
14814 else if (unformat (input, "src-dst"))
14818 errmsg ("parse error '%U'", format_unformat_error, input);
14823 M (ONE_MAP_REQUEST_MODE, mp);
14830 /* wait for reply */
14835 #define api_lisp_map_request_mode api_one_map_request_mode
14838 * Enable/disable ONE proxy ITR.
14840 * @param vam vpp API test context
14841 * @return return code
14844 api_one_pitr_set_locator_set (vat_main_t * vam)
14846 u8 ls_name_set = 0;
14847 unformat_input_t *input = vam->input;
14848 vl_api_one_pitr_set_locator_set_t *mp;
14853 /* Parse args required to build the message */
14854 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14856 if (unformat (input, "del"))
14858 else if (unformat (input, "locator-set %s", &ls_name))
14862 errmsg ("parse error '%U'", format_unformat_error, input);
14869 errmsg ("locator-set name not set!");
14873 M (ONE_PITR_SET_LOCATOR_SET, mp);
14875 mp->is_add = is_add;
14876 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14877 vec_free (ls_name);
14882 /* wait for reply */
14887 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
14890 api_show_one_pitr (vat_main_t * vam)
14892 vl_api_show_one_pitr_t *mp;
14895 if (!vam->json_output)
14897 print (vam->ofp, "%=20s", "lisp status:");
14900 M (SHOW_ONE_PITR, mp);
14904 /* Wait for a reply... */
14909 #define api_show_lisp_pitr api_show_one_pitr
14912 api_one_use_petr (vat_main_t * vam)
14914 unformat_input_t *input = vam->input;
14915 vl_api_one_use_petr_t *mp;
14920 memset (&ip, 0, sizeof (ip));
14922 /* Parse args required to build the message */
14923 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14925 if (unformat (input, "disable"))
14928 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
14931 ip_addr_version (&ip) = IP4;
14934 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
14937 ip_addr_version (&ip) = IP6;
14941 errmsg ("parse error '%U'", format_unformat_error, input);
14946 M (ONE_USE_PETR, mp);
14948 mp->is_add = is_add;
14951 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
14953 clib_memcpy (mp->address, &ip, 4);
14955 clib_memcpy (mp->address, &ip, 16);
14961 /* wait for reply */
14966 #define api_lisp_use_petr api_one_use_petr
14969 api_show_one_use_petr (vat_main_t * vam)
14971 vl_api_show_one_use_petr_t *mp;
14974 if (!vam->json_output)
14976 print (vam->ofp, "%=20s", "Proxy-ETR status:");
14979 M (SHOW_ONE_USE_PETR, mp);
14983 /* Wait for a reply... */
14988 #define api_show_lisp_use_petr api_show_one_use_petr
14991 * Add/delete mapping between vni and vrf
14994 api_one_eid_table_add_del_map (vat_main_t * vam)
14996 unformat_input_t *input = vam->input;
14997 vl_api_one_eid_table_add_del_map_t *mp;
14998 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
14999 u32 vni, vrf, bd_index;
15002 /* Parse args required to build the message */
15003 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15005 if (unformat (input, "del"))
15007 else if (unformat (input, "vrf %d", &vrf))
15009 else if (unformat (input, "bd_index %d", &bd_index))
15011 else if (unformat (input, "vni %d", &vni))
15017 if (!vni_set || (!vrf_set && !bd_index_set))
15019 errmsg ("missing arguments!");
15023 if (vrf_set && bd_index_set)
15025 errmsg ("error: both vrf and bd entered!");
15029 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15031 mp->is_add = is_add;
15032 mp->vni = htonl (vni);
15033 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15034 mp->is_l2 = bd_index_set;
15039 /* wait for reply */
15044 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15047 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15049 u32 *action = va_arg (*args, u32 *);
15052 if (unformat (input, "%s", &s))
15054 if (!strcmp ((char *) s, "no-action"))
15056 else if (!strcmp ((char *) s, "natively-forward"))
15058 else if (!strcmp ((char *) s, "send-map-request"))
15060 else if (!strcmp ((char *) s, "drop"))
15064 clib_warning ("invalid action: '%s'", s);
15076 * Add/del remote mapping to/from ONE control plane
15078 * @param vam vpp API test context
15079 * @return return code
15082 api_one_add_del_remote_mapping (vat_main_t * vam)
15084 unformat_input_t *input = vam->input;
15085 vl_api_one_add_del_remote_mapping_t *mp;
15087 lisp_eid_vat_t _eid, *eid = &_eid;
15088 lisp_eid_vat_t _seid, *seid = &_seid;
15089 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15090 u32 action = ~0, p, w, data_len;
15091 ip4_address_t rloc4;
15092 ip6_address_t rloc6;
15093 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15096 memset (&rloc, 0, sizeof (rloc));
15098 /* Parse args required to build the message */
15099 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15101 if (unformat (input, "del-all"))
15105 else if (unformat (input, "del"))
15109 else if (unformat (input, "add"))
15113 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15117 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15121 else if (unformat (input, "vni %d", &vni))
15125 else if (unformat (input, "p %d w %d", &p, &w))
15129 errmsg ("No RLOC configured for setting priority/weight!");
15132 curr_rloc->priority = p;
15133 curr_rloc->weight = w;
15135 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15138 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
15139 vec_add1 (rlocs, rloc);
15140 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15142 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15145 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
15146 vec_add1 (rlocs, rloc);
15147 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15149 else if (unformat (input, "action %U",
15150 unformat_negative_mapping_action, &action))
15156 clib_warning ("parse error '%U'", format_unformat_error, input);
15163 errmsg ("missing params!");
15167 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15169 errmsg ("no action set for negative map-reply!");
15173 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15175 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15176 mp->is_add = is_add;
15177 mp->vni = htonl (vni);
15178 mp->action = (u8) action;
15179 mp->is_src_dst = seid_set;
15180 mp->eid_len = eid->len;
15181 mp->seid_len = seid->len;
15182 mp->del_all = del_all;
15183 mp->eid_type = eid->type;
15184 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15185 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
15187 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15188 clib_memcpy (mp->rlocs, rlocs, data_len);
15194 /* Wait for a reply... */
15199 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15202 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15203 * forwarding entries in data-plane accordingly.
15205 * @param vam vpp API test context
15206 * @return return code
15209 api_one_add_del_adjacency (vat_main_t * vam)
15211 unformat_input_t *input = vam->input;
15212 vl_api_one_add_del_adjacency_t *mp;
15214 ip4_address_t leid4, reid4;
15215 ip6_address_t leid6, reid6;
15216 u8 reid_mac[6] = { 0 };
15217 u8 leid_mac[6] = { 0 };
15218 u8 reid_type, leid_type;
15219 u32 leid_len = 0, reid_len = 0, len;
15223 leid_type = reid_type = (u8) ~ 0;
15225 /* Parse args required to build the message */
15226 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15228 if (unformat (input, "del"))
15232 else if (unformat (input, "add"))
15236 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
15239 reid_type = 0; /* ipv4 */
15242 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
15245 reid_type = 1; /* ipv6 */
15248 else if (unformat (input, "reid %U", unformat_ethernet_address,
15251 reid_type = 2; /* mac */
15253 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
15256 leid_type = 0; /* ipv4 */
15259 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
15262 leid_type = 1; /* ipv6 */
15265 else if (unformat (input, "leid %U", unformat_ethernet_address,
15268 leid_type = 2; /* mac */
15270 else if (unformat (input, "vni %d", &vni))
15276 errmsg ("parse error '%U'", format_unformat_error, input);
15281 if ((u8) ~ 0 == reid_type)
15283 errmsg ("missing params!");
15287 if (leid_type != reid_type)
15289 errmsg ("remote and local EIDs are of different types!");
15293 M (ONE_ADD_DEL_ADJACENCY, mp);
15294 mp->is_add = is_add;
15295 mp->vni = htonl (vni);
15296 mp->leid_len = leid_len;
15297 mp->reid_len = reid_len;
15298 mp->eid_type = reid_type;
15300 switch (mp->eid_type)
15303 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
15304 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
15307 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
15308 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
15311 clib_memcpy (mp->leid, leid_mac, 6);
15312 clib_memcpy (mp->reid, reid_mac, 6);
15315 errmsg ("unknown EID type %d!", mp->eid_type);
15322 /* Wait for a reply... */
15327 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
15330 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
15332 u32 *mode = va_arg (*args, u32 *);
15334 if (unformat (input, "lisp"))
15336 else if (unformat (input, "vxlan"))
15345 api_gpe_get_encap_mode (vat_main_t * vam)
15347 vl_api_gpe_get_encap_mode_t *mp;
15350 /* Construct the API message */
15351 M (GPE_GET_ENCAP_MODE, mp);
15356 /* Wait for a reply... */
15362 api_gpe_set_encap_mode (vat_main_t * vam)
15364 unformat_input_t *input = vam->input;
15365 vl_api_gpe_set_encap_mode_t *mp;
15369 /* Parse args required to build the message */
15370 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15372 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
15378 /* Construct the API message */
15379 M (GPE_SET_ENCAP_MODE, mp);
15386 /* Wait for a reply... */
15392 api_lisp_gpe_add_del_iface (vat_main_t * vam)
15394 unformat_input_t *input = vam->input;
15395 vl_api_gpe_add_del_iface_t *mp;
15396 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
15397 u32 dp_table = 0, vni = 0;
15400 /* Parse args required to build the message */
15401 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15403 if (unformat (input, "up"))
15408 else if (unformat (input, "down"))
15413 else if (unformat (input, "table_id %d", &dp_table))
15417 else if (unformat (input, "bd_id %d", &dp_table))
15422 else if (unformat (input, "vni %d", &vni))
15430 if (action_set == 0)
15432 errmsg ("Action not set");
15435 if (dp_table_set == 0 || vni_set == 0)
15437 errmsg ("vni and dp_table must be set");
15441 /* Construct the API message */
15442 M (GPE_ADD_DEL_IFACE, mp);
15444 mp->is_add = is_add;
15445 mp->dp_table = dp_table;
15452 /* Wait for a reply... */
15458 * Add/del map request itr rlocs from ONE control plane and updates
15460 * @param vam vpp API test context
15461 * @return return code
15464 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
15466 unformat_input_t *input = vam->input;
15467 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
15468 u8 *locator_set_name = 0;
15469 u8 locator_set_name_set = 0;
15473 /* Parse args required to build the message */
15474 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15476 if (unformat (input, "del"))
15480 else if (unformat (input, "%_%v%_", &locator_set_name))
15482 locator_set_name_set = 1;
15486 clib_warning ("parse error '%U'", format_unformat_error, input);
15491 if (is_add && !locator_set_name_set)
15493 errmsg ("itr-rloc is not set!");
15497 if (is_add && vec_len (locator_set_name) > 64)
15499 errmsg ("itr-rloc locator-set name too long");
15500 vec_free (locator_set_name);
15504 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
15505 mp->is_add = is_add;
15508 clib_memcpy (mp->locator_set_name, locator_set_name,
15509 vec_len (locator_set_name));
15513 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
15515 vec_free (locator_set_name);
15520 /* Wait for a reply... */
15525 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
15528 api_one_locator_dump (vat_main_t * vam)
15530 unformat_input_t *input = vam->input;
15531 vl_api_one_locator_dump_t *mp;
15532 vl_api_control_ping_t *mp_ping;
15533 u8 is_index_set = 0, is_name_set = 0;
15538 /* Parse args required to build the message */
15539 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15541 if (unformat (input, "ls_name %_%v%_", &ls_name))
15545 else if (unformat (input, "ls_index %d", &ls_index))
15551 errmsg ("parse error '%U'", format_unformat_error, input);
15556 if (!is_index_set && !is_name_set)
15558 errmsg ("error: expected one of index or name!");
15562 if (is_index_set && is_name_set)
15564 errmsg ("error: only one param expected!");
15568 if (vec_len (ls_name) > 62)
15570 errmsg ("error: locator set name too long!");
15574 if (!vam->json_output)
15576 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
15579 M (ONE_LOCATOR_DUMP, mp);
15580 mp->is_index_set = is_index_set;
15583 mp->ls_index = clib_host_to_net_u32 (ls_index);
15586 vec_add1 (ls_name, 0);
15587 strncpy ((char *) mp->ls_name, (char *) ls_name,
15588 sizeof (mp->ls_name) - 1);
15594 /* Use a control ping for synchronization */
15595 M (CONTROL_PING, mp_ping);
15598 /* Wait for a reply... */
15603 #define api_lisp_locator_dump api_one_locator_dump
15606 api_one_locator_set_dump (vat_main_t * vam)
15608 vl_api_one_locator_set_dump_t *mp;
15609 vl_api_control_ping_t *mp_ping;
15610 unformat_input_t *input = vam->input;
15614 /* Parse args required to build the message */
15615 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15617 if (unformat (input, "local"))
15621 else if (unformat (input, "remote"))
15627 errmsg ("parse error '%U'", format_unformat_error, input);
15632 if (!vam->json_output)
15634 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
15637 M (ONE_LOCATOR_SET_DUMP, mp);
15639 mp->filter = filter;
15644 /* Use a control ping for synchronization */
15645 M (CONTROL_PING, mp_ping);
15648 /* Wait for a reply... */
15653 #define api_lisp_locator_set_dump api_one_locator_set_dump
15656 api_one_eid_table_map_dump (vat_main_t * vam)
15660 unformat_input_t *input = vam->input;
15661 vl_api_one_eid_table_map_dump_t *mp;
15662 vl_api_control_ping_t *mp_ping;
15665 /* Parse args required to build the message */
15666 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15668 if (unformat (input, "l2"))
15673 else if (unformat (input, "l3"))
15680 errmsg ("parse error '%U'", format_unformat_error, input);
15687 errmsg ("expected one of 'l2' or 'l3' parameter!");
15691 if (!vam->json_output)
15693 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
15696 M (ONE_EID_TABLE_MAP_DUMP, mp);
15702 /* Use a control ping for synchronization */
15703 M (CONTROL_PING, mp_ping);
15706 /* Wait for a reply... */
15711 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
15714 api_one_eid_table_vni_dump (vat_main_t * vam)
15716 vl_api_one_eid_table_vni_dump_t *mp;
15717 vl_api_control_ping_t *mp_ping;
15720 if (!vam->json_output)
15722 print (vam->ofp, "VNI");
15725 M (ONE_EID_TABLE_VNI_DUMP, mp);
15730 /* Use a control ping for synchronization */
15731 M (CONTROL_PING, mp_ping);
15734 /* Wait for a reply... */
15739 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
15742 api_one_eid_table_dump (vat_main_t * vam)
15744 unformat_input_t *i = vam->input;
15745 vl_api_one_eid_table_dump_t *mp;
15746 vl_api_control_ping_t *mp_ping;
15747 struct in_addr ip4;
15748 struct in6_addr ip6;
15750 u8 eid_type = ~0, eid_set = 0;
15751 u32 prefix_length = ~0, t, vni = 0;
15755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15757 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
15763 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
15769 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
15774 else if (unformat (i, "vni %d", &t))
15778 else if (unformat (i, "local"))
15782 else if (unformat (i, "remote"))
15788 errmsg ("parse error '%U'", format_unformat_error, i);
15793 if (!vam->json_output)
15795 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
15796 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
15799 M (ONE_EID_TABLE_DUMP, mp);
15801 mp->filter = filter;
15805 mp->vni = htonl (vni);
15806 mp->eid_type = eid_type;
15810 mp->prefix_length = prefix_length;
15811 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
15814 mp->prefix_length = prefix_length;
15815 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
15818 clib_memcpy (mp->eid, mac, sizeof (mac));
15821 errmsg ("unknown EID type %d!", eid_type);
15829 /* Use a control ping for synchronization */
15830 M (CONTROL_PING, mp_ping);
15833 /* Wait for a reply... */
15838 #define api_lisp_eid_table_dump api_one_eid_table_dump
15841 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
15843 unformat_input_t *i = vam->input;
15844 vl_api_gpe_fwd_entries_get_t *mp;
15849 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15851 if (unformat (i, "vni %d", &vni))
15857 errmsg ("parse error '%U'", format_unformat_error, i);
15864 errmsg ("vni not set!");
15868 if (!vam->json_output)
15870 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15874 M (GPE_FWD_ENTRIES_GET, mp);
15875 mp->vni = clib_host_to_net_u32 (vni);
15880 /* Wait for a reply... */
15885 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15886 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15887 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15888 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
15891 api_one_adjacencies_get (vat_main_t * vam)
15893 unformat_input_t *i = vam->input;
15894 vl_api_one_adjacencies_get_t *mp;
15899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15901 if (unformat (i, "vni %d", &vni))
15907 errmsg ("parse error '%U'", format_unformat_error, i);
15914 errmsg ("vni not set!");
15918 if (!vam->json_output)
15920 print (vam->ofp, "%s %40s", "leid", "reid");
15923 M (ONE_ADJACENCIES_GET, mp);
15924 mp->vni = clib_host_to_net_u32 (vni);
15929 /* Wait for a reply... */
15934 #define api_lisp_adjacencies_get api_one_adjacencies_get
15937 api_one_map_server_dump (vat_main_t * vam)
15939 vl_api_one_map_server_dump_t *mp;
15940 vl_api_control_ping_t *mp_ping;
15943 if (!vam->json_output)
15945 print (vam->ofp, "%=20s", "Map server");
15948 M (ONE_MAP_SERVER_DUMP, mp);
15952 /* Use a control ping for synchronization */
15953 M (CONTROL_PING, mp_ping);
15956 /* Wait for a reply... */
15961 #define api_lisp_map_server_dump api_one_map_server_dump
15964 api_one_map_resolver_dump (vat_main_t * vam)
15966 vl_api_one_map_resolver_dump_t *mp;
15967 vl_api_control_ping_t *mp_ping;
15970 if (!vam->json_output)
15972 print (vam->ofp, "%=20s", "Map resolver");
15975 M (ONE_MAP_RESOLVER_DUMP, mp);
15979 /* Use a control ping for synchronization */
15980 M (CONTROL_PING, mp_ping);
15983 /* Wait for a reply... */
15988 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
15991 api_one_stats_flush (vat_main_t * vam)
15993 vl_api_one_stats_flush_t *mp;
15996 M (ONE_STATS_FLUSH, mp);
16003 api_one_stats_dump (vat_main_t * vam)
16005 vl_api_one_stats_dump_t *mp;
16006 vl_api_control_ping_t *mp_ping;
16009 M (ONE_STATS_DUMP, mp);
16013 /* Use a control ping for synchronization */
16014 M (CONTROL_PING, mp_ping);
16017 /* Wait for a reply... */
16023 api_show_one_status (vat_main_t * vam)
16025 vl_api_show_one_status_t *mp;
16028 if (!vam->json_output)
16030 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
16033 M (SHOW_ONE_STATUS, mp);
16036 /* Wait for a reply... */
16041 #define api_show_lisp_status api_show_one_status
16044 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
16046 vl_api_gpe_fwd_entry_path_dump_t *mp;
16047 vl_api_control_ping_t *mp_ping;
16048 unformat_input_t *i = vam->input;
16049 u32 fwd_entry_index = ~0;
16052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16054 if (unformat (i, "index %d", &fwd_entry_index))
16060 if (~0 == fwd_entry_index)
16062 errmsg ("no index specified!");
16066 if (!vam->json_output)
16068 print (vam->ofp, "first line");
16071 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
16075 /* Use a control ping for synchronization */
16076 M (CONTROL_PING, mp_ping);
16079 /* Wait for a reply... */
16085 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
16087 vl_api_one_get_map_request_itr_rlocs_t *mp;
16090 if (!vam->json_output)
16092 print (vam->ofp, "%=20s", "itr-rlocs:");
16095 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
16098 /* Wait for a reply... */
16103 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
16106 api_af_packet_create (vat_main_t * vam)
16108 unformat_input_t *i = vam->input;
16109 vl_api_af_packet_create_t *mp;
16110 u8 *host_if_name = 0;
16112 u8 random_hw_addr = 1;
16115 memset (hw_addr, 0, sizeof (hw_addr));
16117 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16119 if (unformat (i, "name %s", &host_if_name))
16120 vec_add1 (host_if_name, 0);
16121 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16122 random_hw_addr = 0;
16127 if (!vec_len (host_if_name))
16129 errmsg ("host-interface name must be specified");
16133 if (vec_len (host_if_name) > 64)
16135 errmsg ("host-interface name too long");
16139 M (AF_PACKET_CREATE, mp);
16141 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16142 clib_memcpy (mp->hw_addr, hw_addr, 6);
16143 mp->use_random_hw_addr = random_hw_addr;
16144 vec_free (host_if_name);
16152 fprintf (vam->ofp ? vam->ofp : stderr,
16153 " new sw_if_index = %d\n", vam->sw_if_index);
16160 api_af_packet_delete (vat_main_t * vam)
16162 unformat_input_t *i = vam->input;
16163 vl_api_af_packet_delete_t *mp;
16164 u8 *host_if_name = 0;
16167 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16169 if (unformat (i, "name %s", &host_if_name))
16170 vec_add1 (host_if_name, 0);
16175 if (!vec_len (host_if_name))
16177 errmsg ("host-interface name must be specified");
16181 if (vec_len (host_if_name) > 64)
16183 errmsg ("host-interface name too long");
16187 M (AF_PACKET_DELETE, mp);
16189 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16190 vec_free (host_if_name);
16198 api_policer_add_del (vat_main_t * vam)
16200 unformat_input_t *i = vam->input;
16201 vl_api_policer_add_del_t *mp;
16211 u8 color_aware = 0;
16212 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
16215 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
16216 conform_action.dscp = 0;
16217 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
16218 exceed_action.dscp = 0;
16219 violate_action.action_type = SSE2_QOS_ACTION_DROP;
16220 violate_action.dscp = 0;
16222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16224 if (unformat (i, "del"))
16226 else if (unformat (i, "name %s", &name))
16227 vec_add1 (name, 0);
16228 else if (unformat (i, "cir %u", &cir))
16230 else if (unformat (i, "eir %u", &eir))
16232 else if (unformat (i, "cb %u", &cb))
16234 else if (unformat (i, "eb %u", &eb))
16236 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
16239 else if (unformat (i, "round_type %U", unformat_policer_round_type,
16242 else if (unformat (i, "type %U", unformat_policer_type, &type))
16244 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
16247 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
16250 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
16253 else if (unformat (i, "color-aware"))
16259 if (!vec_len (name))
16261 errmsg ("policer name must be specified");
16265 if (vec_len (name) > 64)
16267 errmsg ("policer name too long");
16271 M (POLICER_ADD_DEL, mp);
16273 clib_memcpy (mp->name, name, vec_len (name));
16275 mp->is_add = is_add;
16280 mp->rate_type = rate_type;
16281 mp->round_type = round_type;
16283 mp->conform_action_type = conform_action.action_type;
16284 mp->conform_dscp = conform_action.dscp;
16285 mp->exceed_action_type = exceed_action.action_type;
16286 mp->exceed_dscp = exceed_action.dscp;
16287 mp->violate_action_type = violate_action.action_type;
16288 mp->violate_dscp = violate_action.dscp;
16289 mp->color_aware = color_aware;
16297 api_policer_dump (vat_main_t * vam)
16299 unformat_input_t *i = vam->input;
16300 vl_api_policer_dump_t *mp;
16301 vl_api_control_ping_t *mp_ping;
16302 u8 *match_name = 0;
16303 u8 match_name_valid = 0;
16306 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16308 if (unformat (i, "name %s", &match_name))
16310 vec_add1 (match_name, 0);
16311 match_name_valid = 1;
16317 M (POLICER_DUMP, mp);
16318 mp->match_name_valid = match_name_valid;
16319 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
16320 vec_free (match_name);
16324 /* Use a control ping for synchronization */
16325 M (CONTROL_PING, mp_ping);
16328 /* Wait for a reply... */
16334 api_policer_classify_set_interface (vat_main_t * vam)
16336 unformat_input_t *i = vam->input;
16337 vl_api_policer_classify_set_interface_t *mp;
16339 int sw_if_index_set;
16340 u32 ip4_table_index = ~0;
16341 u32 ip6_table_index = ~0;
16342 u32 l2_table_index = ~0;
16346 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16348 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16349 sw_if_index_set = 1;
16350 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16351 sw_if_index_set = 1;
16352 else if (unformat (i, "del"))
16354 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16356 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16358 else if (unformat (i, "l2-table %d", &l2_table_index))
16362 clib_warning ("parse error '%U'", format_unformat_error, i);
16367 if (sw_if_index_set == 0)
16369 errmsg ("missing interface name or sw_if_index");
16373 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
16375 mp->sw_if_index = ntohl (sw_if_index);
16376 mp->ip4_table_index = ntohl (ip4_table_index);
16377 mp->ip6_table_index = ntohl (ip6_table_index);
16378 mp->l2_table_index = ntohl (l2_table_index);
16379 mp->is_add = is_add;
16387 api_policer_classify_dump (vat_main_t * vam)
16389 unformat_input_t *i = vam->input;
16390 vl_api_policer_classify_dump_t *mp;
16391 vl_api_control_ping_t *mp_ping;
16392 u8 type = POLICER_CLASSIFY_N_TABLES;
16395 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
16399 errmsg ("classify table type must be specified");
16403 if (!vam->json_output)
16405 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
16408 M (POLICER_CLASSIFY_DUMP, mp);
16413 /* Use a control ping for synchronization */
16414 M (CONTROL_PING, mp_ping);
16417 /* Wait for a reply... */
16423 api_netmap_create (vat_main_t * vam)
16425 unformat_input_t *i = vam->input;
16426 vl_api_netmap_create_t *mp;
16429 u8 random_hw_addr = 1;
16434 memset (hw_addr, 0, sizeof (hw_addr));
16436 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16438 if (unformat (i, "name %s", &if_name))
16439 vec_add1 (if_name, 0);
16440 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16441 random_hw_addr = 0;
16442 else if (unformat (i, "pipe"))
16444 else if (unformat (i, "master"))
16446 else if (unformat (i, "slave"))
16452 if (!vec_len (if_name))
16454 errmsg ("interface name must be specified");
16458 if (vec_len (if_name) > 64)
16460 errmsg ("interface name too long");
16464 M (NETMAP_CREATE, mp);
16466 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16467 clib_memcpy (mp->hw_addr, hw_addr, 6);
16468 mp->use_random_hw_addr = random_hw_addr;
16469 mp->is_pipe = is_pipe;
16470 mp->is_master = is_master;
16471 vec_free (if_name);
16479 api_netmap_delete (vat_main_t * vam)
16481 unformat_input_t *i = vam->input;
16482 vl_api_netmap_delete_t *mp;
16486 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16488 if (unformat (i, "name %s", &if_name))
16489 vec_add1 (if_name, 0);
16494 if (!vec_len (if_name))
16496 errmsg ("interface name must be specified");
16500 if (vec_len (if_name) > 64)
16502 errmsg ("interface name too long");
16506 M (NETMAP_DELETE, mp);
16508 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16509 vec_free (if_name);
16517 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
16519 if (fp->afi == IP46_TYPE_IP6)
16521 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16522 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16523 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16524 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16525 format_ip6_address, fp->next_hop);
16526 else if (fp->afi == IP46_TYPE_IP4)
16528 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16529 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16530 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16531 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16532 format_ip4_address, fp->next_hop);
16536 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
16537 vl_api_fib_path2_t * fp)
16539 struct in_addr ip4;
16540 struct in6_addr ip6;
16542 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16543 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16544 vat_json_object_add_uint (node, "is_local", fp->is_local);
16545 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16546 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16547 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16548 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16549 if (fp->afi == IP46_TYPE_IP4)
16551 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16552 vat_json_object_add_ip4 (node, "next_hop", ip4);
16554 else if (fp->afi == IP46_TYPE_IP6)
16556 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16557 vat_json_object_add_ip6 (node, "next_hop", ip6);
16562 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
16564 vat_main_t *vam = &vat_main;
16565 int count = ntohl (mp->mt_count);
16566 vl_api_fib_path2_t *fp;
16569 print (vam->ofp, "[%d]: sw_if_index %d via:",
16570 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
16572 for (i = 0; i < count; i++)
16574 vl_api_mpls_fib_path_print (vam, fp);
16578 print (vam->ofp, "");
16581 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
16582 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
16585 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
16587 vat_main_t *vam = &vat_main;
16588 vat_json_node_t *node = NULL;
16589 int count = ntohl (mp->mt_count);
16590 vl_api_fib_path2_t *fp;
16593 if (VAT_JSON_ARRAY != vam->json_tree.type)
16595 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16596 vat_json_init_array (&vam->json_tree);
16598 node = vat_json_array_add (&vam->json_tree);
16600 vat_json_init_object (node);
16601 vat_json_object_add_uint (node, "tunnel_index",
16602 ntohl (mp->mt_tunnel_index));
16603 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
16605 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
16608 for (i = 0; i < count; i++)
16610 vl_api_mpls_fib_path_json_print (node, fp);
16616 api_mpls_tunnel_dump (vat_main_t * vam)
16618 vl_api_mpls_tunnel_dump_t *mp;
16619 vl_api_control_ping_t *mp_ping;
16623 /* Parse args required to build the message */
16624 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
16626 if (!unformat (vam->input, "tunnel_index %d", &index))
16633 print (vam->ofp, " tunnel_index %d", index);
16635 M (MPLS_TUNNEL_DUMP, mp);
16636 mp->tunnel_index = htonl (index);
16639 /* Use a control ping for synchronization */
16640 M (CONTROL_PING, mp_ping);
16647 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
16648 #define vl_api_mpls_fib_details_t_print vl_noop_handler
16652 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
16654 vat_main_t *vam = &vat_main;
16655 int count = ntohl (mp->count);
16656 vl_api_fib_path2_t *fp;
16660 "table-id %d, label %u, ess_bit %u",
16661 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
16663 for (i = 0; i < count; i++)
16665 vl_api_mpls_fib_path_print (vam, fp);
16670 static void vl_api_mpls_fib_details_t_handler_json
16671 (vl_api_mpls_fib_details_t * mp)
16673 vat_main_t *vam = &vat_main;
16674 int count = ntohl (mp->count);
16675 vat_json_node_t *node = NULL;
16676 vl_api_fib_path2_t *fp;
16679 if (VAT_JSON_ARRAY != vam->json_tree.type)
16681 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16682 vat_json_init_array (&vam->json_tree);
16684 node = vat_json_array_add (&vam->json_tree);
16686 vat_json_init_object (node);
16687 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16688 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
16689 vat_json_object_add_uint (node, "label", ntohl (mp->label));
16690 vat_json_object_add_uint (node, "path_count", count);
16692 for (i = 0; i < count; i++)
16694 vl_api_mpls_fib_path_json_print (node, fp);
16700 api_mpls_fib_dump (vat_main_t * vam)
16702 vl_api_mpls_fib_dump_t *mp;
16703 vl_api_control_ping_t *mp_ping;
16706 M (MPLS_FIB_DUMP, mp);
16709 /* Use a control ping for synchronization */
16710 M (CONTROL_PING, mp_ping);
16717 #define vl_api_ip_fib_details_t_endian vl_noop_handler
16718 #define vl_api_ip_fib_details_t_print vl_noop_handler
16721 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
16723 vat_main_t *vam = &vat_main;
16724 int count = ntohl (mp->count);
16725 vl_api_fib_path_t *fp;
16729 "table-id %d, prefix %U/%d",
16730 ntohl (mp->table_id), format_ip4_address, mp->address,
16731 mp->address_length);
16733 for (i = 0; i < count; i++)
16735 if (fp->afi == IP46_TYPE_IP6)
16737 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16738 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16739 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16740 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16741 format_ip6_address, fp->next_hop);
16742 else if (fp->afi == IP46_TYPE_IP4)
16744 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16745 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16746 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16747 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16748 format_ip4_address, fp->next_hop);
16753 static void vl_api_ip_fib_details_t_handler_json
16754 (vl_api_ip_fib_details_t * mp)
16756 vat_main_t *vam = &vat_main;
16757 int count = ntohl (mp->count);
16758 vat_json_node_t *node = NULL;
16759 struct in_addr ip4;
16760 struct in6_addr ip6;
16761 vl_api_fib_path_t *fp;
16764 if (VAT_JSON_ARRAY != vam->json_tree.type)
16766 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16767 vat_json_init_array (&vam->json_tree);
16769 node = vat_json_array_add (&vam->json_tree);
16771 vat_json_init_object (node);
16772 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16773 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
16774 vat_json_object_add_ip4 (node, "prefix", ip4);
16775 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16776 vat_json_object_add_uint (node, "path_count", count);
16778 for (i = 0; i < count; i++)
16780 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16781 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16782 vat_json_object_add_uint (node, "is_local", fp->is_local);
16783 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16784 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16785 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16786 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16787 if (fp->afi == IP46_TYPE_IP4)
16789 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16790 vat_json_object_add_ip4 (node, "next_hop", ip4);
16792 else if (fp->afi == IP46_TYPE_IP6)
16794 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16795 vat_json_object_add_ip6 (node, "next_hop", ip6);
16801 api_ip_fib_dump (vat_main_t * vam)
16803 vl_api_ip_fib_dump_t *mp;
16804 vl_api_control_ping_t *mp_ping;
16807 M (IP_FIB_DUMP, mp);
16810 /* Use a control ping for synchronization */
16811 M (CONTROL_PING, mp_ping);
16819 api_ip_mfib_dump (vat_main_t * vam)
16821 vl_api_ip_mfib_dump_t *mp;
16822 vl_api_control_ping_t *mp_ping;
16825 M (IP_MFIB_DUMP, mp);
16828 /* Use a control ping for synchronization */
16829 M (CONTROL_PING, mp_ping);
16836 static void vl_api_ip_neighbor_details_t_handler
16837 (vl_api_ip_neighbor_details_t * mp)
16839 vat_main_t *vam = &vat_main;
16841 print (vam->ofp, "%c %U %U",
16842 (mp->is_static) ? 'S' : 'D',
16843 format_ethernet_address, &mp->mac_address,
16844 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
16848 static void vl_api_ip_neighbor_details_t_handler_json
16849 (vl_api_ip_neighbor_details_t * mp)
16852 vat_main_t *vam = &vat_main;
16853 vat_json_node_t *node;
16854 struct in_addr ip4;
16855 struct in6_addr ip6;
16857 if (VAT_JSON_ARRAY != vam->json_tree.type)
16859 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16860 vat_json_init_array (&vam->json_tree);
16862 node = vat_json_array_add (&vam->json_tree);
16864 vat_json_init_object (node);
16865 vat_json_object_add_string_copy (node, "flag",
16866 (mp->is_static) ? (u8 *) "static" : (u8 *)
16869 vat_json_object_add_string_copy (node, "link_layer",
16870 format (0, "%U", format_ethernet_address,
16871 &mp->mac_address));
16875 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
16876 vat_json_object_add_ip6 (node, "ip_address", ip6);
16880 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
16881 vat_json_object_add_ip4 (node, "ip_address", ip4);
16886 api_ip_neighbor_dump (vat_main_t * vam)
16888 unformat_input_t *i = vam->input;
16889 vl_api_ip_neighbor_dump_t *mp;
16890 vl_api_control_ping_t *mp_ping;
16892 u32 sw_if_index = ~0;
16895 /* Parse args required to build the message */
16896 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16898 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16900 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16902 else if (unformat (i, "ip6"))
16908 if (sw_if_index == ~0)
16910 errmsg ("missing interface name or sw_if_index");
16914 M (IP_NEIGHBOR_DUMP, mp);
16915 mp->is_ipv6 = (u8) is_ipv6;
16916 mp->sw_if_index = ntohl (sw_if_index);
16919 /* Use a control ping for synchronization */
16920 M (CONTROL_PING, mp_ping);
16927 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
16928 #define vl_api_ip6_fib_details_t_print vl_noop_handler
16931 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
16933 vat_main_t *vam = &vat_main;
16934 int count = ntohl (mp->count);
16935 vl_api_fib_path_t *fp;
16939 "table-id %d, prefix %U/%d",
16940 ntohl (mp->table_id), format_ip6_address, mp->address,
16941 mp->address_length);
16943 for (i = 0; i < count; i++)
16945 if (fp->afi == IP46_TYPE_IP6)
16947 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16948 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16949 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16950 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16951 format_ip6_address, fp->next_hop);
16952 else if (fp->afi == IP46_TYPE_IP4)
16954 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16955 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16956 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16957 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16958 format_ip4_address, fp->next_hop);
16963 static void vl_api_ip6_fib_details_t_handler_json
16964 (vl_api_ip6_fib_details_t * mp)
16966 vat_main_t *vam = &vat_main;
16967 int count = ntohl (mp->count);
16968 vat_json_node_t *node = NULL;
16969 struct in_addr ip4;
16970 struct in6_addr ip6;
16971 vl_api_fib_path_t *fp;
16974 if (VAT_JSON_ARRAY != vam->json_tree.type)
16976 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16977 vat_json_init_array (&vam->json_tree);
16979 node = vat_json_array_add (&vam->json_tree);
16981 vat_json_init_object (node);
16982 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16983 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
16984 vat_json_object_add_ip6 (node, "prefix", ip6);
16985 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16986 vat_json_object_add_uint (node, "path_count", count);
16988 for (i = 0; i < count; i++)
16990 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16991 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16992 vat_json_object_add_uint (node, "is_local", fp->is_local);
16993 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16994 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16995 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16996 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16997 if (fp->afi == IP46_TYPE_IP4)
16999 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17000 vat_json_object_add_ip4 (node, "next_hop", ip4);
17002 else if (fp->afi == IP46_TYPE_IP6)
17004 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17005 vat_json_object_add_ip6 (node, "next_hop", ip6);
17011 api_ip6_fib_dump (vat_main_t * vam)
17013 vl_api_ip6_fib_dump_t *mp;
17014 vl_api_control_ping_t *mp_ping;
17017 M (IP6_FIB_DUMP, mp);
17020 /* Use a control ping for synchronization */
17021 M (CONTROL_PING, mp_ping);
17029 api_ip6_mfib_dump (vat_main_t * vam)
17031 vl_api_ip6_mfib_dump_t *mp;
17032 vl_api_control_ping_t *mp_ping;
17035 M (IP6_MFIB_DUMP, mp);
17038 /* Use a control ping for synchronization */
17039 M (CONTROL_PING, mp_ping);
17047 api_classify_table_ids (vat_main_t * vam)
17049 vl_api_classify_table_ids_t *mp;
17052 /* Construct the API message */
17053 M (CLASSIFY_TABLE_IDS, mp);
17062 api_classify_table_by_interface (vat_main_t * vam)
17064 unformat_input_t *input = vam->input;
17065 vl_api_classify_table_by_interface_t *mp;
17067 u32 sw_if_index = ~0;
17069 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17071 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17073 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17078 if (sw_if_index == ~0)
17080 errmsg ("missing interface name or sw_if_index");
17084 /* Construct the API message */
17085 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
17087 mp->sw_if_index = ntohl (sw_if_index);
17095 api_classify_table_info (vat_main_t * vam)
17097 unformat_input_t *input = vam->input;
17098 vl_api_classify_table_info_t *mp;
17102 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17104 if (unformat (input, "table_id %d", &table_id))
17109 if (table_id == ~0)
17111 errmsg ("missing table id");
17115 /* Construct the API message */
17116 M (CLASSIFY_TABLE_INFO, mp);
17118 mp->table_id = ntohl (table_id);
17126 api_classify_session_dump (vat_main_t * vam)
17128 unformat_input_t *input = vam->input;
17129 vl_api_classify_session_dump_t *mp;
17130 vl_api_control_ping_t *mp_ping;
17134 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17136 if (unformat (input, "table_id %d", &table_id))
17141 if (table_id == ~0)
17143 errmsg ("missing table id");
17147 /* Construct the API message */
17148 M (CLASSIFY_SESSION_DUMP, mp);
17150 mp->table_id = ntohl (table_id);
17153 /* Use a control ping for synchronization */
17154 M (CONTROL_PING, mp_ping);
17162 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
17164 vat_main_t *vam = &vat_main;
17166 print (vam->ofp, "collector_address %U, collector_port %d, "
17167 "src_address %U, vrf_id %d, path_mtu %u, "
17168 "template_interval %u, udp_checksum %d",
17169 format_ip4_address, mp->collector_address,
17170 ntohs (mp->collector_port),
17171 format_ip4_address, mp->src_address,
17172 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
17173 ntohl (mp->template_interval), mp->udp_checksum);
17176 vam->result_ready = 1;
17180 vl_api_ipfix_exporter_details_t_handler_json
17181 (vl_api_ipfix_exporter_details_t * mp)
17183 vat_main_t *vam = &vat_main;
17184 vat_json_node_t node;
17185 struct in_addr collector_address;
17186 struct in_addr src_address;
17188 vat_json_init_object (&node);
17189 clib_memcpy (&collector_address, &mp->collector_address,
17190 sizeof (collector_address));
17191 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
17192 vat_json_object_add_uint (&node, "collector_port",
17193 ntohs (mp->collector_port));
17194 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
17195 vat_json_object_add_ip4 (&node, "src_address", src_address);
17196 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
17197 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
17198 vat_json_object_add_uint (&node, "template_interval",
17199 ntohl (mp->template_interval));
17200 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
17202 vat_json_print (vam->ofp, &node);
17203 vat_json_free (&node);
17205 vam->result_ready = 1;
17209 api_ipfix_exporter_dump (vat_main_t * vam)
17211 vl_api_ipfix_exporter_dump_t *mp;
17214 /* Construct the API message */
17215 M (IPFIX_EXPORTER_DUMP, mp);
17224 api_ipfix_classify_stream_dump (vat_main_t * vam)
17226 vl_api_ipfix_classify_stream_dump_t *mp;
17229 /* Construct the API message */
17230 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
17241 vl_api_ipfix_classify_stream_details_t_handler
17242 (vl_api_ipfix_classify_stream_details_t * mp)
17244 vat_main_t *vam = &vat_main;
17245 print (vam->ofp, "domain_id %d, src_port %d",
17246 ntohl (mp->domain_id), ntohs (mp->src_port));
17248 vam->result_ready = 1;
17252 vl_api_ipfix_classify_stream_details_t_handler_json
17253 (vl_api_ipfix_classify_stream_details_t * mp)
17255 vat_main_t *vam = &vat_main;
17256 vat_json_node_t node;
17258 vat_json_init_object (&node);
17259 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
17260 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
17262 vat_json_print (vam->ofp, &node);
17263 vat_json_free (&node);
17265 vam->result_ready = 1;
17269 api_ipfix_classify_table_dump (vat_main_t * vam)
17271 vl_api_ipfix_classify_table_dump_t *mp;
17272 vl_api_control_ping_t *mp_ping;
17275 if (!vam->json_output)
17277 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
17278 "transport_protocol");
17281 /* Construct the API message */
17282 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
17287 /* Use a control ping for synchronization */
17288 M (CONTROL_PING, mp_ping);
17296 vl_api_ipfix_classify_table_details_t_handler
17297 (vl_api_ipfix_classify_table_details_t * mp)
17299 vat_main_t *vam = &vat_main;
17300 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
17301 mp->transport_protocol);
17305 vl_api_ipfix_classify_table_details_t_handler_json
17306 (vl_api_ipfix_classify_table_details_t * mp)
17308 vat_json_node_t *node = NULL;
17309 vat_main_t *vam = &vat_main;
17311 if (VAT_JSON_ARRAY != vam->json_tree.type)
17313 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17314 vat_json_init_array (&vam->json_tree);
17317 node = vat_json_array_add (&vam->json_tree);
17318 vat_json_init_object (node);
17320 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
17321 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
17322 vat_json_object_add_uint (node, "transport_protocol",
17323 mp->transport_protocol);
17327 api_sw_interface_span_enable_disable (vat_main_t * vam)
17329 unformat_input_t *i = vam->input;
17330 vl_api_sw_interface_span_enable_disable_t *mp;
17331 u32 src_sw_if_index = ~0;
17332 u32 dst_sw_if_index = ~0;
17336 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17339 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
17341 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
17345 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
17347 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
17349 else if (unformat (i, "disable"))
17351 else if (unformat (i, "rx"))
17353 else if (unformat (i, "tx"))
17355 else if (unformat (i, "both"))
17361 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
17363 mp->sw_if_index_from = htonl (src_sw_if_index);
17364 mp->sw_if_index_to = htonl (dst_sw_if_index);
17373 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
17376 vat_main_t *vam = &vat_main;
17377 u8 *sw_if_from_name = 0;
17378 u8 *sw_if_to_name = 0;
17379 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17380 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17381 char *states[] = { "none", "rx", "tx", "both" };
17385 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17387 if ((u32) p->value[0] == sw_if_index_from)
17389 sw_if_from_name = (u8 *)(p->key);
17393 if ((u32) p->value[0] == sw_if_index_to)
17395 sw_if_to_name = (u8 *)(p->key);
17396 if (sw_if_from_name)
17401 print (vam->ofp, "%20s => %20s (%s)",
17402 sw_if_from_name, sw_if_to_name, states[mp->state]);
17406 vl_api_sw_interface_span_details_t_handler_json
17407 (vl_api_sw_interface_span_details_t * mp)
17409 vat_main_t *vam = &vat_main;
17410 vat_json_node_t *node = NULL;
17411 u8 *sw_if_from_name = 0;
17412 u8 *sw_if_to_name = 0;
17413 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17414 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17418 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17420 if ((u32) p->value[0] == sw_if_index_from)
17422 sw_if_from_name = (u8 *)(p->key);
17426 if ((u32) p->value[0] == sw_if_index_to)
17428 sw_if_to_name = (u8 *)(p->key);
17429 if (sw_if_from_name)
17435 if (VAT_JSON_ARRAY != vam->json_tree.type)
17437 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17438 vat_json_init_array (&vam->json_tree);
17440 node = vat_json_array_add (&vam->json_tree);
17442 vat_json_init_object (node);
17443 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
17444 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
17445 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
17446 if (0 != sw_if_to_name)
17448 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
17450 vat_json_object_add_uint (node, "state", mp->state);
17454 api_sw_interface_span_dump (vat_main_t * vam)
17456 vl_api_sw_interface_span_dump_t *mp;
17457 vl_api_control_ping_t *mp_ping;
17460 M (SW_INTERFACE_SPAN_DUMP, mp);
17463 /* Use a control ping for synchronization */
17464 M (CONTROL_PING, mp_ping);
17472 api_pg_create_interface (vat_main_t * vam)
17474 unformat_input_t *input = vam->input;
17475 vl_api_pg_create_interface_t *mp;
17479 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17481 if (unformat (input, "if_id %d", &if_id))
17488 errmsg ("missing pg interface index");
17492 /* Construct the API message */
17493 M (PG_CREATE_INTERFACE, mp);
17495 mp->interface_id = ntohl (if_id);
17503 api_pg_capture (vat_main_t * vam)
17505 unformat_input_t *input = vam->input;
17506 vl_api_pg_capture_t *mp;
17511 u8 pcap_file_set = 0;
17514 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17516 if (unformat (input, "if_id %d", &if_id))
17518 else if (unformat (input, "pcap %s", &pcap_file))
17520 else if (unformat (input, "count %d", &count))
17522 else if (unformat (input, "disable"))
17529 errmsg ("missing pg interface index");
17532 if (pcap_file_set > 0)
17534 if (vec_len (pcap_file) > 255)
17536 errmsg ("pcap file name is too long");
17541 u32 name_len = vec_len (pcap_file);
17542 /* Construct the API message */
17543 M (PG_CAPTURE, mp);
17545 mp->interface_id = ntohl (if_id);
17546 mp->is_enabled = enable;
17547 mp->count = ntohl (count);
17548 mp->pcap_name_length = ntohl (name_len);
17549 if (pcap_file_set != 0)
17551 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
17553 vec_free (pcap_file);
17561 api_pg_enable_disable (vat_main_t * vam)
17563 unformat_input_t *input = vam->input;
17564 vl_api_pg_enable_disable_t *mp;
17567 u8 stream_name_set = 0;
17568 u8 *stream_name = 0;
17570 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17572 if (unformat (input, "stream %s", &stream_name))
17573 stream_name_set = 1;
17574 else if (unformat (input, "disable"))
17580 if (stream_name_set > 0)
17582 if (vec_len (stream_name) > 255)
17584 errmsg ("stream name too long");
17589 u32 name_len = vec_len (stream_name);
17590 /* Construct the API message */
17591 M (PG_ENABLE_DISABLE, mp);
17593 mp->is_enabled = enable;
17594 if (stream_name_set != 0)
17596 mp->stream_name_length = ntohl (name_len);
17597 clib_memcpy (mp->stream_name, stream_name, name_len);
17599 vec_free (stream_name);
17607 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
17609 unformat_input_t *input = vam->input;
17610 vl_api_ip_source_and_port_range_check_add_del_t *mp;
17612 u16 *low_ports = 0;
17613 u16 *high_ports = 0;
17616 ip4_address_t ip4_addr;
17617 ip6_address_t ip6_addr;
17626 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17628 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
17634 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
17639 else if (unformat (input, "vrf %d", &vrf_id))
17641 else if (unformat (input, "del"))
17643 else if (unformat (input, "port %d", &tmp))
17645 if (tmp == 0 || tmp > 65535)
17647 errmsg ("port %d out of range", tmp);
17651 this_hi = this_low + 1;
17652 vec_add1 (low_ports, this_low);
17653 vec_add1 (high_ports, this_hi);
17655 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
17657 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
17659 errmsg ("incorrect range parameters");
17663 /* Note: in debug CLI +1 is added to high before
17664 passing to real fn that does "the work"
17665 (ip_source_and_port_range_check_add_del).
17666 This fn is a wrapper around the binary API fn a
17667 control plane will call, which expects this increment
17668 to have occurred. Hence letting the binary API control
17669 plane fn do the increment for consistency between VAT
17670 and other control planes.
17673 vec_add1 (low_ports, this_low);
17674 vec_add1 (high_ports, this_hi);
17680 if (prefix_set == 0)
17682 errmsg ("<address>/<mask> not specified");
17688 errmsg ("VRF ID required, not specified");
17695 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17699 if (vec_len (low_ports) == 0)
17701 errmsg ("At least one port or port range required");
17705 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
17707 mp->is_add = is_add;
17712 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
17717 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
17720 mp->mask_length = length;
17721 mp->number_of_ranges = vec_len (low_ports);
17723 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
17724 vec_free (low_ports);
17726 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
17727 vec_free (high_ports);
17729 mp->vrf_id = ntohl (vrf_id);
17737 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
17739 unformat_input_t *input = vam->input;
17740 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
17741 u32 sw_if_index = ~0;
17743 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
17744 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
17748 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17750 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17752 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17754 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
17756 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
17758 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
17760 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
17762 else if (unformat (input, "del"))
17768 if (sw_if_index == ~0)
17770 errmsg ("Interface required but not specified");
17776 errmsg ("VRF ID required but not specified");
17780 if (tcp_out_vrf_id == 0
17781 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
17784 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17788 /* Construct the API message */
17789 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
17791 mp->sw_if_index = ntohl (sw_if_index);
17792 mp->is_add = is_add;
17793 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
17794 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
17795 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
17796 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
17801 /* Wait for a reply... */
17807 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
17809 unformat_input_t *i = vam->input;
17810 vl_api_ipsec_gre_add_del_tunnel_t *mp;
17811 u32 local_sa_id = 0;
17812 u32 remote_sa_id = 0;
17813 ip4_address_t src_address;
17814 ip4_address_t dst_address;
17818 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17820 if (unformat (i, "local_sa %d", &local_sa_id))
17822 else if (unformat (i, "remote_sa %d", &remote_sa_id))
17824 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
17826 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
17828 else if (unformat (i, "del"))
17832 clib_warning ("parse error '%U'", format_unformat_error, i);
17837 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
17839 mp->local_sa_id = ntohl (local_sa_id);
17840 mp->remote_sa_id = ntohl (remote_sa_id);
17841 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
17842 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
17843 mp->is_add = is_add;
17851 api_punt (vat_main_t * vam)
17853 unformat_input_t *i = vam->input;
17861 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17863 if (unformat (i, "ip %d", &ipv))
17865 else if (unformat (i, "protocol %d", &protocol))
17867 else if (unformat (i, "port %d", &port))
17869 else if (unformat (i, "del"))
17873 clib_warning ("parse error '%U'", format_unformat_error, i);
17880 mp->is_add = (u8) is_add;
17881 mp->ipv = (u8) ipv;
17882 mp->l4_protocol = (u8) protocol;
17883 mp->l4_port = htons ((u16) port);
17890 static void vl_api_ipsec_gre_tunnel_details_t_handler
17891 (vl_api_ipsec_gre_tunnel_details_t * mp)
17893 vat_main_t *vam = &vat_main;
17895 print (vam->ofp, "%11d%15U%15U%14d%14d",
17896 ntohl (mp->sw_if_index),
17897 format_ip4_address, &mp->src_address,
17898 format_ip4_address, &mp->dst_address,
17899 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
17902 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
17903 (vl_api_ipsec_gre_tunnel_details_t * mp)
17905 vat_main_t *vam = &vat_main;
17906 vat_json_node_t *node = NULL;
17907 struct in_addr ip4;
17909 if (VAT_JSON_ARRAY != vam->json_tree.type)
17911 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17912 vat_json_init_array (&vam->json_tree);
17914 node = vat_json_array_add (&vam->json_tree);
17916 vat_json_init_object (node);
17917 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17918 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
17919 vat_json_object_add_ip4 (node, "src_address", ip4);
17920 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
17921 vat_json_object_add_ip4 (node, "dst_address", ip4);
17922 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
17923 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
17927 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
17929 unformat_input_t *i = vam->input;
17930 vl_api_ipsec_gre_tunnel_dump_t *mp;
17931 vl_api_control_ping_t *mp_ping;
17933 u8 sw_if_index_set = 0;
17936 /* Parse args required to build the message */
17937 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17939 if (unformat (i, "sw_if_index %d", &sw_if_index))
17940 sw_if_index_set = 1;
17945 if (sw_if_index_set == 0)
17950 if (!vam->json_output)
17952 print (vam->ofp, "%11s%15s%15s%14s%14s",
17953 "sw_if_index", "src_address", "dst_address",
17954 "local_sa_id", "remote_sa_id");
17957 /* Get list of gre-tunnel interfaces */
17958 M (IPSEC_GRE_TUNNEL_DUMP, mp);
17960 mp->sw_if_index = htonl (sw_if_index);
17964 /* Use a control ping for synchronization */
17965 M (CONTROL_PING, mp_ping);
17973 api_delete_subif (vat_main_t * vam)
17975 unformat_input_t *i = vam->input;
17976 vl_api_delete_subif_t *mp;
17977 u32 sw_if_index = ~0;
17980 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17982 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17984 if (unformat (i, "sw_if_index %d", &sw_if_index))
17990 if (sw_if_index == ~0)
17992 errmsg ("missing sw_if_index");
17996 /* Construct the API message */
17997 M (DELETE_SUBIF, mp);
17998 mp->sw_if_index = ntohl (sw_if_index);
18005 #define foreach_pbb_vtr_op \
18006 _("disable", L2_VTR_DISABLED) \
18007 _("pop", L2_VTR_POP_2) \
18008 _("push", L2_VTR_PUSH_2)
18011 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
18013 unformat_input_t *i = vam->input;
18014 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
18015 u32 sw_if_index = ~0, vtr_op = ~0;
18016 u16 outer_tag = ~0;
18017 u8 dmac[6], smac[6];
18018 u8 dmac_set = 0, smac_set = 0;
18024 /* Shut up coverity */
18025 memset (dmac, 0, sizeof (dmac));
18026 memset (smac, 0, sizeof (smac));
18028 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18030 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18032 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18034 else if (unformat (i, "vtr_op %d", &vtr_op))
18036 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
18039 else if (unformat (i, "translate_pbb_stag"))
18041 if (unformat (i, "%d", &tmp))
18043 vtr_op = L2_VTR_TRANSLATE_2_1;
18049 ("translate_pbb_stag operation requires outer tag definition");
18053 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
18055 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
18057 else if (unformat (i, "sid %d", &sid))
18059 else if (unformat (i, "vlanid %d", &tmp))
18063 clib_warning ("parse error '%U'", format_unformat_error, i);
18068 if ((sw_if_index == ~0) || (vtr_op == ~0))
18070 errmsg ("missing sw_if_index or vtr operation");
18073 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
18074 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
18077 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
18081 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
18082 mp->sw_if_index = ntohl (sw_if_index);
18083 mp->vtr_op = ntohl (vtr_op);
18084 mp->outer_tag = ntohs (outer_tag);
18085 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
18086 clib_memcpy (mp->b_smac, smac, sizeof (smac));
18087 mp->b_vlanid = ntohs (vlanid);
18088 mp->i_sid = ntohl (sid);
18096 api_flow_classify_set_interface (vat_main_t * vam)
18098 unformat_input_t *i = vam->input;
18099 vl_api_flow_classify_set_interface_t *mp;
18101 int sw_if_index_set;
18102 u32 ip4_table_index = ~0;
18103 u32 ip6_table_index = ~0;
18107 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18109 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18110 sw_if_index_set = 1;
18111 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18112 sw_if_index_set = 1;
18113 else if (unformat (i, "del"))
18115 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18117 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18121 clib_warning ("parse error '%U'", format_unformat_error, i);
18126 if (sw_if_index_set == 0)
18128 errmsg ("missing interface name or sw_if_index");
18132 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
18134 mp->sw_if_index = ntohl (sw_if_index);
18135 mp->ip4_table_index = ntohl (ip4_table_index);
18136 mp->ip6_table_index = ntohl (ip6_table_index);
18137 mp->is_add = is_add;
18145 api_flow_classify_dump (vat_main_t * vam)
18147 unformat_input_t *i = vam->input;
18148 vl_api_flow_classify_dump_t *mp;
18149 vl_api_control_ping_t *mp_ping;
18150 u8 type = FLOW_CLASSIFY_N_TABLES;
18153 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
18157 errmsg ("classify table type must be specified");
18161 if (!vam->json_output)
18163 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18166 M (FLOW_CLASSIFY_DUMP, mp);
18171 /* Use a control ping for synchronization */
18172 M (CONTROL_PING, mp_ping);
18175 /* Wait for a reply... */
18181 api_feature_enable_disable (vat_main_t * vam)
18183 unformat_input_t *i = vam->input;
18184 vl_api_feature_enable_disable_t *mp;
18186 u8 *feature_name = 0;
18187 u32 sw_if_index = ~0;
18191 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18193 if (unformat (i, "arc_name %s", &arc_name))
18195 else if (unformat (i, "feature_name %s", &feature_name))
18198 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18200 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18202 else if (unformat (i, "disable"))
18210 errmsg ("missing arc name");
18213 if (vec_len (arc_name) > 63)
18215 errmsg ("arc name too long");
18218 if (feature_name == 0)
18220 errmsg ("missing feature name");
18223 if (vec_len (feature_name) > 63)
18225 errmsg ("feature name too long");
18228 if (sw_if_index == ~0)
18230 errmsg ("missing interface name or sw_if_index");
18234 /* Construct the API message */
18235 M (FEATURE_ENABLE_DISABLE, mp);
18236 mp->sw_if_index = ntohl (sw_if_index);
18237 mp->enable = enable;
18238 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
18239 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
18240 vec_free (arc_name);
18241 vec_free (feature_name);
18249 api_sw_interface_tag_add_del (vat_main_t * vam)
18251 unformat_input_t *i = vam->input;
18252 vl_api_sw_interface_tag_add_del_t *mp;
18253 u32 sw_if_index = ~0;
18258 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18260 if (unformat (i, "tag %s", &tag))
18262 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18264 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18266 else if (unformat (i, "del"))
18272 if (sw_if_index == ~0)
18274 errmsg ("missing interface name or sw_if_index");
18278 if (enable && (tag == 0))
18280 errmsg ("no tag specified");
18284 /* Construct the API message */
18285 M (SW_INTERFACE_TAG_ADD_DEL, mp);
18286 mp->sw_if_index = ntohl (sw_if_index);
18287 mp->is_add = enable;
18289 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
18297 static void vl_api_l2_xconnect_details_t_handler
18298 (vl_api_l2_xconnect_details_t * mp)
18300 vat_main_t *vam = &vat_main;
18302 print (vam->ofp, "%15d%15d",
18303 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
18306 static void vl_api_l2_xconnect_details_t_handler_json
18307 (vl_api_l2_xconnect_details_t * mp)
18309 vat_main_t *vam = &vat_main;
18310 vat_json_node_t *node = NULL;
18312 if (VAT_JSON_ARRAY != vam->json_tree.type)
18314 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18315 vat_json_init_array (&vam->json_tree);
18317 node = vat_json_array_add (&vam->json_tree);
18319 vat_json_init_object (node);
18320 vat_json_object_add_uint (node, "rx_sw_if_index",
18321 ntohl (mp->rx_sw_if_index));
18322 vat_json_object_add_uint (node, "tx_sw_if_index",
18323 ntohl (mp->tx_sw_if_index));
18327 api_l2_xconnect_dump (vat_main_t * vam)
18329 vl_api_l2_xconnect_dump_t *mp;
18330 vl_api_control_ping_t *mp_ping;
18333 if (!vam->json_output)
18335 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
18338 M (L2_XCONNECT_DUMP, mp);
18342 /* Use a control ping for synchronization */
18343 M (CONTROL_PING, mp_ping);
18351 api_sw_interface_set_mtu (vat_main_t * vam)
18353 unformat_input_t *i = vam->input;
18354 vl_api_sw_interface_set_mtu_t *mp;
18355 u32 sw_if_index = ~0;
18359 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18361 if (unformat (i, "mtu %d", &mtu))
18363 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18365 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18371 if (sw_if_index == ~0)
18373 errmsg ("missing interface name or sw_if_index");
18379 errmsg ("no mtu specified");
18383 /* Construct the API message */
18384 M (SW_INTERFACE_SET_MTU, mp);
18385 mp->sw_if_index = ntohl (sw_if_index);
18386 mp->mtu = ntohs ((u16) mtu);
18395 q_or_quit (vat_main_t * vam)
18397 #if VPP_API_TEST_BUILTIN == 0
18398 longjmp (vam->jump_buf, 1);
18400 return 0; /* not so much */
18404 q (vat_main_t * vam)
18406 return q_or_quit (vam);
18410 quit (vat_main_t * vam)
18412 return q_or_quit (vam);
18416 comment (vat_main_t * vam)
18422 cmd_cmp (void *a1, void *a2)
18427 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
18431 help (vat_main_t * vam)
18436 unformat_input_t *i = vam->input;
18439 if (unformat (i, "%s", &name))
18443 vec_add1 (name, 0);
18445 hs = hash_get_mem (vam->help_by_name, name);
18447 print (vam->ofp, "usage: %s %s", name, hs[0]);
18449 print (vam->ofp, "No such msg / command '%s'", name);
18454 print (vam->ofp, "Help is available for the following:");
18457 hash_foreach_pair (p, vam->function_by_name,
18459 vec_add1 (cmds, (u8 *)(p->key));
18463 vec_sort_with_function (cmds, cmd_cmp);
18465 for (j = 0; j < vec_len (cmds); j++)
18466 print (vam->ofp, "%s", cmds[j]);
18473 set (vat_main_t * vam)
18475 u8 *name = 0, *value = 0;
18476 unformat_input_t *i = vam->input;
18478 if (unformat (i, "%s", &name))
18480 /* The input buffer is a vector, not a string. */
18481 value = vec_dup (i->buffer);
18482 vec_delete (value, i->index, 0);
18483 /* Almost certainly has a trailing newline */
18484 if (value[vec_len (value) - 1] == '\n')
18485 value[vec_len (value) - 1] = 0;
18486 /* Make sure it's a proper string, one way or the other */
18487 vec_add1 (value, 0);
18488 (void) clib_macro_set_value (&vam->macro_main,
18489 (char *) name, (char *) value);
18492 errmsg ("usage: set <name> <value>");
18500 unset (vat_main_t * vam)
18504 if (unformat (vam->input, "%s", &name))
18505 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
18506 errmsg ("unset: %s wasn't set", name);
18519 macro_sort_cmp (void *a1, void *a2)
18521 macro_sort_t *s1 = a1;
18522 macro_sort_t *s2 = a2;
18524 return strcmp ((char *) (s1->name), (char *) (s2->name));
18528 dump_macro_table (vat_main_t * vam)
18530 macro_sort_t *sort_me = 0, *sm;
18535 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
18537 vec_add2 (sort_me, sm, 1);
18538 sm->name = (u8 *)(p->key);
18539 sm->value = (u8 *) (p->value[0]);
18543 vec_sort_with_function (sort_me, macro_sort_cmp);
18545 if (vec_len (sort_me))
18546 print (vam->ofp, "%-15s%s", "Name", "Value");
18548 print (vam->ofp, "The macro table is empty...");
18550 for (i = 0; i < vec_len (sort_me); i++)
18551 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
18556 dump_node_table (vat_main_t * vam)
18559 vlib_node_t *node, *next_node;
18561 if (vec_len (vam->graph_nodes) == 0)
18563 print (vam->ofp, "Node table empty, issue get_node_graph...");
18567 for (i = 0; i < vec_len (vam->graph_nodes); i++)
18569 node = vam->graph_nodes[i];
18570 print (vam->ofp, "[%d] %s", i, node->name);
18571 for (j = 0; j < vec_len (node->next_nodes); j++)
18573 if (node->next_nodes[j] != ~0)
18575 next_node = vam->graph_nodes[node->next_nodes[j]];
18576 print (vam->ofp, " [%d] %s", j, next_node->name);
18584 value_sort_cmp (void *a1, void *a2)
18586 name_sort_t *n1 = a1;
18587 name_sort_t *n2 = a2;
18589 if (n1->value < n2->value)
18591 if (n1->value > n2->value)
18598 dump_msg_api_table (vat_main_t * vam)
18600 api_main_t *am = &api_main;
18601 name_sort_t *nses = 0, *ns;
18606 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
18608 vec_add2 (nses, ns, 1);
18609 ns->name = (u8 *)(hp->key);
18610 ns->value = (u32) hp->value[0];
18614 vec_sort_with_function (nses, value_sort_cmp);
18616 for (i = 0; i < vec_len (nses); i++)
18617 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
18623 get_msg_id (vat_main_t * vam)
18628 if (unformat (vam->input, "%s", &name_and_crc))
18630 message_index = vl_api_get_msg_index (name_and_crc);
18631 if (message_index == ~0)
18633 print (vam->ofp, " '%s' not found", name_and_crc);
18636 print (vam->ofp, " '%s' has message index %d",
18637 name_and_crc, message_index);
18640 errmsg ("name_and_crc required...");
18645 search_node_table (vat_main_t * vam)
18647 unformat_input_t *line_input = vam->input;
18650 vlib_node_t *node, *next_node;
18653 if (vam->graph_node_index_by_name == 0)
18655 print (vam->ofp, "Node table empty, issue get_node_graph...");
18659 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
18661 if (unformat (line_input, "%s", &node_to_find))
18663 vec_add1 (node_to_find, 0);
18664 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
18667 print (vam->ofp, "%s not found...", node_to_find);
18670 node = vam->graph_nodes[p[0]];
18671 print (vam->ofp, "[%d] %s", p[0], node->name);
18672 for (j = 0; j < vec_len (node->next_nodes); j++)
18674 if (node->next_nodes[j] != ~0)
18676 next_node = vam->graph_nodes[node->next_nodes[j]];
18677 print (vam->ofp, " [%d] %s", j, next_node->name);
18684 clib_warning ("parse error '%U'", format_unformat_error,
18690 vec_free (node_to_find);
18699 script (vat_main_t * vam)
18701 #if (VPP_API_TEST_BUILTIN==0)
18703 char *save_current_file;
18704 unformat_input_t save_input;
18705 jmp_buf save_jump_buf;
18706 u32 save_line_number;
18708 FILE *new_fp, *save_ifp;
18710 if (unformat (vam->input, "%s", &s))
18712 new_fp = fopen ((char *) s, "r");
18715 errmsg ("Couldn't open script file %s", s);
18722 errmsg ("Missing script name");
18726 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
18727 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
18728 save_ifp = vam->ifp;
18729 save_line_number = vam->input_line_number;
18730 save_current_file = (char *) vam->current_file;
18732 vam->input_line_number = 0;
18734 vam->current_file = s;
18737 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
18738 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
18739 vam->ifp = save_ifp;
18740 vam->input_line_number = save_line_number;
18741 vam->current_file = (u8 *) save_current_file;
18746 clib_warning ("use the exec command...");
18752 echo (vat_main_t * vam)
18754 print (vam->ofp, "%v", vam->input->buffer);
18758 /* List of API message constructors, CLI names map to api_xxx */
18759 #define foreach_vpe_api_msg \
18760 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
18761 _(sw_interface_dump,"") \
18762 _(sw_interface_set_flags, \
18763 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
18764 _(sw_interface_add_del_address, \
18765 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
18766 _(sw_interface_set_table, \
18767 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
18768 _(sw_interface_set_mpls_enable, \
18769 "<intfc> | sw_if_index [disable | dis]") \
18770 _(sw_interface_set_vpath, \
18771 "<intfc> | sw_if_index <id> enable | disable") \
18772 _(sw_interface_set_vxlan_bypass, \
18773 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
18774 _(sw_interface_set_l2_xconnect, \
18775 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18776 "enable | disable") \
18777 _(sw_interface_set_l2_bridge, \
18778 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
18779 "[shg <split-horizon-group>] [bvi]\n" \
18780 "enable | disable") \
18781 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
18782 _(bridge_domain_add_del, \
18783 "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") \
18784 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
18786 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
18787 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
18788 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
18790 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
18792 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
18794 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
18796 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
18798 "<vpp-if-name> | sw_if_index <id>") \
18799 _(sw_interface_tap_dump, "") \
18800 _(ip_add_del_route, \
18801 "<addr>/<mask> via <addr> [table-id <n>]\n" \
18802 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18803 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18804 "[multipath] [count <n>]") \
18805 _(ip_mroute_add_del, \
18806 "<src> <grp>/<mask> [table-id <n>]\n" \
18807 "[<intfc> | sw_if_index <id>] [local] [del]") \
18808 _(mpls_route_add_del, \
18809 "<label> <eos> via <addr> [table-id <n>]\n" \
18810 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18811 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18812 "[multipath] [count <n>]") \
18813 _(mpls_ip_bind_unbind, \
18814 "<label> <addr/len>") \
18815 _(mpls_tunnel_add_del, \
18816 " via <addr> [table-id <n>]\n" \
18817 "sw_if_index <id>] [l2] [del]") \
18818 _(proxy_arp_add_del, \
18819 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
18820 _(proxy_arp_intfc_enable_disable, \
18821 "<intfc> | sw_if_index <id> enable | disable") \
18822 _(sw_interface_set_unnumbered, \
18823 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
18824 _(ip_neighbor_add_del, \
18825 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
18826 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
18827 _(reset_vrf, "vrf <id> [ipv6]") \
18828 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
18829 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
18830 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
18831 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
18832 "[outer_vlan_id_any][inner_vlan_id_any]") \
18833 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
18834 _(reset_fib, "vrf <n> [ipv6]") \
18835 _(dhcp_proxy_config, \
18836 "svr <v46-address> src <v46-address>\n" \
18837 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
18838 _(dhcp_proxy_set_vss, \
18839 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
18840 _(dhcp_proxy_dump, "ip6") \
18841 _(dhcp_client_config, \
18842 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
18843 _(set_ip_flow_hash, \
18844 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
18845 _(sw_interface_ip6_enable_disable, \
18846 "<intfc> | sw_if_index <id> enable | disable") \
18847 _(sw_interface_ip6_set_link_local_address, \
18848 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
18849 _(ip6nd_proxy_add_del, \
18850 "<intfc> | sw_if_index <id> <ip6-address>") \
18851 _(ip6nd_proxy_dump, "") \
18852 _(sw_interface_ip6nd_ra_prefix, \
18853 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
18854 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
18855 "[nolink] [isno]") \
18856 _(sw_interface_ip6nd_ra_config, \
18857 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
18858 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
18859 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
18860 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
18861 _(l2_patch_add_del, \
18862 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18863 "enable | disable") \
18864 _(sr_localsid_add_del, \
18865 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
18866 "fib-table <num> (end.psp) sw_if_index <num>") \
18867 _(classify_add_del_table, \
18868 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
18869 " [del] [del-chain] mask <mask-value>\n" \
18870 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
18871 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
18872 _(classify_add_del_session, \
18873 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
18874 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
18875 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
18876 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
18877 _(classify_set_interface_ip_table, \
18878 "<intfc> | sw_if_index <nn> table <nn>") \
18879 _(classify_set_interface_l2_tables, \
18880 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18881 " [other-table <nn>]") \
18882 _(get_node_index, "node <node-name") \
18883 _(add_node_next, "node <node-name> next <next-node-name>") \
18884 _(l2tpv3_create_tunnel, \
18885 "client_address <ip6-addr> our_address <ip6-addr>\n" \
18886 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
18887 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
18888 _(l2tpv3_set_tunnel_cookies, \
18889 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
18890 "[new_remote_cookie <nn>]\n") \
18891 _(l2tpv3_interface_enable_disable, \
18892 "<intfc> | sw_if_index <nn> enable | disable") \
18893 _(l2tpv3_set_lookup_key, \
18894 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
18895 _(sw_if_l2tpv3_tunnel_dump, "") \
18896 _(vxlan_add_del_tunnel, \
18897 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
18898 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
18899 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
18900 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18901 _(gre_add_del_tunnel, \
18902 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
18903 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18904 _(l2_fib_clear_table, "") \
18905 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
18906 _(l2_interface_vlan_tag_rewrite, \
18907 "<intfc> | sw_if_index <nn> \n" \
18908 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
18909 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
18910 _(create_vhost_user_if, \
18911 "socket <filename> [server] [renumber <dev_instance>] " \
18912 "[mac <mac_address>] " \
18913 "[mode <interrupt | polling>]") \
18914 _(modify_vhost_user_if, \
18915 "<intfc> | sw_if_index <nn> socket <filename>\n" \
18916 "[server] [renumber <dev_instance>] " \
18917 "[mode <interrupt | polling>]") \
18918 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
18919 _(sw_interface_vhost_user_dump, "") \
18920 _(show_version, "") \
18921 _(vxlan_gpe_add_del_tunnel, \
18922 "local <addr> remote <addr> vni <nn>\n" \
18923 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
18924 "[next-ethernet] [next-nsh]\n") \
18925 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18926 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
18927 _(interface_name_renumber, \
18928 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
18929 _(input_acl_set_interface, \
18930 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18931 " [l2-table <nn>] [del]") \
18932 _(want_ip4_arp_events, "address <ip4-address> [del]") \
18933 _(want_ip6_nd_events, "address <ip6-address> [del]") \
18934 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
18935 _(ip_dump, "ipv4 | ipv6") \
18936 _(ipsec_spd_add_del, "spd_id <n> [del]") \
18937 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
18939 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
18940 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
18941 " integ_alg <alg> integ_key <hex>") \
18942 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
18943 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
18944 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
18945 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
18946 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
18947 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
18948 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
18949 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
18950 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
18951 _(ikev2_profile_add_del, "name <profile_name> [del]") \
18952 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
18953 "(auth_data 0x<data> | auth_data <data>)") \
18954 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
18955 "(id_data 0x<data> | id_data <data>) (local|remote)") \
18956 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
18957 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
18958 "(local|remote)") \
18959 _(ikev2_set_local_key, "file <absolute_file_path>") \
18960 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
18961 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18962 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18963 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
18964 _(ikev2_initiate_sa_init, "<profile_name>") \
18965 _(ikev2_initiate_del_ike_sa, "<ispi>") \
18966 _(ikev2_initiate_del_child_sa, "<ispi>") \
18967 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
18968 _(delete_loopback,"sw_if_index <nn>") \
18969 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
18970 _(map_add_domain, \
18971 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
18972 "ip6-src <ip6addr> " \
18973 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
18974 _(map_del_domain, "index <n>") \
18975 _(map_add_del_rule, \
18976 "index <n> psid <n> dst <ip6addr> [del]") \
18977 _(map_domain_dump, "") \
18978 _(map_rule_dump, "index <map-domain>") \
18979 _(want_interface_events, "enable|disable") \
18980 _(want_stats,"enable|disable") \
18981 _(get_first_msg_id, "client <name>") \
18982 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
18983 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
18984 "fib-id <nn> [ip4][ip6][default]") \
18985 _(get_node_graph, " ") \
18986 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
18987 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
18988 _(ioam_disable, "") \
18989 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
18990 " sw_if_index <sw_if_index> p <priority> " \
18991 "w <weight>] [del]") \
18992 _(one_add_del_locator, "locator-set <locator_name> " \
18993 "iface <intf> | sw_if_index <sw_if_index> " \
18994 "p <priority> w <weight> [del]") \
18995 _(one_add_del_local_eid,"vni <vni> eid " \
18996 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18997 "locator-set <locator_name> [del]" \
18998 "[key-id sha1|sha256 secret-key <secret-key>]")\
18999 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
19000 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
19001 _(one_enable_disable, "enable|disable") \
19002 _(one_map_register_enable_disable, "enable|disable") \
19003 _(one_rloc_probe_enable_disable, "enable|disable") \
19004 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
19006 "rloc <locator> p <prio> " \
19007 "w <weight> [rloc <loc> ... ] " \
19008 "action <action> [del-all]") \
19009 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
19011 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
19012 _(one_use_petr, "ip-address> | disable") \
19013 _(one_map_request_mode, "src-dst|dst-only") \
19014 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
19015 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
19016 _(one_locator_set_dump, "[local | remote]") \
19017 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
19018 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
19019 "[local] | [remote]") \
19020 _(one_stats_enable_disable, "enable|disalbe") \
19021 _(show_one_stats_enable_disable, "") \
19022 _(one_eid_table_vni_dump, "") \
19023 _(one_eid_table_map_dump, "l2|l3") \
19024 _(one_map_resolver_dump, "") \
19025 _(one_map_server_dump, "") \
19026 _(one_adjacencies_get, "vni <vni>") \
19027 _(show_one_rloc_probe_state, "") \
19028 _(show_one_map_register_state, "") \
19029 _(show_one_status, "") \
19030 _(one_stats_dump, "") \
19031 _(one_stats_flush, "") \
19032 _(one_get_map_request_itr_rlocs, "") \
19033 _(show_one_pitr, "") \
19034 _(show_one_use_petr, "") \
19035 _(show_one_map_request_mode, "") \
19036 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
19037 " sw_if_index <sw_if_index> p <priority> " \
19038 "w <weight>] [del]") \
19039 _(lisp_add_del_locator, "locator-set <locator_name> " \
19040 "iface <intf> | sw_if_index <sw_if_index> " \
19041 "p <priority> w <weight> [del]") \
19042 _(lisp_add_del_local_eid,"vni <vni> eid " \
19043 "<ipv4|ipv6>/<prefix> | <L2 address> " \
19044 "locator-set <locator_name> [del]" \
19045 "[key-id sha1|sha256 secret-key <secret-key>]") \
19046 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
19047 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
19048 _(lisp_enable_disable, "enable|disable") \
19049 _(lisp_map_register_enable_disable, "enable|disable") \
19050 _(lisp_rloc_probe_enable_disable, "enable|disable") \
19051 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
19053 "rloc <locator> p <prio> " \
19054 "w <weight> [rloc <loc> ... ] " \
19055 "action <action> [del-all]") \
19056 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
19058 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
19059 _(lisp_use_petr, "<ip-address> | disable") \
19060 _(lisp_map_request_mode, "src-dst|dst-only") \
19061 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
19062 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
19063 _(lisp_locator_set_dump, "[local | remote]") \
19064 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
19065 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
19066 "[local] | [remote]") \
19067 _(lisp_eid_table_vni_dump, "") \
19068 _(lisp_eid_table_map_dump, "l2|l3") \
19069 _(lisp_map_resolver_dump, "") \
19070 _(lisp_map_server_dump, "") \
19071 _(lisp_adjacencies_get, "vni <vni>") \
19072 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
19073 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
19074 _(gpe_set_encap_mode, "lisp|vxlan") \
19075 _(gpe_get_encap_mode, "") \
19076 _(lisp_gpe_add_del_iface, "up|down") \
19077 _(lisp_gpe_enable_disable, "enable|disable") \
19078 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
19079 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
19080 _(show_lisp_rloc_probe_state, "") \
19081 _(show_lisp_map_register_state, "") \
19082 _(show_lisp_status, "") \
19083 _(lisp_get_map_request_itr_rlocs, "") \
19084 _(show_lisp_pitr, "") \
19085 _(show_lisp_use_petr, "") \
19086 _(show_lisp_map_request_mode, "") \
19087 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
19088 _(af_packet_delete, "name <host interface name>") \
19089 _(policer_add_del, "name <policer name> <params> [del]") \
19090 _(policer_dump, "[name <policer name>]") \
19091 _(policer_classify_set_interface, \
19092 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19093 " [l2-table <nn>] [del]") \
19094 _(policer_classify_dump, "type [ip4|ip6|l2]") \
19095 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
19096 "[master|slave]") \
19097 _(netmap_delete, "name <interface name>") \
19098 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
19099 _(mpls_fib_dump, "") \
19100 _(classify_table_ids, "") \
19101 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
19102 _(classify_table_info, "table_id <nn>") \
19103 _(classify_session_dump, "table_id <nn>") \
19104 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
19105 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
19106 "[template_interval <nn>] [udp_checksum]") \
19107 _(ipfix_exporter_dump, "") \
19108 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
19109 _(ipfix_classify_stream_dump, "") \
19110 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
19111 _(ipfix_classify_table_dump, "") \
19112 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
19113 _(sw_interface_span_dump, "") \
19114 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
19115 _(pg_create_interface, "if_id <nn>") \
19116 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
19117 _(pg_enable_disable, "[stream <id>] disable") \
19118 _(ip_source_and_port_range_check_add_del, \
19119 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
19120 _(ip_source_and_port_range_check_interface_add_del, \
19121 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
19122 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
19123 _(ipsec_gre_add_del_tunnel, \
19124 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
19125 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
19126 _(delete_subif,"<intfc> | sw_if_index <nn>") \
19127 _(l2_interface_pbb_tag_rewrite, \
19128 "<intfc> | sw_if_index <nn> \n" \
19129 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
19130 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
19131 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
19132 _(flow_classify_set_interface, \
19133 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
19134 _(flow_classify_dump, "type [ip4|ip6]") \
19135 _(ip_fib_dump, "") \
19136 _(ip_mfib_dump, "") \
19137 _(ip6_fib_dump, "") \
19138 _(ip6_mfib_dump, "") \
19139 _(feature_enable_disable, "arc_name <arc_name> " \
19140 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
19141 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
19143 _(l2_xconnect_dump, "") \
19144 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
19145 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
19146 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
19148 /* List of command functions, CLI names map directly to functions */
19149 #define foreach_cli_function \
19150 _(comment, "usage: comment <ignore-rest-of-line>") \
19151 _(dump_interface_table, "usage: dump_interface_table") \
19152 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
19153 _(dump_ipv4_table, "usage: dump_ipv4_table") \
19154 _(dump_ipv6_table, "usage: dump_ipv6_table") \
19155 _(dump_stats_table, "usage: dump_stats_table") \
19156 _(dump_macro_table, "usage: dump_macro_table ") \
19157 _(dump_node_table, "usage: dump_node_table") \
19158 _(dump_msg_api_table, "usage: dump_msg_api_table") \
19159 _(get_msg_id, "usage: get_msg_id name_and_crc") \
19160 _(echo, "usage: echo <message>") \
19161 _(exec, "usage: exec <vpe-debug-CLI-command>") \
19162 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
19163 _(help, "usage: help") \
19164 _(q, "usage: quit") \
19165 _(quit, "usage: quit") \
19166 _(search_node_table, "usage: search_node_table <name>...") \
19167 _(set, "usage: set <variable-name> <value>") \
19168 _(script, "usage: script <file-name>") \
19169 _(unset, "usage: unset <variable-name>")
19172 static void vl_api_##n##_t_handler_uni \
19173 (vl_api_##n##_t * mp) \
19175 vat_main_t * vam = &vat_main; \
19176 if (vam->json_output) { \
19177 vl_api_##n##_t_handler_json(mp); \
19179 vl_api_##n##_t_handler(mp); \
19182 foreach_vpe_api_reply_msg;
19183 #if VPP_API_TEST_BUILTIN == 0
19184 foreach_standalone_reply_msg;
19189 vat_api_hookup (vat_main_t * vam)
19192 vl_msg_api_set_handlers(VL_API_##N, #n, \
19193 vl_api_##n##_t_handler_uni, \
19195 vl_api_##n##_t_endian, \
19196 vl_api_##n##_t_print, \
19197 sizeof(vl_api_##n##_t), 1);
19198 foreach_vpe_api_reply_msg;
19199 #if VPP_API_TEST_BUILTIN == 0
19200 foreach_standalone_reply_msg;
19204 #if (VPP_API_TEST_BUILTIN==0)
19205 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
19207 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
19209 vam->function_by_name = hash_create_string (0, sizeof (uword));
19211 vam->help_by_name = hash_create_string (0, sizeof (uword));
19214 /* API messages we can send */
19215 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
19216 foreach_vpe_api_msg;
19220 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
19221 foreach_vpe_api_msg;
19224 /* CLI functions */
19225 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
19226 foreach_cli_function;
19230 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
19231 foreach_cli_function;
19235 #if VPP_API_TEST_BUILTIN
19236 static clib_error_t *
19237 vat_api_hookup_shim (vlib_main_t * vm)
19239 vat_api_hookup (&vat_main);
19243 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
19247 * fd.io coding-style-patch-verification: ON
19250 * eval: (c-set-style "gnu")