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 */
1326 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1327 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1330 * Special-case: build the bridge domain table, maintain
1331 * the next bd id vbl.
1333 static void vl_api_bridge_domain_details_t_handler
1334 (vl_api_bridge_domain_details_t * mp)
1336 vat_main_t *vam = &vat_main;
1337 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1340 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1341 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1343 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1344 ntohl (mp->bd_id), mp->learn, mp->forward,
1345 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1349 vl_api_bridge_domain_sw_if_t *sw_ifs;
1350 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1353 sw_ifs = mp->sw_if_details;
1354 for (i = 0; i < n_sw_ifs; i++)
1360 sw_if_index = ntohl (sw_ifs->sw_if_index);
1363 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1365 if ((u32) p->value[0] == sw_if_index)
1367 sw_if_name = (u8 *)(p->key);
1372 print (vam->ofp, "%7d %3d %s", sw_if_index,
1373 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1374 "sw_if_index not found!");
1381 static void vl_api_bridge_domain_details_t_handler_json
1382 (vl_api_bridge_domain_details_t * mp)
1384 vat_main_t *vam = &vat_main;
1385 vat_json_node_t *node, *array = NULL;
1386 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1388 if (VAT_JSON_ARRAY != vam->json_tree.type)
1390 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1391 vat_json_init_array (&vam->json_tree);
1393 node = vat_json_array_add (&vam->json_tree);
1395 vat_json_init_object (node);
1396 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1397 vat_json_object_add_uint (node, "flood", mp->flood);
1398 vat_json_object_add_uint (node, "forward", mp->forward);
1399 vat_json_object_add_uint (node, "learn", mp->learn);
1400 vat_json_object_add_uint (node, "bvi_sw_if_index",
1401 ntohl (mp->bvi_sw_if_index));
1402 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1403 array = vat_json_object_add (node, "sw_if");
1404 vat_json_init_array (array);
1410 vl_api_bridge_domain_sw_if_t *sw_ifs;
1413 sw_ifs = mp->sw_if_details;
1414 for (i = 0; i < n_sw_ifs; i++)
1416 node = vat_json_array_add (array);
1417 vat_json_init_object (node);
1418 vat_json_object_add_uint (node, "sw_if_index",
1419 ntohl (sw_ifs->sw_if_index));
1420 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1426 static void vl_api_control_ping_reply_t_handler
1427 (vl_api_control_ping_reply_t * mp)
1429 vat_main_t *vam = &vat_main;
1430 i32 retval = ntohl (mp->retval);
1431 if (vam->async_mode)
1433 vam->async_errors += (retval < 0);
1437 vam->retval = retval;
1438 vam->result_ready = 1;
1442 static void vl_api_control_ping_reply_t_handler_json
1443 (vl_api_control_ping_reply_t * mp)
1445 vat_main_t *vam = &vat_main;
1446 i32 retval = ntohl (mp->retval);
1448 if (VAT_JSON_NONE != vam->json_tree.type)
1450 vat_json_print (vam->ofp, &vam->json_tree);
1451 vat_json_free (&vam->json_tree);
1452 vam->json_tree.type = VAT_JSON_NONE;
1457 vat_json_init_array (&vam->json_tree);
1458 vat_json_print (vam->ofp, &vam->json_tree);
1459 vam->json_tree.type = VAT_JSON_NONE;
1462 vam->retval = retval;
1463 vam->result_ready = 1;
1467 vl_api_bridge_domain_set_mac_age_reply_t_handler
1468 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1470 vat_main_t *vam = &vat_main;
1471 i32 retval = ntohl (mp->retval);
1472 if (vam->async_mode)
1474 vam->async_errors += (retval < 0);
1478 vam->retval = retval;
1479 vam->result_ready = 1;
1483 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1484 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1486 vat_main_t *vam = &vat_main;
1487 vat_json_node_t node;
1489 vat_json_init_object (&node);
1490 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1492 vat_json_print (vam->ofp, &node);
1493 vat_json_free (&node);
1495 vam->retval = ntohl (mp->retval);
1496 vam->result_ready = 1;
1500 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1502 vat_main_t *vam = &vat_main;
1503 i32 retval = ntohl (mp->retval);
1504 if (vam->async_mode)
1506 vam->async_errors += (retval < 0);
1510 vam->retval = retval;
1511 vam->result_ready = 1;
1515 static void vl_api_l2_flags_reply_t_handler_json
1516 (vl_api_l2_flags_reply_t * mp)
1518 vat_main_t *vam = &vat_main;
1519 vat_json_node_t node;
1521 vat_json_init_object (&node);
1522 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1523 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1524 ntohl (mp->resulting_feature_bitmap));
1526 vat_json_print (vam->ofp, &node);
1527 vat_json_free (&node);
1529 vam->retval = ntohl (mp->retval);
1530 vam->result_ready = 1;
1533 static void vl_api_bridge_flags_reply_t_handler
1534 (vl_api_bridge_flags_reply_t * mp)
1536 vat_main_t *vam = &vat_main;
1537 i32 retval = ntohl (mp->retval);
1538 if (vam->async_mode)
1540 vam->async_errors += (retval < 0);
1544 vam->retval = retval;
1545 vam->result_ready = 1;
1549 static void vl_api_bridge_flags_reply_t_handler_json
1550 (vl_api_bridge_flags_reply_t * mp)
1552 vat_main_t *vam = &vat_main;
1553 vat_json_node_t node;
1555 vat_json_init_object (&node);
1556 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1557 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1558 ntohl (mp->resulting_feature_bitmap));
1560 vat_json_print (vam->ofp, &node);
1561 vat_json_free (&node);
1563 vam->retval = ntohl (mp->retval);
1564 vam->result_ready = 1;
1567 static void vl_api_tap_connect_reply_t_handler
1568 (vl_api_tap_connect_reply_t * mp)
1570 vat_main_t *vam = &vat_main;
1571 i32 retval = ntohl (mp->retval);
1572 if (vam->async_mode)
1574 vam->async_errors += (retval < 0);
1578 vam->retval = retval;
1579 vam->sw_if_index = ntohl (mp->sw_if_index);
1580 vam->result_ready = 1;
1585 static void vl_api_tap_connect_reply_t_handler_json
1586 (vl_api_tap_connect_reply_t * mp)
1588 vat_main_t *vam = &vat_main;
1589 vat_json_node_t node;
1591 vat_json_init_object (&node);
1592 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1593 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1595 vat_json_print (vam->ofp, &node);
1596 vat_json_free (&node);
1598 vam->retval = ntohl (mp->retval);
1599 vam->result_ready = 1;
1604 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1606 vat_main_t *vam = &vat_main;
1607 i32 retval = ntohl (mp->retval);
1608 if (vam->async_mode)
1610 vam->async_errors += (retval < 0);
1614 vam->retval = retval;
1615 vam->sw_if_index = ntohl (mp->sw_if_index);
1616 vam->result_ready = 1;
1620 static void vl_api_tap_modify_reply_t_handler_json
1621 (vl_api_tap_modify_reply_t * mp)
1623 vat_main_t *vam = &vat_main;
1624 vat_json_node_t node;
1626 vat_json_init_object (&node);
1627 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1628 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1630 vat_json_print (vam->ofp, &node);
1631 vat_json_free (&node);
1633 vam->retval = ntohl (mp->retval);
1634 vam->result_ready = 1;
1638 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1640 vat_main_t *vam = &vat_main;
1641 i32 retval = ntohl (mp->retval);
1642 if (vam->async_mode)
1644 vam->async_errors += (retval < 0);
1648 vam->retval = retval;
1649 vam->result_ready = 1;
1653 static void vl_api_tap_delete_reply_t_handler_json
1654 (vl_api_tap_delete_reply_t * mp)
1656 vat_main_t *vam = &vat_main;
1657 vat_json_node_t node;
1659 vat_json_init_object (&node);
1660 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1662 vat_json_print (vam->ofp, &node);
1663 vat_json_free (&node);
1665 vam->retval = ntohl (mp->retval);
1666 vam->result_ready = 1;
1669 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1670 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1672 vat_main_t *vam = &vat_main;
1673 i32 retval = ntohl (mp->retval);
1674 if (vam->async_mode)
1676 vam->async_errors += (retval < 0);
1680 vam->retval = retval;
1681 vam->result_ready = 1;
1685 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1686 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1688 vat_main_t *vam = &vat_main;
1689 vat_json_node_t node;
1691 vat_json_init_object (&node);
1692 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1693 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1694 ntohl (mp->sw_if_index));
1696 vat_json_print (vam->ofp, &node);
1697 vat_json_free (&node);
1699 vam->retval = ntohl (mp->retval);
1700 vam->result_ready = 1;
1703 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1704 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1706 vat_main_t *vam = &vat_main;
1707 i32 retval = ntohl (mp->retval);
1708 if (vam->async_mode)
1710 vam->async_errors += (retval < 0);
1714 vam->retval = retval;
1715 vam->sw_if_index = ntohl (mp->sw_if_index);
1716 vam->result_ready = 1;
1720 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1721 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1723 vat_main_t *vam = &vat_main;
1724 vat_json_node_t node;
1726 vat_json_init_object (&node);
1727 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1728 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1730 vat_json_print (vam->ofp, &node);
1731 vat_json_free (&node);
1733 vam->retval = ntohl (mp->retval);
1734 vam->result_ready = 1;
1738 static void vl_api_one_add_del_locator_set_reply_t_handler
1739 (vl_api_one_add_del_locator_set_reply_t * mp)
1741 vat_main_t *vam = &vat_main;
1742 i32 retval = ntohl (mp->retval);
1743 if (vam->async_mode)
1745 vam->async_errors += (retval < 0);
1749 vam->retval = retval;
1750 vam->result_ready = 1;
1754 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1755 (vl_api_one_add_del_locator_set_reply_t * mp)
1757 vat_main_t *vam = &vat_main;
1758 vat_json_node_t node;
1760 vat_json_init_object (&node);
1761 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1762 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1764 vat_json_print (vam->ofp, &node);
1765 vat_json_free (&node);
1767 vam->retval = ntohl (mp->retval);
1768 vam->result_ready = 1;
1771 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1772 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1774 vat_main_t *vam = &vat_main;
1775 i32 retval = ntohl (mp->retval);
1776 if (vam->async_mode)
1778 vam->async_errors += (retval < 0);
1782 vam->retval = retval;
1783 vam->sw_if_index = ntohl (mp->sw_if_index);
1784 vam->result_ready = 1;
1788 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1789 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1791 vat_main_t *vam = &vat_main;
1792 vat_json_node_t node;
1794 vat_json_init_object (&node);
1795 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1796 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1798 vat_json_print (vam->ofp, &node);
1799 vat_json_free (&node);
1801 vam->retval = ntohl (mp->retval);
1802 vam->result_ready = 1;
1805 static void vl_api_gre_add_del_tunnel_reply_t_handler
1806 (vl_api_gre_add_del_tunnel_reply_t * mp)
1808 vat_main_t *vam = &vat_main;
1809 i32 retval = ntohl (mp->retval);
1810 if (vam->async_mode)
1812 vam->async_errors += (retval < 0);
1816 vam->retval = retval;
1817 vam->sw_if_index = ntohl (mp->sw_if_index);
1818 vam->result_ready = 1;
1822 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1823 (vl_api_gre_add_del_tunnel_reply_t * mp)
1825 vat_main_t *vam = &vat_main;
1826 vat_json_node_t node;
1828 vat_json_init_object (&node);
1829 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1830 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1832 vat_json_print (vam->ofp, &node);
1833 vat_json_free (&node);
1835 vam->retval = ntohl (mp->retval);
1836 vam->result_ready = 1;
1839 static void vl_api_create_vhost_user_if_reply_t_handler
1840 (vl_api_create_vhost_user_if_reply_t * mp)
1842 vat_main_t *vam = &vat_main;
1843 i32 retval = ntohl (mp->retval);
1844 if (vam->async_mode)
1846 vam->async_errors += (retval < 0);
1850 vam->retval = retval;
1851 vam->sw_if_index = ntohl (mp->sw_if_index);
1852 vam->result_ready = 1;
1856 static void vl_api_create_vhost_user_if_reply_t_handler_json
1857 (vl_api_create_vhost_user_if_reply_t * mp)
1859 vat_main_t *vam = &vat_main;
1860 vat_json_node_t node;
1862 vat_json_init_object (&node);
1863 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1864 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1866 vat_json_print (vam->ofp, &node);
1867 vat_json_free (&node);
1869 vam->retval = ntohl (mp->retval);
1870 vam->result_ready = 1;
1873 static void vl_api_ip_address_details_t_handler
1874 (vl_api_ip_address_details_t * mp)
1876 vat_main_t *vam = &vat_main;
1877 static ip_address_details_t empty_ip_address_details = { {0} };
1878 ip_address_details_t *address = NULL;
1879 ip_details_t *current_ip_details = NULL;
1880 ip_details_t *details = NULL;
1882 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1884 if (!details || vam->current_sw_if_index >= vec_len (details)
1885 || !details[vam->current_sw_if_index].present)
1887 errmsg ("ip address details arrived but not stored");
1888 errmsg ("ip_dump should be called first");
1892 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1894 #define addresses (current_ip_details->addr)
1896 vec_validate_init_empty (addresses, vec_len (addresses),
1897 empty_ip_address_details);
1899 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1901 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1902 address->prefix_length = mp->prefix_length;
1906 static void vl_api_ip_address_details_t_handler_json
1907 (vl_api_ip_address_details_t * mp)
1909 vat_main_t *vam = &vat_main;
1910 vat_json_node_t *node = NULL;
1911 struct in6_addr ip6;
1914 if (VAT_JSON_ARRAY != vam->json_tree.type)
1916 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1917 vat_json_init_array (&vam->json_tree);
1919 node = vat_json_array_add (&vam->json_tree);
1921 vat_json_init_object (node);
1924 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1925 vat_json_object_add_ip6 (node, "ip", ip6);
1929 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1930 vat_json_object_add_ip4 (node, "ip", ip4);
1932 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1936 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1938 vat_main_t *vam = &vat_main;
1939 static ip_details_t empty_ip_details = { 0 };
1940 ip_details_t *ip = NULL;
1941 u32 sw_if_index = ~0;
1943 sw_if_index = ntohl (mp->sw_if_index);
1945 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1946 sw_if_index, empty_ip_details);
1948 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1955 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1957 vat_main_t *vam = &vat_main;
1959 if (VAT_JSON_ARRAY != vam->json_tree.type)
1961 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1962 vat_json_init_array (&vam->json_tree);
1964 vat_json_array_add_uint (&vam->json_tree,
1965 clib_net_to_host_u32 (mp->sw_if_index));
1968 static void vl_api_map_domain_details_t_handler_json
1969 (vl_api_map_domain_details_t * mp)
1971 vat_json_node_t *node = NULL;
1972 vat_main_t *vam = &vat_main;
1973 struct in6_addr ip6;
1976 if (VAT_JSON_ARRAY != vam->json_tree.type)
1978 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1979 vat_json_init_array (&vam->json_tree);
1982 node = vat_json_array_add (&vam->json_tree);
1983 vat_json_init_object (node);
1985 vat_json_object_add_uint (node, "domain_index",
1986 clib_net_to_host_u32 (mp->domain_index));
1987 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1988 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1989 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1990 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1991 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1992 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1993 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1994 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1995 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1996 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1997 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1998 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1999 vat_json_object_add_uint (node, "flags", mp->flags);
2000 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2001 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2004 static void vl_api_map_domain_details_t_handler
2005 (vl_api_map_domain_details_t * mp)
2007 vat_main_t *vam = &vat_main;
2009 if (mp->is_translation)
2012 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2013 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2014 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2015 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2016 clib_net_to_host_u32 (mp->domain_index));
2021 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2022 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2023 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2024 format_ip6_address, mp->ip6_src,
2025 clib_net_to_host_u32 (mp->domain_index));
2027 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2028 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2029 mp->is_translation ? "map-t" : "");
2032 static void vl_api_map_rule_details_t_handler_json
2033 (vl_api_map_rule_details_t * mp)
2035 struct in6_addr ip6;
2036 vat_json_node_t *node = NULL;
2037 vat_main_t *vam = &vat_main;
2039 if (VAT_JSON_ARRAY != vam->json_tree.type)
2041 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2042 vat_json_init_array (&vam->json_tree);
2045 node = vat_json_array_add (&vam->json_tree);
2046 vat_json_init_object (node);
2048 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2049 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2050 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2054 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2056 vat_main_t *vam = &vat_main;
2057 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2058 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2062 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2064 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2065 "router_addr %U host_mac %U",
2066 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2067 format_ip4_address, &mp->host_address,
2068 format_ip4_address, &mp->router_address,
2069 format_ethernet_address, mp->host_mac);
2072 static void vl_api_dhcp_compl_event_t_handler_json
2073 (vl_api_dhcp_compl_event_t * mp)
2075 /* JSON output not supported */
2079 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2082 vat_main_t *vam = &vat_main;
2083 static u64 default_counter = 0;
2085 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2087 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2088 sw_if_index, default_counter);
2089 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2093 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2094 interface_counter_t counter)
2096 vat_main_t *vam = &vat_main;
2097 static interface_counter_t default_counter = { 0, };
2099 vec_validate_init_empty (vam->combined_interface_counters,
2100 vnet_counter_type, NULL);
2101 vec_validate_init_empty (vam->combined_interface_counters
2102 [vnet_counter_type], sw_if_index, default_counter);
2103 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2106 static void vl_api_vnet_interface_simple_counters_t_handler
2107 (vl_api_vnet_interface_simple_counters_t * mp)
2112 static void vl_api_vnet_interface_combined_counters_t_handler
2113 (vl_api_vnet_interface_combined_counters_t * mp)
2118 static void vl_api_vnet_interface_simple_counters_t_handler_json
2119 (vl_api_vnet_interface_simple_counters_t * mp)
2124 u32 first_sw_if_index;
2127 count = ntohl (mp->count);
2128 first_sw_if_index = ntohl (mp->first_sw_if_index);
2130 v_packets = (u64 *) & mp->data;
2131 for (i = 0; i < count; i++)
2133 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2134 set_simple_interface_counter (mp->vnet_counter_type,
2135 first_sw_if_index + i, packets);
2140 static void vl_api_vnet_interface_combined_counters_t_handler_json
2141 (vl_api_vnet_interface_combined_counters_t * mp)
2143 interface_counter_t counter;
2145 u32 first_sw_if_index;
2149 count = ntohl (mp->count);
2150 first_sw_if_index = ntohl (mp->first_sw_if_index);
2152 v = (vlib_counter_t *) & mp->data;
2153 for (i = 0; i < count; i++)
2156 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2158 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2159 set_combined_interface_counter (mp->vnet_counter_type,
2160 first_sw_if_index + i, counter);
2166 ip4_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->ip4_fib_counters_vrf_id_by_index); i++)
2173 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2182 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2184 vat_main_t *vam = &vat_main;
2187 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2189 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2197 static void vl_api_vnet_ip4_fib_counters_t_handler
2198 (vl_api_vnet_ip4_fib_counters_t * mp)
2203 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2204 (vl_api_vnet_ip4_fib_counters_t * mp)
2206 vat_main_t *vam = &vat_main;
2207 vl_api_ip4_fib_counter_t *v;
2208 ip4_fib_counter_t *counter;
2215 vrf_id = ntohl (mp->vrf_id);
2216 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2217 if (~0 == vrf_index)
2219 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2220 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2221 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2222 vec_validate (vam->ip4_fib_counters, vrf_index);
2223 vam->ip4_fib_counters[vrf_index] = NULL;
2226 vec_free (vam->ip4_fib_counters[vrf_index]);
2227 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2228 count = ntohl (mp->count);
2229 for (i = 0; i < count; i++)
2231 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2232 counter = &vam->ip4_fib_counters[vrf_index][i];
2233 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2234 counter->address = ip4;
2235 counter->address_length = v->address_length;
2236 counter->packets = clib_net_to_host_u64 (v->packets);
2237 counter->bytes = clib_net_to_host_u64 (v->bytes);
2242 static void vl_api_vnet_ip4_nbr_counters_t_handler
2243 (vl_api_vnet_ip4_nbr_counters_t * mp)
2248 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2249 (vl_api_vnet_ip4_nbr_counters_t * mp)
2251 vat_main_t *vam = &vat_main;
2252 vl_api_ip4_nbr_counter_t *v;
2253 ip4_nbr_counter_t *counter;
2258 sw_if_index = ntohl (mp->sw_if_index);
2259 count = ntohl (mp->count);
2260 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2263 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2265 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2266 for (i = 0; i < count; i++)
2268 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2269 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2270 counter->address.s_addr = v->address;
2271 counter->packets = clib_net_to_host_u64 (v->packets);
2272 counter->bytes = clib_net_to_host_u64 (v->bytes);
2273 counter->linkt = v->link_type;
2278 static void vl_api_vnet_ip6_fib_counters_t_handler
2279 (vl_api_vnet_ip6_fib_counters_t * mp)
2284 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2285 (vl_api_vnet_ip6_fib_counters_t * mp)
2287 vat_main_t *vam = &vat_main;
2288 vl_api_ip6_fib_counter_t *v;
2289 ip6_fib_counter_t *counter;
2290 struct in6_addr ip6;
2296 vrf_id = ntohl (mp->vrf_id);
2297 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2298 if (~0 == vrf_index)
2300 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2301 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2302 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2303 vec_validate (vam->ip6_fib_counters, vrf_index);
2304 vam->ip6_fib_counters[vrf_index] = NULL;
2307 vec_free (vam->ip6_fib_counters[vrf_index]);
2308 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2309 count = ntohl (mp->count);
2310 for (i = 0; i < count; i++)
2312 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2313 counter = &vam->ip6_fib_counters[vrf_index][i];
2314 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2315 counter->address = ip6;
2316 counter->address_length = v->address_length;
2317 counter->packets = clib_net_to_host_u64 (v->packets);
2318 counter->bytes = clib_net_to_host_u64 (v->bytes);
2323 static void vl_api_vnet_ip6_nbr_counters_t_handler
2324 (vl_api_vnet_ip6_nbr_counters_t * mp)
2329 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2330 (vl_api_vnet_ip6_nbr_counters_t * mp)
2332 vat_main_t *vam = &vat_main;
2333 vl_api_ip6_nbr_counter_t *v;
2334 ip6_nbr_counter_t *counter;
2335 struct in6_addr ip6;
2340 sw_if_index = ntohl (mp->sw_if_index);
2341 count = ntohl (mp->count);
2342 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2345 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2347 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2348 for (i = 0; i < count; i++)
2350 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2351 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2352 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2353 counter->address = ip6;
2354 counter->packets = clib_net_to_host_u64 (v->packets);
2355 counter->bytes = clib_net_to_host_u64 (v->bytes);
2360 static void vl_api_get_first_msg_id_reply_t_handler
2361 (vl_api_get_first_msg_id_reply_t * mp)
2363 vat_main_t *vam = &vat_main;
2364 i32 retval = ntohl (mp->retval);
2366 if (vam->async_mode)
2368 vam->async_errors += (retval < 0);
2372 vam->retval = retval;
2373 vam->result_ready = 1;
2377 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2381 static void vl_api_get_first_msg_id_reply_t_handler_json
2382 (vl_api_get_first_msg_id_reply_t * mp)
2384 vat_main_t *vam = &vat_main;
2385 vat_json_node_t node;
2387 vat_json_init_object (&node);
2388 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2389 vat_json_object_add_uint (&node, "first_msg_id",
2390 (uint) ntohs (mp->first_msg_id));
2392 vat_json_print (vam->ofp, &node);
2393 vat_json_free (&node);
2395 vam->retval = ntohl (mp->retval);
2396 vam->result_ready = 1;
2399 static void vl_api_get_node_graph_reply_t_handler
2400 (vl_api_get_node_graph_reply_t * mp)
2402 vat_main_t *vam = &vat_main;
2403 api_main_t *am = &api_main;
2404 i32 retval = ntohl (mp->retval);
2405 u8 *pvt_copy, *reply;
2410 if (vam->async_mode)
2412 vam->async_errors += (retval < 0);
2416 vam->retval = retval;
2417 vam->result_ready = 1;
2420 /* "Should never happen..." */
2424 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2425 pvt_copy = vec_dup (reply);
2427 /* Toss the shared-memory original... */
2428 pthread_mutex_lock (&am->vlib_rp->mutex);
2429 oldheap = svm_push_data_heap (am->vlib_rp);
2433 svm_pop_heap (oldheap);
2434 pthread_mutex_unlock (&am->vlib_rp->mutex);
2436 if (vam->graph_nodes)
2438 hash_free (vam->graph_node_index_by_name);
2440 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2442 node = vam->graph_nodes[i];
2443 vec_free (node->name);
2444 vec_free (node->next_nodes);
2447 vec_free (vam->graph_nodes);
2450 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2451 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2452 vec_free (pvt_copy);
2454 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2456 node = vam->graph_nodes[i];
2457 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2461 static void vl_api_get_node_graph_reply_t_handler_json
2462 (vl_api_get_node_graph_reply_t * mp)
2464 vat_main_t *vam = &vat_main;
2465 api_main_t *am = &api_main;
2467 vat_json_node_t node;
2470 /* $$$$ make this real? */
2471 vat_json_init_object (&node);
2472 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2473 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2475 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2477 /* Toss the shared-memory original... */
2478 pthread_mutex_lock (&am->vlib_rp->mutex);
2479 oldheap = svm_push_data_heap (am->vlib_rp);
2483 svm_pop_heap (oldheap);
2484 pthread_mutex_unlock (&am->vlib_rp->mutex);
2486 vat_json_print (vam->ofp, &node);
2487 vat_json_free (&node);
2489 vam->retval = ntohl (mp->retval);
2490 vam->result_ready = 1;
2494 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2496 vat_main_t *vam = &vat_main;
2501 s = format (s, "%=16d%=16d%=16d",
2502 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2506 s = format (s, "%=16U%=16d%=16d",
2507 mp->is_ipv6 ? format_ip6_address :
2509 mp->ip_address, mp->priority, mp->weight);
2512 print (vam->ofp, "%v", s);
2517 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2519 vat_main_t *vam = &vat_main;
2520 vat_json_node_t *node = NULL;
2521 struct in6_addr ip6;
2524 if (VAT_JSON_ARRAY != vam->json_tree.type)
2526 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2527 vat_json_init_array (&vam->json_tree);
2529 node = vat_json_array_add (&vam->json_tree);
2530 vat_json_init_object (node);
2532 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2533 vat_json_object_add_uint (node, "priority", mp->priority);
2534 vat_json_object_add_uint (node, "weight", mp->weight);
2537 vat_json_object_add_uint (node, "sw_if_index",
2538 clib_net_to_host_u32 (mp->sw_if_index));
2543 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2544 vat_json_object_add_ip6 (node, "address", ip6);
2548 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2549 vat_json_object_add_ip4 (node, "address", ip4);
2555 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2558 vat_main_t *vam = &vat_main;
2561 ls_name = format (0, "%s", mp->ls_name);
2563 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2569 vl_api_one_locator_set_details_t_handler_json
2570 (vl_api_one_locator_set_details_t * mp)
2572 vat_main_t *vam = &vat_main;
2573 vat_json_node_t *node = 0;
2576 ls_name = format (0, "%s", mp->ls_name);
2577 vec_add1 (ls_name, 0);
2579 if (VAT_JSON_ARRAY != vam->json_tree.type)
2581 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2582 vat_json_init_array (&vam->json_tree);
2584 node = vat_json_array_add (&vam->json_tree);
2586 vat_json_init_object (node);
2587 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2588 vat_json_object_add_uint (node, "ls_index",
2589 clib_net_to_host_u32 (mp->ls_index));
2594 format_lisp_flat_eid (u8 * s, va_list * args)
2596 u32 type = va_arg (*args, u32);
2597 u8 *eid = va_arg (*args, u8 *);
2598 u32 eid_len = va_arg (*args, u32);
2603 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2605 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2607 return format (s, "%U", format_ethernet_address, eid);
2613 format_lisp_eid_vat (u8 * s, va_list * args)
2615 u32 type = va_arg (*args, u32);
2616 u8 *eid = va_arg (*args, u8 *);
2617 u32 eid_len = va_arg (*args, u32);
2618 u8 *seid = va_arg (*args, u8 *);
2619 u32 seid_len = va_arg (*args, u32);
2620 u32 is_src_dst = va_arg (*args, u32);
2623 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2625 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2631 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2633 vat_main_t *vam = &vat_main;
2634 u8 *s = 0, *eid = 0;
2636 if (~0 == mp->locator_set_index)
2637 s = format (0, "action: %d", mp->action);
2639 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2641 eid = format (0, "%U", format_lisp_eid_vat,
2645 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2648 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2649 clib_net_to_host_u32 (mp->vni),
2651 mp->is_local ? "local" : "remote",
2652 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2653 clib_net_to_host_u16 (mp->key_id), mp->key);
2660 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2663 vat_main_t *vam = &vat_main;
2664 vat_json_node_t *node = 0;
2667 if (VAT_JSON_ARRAY != vam->json_tree.type)
2669 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2670 vat_json_init_array (&vam->json_tree);
2672 node = vat_json_array_add (&vam->json_tree);
2674 vat_json_init_object (node);
2675 if (~0 == mp->locator_set_index)
2676 vat_json_object_add_uint (node, "action", mp->action);
2678 vat_json_object_add_uint (node, "locator_set_index",
2679 clib_net_to_host_u32 (mp->locator_set_index));
2681 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2682 eid = format (0, "%U", format_lisp_eid_vat,
2686 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2688 vat_json_object_add_string_copy (node, "eid", eid);
2689 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2690 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2691 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2695 vat_json_object_add_uint (node, "key_id",
2696 clib_net_to_host_u16 (mp->key_id));
2697 vat_json_object_add_string_copy (node, "key", mp->key);
2703 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
2705 vat_main_t *vam = &vat_main;
2706 u8 *seid = 0, *deid = 0;
2707 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2709 deid = format (0, "%U", format_lisp_eid_vat,
2710 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2712 seid = format (0, "%U", format_lisp_eid_vat,
2713 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2719 format_ip_address_fcn = format_ip4_address;
2721 format_ip_address_fcn = format_ip6_address;
2724 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
2725 clib_net_to_host_u32 (mp->vni),
2727 format_ip_address_fcn, mp->lloc,
2728 format_ip_address_fcn, mp->rloc,
2729 clib_net_to_host_u32 (mp->pkt_count),
2730 clib_net_to_host_u32 (mp->bytes));
2737 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
2739 struct in6_addr ip6;
2741 vat_main_t *vam = &vat_main;
2742 vat_json_node_t *node = 0;
2743 u8 *deid = 0, *seid = 0;
2745 if (VAT_JSON_ARRAY != vam->json_tree.type)
2747 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2748 vat_json_init_array (&vam->json_tree);
2750 node = vat_json_array_add (&vam->json_tree);
2752 vat_json_init_object (node);
2753 deid = format (0, "%U", format_lisp_eid_vat,
2754 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2756 seid = format (0, "%U", format_lisp_eid_vat,
2757 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2762 vat_json_object_add_string_copy (node, "seid", seid);
2763 vat_json_object_add_string_copy (node, "deid", deid);
2764 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2768 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
2769 vat_json_object_add_ip4 (node, "lloc", ip4);
2770 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
2771 vat_json_object_add_ip4 (node, "rloc", ip4);
2775 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
2776 vat_json_object_add_ip6 (node, "lloc", ip6);
2777 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
2778 vat_json_object_add_ip6 (node, "rloc", ip6);
2780 vat_json_object_add_uint (node, "pkt_count",
2781 clib_net_to_host_u32 (mp->pkt_count));
2782 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
2789 vl_api_one_eid_table_map_details_t_handler
2790 (vl_api_one_eid_table_map_details_t * mp)
2792 vat_main_t *vam = &vat_main;
2794 u8 *line = format (0, "%=10d%=10d",
2795 clib_net_to_host_u32 (mp->vni),
2796 clib_net_to_host_u32 (mp->dp_table));
2797 print (vam->ofp, "%v", line);
2802 vl_api_one_eid_table_map_details_t_handler_json
2803 (vl_api_one_eid_table_map_details_t * mp)
2805 vat_main_t *vam = &vat_main;
2806 vat_json_node_t *node = NULL;
2808 if (VAT_JSON_ARRAY != vam->json_tree.type)
2810 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2811 vat_json_init_array (&vam->json_tree);
2813 node = vat_json_array_add (&vam->json_tree);
2814 vat_json_init_object (node);
2815 vat_json_object_add_uint (node, "dp_table",
2816 clib_net_to_host_u32 (mp->dp_table));
2817 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2821 vl_api_one_eid_table_vni_details_t_handler
2822 (vl_api_one_eid_table_vni_details_t * mp)
2824 vat_main_t *vam = &vat_main;
2826 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2827 print (vam->ofp, "%v", line);
2832 vl_api_one_eid_table_vni_details_t_handler_json
2833 (vl_api_one_eid_table_vni_details_t * mp)
2835 vat_main_t *vam = &vat_main;
2836 vat_json_node_t *node = NULL;
2838 if (VAT_JSON_ARRAY != vam->json_tree.type)
2840 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2841 vat_json_init_array (&vam->json_tree);
2843 node = vat_json_array_add (&vam->json_tree);
2844 vat_json_init_object (node);
2845 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2849 vl_api_show_one_map_register_state_reply_t_handler
2850 (vl_api_show_one_map_register_state_reply_t * mp)
2852 vat_main_t *vam = &vat_main;
2853 int retval = clib_net_to_host_u32 (mp->retval);
2855 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2857 vam->retval = retval;
2858 vam->result_ready = 1;
2862 vl_api_show_one_map_register_state_reply_t_handler_json
2863 (vl_api_show_one_map_register_state_reply_t * mp)
2865 vat_main_t *vam = &vat_main;
2866 vat_json_node_t _node, *node = &_node;
2867 int retval = clib_net_to_host_u32 (mp->retval);
2869 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2871 vat_json_init_object (node);
2872 vat_json_object_add_string_copy (node, "state", s);
2874 vat_json_print (vam->ofp, node);
2875 vat_json_free (node);
2877 vam->retval = retval;
2878 vam->result_ready = 1;
2883 vl_api_show_one_rloc_probe_state_reply_t_handler
2884 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2886 vat_main_t *vam = &vat_main;
2887 int retval = clib_net_to_host_u32 (mp->retval);
2892 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2894 vam->retval = retval;
2895 vam->result_ready = 1;
2899 vl_api_show_one_rloc_probe_state_reply_t_handler_json
2900 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2902 vat_main_t *vam = &vat_main;
2903 vat_json_node_t _node, *node = &_node;
2904 int retval = clib_net_to_host_u32 (mp->retval);
2906 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2907 vat_json_init_object (node);
2908 vat_json_object_add_string_copy (node, "state", s);
2910 vat_json_print (vam->ofp, node);
2911 vat_json_free (node);
2913 vam->retval = retval;
2914 vam->result_ready = 1;
2919 vl_api_show_one_stats_enable_disable_reply_t_handler
2920 (vl_api_show_one_stats_enable_disable_reply_t * mp)
2922 vat_main_t *vam = &vat_main;
2923 int retval = clib_net_to_host_u32 (mp->retval);
2928 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
2930 vam->retval = retval;
2931 vam->result_ready = 1;
2935 vl_api_show_one_stats_enable_disable_reply_t_handler_json
2936 (vl_api_show_one_stats_enable_disable_reply_t * mp)
2938 vat_main_t *vam = &vat_main;
2939 vat_json_node_t _node, *node = &_node;
2940 int retval = clib_net_to_host_u32 (mp->retval);
2942 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
2943 vat_json_init_object (node);
2944 vat_json_object_add_string_copy (node, "state", s);
2946 vat_json_print (vam->ofp, node);
2947 vat_json_free (node);
2949 vam->retval = retval;
2950 vam->result_ready = 1;
2955 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
2957 e->dp_table = clib_net_to_host_u32 (e->dp_table);
2958 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
2962 gpe_fwd_entries_get_reply_t_net_to_host
2963 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2967 mp->count = clib_net_to_host_u32 (mp->count);
2968 for (i = 0; i < mp->count; i++)
2970 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
2975 format_gpe_encap_mode (u8 * s, va_list * args)
2977 u32 mode = va_arg (*args, u32);
2982 return format (s, "lisp");
2984 return format (s, "vxlan");
2990 vl_api_gpe_get_encap_mode_reply_t_handler
2991 (vl_api_gpe_get_encap_mode_reply_t * mp)
2993 vat_main_t *vam = &vat_main;
2995 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
2996 vam->retval = ntohl (mp->retval);
2997 vam->result_ready = 1;
3001 vl_api_gpe_get_encap_mode_reply_t_handler_json
3002 (vl_api_gpe_get_encap_mode_reply_t * mp)
3004 vat_main_t *vam = &vat_main;
3005 vat_json_node_t node;
3007 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3008 vec_add1 (encap_mode, 0);
3010 vat_json_init_object (&node);
3011 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3013 vec_free (encap_mode);
3014 vat_json_print (vam->ofp, &node);
3015 vat_json_free (&node);
3017 vam->retval = ntohl (mp->retval);
3018 vam->result_ready = 1;
3022 vl_api_gpe_fwd_entry_path_details_t_handler
3023 (vl_api_gpe_fwd_entry_path_details_t * mp)
3025 vat_main_t *vam = &vat_main;
3026 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3028 if (mp->lcl_loc.is_ip4)
3029 format_ip_address_fcn = format_ip4_address;
3031 format_ip_address_fcn = format_ip6_address;
3033 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3034 format_ip_address_fcn, &mp->lcl_loc,
3035 format_ip_address_fcn, &mp->rmt_loc);
3039 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3041 struct in6_addr ip6;
3046 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3047 vat_json_object_add_ip4 (n, "address", ip4);
3051 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3052 vat_json_object_add_ip6 (n, "address", ip6);
3054 vat_json_object_add_uint (n, "weight", loc->weight);
3058 vl_api_gpe_fwd_entry_path_details_t_handler_json
3059 (vl_api_gpe_fwd_entry_path_details_t * mp)
3061 vat_main_t *vam = &vat_main;
3062 vat_json_node_t *node = NULL;
3063 vat_json_node_t *loc_node;
3065 if (VAT_JSON_ARRAY != vam->json_tree.type)
3067 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3068 vat_json_init_array (&vam->json_tree);
3070 node = vat_json_array_add (&vam->json_tree);
3071 vat_json_init_object (node);
3073 loc_node = vat_json_object_add (node, "local_locator");
3074 vat_json_init_object (loc_node);
3075 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3077 loc_node = vat_json_object_add (node, "remote_locator");
3078 vat_json_init_object (loc_node);
3079 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3083 vl_api_gpe_fwd_entries_get_reply_t_handler
3084 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3086 vat_main_t *vam = &vat_main;
3088 int retval = clib_net_to_host_u32 (mp->retval);
3089 vl_api_gpe_fwd_entry_t *e;
3094 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3096 for (i = 0; i < mp->count; i++)
3098 e = &mp->entries[i];
3099 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3100 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3101 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3105 vam->retval = retval;
3106 vam->result_ready = 1;
3110 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3111 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3114 vat_main_t *vam = &vat_main;
3115 vat_json_node_t *e = 0, root;
3117 int retval = clib_net_to_host_u32 (mp->retval);
3118 vl_api_gpe_fwd_entry_t *fwd;
3123 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3124 vat_json_init_array (&root);
3126 for (i = 0; i < mp->count; i++)
3128 e = vat_json_array_add (&root);
3129 fwd = &mp->entries[i];
3131 vat_json_init_object (e);
3132 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3133 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3135 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3136 fwd->leid_prefix_len);
3138 vat_json_object_add_string_copy (e, "leid", s);
3141 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3142 fwd->reid_prefix_len);
3144 vat_json_object_add_string_copy (e, "reid", s);
3148 vat_json_print (vam->ofp, &root);
3149 vat_json_free (&root);
3152 vam->retval = retval;
3153 vam->result_ready = 1;
3157 vl_api_one_adjacencies_get_reply_t_handler
3158 (vl_api_one_adjacencies_get_reply_t * mp)
3160 vat_main_t *vam = &vat_main;
3162 int retval = clib_net_to_host_u32 (mp->retval);
3163 vl_api_one_adjacency_t *a;
3168 n = clib_net_to_host_u32 (mp->count);
3170 for (i = 0; i < n; i++)
3172 a = &mp->adjacencies[i];
3173 print (vam->ofp, "%U %40U",
3174 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3175 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3179 vam->retval = retval;
3180 vam->result_ready = 1;
3184 vl_api_one_adjacencies_get_reply_t_handler_json
3185 (vl_api_one_adjacencies_get_reply_t * mp)
3188 vat_main_t *vam = &vat_main;
3189 vat_json_node_t *e = 0, root;
3191 int retval = clib_net_to_host_u32 (mp->retval);
3192 vl_api_one_adjacency_t *a;
3197 n = clib_net_to_host_u32 (mp->count);
3198 vat_json_init_array (&root);
3200 for (i = 0; i < n; i++)
3202 e = vat_json_array_add (&root);
3203 a = &mp->adjacencies[i];
3205 vat_json_init_object (e);
3206 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3207 a->leid_prefix_len);
3209 vat_json_object_add_string_copy (e, "leid", s);
3212 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3213 a->reid_prefix_len);
3215 vat_json_object_add_string_copy (e, "reid", s);
3219 vat_json_print (vam->ofp, &root);
3220 vat_json_free (&root);
3223 vam->retval = retval;
3224 vam->result_ready = 1;
3228 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3230 vat_main_t *vam = &vat_main;
3232 print (vam->ofp, "%=20U",
3233 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3238 vl_api_one_map_server_details_t_handler_json
3239 (vl_api_one_map_server_details_t * mp)
3241 vat_main_t *vam = &vat_main;
3242 vat_json_node_t *node = NULL;
3243 struct in6_addr ip6;
3246 if (VAT_JSON_ARRAY != vam->json_tree.type)
3248 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3249 vat_json_init_array (&vam->json_tree);
3251 node = vat_json_array_add (&vam->json_tree);
3253 vat_json_init_object (node);
3256 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3257 vat_json_object_add_ip6 (node, "map-server", ip6);
3261 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3262 vat_json_object_add_ip4 (node, "map-server", ip4);
3267 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3270 vat_main_t *vam = &vat_main;
3272 print (vam->ofp, "%=20U",
3273 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3278 vl_api_one_map_resolver_details_t_handler_json
3279 (vl_api_one_map_resolver_details_t * mp)
3281 vat_main_t *vam = &vat_main;
3282 vat_json_node_t *node = NULL;
3283 struct in6_addr ip6;
3286 if (VAT_JSON_ARRAY != vam->json_tree.type)
3288 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3289 vat_json_init_array (&vam->json_tree);
3291 node = vat_json_array_add (&vam->json_tree);
3293 vat_json_init_object (node);
3296 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3297 vat_json_object_add_ip6 (node, "map resolver", ip6);
3301 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3302 vat_json_object_add_ip4 (node, "map resolver", ip4);
3307 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3309 vat_main_t *vam = &vat_main;
3310 i32 retval = ntohl (mp->retval);
3314 print (vam->ofp, "feature: %s\ngpe: %s",
3315 mp->feature_status ? "enabled" : "disabled",
3316 mp->gpe_status ? "enabled" : "disabled");
3319 vam->retval = retval;
3320 vam->result_ready = 1;
3324 vl_api_show_one_status_reply_t_handler_json
3325 (vl_api_show_one_status_reply_t * mp)
3327 vat_main_t *vam = &vat_main;
3328 vat_json_node_t node;
3329 u8 *gpe_status = NULL;
3330 u8 *feature_status = NULL;
3332 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3333 feature_status = format (0, "%s",
3334 mp->feature_status ? "enabled" : "disabled");
3335 vec_add1 (gpe_status, 0);
3336 vec_add1 (feature_status, 0);
3338 vat_json_init_object (&node);
3339 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3340 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3342 vec_free (gpe_status);
3343 vec_free (feature_status);
3345 vat_json_print (vam->ofp, &node);
3346 vat_json_free (&node);
3348 vam->retval = ntohl (mp->retval);
3349 vam->result_ready = 1;
3353 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3354 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3356 vat_main_t *vam = &vat_main;
3357 i32 retval = ntohl (mp->retval);
3361 print (vam->ofp, "%=20s", mp->locator_set_name);
3364 vam->retval = retval;
3365 vam->result_ready = 1;
3369 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3370 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3372 vat_main_t *vam = &vat_main;
3373 vat_json_node_t *node = NULL;
3375 if (VAT_JSON_ARRAY != vam->json_tree.type)
3377 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3378 vat_json_init_array (&vam->json_tree);
3380 node = vat_json_array_add (&vam->json_tree);
3382 vat_json_init_object (node);
3383 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3385 vat_json_print (vam->ofp, node);
3386 vat_json_free (node);
3388 vam->retval = ntohl (mp->retval);
3389 vam->result_ready = 1;
3393 format_lisp_map_request_mode (u8 * s, va_list * args)
3395 u32 mode = va_arg (*args, u32);
3400 return format (0, "dst-only");
3402 return format (0, "src-dst");
3408 vl_api_show_one_map_request_mode_reply_t_handler
3409 (vl_api_show_one_map_request_mode_reply_t * mp)
3411 vat_main_t *vam = &vat_main;
3412 i32 retval = ntohl (mp->retval);
3416 u32 mode = mp->mode;
3417 print (vam->ofp, "map_request_mode: %U",
3418 format_lisp_map_request_mode, mode);
3421 vam->retval = retval;
3422 vam->result_ready = 1;
3426 vl_api_show_one_map_request_mode_reply_t_handler_json
3427 (vl_api_show_one_map_request_mode_reply_t * mp)
3429 vat_main_t *vam = &vat_main;
3430 vat_json_node_t node;
3435 s = format (0, "%U", format_lisp_map_request_mode, mode);
3438 vat_json_init_object (&node);
3439 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3440 vat_json_print (vam->ofp, &node);
3441 vat_json_free (&node);
3444 vam->retval = ntohl (mp->retval);
3445 vam->result_ready = 1;
3449 vl_api_show_one_use_petr_reply_t_handler
3450 (vl_api_show_one_use_petr_reply_t * mp)
3452 vat_main_t *vam = &vat_main;
3453 i32 retval = ntohl (mp->retval);
3457 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
3460 print (vam->ofp, "Proxy-ETR address; %U",
3461 mp->is_ip4 ? format_ip4_address : format_ip6_address,
3466 vam->retval = retval;
3467 vam->result_ready = 1;
3471 vl_api_show_one_use_petr_reply_t_handler_json
3472 (vl_api_show_one_use_petr_reply_t * mp)
3474 vat_main_t *vam = &vat_main;
3475 vat_json_node_t node;
3478 struct in6_addr ip6;
3480 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3481 vec_add1 (status, 0);
3483 vat_json_init_object (&node);
3484 vat_json_object_add_string_copy (&node, "status", status);
3489 clib_memcpy (&ip6, mp->address, sizeof (ip6));
3490 vat_json_object_add_ip6 (&node, "address", ip6);
3494 clib_memcpy (&ip4, mp->address, sizeof (ip4));
3495 vat_json_object_add_ip4 (&node, "address", ip4);
3501 vat_json_print (vam->ofp, &node);
3502 vat_json_free (&node);
3504 vam->retval = ntohl (mp->retval);
3505 vam->result_ready = 1;
3509 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3511 vat_main_t *vam = &vat_main;
3512 i32 retval = ntohl (mp->retval);
3516 print (vam->ofp, "%-20s%-16s",
3517 mp->status ? "enabled" : "disabled",
3518 mp->status ? (char *) mp->locator_set_name : "");
3521 vam->retval = retval;
3522 vam->result_ready = 1;
3526 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3528 vat_main_t *vam = &vat_main;
3529 vat_json_node_t node;
3532 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3533 vec_add1 (status, 0);
3535 vat_json_init_object (&node);
3536 vat_json_object_add_string_copy (&node, "status", status);
3539 vat_json_object_add_string_copy (&node, "locator_set",
3540 mp->locator_set_name);
3545 vat_json_print (vam->ofp, &node);
3546 vat_json_free (&node);
3548 vam->retval = ntohl (mp->retval);
3549 vam->result_ready = 1;
3553 format_policer_type (u8 * s, va_list * va)
3555 u32 i = va_arg (*va, u32);
3557 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3558 s = format (s, "1r2c");
3559 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3560 s = format (s, "1r3c");
3561 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3562 s = format (s, "2r3c-2698");
3563 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3564 s = format (s, "2r3c-4115");
3565 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3566 s = format (s, "2r3c-mef5cf1");
3568 s = format (s, "ILLEGAL");
3573 format_policer_rate_type (u8 * s, va_list * va)
3575 u32 i = va_arg (*va, u32);
3577 if (i == SSE2_QOS_RATE_KBPS)
3578 s = format (s, "kbps");
3579 else if (i == SSE2_QOS_RATE_PPS)
3580 s = format (s, "pps");
3582 s = format (s, "ILLEGAL");
3587 format_policer_round_type (u8 * s, va_list * va)
3589 u32 i = va_arg (*va, u32);
3591 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3592 s = format (s, "closest");
3593 else if (i == SSE2_QOS_ROUND_TO_UP)
3594 s = format (s, "up");
3595 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3596 s = format (s, "down");
3598 s = format (s, "ILLEGAL");
3603 format_policer_action_type (u8 * s, va_list * va)
3605 u32 i = va_arg (*va, u32);
3607 if (i == SSE2_QOS_ACTION_DROP)
3608 s = format (s, "drop");
3609 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3610 s = format (s, "transmit");
3611 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3612 s = format (s, "mark-and-transmit");
3614 s = format (s, "ILLEGAL");
3619 format_dscp (u8 * s, va_list * va)
3621 u32 i = va_arg (*va, u32);
3626 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3630 return format (s, "ILLEGAL");
3632 s = format (s, "%s", t);
3637 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3639 vat_main_t *vam = &vat_main;
3640 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3642 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3643 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3645 conform_dscp_str = format (0, "");
3647 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3648 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3650 exceed_dscp_str = format (0, "");
3652 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3653 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3655 violate_dscp_str = format (0, "");
3657 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3658 "rate type %U, round type %U, %s rate, %s color-aware, "
3659 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3660 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3661 "conform action %U%s, exceed action %U%s, violate action %U%s",
3663 format_policer_type, mp->type,
3666 clib_net_to_host_u64 (mp->cb),
3667 clib_net_to_host_u64 (mp->eb),
3668 format_policer_rate_type, mp->rate_type,
3669 format_policer_round_type, mp->round_type,
3670 mp->single_rate ? "single" : "dual",
3671 mp->color_aware ? "is" : "not",
3672 ntohl (mp->cir_tokens_per_period),
3673 ntohl (mp->pir_tokens_per_period),
3675 ntohl (mp->current_limit),
3676 ntohl (mp->current_bucket),
3677 ntohl (mp->extended_limit),
3678 ntohl (mp->extended_bucket),
3679 clib_net_to_host_u64 (mp->last_update_time),
3680 format_policer_action_type, mp->conform_action_type,
3682 format_policer_action_type, mp->exceed_action_type,
3684 format_policer_action_type, mp->violate_action_type,
3687 vec_free (conform_dscp_str);
3688 vec_free (exceed_dscp_str);
3689 vec_free (violate_dscp_str);
3692 static void vl_api_policer_details_t_handler_json
3693 (vl_api_policer_details_t * mp)
3695 vat_main_t *vam = &vat_main;
3696 vat_json_node_t *node;
3697 u8 *rate_type_str, *round_type_str, *type_str;
3698 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3700 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3702 format (0, "%U", format_policer_round_type, mp->round_type);
3703 type_str = format (0, "%U", format_policer_type, mp->type);
3704 conform_action_str = format (0, "%U", format_policer_action_type,
3705 mp->conform_action_type);
3706 exceed_action_str = format (0, "%U", format_policer_action_type,
3707 mp->exceed_action_type);
3708 violate_action_str = format (0, "%U", format_policer_action_type,
3709 mp->violate_action_type);
3711 if (VAT_JSON_ARRAY != vam->json_tree.type)
3713 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3714 vat_json_init_array (&vam->json_tree);
3716 node = vat_json_array_add (&vam->json_tree);
3718 vat_json_init_object (node);
3719 vat_json_object_add_string_copy (node, "name", mp->name);
3720 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3721 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3722 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
3723 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
3724 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3725 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3726 vat_json_object_add_string_copy (node, "type", type_str);
3727 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3728 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3729 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3730 vat_json_object_add_uint (node, "cir_tokens_per_period",
3731 ntohl (mp->cir_tokens_per_period));
3732 vat_json_object_add_uint (node, "eir_tokens_per_period",
3733 ntohl (mp->pir_tokens_per_period));
3734 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3735 vat_json_object_add_uint (node, "current_bucket",
3736 ntohl (mp->current_bucket));
3737 vat_json_object_add_uint (node, "extended_limit",
3738 ntohl (mp->extended_limit));
3739 vat_json_object_add_uint (node, "extended_bucket",
3740 ntohl (mp->extended_bucket));
3741 vat_json_object_add_uint (node, "last_update_time",
3742 ntohl (mp->last_update_time));
3743 vat_json_object_add_string_copy (node, "conform_action",
3744 conform_action_str);
3745 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3747 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3748 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3749 vec_free (dscp_str);
3751 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3752 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3754 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3755 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3756 vec_free (dscp_str);
3758 vat_json_object_add_string_copy (node, "violate_action",
3759 violate_action_str);
3760 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3762 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3763 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3764 vec_free (dscp_str);
3767 vec_free (rate_type_str);
3768 vec_free (round_type_str);
3769 vec_free (type_str);
3770 vec_free (conform_action_str);
3771 vec_free (exceed_action_str);
3772 vec_free (violate_action_str);
3776 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3779 vat_main_t *vam = &vat_main;
3780 int i, count = ntohl (mp->count);
3783 print (vam->ofp, "classify table ids (%d) : ", count);
3784 for (i = 0; i < count; i++)
3786 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3787 print (vam->ofp, (i < count - 1) ? "," : "");
3789 vam->retval = ntohl (mp->retval);
3790 vam->result_ready = 1;
3794 vl_api_classify_table_ids_reply_t_handler_json
3795 (vl_api_classify_table_ids_reply_t * mp)
3797 vat_main_t *vam = &vat_main;
3798 int i, count = ntohl (mp->count);
3802 vat_json_node_t node;
3804 vat_json_init_object (&node);
3805 for (i = 0; i < count; i++)
3807 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3809 vat_json_print (vam->ofp, &node);
3810 vat_json_free (&node);
3812 vam->retval = ntohl (mp->retval);
3813 vam->result_ready = 1;
3817 vl_api_classify_table_by_interface_reply_t_handler
3818 (vl_api_classify_table_by_interface_reply_t * mp)
3820 vat_main_t *vam = &vat_main;
3823 table_id = ntohl (mp->l2_table_id);
3825 print (vam->ofp, "l2 table id : %d", table_id);
3827 print (vam->ofp, "l2 table id : No input ACL tables configured");
3828 table_id = ntohl (mp->ip4_table_id);
3830 print (vam->ofp, "ip4 table id : %d", table_id);
3832 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3833 table_id = ntohl (mp->ip6_table_id);
3835 print (vam->ofp, "ip6 table id : %d", table_id);
3837 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3838 vam->retval = ntohl (mp->retval);
3839 vam->result_ready = 1;
3843 vl_api_classify_table_by_interface_reply_t_handler_json
3844 (vl_api_classify_table_by_interface_reply_t * mp)
3846 vat_main_t *vam = &vat_main;
3847 vat_json_node_t node;
3849 vat_json_init_object (&node);
3851 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3852 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3853 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3855 vat_json_print (vam->ofp, &node);
3856 vat_json_free (&node);
3858 vam->retval = ntohl (mp->retval);
3859 vam->result_ready = 1;
3862 static void vl_api_policer_add_del_reply_t_handler
3863 (vl_api_policer_add_del_reply_t * mp)
3865 vat_main_t *vam = &vat_main;
3866 i32 retval = ntohl (mp->retval);
3867 if (vam->async_mode)
3869 vam->async_errors += (retval < 0);
3873 vam->retval = retval;
3874 vam->result_ready = 1;
3875 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3877 * Note: this is just barely thread-safe, depends on
3878 * the main thread spinning waiting for an answer...
3880 errmsg ("policer index %d", ntohl (mp->policer_index));
3884 static void vl_api_policer_add_del_reply_t_handler_json
3885 (vl_api_policer_add_del_reply_t * mp)
3887 vat_main_t *vam = &vat_main;
3888 vat_json_node_t node;
3890 vat_json_init_object (&node);
3891 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3892 vat_json_object_add_uint (&node, "policer_index",
3893 ntohl (mp->policer_index));
3895 vat_json_print (vam->ofp, &node);
3896 vat_json_free (&node);
3898 vam->retval = ntohl (mp->retval);
3899 vam->result_ready = 1;
3902 /* Format hex dump. */
3904 format_hex_bytes (u8 * s, va_list * va)
3906 u8 *bytes = va_arg (*va, u8 *);
3907 int n_bytes = va_arg (*va, int);
3910 /* Print short or long form depending on byte count. */
3911 uword short_form = n_bytes <= 32;
3912 uword indent = format_get_indent (s);
3917 for (i = 0; i < n_bytes; i++)
3919 if (!short_form && (i % 32) == 0)
3920 s = format (s, "%08x: ", i);
3921 s = format (s, "%02x", bytes[i]);
3922 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3923 s = format (s, "\n%U", format_white_space, indent);
3930 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3933 vat_main_t *vam = &vat_main;
3934 i32 retval = ntohl (mp->retval);
3937 print (vam->ofp, "classify table info :");
3938 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3939 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3940 ntohl (mp->miss_next_index));
3941 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3942 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3943 ntohl (mp->match_n_vectors));
3944 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3945 ntohl (mp->mask_length));
3947 vam->retval = retval;
3948 vam->result_ready = 1;
3952 vl_api_classify_table_info_reply_t_handler_json
3953 (vl_api_classify_table_info_reply_t * mp)
3955 vat_main_t *vam = &vat_main;
3956 vat_json_node_t node;
3958 i32 retval = ntohl (mp->retval);
3961 vat_json_init_object (&node);
3963 vat_json_object_add_int (&node, "sessions",
3964 ntohl (mp->active_sessions));
3965 vat_json_object_add_int (&node, "nexttbl",
3966 ntohl (mp->next_table_index));
3967 vat_json_object_add_int (&node, "nextnode",
3968 ntohl (mp->miss_next_index));
3969 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3970 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3971 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3972 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3973 ntohl (mp->mask_length), 0);
3974 vat_json_object_add_string_copy (&node, "mask", s);
3976 vat_json_print (vam->ofp, &node);
3977 vat_json_free (&node);
3979 vam->retval = ntohl (mp->retval);
3980 vam->result_ready = 1;
3984 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3987 vat_main_t *vam = &vat_main;
3989 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3990 ntohl (mp->hit_next_index), ntohl (mp->advance),
3991 ntohl (mp->opaque_index));
3992 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3993 ntohl (mp->match_length));
3997 vl_api_classify_session_details_t_handler_json
3998 (vl_api_classify_session_details_t * mp)
4000 vat_main_t *vam = &vat_main;
4001 vat_json_node_t *node = NULL;
4003 if (VAT_JSON_ARRAY != vam->json_tree.type)
4005 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4006 vat_json_init_array (&vam->json_tree);
4008 node = vat_json_array_add (&vam->json_tree);
4010 vat_json_init_object (node);
4011 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4012 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4013 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4015 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4017 vat_json_object_add_string_copy (node, "match", s);
4020 static void vl_api_pg_create_interface_reply_t_handler
4021 (vl_api_pg_create_interface_reply_t * mp)
4023 vat_main_t *vam = &vat_main;
4025 vam->retval = ntohl (mp->retval);
4026 vam->result_ready = 1;
4029 static void vl_api_pg_create_interface_reply_t_handler_json
4030 (vl_api_pg_create_interface_reply_t * mp)
4032 vat_main_t *vam = &vat_main;
4033 vat_json_node_t node;
4035 i32 retval = ntohl (mp->retval);
4038 vat_json_init_object (&node);
4040 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4042 vat_json_print (vam->ofp, &node);
4043 vat_json_free (&node);
4045 vam->retval = ntohl (mp->retval);
4046 vam->result_ready = 1;
4049 static void vl_api_policer_classify_details_t_handler
4050 (vl_api_policer_classify_details_t * mp)
4052 vat_main_t *vam = &vat_main;
4054 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4055 ntohl (mp->table_index));
4058 static void vl_api_policer_classify_details_t_handler_json
4059 (vl_api_policer_classify_details_t * mp)
4061 vat_main_t *vam = &vat_main;
4062 vat_json_node_t *node;
4064 if (VAT_JSON_ARRAY != vam->json_tree.type)
4066 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4067 vat_json_init_array (&vam->json_tree);
4069 node = vat_json_array_add (&vam->json_tree);
4071 vat_json_init_object (node);
4072 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4073 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4076 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4077 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4079 vat_main_t *vam = &vat_main;
4080 i32 retval = ntohl (mp->retval);
4081 if (vam->async_mode)
4083 vam->async_errors += (retval < 0);
4087 vam->retval = retval;
4088 vam->sw_if_index = ntohl (mp->sw_if_index);
4089 vam->result_ready = 1;
4093 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4094 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4096 vat_main_t *vam = &vat_main;
4097 vat_json_node_t node;
4099 vat_json_init_object (&node);
4100 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4101 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4103 vat_json_print (vam->ofp, &node);
4104 vat_json_free (&node);
4106 vam->retval = ntohl (mp->retval);
4107 vam->result_ready = 1;
4110 static void vl_api_flow_classify_details_t_handler
4111 (vl_api_flow_classify_details_t * mp)
4113 vat_main_t *vam = &vat_main;
4115 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4116 ntohl (mp->table_index));
4119 static void vl_api_flow_classify_details_t_handler_json
4120 (vl_api_flow_classify_details_t * mp)
4122 vat_main_t *vam = &vat_main;
4123 vat_json_node_t *node;
4125 if (VAT_JSON_ARRAY != vam->json_tree.type)
4127 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4128 vat_json_init_array (&vam->json_tree);
4130 node = vat_json_array_add (&vam->json_tree);
4132 vat_json_init_object (node);
4133 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4134 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4137 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
4138 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
4139 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
4140 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
4141 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4142 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4143 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4144 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4145 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4146 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4147 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4148 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4149 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4150 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4153 * Generate boilerplate reply handlers, which
4154 * dig the return value out of the xxx_reply_t API message,
4155 * stick it into vam->retval, and set vam->result_ready
4157 * Could also do this by pointing N message decode slots at
4158 * a single function, but that could break in subtle ways.
4161 #define foreach_standard_reply_retval_handler \
4162 _(sw_interface_set_flags_reply) \
4163 _(sw_interface_add_del_address_reply) \
4164 _(sw_interface_set_table_reply) \
4165 _(sw_interface_set_mpls_enable_reply) \
4166 _(sw_interface_set_vpath_reply) \
4167 _(sw_interface_set_vxlan_bypass_reply) \
4168 _(sw_interface_set_l2_bridge_reply) \
4169 _(bridge_domain_add_del_reply) \
4170 _(sw_interface_set_l2_xconnect_reply) \
4171 _(l2fib_add_del_reply) \
4172 _(l2fib_flush_int_reply) \
4173 _(l2fib_flush_bd_reply) \
4174 _(ip_add_del_route_reply) \
4175 _(ip_mroute_add_del_reply) \
4176 _(mpls_route_add_del_reply) \
4177 _(mpls_ip_bind_unbind_reply) \
4178 _(proxy_arp_add_del_reply) \
4179 _(proxy_arp_intfc_enable_disable_reply) \
4180 _(sw_interface_set_unnumbered_reply) \
4181 _(ip_neighbor_add_del_reply) \
4182 _(reset_vrf_reply) \
4183 _(oam_add_del_reply) \
4184 _(reset_fib_reply) \
4185 _(dhcp_proxy_config_reply) \
4186 _(dhcp_proxy_set_vss_reply) \
4187 _(dhcp_client_config_reply) \
4188 _(set_ip_flow_hash_reply) \
4189 _(sw_interface_ip6_enable_disable_reply) \
4190 _(sw_interface_ip6_set_link_local_address_reply) \
4191 _(ip6nd_proxy_add_del_reply) \
4192 _(sw_interface_ip6nd_ra_prefix_reply) \
4193 _(sw_interface_ip6nd_ra_config_reply) \
4194 _(set_arp_neighbor_limit_reply) \
4195 _(l2_patch_add_del_reply) \
4196 _(sr_policy_add_reply) \
4197 _(sr_policy_mod_reply) \
4198 _(sr_policy_del_reply) \
4199 _(sr_localsid_add_del_reply) \
4200 _(sr_steering_add_del_reply) \
4201 _(classify_add_del_session_reply) \
4202 _(classify_set_interface_ip_table_reply) \
4203 _(classify_set_interface_l2_tables_reply) \
4204 _(l2tpv3_set_tunnel_cookies_reply) \
4205 _(l2tpv3_interface_enable_disable_reply) \
4206 _(l2tpv3_set_lookup_key_reply) \
4207 _(l2_fib_clear_table_reply) \
4208 _(l2_interface_efp_filter_reply) \
4209 _(l2_interface_vlan_tag_rewrite_reply) \
4210 _(modify_vhost_user_if_reply) \
4211 _(delete_vhost_user_if_reply) \
4212 _(want_ip4_arp_events_reply) \
4213 _(want_ip6_nd_events_reply) \
4214 _(input_acl_set_interface_reply) \
4215 _(ipsec_spd_add_del_reply) \
4216 _(ipsec_interface_add_del_spd_reply) \
4217 _(ipsec_spd_add_del_entry_reply) \
4218 _(ipsec_sad_add_del_entry_reply) \
4219 _(ipsec_sa_set_key_reply) \
4220 _(ipsec_tunnel_if_add_del_reply) \
4221 _(ikev2_profile_add_del_reply) \
4222 _(ikev2_profile_set_auth_reply) \
4223 _(ikev2_profile_set_id_reply) \
4224 _(ikev2_profile_set_ts_reply) \
4225 _(ikev2_set_local_key_reply) \
4226 _(ikev2_set_responder_reply) \
4227 _(ikev2_set_ike_transforms_reply) \
4228 _(ikev2_set_esp_transforms_reply) \
4229 _(ikev2_set_sa_lifetime_reply) \
4230 _(ikev2_initiate_sa_init_reply) \
4231 _(ikev2_initiate_del_ike_sa_reply) \
4232 _(ikev2_initiate_del_child_sa_reply) \
4233 _(ikev2_initiate_rekey_child_sa_reply) \
4234 _(delete_loopback_reply) \
4235 _(bd_ip_mac_add_del_reply) \
4236 _(map_del_domain_reply) \
4237 _(map_add_del_rule_reply) \
4238 _(want_interface_events_reply) \
4239 _(want_stats_reply) \
4240 _(cop_interface_enable_disable_reply) \
4241 _(cop_whitelist_enable_disable_reply) \
4242 _(sw_interface_clear_stats_reply) \
4243 _(ioam_enable_reply) \
4244 _(ioam_disable_reply) \
4245 _(one_add_del_locator_reply) \
4246 _(one_add_del_local_eid_reply) \
4247 _(one_add_del_remote_mapping_reply) \
4248 _(one_add_del_adjacency_reply) \
4249 _(one_add_del_map_resolver_reply) \
4250 _(one_add_del_map_server_reply) \
4251 _(one_enable_disable_reply) \
4252 _(one_rloc_probe_enable_disable_reply) \
4253 _(one_map_register_enable_disable_reply) \
4254 _(one_pitr_set_locator_set_reply) \
4255 _(one_map_request_mode_reply) \
4256 _(one_add_del_map_request_itr_rlocs_reply) \
4257 _(one_eid_table_add_del_map_reply) \
4258 _(one_use_petr_reply) \
4259 _(one_stats_enable_disable_reply) \
4260 _(one_stats_flush_reply) \
4261 _(gpe_add_del_fwd_entry_reply) \
4262 _(gpe_enable_disable_reply) \
4263 _(gpe_set_encap_mode_reply) \
4264 _(gpe_add_del_iface_reply) \
4265 _(vxlan_gpe_add_del_tunnel_reply) \
4266 _(af_packet_delete_reply) \
4267 _(policer_classify_set_interface_reply) \
4268 _(netmap_create_reply) \
4269 _(netmap_delete_reply) \
4270 _(set_ipfix_exporter_reply) \
4271 _(set_ipfix_classify_stream_reply) \
4272 _(ipfix_classify_table_add_del_reply) \
4273 _(flow_classify_set_interface_reply) \
4274 _(sw_interface_span_enable_disable_reply) \
4275 _(pg_capture_reply) \
4276 _(pg_enable_disable_reply) \
4277 _(ip_source_and_port_range_check_add_del_reply) \
4278 _(ip_source_and_port_range_check_interface_add_del_reply)\
4279 _(delete_subif_reply) \
4280 _(l2_interface_pbb_tag_rewrite_reply) \
4282 _(feature_enable_disable_reply) \
4283 _(sw_interface_tag_add_del_reply) \
4284 _(sw_interface_set_mtu_reply)
4287 static void vl_api_##n##_t_handler \
4288 (vl_api_##n##_t * mp) \
4290 vat_main_t * vam = &vat_main; \
4291 i32 retval = ntohl(mp->retval); \
4292 if (vam->async_mode) { \
4293 vam->async_errors += (retval < 0); \
4295 vam->retval = retval; \
4296 vam->result_ready = 1; \
4299 foreach_standard_reply_retval_handler;
4303 static void vl_api_##n##_t_handler_json \
4304 (vl_api_##n##_t * mp) \
4306 vat_main_t * vam = &vat_main; \
4307 vat_json_node_t node; \
4308 vat_json_init_object(&node); \
4309 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4310 vat_json_print(vam->ofp, &node); \
4311 vam->retval = ntohl(mp->retval); \
4312 vam->result_ready = 1; \
4314 foreach_standard_reply_retval_handler;
4318 * Table of message reply handlers, must include boilerplate handlers
4322 #define foreach_vpe_api_reply_msg \
4323 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4324 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4325 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4326 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4327 _(CONTROL_PING_REPLY, control_ping_reply) \
4328 _(CLI_REPLY, cli_reply) \
4329 _(CLI_INBAND_REPLY, cli_inband_reply) \
4330 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4331 sw_interface_add_del_address_reply) \
4332 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4333 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4334 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4335 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4336 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4337 sw_interface_set_l2_xconnect_reply) \
4338 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4339 sw_interface_set_l2_bridge_reply) \
4340 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4341 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4342 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
4343 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4344 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
4345 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
4346 _(L2_FLAGS_REPLY, l2_flags_reply) \
4347 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4348 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4349 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4350 _(TAP_DELETE_REPLY, tap_delete_reply) \
4351 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4352 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4353 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4354 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4355 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4356 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4357 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4358 proxy_arp_intfc_enable_disable_reply) \
4359 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4360 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4361 sw_interface_set_unnumbered_reply) \
4362 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4363 _(RESET_VRF_REPLY, reset_vrf_reply) \
4364 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4365 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4366 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4367 _(RESET_FIB_REPLY, reset_fib_reply) \
4368 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4369 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4370 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4371 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4372 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4373 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4374 sw_interface_ip6_enable_disable_reply) \
4375 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4376 sw_interface_ip6_set_link_local_address_reply) \
4377 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
4378 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
4379 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4380 sw_interface_ip6nd_ra_prefix_reply) \
4381 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4382 sw_interface_ip6nd_ra_config_reply) \
4383 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4384 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4385 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4386 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4387 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4388 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4389 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4390 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4391 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4392 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4393 classify_set_interface_ip_table_reply) \
4394 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4395 classify_set_interface_l2_tables_reply) \
4396 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4397 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4398 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4399 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4400 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4401 l2tpv3_interface_enable_disable_reply) \
4402 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4403 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4404 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4405 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4406 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4407 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4408 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4409 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4410 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4411 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4412 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4413 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4414 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4415 _(SHOW_VERSION_REPLY, show_version_reply) \
4416 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
4417 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4418 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4419 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4420 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4421 _(IP4_ARP_EVENT, ip4_arp_event) \
4422 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4423 _(IP6_ND_EVENT, ip6_nd_event) \
4424 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4425 _(IP_ADDRESS_DETAILS, ip_address_details) \
4426 _(IP_DETAILS, ip_details) \
4427 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4428 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4429 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4430 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4431 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4432 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
4433 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4434 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4435 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4436 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4437 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4438 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4439 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4440 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4441 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4442 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4443 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4444 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4445 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4446 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4447 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4448 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4449 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4450 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4451 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4452 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4453 _(MAP_RULE_DETAILS, map_rule_details) \
4454 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4455 _(WANT_STATS_REPLY, want_stats_reply) \
4456 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4457 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4458 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4459 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4460 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4461 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4462 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4463 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4464 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4465 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4466 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4467 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4468 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4469 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4470 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4471 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4472 one_map_register_enable_disable_reply) \
4473 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4474 one_rloc_probe_enable_disable_reply) \
4475 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4476 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
4477 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4478 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4479 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4480 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4481 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4482 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4483 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4484 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4485 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4486 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4487 _(ONE_STATS_DETAILS, one_stats_details) \
4488 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
4489 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
4490 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
4491 show_one_stats_enable_disable_reply) \
4492 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4493 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4494 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4495 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4496 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4497 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4498 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4499 gpe_fwd_entry_path_details) \
4500 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4501 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4502 one_add_del_map_request_itr_rlocs_reply) \
4503 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4504 one_get_map_request_itr_rlocs_reply) \
4505 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4506 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
4507 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4508 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4509 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4510 show_one_map_register_state_reply) \
4511 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4512 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4513 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4514 _(POLICER_DETAILS, policer_details) \
4515 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4516 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4517 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4518 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4519 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4520 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4521 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4522 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4523 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4524 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4525 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4526 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4527 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4528 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4529 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4530 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4531 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4532 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4533 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4534 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4535 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4536 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4537 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4538 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4539 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4540 ip_source_and_port_range_check_add_del_reply) \
4541 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4542 ip_source_and_port_range_check_interface_add_del_reply) \
4543 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4544 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4545 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4546 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4547 _(PUNT_REPLY, punt_reply) \
4548 _(IP_FIB_DETAILS, ip_fib_details) \
4549 _(IP6_FIB_DETAILS, ip6_fib_details) \
4550 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4551 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4552 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4553 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4554 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4555 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4557 #define foreach_standalone_reply_msg \
4558 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4559 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
4560 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
4561 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4562 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4563 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4564 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
4573 #define STR_VTR_OP_CASE(op) \
4574 case L2_VTR_ ## op: \
4578 str_vtr_op (u32 vtr_op)
4582 STR_VTR_OP_CASE (DISABLED);
4583 STR_VTR_OP_CASE (PUSH_1);
4584 STR_VTR_OP_CASE (PUSH_2);
4585 STR_VTR_OP_CASE (POP_1);
4586 STR_VTR_OP_CASE (POP_2);
4587 STR_VTR_OP_CASE (TRANSLATE_1_1);
4588 STR_VTR_OP_CASE (TRANSLATE_1_2);
4589 STR_VTR_OP_CASE (TRANSLATE_2_1);
4590 STR_VTR_OP_CASE (TRANSLATE_2_2);
4597 dump_sub_interface_table (vat_main_t * vam)
4599 const sw_interface_subif_t *sub = NULL;
4601 if (vam->json_output)
4604 ("JSON output supported only for VPE API calls and dump_stats_table");
4609 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4610 "Interface", "sw_if_index",
4611 "sub id", "dot1ad", "tags", "outer id",
4612 "inner id", "exact", "default", "outer any", "inner any");
4614 vec_foreach (sub, vam->sw_if_subif_table)
4617 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4618 sub->interface_name,
4620 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4621 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4622 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4623 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4624 if (sub->vtr_op != L2_VTR_DISABLED)
4627 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4628 "tag1: %d tag2: %d ]",
4629 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4630 sub->vtr_tag1, sub->vtr_tag2);
4638 name_sort_cmp (void *a1, void *a2)
4640 name_sort_t *n1 = a1;
4641 name_sort_t *n2 = a2;
4643 return strcmp ((char *) n1->name, (char *) n2->name);
4647 dump_interface_table (vat_main_t * vam)
4650 name_sort_t *nses = 0, *ns;
4652 if (vam->json_output)
4655 ("JSON output supported only for VPE API calls and dump_stats_table");
4660 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4662 vec_add2 (nses, ns, 1);
4663 ns->name = (u8 *)(p->key);
4664 ns->value = (u32) p->value[0];
4668 vec_sort_with_function (nses, name_sort_cmp);
4670 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4671 vec_foreach (ns, nses)
4673 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4680 dump_ip_table (vat_main_t * vam, int is_ipv6)
4682 const ip_details_t *det = NULL;
4683 const ip_address_details_t *address = NULL;
4686 print (vam->ofp, "%-12s", "sw_if_index");
4688 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4695 print (vam->ofp, "%-12d", i);
4696 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4701 vec_foreach (address, det->addr)
4705 is_ipv6 ? format_ip6_address : format_ip4_address,
4706 address->ip, address->prefix_length);
4714 dump_ipv4_table (vat_main_t * vam)
4716 if (vam->json_output)
4719 ("JSON output supported only for VPE API calls and dump_stats_table");
4723 return dump_ip_table (vam, 0);
4727 dump_ipv6_table (vat_main_t * vam)
4729 if (vam->json_output)
4732 ("JSON output supported only for VPE API calls and dump_stats_table");
4736 return dump_ip_table (vam, 1);
4740 counter_type_to_str (u8 counter_type, u8 is_combined)
4744 switch (counter_type)
4746 case VNET_INTERFACE_COUNTER_DROP:
4748 case VNET_INTERFACE_COUNTER_PUNT:
4750 case VNET_INTERFACE_COUNTER_IP4:
4752 case VNET_INTERFACE_COUNTER_IP6:
4754 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4756 case VNET_INTERFACE_COUNTER_RX_MISS:
4758 case VNET_INTERFACE_COUNTER_RX_ERROR:
4760 case VNET_INTERFACE_COUNTER_TX_ERROR:
4763 return "INVALID-COUNTER-TYPE";
4768 switch (counter_type)
4770 case VNET_INTERFACE_COUNTER_RX:
4772 case VNET_INTERFACE_COUNTER_TX:
4775 return "INVALID-COUNTER-TYPE";
4781 dump_stats_table (vat_main_t * vam)
4783 vat_json_node_t node;
4784 vat_json_node_t *msg_array;
4785 vat_json_node_t *msg;
4786 vat_json_node_t *counter_array;
4787 vat_json_node_t *counter;
4788 interface_counter_t c;
4790 ip4_fib_counter_t *c4;
4791 ip6_fib_counter_t *c6;
4792 ip4_nbr_counter_t *n4;
4793 ip6_nbr_counter_t *n6;
4796 if (!vam->json_output)
4798 clib_warning ("dump_stats_table supported only in JSON format");
4802 vat_json_init_object (&node);
4804 /* interface counters */
4805 msg_array = vat_json_object_add (&node, "interface_counters");
4806 vat_json_init_array (msg_array);
4807 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4809 msg = vat_json_array_add (msg_array);
4810 vat_json_init_object (msg);
4811 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4812 (u8 *) counter_type_to_str (i, 0));
4813 vat_json_object_add_int (msg, "is_combined", 0);
4814 counter_array = vat_json_object_add (msg, "data");
4815 vat_json_init_array (counter_array);
4816 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4818 packets = vam->simple_interface_counters[i][j];
4819 vat_json_array_add_uint (counter_array, packets);
4822 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4824 msg = vat_json_array_add (msg_array);
4825 vat_json_init_object (msg);
4826 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4827 (u8 *) counter_type_to_str (i, 1));
4828 vat_json_object_add_int (msg, "is_combined", 1);
4829 counter_array = vat_json_object_add (msg, "data");
4830 vat_json_init_array (counter_array);
4831 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4833 c = vam->combined_interface_counters[i][j];
4834 counter = vat_json_array_add (counter_array);
4835 vat_json_init_object (counter);
4836 vat_json_object_add_uint (counter, "packets", c.packets);
4837 vat_json_object_add_uint (counter, "bytes", c.bytes);
4841 /* ip4 fib counters */
4842 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4843 vat_json_init_array (msg_array);
4844 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4846 msg = vat_json_array_add (msg_array);
4847 vat_json_init_object (msg);
4848 vat_json_object_add_uint (msg, "vrf_id",
4849 vam->ip4_fib_counters_vrf_id_by_index[i]);
4850 counter_array = vat_json_object_add (msg, "c");
4851 vat_json_init_array (counter_array);
4852 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4854 counter = vat_json_array_add (counter_array);
4855 vat_json_init_object (counter);
4856 c4 = &vam->ip4_fib_counters[i][j];
4857 vat_json_object_add_ip4 (counter, "address", c4->address);
4858 vat_json_object_add_uint (counter, "address_length",
4859 c4->address_length);
4860 vat_json_object_add_uint (counter, "packets", c4->packets);
4861 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4865 /* ip6 fib counters */
4866 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4867 vat_json_init_array (msg_array);
4868 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4870 msg = vat_json_array_add (msg_array);
4871 vat_json_init_object (msg);
4872 vat_json_object_add_uint (msg, "vrf_id",
4873 vam->ip6_fib_counters_vrf_id_by_index[i]);
4874 counter_array = vat_json_object_add (msg, "c");
4875 vat_json_init_array (counter_array);
4876 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4878 counter = vat_json_array_add (counter_array);
4879 vat_json_init_object (counter);
4880 c6 = &vam->ip6_fib_counters[i][j];
4881 vat_json_object_add_ip6 (counter, "address", c6->address);
4882 vat_json_object_add_uint (counter, "address_length",
4883 c6->address_length);
4884 vat_json_object_add_uint (counter, "packets", c6->packets);
4885 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4889 /* ip4 nbr counters */
4890 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4891 vat_json_init_array (msg_array);
4892 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4894 msg = vat_json_array_add (msg_array);
4895 vat_json_init_object (msg);
4896 vat_json_object_add_uint (msg, "sw_if_index", i);
4897 counter_array = vat_json_object_add (msg, "c");
4898 vat_json_init_array (counter_array);
4899 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4901 counter = vat_json_array_add (counter_array);
4902 vat_json_init_object (counter);
4903 n4 = &vam->ip4_nbr_counters[i][j];
4904 vat_json_object_add_ip4 (counter, "address", n4->address);
4905 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4906 vat_json_object_add_uint (counter, "packets", n4->packets);
4907 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4911 /* ip6 nbr counters */
4912 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4913 vat_json_init_array (msg_array);
4914 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4916 msg = vat_json_array_add (msg_array);
4917 vat_json_init_object (msg);
4918 vat_json_object_add_uint (msg, "sw_if_index", i);
4919 counter_array = vat_json_object_add (msg, "c");
4920 vat_json_init_array (counter_array);
4921 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4923 counter = vat_json_array_add (counter_array);
4924 vat_json_init_object (counter);
4925 n6 = &vam->ip6_nbr_counters[i][j];
4926 vat_json_object_add_ip6 (counter, "address", n6->address);
4927 vat_json_object_add_uint (counter, "packets", n6->packets);
4928 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4932 vat_json_print (vam->ofp, &node);
4933 vat_json_free (&node);
4939 exec (vat_main_t * vam)
4941 api_main_t *am = &api_main;
4946 unformat_input_t *i = vam->input;
4948 if (vec_len (i->buffer) == 0)
4951 if (vam->exec_mode == 0 && unformat (i, "mode"))
4956 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4966 * Copy cmd into shared memory.
4967 * In order for the CLI command to work, it
4968 * must be a vector ending in \n, not a C-string ending
4971 pthread_mutex_lock (&am->vlib_rp->mutex);
4972 oldheap = svm_push_data_heap (am->vlib_rp);
4974 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4975 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4977 svm_pop_heap (oldheap);
4978 pthread_mutex_unlock (&am->vlib_rp->mutex);
4980 mp->cmd_in_shmem = pointer_to_uword (cmd);
4982 timeout = vat_time_now (vam) + 10.0;
4984 while (vat_time_now (vam) < timeout)
4986 if (vam->result_ready == 1)
4989 if (vam->shmem_result != NULL)
4990 print (vam->ofp, "%s", vam->shmem_result);
4991 pthread_mutex_lock (&am->vlib_rp->mutex);
4992 oldheap = svm_push_data_heap (am->vlib_rp);
4994 free_me = (u8 *) vam->shmem_result;
4997 svm_pop_heap (oldheap);
4998 pthread_mutex_unlock (&am->vlib_rp->mutex);
5006 * Future replacement of exec() that passes CLI buffers directly in
5007 * the API messages instead of an additional shared memory area.
5010 exec_inband (vat_main_t * vam)
5012 vl_api_cli_inband_t *mp;
5013 unformat_input_t *i = vam->input;
5016 if (vec_len (i->buffer) == 0)
5019 if (vam->exec_mode == 0 && unformat (i, "mode"))
5024 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5031 * In order for the CLI command to work, it
5032 * must be a vector ending in \n, not a C-string ending
5035 u32 len = vec_len (vam->input->buffer);
5036 M2 (CLI_INBAND, mp, len);
5037 clib_memcpy (mp->cmd, vam->input->buffer, len);
5038 mp->length = htonl (len);
5041 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
5046 api_create_loopback (vat_main_t * vam)
5048 unformat_input_t *i = vam->input;
5049 vl_api_create_loopback_t *mp;
5050 vl_api_create_loopback_instance_t *mp_lbi;
5053 u8 is_specified = 0;
5054 u32 user_instance = 0;
5057 memset (mac_address, 0, sizeof (mac_address));
5059 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5061 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5063 if (unformat (i, "instance %d", &user_instance))
5071 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5072 mp_lbi->is_specified = is_specified;
5074 mp_lbi->user_instance = htonl (user_instance);
5076 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5081 /* Construct the API message */
5082 M (CREATE_LOOPBACK, mp);
5084 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5093 api_delete_loopback (vat_main_t * vam)
5095 unformat_input_t *i = vam->input;
5096 vl_api_delete_loopback_t *mp;
5097 u32 sw_if_index = ~0;
5100 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5102 if (unformat (i, "sw_if_index %d", &sw_if_index))
5108 if (sw_if_index == ~0)
5110 errmsg ("missing sw_if_index");
5114 /* Construct the API message */
5115 M (DELETE_LOOPBACK, mp);
5116 mp->sw_if_index = ntohl (sw_if_index);
5124 api_want_stats (vat_main_t * vam)
5126 unformat_input_t *i = vam->input;
5127 vl_api_want_stats_t *mp;
5131 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5133 if (unformat (i, "enable"))
5135 else if (unformat (i, "disable"))
5143 errmsg ("missing enable|disable");
5148 mp->enable_disable = enable;
5156 api_want_interface_events (vat_main_t * vam)
5158 unformat_input_t *i = vam->input;
5159 vl_api_want_interface_events_t *mp;
5163 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5165 if (unformat (i, "enable"))
5167 else if (unformat (i, "disable"))
5175 errmsg ("missing enable|disable");
5179 M (WANT_INTERFACE_EVENTS, mp);
5180 mp->enable_disable = enable;
5182 vam->interface_event_display = enable;
5190 /* Note: non-static, called once to set up the initial intfc table */
5192 api_sw_interface_dump (vat_main_t * vam)
5194 vl_api_sw_interface_dump_t *mp;
5195 vl_api_control_ping_t *mp_ping;
5197 name_sort_t *nses = 0, *ns;
5198 sw_interface_subif_t *sub = NULL;
5201 /* Toss the old name table */
5203 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5205 vec_add2 (nses, ns, 1);
5206 ns->name = (u8 *)(p->key);
5207 ns->value = (u32) p->value[0];
5211 hash_free (vam->sw_if_index_by_interface_name);
5213 vec_foreach (ns, nses) vec_free (ns->name);
5217 vec_foreach (sub, vam->sw_if_subif_table)
5219 vec_free (sub->interface_name);
5221 vec_free (vam->sw_if_subif_table);
5223 /* recreate the interface name hash table */
5224 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5226 /* Get list of ethernets */
5227 M (SW_INTERFACE_DUMP, mp);
5228 mp->name_filter_valid = 1;
5229 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
5232 /* and local / loopback interfaces */
5233 M (SW_INTERFACE_DUMP, mp);
5234 mp->name_filter_valid = 1;
5235 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
5238 /* and packet-generator interfaces */
5239 M (SW_INTERFACE_DUMP, mp);
5240 mp->name_filter_valid = 1;
5241 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
5244 /* and vxlan-gpe tunnel interfaces */
5245 M (SW_INTERFACE_DUMP, mp);
5246 mp->name_filter_valid = 1;
5247 strncpy ((char *) mp->name_filter, "vxlan_gpe",
5248 sizeof (mp->name_filter) - 1);
5251 /* and vxlan tunnel interfaces */
5252 M (SW_INTERFACE_DUMP, mp);
5253 mp->name_filter_valid = 1;
5254 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
5257 /* and host (af_packet) interfaces */
5258 M (SW_INTERFACE_DUMP, mp);
5259 mp->name_filter_valid = 1;
5260 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
5263 /* and l2tpv3 tunnel interfaces */
5264 M (SW_INTERFACE_DUMP, mp);
5265 mp->name_filter_valid = 1;
5266 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
5267 sizeof (mp->name_filter) - 1);
5270 /* and GRE tunnel interfaces */
5271 M (SW_INTERFACE_DUMP, mp);
5272 mp->name_filter_valid = 1;
5273 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
5276 /* and LISP-GPE interfaces */
5277 M (SW_INTERFACE_DUMP, mp);
5278 mp->name_filter_valid = 1;
5279 strncpy ((char *) mp->name_filter, "lisp_gpe",
5280 sizeof (mp->name_filter) - 1);
5283 /* and IPSEC tunnel interfaces */
5284 M (SW_INTERFACE_DUMP, mp);
5285 mp->name_filter_valid = 1;
5286 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
5289 /* Use a control ping for synchronization */
5290 M (CONTROL_PING, mp_ping);
5298 api_sw_interface_set_flags (vat_main_t * vam)
5300 unformat_input_t *i = vam->input;
5301 vl_api_sw_interface_set_flags_t *mp;
5303 u8 sw_if_index_set = 0;
5304 u8 admin_up = 0, link_up = 0;
5307 /* Parse args required to build the message */
5308 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5310 if (unformat (i, "admin-up"))
5312 else if (unformat (i, "admin-down"))
5314 else if (unformat (i, "link-up"))
5316 else if (unformat (i, "link-down"))
5319 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5320 sw_if_index_set = 1;
5321 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5322 sw_if_index_set = 1;
5327 if (sw_if_index_set == 0)
5329 errmsg ("missing interface name or sw_if_index");
5333 /* Construct the API message */
5334 M (SW_INTERFACE_SET_FLAGS, mp);
5335 mp->sw_if_index = ntohl (sw_if_index);
5336 mp->admin_up_down = admin_up;
5337 mp->link_up_down = link_up;
5342 /* Wait for a reply, return the good/bad news... */
5348 api_sw_interface_clear_stats (vat_main_t * vam)
5350 unformat_input_t *i = vam->input;
5351 vl_api_sw_interface_clear_stats_t *mp;
5353 u8 sw_if_index_set = 0;
5356 /* Parse args required to build the message */
5357 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5359 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5360 sw_if_index_set = 1;
5361 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5362 sw_if_index_set = 1;
5367 /* Construct the API message */
5368 M (SW_INTERFACE_CLEAR_STATS, mp);
5370 if (sw_if_index_set == 1)
5371 mp->sw_if_index = ntohl (sw_if_index);
5373 mp->sw_if_index = ~0;
5378 /* Wait for a reply, return the good/bad news... */
5384 api_sw_interface_add_del_address (vat_main_t * vam)
5386 unformat_input_t *i = vam->input;
5387 vl_api_sw_interface_add_del_address_t *mp;
5389 u8 sw_if_index_set = 0;
5390 u8 is_add = 1, del_all = 0;
5391 u32 address_length = 0;
5392 u8 v4_address_set = 0;
5393 u8 v6_address_set = 0;
5394 ip4_address_t v4address;
5395 ip6_address_t v6address;
5398 /* Parse args required to build the message */
5399 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5401 if (unformat (i, "del-all"))
5403 else if (unformat (i, "del"))
5406 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5407 sw_if_index_set = 1;
5408 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5409 sw_if_index_set = 1;
5410 else if (unformat (i, "%U/%d",
5411 unformat_ip4_address, &v4address, &address_length))
5413 else if (unformat (i, "%U/%d",
5414 unformat_ip6_address, &v6address, &address_length))
5420 if (sw_if_index_set == 0)
5422 errmsg ("missing interface name or sw_if_index");
5425 if (v4_address_set && v6_address_set)
5427 errmsg ("both v4 and v6 addresses set");
5430 if (!v4_address_set && !v6_address_set && !del_all)
5432 errmsg ("no addresses set");
5436 /* Construct the API message */
5437 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5439 mp->sw_if_index = ntohl (sw_if_index);
5440 mp->is_add = is_add;
5441 mp->del_all = del_all;
5445 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5449 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5451 mp->address_length = address_length;
5456 /* Wait for a reply, return good/bad news */
5462 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5464 unformat_input_t *i = vam->input;
5465 vl_api_sw_interface_set_mpls_enable_t *mp;
5467 u8 sw_if_index_set = 0;
5471 /* Parse args required to build the message */
5472 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5474 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5475 sw_if_index_set = 1;
5476 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5477 sw_if_index_set = 1;
5478 else if (unformat (i, "disable"))
5480 else if (unformat (i, "dis"))
5486 if (sw_if_index_set == 0)
5488 errmsg ("missing interface name or sw_if_index");
5492 /* Construct the API message */
5493 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5495 mp->sw_if_index = ntohl (sw_if_index);
5496 mp->enable = enable;
5501 /* Wait for a reply... */
5507 api_sw_interface_set_table (vat_main_t * vam)
5509 unformat_input_t *i = vam->input;
5510 vl_api_sw_interface_set_table_t *mp;
5511 u32 sw_if_index, vrf_id = 0;
5512 u8 sw_if_index_set = 0;
5516 /* Parse args required to build the message */
5517 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5519 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5520 sw_if_index_set = 1;
5521 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5522 sw_if_index_set = 1;
5523 else if (unformat (i, "vrf %d", &vrf_id))
5525 else if (unformat (i, "ipv6"))
5531 if (sw_if_index_set == 0)
5533 errmsg ("missing interface name or sw_if_index");
5537 /* Construct the API message */
5538 M (SW_INTERFACE_SET_TABLE, mp);
5540 mp->sw_if_index = ntohl (sw_if_index);
5541 mp->is_ipv6 = is_ipv6;
5542 mp->vrf_id = ntohl (vrf_id);
5547 /* Wait for a reply... */
5552 static void vl_api_sw_interface_get_table_reply_t_handler
5553 (vl_api_sw_interface_get_table_reply_t * mp)
5555 vat_main_t *vam = &vat_main;
5557 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5559 vam->retval = ntohl (mp->retval);
5560 vam->result_ready = 1;
5564 static void vl_api_sw_interface_get_table_reply_t_handler_json
5565 (vl_api_sw_interface_get_table_reply_t * mp)
5567 vat_main_t *vam = &vat_main;
5568 vat_json_node_t node;
5570 vat_json_init_object (&node);
5571 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5572 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5574 vat_json_print (vam->ofp, &node);
5575 vat_json_free (&node);
5577 vam->retval = ntohl (mp->retval);
5578 vam->result_ready = 1;
5582 api_sw_interface_get_table (vat_main_t * vam)
5584 unformat_input_t *i = vam->input;
5585 vl_api_sw_interface_get_table_t *mp;
5587 u8 sw_if_index_set = 0;
5591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5593 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5594 sw_if_index_set = 1;
5595 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5596 sw_if_index_set = 1;
5597 else if (unformat (i, "ipv6"))
5603 if (sw_if_index_set == 0)
5605 errmsg ("missing interface name or sw_if_index");
5609 M (SW_INTERFACE_GET_TABLE, mp);
5610 mp->sw_if_index = htonl (sw_if_index);
5611 mp->is_ipv6 = is_ipv6;
5619 api_sw_interface_set_vpath (vat_main_t * vam)
5621 unformat_input_t *i = vam->input;
5622 vl_api_sw_interface_set_vpath_t *mp;
5623 u32 sw_if_index = 0;
5624 u8 sw_if_index_set = 0;
5628 /* Parse args required to build the message */
5629 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5631 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5632 sw_if_index_set = 1;
5633 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5634 sw_if_index_set = 1;
5635 else if (unformat (i, "enable"))
5637 else if (unformat (i, "disable"))
5643 if (sw_if_index_set == 0)
5645 errmsg ("missing interface name or sw_if_index");
5649 /* Construct the API message */
5650 M (SW_INTERFACE_SET_VPATH, mp);
5652 mp->sw_if_index = ntohl (sw_if_index);
5653 mp->enable = is_enable;
5658 /* Wait for a reply... */
5664 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5666 unformat_input_t *i = vam->input;
5667 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5668 u32 sw_if_index = 0;
5669 u8 sw_if_index_set = 0;
5674 /* Parse args required to build the message */
5675 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5677 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5678 sw_if_index_set = 1;
5679 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5680 sw_if_index_set = 1;
5681 else if (unformat (i, "enable"))
5683 else if (unformat (i, "disable"))
5685 else if (unformat (i, "ip4"))
5687 else if (unformat (i, "ip6"))
5693 if (sw_if_index_set == 0)
5695 errmsg ("missing interface name or sw_if_index");
5699 /* Construct the API message */
5700 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5702 mp->sw_if_index = ntohl (sw_if_index);
5703 mp->enable = is_enable;
5704 mp->is_ipv6 = is_ipv6;
5709 /* Wait for a reply... */
5715 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5717 unformat_input_t *i = vam->input;
5718 vl_api_sw_interface_set_l2_xconnect_t *mp;
5720 u8 rx_sw_if_index_set = 0;
5722 u8 tx_sw_if_index_set = 0;
5726 /* Parse args required to build the message */
5727 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5729 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5730 rx_sw_if_index_set = 1;
5731 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5732 tx_sw_if_index_set = 1;
5733 else if (unformat (i, "rx"))
5735 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5737 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5739 rx_sw_if_index_set = 1;
5744 else if (unformat (i, "tx"))
5746 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5748 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5750 tx_sw_if_index_set = 1;
5755 else if (unformat (i, "enable"))
5757 else if (unformat (i, "disable"))
5763 if (rx_sw_if_index_set == 0)
5765 errmsg ("missing rx interface name or rx_sw_if_index");
5769 if (enable && (tx_sw_if_index_set == 0))
5771 errmsg ("missing tx interface name or tx_sw_if_index");
5775 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5777 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5778 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5779 mp->enable = enable;
5787 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5789 unformat_input_t *i = vam->input;
5790 vl_api_sw_interface_set_l2_bridge_t *mp;
5792 u8 rx_sw_if_index_set = 0;
5800 /* Parse args required to build the message */
5801 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5803 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5804 rx_sw_if_index_set = 1;
5805 else if (unformat (i, "bd_id %d", &bd_id))
5809 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5810 rx_sw_if_index_set = 1;
5811 else if (unformat (i, "shg %d", &shg))
5813 else if (unformat (i, "bvi"))
5815 else if (unformat (i, "enable"))
5817 else if (unformat (i, "disable"))
5823 if (rx_sw_if_index_set == 0)
5825 errmsg ("missing rx interface name or sw_if_index");
5829 if (enable && (bd_id_set == 0))
5831 errmsg ("missing bridge domain");
5835 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
5837 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5838 mp->bd_id = ntohl (bd_id);
5841 mp->enable = enable;
5849 api_bridge_domain_dump (vat_main_t * vam)
5851 unformat_input_t *i = vam->input;
5852 vl_api_bridge_domain_dump_t *mp;
5853 vl_api_control_ping_t *mp_ping;
5857 /* Parse args required to build the message */
5858 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5860 if (unformat (i, "bd_id %d", &bd_id))
5866 M (BRIDGE_DOMAIN_DUMP, mp);
5867 mp->bd_id = ntohl (bd_id);
5870 /* Use a control ping for synchronization */
5871 M (CONTROL_PING, mp_ping);
5879 api_bridge_domain_add_del (vat_main_t * vam)
5881 unformat_input_t *i = vam->input;
5882 vl_api_bridge_domain_add_del_t *mp;
5885 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5889 /* Parse args required to build the message */
5890 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5892 if (unformat (i, "bd_id %d", &bd_id))
5894 else if (unformat (i, "flood %d", &flood))
5896 else if (unformat (i, "uu-flood %d", &uu_flood))
5898 else if (unformat (i, "forward %d", &forward))
5900 else if (unformat (i, "learn %d", &learn))
5902 else if (unformat (i, "arp-term %d", &arp_term))
5904 else if (unformat (i, "mac-age %d", &mac_age))
5906 else if (unformat (i, "del"))
5909 flood = uu_flood = forward = learn = 0;
5917 errmsg ("missing bridge domain");
5923 errmsg ("mac age must be less than 256 ");
5927 M (BRIDGE_DOMAIN_ADD_DEL, mp);
5929 mp->bd_id = ntohl (bd_id);
5931 mp->uu_flood = uu_flood;
5932 mp->forward = forward;
5934 mp->arp_term = arp_term;
5935 mp->is_add = is_add;
5936 mp->mac_age = (u8) mac_age;
5944 api_l2fib_flush_bd (vat_main_t * vam)
5946 unformat_input_t *i = vam->input;
5947 vl_api_l2fib_flush_bd_t *mp;
5951 /* Parse args required to build the message */
5952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5954 if (unformat (i, "bd_id %d", &bd_id));
5961 errmsg ("missing bridge domain");
5965 M (L2FIB_FLUSH_BD, mp);
5967 mp->bd_id = htonl (bd_id);
5975 api_l2fib_flush_int (vat_main_t * vam)
5977 unformat_input_t *i = vam->input;
5978 vl_api_l2fib_flush_int_t *mp;
5979 u32 sw_if_index = ~0;
5982 /* Parse args required to build the message */
5983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5985 if (unformat (i, "sw_if_index %d", &sw_if_index));
5987 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
5992 if (sw_if_index == ~0)
5994 errmsg ("missing interface name or sw_if_index");
5998 M (L2FIB_FLUSH_INT, mp);
6000 mp->sw_if_index = ntohl (sw_if_index);
6008 api_l2fib_add_del (vat_main_t * vam)
6010 unformat_input_t *i = vam->input;
6011 vl_api_l2fib_add_del_t *mp;
6017 u32 sw_if_index = ~0;
6018 u8 sw_if_index_set = 0;
6027 /* Parse args required to build the message */
6028 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6030 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6032 else if (unformat (i, "bd_id %d", &bd_id))
6034 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6035 sw_if_index_set = 1;
6036 else if (unformat (i, "sw_if"))
6038 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6041 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6042 sw_if_index_set = 1;
6047 else if (unformat (i, "static"))
6049 else if (unformat (i, "filter"))
6054 else if (unformat (i, "bvi"))
6059 else if (unformat (i, "del"))
6061 else if (unformat (i, "count %d", &count))
6069 errmsg ("missing mac address");
6075 errmsg ("missing bridge domain");
6079 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6081 errmsg ("missing interface name or sw_if_index");
6087 /* Turn on async mode */
6088 vam->async_mode = 1;
6089 vam->async_errors = 0;
6090 before = vat_time_now (vam);
6093 for (j = 0; j < count; j++)
6095 M (L2FIB_ADD_DEL, mp);
6098 mp->bd_id = ntohl (bd_id);
6099 mp->is_add = is_add;
6103 mp->sw_if_index = ntohl (sw_if_index);
6104 mp->static_mac = static_mac;
6105 mp->filter_mac = filter_mac;
6106 mp->bvi_mac = bvi_mac;
6108 increment_mac_address (&mac);
6115 vl_api_control_ping_t *mp_ping;
6118 /* Shut off async mode */
6119 vam->async_mode = 0;
6121 M (CONTROL_PING, mp_ping);
6124 timeout = vat_time_now (vam) + 1.0;
6125 while (vat_time_now (vam) < timeout)
6126 if (vam->result_ready == 1)
6131 if (vam->retval == -99)
6134 if (vam->async_errors > 0)
6136 errmsg ("%d asynchronous errors", vam->async_errors);
6139 vam->async_errors = 0;
6140 after = vat_time_now (vam);
6142 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6143 count, after - before, count / (after - before));
6149 /* Wait for a reply... */
6153 /* Return the good/bad news */
6154 return (vam->retval);
6158 api_bridge_domain_set_mac_age (vat_main_t * vam)
6160 unformat_input_t *i = vam->input;
6161 vl_api_bridge_domain_set_mac_age_t *mp;
6166 /* Parse args required to build the message */
6167 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6169 if (unformat (i, "bd_id %d", &bd_id));
6170 else if (unformat (i, "mac-age %d", &mac_age));
6177 errmsg ("missing bridge domain");
6183 errmsg ("mac age must be less than 256 ");
6187 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6189 mp->bd_id = htonl (bd_id);
6190 mp->mac_age = (u8) mac_age;
6198 api_l2_flags (vat_main_t * vam)
6200 unformat_input_t *i = vam->input;
6201 vl_api_l2_flags_t *mp;
6203 u32 feature_bitmap = 0;
6204 u8 sw_if_index_set = 0;
6207 /* Parse args required to build the message */
6208 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6210 if (unformat (i, "sw_if_index %d", &sw_if_index))
6211 sw_if_index_set = 1;
6212 else if (unformat (i, "sw_if"))
6214 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6217 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6218 sw_if_index_set = 1;
6223 else if (unformat (i, "learn"))
6224 feature_bitmap |= L2INPUT_FEAT_LEARN;
6225 else if (unformat (i, "forward"))
6226 feature_bitmap |= L2INPUT_FEAT_FWD;
6227 else if (unformat (i, "flood"))
6228 feature_bitmap |= L2INPUT_FEAT_FLOOD;
6229 else if (unformat (i, "uu-flood"))
6230 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
6235 if (sw_if_index_set == 0)
6237 errmsg ("missing interface name or sw_if_index");
6243 mp->sw_if_index = ntohl (sw_if_index);
6244 mp->feature_bitmap = ntohl (feature_bitmap);
6252 api_bridge_flags (vat_main_t * vam)
6254 unformat_input_t *i = vam->input;
6255 vl_api_bridge_flags_t *mp;
6262 /* Parse args required to build the message */
6263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6265 if (unformat (i, "bd_id %d", &bd_id))
6267 else if (unformat (i, "learn"))
6269 else if (unformat (i, "forward"))
6271 else if (unformat (i, "flood"))
6273 else if (unformat (i, "uu-flood"))
6274 flags |= L2_UU_FLOOD;
6275 else if (unformat (i, "arp-term"))
6276 flags |= L2_ARP_TERM;
6277 else if (unformat (i, "off"))
6279 else if (unformat (i, "disable"))
6287 errmsg ("missing bridge domain");
6291 M (BRIDGE_FLAGS, mp);
6293 mp->bd_id = ntohl (bd_id);
6294 mp->feature_bitmap = ntohl (flags);
6295 mp->is_set = is_set;
6303 api_bd_ip_mac_add_del (vat_main_t * vam)
6305 unformat_input_t *i = vam->input;
6306 vl_api_bd_ip_mac_add_del_t *mp;
6313 ip4_address_t v4addr;
6314 ip6_address_t v6addr;
6319 /* Parse args required to build the message */
6320 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6322 if (unformat (i, "bd_id %d", &bd_id))
6326 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6330 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6335 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6339 else if (unformat (i, "del"))
6347 errmsg ("missing bridge domain");
6350 else if (ip_set == 0)
6352 errmsg ("missing IP address");
6355 else if (mac_set == 0)
6357 errmsg ("missing MAC address");
6361 M (BD_IP_MAC_ADD_DEL, mp);
6363 mp->bd_id = ntohl (bd_id);
6364 mp->is_ipv6 = is_ipv6;
6365 mp->is_add = is_add;
6367 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6369 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6370 clib_memcpy (mp->mac_address, macaddr, 6);
6377 api_tap_connect (vat_main_t * vam)
6379 unformat_input_t *i = vam->input;
6380 vl_api_tap_connect_t *mp;
6386 ip4_address_t ip4_address;
6388 int ip4_address_set = 0;
6389 ip6_address_t ip6_address;
6391 int ip6_address_set = 0;
6394 memset (mac_address, 0, sizeof (mac_address));
6396 /* Parse args required to build the message */
6397 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6399 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6403 else if (unformat (i, "random-mac"))
6405 else if (unformat (i, "tapname %s", &tap_name))
6407 else if (unformat (i, "tag %s", &tag))
6409 else if (unformat (i, "address %U/%d",
6410 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6411 ip4_address_set = 1;
6412 else if (unformat (i, "address %U/%d",
6413 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6414 ip6_address_set = 1;
6421 errmsg ("missing tap name");
6424 if (vec_len (tap_name) > 63)
6426 errmsg ("tap name too long");
6429 vec_add1 (tap_name, 0);
6431 if (vec_len (tag) > 63)
6433 errmsg ("tag too long");
6437 /* Construct the API message */
6438 M (TAP_CONNECT, mp);
6440 mp->use_random_mac = random_mac;
6441 clib_memcpy (mp->mac_address, mac_address, 6);
6442 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6444 clib_memcpy (mp->tag, tag, vec_len (tag));
6446 if (ip4_address_set)
6448 mp->ip4_address_set = 1;
6449 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6450 mp->ip4_mask_width = ip4_mask_width;
6452 if (ip6_address_set)
6454 mp->ip6_address_set = 1;
6455 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6456 mp->ip6_mask_width = ip6_mask_width;
6459 vec_free (tap_name);
6465 /* Wait for a reply... */
6471 api_tap_modify (vat_main_t * vam)
6473 unformat_input_t *i = vam->input;
6474 vl_api_tap_modify_t *mp;
6479 u32 sw_if_index = ~0;
6480 u8 sw_if_index_set = 0;
6483 memset (mac_address, 0, sizeof (mac_address));
6485 /* Parse args required to build the message */
6486 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6488 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6489 sw_if_index_set = 1;
6490 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6491 sw_if_index_set = 1;
6492 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6496 else if (unformat (i, "random-mac"))
6498 else if (unformat (i, "tapname %s", &tap_name))
6504 if (sw_if_index_set == 0)
6506 errmsg ("missing vpp interface name");
6511 errmsg ("missing tap name");
6514 if (vec_len (tap_name) > 63)
6516 errmsg ("tap name too long");
6518 vec_add1 (tap_name, 0);
6520 /* Construct the API message */
6523 mp->use_random_mac = random_mac;
6524 mp->sw_if_index = ntohl (sw_if_index);
6525 clib_memcpy (mp->mac_address, mac_address, 6);
6526 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6527 vec_free (tap_name);
6532 /* Wait for a reply... */
6538 api_tap_delete (vat_main_t * vam)
6540 unformat_input_t *i = vam->input;
6541 vl_api_tap_delete_t *mp;
6542 u32 sw_if_index = ~0;
6543 u8 sw_if_index_set = 0;
6546 /* Parse args required to build the message */
6547 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6549 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6550 sw_if_index_set = 1;
6551 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6552 sw_if_index_set = 1;
6557 if (sw_if_index_set == 0)
6559 errmsg ("missing vpp interface name");
6563 /* Construct the API message */
6566 mp->sw_if_index = ntohl (sw_if_index);
6571 /* Wait for a reply... */
6577 api_ip_add_del_route (vat_main_t * vam)
6579 unformat_input_t *i = vam->input;
6580 vl_api_ip_add_del_route_t *mp;
6581 u32 sw_if_index = ~0, vrf_id = 0;
6583 u8 is_local = 0, is_drop = 0;
6584 u8 is_unreach = 0, is_prohibit = 0;
6585 u8 create_vrf_if_needed = 0;
6587 u32 next_hop_weight = 1;
6589 u8 is_multipath = 0;
6591 u8 address_length_set = 0;
6592 u32 next_hop_table_id = 0;
6593 u32 resolve_attempts = 0;
6594 u32 dst_address_length = 0;
6595 u8 next_hop_set = 0;
6596 ip4_address_t v4_dst_address, v4_next_hop_address;
6597 ip6_address_t v6_dst_address, v6_next_hop_address;
6601 u32 random_add_del = 0;
6602 u32 *random_vector = 0;
6604 u32 random_seed = 0xdeaddabe;
6605 u32 classify_table_index = ~0;
6607 u8 resolve_host = 0, resolve_attached = 0;
6608 mpls_label_t *next_hop_out_label_stack = NULL;
6609 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6610 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6612 /* Parse args required to build the message */
6613 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6615 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6617 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6619 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6624 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6629 else if (unformat (i, "/%d", &dst_address_length))
6631 address_length_set = 1;
6634 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6635 &v4_next_hop_address))
6639 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6640 &v6_next_hop_address))
6644 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6646 else if (unformat (i, "weight %d", &next_hop_weight))
6648 else if (unformat (i, "drop"))
6652 else if (unformat (i, "null-send-unreach"))
6656 else if (unformat (i, "null-send-prohibit"))
6660 else if (unformat (i, "local"))
6664 else if (unformat (i, "classify %d", &classify_table_index))
6668 else if (unformat (i, "del"))
6670 else if (unformat (i, "add"))
6672 else if (unformat (i, "not-last"))
6674 else if (unformat (i, "resolve-via-host"))
6676 else if (unformat (i, "resolve-via-attached"))
6677 resolve_attached = 1;
6678 else if (unformat (i, "multipath"))
6680 else if (unformat (i, "vrf %d", &vrf_id))
6682 else if (unformat (i, "create-vrf"))
6683 create_vrf_if_needed = 1;
6684 else if (unformat (i, "count %d", &count))
6686 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6688 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6690 else if (unformat (i, "out-label %d", &next_hop_out_label))
6691 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6692 else if (unformat (i, "via-label %d", &next_hop_via_label))
6694 else if (unformat (i, "random"))
6696 else if (unformat (i, "seed %d", &random_seed))
6700 clib_warning ("parse error '%U'", format_unformat_error, i);
6705 if (!next_hop_set && !is_drop && !is_local &&
6706 !is_classify && !is_unreach && !is_prohibit &&
6707 MPLS_LABEL_INVALID == next_hop_via_label)
6710 ("next hop / local / drop / unreach / prohibit / classify not set");
6714 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6716 errmsg ("next hop and next-hop via label set");
6719 if (address_set == 0)
6721 errmsg ("missing addresses");
6725 if (address_length_set == 0)
6727 errmsg ("missing address length");
6731 /* Generate a pile of unique, random routes */
6734 u32 this_random_address;
6735 random_hash = hash_create (count, sizeof (uword));
6737 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6738 for (j = 0; j <= count; j++)
6742 this_random_address = random_u32 (&random_seed);
6743 this_random_address =
6744 clib_host_to_net_u32 (this_random_address);
6746 while (hash_get (random_hash, this_random_address));
6747 vec_add1 (random_vector, this_random_address);
6748 hash_set (random_hash, this_random_address, 1);
6750 hash_free (random_hash);
6751 v4_dst_address.as_u32 = random_vector[0];
6756 /* Turn on async mode */
6757 vam->async_mode = 1;
6758 vam->async_errors = 0;
6759 before = vat_time_now (vam);
6762 for (j = 0; j < count; j++)
6764 /* Construct the API message */
6765 M2 (IP_ADD_DEL_ROUTE, mp,
6766 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6768 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6769 mp->table_id = ntohl (vrf_id);
6770 mp->create_vrf_if_needed = create_vrf_if_needed;
6772 mp->is_add = is_add;
6773 mp->is_drop = is_drop;
6774 mp->is_unreach = is_unreach;
6775 mp->is_prohibit = is_prohibit;
6776 mp->is_ipv6 = is_ipv6;
6777 mp->is_local = is_local;
6778 mp->is_classify = is_classify;
6779 mp->is_multipath = is_multipath;
6780 mp->is_resolve_host = resolve_host;
6781 mp->is_resolve_attached = resolve_attached;
6782 mp->not_last = not_last;
6783 mp->next_hop_weight = next_hop_weight;
6784 mp->dst_address_length = dst_address_length;
6785 mp->next_hop_table_id = ntohl (next_hop_table_id);
6786 mp->classify_table_index = ntohl (classify_table_index);
6787 mp->next_hop_via_label = ntohl (next_hop_via_label);
6788 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6789 if (0 != mp->next_hop_n_out_labels)
6791 memcpy (mp->next_hop_out_label_stack,
6792 next_hop_out_label_stack,
6793 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6794 vec_free (next_hop_out_label_stack);
6799 clib_memcpy (mp->dst_address, &v6_dst_address,
6800 sizeof (v6_dst_address));
6802 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6803 sizeof (v6_next_hop_address));
6804 increment_v6_address (&v6_dst_address);
6808 clib_memcpy (mp->dst_address, &v4_dst_address,
6809 sizeof (v4_dst_address));
6811 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6812 sizeof (v4_next_hop_address));
6814 v4_dst_address.as_u32 = random_vector[j + 1];
6816 increment_v4_address (&v4_dst_address);
6820 /* If we receive SIGTERM, stop now... */
6825 /* When testing multiple add/del ops, use a control-ping to sync */
6828 vl_api_control_ping_t *mp_ping;
6832 /* Shut off async mode */
6833 vam->async_mode = 0;
6835 M (CONTROL_PING, mp_ping);
6838 timeout = vat_time_now (vam) + 1.0;
6839 while (vat_time_now (vam) < timeout)
6840 if (vam->result_ready == 1)
6845 if (vam->retval == -99)
6848 if (vam->async_errors > 0)
6850 errmsg ("%d asynchronous errors", vam->async_errors);
6853 vam->async_errors = 0;
6854 after = vat_time_now (vam);
6856 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6860 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6861 count, after - before, count / (after - before));
6867 /* Wait for a reply... */
6872 /* Return the good/bad news */
6873 return (vam->retval);
6877 api_ip_mroute_add_del (vat_main_t * vam)
6879 unformat_input_t *i = vam->input;
6880 vl_api_ip_mroute_add_del_t *mp;
6881 u32 sw_if_index = ~0, vrf_id = 0;
6884 u8 create_vrf_if_needed = 0;
6887 u32 grp_address_length = 0;
6888 ip4_address_t v4_grp_address, v4_src_address;
6889 ip6_address_t v6_grp_address, v6_src_address;
6890 mfib_itf_flags_t iflags = 0;
6891 mfib_entry_flags_t eflags = 0;
6894 /* Parse args required to build the message */
6895 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6897 if (unformat (i, "sw_if_index %d", &sw_if_index))
6899 else if (unformat (i, "%U %U",
6900 unformat_ip4_address, &v4_src_address,
6901 unformat_ip4_address, &v4_grp_address))
6903 grp_address_length = 64;
6907 else if (unformat (i, "%U %U",
6908 unformat_ip6_address, &v6_src_address,
6909 unformat_ip6_address, &v6_grp_address))
6911 grp_address_length = 256;
6915 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
6917 memset (&v4_src_address, 0, sizeof (v4_src_address));
6918 grp_address_length = 32;
6922 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
6924 memset (&v6_src_address, 0, sizeof (v6_src_address));
6925 grp_address_length = 128;
6929 else if (unformat (i, "/%d", &grp_address_length))
6931 else if (unformat (i, "local"))
6935 else if (unformat (i, "del"))
6937 else if (unformat (i, "add"))
6939 else if (unformat (i, "vrf %d", &vrf_id))
6941 else if (unformat (i, "create-vrf"))
6942 create_vrf_if_needed = 1;
6943 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
6945 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
6949 clib_warning ("parse error '%U'", format_unformat_error, i);
6954 if (address_set == 0)
6956 errmsg ("missing addresses\n");
6960 /* Construct the API message */
6961 M (IP_MROUTE_ADD_DEL, mp);
6963 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6964 mp->table_id = ntohl (vrf_id);
6965 mp->create_vrf_if_needed = create_vrf_if_needed;
6967 mp->is_add = is_add;
6968 mp->is_ipv6 = is_ipv6;
6969 mp->is_local = is_local;
6970 mp->itf_flags = ntohl (iflags);
6971 mp->entry_flags = ntohl (eflags);
6972 mp->grp_address_length = grp_address_length;
6973 mp->grp_address_length = ntohs (mp->grp_address_length);
6977 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
6978 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
6982 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
6983 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
6989 /* Wait for a reply... */
6995 api_mpls_route_add_del (vat_main_t * vam)
6997 unformat_input_t *i = vam->input;
6998 vl_api_mpls_route_add_del_t *mp;
6999 u32 sw_if_index = ~0, table_id = 0;
7000 u8 create_table_if_needed = 0;
7002 u32 next_hop_weight = 1;
7003 u8 is_multipath = 0;
7004 u32 next_hop_table_id = 0;
7005 u8 next_hop_set = 0;
7006 ip4_address_t v4_next_hop_address = {
7009 ip6_address_t v6_next_hop_address = { {0} };
7013 u32 classify_table_index = ~0;
7015 u8 resolve_host = 0, resolve_attached = 0;
7016 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7017 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7018 mpls_label_t *next_hop_out_label_stack = NULL;
7019 mpls_label_t local_label = MPLS_LABEL_INVALID;
7021 u8 next_hop_proto_is_ip4 = 1;
7023 /* Parse args required to build the message */
7024 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7026 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7028 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7030 else if (unformat (i, "%d", &local_label))
7032 else if (unformat (i, "eos"))
7034 else if (unformat (i, "non-eos"))
7036 else if (unformat (i, "via %U", unformat_ip4_address,
7037 &v4_next_hop_address))
7040 next_hop_proto_is_ip4 = 1;
7042 else if (unformat (i, "via %U", unformat_ip6_address,
7043 &v6_next_hop_address))
7046 next_hop_proto_is_ip4 = 0;
7048 else if (unformat (i, "weight %d", &next_hop_weight))
7050 else if (unformat (i, "create-table"))
7051 create_table_if_needed = 1;
7052 else if (unformat (i, "classify %d", &classify_table_index))
7056 else if (unformat (i, "del"))
7058 else if (unformat (i, "add"))
7060 else if (unformat (i, "resolve-via-host"))
7062 else if (unformat (i, "resolve-via-attached"))
7063 resolve_attached = 1;
7064 else if (unformat (i, "multipath"))
7066 else if (unformat (i, "count %d", &count))
7068 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
7071 next_hop_proto_is_ip4 = 1;
7073 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
7076 next_hop_proto_is_ip4 = 0;
7078 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7080 else if (unformat (i, "via-label %d", &next_hop_via_label))
7082 else if (unformat (i, "out-label %d", &next_hop_out_label))
7083 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7086 clib_warning ("parse error '%U'", format_unformat_error, i);
7091 if (!next_hop_set && !is_classify)
7093 errmsg ("next hop / classify not set");
7097 if (MPLS_LABEL_INVALID == local_label)
7099 errmsg ("missing label");
7105 /* Turn on async mode */
7106 vam->async_mode = 1;
7107 vam->async_errors = 0;
7108 before = vat_time_now (vam);
7111 for (j = 0; j < count; j++)
7113 /* Construct the API message */
7114 M2 (MPLS_ROUTE_ADD_DEL, mp,
7115 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7117 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
7118 mp->mr_table_id = ntohl (table_id);
7119 mp->mr_create_table_if_needed = create_table_if_needed;
7121 mp->mr_is_add = is_add;
7122 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7123 mp->mr_is_classify = is_classify;
7124 mp->mr_is_multipath = is_multipath;
7125 mp->mr_is_resolve_host = resolve_host;
7126 mp->mr_is_resolve_attached = resolve_attached;
7127 mp->mr_next_hop_weight = next_hop_weight;
7128 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
7129 mp->mr_classify_table_index = ntohl (classify_table_index);
7130 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
7131 mp->mr_label = ntohl (local_label);
7132 mp->mr_eos = is_eos;
7134 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7135 if (0 != mp->mr_next_hop_n_out_labels)
7137 memcpy (mp->mr_next_hop_out_label_stack,
7138 next_hop_out_label_stack,
7139 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7140 vec_free (next_hop_out_label_stack);
7145 if (next_hop_proto_is_ip4)
7147 clib_memcpy (mp->mr_next_hop,
7148 &v4_next_hop_address,
7149 sizeof (v4_next_hop_address));
7153 clib_memcpy (mp->mr_next_hop,
7154 &v6_next_hop_address,
7155 sizeof (v6_next_hop_address));
7162 /* If we receive SIGTERM, stop now... */
7167 /* When testing multiple add/del ops, use a control-ping to sync */
7170 vl_api_control_ping_t *mp_ping;
7174 /* Shut off async mode */
7175 vam->async_mode = 0;
7177 M (CONTROL_PING, mp_ping);
7180 timeout = vat_time_now (vam) + 1.0;
7181 while (vat_time_now (vam) < timeout)
7182 if (vam->result_ready == 1)
7187 if (vam->retval == -99)
7190 if (vam->async_errors > 0)
7192 errmsg ("%d asynchronous errors", vam->async_errors);
7195 vam->async_errors = 0;
7196 after = vat_time_now (vam);
7198 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7202 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7203 count, after - before, count / (after - before));
7209 /* Wait for a reply... */
7214 /* Return the good/bad news */
7215 return (vam->retval);
7219 api_mpls_ip_bind_unbind (vat_main_t * vam)
7221 unformat_input_t *i = vam->input;
7222 vl_api_mpls_ip_bind_unbind_t *mp;
7223 u32 ip_table_id = 0;
7224 u8 create_table_if_needed = 0;
7227 ip4_address_t v4_address;
7228 ip6_address_t v6_address;
7231 mpls_label_t local_label = MPLS_LABEL_INVALID;
7234 /* Parse args required to build the message */
7235 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7237 if (unformat (i, "%U/%d", unformat_ip4_address,
7238 &v4_address, &address_length))
7243 else if (unformat (i, "%U/%d", unformat_ip6_address,
7244 &v6_address, &address_length))
7249 else if (unformat (i, "%d", &local_label))
7251 else if (unformat (i, "create-table"))
7252 create_table_if_needed = 1;
7253 else if (unformat (i, "table-id %d", &ip_table_id))
7255 else if (unformat (i, "unbind"))
7257 else if (unformat (i, "bind"))
7261 clib_warning ("parse error '%U'", format_unformat_error, i);
7268 errmsg ("IP addres not set");
7272 if (MPLS_LABEL_INVALID == local_label)
7274 errmsg ("missing label");
7278 /* Construct the API message */
7279 M (MPLS_IP_BIND_UNBIND, mp);
7281 mp->mb_create_table_if_needed = create_table_if_needed;
7282 mp->mb_is_bind = is_bind;
7283 mp->mb_is_ip4 = is_ip4;
7284 mp->mb_ip_table_id = ntohl (ip_table_id);
7285 mp->mb_mpls_table_id = 0;
7286 mp->mb_label = ntohl (local_label);
7287 mp->mb_address_length = address_length;
7290 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7292 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7297 /* Wait for a reply... */
7303 api_proxy_arp_add_del (vat_main_t * vam)
7305 unformat_input_t *i = vam->input;
7306 vl_api_proxy_arp_add_del_t *mp;
7309 ip4_address_t lo, hi;
7313 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7315 if (unformat (i, "vrf %d", &vrf_id))
7317 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7318 unformat_ip4_address, &hi))
7320 else if (unformat (i, "del"))
7324 clib_warning ("parse error '%U'", format_unformat_error, i);
7331 errmsg ("address range not set");
7335 M (PROXY_ARP_ADD_DEL, mp);
7337 mp->vrf_id = ntohl (vrf_id);
7338 mp->is_add = is_add;
7339 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7340 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7348 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7350 unformat_input_t *i = vam->input;
7351 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7354 u8 sw_if_index_set = 0;
7357 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7359 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7360 sw_if_index_set = 1;
7361 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7362 sw_if_index_set = 1;
7363 else if (unformat (i, "enable"))
7365 else if (unformat (i, "disable"))
7369 clib_warning ("parse error '%U'", format_unformat_error, i);
7374 if (sw_if_index_set == 0)
7376 errmsg ("missing interface name or sw_if_index");
7380 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7382 mp->sw_if_index = ntohl (sw_if_index);
7383 mp->enable_disable = enable;
7391 api_mpls_tunnel_add_del (vat_main_t * vam)
7393 unformat_input_t *i = vam->input;
7394 vl_api_mpls_tunnel_add_del_t *mp;
7398 u32 sw_if_index = ~0;
7399 u32 next_hop_sw_if_index = ~0;
7400 u32 next_hop_proto_is_ip4 = 1;
7402 u32 next_hop_table_id = 0;
7403 ip4_address_t v4_next_hop_address = {
7406 ip6_address_t v6_next_hop_address = { {0} };
7407 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7410 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7412 if (unformat (i, "add"))
7414 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7416 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7418 else if (unformat (i, "via %U",
7419 unformat_ip4_address, &v4_next_hop_address))
7421 next_hop_proto_is_ip4 = 1;
7423 else if (unformat (i, "via %U",
7424 unformat_ip6_address, &v6_next_hop_address))
7426 next_hop_proto_is_ip4 = 0;
7428 else if (unformat (i, "l2-only"))
7430 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7432 else if (unformat (i, "out-label %d", &next_hop_out_label))
7433 vec_add1 (labels, ntohl (next_hop_out_label));
7436 clib_warning ("parse error '%U'", format_unformat_error, i);
7441 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7443 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7444 mp->mt_sw_if_index = ntohl (sw_if_index);
7445 mp->mt_is_add = is_add;
7446 mp->mt_l2_only = l2_only;
7447 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7448 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7450 mp->mt_next_hop_n_out_labels = vec_len (labels);
7452 if (0 != mp->mt_next_hop_n_out_labels)
7454 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7455 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7459 if (next_hop_proto_is_ip4)
7461 clib_memcpy (mp->mt_next_hop,
7462 &v4_next_hop_address, sizeof (v4_next_hop_address));
7466 clib_memcpy (mp->mt_next_hop,
7467 &v6_next_hop_address, sizeof (v6_next_hop_address));
7476 api_sw_interface_set_unnumbered (vat_main_t * vam)
7478 unformat_input_t *i = vam->input;
7479 vl_api_sw_interface_set_unnumbered_t *mp;
7481 u32 unnum_sw_index = ~0;
7483 u8 sw_if_index_set = 0;
7486 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7488 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7489 sw_if_index_set = 1;
7490 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7491 sw_if_index_set = 1;
7492 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7494 else if (unformat (i, "del"))
7498 clib_warning ("parse error '%U'", format_unformat_error, i);
7503 if (sw_if_index_set == 0)
7505 errmsg ("missing interface name or sw_if_index");
7509 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7511 mp->sw_if_index = ntohl (sw_if_index);
7512 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7513 mp->is_add = is_add;
7521 api_ip_neighbor_add_del (vat_main_t * vam)
7523 unformat_input_t *i = vam->input;
7524 vl_api_ip_neighbor_add_del_t *mp;
7526 u8 sw_if_index_set = 0;
7529 u8 is_no_fib_entry = 0;
7532 u8 v4_address_set = 0;
7533 u8 v6_address_set = 0;
7534 ip4_address_t v4address;
7535 ip6_address_t v6address;
7538 memset (mac_address, 0, sizeof (mac_address));
7540 /* Parse args required to build the message */
7541 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7543 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7547 else if (unformat (i, "del"))
7550 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7551 sw_if_index_set = 1;
7552 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7553 sw_if_index_set = 1;
7554 else if (unformat (i, "is_static"))
7556 else if (unformat (i, "no-fib-entry"))
7557 is_no_fib_entry = 1;
7558 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7560 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7564 clib_warning ("parse error '%U'", format_unformat_error, i);
7569 if (sw_if_index_set == 0)
7571 errmsg ("missing interface name or sw_if_index");
7574 if (v4_address_set && v6_address_set)
7576 errmsg ("both v4 and v6 addresses set");
7579 if (!v4_address_set && !v6_address_set)
7581 errmsg ("no address set");
7585 /* Construct the API message */
7586 M (IP_NEIGHBOR_ADD_DEL, mp);
7588 mp->sw_if_index = ntohl (sw_if_index);
7589 mp->is_add = is_add;
7590 mp->is_static = is_static;
7591 mp->is_no_adj_fib = is_no_fib_entry;
7593 clib_memcpy (mp->mac_address, mac_address, 6);
7597 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7601 /* mp->is_ipv6 = 0; via memset in M macro above */
7602 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7608 /* Wait for a reply, return good/bad news */
7614 api_reset_vrf (vat_main_t * vam)
7616 unformat_input_t *i = vam->input;
7617 vl_api_reset_vrf_t *mp;
7623 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7625 if (unformat (i, "vrf %d", &vrf_id))
7627 else if (unformat (i, "ipv6"))
7631 clib_warning ("parse error '%U'", format_unformat_error, i);
7636 if (vrf_id_set == 0)
7638 errmsg ("missing vrf id");
7644 mp->vrf_id = ntohl (vrf_id);
7645 mp->is_ipv6 = is_ipv6;
7653 api_create_vlan_subif (vat_main_t * vam)
7655 unformat_input_t *i = vam->input;
7656 vl_api_create_vlan_subif_t *mp;
7658 u8 sw_if_index_set = 0;
7663 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7665 if (unformat (i, "sw_if_index %d", &sw_if_index))
7666 sw_if_index_set = 1;
7668 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7669 sw_if_index_set = 1;
7670 else if (unformat (i, "vlan %d", &vlan_id))
7674 clib_warning ("parse error '%U'", format_unformat_error, i);
7679 if (sw_if_index_set == 0)
7681 errmsg ("missing interface name or sw_if_index");
7685 if (vlan_id_set == 0)
7687 errmsg ("missing vlan_id");
7690 M (CREATE_VLAN_SUBIF, mp);
7692 mp->sw_if_index = ntohl (sw_if_index);
7693 mp->vlan_id = ntohl (vlan_id);
7700 #define foreach_create_subif_bit \
7707 _(outer_vlan_id_any) \
7708 _(inner_vlan_id_any)
7711 api_create_subif (vat_main_t * vam)
7713 unformat_input_t *i = vam->input;
7714 vl_api_create_subif_t *mp;
7716 u8 sw_if_index_set = 0;
7723 u32 exact_match = 0;
7724 u32 default_sub = 0;
7725 u32 outer_vlan_id_any = 0;
7726 u32 inner_vlan_id_any = 0;
7728 u16 outer_vlan_id = 0;
7729 u16 inner_vlan_id = 0;
7732 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7734 if (unformat (i, "sw_if_index %d", &sw_if_index))
7735 sw_if_index_set = 1;
7737 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7738 sw_if_index_set = 1;
7739 else if (unformat (i, "sub_id %d", &sub_id))
7741 else if (unformat (i, "outer_vlan_id %d", &tmp))
7742 outer_vlan_id = tmp;
7743 else if (unformat (i, "inner_vlan_id %d", &tmp))
7744 inner_vlan_id = tmp;
7746 #define _(a) else if (unformat (i, #a)) a = 1 ;
7747 foreach_create_subif_bit
7751 clib_warning ("parse error '%U'", format_unformat_error, i);
7756 if (sw_if_index_set == 0)
7758 errmsg ("missing interface name or sw_if_index");
7762 if (sub_id_set == 0)
7764 errmsg ("missing sub_id");
7767 M (CREATE_SUBIF, mp);
7769 mp->sw_if_index = ntohl (sw_if_index);
7770 mp->sub_id = ntohl (sub_id);
7772 #define _(a) mp->a = a;
7773 foreach_create_subif_bit;
7776 mp->outer_vlan_id = ntohs (outer_vlan_id);
7777 mp->inner_vlan_id = ntohs (inner_vlan_id);
7785 api_oam_add_del (vat_main_t * vam)
7787 unformat_input_t *i = vam->input;
7788 vl_api_oam_add_del_t *mp;
7791 ip4_address_t src, dst;
7796 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7798 if (unformat (i, "vrf %d", &vrf_id))
7800 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7802 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7804 else if (unformat (i, "del"))
7808 clib_warning ("parse error '%U'", format_unformat_error, i);
7815 errmsg ("missing src addr");
7821 errmsg ("missing dst addr");
7825 M (OAM_ADD_DEL, mp);
7827 mp->vrf_id = ntohl (vrf_id);
7828 mp->is_add = is_add;
7829 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7830 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7838 api_reset_fib (vat_main_t * vam)
7840 unformat_input_t *i = vam->input;
7841 vl_api_reset_fib_t *mp;
7847 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7849 if (unformat (i, "vrf %d", &vrf_id))
7851 else if (unformat (i, "ipv6"))
7855 clib_warning ("parse error '%U'", format_unformat_error, i);
7860 if (vrf_id_set == 0)
7862 errmsg ("missing vrf id");
7868 mp->vrf_id = ntohl (vrf_id);
7869 mp->is_ipv6 = is_ipv6;
7877 api_dhcp_proxy_config (vat_main_t * vam)
7879 unformat_input_t *i = vam->input;
7880 vl_api_dhcp_proxy_config_t *mp;
7882 u32 server_vrf_id = 0;
7884 u8 v4_address_set = 0;
7885 u8 v6_address_set = 0;
7886 ip4_address_t v4address;
7887 ip6_address_t v6address;
7888 u8 v4_src_address_set = 0;
7889 u8 v6_src_address_set = 0;
7890 ip4_address_t v4srcaddress;
7891 ip6_address_t v6srcaddress;
7894 /* Parse args required to build the message */
7895 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7897 if (unformat (i, "del"))
7899 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7901 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7903 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7905 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7907 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7908 v4_src_address_set = 1;
7909 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7910 v6_src_address_set = 1;
7915 if (v4_address_set && v6_address_set)
7917 errmsg ("both v4 and v6 server addresses set");
7920 if (!v4_address_set && !v6_address_set)
7922 errmsg ("no server addresses set");
7926 if (v4_src_address_set && v6_src_address_set)
7928 errmsg ("both v4 and v6 src addresses set");
7931 if (!v4_src_address_set && !v6_src_address_set)
7933 errmsg ("no src addresses set");
7937 if (!(v4_src_address_set && v4_address_set) &&
7938 !(v6_src_address_set && v6_address_set))
7940 errmsg ("no matching server and src addresses set");
7944 /* Construct the API message */
7945 M (DHCP_PROXY_CONFIG, mp);
7947 mp->is_add = is_add;
7948 mp->rx_vrf_id = ntohl (rx_vrf_id);
7949 mp->server_vrf_id = ntohl (server_vrf_id);
7953 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7954 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7958 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7959 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7965 /* Wait for a reply, return good/bad news */
7970 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
7971 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
7974 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
7976 vat_main_t *vam = &vat_main;
7977 u32 i, count = mp->count;
7978 vl_api_dhcp_server_t *s;
7982 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7983 ntohl (mp->rx_vrf_id),
7984 format_ip6_address, mp->dhcp_src_address,
7985 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7988 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7989 ntohl (mp->rx_vrf_id),
7990 format_ip4_address, mp->dhcp_src_address,
7991 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7993 for (i = 0; i < count; i++)
7995 s = &mp->servers[i];
7999 " Server Table-ID %d, Server Address %U",
8000 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
8003 " Server Table-ID %d, Server Address %U",
8004 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
8008 static void vl_api_dhcp_proxy_details_t_handler_json
8009 (vl_api_dhcp_proxy_details_t * mp)
8011 vat_main_t *vam = &vat_main;
8012 vat_json_node_t *node = NULL;
8013 u32 i, count = mp->count;
8015 struct in6_addr ip6;
8016 vl_api_dhcp_server_t *s;
8018 if (VAT_JSON_ARRAY != vam->json_tree.type)
8020 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8021 vat_json_init_array (&vam->json_tree);
8023 node = vat_json_array_add (&vam->json_tree);
8025 vat_json_init_object (node);
8026 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
8027 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
8028 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
8032 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
8033 vat_json_object_add_ip6 (node, "src_address", ip6);
8037 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
8038 vat_json_object_add_ip4 (node, "src_address", ip4);
8041 for (i = 0; i < count; i++)
8043 s = &mp->servers[i];
8045 vat_json_object_add_uint (node, "server-table-id",
8046 ntohl (s->server_vrf_id));
8050 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
8051 vat_json_object_add_ip4 (node, "src_address", ip4);
8055 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
8056 vat_json_object_add_ip6 (node, "server_address", ip6);
8062 api_dhcp_proxy_dump (vat_main_t * vam)
8064 unformat_input_t *i = vam->input;
8065 vl_api_control_ping_t *mp_ping;
8066 vl_api_dhcp_proxy_dump_t *mp;
8070 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8072 if (unformat (i, "ipv6"))
8076 clib_warning ("parse error '%U'", format_unformat_error, i);
8081 M (DHCP_PROXY_DUMP, mp);
8083 mp->is_ip6 = is_ipv6;
8086 /* Use a control ping for synchronization */
8087 M (CONTROL_PING, mp_ping);
8095 api_dhcp_proxy_set_vss (vat_main_t * vam)
8097 unformat_input_t *i = vam->input;
8098 vl_api_dhcp_proxy_set_vss_t *mp;
8109 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8111 if (unformat (i, "tbl_id %d", &tbl_id))
8113 if (unformat (i, "fib_id %d", &fib_id))
8115 if (unformat (i, "oui %d", &oui))
8117 else if (unformat (i, "ipv6"))
8119 else if (unformat (i, "del"))
8123 clib_warning ("parse error '%U'", format_unformat_error, i);
8128 if (tbl_id_set == 0)
8130 errmsg ("missing tbl id");
8134 if (fib_id_set == 0)
8136 errmsg ("missing fib id");
8141 errmsg ("missing oui");
8145 M (DHCP_PROXY_SET_VSS, mp);
8146 mp->tbl_id = ntohl (tbl_id);
8147 mp->fib_id = ntohl (fib_id);
8148 mp->oui = ntohl (oui);
8149 mp->is_ipv6 = is_ipv6;
8150 mp->is_add = is_add;
8158 api_dhcp_client_config (vat_main_t * vam)
8160 unformat_input_t *i = vam->input;
8161 vl_api_dhcp_client_config_t *mp;
8163 u8 sw_if_index_set = 0;
8166 u8 disable_event = 0;
8169 /* Parse args required to build the message */
8170 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8172 if (unformat (i, "del"))
8175 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8176 sw_if_index_set = 1;
8177 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8178 sw_if_index_set = 1;
8179 else if (unformat (i, "hostname %s", &hostname))
8181 else if (unformat (i, "disable_event"))
8187 if (sw_if_index_set == 0)
8189 errmsg ("missing interface name or sw_if_index");
8193 if (vec_len (hostname) > 63)
8195 errmsg ("hostname too long");
8197 vec_add1 (hostname, 0);
8199 /* Construct the API message */
8200 M (DHCP_CLIENT_CONFIG, mp);
8202 mp->sw_if_index = htonl (sw_if_index);
8203 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
8204 vec_free (hostname);
8205 mp->is_add = is_add;
8206 mp->want_dhcp_event = disable_event ? 0 : 1;
8207 mp->pid = htonl (getpid ());
8212 /* Wait for a reply, return good/bad news */
8218 api_set_ip_flow_hash (vat_main_t * vam)
8220 unformat_input_t *i = vam->input;
8221 vl_api_set_ip_flow_hash_t *mp;
8233 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8235 if (unformat (i, "vrf %d", &vrf_id))
8237 else if (unformat (i, "ipv6"))
8239 else if (unformat (i, "src"))
8241 else if (unformat (i, "dst"))
8243 else if (unformat (i, "sport"))
8245 else if (unformat (i, "dport"))
8247 else if (unformat (i, "proto"))
8249 else if (unformat (i, "reverse"))
8254 clib_warning ("parse error '%U'", format_unformat_error, i);
8259 if (vrf_id_set == 0)
8261 errmsg ("missing vrf id");
8265 M (SET_IP_FLOW_HASH, mp);
8271 mp->reverse = reverse;
8272 mp->vrf_id = ntohl (vrf_id);
8273 mp->is_ipv6 = is_ipv6;
8281 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8283 unformat_input_t *i = vam->input;
8284 vl_api_sw_interface_ip6_enable_disable_t *mp;
8286 u8 sw_if_index_set = 0;
8290 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8292 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8293 sw_if_index_set = 1;
8294 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8295 sw_if_index_set = 1;
8296 else if (unformat (i, "enable"))
8298 else if (unformat (i, "disable"))
8302 clib_warning ("parse error '%U'", format_unformat_error, i);
8307 if (sw_if_index_set == 0)
8309 errmsg ("missing interface name or sw_if_index");
8313 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8315 mp->sw_if_index = ntohl (sw_if_index);
8316 mp->enable = enable;
8324 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8326 unformat_input_t *i = vam->input;
8327 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8329 u8 sw_if_index_set = 0;
8330 u8 v6_address_set = 0;
8331 ip6_address_t v6address;
8334 /* Parse args required to build the message */
8335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8337 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8338 sw_if_index_set = 1;
8339 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8340 sw_if_index_set = 1;
8341 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8347 if (sw_if_index_set == 0)
8349 errmsg ("missing interface name or sw_if_index");
8352 if (!v6_address_set)
8354 errmsg ("no address set");
8358 /* Construct the API message */
8359 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8361 mp->sw_if_index = ntohl (sw_if_index);
8362 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8367 /* Wait for a reply, return good/bad news */
8373 api_ip6nd_proxy_add_del (vat_main_t * vam)
8375 unformat_input_t *i = vam->input;
8376 vl_api_ip6nd_proxy_add_del_t *mp;
8377 u32 sw_if_index = ~0;
8378 u8 v6_address_set = 0;
8379 ip6_address_t v6address;
8383 /* Parse args required to build the message */
8384 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8386 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8388 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8390 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8392 if (unformat (i, "del"))
8396 clib_warning ("parse error '%U'", format_unformat_error, i);
8401 if (sw_if_index == ~0)
8403 errmsg ("missing interface name or sw_if_index");
8406 if (!v6_address_set)
8408 errmsg ("no address set");
8412 /* Construct the API message */
8413 M (IP6ND_PROXY_ADD_DEL, mp);
8415 mp->is_del = is_del;
8416 mp->sw_if_index = ntohl (sw_if_index);
8417 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8422 /* Wait for a reply, return good/bad news */
8428 api_ip6nd_proxy_dump (vat_main_t * vam)
8430 vl_api_ip6nd_proxy_dump_t *mp;
8431 vl_api_control_ping_t *mp_ping;
8434 M (IP6ND_PROXY_DUMP, mp);
8438 /* Use a control ping for synchronization */
8439 M (CONTROL_PING, mp_ping);
8446 static void vl_api_ip6nd_proxy_details_t_handler
8447 (vl_api_ip6nd_proxy_details_t * mp)
8449 vat_main_t *vam = &vat_main;
8451 print (vam->ofp, "host %U sw_if_index %d",
8452 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
8455 static void vl_api_ip6nd_proxy_details_t_handler_json
8456 (vl_api_ip6nd_proxy_details_t * mp)
8458 vat_main_t *vam = &vat_main;
8459 struct in6_addr ip6;
8460 vat_json_node_t *node = NULL;
8462 if (VAT_JSON_ARRAY != vam->json_tree.type)
8464 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8465 vat_json_init_array (&vam->json_tree);
8467 node = vat_json_array_add (&vam->json_tree);
8469 vat_json_init_object (node);
8470 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
8472 clib_memcpy (&ip6, mp->address, sizeof (ip6));
8473 vat_json_object_add_ip6 (node, "host", ip6);
8477 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8479 unformat_input_t *i = vam->input;
8480 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8482 u8 sw_if_index_set = 0;
8483 u32 address_length = 0;
8484 u8 v6_address_set = 0;
8485 ip6_address_t v6address;
8487 u8 no_advertise = 0;
8489 u8 no_autoconfig = 0;
8492 u32 val_lifetime = 0;
8493 u32 pref_lifetime = 0;
8496 /* Parse args required to build the message */
8497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8499 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8500 sw_if_index_set = 1;
8501 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8502 sw_if_index_set = 1;
8503 else if (unformat (i, "%U/%d",
8504 unformat_ip6_address, &v6address, &address_length))
8506 else if (unformat (i, "val_life %d", &val_lifetime))
8508 else if (unformat (i, "pref_life %d", &pref_lifetime))
8510 else if (unformat (i, "def"))
8512 else if (unformat (i, "noadv"))
8514 else if (unformat (i, "offl"))
8516 else if (unformat (i, "noauto"))
8518 else if (unformat (i, "nolink"))
8520 else if (unformat (i, "isno"))
8524 clib_warning ("parse error '%U'", format_unformat_error, i);
8529 if (sw_if_index_set == 0)
8531 errmsg ("missing interface name or sw_if_index");
8534 if (!v6_address_set)
8536 errmsg ("no address set");
8540 /* Construct the API message */
8541 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8543 mp->sw_if_index = ntohl (sw_if_index);
8544 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8545 mp->address_length = address_length;
8546 mp->use_default = use_default;
8547 mp->no_advertise = no_advertise;
8548 mp->off_link = off_link;
8549 mp->no_autoconfig = no_autoconfig;
8550 mp->no_onlink = no_onlink;
8552 mp->val_lifetime = ntohl (val_lifetime);
8553 mp->pref_lifetime = ntohl (pref_lifetime);
8558 /* Wait for a reply, return good/bad news */
8564 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8566 unformat_input_t *i = vam->input;
8567 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8569 u8 sw_if_index_set = 0;
8574 u8 send_unicast = 0;
8577 u8 default_router = 0;
8578 u32 max_interval = 0;
8579 u32 min_interval = 0;
8581 u32 initial_count = 0;
8582 u32 initial_interval = 0;
8586 /* Parse args required to build the message */
8587 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8589 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8590 sw_if_index_set = 1;
8591 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8592 sw_if_index_set = 1;
8593 else if (unformat (i, "maxint %d", &max_interval))
8595 else if (unformat (i, "minint %d", &min_interval))
8597 else if (unformat (i, "life %d", &lifetime))
8599 else if (unformat (i, "count %d", &initial_count))
8601 else if (unformat (i, "interval %d", &initial_interval))
8603 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8605 else if (unformat (i, "managed"))
8607 else if (unformat (i, "other"))
8609 else if (unformat (i, "ll"))
8611 else if (unformat (i, "send"))
8613 else if (unformat (i, "cease"))
8615 else if (unformat (i, "isno"))
8617 else if (unformat (i, "def"))
8621 clib_warning ("parse error '%U'", format_unformat_error, i);
8626 if (sw_if_index_set == 0)
8628 errmsg ("missing interface name or sw_if_index");
8632 /* Construct the API message */
8633 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8635 mp->sw_if_index = ntohl (sw_if_index);
8636 mp->max_interval = ntohl (max_interval);
8637 mp->min_interval = ntohl (min_interval);
8638 mp->lifetime = ntohl (lifetime);
8639 mp->initial_count = ntohl (initial_count);
8640 mp->initial_interval = ntohl (initial_interval);
8641 mp->suppress = suppress;
8642 mp->managed = managed;
8644 mp->ll_option = ll_option;
8645 mp->send_unicast = send_unicast;
8648 mp->default_router = default_router;
8653 /* Wait for a reply, return good/bad news */
8659 api_set_arp_neighbor_limit (vat_main_t * vam)
8661 unformat_input_t *i = vam->input;
8662 vl_api_set_arp_neighbor_limit_t *mp;
8668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8670 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8672 else if (unformat (i, "ipv6"))
8676 clib_warning ("parse error '%U'", format_unformat_error, i);
8683 errmsg ("missing limit value");
8687 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8689 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8690 mp->is_ipv6 = is_ipv6;
8698 api_l2_patch_add_del (vat_main_t * vam)
8700 unformat_input_t *i = vam->input;
8701 vl_api_l2_patch_add_del_t *mp;
8703 u8 rx_sw_if_index_set = 0;
8705 u8 tx_sw_if_index_set = 0;
8709 /* Parse args required to build the message */
8710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8712 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8713 rx_sw_if_index_set = 1;
8714 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8715 tx_sw_if_index_set = 1;
8716 else if (unformat (i, "rx"))
8718 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8720 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8722 rx_sw_if_index_set = 1;
8727 else if (unformat (i, "tx"))
8729 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8731 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8733 tx_sw_if_index_set = 1;
8738 else if (unformat (i, "del"))
8744 if (rx_sw_if_index_set == 0)
8746 errmsg ("missing rx interface name or rx_sw_if_index");
8750 if (tx_sw_if_index_set == 0)
8752 errmsg ("missing tx interface name or tx_sw_if_index");
8756 M (L2_PATCH_ADD_DEL, mp);
8758 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8759 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8760 mp->is_add = is_add;
8768 u8 localsid_addr[16];
8777 api_sr_localsid_add_del (vat_main_t * vam)
8779 unformat_input_t *i = vam->input;
8780 vl_api_sr_localsid_add_del_t *mp;
8783 ip6_address_t localsid;
8787 u32 fib_table = ~(u32) 0;
8788 ip6_address_t next_hop;
8790 bool nexthop_set = 0;
8794 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8796 if (unformat (i, "del"))
8798 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
8799 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
8801 else if (unformat (i, "behavior %u", &behavior));
8802 else if (unformat (i, "sw_if_index %u", &sw_if_index));
8803 else if (unformat (i, "fib-table %u", &fib_table));
8804 else if (unformat (i, "end.psp %u", &behavior));
8809 M (SR_LOCALSID_ADD_DEL, mp);
8811 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
8813 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
8814 mp->behavior = behavior;
8815 mp->sw_if_index = ntohl (sw_if_index);
8816 mp->fib_table = ntohl (fib_table);
8817 mp->end_psp = end_psp;
8818 mp->is_del = is_del;
8826 api_ioam_enable (vat_main_t * vam)
8828 unformat_input_t *input = vam->input;
8829 vl_api_ioam_enable_t *mp;
8831 int has_trace_option = 0;
8832 int has_pot_option = 0;
8833 int has_seqno_option = 0;
8834 int has_analyse_option = 0;
8837 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8839 if (unformat (input, "trace"))
8840 has_trace_option = 1;
8841 else if (unformat (input, "pot"))
8843 else if (unformat (input, "seqno"))
8844 has_seqno_option = 1;
8845 else if (unformat (input, "analyse"))
8846 has_analyse_option = 1;
8850 M (IOAM_ENABLE, mp);
8851 mp->id = htons (id);
8852 mp->seqno = has_seqno_option;
8853 mp->analyse = has_analyse_option;
8854 mp->pot_enable = has_pot_option;
8855 mp->trace_enable = has_trace_option;
8864 api_ioam_disable (vat_main_t * vam)
8866 vl_api_ioam_disable_t *mp;
8869 M (IOAM_DISABLE, mp);
8875 #define foreach_tcp_proto_field \
8879 #define foreach_udp_proto_field \
8883 #define foreach_ip4_proto_field \
8895 u16 src_port, dst_port;
8898 #if VPP_API_TEST_BUILTIN == 0
8900 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8902 u8 **maskp = va_arg (*args, u8 **);
8904 u8 found_something = 0;
8907 #define _(a) u8 a=0;
8908 foreach_tcp_proto_field;
8911 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8914 #define _(a) else if (unformat (input, #a)) a=1;
8915 foreach_tcp_proto_field
8921 #define _(a) found_something += a;
8922 foreach_tcp_proto_field;
8925 if (found_something == 0)
8928 vec_validate (mask, sizeof (*tcp) - 1);
8930 tcp = (tcp_header_t *) mask;
8932 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8933 foreach_tcp_proto_field;
8941 unformat_udp_mask (unformat_input_t * input, va_list * args)
8943 u8 **maskp = va_arg (*args, u8 **);
8945 u8 found_something = 0;
8948 #define _(a) u8 a=0;
8949 foreach_udp_proto_field;
8952 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8955 #define _(a) else if (unformat (input, #a)) a=1;
8956 foreach_udp_proto_field
8962 #define _(a) found_something += a;
8963 foreach_udp_proto_field;
8966 if (found_something == 0)
8969 vec_validate (mask, sizeof (*udp) - 1);
8971 udp = (udp_header_t *) mask;
8973 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8974 foreach_udp_proto_field;
8982 unformat_l4_mask (unformat_input_t * input, va_list * args)
8984 u8 **maskp = va_arg (*args, u8 **);
8985 u16 src_port = 0, dst_port = 0;
8986 tcpudp_header_t *tcpudp;
8988 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8990 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8992 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8994 else if (unformat (input, "src_port"))
8996 else if (unformat (input, "dst_port"))
9002 if (!src_port && !dst_port)
9006 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9008 tcpudp = (tcpudp_header_t *) mask;
9009 tcpudp->src_port = src_port;
9010 tcpudp->dst_port = dst_port;
9018 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9020 u8 **maskp = va_arg (*args, u8 **);
9022 u8 found_something = 0;
9025 #define _(a) u8 a=0;
9026 foreach_ip4_proto_field;
9032 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9034 if (unformat (input, "version"))
9036 else if (unformat (input, "hdr_length"))
9038 else if (unformat (input, "src"))
9040 else if (unformat (input, "dst"))
9042 else if (unformat (input, "proto"))
9045 #define _(a) else if (unformat (input, #a)) a=1;
9046 foreach_ip4_proto_field
9052 #define _(a) found_something += a;
9053 foreach_ip4_proto_field;
9056 if (found_something == 0)
9059 vec_validate (mask, sizeof (*ip) - 1);
9061 ip = (ip4_header_t *) mask;
9063 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9064 foreach_ip4_proto_field;
9067 ip->ip_version_and_header_length = 0;
9070 ip->ip_version_and_header_length |= 0xF0;
9073 ip->ip_version_and_header_length |= 0x0F;
9079 #define foreach_ip6_proto_field \
9087 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9089 u8 **maskp = va_arg (*args, u8 **);
9091 u8 found_something = 0;
9093 u32 ip_version_traffic_class_and_flow_label;
9095 #define _(a) u8 a=0;
9096 foreach_ip6_proto_field;
9099 u8 traffic_class = 0;
9102 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9104 if (unformat (input, "version"))
9106 else if (unformat (input, "traffic-class"))
9108 else if (unformat (input, "flow-label"))
9110 else if (unformat (input, "src"))
9112 else if (unformat (input, "dst"))
9114 else if (unformat (input, "proto"))
9117 #define _(a) else if (unformat (input, #a)) a=1;
9118 foreach_ip6_proto_field
9124 #define _(a) found_something += a;
9125 foreach_ip6_proto_field;
9128 if (found_something == 0)
9131 vec_validate (mask, sizeof (*ip) - 1);
9133 ip = (ip6_header_t *) mask;
9135 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9136 foreach_ip6_proto_field;
9139 ip_version_traffic_class_and_flow_label = 0;
9142 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9145 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9148 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9150 ip->ip_version_traffic_class_and_flow_label =
9151 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9158 unformat_l3_mask (unformat_input_t * input, va_list * args)
9160 u8 **maskp = va_arg (*args, u8 **);
9162 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9164 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9166 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9175 unformat_l2_mask (unformat_input_t * input, va_list * args)
9177 u8 **maskp = va_arg (*args, u8 **);
9192 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9194 if (unformat (input, "src"))
9196 else if (unformat (input, "dst"))
9198 else if (unformat (input, "proto"))
9200 else if (unformat (input, "tag1"))
9202 else if (unformat (input, "tag2"))
9204 else if (unformat (input, "ignore-tag1"))
9206 else if (unformat (input, "ignore-tag2"))
9208 else if (unformat (input, "cos1"))
9210 else if (unformat (input, "cos2"))
9212 else if (unformat (input, "dot1q"))
9214 else if (unformat (input, "dot1ad"))
9219 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9220 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9223 if (tag1 || ignore_tag1 || cos1 || dot1q)
9225 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9228 vec_validate (mask, len - 1);
9231 memset (mask, 0xff, 6);
9234 memset (mask + 6, 0xff, 6);
9238 /* inner vlan tag */
9247 mask[21] = mask[20] = 0xff;
9268 mask[16] = mask[17] = 0xff;
9278 mask[12] = mask[13] = 0xff;
9285 unformat_classify_mask (unformat_input_t * input, va_list * args)
9287 u8 **maskp = va_arg (*args, u8 **);
9288 u32 *skipp = va_arg (*args, u32 *);
9289 u32 *matchp = va_arg (*args, u32 *);
9297 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9299 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9301 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9303 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9305 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9319 if (mask || l2 || l3 || l4)
9323 /* "With a free Ethernet header in every package" */
9325 vec_validate (l2, 13);
9329 vec_append (mask, l3);
9334 vec_append (mask, l4);
9339 /* Scan forward looking for the first significant mask octet */
9340 for (i = 0; i < vec_len (mask); i++)
9344 /* compute (skip, match) params */
9345 *skipp = i / sizeof (u32x4);
9346 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9348 /* Pad mask to an even multiple of the vector size */
9349 while (vec_len (mask) % sizeof (u32x4))
9352 match = vec_len (mask) / sizeof (u32x4);
9354 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9356 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9357 if (*tmp || *(tmp + 1))
9362 clib_warning ("BUG: match 0");
9364 _vec_len (mask) = match * sizeof (u32x4);
9374 #endif /* VPP_API_TEST_BUILTIN */
9376 #define foreach_l2_next \
9378 _(ethernet, ETHERNET_INPUT) \
9383 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9385 u32 *miss_next_indexp = va_arg (*args, u32 *);
9390 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9394 if (unformat (input, "%d", &tmp))
9403 *miss_next_indexp = next_index;
9407 #define foreach_ip_next \
9413 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9415 u32 *miss_next_indexp = va_arg (*args, u32 *);
9420 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9424 if (unformat (input, "%d", &tmp))
9433 *miss_next_indexp = next_index;
9437 #define foreach_acl_next \
9441 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9443 u32 *miss_next_indexp = va_arg (*args, u32 *);
9448 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9452 if (unformat (input, "permit"))
9457 else if (unformat (input, "%d", &tmp))
9466 *miss_next_indexp = next_index;
9471 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9473 u32 *r = va_arg (*args, u32 *);
9475 if (unformat (input, "conform-color"))
9476 *r = POLICE_CONFORM;
9477 else if (unformat (input, "exceed-color"))
9486 api_classify_add_del_table (vat_main_t * vam)
9488 unformat_input_t *i = vam->input;
9489 vl_api_classify_add_del_table_t *mp;
9496 u32 table_index = ~0;
9497 u32 next_table_index = ~0;
9498 u32 miss_next_index = ~0;
9499 u32 memory_size = 32 << 20;
9501 u32 current_data_flag = 0;
9502 int current_data_offset = 0;
9505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9507 if (unformat (i, "del"))
9509 else if (unformat (i, "del-chain"))
9514 else if (unformat (i, "buckets %d", &nbuckets))
9516 else if (unformat (i, "memory_size %d", &memory_size))
9518 else if (unformat (i, "skip %d", &skip))
9520 else if (unformat (i, "match %d", &match))
9522 else if (unformat (i, "table %d", &table_index))
9524 else if (unformat (i, "mask %U", unformat_classify_mask,
9525 &mask, &skip, &match))
9527 else if (unformat (i, "next-table %d", &next_table_index))
9529 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9532 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9535 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9538 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9540 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9546 if (is_add && mask == 0)
9548 errmsg ("Mask required");
9552 if (is_add && skip == ~0)
9554 errmsg ("skip count required");
9558 if (is_add && match == ~0)
9560 errmsg ("match count required");
9564 if (!is_add && table_index == ~0)
9566 errmsg ("table index required for delete");
9570 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9572 mp->is_add = is_add;
9573 mp->del_chain = del_chain;
9574 mp->table_index = ntohl (table_index);
9575 mp->nbuckets = ntohl (nbuckets);
9576 mp->memory_size = ntohl (memory_size);
9577 mp->skip_n_vectors = ntohl (skip);
9578 mp->match_n_vectors = ntohl (match);
9579 mp->next_table_index = ntohl (next_table_index);
9580 mp->miss_next_index = ntohl (miss_next_index);
9581 mp->current_data_flag = ntohl (current_data_flag);
9582 mp->current_data_offset = ntohl (current_data_offset);
9583 clib_memcpy (mp->mask, mask, vec_len (mask));
9592 #if VPP_API_TEST_BUILTIN == 0
9594 unformat_l4_match (unformat_input_t * input, va_list * args)
9596 u8 **matchp = va_arg (*args, u8 **);
9598 u8 *proto_header = 0;
9604 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9606 if (unformat (input, "src_port %d", &src_port))
9608 else if (unformat (input, "dst_port %d", &dst_port))
9614 h.src_port = clib_host_to_net_u16 (src_port);
9615 h.dst_port = clib_host_to_net_u16 (dst_port);
9616 vec_validate (proto_header, sizeof (h) - 1);
9617 memcpy (proto_header, &h, sizeof (h));
9619 *matchp = proto_header;
9625 unformat_ip4_match (unformat_input_t * input, va_list * args)
9627 u8 **matchp = va_arg (*args, u8 **);
9634 int src = 0, dst = 0;
9635 ip4_address_t src_val, dst_val;
9642 int fragment_id = 0;
9643 u32 fragment_id_val;
9649 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9651 if (unformat (input, "version %d", &version_val))
9653 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9655 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9657 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9659 else if (unformat (input, "proto %d", &proto_val))
9661 else if (unformat (input, "tos %d", &tos_val))
9663 else if (unformat (input, "length %d", &length_val))
9665 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9667 else if (unformat (input, "ttl %d", &ttl_val))
9669 else if (unformat (input, "checksum %d", &checksum_val))
9675 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9676 + ttl + checksum == 0)
9680 * Aligned because we use the real comparison functions
9682 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9684 ip = (ip4_header_t *) match;
9686 /* These are realistically matched in practice */
9688 ip->src_address.as_u32 = src_val.as_u32;
9691 ip->dst_address.as_u32 = dst_val.as_u32;
9694 ip->protocol = proto_val;
9697 /* These are not, but they're included for completeness */
9699 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9702 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9708 ip->length = clib_host_to_net_u16 (length_val);
9714 ip->checksum = clib_host_to_net_u16 (checksum_val);
9721 unformat_ip6_match (unformat_input_t * input, va_list * args)
9723 u8 **matchp = va_arg (*args, u8 **);
9728 u8 traffic_class = 0;
9729 u32 traffic_class_val = 0;
9732 int src = 0, dst = 0;
9733 ip6_address_t src_val, dst_val;
9736 int payload_length = 0;
9737 u32 payload_length_val;
9740 u32 ip_version_traffic_class_and_flow_label;
9742 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9744 if (unformat (input, "version %d", &version_val))
9746 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9748 else if (unformat (input, "flow_label %d", &flow_label_val))
9750 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9752 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9754 else if (unformat (input, "proto %d", &proto_val))
9756 else if (unformat (input, "payload_length %d", &payload_length_val))
9758 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9764 if (version + traffic_class + flow_label + src + dst + proto +
9765 payload_length + hop_limit == 0)
9769 * Aligned because we use the real comparison functions
9771 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9773 ip = (ip6_header_t *) match;
9776 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9779 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9782 ip->protocol = proto_val;
9784 ip_version_traffic_class_and_flow_label = 0;
9787 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9790 ip_version_traffic_class_and_flow_label |=
9791 (traffic_class_val & 0xFF) << 20;
9794 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9796 ip->ip_version_traffic_class_and_flow_label =
9797 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9800 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9803 ip->hop_limit = hop_limit_val;
9810 unformat_l3_match (unformat_input_t * input, va_list * args)
9812 u8 **matchp = va_arg (*args, u8 **);
9814 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9816 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9818 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9827 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9829 u8 *tagp = va_arg (*args, u8 *);
9832 if (unformat (input, "%d", &tag))
9834 tagp[0] = (tag >> 8) & 0x0F;
9835 tagp[1] = tag & 0xFF;
9843 unformat_l2_match (unformat_input_t * input, va_list * args)
9845 u8 **matchp = va_arg (*args, u8 **);
9865 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9867 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9870 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9872 else if (unformat (input, "proto %U",
9873 unformat_ethernet_type_host_byte_order, &proto_val))
9875 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9877 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9879 else if (unformat (input, "ignore-tag1"))
9881 else if (unformat (input, "ignore-tag2"))
9883 else if (unformat (input, "cos1 %d", &cos1_val))
9885 else if (unformat (input, "cos2 %d", &cos2_val))
9890 if ((src + dst + proto + tag1 + tag2 +
9891 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9894 if (tag1 || ignore_tag1 || cos1)
9896 if (tag2 || ignore_tag2 || cos2)
9899 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9902 clib_memcpy (match, dst_val, 6);
9905 clib_memcpy (match + 6, src_val, 6);
9909 /* inner vlan tag */
9910 match[19] = tag2_val[1];
9911 match[18] = tag2_val[0];
9913 match[18] |= (cos2_val & 0x7) << 5;
9916 match[21] = proto_val & 0xff;
9917 match[20] = proto_val >> 8;
9921 match[15] = tag1_val[1];
9922 match[14] = tag1_val[0];
9925 match[14] |= (cos1_val & 0x7) << 5;
9931 match[15] = tag1_val[1];
9932 match[14] = tag1_val[0];
9935 match[17] = proto_val & 0xff;
9936 match[16] = proto_val >> 8;
9939 match[14] |= (cos1_val & 0x7) << 5;
9945 match[18] |= (cos2_val & 0x7) << 5;
9947 match[14] |= (cos1_val & 0x7) << 5;
9950 match[13] = proto_val & 0xff;
9951 match[12] = proto_val >> 8;
9960 api_unformat_classify_match (unformat_input_t * input, va_list * args)
9962 u8 **matchp = va_arg (*args, u8 **);
9963 u32 skip_n_vectors = va_arg (*args, u32);
9964 u32 match_n_vectors = va_arg (*args, u32);
9971 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9973 if (unformat (input, "hex %U", unformat_hex_string, &match))
9975 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9977 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9979 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9993 if (match || l2 || l3 || l4)
9997 /* "Win a free Ethernet header in every packet" */
9999 vec_validate_aligned (l2, 13, sizeof (u32x4));
10003 vec_append_aligned (match, l3, sizeof (u32x4));
10008 vec_append_aligned (match, l4, sizeof (u32x4));
10013 /* Make sure the vector is big enough even if key is all 0's */
10014 vec_validate_aligned
10015 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10018 /* Set size, include skipped vectors */
10019 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10030 api_classify_add_del_session (vat_main_t * vam)
10032 unformat_input_t *i = vam->input;
10033 vl_api_classify_add_del_session_t *mp;
10035 u32 table_index = ~0;
10036 u32 hit_next_index = ~0;
10037 u32 opaque_index = ~0;
10040 u32 skip_n_vectors = 0;
10041 u32 match_n_vectors = 0;
10047 * Warning: you have to supply skip_n and match_n
10048 * because the API client cant simply look at the classify
10052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10054 if (unformat (i, "del"))
10056 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10059 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10062 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10065 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10067 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10069 else if (unformat (i, "opaque-index %d", &opaque_index))
10071 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10073 else if (unformat (i, "match_n %d", &match_n_vectors))
10075 else if (unformat (i, "match %U", api_unformat_classify_match,
10076 &match, skip_n_vectors, match_n_vectors))
10078 else if (unformat (i, "advance %d", &advance))
10080 else if (unformat (i, "table-index %d", &table_index))
10082 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10084 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10086 else if (unformat (i, "action %d", &action))
10088 else if (unformat (i, "metadata %d", &metadata))
10094 if (table_index == ~0)
10096 errmsg ("Table index required");
10100 if (is_add && match == 0)
10102 errmsg ("Match value required");
10106 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10108 mp->is_add = is_add;
10109 mp->table_index = ntohl (table_index);
10110 mp->hit_next_index = ntohl (hit_next_index);
10111 mp->opaque_index = ntohl (opaque_index);
10112 mp->advance = ntohl (advance);
10113 mp->action = action;
10114 mp->metadata = ntohl (metadata);
10115 clib_memcpy (mp->match, match, vec_len (match));
10124 api_classify_set_interface_ip_table (vat_main_t * vam)
10126 unformat_input_t *i = vam->input;
10127 vl_api_classify_set_interface_ip_table_t *mp;
10129 int sw_if_index_set;
10130 u32 table_index = ~0;
10134 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10136 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10137 sw_if_index_set = 1;
10138 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10139 sw_if_index_set = 1;
10140 else if (unformat (i, "table %d", &table_index))
10144 clib_warning ("parse error '%U'", format_unformat_error, i);
10149 if (sw_if_index_set == 0)
10151 errmsg ("missing interface name or sw_if_index");
10156 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10158 mp->sw_if_index = ntohl (sw_if_index);
10159 mp->table_index = ntohl (table_index);
10160 mp->is_ipv6 = is_ipv6;
10168 api_classify_set_interface_l2_tables (vat_main_t * vam)
10170 unformat_input_t *i = vam->input;
10171 vl_api_classify_set_interface_l2_tables_t *mp;
10173 int sw_if_index_set;
10174 u32 ip4_table_index = ~0;
10175 u32 ip6_table_index = ~0;
10176 u32 other_table_index = ~0;
10180 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10182 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10183 sw_if_index_set = 1;
10184 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10185 sw_if_index_set = 1;
10186 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10188 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10190 else if (unformat (i, "other-table %d", &other_table_index))
10192 else if (unformat (i, "is-input %d", &is_input))
10196 clib_warning ("parse error '%U'", format_unformat_error, i);
10201 if (sw_if_index_set == 0)
10203 errmsg ("missing interface name or sw_if_index");
10208 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10210 mp->sw_if_index = ntohl (sw_if_index);
10211 mp->ip4_table_index = ntohl (ip4_table_index);
10212 mp->ip6_table_index = ntohl (ip6_table_index);
10213 mp->other_table_index = ntohl (other_table_index);
10214 mp->is_input = (u8) is_input;
10222 api_set_ipfix_exporter (vat_main_t * vam)
10224 unformat_input_t *i = vam->input;
10225 vl_api_set_ipfix_exporter_t *mp;
10226 ip4_address_t collector_address;
10227 u8 collector_address_set = 0;
10228 u32 collector_port = ~0;
10229 ip4_address_t src_address;
10230 u8 src_address_set = 0;
10233 u32 template_interval = ~0;
10234 u8 udp_checksum = 0;
10237 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10239 if (unformat (i, "collector_address %U", unformat_ip4_address,
10240 &collector_address))
10241 collector_address_set = 1;
10242 else if (unformat (i, "collector_port %d", &collector_port))
10244 else if (unformat (i, "src_address %U", unformat_ip4_address,
10246 src_address_set = 1;
10247 else if (unformat (i, "vrf_id %d", &vrf_id))
10249 else if (unformat (i, "path_mtu %d", &path_mtu))
10251 else if (unformat (i, "template_interval %d", &template_interval))
10253 else if (unformat (i, "udp_checksum"))
10259 if (collector_address_set == 0)
10261 errmsg ("collector_address required");
10265 if (src_address_set == 0)
10267 errmsg ("src_address required");
10271 M (SET_IPFIX_EXPORTER, mp);
10273 memcpy (mp->collector_address, collector_address.data,
10274 sizeof (collector_address.data));
10275 mp->collector_port = htons ((u16) collector_port);
10276 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10277 mp->vrf_id = htonl (vrf_id);
10278 mp->path_mtu = htonl (path_mtu);
10279 mp->template_interval = htonl (template_interval);
10280 mp->udp_checksum = udp_checksum;
10288 api_set_ipfix_classify_stream (vat_main_t * vam)
10290 unformat_input_t *i = vam->input;
10291 vl_api_set_ipfix_classify_stream_t *mp;
10293 u32 src_port = UDP_DST_PORT_ipfix;
10296 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10298 if (unformat (i, "domain %d", &domain_id))
10300 else if (unformat (i, "src_port %d", &src_port))
10304 errmsg ("unknown input `%U'", format_unformat_error, i);
10309 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10311 mp->domain_id = htonl (domain_id);
10312 mp->src_port = htons ((u16) src_port);
10320 api_ipfix_classify_table_add_del (vat_main_t * vam)
10322 unformat_input_t *i = vam->input;
10323 vl_api_ipfix_classify_table_add_del_t *mp;
10325 u32 classify_table_index = ~0;
10327 u8 transport_protocol = 255;
10330 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10332 if (unformat (i, "add"))
10334 else if (unformat (i, "del"))
10336 else if (unformat (i, "table %d", &classify_table_index))
10338 else if (unformat (i, "ip4"))
10340 else if (unformat (i, "ip6"))
10342 else if (unformat (i, "tcp"))
10343 transport_protocol = 6;
10344 else if (unformat (i, "udp"))
10345 transport_protocol = 17;
10348 errmsg ("unknown input `%U'", format_unformat_error, i);
10355 errmsg ("expecting: add|del");
10358 if (classify_table_index == ~0)
10360 errmsg ("classifier table not specified");
10363 if (ip_version == 0)
10365 errmsg ("IP version not specified");
10369 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10371 mp->is_add = is_add;
10372 mp->table_id = htonl (classify_table_index);
10373 mp->ip_version = ip_version;
10374 mp->transport_protocol = transport_protocol;
10382 api_get_node_index (vat_main_t * vam)
10384 unformat_input_t *i = vam->input;
10385 vl_api_get_node_index_t *mp;
10389 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10391 if (unformat (i, "node %s", &name))
10398 errmsg ("node name required");
10401 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10403 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10407 M (GET_NODE_INDEX, mp);
10408 clib_memcpy (mp->node_name, name, vec_len (name));
10417 api_get_next_index (vat_main_t * vam)
10419 unformat_input_t *i = vam->input;
10420 vl_api_get_next_index_t *mp;
10421 u8 *node_name = 0, *next_node_name = 0;
10424 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10426 if (unformat (i, "node-name %s", &node_name))
10428 else if (unformat (i, "next-node-name %s", &next_node_name))
10432 if (node_name == 0)
10434 errmsg ("node name required");
10437 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10439 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10443 if (next_node_name == 0)
10445 errmsg ("next node name required");
10448 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10450 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10454 M (GET_NEXT_INDEX, mp);
10455 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10456 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10457 vec_free (node_name);
10458 vec_free (next_node_name);
10466 api_add_node_next (vat_main_t * vam)
10468 unformat_input_t *i = vam->input;
10469 vl_api_add_node_next_t *mp;
10474 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10476 if (unformat (i, "node %s", &name))
10478 else if (unformat (i, "next %s", &next))
10485 errmsg ("node name required");
10488 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10490 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10495 errmsg ("next node required");
10498 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10500 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10504 M (ADD_NODE_NEXT, mp);
10505 clib_memcpy (mp->node_name, name, vec_len (name));
10506 clib_memcpy (mp->next_name, next, vec_len (next));
10516 api_l2tpv3_create_tunnel (vat_main_t * vam)
10518 unformat_input_t *i = vam->input;
10519 ip6_address_t client_address, our_address;
10520 int client_address_set = 0;
10521 int our_address_set = 0;
10522 u32 local_session_id = 0;
10523 u32 remote_session_id = 0;
10524 u64 local_cookie = 0;
10525 u64 remote_cookie = 0;
10526 u8 l2_sublayer_present = 0;
10527 vl_api_l2tpv3_create_tunnel_t *mp;
10530 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10532 if (unformat (i, "client_address %U", unformat_ip6_address,
10534 client_address_set = 1;
10535 else if (unformat (i, "our_address %U", unformat_ip6_address,
10537 our_address_set = 1;
10538 else if (unformat (i, "local_session_id %d", &local_session_id))
10540 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10542 else if (unformat (i, "local_cookie %lld", &local_cookie))
10544 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10546 else if (unformat (i, "l2-sublayer-present"))
10547 l2_sublayer_present = 1;
10552 if (client_address_set == 0)
10554 errmsg ("client_address required");
10558 if (our_address_set == 0)
10560 errmsg ("our_address required");
10564 M (L2TPV3_CREATE_TUNNEL, mp);
10566 clib_memcpy (mp->client_address, client_address.as_u8,
10567 sizeof (mp->client_address));
10569 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10571 mp->local_session_id = ntohl (local_session_id);
10572 mp->remote_session_id = ntohl (remote_session_id);
10573 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10574 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10575 mp->l2_sublayer_present = l2_sublayer_present;
10584 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10586 unformat_input_t *i = vam->input;
10588 u8 sw_if_index_set = 0;
10589 u64 new_local_cookie = 0;
10590 u64 new_remote_cookie = 0;
10591 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10594 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10596 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10597 sw_if_index_set = 1;
10598 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10599 sw_if_index_set = 1;
10600 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10602 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10608 if (sw_if_index_set == 0)
10610 errmsg ("missing interface name or sw_if_index");
10614 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10616 mp->sw_if_index = ntohl (sw_if_index);
10617 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10618 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10626 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10628 unformat_input_t *i = vam->input;
10629 vl_api_l2tpv3_interface_enable_disable_t *mp;
10631 u8 sw_if_index_set = 0;
10632 u8 enable_disable = 1;
10635 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10637 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10638 sw_if_index_set = 1;
10639 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10640 sw_if_index_set = 1;
10641 else if (unformat (i, "enable"))
10642 enable_disable = 1;
10643 else if (unformat (i, "disable"))
10644 enable_disable = 0;
10649 if (sw_if_index_set == 0)
10651 errmsg ("missing interface name or sw_if_index");
10655 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10657 mp->sw_if_index = ntohl (sw_if_index);
10658 mp->enable_disable = enable_disable;
10666 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10668 unformat_input_t *i = vam->input;
10669 vl_api_l2tpv3_set_lookup_key_t *mp;
10673 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10675 if (unformat (i, "lookup_v6_src"))
10676 key = L2T_LOOKUP_SRC_ADDRESS;
10677 else if (unformat (i, "lookup_v6_dst"))
10678 key = L2T_LOOKUP_DST_ADDRESS;
10679 else if (unformat (i, "lookup_session_id"))
10680 key = L2T_LOOKUP_SESSION_ID;
10685 if (key == (u8) ~ 0)
10687 errmsg ("l2tp session lookup key unset");
10691 M (L2TPV3_SET_LOOKUP_KEY, mp);
10700 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10701 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10703 vat_main_t *vam = &vat_main;
10705 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10706 format_ip6_address, mp->our_address,
10707 format_ip6_address, mp->client_address,
10708 clib_net_to_host_u32 (mp->sw_if_index));
10711 " local cookies %016llx %016llx remote cookie %016llx",
10712 clib_net_to_host_u64 (mp->local_cookie[0]),
10713 clib_net_to_host_u64 (mp->local_cookie[1]),
10714 clib_net_to_host_u64 (mp->remote_cookie));
10716 print (vam->ofp, " local session-id %d remote session-id %d",
10717 clib_net_to_host_u32 (mp->local_session_id),
10718 clib_net_to_host_u32 (mp->remote_session_id));
10720 print (vam->ofp, " l2 specific sublayer %s\n",
10721 mp->l2_sublayer_present ? "preset" : "absent");
10725 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10726 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10728 vat_main_t *vam = &vat_main;
10729 vat_json_node_t *node = NULL;
10730 struct in6_addr addr;
10732 if (VAT_JSON_ARRAY != vam->json_tree.type)
10734 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10735 vat_json_init_array (&vam->json_tree);
10737 node = vat_json_array_add (&vam->json_tree);
10739 vat_json_init_object (node);
10741 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10742 vat_json_object_add_ip6 (node, "our_address", addr);
10743 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10744 vat_json_object_add_ip6 (node, "client_address", addr);
10746 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10747 vat_json_init_array (lc);
10748 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10749 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10750 vat_json_object_add_uint (node, "remote_cookie",
10751 clib_net_to_host_u64 (mp->remote_cookie));
10753 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10754 vat_json_object_add_uint (node, "local_session_id",
10755 clib_net_to_host_u32 (mp->local_session_id));
10756 vat_json_object_add_uint (node, "remote_session_id",
10757 clib_net_to_host_u32 (mp->remote_session_id));
10758 vat_json_object_add_string_copy (node, "l2_sublayer",
10759 mp->l2_sublayer_present ? (u8 *) "present"
10760 : (u8 *) "absent");
10764 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10766 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10767 vl_api_control_ping_t *mp_ping;
10770 /* Get list of l2tpv3-tunnel interfaces */
10771 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10774 /* Use a control ping for synchronization */
10775 M (CONTROL_PING, mp_ping);
10783 static void vl_api_sw_interface_tap_details_t_handler
10784 (vl_api_sw_interface_tap_details_t * mp)
10786 vat_main_t *vam = &vat_main;
10788 print (vam->ofp, "%-16s %d",
10789 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10792 static void vl_api_sw_interface_tap_details_t_handler_json
10793 (vl_api_sw_interface_tap_details_t * mp)
10795 vat_main_t *vam = &vat_main;
10796 vat_json_node_t *node = NULL;
10798 if (VAT_JSON_ARRAY != vam->json_tree.type)
10800 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10801 vat_json_init_array (&vam->json_tree);
10803 node = vat_json_array_add (&vam->json_tree);
10805 vat_json_init_object (node);
10806 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10807 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10811 api_sw_interface_tap_dump (vat_main_t * vam)
10813 vl_api_sw_interface_tap_dump_t *mp;
10814 vl_api_control_ping_t *mp_ping;
10817 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10818 /* Get list of tap interfaces */
10819 M (SW_INTERFACE_TAP_DUMP, mp);
10822 /* Use a control ping for synchronization */
10823 M (CONTROL_PING, mp_ping);
10830 static uword unformat_vxlan_decap_next
10831 (unformat_input_t * input, va_list * args)
10833 u32 *result = va_arg (*args, u32 *);
10836 if (unformat (input, "l2"))
10837 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10838 else if (unformat (input, "%d", &tmp))
10846 api_vxlan_add_del_tunnel (vat_main_t * vam)
10848 unformat_input_t *line_input = vam->input;
10849 vl_api_vxlan_add_del_tunnel_t *mp;
10850 ip46_address_t src, dst;
10852 u8 ipv4_set = 0, ipv6_set = 0;
10856 u32 mcast_sw_if_index = ~0;
10857 u32 encap_vrf_id = 0;
10858 u32 decap_next_index = ~0;
10862 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10863 memset (&src, 0, sizeof src);
10864 memset (&dst, 0, sizeof dst);
10866 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10868 if (unformat (line_input, "del"))
10871 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10877 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10883 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10889 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10894 else if (unformat (line_input, "group %U %U",
10895 unformat_ip4_address, &dst.ip4,
10896 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10898 grp_set = dst_set = 1;
10901 else if (unformat (line_input, "group %U",
10902 unformat_ip4_address, &dst.ip4))
10904 grp_set = dst_set = 1;
10907 else if (unformat (line_input, "group %U %U",
10908 unformat_ip6_address, &dst.ip6,
10909 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10911 grp_set = dst_set = 1;
10914 else if (unformat (line_input, "group %U",
10915 unformat_ip6_address, &dst.ip6))
10917 grp_set = dst_set = 1;
10921 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10923 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10925 else if (unformat (line_input, "decap-next %U",
10926 unformat_vxlan_decap_next, &decap_next_index))
10928 else if (unformat (line_input, "vni %d", &vni))
10932 errmsg ("parse error '%U'", format_unformat_error, line_input);
10939 errmsg ("tunnel src address not specified");
10944 errmsg ("tunnel dst address not specified");
10948 if (grp_set && !ip46_address_is_multicast (&dst))
10950 errmsg ("tunnel group address not multicast");
10953 if (grp_set && mcast_sw_if_index == ~0)
10955 errmsg ("tunnel nonexistent multicast device");
10958 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10960 errmsg ("tunnel dst address must be unicast");
10965 if (ipv4_set && ipv6_set)
10967 errmsg ("both IPv4 and IPv6 addresses specified");
10971 if ((vni == 0) || (vni >> 24))
10973 errmsg ("vni not specified or out of range");
10977 M (VXLAN_ADD_DEL_TUNNEL, mp);
10981 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10982 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10986 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10987 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10989 mp->encap_vrf_id = ntohl (encap_vrf_id);
10990 mp->decap_next_index = ntohl (decap_next_index);
10991 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10992 mp->vni = ntohl (vni);
10993 mp->is_add = is_add;
10994 mp->is_ipv6 = ipv6_set;
11001 static void vl_api_vxlan_tunnel_details_t_handler
11002 (vl_api_vxlan_tunnel_details_t * mp)
11004 vat_main_t *vam = &vat_main;
11005 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
11006 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
11008 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
11009 ntohl (mp->sw_if_index),
11010 format_ip46_address, &src, IP46_TYPE_ANY,
11011 format_ip46_address, &dst, IP46_TYPE_ANY,
11012 ntohl (mp->encap_vrf_id),
11013 ntohl (mp->decap_next_index), ntohl (mp->vni),
11014 ntohl (mp->mcast_sw_if_index));
11017 static void vl_api_vxlan_tunnel_details_t_handler_json
11018 (vl_api_vxlan_tunnel_details_t * mp)
11020 vat_main_t *vam = &vat_main;
11021 vat_json_node_t *node = NULL;
11023 if (VAT_JSON_ARRAY != vam->json_tree.type)
11025 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11026 vat_json_init_array (&vam->json_tree);
11028 node = vat_json_array_add (&vam->json_tree);
11030 vat_json_init_object (node);
11031 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11034 struct in6_addr ip6;
11036 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
11037 vat_json_object_add_ip6 (node, "src_address", ip6);
11038 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
11039 vat_json_object_add_ip6 (node, "dst_address", ip6);
11043 struct in_addr ip4;
11045 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
11046 vat_json_object_add_ip4 (node, "src_address", ip4);
11047 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
11048 vat_json_object_add_ip4 (node, "dst_address", ip4);
11050 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11051 vat_json_object_add_uint (node, "decap_next_index",
11052 ntohl (mp->decap_next_index));
11053 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11054 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11055 vat_json_object_add_uint (node, "mcast_sw_if_index",
11056 ntohl (mp->mcast_sw_if_index));
11060 api_vxlan_tunnel_dump (vat_main_t * vam)
11062 unformat_input_t *i = vam->input;
11063 vl_api_vxlan_tunnel_dump_t *mp;
11064 vl_api_control_ping_t *mp_ping;
11066 u8 sw_if_index_set = 0;
11069 /* Parse args required to build the message */
11070 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11072 if (unformat (i, "sw_if_index %d", &sw_if_index))
11073 sw_if_index_set = 1;
11078 if (sw_if_index_set == 0)
11083 if (!vam->json_output)
11085 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
11086 "sw_if_index", "src_address", "dst_address",
11087 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11090 /* Get list of vxlan-tunnel interfaces */
11091 M (VXLAN_TUNNEL_DUMP, mp);
11093 mp->sw_if_index = htonl (sw_if_index);
11097 /* Use a control ping for synchronization */
11098 M (CONTROL_PING, mp_ping);
11106 api_gre_add_del_tunnel (vat_main_t * vam)
11108 unformat_input_t *line_input = vam->input;
11109 vl_api_gre_add_del_tunnel_t *mp;
11110 ip4_address_t src4, dst4;
11111 ip6_address_t src6, dst6;
11118 u32 outer_fib_id = 0;
11121 memset (&src4, 0, sizeof src4);
11122 memset (&dst4, 0, sizeof dst4);
11123 memset (&src6, 0, sizeof src6);
11124 memset (&dst6, 0, sizeof dst6);
11126 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11128 if (unformat (line_input, "del"))
11130 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
11135 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
11140 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
11145 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
11150 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
11152 else if (unformat (line_input, "teb"))
11156 errmsg ("parse error '%U'", format_unformat_error, line_input);
11163 errmsg ("tunnel src address not specified");
11168 errmsg ("tunnel dst address not specified");
11171 if (ipv4_set && ipv6_set)
11173 errmsg ("both IPv4 and IPv6 addresses specified");
11178 M (GRE_ADD_DEL_TUNNEL, mp);
11182 clib_memcpy (&mp->src_address, &src4, 4);
11183 clib_memcpy (&mp->dst_address, &dst4, 4);
11187 clib_memcpy (&mp->src_address, &src6, 16);
11188 clib_memcpy (&mp->dst_address, &dst6, 16);
11190 mp->outer_fib_id = ntohl (outer_fib_id);
11191 mp->is_add = is_add;
11193 mp->is_ipv6 = ipv6_set;
11200 static void vl_api_gre_tunnel_details_t_handler
11201 (vl_api_gre_tunnel_details_t * mp)
11203 vat_main_t *vam = &vat_main;
11204 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
11205 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
11207 print (vam->ofp, "%11d%24U%24U%6d%14d",
11208 ntohl (mp->sw_if_index),
11209 format_ip46_address, &src, IP46_TYPE_ANY,
11210 format_ip46_address, &dst, IP46_TYPE_ANY,
11211 mp->teb, ntohl (mp->outer_fib_id));
11214 static void vl_api_gre_tunnel_details_t_handler_json
11215 (vl_api_gre_tunnel_details_t * mp)
11217 vat_main_t *vam = &vat_main;
11218 vat_json_node_t *node = NULL;
11219 struct in_addr ip4;
11220 struct in6_addr ip6;
11222 if (VAT_JSON_ARRAY != vam->json_tree.type)
11224 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11225 vat_json_init_array (&vam->json_tree);
11227 node = vat_json_array_add (&vam->json_tree);
11229 vat_json_init_object (node);
11230 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11233 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11234 vat_json_object_add_ip4 (node, "src_address", ip4);
11235 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11236 vat_json_object_add_ip4 (node, "dst_address", ip4);
11240 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
11241 vat_json_object_add_ip6 (node, "src_address", ip6);
11242 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
11243 vat_json_object_add_ip6 (node, "dst_address", ip6);
11245 vat_json_object_add_uint (node, "teb", mp->teb);
11246 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11247 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
11251 api_gre_tunnel_dump (vat_main_t * vam)
11253 unformat_input_t *i = vam->input;
11254 vl_api_gre_tunnel_dump_t *mp;
11255 vl_api_control_ping_t *mp_ping;
11257 u8 sw_if_index_set = 0;
11260 /* Parse args required to build the message */
11261 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11263 if (unformat (i, "sw_if_index %d", &sw_if_index))
11264 sw_if_index_set = 1;
11269 if (sw_if_index_set == 0)
11274 if (!vam->json_output)
11276 print (vam->ofp, "%11s%24s%24s%6s%14s",
11277 "sw_if_index", "src_address", "dst_address", "teb",
11281 /* Get list of gre-tunnel interfaces */
11282 M (GRE_TUNNEL_DUMP, mp);
11284 mp->sw_if_index = htonl (sw_if_index);
11288 /* Use a control ping for synchronization */
11289 M (CONTROL_PING, mp_ping);
11297 api_l2_fib_clear_table (vat_main_t * vam)
11299 // unformat_input_t * i = vam->input;
11300 vl_api_l2_fib_clear_table_t *mp;
11303 M (L2_FIB_CLEAR_TABLE, mp);
11311 api_l2_interface_efp_filter (vat_main_t * vam)
11313 unformat_input_t *i = vam->input;
11314 vl_api_l2_interface_efp_filter_t *mp;
11317 u8 sw_if_index_set = 0;
11320 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11322 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11323 sw_if_index_set = 1;
11324 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11325 sw_if_index_set = 1;
11326 else if (unformat (i, "enable"))
11328 else if (unformat (i, "disable"))
11332 clib_warning ("parse error '%U'", format_unformat_error, i);
11337 if (sw_if_index_set == 0)
11339 errmsg ("missing sw_if_index");
11343 M (L2_INTERFACE_EFP_FILTER, mp);
11345 mp->sw_if_index = ntohl (sw_if_index);
11346 mp->enable_disable = enable;
11353 #define foreach_vtr_op \
11354 _("disable", L2_VTR_DISABLED) \
11355 _("push-1", L2_VTR_PUSH_1) \
11356 _("push-2", L2_VTR_PUSH_2) \
11357 _("pop-1", L2_VTR_POP_1) \
11358 _("pop-2", L2_VTR_POP_2) \
11359 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11360 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11361 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11362 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11365 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11367 unformat_input_t *i = vam->input;
11368 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11370 u8 sw_if_index_set = 0;
11373 u32 push_dot1q = 1;
11378 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11380 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11381 sw_if_index_set = 1;
11382 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11383 sw_if_index_set = 1;
11384 else if (unformat (i, "vtr_op %d", &vtr_op))
11386 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11389 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11391 else if (unformat (i, "tag1 %d", &tag1))
11393 else if (unformat (i, "tag2 %d", &tag2))
11397 clib_warning ("parse error '%U'", format_unformat_error, i);
11402 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11404 errmsg ("missing vtr operation or sw_if_index");
11408 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11409 mp->sw_if_index = ntohl (sw_if_index);
11410 mp->vtr_op = ntohl (vtr_op);
11411 mp->push_dot1q = ntohl (push_dot1q);
11412 mp->tag1 = ntohl (tag1);
11413 mp->tag2 = ntohl (tag2);
11421 api_create_vhost_user_if (vat_main_t * vam)
11423 unformat_input_t *i = vam->input;
11424 vl_api_create_vhost_user_if_t *mp;
11427 u8 file_name_set = 0;
11428 u32 custom_dev_instance = ~0;
11430 u8 use_custom_mac = 0;
11433 u8 operation_mode = VHOST_USER_POLLING_MODE;
11435 /* Shut up coverity */
11436 memset (hwaddr, 0, sizeof (hwaddr));
11438 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11440 if (unformat (i, "socket %s", &file_name))
11444 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11446 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11447 use_custom_mac = 1;
11448 else if (unformat (i, "server"))
11450 else if (unformat (i, "tag %s", &tag))
11452 else if (unformat (i, "mode %U",
11453 api_unformat_vhost_user_operation_mode,
11460 if (file_name_set == 0)
11462 errmsg ("missing socket file name");
11466 if (vec_len (file_name) > 255)
11468 errmsg ("socket file name too long");
11471 vec_add1 (file_name, 0);
11473 M (CREATE_VHOST_USER_IF, mp);
11475 mp->operation_mode = operation_mode;
11476 mp->is_server = is_server;
11477 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11478 vec_free (file_name);
11479 if (custom_dev_instance != ~0)
11482 mp->custom_dev_instance = ntohl (custom_dev_instance);
11484 mp->use_custom_mac = use_custom_mac;
11485 clib_memcpy (mp->mac_address, hwaddr, 6);
11487 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11496 api_modify_vhost_user_if (vat_main_t * vam)
11498 unformat_input_t *i = vam->input;
11499 vl_api_modify_vhost_user_if_t *mp;
11502 u8 file_name_set = 0;
11503 u32 custom_dev_instance = ~0;
11504 u8 sw_if_index_set = 0;
11505 u32 sw_if_index = (u32) ~ 0;
11507 u8 operation_mode = VHOST_USER_POLLING_MODE;
11509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11511 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11512 sw_if_index_set = 1;
11513 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11514 sw_if_index_set = 1;
11515 else if (unformat (i, "socket %s", &file_name))
11519 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11521 else if (unformat (i, "server"))
11523 else if (unformat (i, "mode %U",
11524 api_unformat_vhost_user_operation_mode,
11531 if (sw_if_index_set == 0)
11533 errmsg ("missing sw_if_index or interface name");
11537 if (file_name_set == 0)
11539 errmsg ("missing socket file name");
11543 if (vec_len (file_name) > 255)
11545 errmsg ("socket file name too long");
11548 vec_add1 (file_name, 0);
11550 M (MODIFY_VHOST_USER_IF, mp);
11552 mp->operation_mode = operation_mode;
11553 mp->sw_if_index = ntohl (sw_if_index);
11554 mp->is_server = is_server;
11555 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11556 vec_free (file_name);
11557 if (custom_dev_instance != ~0)
11560 mp->custom_dev_instance = ntohl (custom_dev_instance);
11569 api_delete_vhost_user_if (vat_main_t * vam)
11571 unformat_input_t *i = vam->input;
11572 vl_api_delete_vhost_user_if_t *mp;
11573 u32 sw_if_index = ~0;
11574 u8 sw_if_index_set = 0;
11577 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11579 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11580 sw_if_index_set = 1;
11581 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11582 sw_if_index_set = 1;
11587 if (sw_if_index_set == 0)
11589 errmsg ("missing sw_if_index or interface name");
11594 M (DELETE_VHOST_USER_IF, mp);
11596 mp->sw_if_index = ntohl (sw_if_index);
11603 static void vl_api_sw_interface_vhost_user_details_t_handler
11604 (vl_api_sw_interface_vhost_user_details_t * mp)
11606 vat_main_t *vam = &vat_main;
11608 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %U %s",
11609 (char *) mp->interface_name,
11610 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11611 clib_net_to_host_u64 (mp->features), mp->is_server,
11612 ntohl (mp->num_regions), api_format_vhost_user_operation_mode,
11613 mp->operation_mode, (char *) mp->sock_filename);
11614 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11617 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11618 (vl_api_sw_interface_vhost_user_details_t * mp)
11620 vat_main_t *vam = &vat_main;
11621 vat_json_node_t *node = NULL;
11623 if (VAT_JSON_ARRAY != vam->json_tree.type)
11625 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11626 vat_json_init_array (&vam->json_tree);
11628 node = vat_json_array_add (&vam->json_tree);
11630 vat_json_init_object (node);
11631 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11632 vat_json_object_add_string_copy (node, "interface_name",
11633 mp->interface_name);
11634 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11635 ntohl (mp->virtio_net_hdr_sz));
11636 vat_json_object_add_uint (node, "features",
11637 clib_net_to_host_u64 (mp->features));
11638 vat_json_object_add_uint (node, "is_server", mp->is_server);
11639 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11640 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11641 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11642 vat_json_object_add_uint (node, "mode", mp->operation_mode);
11646 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11648 vl_api_sw_interface_vhost_user_dump_t *mp;
11649 vl_api_control_ping_t *mp_ping;
11652 "Interface name idx hdr_sz features server regions mode"
11655 /* Get list of vhost-user interfaces */
11656 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11659 /* Use a control ping for synchronization */
11660 M (CONTROL_PING, mp_ping);
11668 api_show_version (vat_main_t * vam)
11670 vl_api_show_version_t *mp;
11673 M (SHOW_VERSION, mp);
11682 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11684 unformat_input_t *line_input = vam->input;
11685 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11686 ip4_address_t local4, remote4;
11687 ip6_address_t local6, remote6;
11689 u8 ipv4_set = 0, ipv6_set = 0;
11692 u32 encap_vrf_id = 0;
11693 u32 decap_vrf_id = 0;
11699 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11701 if (unformat (line_input, "del"))
11703 else if (unformat (line_input, "local %U",
11704 unformat_ip4_address, &local4))
11709 else if (unformat (line_input, "remote %U",
11710 unformat_ip4_address, &remote4))
11715 else if (unformat (line_input, "local %U",
11716 unformat_ip6_address, &local6))
11721 else if (unformat (line_input, "remote %U",
11722 unformat_ip6_address, &remote6))
11727 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11729 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11731 else if (unformat (line_input, "vni %d", &vni))
11733 else if (unformat (line_input, "next-ip4"))
11735 else if (unformat (line_input, "next-ip6"))
11737 else if (unformat (line_input, "next-ethernet"))
11739 else if (unformat (line_input, "next-nsh"))
11743 errmsg ("parse error '%U'", format_unformat_error, line_input);
11748 if (local_set == 0)
11750 errmsg ("tunnel local address not specified");
11753 if (remote_set == 0)
11755 errmsg ("tunnel remote address not specified");
11758 if (ipv4_set && ipv6_set)
11760 errmsg ("both IPv4 and IPv6 addresses specified");
11766 errmsg ("vni not specified");
11770 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11775 clib_memcpy (&mp->local, &local6, sizeof (local6));
11776 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11780 clib_memcpy (&mp->local, &local4, sizeof (local4));
11781 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11784 mp->encap_vrf_id = ntohl (encap_vrf_id);
11785 mp->decap_vrf_id = ntohl (decap_vrf_id);
11786 mp->protocol = protocol;
11787 mp->vni = ntohl (vni);
11788 mp->is_add = is_add;
11789 mp->is_ipv6 = ipv6_set;
11796 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11797 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11799 vat_main_t *vam = &vat_main;
11801 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11802 ntohl (mp->sw_if_index),
11803 format_ip46_address, &(mp->local[0]),
11804 format_ip46_address, &(mp->remote[0]),
11806 ntohl (mp->protocol),
11807 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11810 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11811 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11813 vat_main_t *vam = &vat_main;
11814 vat_json_node_t *node = NULL;
11815 struct in_addr ip4;
11816 struct in6_addr ip6;
11818 if (VAT_JSON_ARRAY != vam->json_tree.type)
11820 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11821 vat_json_init_array (&vam->json_tree);
11823 node = vat_json_array_add (&vam->json_tree);
11825 vat_json_init_object (node);
11826 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11829 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11830 vat_json_object_add_ip6 (node, "local", ip6);
11831 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11832 vat_json_object_add_ip6 (node, "remote", ip6);
11836 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11837 vat_json_object_add_ip4 (node, "local", ip4);
11838 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11839 vat_json_object_add_ip4 (node, "remote", ip4);
11841 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11842 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11843 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11844 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11845 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11849 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11851 unformat_input_t *i = vam->input;
11852 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11853 vl_api_control_ping_t *mp_ping;
11855 u8 sw_if_index_set = 0;
11858 /* Parse args required to build the message */
11859 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11861 if (unformat (i, "sw_if_index %d", &sw_if_index))
11862 sw_if_index_set = 1;
11867 if (sw_if_index_set == 0)
11872 if (!vam->json_output)
11874 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11875 "sw_if_index", "local", "remote", "vni",
11876 "protocol", "encap_vrf_id", "decap_vrf_id");
11879 /* Get list of vxlan-tunnel interfaces */
11880 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11882 mp->sw_if_index = htonl (sw_if_index);
11886 /* Use a control ping for synchronization */
11887 M (CONTROL_PING, mp_ping);
11895 format_l2_fib_mac_address (u8 * s, va_list * args)
11897 u8 *a = va_arg (*args, u8 *);
11899 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11900 a[2], a[3], a[4], a[5], a[6], a[7]);
11903 static void vl_api_l2_fib_table_details_t_handler
11904 (vl_api_l2_fib_table_details_t * mp)
11906 vat_main_t *vam = &vat_main;
11908 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11910 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11911 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11915 static void vl_api_l2_fib_table_details_t_handler_json
11916 (vl_api_l2_fib_table_details_t * mp)
11918 vat_main_t *vam = &vat_main;
11919 vat_json_node_t *node = NULL;
11921 if (VAT_JSON_ARRAY != vam->json_tree.type)
11923 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11924 vat_json_init_array (&vam->json_tree);
11926 node = vat_json_array_add (&vam->json_tree);
11928 vat_json_init_object (node);
11929 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11930 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11931 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11932 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11933 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11934 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11938 api_l2_fib_table_dump (vat_main_t * vam)
11940 unformat_input_t *i = vam->input;
11941 vl_api_l2_fib_table_dump_t *mp;
11942 vl_api_control_ping_t *mp_ping;
11947 /* Parse args required to build the message */
11948 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11950 if (unformat (i, "bd_id %d", &bd_id))
11956 if (bd_id_set == 0)
11958 errmsg ("missing bridge domain");
11962 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11964 /* Get list of l2 fib entries */
11965 M (L2_FIB_TABLE_DUMP, mp);
11967 mp->bd_id = ntohl (bd_id);
11970 /* Use a control ping for synchronization */
11971 M (CONTROL_PING, mp_ping);
11980 api_interface_name_renumber (vat_main_t * vam)
11982 unformat_input_t *line_input = vam->input;
11983 vl_api_interface_name_renumber_t *mp;
11984 u32 sw_if_index = ~0;
11985 u32 new_show_dev_instance = ~0;
11988 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11990 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11993 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11995 else if (unformat (line_input, "new_show_dev_instance %d",
11996 &new_show_dev_instance))
12002 if (sw_if_index == ~0)
12004 errmsg ("missing interface name or sw_if_index");
12008 if (new_show_dev_instance == ~0)
12010 errmsg ("missing new_show_dev_instance");
12014 M (INTERFACE_NAME_RENUMBER, mp);
12016 mp->sw_if_index = ntohl (sw_if_index);
12017 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
12025 api_want_ip4_arp_events (vat_main_t * vam)
12027 unformat_input_t *line_input = vam->input;
12028 vl_api_want_ip4_arp_events_t *mp;
12029 ip4_address_t address;
12030 int address_set = 0;
12031 u32 enable_disable = 1;
12034 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12036 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
12038 else if (unformat (line_input, "del"))
12039 enable_disable = 0;
12044 if (address_set == 0)
12046 errmsg ("missing addresses");
12050 M (WANT_IP4_ARP_EVENTS, mp);
12051 mp->enable_disable = enable_disable;
12052 mp->pid = htonl (getpid ());
12053 mp->address = address.as_u32;
12061 api_want_ip6_nd_events (vat_main_t * vam)
12063 unformat_input_t *line_input = vam->input;
12064 vl_api_want_ip6_nd_events_t *mp;
12065 ip6_address_t address;
12066 int address_set = 0;
12067 u32 enable_disable = 1;
12070 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12072 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
12074 else if (unformat (line_input, "del"))
12075 enable_disable = 0;
12080 if (address_set == 0)
12082 errmsg ("missing addresses");
12086 M (WANT_IP6_ND_EVENTS, mp);
12087 mp->enable_disable = enable_disable;
12088 mp->pid = htonl (getpid ());
12089 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
12097 api_input_acl_set_interface (vat_main_t * vam)
12099 unformat_input_t *i = vam->input;
12100 vl_api_input_acl_set_interface_t *mp;
12102 int sw_if_index_set;
12103 u32 ip4_table_index = ~0;
12104 u32 ip6_table_index = ~0;
12105 u32 l2_table_index = ~0;
12109 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12111 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12112 sw_if_index_set = 1;
12113 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12114 sw_if_index_set = 1;
12115 else if (unformat (i, "del"))
12117 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12119 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12121 else if (unformat (i, "l2-table %d", &l2_table_index))
12125 clib_warning ("parse error '%U'", format_unformat_error, i);
12130 if (sw_if_index_set == 0)
12132 errmsg ("missing interface name or sw_if_index");
12136 M (INPUT_ACL_SET_INTERFACE, mp);
12138 mp->sw_if_index = ntohl (sw_if_index);
12139 mp->ip4_table_index = ntohl (ip4_table_index);
12140 mp->ip6_table_index = ntohl (ip6_table_index);
12141 mp->l2_table_index = ntohl (l2_table_index);
12142 mp->is_add = is_add;
12150 api_ip_address_dump (vat_main_t * vam)
12152 unformat_input_t *i = vam->input;
12153 vl_api_ip_address_dump_t *mp;
12154 vl_api_control_ping_t *mp_ping;
12155 u32 sw_if_index = ~0;
12156 u8 sw_if_index_set = 0;
12161 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12163 if (unformat (i, "sw_if_index %d", &sw_if_index))
12164 sw_if_index_set = 1;
12166 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12167 sw_if_index_set = 1;
12168 else if (unformat (i, "ipv4"))
12170 else if (unformat (i, "ipv6"))
12176 if (ipv4_set && ipv6_set)
12178 errmsg ("ipv4 and ipv6 flags cannot be both set");
12182 if ((!ipv4_set) && (!ipv6_set))
12184 errmsg ("no ipv4 nor ipv6 flag set");
12188 if (sw_if_index_set == 0)
12190 errmsg ("missing interface name or sw_if_index");
12194 vam->current_sw_if_index = sw_if_index;
12195 vam->is_ipv6 = ipv6_set;
12197 M (IP_ADDRESS_DUMP, mp);
12198 mp->sw_if_index = ntohl (sw_if_index);
12199 mp->is_ipv6 = ipv6_set;
12202 /* Use a control ping for synchronization */
12203 M (CONTROL_PING, mp_ping);
12211 api_ip_dump (vat_main_t * vam)
12213 vl_api_ip_dump_t *mp;
12214 vl_api_control_ping_t *mp_ping;
12215 unformat_input_t *in = vam->input;
12222 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
12224 if (unformat (in, "ipv4"))
12226 else if (unformat (in, "ipv6"))
12232 if (ipv4_set && ipv6_set)
12234 errmsg ("ipv4 and ipv6 flags cannot be both set");
12238 if ((!ipv4_set) && (!ipv6_set))
12240 errmsg ("no ipv4 nor ipv6 flag set");
12244 is_ipv6 = ipv6_set;
12245 vam->is_ipv6 = is_ipv6;
12247 /* free old data */
12248 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12250 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12252 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12255 mp->is_ipv6 = ipv6_set;
12258 /* Use a control ping for synchronization */
12259 M (CONTROL_PING, mp_ping);
12267 api_ipsec_spd_add_del (vat_main_t * vam)
12269 unformat_input_t *i = vam->input;
12270 vl_api_ipsec_spd_add_del_t *mp;
12275 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12277 if (unformat (i, "spd_id %d", &spd_id))
12279 else if (unformat (i, "del"))
12283 clib_warning ("parse error '%U'", format_unformat_error, i);
12289 errmsg ("spd_id must be set");
12293 M (IPSEC_SPD_ADD_DEL, mp);
12295 mp->spd_id = ntohl (spd_id);
12296 mp->is_add = is_add;
12304 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12306 unformat_input_t *i = vam->input;
12307 vl_api_ipsec_interface_add_del_spd_t *mp;
12309 u8 sw_if_index_set = 0;
12310 u32 spd_id = (u32) ~ 0;
12314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12316 if (unformat (i, "del"))
12318 else if (unformat (i, "spd_id %d", &spd_id))
12321 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12322 sw_if_index_set = 1;
12323 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12324 sw_if_index_set = 1;
12327 clib_warning ("parse error '%U'", format_unformat_error, i);
12333 if (spd_id == (u32) ~ 0)
12335 errmsg ("spd_id must be set");
12339 if (sw_if_index_set == 0)
12341 errmsg ("missing interface name or sw_if_index");
12345 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12347 mp->spd_id = ntohl (spd_id);
12348 mp->sw_if_index = ntohl (sw_if_index);
12349 mp->is_add = is_add;
12357 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12359 unformat_input_t *i = vam->input;
12360 vl_api_ipsec_spd_add_del_entry_t *mp;
12361 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12362 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12364 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12365 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12366 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12367 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12370 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12371 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12372 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12373 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12374 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12375 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12377 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12379 if (unformat (i, "del"))
12381 if (unformat (i, "outbound"))
12383 if (unformat (i, "inbound"))
12385 else if (unformat (i, "spd_id %d", &spd_id))
12387 else if (unformat (i, "sa_id %d", &sa_id))
12389 else if (unformat (i, "priority %d", &priority))
12391 else if (unformat (i, "protocol %d", &protocol))
12393 else if (unformat (i, "lport_start %d", &lport_start))
12395 else if (unformat (i, "lport_stop %d", &lport_stop))
12397 else if (unformat (i, "rport_start %d", &rport_start))
12399 else if (unformat (i, "rport_stop %d", &rport_stop))
12403 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12409 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12416 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12422 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12429 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12435 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12442 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12448 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12454 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12456 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12458 clib_warning ("unsupported action: 'resolve'");
12464 clib_warning ("parse error '%U'", format_unformat_error, i);
12470 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12472 mp->spd_id = ntohl (spd_id);
12473 mp->priority = ntohl (priority);
12474 mp->is_outbound = is_outbound;
12476 mp->is_ipv6 = is_ipv6;
12477 if (is_ipv6 || is_ip_any)
12479 clib_memcpy (mp->remote_address_start, &raddr6_start,
12480 sizeof (ip6_address_t));
12481 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12482 sizeof (ip6_address_t));
12483 clib_memcpy (mp->local_address_start, &laddr6_start,
12484 sizeof (ip6_address_t));
12485 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12486 sizeof (ip6_address_t));
12490 clib_memcpy (mp->remote_address_start, &raddr4_start,
12491 sizeof (ip4_address_t));
12492 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12493 sizeof (ip4_address_t));
12494 clib_memcpy (mp->local_address_start, &laddr4_start,
12495 sizeof (ip4_address_t));
12496 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12497 sizeof (ip4_address_t));
12499 mp->protocol = (u8) protocol;
12500 mp->local_port_start = ntohs ((u16) lport_start);
12501 mp->local_port_stop = ntohs ((u16) lport_stop);
12502 mp->remote_port_start = ntohs ((u16) rport_start);
12503 mp->remote_port_stop = ntohs ((u16) rport_stop);
12504 mp->policy = (u8) policy;
12505 mp->sa_id = ntohl (sa_id);
12506 mp->is_add = is_add;
12507 mp->is_ip_any = is_ip_any;
12514 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12516 unformat_input_t *i = vam->input;
12517 vl_api_ipsec_sad_add_del_entry_t *mp;
12518 u32 sad_id = 0, spi = 0;
12519 u8 *ck = 0, *ik = 0;
12522 u8 protocol = IPSEC_PROTOCOL_AH;
12523 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12524 u32 crypto_alg = 0, integ_alg = 0;
12525 ip4_address_t tun_src4;
12526 ip4_address_t tun_dst4;
12527 ip6_address_t tun_src6;
12528 ip6_address_t tun_dst6;
12531 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12533 if (unformat (i, "del"))
12535 else if (unformat (i, "sad_id %d", &sad_id))
12537 else if (unformat (i, "spi %d", &spi))
12539 else if (unformat (i, "esp"))
12540 protocol = IPSEC_PROTOCOL_ESP;
12541 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12544 is_tunnel_ipv6 = 0;
12546 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12549 is_tunnel_ipv6 = 0;
12551 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12554 is_tunnel_ipv6 = 1;
12556 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12559 is_tunnel_ipv6 = 1;
12563 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12565 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12566 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12568 clib_warning ("unsupported crypto-alg: '%U'",
12569 format_ipsec_crypto_alg, crypto_alg);
12573 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12577 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12579 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12580 integ_alg >= IPSEC_INTEG_N_ALG)
12582 clib_warning ("unsupported integ-alg: '%U'",
12583 format_ipsec_integ_alg, integ_alg);
12587 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12591 clib_warning ("parse error '%U'", format_unformat_error, i);
12597 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12599 mp->sad_id = ntohl (sad_id);
12600 mp->is_add = is_add;
12601 mp->protocol = protocol;
12602 mp->spi = ntohl (spi);
12603 mp->is_tunnel = is_tunnel;
12604 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12605 mp->crypto_algorithm = crypto_alg;
12606 mp->integrity_algorithm = integ_alg;
12607 mp->crypto_key_length = vec_len (ck);
12608 mp->integrity_key_length = vec_len (ik);
12610 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12611 mp->crypto_key_length = sizeof (mp->crypto_key);
12613 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12614 mp->integrity_key_length = sizeof (mp->integrity_key);
12617 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12619 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12623 if (is_tunnel_ipv6)
12625 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12626 sizeof (ip6_address_t));
12627 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12628 sizeof (ip6_address_t));
12632 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12633 sizeof (ip4_address_t));
12634 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12635 sizeof (ip4_address_t));
12645 api_ipsec_sa_set_key (vat_main_t * vam)
12647 unformat_input_t *i = vam->input;
12648 vl_api_ipsec_sa_set_key_t *mp;
12650 u8 *ck = 0, *ik = 0;
12653 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12655 if (unformat (i, "sa_id %d", &sa_id))
12657 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12659 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12663 clib_warning ("parse error '%U'", format_unformat_error, i);
12668 M (IPSEC_SA_SET_KEY, mp);
12670 mp->sa_id = ntohl (sa_id);
12671 mp->crypto_key_length = vec_len (ck);
12672 mp->integrity_key_length = vec_len (ik);
12674 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12675 mp->crypto_key_length = sizeof (mp->crypto_key);
12677 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12678 mp->integrity_key_length = sizeof (mp->integrity_key);
12681 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12683 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12691 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
12693 unformat_input_t *i = vam->input;
12694 vl_api_ipsec_tunnel_if_add_del_t *mp;
12695 u32 local_spi = 0, remote_spi = 0;
12696 u32 crypto_alg = 0, integ_alg = 0;
12697 u8 *lck = NULL, *rck = NULL;
12698 u8 *lik = NULL, *rik = NULL;
12699 ip4_address_t local_ip = { {0} };
12700 ip4_address_t remote_ip = { {0} };
12703 u8 anti_replay = 0;
12706 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12708 if (unformat (i, "del"))
12710 else if (unformat (i, "esn"))
12712 else if (unformat (i, "anti_replay"))
12714 else if (unformat (i, "local_spi %d", &local_spi))
12716 else if (unformat (i, "remote_spi %d", &remote_spi))
12718 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
12720 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
12722 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
12725 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
12727 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
12729 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
12733 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12735 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12736 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12738 errmsg ("unsupported crypto-alg: '%U'\n",
12739 format_ipsec_crypto_alg, crypto_alg);
12745 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12747 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12748 integ_alg >= IPSEC_INTEG_N_ALG)
12750 errmsg ("unsupported integ-alg: '%U'\n",
12751 format_ipsec_integ_alg, integ_alg);
12757 errmsg ("parse error '%U'\n", format_unformat_error, i);
12762 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
12764 mp->is_add = is_add;
12766 mp->anti_replay = anti_replay;
12768 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
12769 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
12771 mp->local_spi = htonl (local_spi);
12772 mp->remote_spi = htonl (remote_spi);
12773 mp->crypto_alg = (u8) crypto_alg;
12775 mp->local_crypto_key_len = 0;
12778 mp->local_crypto_key_len = vec_len (lck);
12779 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
12780 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
12781 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
12784 mp->remote_crypto_key_len = 0;
12787 mp->remote_crypto_key_len = vec_len (rck);
12788 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
12789 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
12790 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
12793 mp->integ_alg = (u8) integ_alg;
12795 mp->local_integ_key_len = 0;
12798 mp->local_integ_key_len = vec_len (lik);
12799 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
12800 mp->local_integ_key_len = sizeof (mp->local_integ_key);
12801 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
12804 mp->remote_integ_key_len = 0;
12807 mp->remote_integ_key_len = vec_len (rik);
12808 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
12809 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
12810 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
12819 api_ikev2_profile_add_del (vat_main_t * vam)
12821 unformat_input_t *i = vam->input;
12822 vl_api_ikev2_profile_add_del_t *mp;
12827 const char *valid_chars = "a-zA-Z0-9_";
12829 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12831 if (unformat (i, "del"))
12833 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12834 vec_add1 (name, 0);
12837 errmsg ("parse error '%U'", format_unformat_error, i);
12842 if (!vec_len (name))
12844 errmsg ("profile name must be specified");
12848 if (vec_len (name) > 64)
12850 errmsg ("profile name too long");
12854 M (IKEV2_PROFILE_ADD_DEL, mp);
12856 clib_memcpy (mp->name, name, vec_len (name));
12857 mp->is_add = is_add;
12866 api_ikev2_profile_set_auth (vat_main_t * vam)
12868 unformat_input_t *i = vam->input;
12869 vl_api_ikev2_profile_set_auth_t *mp;
12872 u32 auth_method = 0;
12876 const char *valid_chars = "a-zA-Z0-9_";
12878 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12880 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12881 vec_add1 (name, 0);
12882 else if (unformat (i, "auth_method %U",
12883 unformat_ikev2_auth_method, &auth_method))
12885 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12887 else if (unformat (i, "auth_data %v", &data))
12891 errmsg ("parse error '%U'", format_unformat_error, i);
12896 if (!vec_len (name))
12898 errmsg ("profile name must be specified");
12902 if (vec_len (name) > 64)
12904 errmsg ("profile name too long");
12908 if (!vec_len (data))
12910 errmsg ("auth_data must be specified");
12916 errmsg ("auth_method must be specified");
12920 M (IKEV2_PROFILE_SET_AUTH, mp);
12922 mp->is_hex = is_hex;
12923 mp->auth_method = (u8) auth_method;
12924 mp->data_len = vec_len (data);
12925 clib_memcpy (mp->name, name, vec_len (name));
12926 clib_memcpy (mp->data, data, vec_len (data));
12936 api_ikev2_profile_set_id (vat_main_t * vam)
12938 unformat_input_t *i = vam->input;
12939 vl_api_ikev2_profile_set_id_t *mp;
12947 const char *valid_chars = "a-zA-Z0-9_";
12949 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12951 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12952 vec_add1 (name, 0);
12953 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12955 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12957 data = vec_new (u8, 4);
12958 clib_memcpy (data, ip4.as_u8, 4);
12960 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12962 else if (unformat (i, "id_data %v", &data))
12964 else if (unformat (i, "local"))
12966 else if (unformat (i, "remote"))
12970 errmsg ("parse error '%U'", format_unformat_error, i);
12975 if (!vec_len (name))
12977 errmsg ("profile name must be specified");
12981 if (vec_len (name) > 64)
12983 errmsg ("profile name too long");
12987 if (!vec_len (data))
12989 errmsg ("id_data must be specified");
12995 errmsg ("id_type must be specified");
12999 M (IKEV2_PROFILE_SET_ID, mp);
13001 mp->is_local = is_local;
13002 mp->id_type = (u8) id_type;
13003 mp->data_len = vec_len (data);
13004 clib_memcpy (mp->name, name, vec_len (name));
13005 clib_memcpy (mp->data, data, vec_len (data));
13015 api_ikev2_profile_set_ts (vat_main_t * vam)
13017 unformat_input_t *i = vam->input;
13018 vl_api_ikev2_profile_set_ts_t *mp;
13021 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
13022 ip4_address_t start_addr, end_addr;
13024 const char *valid_chars = "a-zA-Z0-9_";
13027 start_addr.as_u32 = 0;
13028 end_addr.as_u32 = (u32) ~ 0;
13030 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13032 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13033 vec_add1 (name, 0);
13034 else if (unformat (i, "protocol %d", &proto))
13036 else if (unformat (i, "start_port %d", &start_port))
13038 else if (unformat (i, "end_port %d", &end_port))
13041 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
13043 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
13045 else if (unformat (i, "local"))
13047 else if (unformat (i, "remote"))
13051 errmsg ("parse error '%U'", format_unformat_error, i);
13056 if (!vec_len (name))
13058 errmsg ("profile name must be specified");
13062 if (vec_len (name) > 64)
13064 errmsg ("profile name too long");
13068 M (IKEV2_PROFILE_SET_TS, mp);
13070 mp->is_local = is_local;
13071 mp->proto = (u8) proto;
13072 mp->start_port = (u16) start_port;
13073 mp->end_port = (u16) end_port;
13074 mp->start_addr = start_addr.as_u32;
13075 mp->end_addr = end_addr.as_u32;
13076 clib_memcpy (mp->name, name, vec_len (name));
13085 api_ikev2_set_local_key (vat_main_t * vam)
13087 unformat_input_t *i = vam->input;
13088 vl_api_ikev2_set_local_key_t *mp;
13092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13094 if (unformat (i, "file %v", &file))
13095 vec_add1 (file, 0);
13098 errmsg ("parse error '%U'", format_unformat_error, i);
13103 if (!vec_len (file))
13105 errmsg ("RSA key file must be specified");
13109 if (vec_len (file) > 256)
13111 errmsg ("file name too long");
13115 M (IKEV2_SET_LOCAL_KEY, mp);
13117 clib_memcpy (mp->key_file, file, vec_len (file));
13126 api_ikev2_set_responder (vat_main_t * vam)
13128 unformat_input_t *i = vam->input;
13129 vl_api_ikev2_set_responder_t *mp;
13132 u32 sw_if_index = ~0;
13133 ip4_address_t address;
13135 const char *valid_chars = "a-zA-Z0-9_";
13137 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13140 (i, "%U interface %d address %U", unformat_token, valid_chars,
13141 &name, &sw_if_index, unformat_ip4_address, &address))
13142 vec_add1 (name, 0);
13145 errmsg ("parse error '%U'", format_unformat_error, i);
13150 if (!vec_len (name))
13152 errmsg ("profile name must be specified");
13156 if (vec_len (name) > 64)
13158 errmsg ("profile name too long");
13162 M (IKEV2_SET_RESPONDER, mp);
13164 clib_memcpy (mp->name, name, vec_len (name));
13167 mp->sw_if_index = sw_if_index;
13168 clib_memcpy (mp->address, &address, sizeof (address));
13176 api_ikev2_set_ike_transforms (vat_main_t * vam)
13178 unformat_input_t *i = vam->input;
13179 vl_api_ikev2_set_ike_transforms_t *mp;
13182 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13184 const char *valid_chars = "a-zA-Z0-9_";
13186 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13188 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13189 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13190 vec_add1 (name, 0);
13193 errmsg ("parse error '%U'", format_unformat_error, i);
13198 if (!vec_len (name))
13200 errmsg ("profile name must be specified");
13204 if (vec_len (name) > 64)
13206 errmsg ("profile name too long");
13210 M (IKEV2_SET_IKE_TRANSFORMS, mp);
13212 clib_memcpy (mp->name, name, vec_len (name));
13214 mp->crypto_alg = crypto_alg;
13215 mp->crypto_key_size = crypto_key_size;
13216 mp->integ_alg = integ_alg;
13217 mp->dh_group = dh_group;
13226 api_ikev2_set_esp_transforms (vat_main_t * vam)
13228 unformat_input_t *i = vam->input;
13229 vl_api_ikev2_set_esp_transforms_t *mp;
13232 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13234 const char *valid_chars = "a-zA-Z0-9_";
13236 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13238 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13239 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13240 vec_add1 (name, 0);
13243 errmsg ("parse error '%U'", format_unformat_error, i);
13248 if (!vec_len (name))
13250 errmsg ("profile name must be specified");
13254 if (vec_len (name) > 64)
13256 errmsg ("profile name too long");
13260 M (IKEV2_SET_ESP_TRANSFORMS, mp);
13262 clib_memcpy (mp->name, name, vec_len (name));
13264 mp->crypto_alg = crypto_alg;
13265 mp->crypto_key_size = crypto_key_size;
13266 mp->integ_alg = integ_alg;
13267 mp->dh_group = dh_group;
13275 api_ikev2_set_sa_lifetime (vat_main_t * vam)
13277 unformat_input_t *i = vam->input;
13278 vl_api_ikev2_set_sa_lifetime_t *mp;
13281 u64 lifetime, lifetime_maxdata;
13282 u32 lifetime_jitter, handover;
13284 const char *valid_chars = "a-zA-Z0-9_";
13286 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13288 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
13289 &lifetime, &lifetime_jitter, &handover,
13290 &lifetime_maxdata))
13291 vec_add1 (name, 0);
13294 errmsg ("parse error '%U'", format_unformat_error, i);
13299 if (!vec_len (name))
13301 errmsg ("profile name must be specified");
13305 if (vec_len (name) > 64)
13307 errmsg ("profile name too long");
13311 M (IKEV2_SET_SA_LIFETIME, mp);
13313 clib_memcpy (mp->name, name, vec_len (name));
13315 mp->lifetime = lifetime;
13316 mp->lifetime_jitter = lifetime_jitter;
13317 mp->handover = handover;
13318 mp->lifetime_maxdata = lifetime_maxdata;
13326 api_ikev2_initiate_sa_init (vat_main_t * vam)
13328 unformat_input_t *i = vam->input;
13329 vl_api_ikev2_initiate_sa_init_t *mp;
13333 const char *valid_chars = "a-zA-Z0-9_";
13335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13337 if (unformat (i, "%U", unformat_token, valid_chars, &name))
13338 vec_add1 (name, 0);
13341 errmsg ("parse error '%U'", format_unformat_error, i);
13346 if (!vec_len (name))
13348 errmsg ("profile name must be specified");
13352 if (vec_len (name) > 64)
13354 errmsg ("profile name too long");
13358 M (IKEV2_INITIATE_SA_INIT, mp);
13360 clib_memcpy (mp->name, name, vec_len (name));
13369 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
13371 unformat_input_t *i = vam->input;
13372 vl_api_ikev2_initiate_del_ike_sa_t *mp;
13377 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13379 if (unformat (i, "%lx", &ispi))
13383 errmsg ("parse error '%U'", format_unformat_error, i);
13388 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
13398 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13400 unformat_input_t *i = vam->input;
13401 vl_api_ikev2_initiate_del_child_sa_t *mp;
13406 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13408 if (unformat (i, "%x", &ispi))
13412 errmsg ("parse error '%U'", format_unformat_error, i);
13417 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13427 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13429 unformat_input_t *i = vam->input;
13430 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13437 if (unformat (i, "%x", &ispi))
13441 errmsg ("parse error '%U'", format_unformat_error, i);
13446 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
13459 api_map_add_domain (vat_main_t * vam)
13461 unformat_input_t *i = vam->input;
13462 vl_api_map_add_domain_t *mp;
13464 ip4_address_t ip4_prefix;
13465 ip6_address_t ip6_prefix;
13466 ip6_address_t ip6_src;
13467 u32 num_m_args = 0;
13468 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
13469 0, psid_length = 0;
13470 u8 is_translation = 0;
13472 u32 ip6_src_len = 128;
13475 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13477 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
13478 &ip4_prefix, &ip4_prefix_len))
13480 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
13481 &ip6_prefix, &ip6_prefix_len))
13485 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
13488 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
13490 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
13492 else if (unformat (i, "psid-offset %d", &psid_offset))
13494 else if (unformat (i, "psid-len %d", &psid_length))
13496 else if (unformat (i, "mtu %d", &mtu))
13498 else if (unformat (i, "map-t"))
13499 is_translation = 1;
13502 clib_warning ("parse error '%U'", format_unformat_error, i);
13507 if (num_m_args < 3)
13509 errmsg ("mandatory argument(s) missing");
13513 /* Construct the API message */
13514 M (MAP_ADD_DOMAIN, mp);
13516 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
13517 mp->ip4_prefix_len = ip4_prefix_len;
13519 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
13520 mp->ip6_prefix_len = ip6_prefix_len;
13522 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
13523 mp->ip6_src_prefix_len = ip6_src_len;
13525 mp->ea_bits_len = ea_bits_len;
13526 mp->psid_offset = psid_offset;
13527 mp->psid_length = psid_length;
13528 mp->is_translation = is_translation;
13529 mp->mtu = htons (mtu);
13534 /* Wait for a reply, return good/bad news */
13540 api_map_del_domain (vat_main_t * vam)
13542 unformat_input_t *i = vam->input;
13543 vl_api_map_del_domain_t *mp;
13545 u32 num_m_args = 0;
13549 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13551 if (unformat (i, "index %d", &index))
13555 clib_warning ("parse error '%U'", format_unformat_error, i);
13560 if (num_m_args != 1)
13562 errmsg ("mandatory argument(s) missing");
13566 /* Construct the API message */
13567 M (MAP_DEL_DOMAIN, mp);
13569 mp->index = ntohl (index);
13574 /* Wait for a reply, return good/bad news */
13580 api_map_add_del_rule (vat_main_t * vam)
13582 unformat_input_t *i = vam->input;
13583 vl_api_map_add_del_rule_t *mp;
13585 ip6_address_t ip6_dst;
13586 u32 num_m_args = 0, index, psid = 0;
13589 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13591 if (unformat (i, "index %d", &index))
13593 else if (unformat (i, "psid %d", &psid))
13595 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13597 else if (unformat (i, "del"))
13603 clib_warning ("parse error '%U'", format_unformat_error, i);
13608 /* Construct the API message */
13609 M (MAP_ADD_DEL_RULE, mp);
13611 mp->index = ntohl (index);
13612 mp->is_add = is_add;
13613 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13614 mp->psid = ntohs (psid);
13619 /* Wait for a reply, return good/bad news */
13625 api_map_domain_dump (vat_main_t * vam)
13627 vl_api_map_domain_dump_t *mp;
13628 vl_api_control_ping_t *mp_ping;
13631 /* Construct the API message */
13632 M (MAP_DOMAIN_DUMP, mp);
13637 /* Use a control ping for synchronization */
13638 M (CONTROL_PING, mp_ping);
13646 api_map_rule_dump (vat_main_t * vam)
13648 unformat_input_t *i = vam->input;
13649 vl_api_map_rule_dump_t *mp;
13650 vl_api_control_ping_t *mp_ping;
13651 u32 domain_index = ~0;
13654 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13656 if (unformat (i, "index %u", &domain_index))
13662 if (domain_index == ~0)
13664 clib_warning ("parse error: domain index expected");
13668 /* Construct the API message */
13669 M (MAP_RULE_DUMP, mp);
13671 mp->domain_index = htonl (domain_index);
13676 /* Use a control ping for synchronization */
13677 M (CONTROL_PING, mp_ping);
13684 static void vl_api_map_add_domain_reply_t_handler
13685 (vl_api_map_add_domain_reply_t * mp)
13687 vat_main_t *vam = &vat_main;
13688 i32 retval = ntohl (mp->retval);
13690 if (vam->async_mode)
13692 vam->async_errors += (retval < 0);
13696 vam->retval = retval;
13697 vam->result_ready = 1;
13701 static void vl_api_map_add_domain_reply_t_handler_json
13702 (vl_api_map_add_domain_reply_t * mp)
13704 vat_main_t *vam = &vat_main;
13705 vat_json_node_t node;
13707 vat_json_init_object (&node);
13708 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13709 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13711 vat_json_print (vam->ofp, &node);
13712 vat_json_free (&node);
13714 vam->retval = ntohl (mp->retval);
13715 vam->result_ready = 1;
13719 api_get_first_msg_id (vat_main_t * vam)
13721 vl_api_get_first_msg_id_t *mp;
13722 unformat_input_t *i = vam->input;
13727 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13729 if (unformat (i, "client %s", &name))
13737 errmsg ("missing client name");
13740 vec_add1 (name, 0);
13742 if (vec_len (name) > 63)
13744 errmsg ("client name too long");
13748 M (GET_FIRST_MSG_ID, mp);
13749 clib_memcpy (mp->name, name, vec_len (name));
13756 api_cop_interface_enable_disable (vat_main_t * vam)
13758 unformat_input_t *line_input = vam->input;
13759 vl_api_cop_interface_enable_disable_t *mp;
13760 u32 sw_if_index = ~0;
13761 u8 enable_disable = 1;
13764 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13766 if (unformat (line_input, "disable"))
13767 enable_disable = 0;
13768 if (unformat (line_input, "enable"))
13769 enable_disable = 1;
13770 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13771 vam, &sw_if_index))
13773 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13779 if (sw_if_index == ~0)
13781 errmsg ("missing interface name or sw_if_index");
13785 /* Construct the API message */
13786 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13787 mp->sw_if_index = ntohl (sw_if_index);
13788 mp->enable_disable = enable_disable;
13792 /* Wait for the reply */
13798 api_cop_whitelist_enable_disable (vat_main_t * vam)
13800 unformat_input_t *line_input = vam->input;
13801 vl_api_cop_whitelist_enable_disable_t *mp;
13802 u32 sw_if_index = ~0;
13803 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13807 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13809 if (unformat (line_input, "ip4"))
13811 else if (unformat (line_input, "ip6"))
13813 else if (unformat (line_input, "default"))
13815 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13816 vam, &sw_if_index))
13818 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13820 else if (unformat (line_input, "fib-id %d", &fib_id))
13826 if (sw_if_index == ~0)
13828 errmsg ("missing interface name or sw_if_index");
13832 /* Construct the API message */
13833 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13834 mp->sw_if_index = ntohl (sw_if_index);
13835 mp->fib_id = ntohl (fib_id);
13838 mp->default_cop = default_cop;
13842 /* Wait for the reply */
13848 api_get_node_graph (vat_main_t * vam)
13850 vl_api_get_node_graph_t *mp;
13853 M (GET_NODE_GRAPH, mp);
13857 /* Wait for the reply */
13863 /** Used for parsing LISP eids */
13864 typedef CLIB_PACKED(struct{
13865 u8 addr[16]; /**< eid address */
13866 u32 len; /**< prefix length if IP */
13867 u8 type; /**< type of eid */
13872 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13874 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13876 memset (a, 0, sizeof (a[0]));
13878 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13880 a->type = 0; /* ipv4 type */
13882 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13884 a->type = 1; /* ipv6 type */
13886 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13888 a->type = 2; /* mac type */
13895 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13904 lisp_eid_size_vat (u8 type)
13919 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13921 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13925 api_one_add_del_locator_set (vat_main_t * vam)
13927 unformat_input_t *input = vam->input;
13928 vl_api_one_add_del_locator_set_t *mp;
13930 u8 *locator_set_name = NULL;
13931 u8 locator_set_name_set = 0;
13932 vl_api_local_locator_t locator, *locators = 0;
13933 u32 sw_if_index, priority, weight;
13937 /* Parse args required to build the message */
13938 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13940 if (unformat (input, "del"))
13944 else if (unformat (input, "locator-set %s", &locator_set_name))
13946 locator_set_name_set = 1;
13948 else if (unformat (input, "sw_if_index %u p %u w %u",
13949 &sw_if_index, &priority, &weight))
13951 locator.sw_if_index = htonl (sw_if_index);
13952 locator.priority = priority;
13953 locator.weight = weight;
13954 vec_add1 (locators, locator);
13958 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13959 &sw_if_index, &priority, &weight))
13961 locator.sw_if_index = htonl (sw_if_index);
13962 locator.priority = priority;
13963 locator.weight = weight;
13964 vec_add1 (locators, locator);
13970 if (locator_set_name_set == 0)
13972 errmsg ("missing locator-set name");
13973 vec_free (locators);
13977 if (vec_len (locator_set_name) > 64)
13979 errmsg ("locator-set name too long");
13980 vec_free (locator_set_name);
13981 vec_free (locators);
13984 vec_add1 (locator_set_name, 0);
13986 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13988 /* Construct the API message */
13989 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
13991 mp->is_add = is_add;
13992 clib_memcpy (mp->locator_set_name, locator_set_name,
13993 vec_len (locator_set_name));
13994 vec_free (locator_set_name);
13996 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13998 clib_memcpy (mp->locators, locators, data_len);
13999 vec_free (locators);
14004 /* Wait for a reply... */
14009 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14012 api_one_add_del_locator (vat_main_t * vam)
14014 unformat_input_t *input = vam->input;
14015 vl_api_one_add_del_locator_t *mp;
14016 u32 tmp_if_index = ~0;
14017 u32 sw_if_index = ~0;
14018 u8 sw_if_index_set = 0;
14019 u8 sw_if_index_if_name_set = 0;
14021 u8 priority_set = 0;
14025 u8 *locator_set_name = NULL;
14026 u8 locator_set_name_set = 0;
14029 /* Parse args required to build the message */
14030 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14032 if (unformat (input, "del"))
14036 else if (unformat (input, "locator-set %s", &locator_set_name))
14038 locator_set_name_set = 1;
14040 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14043 sw_if_index_if_name_set = 1;
14044 sw_if_index = tmp_if_index;
14046 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14048 sw_if_index_set = 1;
14049 sw_if_index = tmp_if_index;
14051 else if (unformat (input, "p %d", &priority))
14055 else if (unformat (input, "w %d", &weight))
14063 if (locator_set_name_set == 0)
14065 errmsg ("missing locator-set name");
14069 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14071 errmsg ("missing sw_if_index");
14072 vec_free (locator_set_name);
14076 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14078 errmsg ("cannot use both params interface name and sw_if_index");
14079 vec_free (locator_set_name);
14083 if (priority_set == 0)
14085 errmsg ("missing locator-set priority");
14086 vec_free (locator_set_name);
14090 if (weight_set == 0)
14092 errmsg ("missing locator-set weight");
14093 vec_free (locator_set_name);
14097 if (vec_len (locator_set_name) > 64)
14099 errmsg ("locator-set name too long");
14100 vec_free (locator_set_name);
14103 vec_add1 (locator_set_name, 0);
14105 /* Construct the API message */
14106 M (ONE_ADD_DEL_LOCATOR, mp);
14108 mp->is_add = is_add;
14109 mp->sw_if_index = ntohl (sw_if_index);
14110 mp->priority = priority;
14111 mp->weight = weight;
14112 clib_memcpy (mp->locator_set_name, locator_set_name,
14113 vec_len (locator_set_name));
14114 vec_free (locator_set_name);
14119 /* Wait for a reply... */
14124 #define api_lisp_add_del_locator api_one_add_del_locator
14127 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14129 u32 *key_id = va_arg (*args, u32 *);
14132 if (unformat (input, "%s", &s))
14134 if (!strcmp ((char *) s, "sha1"))
14135 key_id[0] = HMAC_SHA_1_96;
14136 else if (!strcmp ((char *) s, "sha256"))
14137 key_id[0] = HMAC_SHA_256_128;
14140 clib_warning ("invalid key_id: '%s'", s);
14141 key_id[0] = HMAC_NO_KEY;
14152 api_one_add_del_local_eid (vat_main_t * vam)
14154 unformat_input_t *input = vam->input;
14155 vl_api_one_add_del_local_eid_t *mp;
14158 lisp_eid_vat_t _eid, *eid = &_eid;
14159 u8 *locator_set_name = 0;
14160 u8 locator_set_name_set = 0;
14166 /* Parse args required to build the message */
14167 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14169 if (unformat (input, "del"))
14173 else if (unformat (input, "vni %d", &vni))
14177 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14181 else if (unformat (input, "locator-set %s", &locator_set_name))
14183 locator_set_name_set = 1;
14185 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14187 else if (unformat (input, "secret-key %_%v%_", &key))
14193 if (locator_set_name_set == 0)
14195 errmsg ("missing locator-set name");
14201 errmsg ("EID address not set!");
14202 vec_free (locator_set_name);
14206 if (key && (0 == key_id))
14208 errmsg ("invalid key_id!");
14212 if (vec_len (key) > 64)
14214 errmsg ("key too long");
14219 if (vec_len (locator_set_name) > 64)
14221 errmsg ("locator-set name too long");
14222 vec_free (locator_set_name);
14225 vec_add1 (locator_set_name, 0);
14227 /* Construct the API message */
14228 M (ONE_ADD_DEL_LOCAL_EID, mp);
14230 mp->is_add = is_add;
14231 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14232 mp->eid_type = eid->type;
14233 mp->prefix_len = eid->len;
14234 mp->vni = clib_host_to_net_u32 (vni);
14235 mp->key_id = clib_host_to_net_u16 (key_id);
14236 clib_memcpy (mp->locator_set_name, locator_set_name,
14237 vec_len (locator_set_name));
14238 clib_memcpy (mp->key, key, vec_len (key));
14240 vec_free (locator_set_name);
14246 /* Wait for a reply... */
14251 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14254 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14256 u32 dp_table = 0, vni = 0;;
14257 unformat_input_t *input = vam->input;
14258 vl_api_gpe_add_del_fwd_entry_t *mp;
14260 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14261 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14262 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14263 u32 action = ~0, w;
14264 ip4_address_t rmt_rloc4, lcl_rloc4;
14265 ip6_address_t rmt_rloc6, lcl_rloc6;
14266 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14269 memset (&rloc, 0, sizeof (rloc));
14271 /* Parse args required to build the message */
14272 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14274 if (unformat (input, "del"))
14276 else if (unformat (input, "add"))
14278 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14282 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14286 else if (unformat (input, "vrf %d", &dp_table))
14288 else if (unformat (input, "bd %d", &dp_table))
14290 else if (unformat (input, "vni %d", &vni))
14292 else if (unformat (input, "w %d", &w))
14296 errmsg ("No RLOC configured for setting priority/weight!");
14299 curr_rloc->weight = w;
14301 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14302 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14306 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
14308 vec_add1 (lcl_locs, rloc);
14310 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
14311 vec_add1 (rmt_locs, rloc);
14312 /* weight saved in rmt loc */
14313 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14315 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14316 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14319 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
14321 vec_add1 (lcl_locs, rloc);
14323 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
14324 vec_add1 (rmt_locs, rloc);
14325 /* weight saved in rmt loc */
14326 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14328 else if (unformat (input, "action %d", &action))
14334 clib_warning ("parse error '%U'", format_unformat_error, input);
14341 errmsg ("remote eid addresses not set");
14345 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14347 errmsg ("eid types don't match");
14351 if (0 == rmt_locs && (u32) ~ 0 == action)
14353 errmsg ("action not set for negative mapping");
14357 /* Construct the API message */
14358 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14359 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14361 mp->is_add = is_add;
14362 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14363 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14364 mp->eid_type = rmt_eid->type;
14365 mp->dp_table = clib_host_to_net_u32 (dp_table);
14366 mp->vni = clib_host_to_net_u32 (vni);
14367 mp->rmt_len = rmt_eid->len;
14368 mp->lcl_len = lcl_eid->len;
14369 mp->action = action;
14371 if (0 != rmt_locs && 0 != lcl_locs)
14373 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14374 clib_memcpy (mp->locs, lcl_locs,
14375 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14377 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14378 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14379 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14381 vec_free (lcl_locs);
14382 vec_free (rmt_locs);
14387 /* Wait for a reply... */
14393 api_one_add_del_map_server (vat_main_t * vam)
14395 unformat_input_t *input = vam->input;
14396 vl_api_one_add_del_map_server_t *mp;
14400 ip4_address_t ipv4;
14401 ip6_address_t ipv6;
14404 /* Parse args required to build the message */
14405 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14407 if (unformat (input, "del"))
14411 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14415 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14423 if (ipv4_set && ipv6_set)
14425 errmsg ("both eid v4 and v6 addresses set");
14429 if (!ipv4_set && !ipv6_set)
14431 errmsg ("eid addresses not set");
14435 /* Construct the API message */
14436 M (ONE_ADD_DEL_MAP_SERVER, mp);
14438 mp->is_add = is_add;
14442 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14447 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14453 /* Wait for a reply... */
14458 #define api_lisp_add_del_map_server api_one_add_del_map_server
14461 api_one_add_del_map_resolver (vat_main_t * vam)
14463 unformat_input_t *input = vam->input;
14464 vl_api_one_add_del_map_resolver_t *mp;
14468 ip4_address_t ipv4;
14469 ip6_address_t ipv6;
14472 /* Parse args required to build the message */
14473 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14475 if (unformat (input, "del"))
14479 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14483 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14491 if (ipv4_set && ipv6_set)
14493 errmsg ("both eid v4 and v6 addresses set");
14497 if (!ipv4_set && !ipv6_set)
14499 errmsg ("eid addresses not set");
14503 /* Construct the API message */
14504 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14506 mp->is_add = is_add;
14510 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14515 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14521 /* Wait for a reply... */
14526 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14529 api_lisp_gpe_enable_disable (vat_main_t * vam)
14531 unformat_input_t *input = vam->input;
14532 vl_api_gpe_enable_disable_t *mp;
14537 /* Parse args required to build the message */
14538 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14540 if (unformat (input, "enable"))
14545 else if (unformat (input, "disable"))
14556 errmsg ("Value not set");
14560 /* Construct the API message */
14561 M (GPE_ENABLE_DISABLE, mp);
14568 /* Wait for a reply... */
14574 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14576 unformat_input_t *input = vam->input;
14577 vl_api_one_rloc_probe_enable_disable_t *mp;
14582 /* Parse args required to build the message */
14583 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14585 if (unformat (input, "enable"))
14590 else if (unformat (input, "disable"))
14598 errmsg ("Value not set");
14602 /* Construct the API message */
14603 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14605 mp->is_enabled = is_en;
14610 /* Wait for a reply... */
14615 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14618 api_one_map_register_enable_disable (vat_main_t * vam)
14620 unformat_input_t *input = vam->input;
14621 vl_api_one_map_register_enable_disable_t *mp;
14626 /* Parse args required to build the message */
14627 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14629 if (unformat (input, "enable"))
14634 else if (unformat (input, "disable"))
14642 errmsg ("Value not set");
14646 /* Construct the API message */
14647 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14649 mp->is_enabled = is_en;
14654 /* Wait for a reply... */
14659 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14662 api_one_enable_disable (vat_main_t * vam)
14664 unformat_input_t *input = vam->input;
14665 vl_api_one_enable_disable_t *mp;
14670 /* Parse args required to build the message */
14671 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14673 if (unformat (input, "enable"))
14678 else if (unformat (input, "disable"))
14688 errmsg ("Value not set");
14692 /* Construct the API message */
14693 M (ONE_ENABLE_DISABLE, mp);
14700 /* Wait for a reply... */
14705 #define api_lisp_enable_disable api_one_enable_disable
14708 api_show_one_map_register_state (vat_main_t * vam)
14710 vl_api_show_one_map_register_state_t *mp;
14713 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14718 /* wait for reply */
14723 #define api_show_lisp_map_register_state api_show_one_map_register_state
14726 api_show_one_rloc_probe_state (vat_main_t * vam)
14728 vl_api_show_one_rloc_probe_state_t *mp;
14731 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14736 /* wait for reply */
14741 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14744 api_one_stats_enable_disable (vat_main_t * vam)
14746 vl_api_one_stats_enable_disable_t *mp;
14747 unformat_input_t *input = vam->input;
14752 /* Parse args required to build the message */
14753 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14755 if (unformat (input, "enable"))
14760 else if (unformat (input, "disable"))
14770 errmsg ("Value not set");
14774 M (ONE_STATS_ENABLE_DISABLE, mp);
14780 /* wait for reply */
14786 api_show_one_stats_enable_disable (vat_main_t * vam)
14788 vl_api_show_one_stats_enable_disable_t *mp;
14791 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
14796 /* wait for reply */
14802 api_show_one_map_request_mode (vat_main_t * vam)
14804 vl_api_show_one_map_request_mode_t *mp;
14807 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
14812 /* wait for reply */
14817 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
14820 api_one_map_request_mode (vat_main_t * vam)
14822 unformat_input_t *input = vam->input;
14823 vl_api_one_map_request_mode_t *mp;
14827 /* Parse args required to build the message */
14828 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14830 if (unformat (input, "dst-only"))
14832 else if (unformat (input, "src-dst"))
14836 errmsg ("parse error '%U'", format_unformat_error, input);
14841 M (ONE_MAP_REQUEST_MODE, mp);
14848 /* wait for reply */
14853 #define api_lisp_map_request_mode api_one_map_request_mode
14856 * Enable/disable ONE proxy ITR.
14858 * @param vam vpp API test context
14859 * @return return code
14862 api_one_pitr_set_locator_set (vat_main_t * vam)
14864 u8 ls_name_set = 0;
14865 unformat_input_t *input = vam->input;
14866 vl_api_one_pitr_set_locator_set_t *mp;
14871 /* Parse args required to build the message */
14872 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14874 if (unformat (input, "del"))
14876 else if (unformat (input, "locator-set %s", &ls_name))
14880 errmsg ("parse error '%U'", format_unformat_error, input);
14887 errmsg ("locator-set name not set!");
14891 M (ONE_PITR_SET_LOCATOR_SET, mp);
14893 mp->is_add = is_add;
14894 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14895 vec_free (ls_name);
14900 /* wait for reply */
14905 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
14908 api_show_one_pitr (vat_main_t * vam)
14910 vl_api_show_one_pitr_t *mp;
14913 if (!vam->json_output)
14915 print (vam->ofp, "%=20s", "lisp status:");
14918 M (SHOW_ONE_PITR, mp);
14922 /* Wait for a reply... */
14927 #define api_show_lisp_pitr api_show_one_pitr
14930 api_one_use_petr (vat_main_t * vam)
14932 unformat_input_t *input = vam->input;
14933 vl_api_one_use_petr_t *mp;
14938 memset (&ip, 0, sizeof (ip));
14940 /* Parse args required to build the message */
14941 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14943 if (unformat (input, "disable"))
14946 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
14949 ip_addr_version (&ip) = IP4;
14952 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
14955 ip_addr_version (&ip) = IP6;
14959 errmsg ("parse error '%U'", format_unformat_error, input);
14964 M (ONE_USE_PETR, mp);
14966 mp->is_add = is_add;
14969 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
14971 clib_memcpy (mp->address, &ip, 4);
14973 clib_memcpy (mp->address, &ip, 16);
14979 /* wait for reply */
14984 #define api_lisp_use_petr api_one_use_petr
14987 api_show_one_use_petr (vat_main_t * vam)
14989 vl_api_show_one_use_petr_t *mp;
14992 if (!vam->json_output)
14994 print (vam->ofp, "%=20s", "Proxy-ETR status:");
14997 M (SHOW_ONE_USE_PETR, mp);
15001 /* Wait for a reply... */
15006 #define api_show_lisp_use_petr api_show_one_use_petr
15009 * Add/delete mapping between vni and vrf
15012 api_one_eid_table_add_del_map (vat_main_t * vam)
15014 unformat_input_t *input = vam->input;
15015 vl_api_one_eid_table_add_del_map_t *mp;
15016 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15017 u32 vni, vrf, bd_index;
15020 /* Parse args required to build the message */
15021 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15023 if (unformat (input, "del"))
15025 else if (unformat (input, "vrf %d", &vrf))
15027 else if (unformat (input, "bd_index %d", &bd_index))
15029 else if (unformat (input, "vni %d", &vni))
15035 if (!vni_set || (!vrf_set && !bd_index_set))
15037 errmsg ("missing arguments!");
15041 if (vrf_set && bd_index_set)
15043 errmsg ("error: both vrf and bd entered!");
15047 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15049 mp->is_add = is_add;
15050 mp->vni = htonl (vni);
15051 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15052 mp->is_l2 = bd_index_set;
15057 /* wait for reply */
15062 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15065 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15067 u32 *action = va_arg (*args, u32 *);
15070 if (unformat (input, "%s", &s))
15072 if (!strcmp ((char *) s, "no-action"))
15074 else if (!strcmp ((char *) s, "natively-forward"))
15076 else if (!strcmp ((char *) s, "send-map-request"))
15078 else if (!strcmp ((char *) s, "drop"))
15082 clib_warning ("invalid action: '%s'", s);
15094 * Add/del remote mapping to/from ONE control plane
15096 * @param vam vpp API test context
15097 * @return return code
15100 api_one_add_del_remote_mapping (vat_main_t * vam)
15102 unformat_input_t *input = vam->input;
15103 vl_api_one_add_del_remote_mapping_t *mp;
15105 lisp_eid_vat_t _eid, *eid = &_eid;
15106 lisp_eid_vat_t _seid, *seid = &_seid;
15107 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15108 u32 action = ~0, p, w, data_len;
15109 ip4_address_t rloc4;
15110 ip6_address_t rloc6;
15111 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15114 memset (&rloc, 0, sizeof (rloc));
15116 /* Parse args required to build the message */
15117 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15119 if (unformat (input, "del-all"))
15123 else if (unformat (input, "del"))
15127 else if (unformat (input, "add"))
15131 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15135 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15139 else if (unformat (input, "vni %d", &vni))
15143 else if (unformat (input, "p %d w %d", &p, &w))
15147 errmsg ("No RLOC configured for setting priority/weight!");
15150 curr_rloc->priority = p;
15151 curr_rloc->weight = w;
15153 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15156 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
15157 vec_add1 (rlocs, rloc);
15158 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15160 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15163 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
15164 vec_add1 (rlocs, rloc);
15165 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15167 else if (unformat (input, "action %U",
15168 unformat_negative_mapping_action, &action))
15174 clib_warning ("parse error '%U'", format_unformat_error, input);
15181 errmsg ("missing params!");
15185 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15187 errmsg ("no action set for negative map-reply!");
15191 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15193 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15194 mp->is_add = is_add;
15195 mp->vni = htonl (vni);
15196 mp->action = (u8) action;
15197 mp->is_src_dst = seid_set;
15198 mp->eid_len = eid->len;
15199 mp->seid_len = seid->len;
15200 mp->del_all = del_all;
15201 mp->eid_type = eid->type;
15202 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15203 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
15205 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15206 clib_memcpy (mp->rlocs, rlocs, data_len);
15212 /* Wait for a reply... */
15217 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15220 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15221 * forwarding entries in data-plane accordingly.
15223 * @param vam vpp API test context
15224 * @return return code
15227 api_one_add_del_adjacency (vat_main_t * vam)
15229 unformat_input_t *input = vam->input;
15230 vl_api_one_add_del_adjacency_t *mp;
15232 ip4_address_t leid4, reid4;
15233 ip6_address_t leid6, reid6;
15234 u8 reid_mac[6] = { 0 };
15235 u8 leid_mac[6] = { 0 };
15236 u8 reid_type, leid_type;
15237 u32 leid_len = 0, reid_len = 0, len;
15241 leid_type = reid_type = (u8) ~ 0;
15243 /* Parse args required to build the message */
15244 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15246 if (unformat (input, "del"))
15250 else if (unformat (input, "add"))
15254 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
15257 reid_type = 0; /* ipv4 */
15260 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
15263 reid_type = 1; /* ipv6 */
15266 else if (unformat (input, "reid %U", unformat_ethernet_address,
15269 reid_type = 2; /* mac */
15271 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
15274 leid_type = 0; /* ipv4 */
15277 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
15280 leid_type = 1; /* ipv6 */
15283 else if (unformat (input, "leid %U", unformat_ethernet_address,
15286 leid_type = 2; /* mac */
15288 else if (unformat (input, "vni %d", &vni))
15294 errmsg ("parse error '%U'", format_unformat_error, input);
15299 if ((u8) ~ 0 == reid_type)
15301 errmsg ("missing params!");
15305 if (leid_type != reid_type)
15307 errmsg ("remote and local EIDs are of different types!");
15311 M (ONE_ADD_DEL_ADJACENCY, mp);
15312 mp->is_add = is_add;
15313 mp->vni = htonl (vni);
15314 mp->leid_len = leid_len;
15315 mp->reid_len = reid_len;
15316 mp->eid_type = reid_type;
15318 switch (mp->eid_type)
15321 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
15322 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
15325 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
15326 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
15329 clib_memcpy (mp->leid, leid_mac, 6);
15330 clib_memcpy (mp->reid, reid_mac, 6);
15333 errmsg ("unknown EID type %d!", mp->eid_type);
15340 /* Wait for a reply... */
15345 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
15348 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
15350 u32 *mode = va_arg (*args, u32 *);
15352 if (unformat (input, "lisp"))
15354 else if (unformat (input, "vxlan"))
15363 api_gpe_get_encap_mode (vat_main_t * vam)
15365 vl_api_gpe_get_encap_mode_t *mp;
15368 /* Construct the API message */
15369 M (GPE_GET_ENCAP_MODE, mp);
15374 /* Wait for a reply... */
15380 api_gpe_set_encap_mode (vat_main_t * vam)
15382 unformat_input_t *input = vam->input;
15383 vl_api_gpe_set_encap_mode_t *mp;
15387 /* Parse args required to build the message */
15388 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15390 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
15396 /* Construct the API message */
15397 M (GPE_SET_ENCAP_MODE, mp);
15404 /* Wait for a reply... */
15410 api_lisp_gpe_add_del_iface (vat_main_t * vam)
15412 unformat_input_t *input = vam->input;
15413 vl_api_gpe_add_del_iface_t *mp;
15414 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
15415 u32 dp_table = 0, vni = 0;
15418 /* Parse args required to build the message */
15419 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15421 if (unformat (input, "up"))
15426 else if (unformat (input, "down"))
15431 else if (unformat (input, "table_id %d", &dp_table))
15435 else if (unformat (input, "bd_id %d", &dp_table))
15440 else if (unformat (input, "vni %d", &vni))
15448 if (action_set == 0)
15450 errmsg ("Action not set");
15453 if (dp_table_set == 0 || vni_set == 0)
15455 errmsg ("vni and dp_table must be set");
15459 /* Construct the API message */
15460 M (GPE_ADD_DEL_IFACE, mp);
15462 mp->is_add = is_add;
15463 mp->dp_table = dp_table;
15470 /* Wait for a reply... */
15476 * Add/del map request itr rlocs from ONE control plane and updates
15478 * @param vam vpp API test context
15479 * @return return code
15482 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
15484 unformat_input_t *input = vam->input;
15485 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
15486 u8 *locator_set_name = 0;
15487 u8 locator_set_name_set = 0;
15491 /* Parse args required to build the message */
15492 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15494 if (unformat (input, "del"))
15498 else if (unformat (input, "%_%v%_", &locator_set_name))
15500 locator_set_name_set = 1;
15504 clib_warning ("parse error '%U'", format_unformat_error, input);
15509 if (is_add && !locator_set_name_set)
15511 errmsg ("itr-rloc is not set!");
15515 if (is_add && vec_len (locator_set_name) > 64)
15517 errmsg ("itr-rloc locator-set name too long");
15518 vec_free (locator_set_name);
15522 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
15523 mp->is_add = is_add;
15526 clib_memcpy (mp->locator_set_name, locator_set_name,
15527 vec_len (locator_set_name));
15531 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
15533 vec_free (locator_set_name);
15538 /* Wait for a reply... */
15543 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
15546 api_one_locator_dump (vat_main_t * vam)
15548 unformat_input_t *input = vam->input;
15549 vl_api_one_locator_dump_t *mp;
15550 vl_api_control_ping_t *mp_ping;
15551 u8 is_index_set = 0, is_name_set = 0;
15556 /* Parse args required to build the message */
15557 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15559 if (unformat (input, "ls_name %_%v%_", &ls_name))
15563 else if (unformat (input, "ls_index %d", &ls_index))
15569 errmsg ("parse error '%U'", format_unformat_error, input);
15574 if (!is_index_set && !is_name_set)
15576 errmsg ("error: expected one of index or name!");
15580 if (is_index_set && is_name_set)
15582 errmsg ("error: only one param expected!");
15586 if (vec_len (ls_name) > 62)
15588 errmsg ("error: locator set name too long!");
15592 if (!vam->json_output)
15594 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
15597 M (ONE_LOCATOR_DUMP, mp);
15598 mp->is_index_set = is_index_set;
15601 mp->ls_index = clib_host_to_net_u32 (ls_index);
15604 vec_add1 (ls_name, 0);
15605 strncpy ((char *) mp->ls_name, (char *) ls_name,
15606 sizeof (mp->ls_name) - 1);
15612 /* Use a control ping for synchronization */
15613 M (CONTROL_PING, mp_ping);
15616 /* Wait for a reply... */
15621 #define api_lisp_locator_dump api_one_locator_dump
15624 api_one_locator_set_dump (vat_main_t * vam)
15626 vl_api_one_locator_set_dump_t *mp;
15627 vl_api_control_ping_t *mp_ping;
15628 unformat_input_t *input = vam->input;
15632 /* Parse args required to build the message */
15633 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15635 if (unformat (input, "local"))
15639 else if (unformat (input, "remote"))
15645 errmsg ("parse error '%U'", format_unformat_error, input);
15650 if (!vam->json_output)
15652 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
15655 M (ONE_LOCATOR_SET_DUMP, mp);
15657 mp->filter = filter;
15662 /* Use a control ping for synchronization */
15663 M (CONTROL_PING, mp_ping);
15666 /* Wait for a reply... */
15671 #define api_lisp_locator_set_dump api_one_locator_set_dump
15674 api_one_eid_table_map_dump (vat_main_t * vam)
15678 unformat_input_t *input = vam->input;
15679 vl_api_one_eid_table_map_dump_t *mp;
15680 vl_api_control_ping_t *mp_ping;
15683 /* Parse args required to build the message */
15684 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15686 if (unformat (input, "l2"))
15691 else if (unformat (input, "l3"))
15698 errmsg ("parse error '%U'", format_unformat_error, input);
15705 errmsg ("expected one of 'l2' or 'l3' parameter!");
15709 if (!vam->json_output)
15711 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
15714 M (ONE_EID_TABLE_MAP_DUMP, mp);
15720 /* Use a control ping for synchronization */
15721 M (CONTROL_PING, mp_ping);
15724 /* Wait for a reply... */
15729 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
15732 api_one_eid_table_vni_dump (vat_main_t * vam)
15734 vl_api_one_eid_table_vni_dump_t *mp;
15735 vl_api_control_ping_t *mp_ping;
15738 if (!vam->json_output)
15740 print (vam->ofp, "VNI");
15743 M (ONE_EID_TABLE_VNI_DUMP, mp);
15748 /* Use a control ping for synchronization */
15749 M (CONTROL_PING, mp_ping);
15752 /* Wait for a reply... */
15757 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
15760 api_one_eid_table_dump (vat_main_t * vam)
15762 unformat_input_t *i = vam->input;
15763 vl_api_one_eid_table_dump_t *mp;
15764 vl_api_control_ping_t *mp_ping;
15765 struct in_addr ip4;
15766 struct in6_addr ip6;
15768 u8 eid_type = ~0, eid_set = 0;
15769 u32 prefix_length = ~0, t, vni = 0;
15773 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15775 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
15781 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
15787 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
15792 else if (unformat (i, "vni %d", &t))
15796 else if (unformat (i, "local"))
15800 else if (unformat (i, "remote"))
15806 errmsg ("parse error '%U'", format_unformat_error, i);
15811 if (!vam->json_output)
15813 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
15814 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
15817 M (ONE_EID_TABLE_DUMP, mp);
15819 mp->filter = filter;
15823 mp->vni = htonl (vni);
15824 mp->eid_type = eid_type;
15828 mp->prefix_length = prefix_length;
15829 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
15832 mp->prefix_length = prefix_length;
15833 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
15836 clib_memcpy (mp->eid, mac, sizeof (mac));
15839 errmsg ("unknown EID type %d!", eid_type);
15847 /* Use a control ping for synchronization */
15848 M (CONTROL_PING, mp_ping);
15851 /* Wait for a reply... */
15856 #define api_lisp_eid_table_dump api_one_eid_table_dump
15859 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
15861 unformat_input_t *i = vam->input;
15862 vl_api_gpe_fwd_entries_get_t *mp;
15867 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15869 if (unformat (i, "vni %d", &vni))
15875 errmsg ("parse error '%U'", format_unformat_error, i);
15882 errmsg ("vni not set!");
15886 if (!vam->json_output)
15888 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15892 M (GPE_FWD_ENTRIES_GET, mp);
15893 mp->vni = clib_host_to_net_u32 (vni);
15898 /* Wait for a reply... */
15903 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15904 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15905 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15906 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
15909 api_one_adjacencies_get (vat_main_t * vam)
15911 unformat_input_t *i = vam->input;
15912 vl_api_one_adjacencies_get_t *mp;
15917 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15919 if (unformat (i, "vni %d", &vni))
15925 errmsg ("parse error '%U'", format_unformat_error, i);
15932 errmsg ("vni not set!");
15936 if (!vam->json_output)
15938 print (vam->ofp, "%s %40s", "leid", "reid");
15941 M (ONE_ADJACENCIES_GET, mp);
15942 mp->vni = clib_host_to_net_u32 (vni);
15947 /* Wait for a reply... */
15952 #define api_lisp_adjacencies_get api_one_adjacencies_get
15955 api_one_map_server_dump (vat_main_t * vam)
15957 vl_api_one_map_server_dump_t *mp;
15958 vl_api_control_ping_t *mp_ping;
15961 if (!vam->json_output)
15963 print (vam->ofp, "%=20s", "Map server");
15966 M (ONE_MAP_SERVER_DUMP, mp);
15970 /* Use a control ping for synchronization */
15971 M (CONTROL_PING, mp_ping);
15974 /* Wait for a reply... */
15979 #define api_lisp_map_server_dump api_one_map_server_dump
15982 api_one_map_resolver_dump (vat_main_t * vam)
15984 vl_api_one_map_resolver_dump_t *mp;
15985 vl_api_control_ping_t *mp_ping;
15988 if (!vam->json_output)
15990 print (vam->ofp, "%=20s", "Map resolver");
15993 M (ONE_MAP_RESOLVER_DUMP, mp);
15997 /* Use a control ping for synchronization */
15998 M (CONTROL_PING, mp_ping);
16001 /* Wait for a reply... */
16006 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
16009 api_one_stats_flush (vat_main_t * vam)
16011 vl_api_one_stats_flush_t *mp;
16014 M (ONE_STATS_FLUSH, mp);
16021 api_one_stats_dump (vat_main_t * vam)
16023 vl_api_one_stats_dump_t *mp;
16024 vl_api_control_ping_t *mp_ping;
16027 M (ONE_STATS_DUMP, mp);
16031 /* Use a control ping for synchronization */
16032 M (CONTROL_PING, mp_ping);
16035 /* Wait for a reply... */
16041 api_show_one_status (vat_main_t * vam)
16043 vl_api_show_one_status_t *mp;
16046 if (!vam->json_output)
16048 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
16051 M (SHOW_ONE_STATUS, mp);
16054 /* Wait for a reply... */
16059 #define api_show_lisp_status api_show_one_status
16062 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
16064 vl_api_gpe_fwd_entry_path_dump_t *mp;
16065 vl_api_control_ping_t *mp_ping;
16066 unformat_input_t *i = vam->input;
16067 u32 fwd_entry_index = ~0;
16070 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16072 if (unformat (i, "index %d", &fwd_entry_index))
16078 if (~0 == fwd_entry_index)
16080 errmsg ("no index specified!");
16084 if (!vam->json_output)
16086 print (vam->ofp, "first line");
16089 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
16093 /* Use a control ping for synchronization */
16094 M (CONTROL_PING, mp_ping);
16097 /* Wait for a reply... */
16103 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
16105 vl_api_one_get_map_request_itr_rlocs_t *mp;
16108 if (!vam->json_output)
16110 print (vam->ofp, "%=20s", "itr-rlocs:");
16113 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
16116 /* Wait for a reply... */
16121 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
16124 api_af_packet_create (vat_main_t * vam)
16126 unformat_input_t *i = vam->input;
16127 vl_api_af_packet_create_t *mp;
16128 u8 *host_if_name = 0;
16130 u8 random_hw_addr = 1;
16133 memset (hw_addr, 0, sizeof (hw_addr));
16135 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16137 if (unformat (i, "name %s", &host_if_name))
16138 vec_add1 (host_if_name, 0);
16139 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16140 random_hw_addr = 0;
16145 if (!vec_len (host_if_name))
16147 errmsg ("host-interface name must be specified");
16151 if (vec_len (host_if_name) > 64)
16153 errmsg ("host-interface name too long");
16157 M (AF_PACKET_CREATE, mp);
16159 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16160 clib_memcpy (mp->hw_addr, hw_addr, 6);
16161 mp->use_random_hw_addr = random_hw_addr;
16162 vec_free (host_if_name);
16170 fprintf (vam->ofp ? vam->ofp : stderr,
16171 " new sw_if_index = %d\n", vam->sw_if_index);
16178 api_af_packet_delete (vat_main_t * vam)
16180 unformat_input_t *i = vam->input;
16181 vl_api_af_packet_delete_t *mp;
16182 u8 *host_if_name = 0;
16185 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16187 if (unformat (i, "name %s", &host_if_name))
16188 vec_add1 (host_if_name, 0);
16193 if (!vec_len (host_if_name))
16195 errmsg ("host-interface name must be specified");
16199 if (vec_len (host_if_name) > 64)
16201 errmsg ("host-interface name too long");
16205 M (AF_PACKET_DELETE, mp);
16207 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16208 vec_free (host_if_name);
16216 api_policer_add_del (vat_main_t * vam)
16218 unformat_input_t *i = vam->input;
16219 vl_api_policer_add_del_t *mp;
16229 u8 color_aware = 0;
16230 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
16233 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
16234 conform_action.dscp = 0;
16235 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
16236 exceed_action.dscp = 0;
16237 violate_action.action_type = SSE2_QOS_ACTION_DROP;
16238 violate_action.dscp = 0;
16240 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16242 if (unformat (i, "del"))
16244 else if (unformat (i, "name %s", &name))
16245 vec_add1 (name, 0);
16246 else if (unformat (i, "cir %u", &cir))
16248 else if (unformat (i, "eir %u", &eir))
16250 else if (unformat (i, "cb %u", &cb))
16252 else if (unformat (i, "eb %u", &eb))
16254 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
16257 else if (unformat (i, "round_type %U", unformat_policer_round_type,
16260 else if (unformat (i, "type %U", unformat_policer_type, &type))
16262 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
16265 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
16268 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
16271 else if (unformat (i, "color-aware"))
16277 if (!vec_len (name))
16279 errmsg ("policer name must be specified");
16283 if (vec_len (name) > 64)
16285 errmsg ("policer name too long");
16289 M (POLICER_ADD_DEL, mp);
16291 clib_memcpy (mp->name, name, vec_len (name));
16293 mp->is_add = is_add;
16298 mp->rate_type = rate_type;
16299 mp->round_type = round_type;
16301 mp->conform_action_type = conform_action.action_type;
16302 mp->conform_dscp = conform_action.dscp;
16303 mp->exceed_action_type = exceed_action.action_type;
16304 mp->exceed_dscp = exceed_action.dscp;
16305 mp->violate_action_type = violate_action.action_type;
16306 mp->violate_dscp = violate_action.dscp;
16307 mp->color_aware = color_aware;
16315 api_policer_dump (vat_main_t * vam)
16317 unformat_input_t *i = vam->input;
16318 vl_api_policer_dump_t *mp;
16319 vl_api_control_ping_t *mp_ping;
16320 u8 *match_name = 0;
16321 u8 match_name_valid = 0;
16324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16326 if (unformat (i, "name %s", &match_name))
16328 vec_add1 (match_name, 0);
16329 match_name_valid = 1;
16335 M (POLICER_DUMP, mp);
16336 mp->match_name_valid = match_name_valid;
16337 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
16338 vec_free (match_name);
16342 /* Use a control ping for synchronization */
16343 M (CONTROL_PING, mp_ping);
16346 /* Wait for a reply... */
16352 api_policer_classify_set_interface (vat_main_t * vam)
16354 unformat_input_t *i = vam->input;
16355 vl_api_policer_classify_set_interface_t *mp;
16357 int sw_if_index_set;
16358 u32 ip4_table_index = ~0;
16359 u32 ip6_table_index = ~0;
16360 u32 l2_table_index = ~0;
16364 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16366 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16367 sw_if_index_set = 1;
16368 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16369 sw_if_index_set = 1;
16370 else if (unformat (i, "del"))
16372 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16374 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16376 else if (unformat (i, "l2-table %d", &l2_table_index))
16380 clib_warning ("parse error '%U'", format_unformat_error, i);
16385 if (sw_if_index_set == 0)
16387 errmsg ("missing interface name or sw_if_index");
16391 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
16393 mp->sw_if_index = ntohl (sw_if_index);
16394 mp->ip4_table_index = ntohl (ip4_table_index);
16395 mp->ip6_table_index = ntohl (ip6_table_index);
16396 mp->l2_table_index = ntohl (l2_table_index);
16397 mp->is_add = is_add;
16405 api_policer_classify_dump (vat_main_t * vam)
16407 unformat_input_t *i = vam->input;
16408 vl_api_policer_classify_dump_t *mp;
16409 vl_api_control_ping_t *mp_ping;
16410 u8 type = POLICER_CLASSIFY_N_TABLES;
16413 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
16417 errmsg ("classify table type must be specified");
16421 if (!vam->json_output)
16423 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
16426 M (POLICER_CLASSIFY_DUMP, mp);
16431 /* Use a control ping for synchronization */
16432 M (CONTROL_PING, mp_ping);
16435 /* Wait for a reply... */
16441 api_netmap_create (vat_main_t * vam)
16443 unformat_input_t *i = vam->input;
16444 vl_api_netmap_create_t *mp;
16447 u8 random_hw_addr = 1;
16452 memset (hw_addr, 0, sizeof (hw_addr));
16454 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16456 if (unformat (i, "name %s", &if_name))
16457 vec_add1 (if_name, 0);
16458 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16459 random_hw_addr = 0;
16460 else if (unformat (i, "pipe"))
16462 else if (unformat (i, "master"))
16464 else if (unformat (i, "slave"))
16470 if (!vec_len (if_name))
16472 errmsg ("interface name must be specified");
16476 if (vec_len (if_name) > 64)
16478 errmsg ("interface name too long");
16482 M (NETMAP_CREATE, mp);
16484 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16485 clib_memcpy (mp->hw_addr, hw_addr, 6);
16486 mp->use_random_hw_addr = random_hw_addr;
16487 mp->is_pipe = is_pipe;
16488 mp->is_master = is_master;
16489 vec_free (if_name);
16497 api_netmap_delete (vat_main_t * vam)
16499 unformat_input_t *i = vam->input;
16500 vl_api_netmap_delete_t *mp;
16504 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16506 if (unformat (i, "name %s", &if_name))
16507 vec_add1 (if_name, 0);
16512 if (!vec_len (if_name))
16514 errmsg ("interface name must be specified");
16518 if (vec_len (if_name) > 64)
16520 errmsg ("interface name too long");
16524 M (NETMAP_DELETE, mp);
16526 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16527 vec_free (if_name);
16535 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
16537 if (fp->afi == IP46_TYPE_IP6)
16539 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16540 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16541 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16542 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16543 format_ip6_address, fp->next_hop);
16544 else if (fp->afi == IP46_TYPE_IP4)
16546 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16547 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16548 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16549 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16550 format_ip4_address, fp->next_hop);
16554 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
16555 vl_api_fib_path2_t * fp)
16557 struct in_addr ip4;
16558 struct in6_addr ip6;
16560 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16561 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16562 vat_json_object_add_uint (node, "is_local", fp->is_local);
16563 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16564 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16565 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16566 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16567 if (fp->afi == IP46_TYPE_IP4)
16569 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16570 vat_json_object_add_ip4 (node, "next_hop", ip4);
16572 else if (fp->afi == IP46_TYPE_IP6)
16574 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16575 vat_json_object_add_ip6 (node, "next_hop", ip6);
16580 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
16582 vat_main_t *vam = &vat_main;
16583 int count = ntohl (mp->mt_count);
16584 vl_api_fib_path2_t *fp;
16587 print (vam->ofp, "[%d]: sw_if_index %d via:",
16588 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
16590 for (i = 0; i < count; i++)
16592 vl_api_mpls_fib_path_print (vam, fp);
16596 print (vam->ofp, "");
16599 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
16600 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
16603 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
16605 vat_main_t *vam = &vat_main;
16606 vat_json_node_t *node = NULL;
16607 int count = ntohl (mp->mt_count);
16608 vl_api_fib_path2_t *fp;
16611 if (VAT_JSON_ARRAY != vam->json_tree.type)
16613 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16614 vat_json_init_array (&vam->json_tree);
16616 node = vat_json_array_add (&vam->json_tree);
16618 vat_json_init_object (node);
16619 vat_json_object_add_uint (node, "tunnel_index",
16620 ntohl (mp->mt_tunnel_index));
16621 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
16623 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
16626 for (i = 0; i < count; i++)
16628 vl_api_mpls_fib_path_json_print (node, fp);
16634 api_mpls_tunnel_dump (vat_main_t * vam)
16636 vl_api_mpls_tunnel_dump_t *mp;
16637 vl_api_control_ping_t *mp_ping;
16641 /* Parse args required to build the message */
16642 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
16644 if (!unformat (vam->input, "tunnel_index %d", &index))
16651 print (vam->ofp, " tunnel_index %d", index);
16653 M (MPLS_TUNNEL_DUMP, mp);
16654 mp->tunnel_index = htonl (index);
16657 /* Use a control ping for synchronization */
16658 M (CONTROL_PING, mp_ping);
16665 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
16666 #define vl_api_mpls_fib_details_t_print vl_noop_handler
16670 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
16672 vat_main_t *vam = &vat_main;
16673 int count = ntohl (mp->count);
16674 vl_api_fib_path2_t *fp;
16678 "table-id %d, label %u, ess_bit %u",
16679 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
16681 for (i = 0; i < count; i++)
16683 vl_api_mpls_fib_path_print (vam, fp);
16688 static void vl_api_mpls_fib_details_t_handler_json
16689 (vl_api_mpls_fib_details_t * mp)
16691 vat_main_t *vam = &vat_main;
16692 int count = ntohl (mp->count);
16693 vat_json_node_t *node = NULL;
16694 vl_api_fib_path2_t *fp;
16697 if (VAT_JSON_ARRAY != vam->json_tree.type)
16699 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16700 vat_json_init_array (&vam->json_tree);
16702 node = vat_json_array_add (&vam->json_tree);
16704 vat_json_init_object (node);
16705 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16706 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
16707 vat_json_object_add_uint (node, "label", ntohl (mp->label));
16708 vat_json_object_add_uint (node, "path_count", count);
16710 for (i = 0; i < count; i++)
16712 vl_api_mpls_fib_path_json_print (node, fp);
16718 api_mpls_fib_dump (vat_main_t * vam)
16720 vl_api_mpls_fib_dump_t *mp;
16721 vl_api_control_ping_t *mp_ping;
16724 M (MPLS_FIB_DUMP, mp);
16727 /* Use a control ping for synchronization */
16728 M (CONTROL_PING, mp_ping);
16735 #define vl_api_ip_fib_details_t_endian vl_noop_handler
16736 #define vl_api_ip_fib_details_t_print vl_noop_handler
16739 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
16741 vat_main_t *vam = &vat_main;
16742 int count = ntohl (mp->count);
16743 vl_api_fib_path_t *fp;
16747 "table-id %d, prefix %U/%d",
16748 ntohl (mp->table_id), format_ip4_address, mp->address,
16749 mp->address_length);
16751 for (i = 0; i < count; i++)
16753 if (fp->afi == IP46_TYPE_IP6)
16755 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16756 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16757 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16758 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16759 format_ip6_address, fp->next_hop);
16760 else if (fp->afi == IP46_TYPE_IP4)
16762 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16763 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16764 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16765 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16766 format_ip4_address, fp->next_hop);
16771 static void vl_api_ip_fib_details_t_handler_json
16772 (vl_api_ip_fib_details_t * mp)
16774 vat_main_t *vam = &vat_main;
16775 int count = ntohl (mp->count);
16776 vat_json_node_t *node = NULL;
16777 struct in_addr ip4;
16778 struct in6_addr ip6;
16779 vl_api_fib_path_t *fp;
16782 if (VAT_JSON_ARRAY != vam->json_tree.type)
16784 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16785 vat_json_init_array (&vam->json_tree);
16787 node = vat_json_array_add (&vam->json_tree);
16789 vat_json_init_object (node);
16790 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16791 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
16792 vat_json_object_add_ip4 (node, "prefix", ip4);
16793 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16794 vat_json_object_add_uint (node, "path_count", count);
16796 for (i = 0; i < count; i++)
16798 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16799 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16800 vat_json_object_add_uint (node, "is_local", fp->is_local);
16801 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16802 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16803 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16804 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16805 if (fp->afi == IP46_TYPE_IP4)
16807 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16808 vat_json_object_add_ip4 (node, "next_hop", ip4);
16810 else if (fp->afi == IP46_TYPE_IP6)
16812 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16813 vat_json_object_add_ip6 (node, "next_hop", ip6);
16819 api_ip_fib_dump (vat_main_t * vam)
16821 vl_api_ip_fib_dump_t *mp;
16822 vl_api_control_ping_t *mp_ping;
16825 M (IP_FIB_DUMP, mp);
16828 /* Use a control ping for synchronization */
16829 M (CONTROL_PING, mp_ping);
16837 api_ip_mfib_dump (vat_main_t * vam)
16839 vl_api_ip_mfib_dump_t *mp;
16840 vl_api_control_ping_t *mp_ping;
16843 M (IP_MFIB_DUMP, mp);
16846 /* Use a control ping for synchronization */
16847 M (CONTROL_PING, mp_ping);
16854 static void vl_api_ip_neighbor_details_t_handler
16855 (vl_api_ip_neighbor_details_t * mp)
16857 vat_main_t *vam = &vat_main;
16859 print (vam->ofp, "%c %U %U",
16860 (mp->is_static) ? 'S' : 'D',
16861 format_ethernet_address, &mp->mac_address,
16862 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
16866 static void vl_api_ip_neighbor_details_t_handler_json
16867 (vl_api_ip_neighbor_details_t * mp)
16870 vat_main_t *vam = &vat_main;
16871 vat_json_node_t *node;
16872 struct in_addr ip4;
16873 struct in6_addr ip6;
16875 if (VAT_JSON_ARRAY != vam->json_tree.type)
16877 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16878 vat_json_init_array (&vam->json_tree);
16880 node = vat_json_array_add (&vam->json_tree);
16882 vat_json_init_object (node);
16883 vat_json_object_add_string_copy (node, "flag",
16884 (mp->is_static) ? (u8 *) "static" : (u8 *)
16887 vat_json_object_add_string_copy (node, "link_layer",
16888 format (0, "%U", format_ethernet_address,
16889 &mp->mac_address));
16893 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
16894 vat_json_object_add_ip6 (node, "ip_address", ip6);
16898 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
16899 vat_json_object_add_ip4 (node, "ip_address", ip4);
16904 api_ip_neighbor_dump (vat_main_t * vam)
16906 unformat_input_t *i = vam->input;
16907 vl_api_ip_neighbor_dump_t *mp;
16908 vl_api_control_ping_t *mp_ping;
16910 u32 sw_if_index = ~0;
16913 /* Parse args required to build the message */
16914 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16916 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16918 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16920 else if (unformat (i, "ip6"))
16926 if (sw_if_index == ~0)
16928 errmsg ("missing interface name or sw_if_index");
16932 M (IP_NEIGHBOR_DUMP, mp);
16933 mp->is_ipv6 = (u8) is_ipv6;
16934 mp->sw_if_index = ntohl (sw_if_index);
16937 /* Use a control ping for synchronization */
16938 M (CONTROL_PING, mp_ping);
16945 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
16946 #define vl_api_ip6_fib_details_t_print vl_noop_handler
16949 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
16951 vat_main_t *vam = &vat_main;
16952 int count = ntohl (mp->count);
16953 vl_api_fib_path_t *fp;
16957 "table-id %d, prefix %U/%d",
16958 ntohl (mp->table_id), format_ip6_address, mp->address,
16959 mp->address_length);
16961 for (i = 0; i < count; i++)
16963 if (fp->afi == IP46_TYPE_IP6)
16965 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16966 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16967 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16968 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16969 format_ip6_address, fp->next_hop);
16970 else if (fp->afi == IP46_TYPE_IP4)
16972 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16973 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16974 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16975 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16976 format_ip4_address, fp->next_hop);
16981 static void vl_api_ip6_fib_details_t_handler_json
16982 (vl_api_ip6_fib_details_t * mp)
16984 vat_main_t *vam = &vat_main;
16985 int count = ntohl (mp->count);
16986 vat_json_node_t *node = NULL;
16987 struct in_addr ip4;
16988 struct in6_addr ip6;
16989 vl_api_fib_path_t *fp;
16992 if (VAT_JSON_ARRAY != vam->json_tree.type)
16994 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16995 vat_json_init_array (&vam->json_tree);
16997 node = vat_json_array_add (&vam->json_tree);
16999 vat_json_init_object (node);
17000 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17001 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
17002 vat_json_object_add_ip6 (node, "prefix", ip6);
17003 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17004 vat_json_object_add_uint (node, "path_count", count);
17006 for (i = 0; i < count; i++)
17008 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17009 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17010 vat_json_object_add_uint (node, "is_local", fp->is_local);
17011 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17012 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17013 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17014 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17015 if (fp->afi == IP46_TYPE_IP4)
17017 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17018 vat_json_object_add_ip4 (node, "next_hop", ip4);
17020 else if (fp->afi == IP46_TYPE_IP6)
17022 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17023 vat_json_object_add_ip6 (node, "next_hop", ip6);
17029 api_ip6_fib_dump (vat_main_t * vam)
17031 vl_api_ip6_fib_dump_t *mp;
17032 vl_api_control_ping_t *mp_ping;
17035 M (IP6_FIB_DUMP, mp);
17038 /* Use a control ping for synchronization */
17039 M (CONTROL_PING, mp_ping);
17047 api_ip6_mfib_dump (vat_main_t * vam)
17049 vl_api_ip6_mfib_dump_t *mp;
17050 vl_api_control_ping_t *mp_ping;
17053 M (IP6_MFIB_DUMP, mp);
17056 /* Use a control ping for synchronization */
17057 M (CONTROL_PING, mp_ping);
17065 api_classify_table_ids (vat_main_t * vam)
17067 vl_api_classify_table_ids_t *mp;
17070 /* Construct the API message */
17071 M (CLASSIFY_TABLE_IDS, mp);
17080 api_classify_table_by_interface (vat_main_t * vam)
17082 unformat_input_t *input = vam->input;
17083 vl_api_classify_table_by_interface_t *mp;
17085 u32 sw_if_index = ~0;
17087 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17089 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17091 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17096 if (sw_if_index == ~0)
17098 errmsg ("missing interface name or sw_if_index");
17102 /* Construct the API message */
17103 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
17105 mp->sw_if_index = ntohl (sw_if_index);
17113 api_classify_table_info (vat_main_t * vam)
17115 unformat_input_t *input = vam->input;
17116 vl_api_classify_table_info_t *mp;
17120 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17122 if (unformat (input, "table_id %d", &table_id))
17127 if (table_id == ~0)
17129 errmsg ("missing table id");
17133 /* Construct the API message */
17134 M (CLASSIFY_TABLE_INFO, mp);
17136 mp->table_id = ntohl (table_id);
17144 api_classify_session_dump (vat_main_t * vam)
17146 unformat_input_t *input = vam->input;
17147 vl_api_classify_session_dump_t *mp;
17148 vl_api_control_ping_t *mp_ping;
17152 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17154 if (unformat (input, "table_id %d", &table_id))
17159 if (table_id == ~0)
17161 errmsg ("missing table id");
17165 /* Construct the API message */
17166 M (CLASSIFY_SESSION_DUMP, mp);
17168 mp->table_id = ntohl (table_id);
17171 /* Use a control ping for synchronization */
17172 M (CONTROL_PING, mp_ping);
17180 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
17182 vat_main_t *vam = &vat_main;
17184 print (vam->ofp, "collector_address %U, collector_port %d, "
17185 "src_address %U, vrf_id %d, path_mtu %u, "
17186 "template_interval %u, udp_checksum %d",
17187 format_ip4_address, mp->collector_address,
17188 ntohs (mp->collector_port),
17189 format_ip4_address, mp->src_address,
17190 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
17191 ntohl (mp->template_interval), mp->udp_checksum);
17194 vam->result_ready = 1;
17198 vl_api_ipfix_exporter_details_t_handler_json
17199 (vl_api_ipfix_exporter_details_t * mp)
17201 vat_main_t *vam = &vat_main;
17202 vat_json_node_t node;
17203 struct in_addr collector_address;
17204 struct in_addr src_address;
17206 vat_json_init_object (&node);
17207 clib_memcpy (&collector_address, &mp->collector_address,
17208 sizeof (collector_address));
17209 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
17210 vat_json_object_add_uint (&node, "collector_port",
17211 ntohs (mp->collector_port));
17212 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
17213 vat_json_object_add_ip4 (&node, "src_address", src_address);
17214 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
17215 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
17216 vat_json_object_add_uint (&node, "template_interval",
17217 ntohl (mp->template_interval));
17218 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
17220 vat_json_print (vam->ofp, &node);
17221 vat_json_free (&node);
17223 vam->result_ready = 1;
17227 api_ipfix_exporter_dump (vat_main_t * vam)
17229 vl_api_ipfix_exporter_dump_t *mp;
17232 /* Construct the API message */
17233 M (IPFIX_EXPORTER_DUMP, mp);
17242 api_ipfix_classify_stream_dump (vat_main_t * vam)
17244 vl_api_ipfix_classify_stream_dump_t *mp;
17247 /* Construct the API message */
17248 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
17259 vl_api_ipfix_classify_stream_details_t_handler
17260 (vl_api_ipfix_classify_stream_details_t * mp)
17262 vat_main_t *vam = &vat_main;
17263 print (vam->ofp, "domain_id %d, src_port %d",
17264 ntohl (mp->domain_id), ntohs (mp->src_port));
17266 vam->result_ready = 1;
17270 vl_api_ipfix_classify_stream_details_t_handler_json
17271 (vl_api_ipfix_classify_stream_details_t * mp)
17273 vat_main_t *vam = &vat_main;
17274 vat_json_node_t node;
17276 vat_json_init_object (&node);
17277 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
17278 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
17280 vat_json_print (vam->ofp, &node);
17281 vat_json_free (&node);
17283 vam->result_ready = 1;
17287 api_ipfix_classify_table_dump (vat_main_t * vam)
17289 vl_api_ipfix_classify_table_dump_t *mp;
17290 vl_api_control_ping_t *mp_ping;
17293 if (!vam->json_output)
17295 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
17296 "transport_protocol");
17299 /* Construct the API message */
17300 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
17305 /* Use a control ping for synchronization */
17306 M (CONTROL_PING, mp_ping);
17314 vl_api_ipfix_classify_table_details_t_handler
17315 (vl_api_ipfix_classify_table_details_t * mp)
17317 vat_main_t *vam = &vat_main;
17318 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
17319 mp->transport_protocol);
17323 vl_api_ipfix_classify_table_details_t_handler_json
17324 (vl_api_ipfix_classify_table_details_t * mp)
17326 vat_json_node_t *node = NULL;
17327 vat_main_t *vam = &vat_main;
17329 if (VAT_JSON_ARRAY != vam->json_tree.type)
17331 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17332 vat_json_init_array (&vam->json_tree);
17335 node = vat_json_array_add (&vam->json_tree);
17336 vat_json_init_object (node);
17338 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
17339 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
17340 vat_json_object_add_uint (node, "transport_protocol",
17341 mp->transport_protocol);
17345 api_sw_interface_span_enable_disable (vat_main_t * vam)
17347 unformat_input_t *i = vam->input;
17348 vl_api_sw_interface_span_enable_disable_t *mp;
17349 u32 src_sw_if_index = ~0;
17350 u32 dst_sw_if_index = ~0;
17354 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17357 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
17359 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
17363 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
17365 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
17367 else if (unformat (i, "disable"))
17369 else if (unformat (i, "rx"))
17371 else if (unformat (i, "tx"))
17373 else if (unformat (i, "both"))
17379 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
17381 mp->sw_if_index_from = htonl (src_sw_if_index);
17382 mp->sw_if_index_to = htonl (dst_sw_if_index);
17391 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
17394 vat_main_t *vam = &vat_main;
17395 u8 *sw_if_from_name = 0;
17396 u8 *sw_if_to_name = 0;
17397 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17398 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17399 char *states[] = { "none", "rx", "tx", "both" };
17403 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17405 if ((u32) p->value[0] == sw_if_index_from)
17407 sw_if_from_name = (u8 *)(p->key);
17411 if ((u32) p->value[0] == sw_if_index_to)
17413 sw_if_to_name = (u8 *)(p->key);
17414 if (sw_if_from_name)
17419 print (vam->ofp, "%20s => %20s (%s)",
17420 sw_if_from_name, sw_if_to_name, states[mp->state]);
17424 vl_api_sw_interface_span_details_t_handler_json
17425 (vl_api_sw_interface_span_details_t * mp)
17427 vat_main_t *vam = &vat_main;
17428 vat_json_node_t *node = NULL;
17429 u8 *sw_if_from_name = 0;
17430 u8 *sw_if_to_name = 0;
17431 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17432 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17436 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17438 if ((u32) p->value[0] == sw_if_index_from)
17440 sw_if_from_name = (u8 *)(p->key);
17444 if ((u32) p->value[0] == sw_if_index_to)
17446 sw_if_to_name = (u8 *)(p->key);
17447 if (sw_if_from_name)
17453 if (VAT_JSON_ARRAY != vam->json_tree.type)
17455 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17456 vat_json_init_array (&vam->json_tree);
17458 node = vat_json_array_add (&vam->json_tree);
17460 vat_json_init_object (node);
17461 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
17462 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
17463 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
17464 if (0 != sw_if_to_name)
17466 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
17468 vat_json_object_add_uint (node, "state", mp->state);
17472 api_sw_interface_span_dump (vat_main_t * vam)
17474 vl_api_sw_interface_span_dump_t *mp;
17475 vl_api_control_ping_t *mp_ping;
17478 M (SW_INTERFACE_SPAN_DUMP, mp);
17481 /* Use a control ping for synchronization */
17482 M (CONTROL_PING, mp_ping);
17490 api_pg_create_interface (vat_main_t * vam)
17492 unformat_input_t *input = vam->input;
17493 vl_api_pg_create_interface_t *mp;
17497 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17499 if (unformat (input, "if_id %d", &if_id))
17506 errmsg ("missing pg interface index");
17510 /* Construct the API message */
17511 M (PG_CREATE_INTERFACE, mp);
17513 mp->interface_id = ntohl (if_id);
17521 api_pg_capture (vat_main_t * vam)
17523 unformat_input_t *input = vam->input;
17524 vl_api_pg_capture_t *mp;
17529 u8 pcap_file_set = 0;
17532 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17534 if (unformat (input, "if_id %d", &if_id))
17536 else if (unformat (input, "pcap %s", &pcap_file))
17538 else if (unformat (input, "count %d", &count))
17540 else if (unformat (input, "disable"))
17547 errmsg ("missing pg interface index");
17550 if (pcap_file_set > 0)
17552 if (vec_len (pcap_file) > 255)
17554 errmsg ("pcap file name is too long");
17559 u32 name_len = vec_len (pcap_file);
17560 /* Construct the API message */
17561 M (PG_CAPTURE, mp);
17563 mp->interface_id = ntohl (if_id);
17564 mp->is_enabled = enable;
17565 mp->count = ntohl (count);
17566 mp->pcap_name_length = ntohl (name_len);
17567 if (pcap_file_set != 0)
17569 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
17571 vec_free (pcap_file);
17579 api_pg_enable_disable (vat_main_t * vam)
17581 unformat_input_t *input = vam->input;
17582 vl_api_pg_enable_disable_t *mp;
17585 u8 stream_name_set = 0;
17586 u8 *stream_name = 0;
17588 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17590 if (unformat (input, "stream %s", &stream_name))
17591 stream_name_set = 1;
17592 else if (unformat (input, "disable"))
17598 if (stream_name_set > 0)
17600 if (vec_len (stream_name) > 255)
17602 errmsg ("stream name too long");
17607 u32 name_len = vec_len (stream_name);
17608 /* Construct the API message */
17609 M (PG_ENABLE_DISABLE, mp);
17611 mp->is_enabled = enable;
17612 if (stream_name_set != 0)
17614 mp->stream_name_length = ntohl (name_len);
17615 clib_memcpy (mp->stream_name, stream_name, name_len);
17617 vec_free (stream_name);
17625 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
17627 unformat_input_t *input = vam->input;
17628 vl_api_ip_source_and_port_range_check_add_del_t *mp;
17630 u16 *low_ports = 0;
17631 u16 *high_ports = 0;
17634 ip4_address_t ip4_addr;
17635 ip6_address_t ip6_addr;
17644 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17646 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
17652 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
17657 else if (unformat (input, "vrf %d", &vrf_id))
17659 else if (unformat (input, "del"))
17661 else if (unformat (input, "port %d", &tmp))
17663 if (tmp == 0 || tmp > 65535)
17665 errmsg ("port %d out of range", tmp);
17669 this_hi = this_low + 1;
17670 vec_add1 (low_ports, this_low);
17671 vec_add1 (high_ports, this_hi);
17673 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
17675 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
17677 errmsg ("incorrect range parameters");
17681 /* Note: in debug CLI +1 is added to high before
17682 passing to real fn that does "the work"
17683 (ip_source_and_port_range_check_add_del).
17684 This fn is a wrapper around the binary API fn a
17685 control plane will call, which expects this increment
17686 to have occurred. Hence letting the binary API control
17687 plane fn do the increment for consistency between VAT
17688 and other control planes.
17691 vec_add1 (low_ports, this_low);
17692 vec_add1 (high_ports, this_hi);
17698 if (prefix_set == 0)
17700 errmsg ("<address>/<mask> not specified");
17706 errmsg ("VRF ID required, not specified");
17713 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17717 if (vec_len (low_ports) == 0)
17719 errmsg ("At least one port or port range required");
17723 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
17725 mp->is_add = is_add;
17730 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
17735 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
17738 mp->mask_length = length;
17739 mp->number_of_ranges = vec_len (low_ports);
17741 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
17742 vec_free (low_ports);
17744 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
17745 vec_free (high_ports);
17747 mp->vrf_id = ntohl (vrf_id);
17755 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
17757 unformat_input_t *input = vam->input;
17758 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
17759 u32 sw_if_index = ~0;
17761 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
17762 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
17766 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17768 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17770 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17772 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
17774 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
17776 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
17778 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
17780 else if (unformat (input, "del"))
17786 if (sw_if_index == ~0)
17788 errmsg ("Interface required but not specified");
17794 errmsg ("VRF ID required but not specified");
17798 if (tcp_out_vrf_id == 0
17799 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
17802 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17806 /* Construct the API message */
17807 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
17809 mp->sw_if_index = ntohl (sw_if_index);
17810 mp->is_add = is_add;
17811 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
17812 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
17813 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
17814 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
17819 /* Wait for a reply... */
17825 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
17827 unformat_input_t *i = vam->input;
17828 vl_api_ipsec_gre_add_del_tunnel_t *mp;
17829 u32 local_sa_id = 0;
17830 u32 remote_sa_id = 0;
17831 ip4_address_t src_address;
17832 ip4_address_t dst_address;
17836 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17838 if (unformat (i, "local_sa %d", &local_sa_id))
17840 else if (unformat (i, "remote_sa %d", &remote_sa_id))
17842 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
17844 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
17846 else if (unformat (i, "del"))
17850 clib_warning ("parse error '%U'", format_unformat_error, i);
17855 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
17857 mp->local_sa_id = ntohl (local_sa_id);
17858 mp->remote_sa_id = ntohl (remote_sa_id);
17859 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
17860 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
17861 mp->is_add = is_add;
17869 api_punt (vat_main_t * vam)
17871 unformat_input_t *i = vam->input;
17879 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17881 if (unformat (i, "ip %d", &ipv))
17883 else if (unformat (i, "protocol %d", &protocol))
17885 else if (unformat (i, "port %d", &port))
17887 else if (unformat (i, "del"))
17891 clib_warning ("parse error '%U'", format_unformat_error, i);
17898 mp->is_add = (u8) is_add;
17899 mp->ipv = (u8) ipv;
17900 mp->l4_protocol = (u8) protocol;
17901 mp->l4_port = htons ((u16) port);
17908 static void vl_api_ipsec_gre_tunnel_details_t_handler
17909 (vl_api_ipsec_gre_tunnel_details_t * mp)
17911 vat_main_t *vam = &vat_main;
17913 print (vam->ofp, "%11d%15U%15U%14d%14d",
17914 ntohl (mp->sw_if_index),
17915 format_ip4_address, &mp->src_address,
17916 format_ip4_address, &mp->dst_address,
17917 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
17920 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
17921 (vl_api_ipsec_gre_tunnel_details_t * mp)
17923 vat_main_t *vam = &vat_main;
17924 vat_json_node_t *node = NULL;
17925 struct in_addr ip4;
17927 if (VAT_JSON_ARRAY != vam->json_tree.type)
17929 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17930 vat_json_init_array (&vam->json_tree);
17932 node = vat_json_array_add (&vam->json_tree);
17934 vat_json_init_object (node);
17935 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17936 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
17937 vat_json_object_add_ip4 (node, "src_address", ip4);
17938 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
17939 vat_json_object_add_ip4 (node, "dst_address", ip4);
17940 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
17941 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
17945 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
17947 unformat_input_t *i = vam->input;
17948 vl_api_ipsec_gre_tunnel_dump_t *mp;
17949 vl_api_control_ping_t *mp_ping;
17951 u8 sw_if_index_set = 0;
17954 /* Parse args required to build the message */
17955 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17957 if (unformat (i, "sw_if_index %d", &sw_if_index))
17958 sw_if_index_set = 1;
17963 if (sw_if_index_set == 0)
17968 if (!vam->json_output)
17970 print (vam->ofp, "%11s%15s%15s%14s%14s",
17971 "sw_if_index", "src_address", "dst_address",
17972 "local_sa_id", "remote_sa_id");
17975 /* Get list of gre-tunnel interfaces */
17976 M (IPSEC_GRE_TUNNEL_DUMP, mp);
17978 mp->sw_if_index = htonl (sw_if_index);
17982 /* Use a control ping for synchronization */
17983 M (CONTROL_PING, mp_ping);
17991 api_delete_subif (vat_main_t * vam)
17993 unformat_input_t *i = vam->input;
17994 vl_api_delete_subif_t *mp;
17995 u32 sw_if_index = ~0;
17998 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18000 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18002 if (unformat (i, "sw_if_index %d", &sw_if_index))
18008 if (sw_if_index == ~0)
18010 errmsg ("missing sw_if_index");
18014 /* Construct the API message */
18015 M (DELETE_SUBIF, mp);
18016 mp->sw_if_index = ntohl (sw_if_index);
18023 #define foreach_pbb_vtr_op \
18024 _("disable", L2_VTR_DISABLED) \
18025 _("pop", L2_VTR_POP_2) \
18026 _("push", L2_VTR_PUSH_2)
18029 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
18031 unformat_input_t *i = vam->input;
18032 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
18033 u32 sw_if_index = ~0, vtr_op = ~0;
18034 u16 outer_tag = ~0;
18035 u8 dmac[6], smac[6];
18036 u8 dmac_set = 0, smac_set = 0;
18042 /* Shut up coverity */
18043 memset (dmac, 0, sizeof (dmac));
18044 memset (smac, 0, sizeof (smac));
18046 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18048 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18050 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18052 else if (unformat (i, "vtr_op %d", &vtr_op))
18054 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
18057 else if (unformat (i, "translate_pbb_stag"))
18059 if (unformat (i, "%d", &tmp))
18061 vtr_op = L2_VTR_TRANSLATE_2_1;
18067 ("translate_pbb_stag operation requires outer tag definition");
18071 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
18073 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
18075 else if (unformat (i, "sid %d", &sid))
18077 else if (unformat (i, "vlanid %d", &tmp))
18081 clib_warning ("parse error '%U'", format_unformat_error, i);
18086 if ((sw_if_index == ~0) || (vtr_op == ~0))
18088 errmsg ("missing sw_if_index or vtr operation");
18091 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
18092 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
18095 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
18099 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
18100 mp->sw_if_index = ntohl (sw_if_index);
18101 mp->vtr_op = ntohl (vtr_op);
18102 mp->outer_tag = ntohs (outer_tag);
18103 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
18104 clib_memcpy (mp->b_smac, smac, sizeof (smac));
18105 mp->b_vlanid = ntohs (vlanid);
18106 mp->i_sid = ntohl (sid);
18114 api_flow_classify_set_interface (vat_main_t * vam)
18116 unformat_input_t *i = vam->input;
18117 vl_api_flow_classify_set_interface_t *mp;
18119 int sw_if_index_set;
18120 u32 ip4_table_index = ~0;
18121 u32 ip6_table_index = ~0;
18125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18127 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18128 sw_if_index_set = 1;
18129 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18130 sw_if_index_set = 1;
18131 else if (unformat (i, "del"))
18133 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18135 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18139 clib_warning ("parse error '%U'", format_unformat_error, i);
18144 if (sw_if_index_set == 0)
18146 errmsg ("missing interface name or sw_if_index");
18150 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
18152 mp->sw_if_index = ntohl (sw_if_index);
18153 mp->ip4_table_index = ntohl (ip4_table_index);
18154 mp->ip6_table_index = ntohl (ip6_table_index);
18155 mp->is_add = is_add;
18163 api_flow_classify_dump (vat_main_t * vam)
18165 unformat_input_t *i = vam->input;
18166 vl_api_flow_classify_dump_t *mp;
18167 vl_api_control_ping_t *mp_ping;
18168 u8 type = FLOW_CLASSIFY_N_TABLES;
18171 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
18175 errmsg ("classify table type must be specified");
18179 if (!vam->json_output)
18181 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18184 M (FLOW_CLASSIFY_DUMP, mp);
18189 /* Use a control ping for synchronization */
18190 M (CONTROL_PING, mp_ping);
18193 /* Wait for a reply... */
18199 api_feature_enable_disable (vat_main_t * vam)
18201 unformat_input_t *i = vam->input;
18202 vl_api_feature_enable_disable_t *mp;
18204 u8 *feature_name = 0;
18205 u32 sw_if_index = ~0;
18209 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18211 if (unformat (i, "arc_name %s", &arc_name))
18213 else if (unformat (i, "feature_name %s", &feature_name))
18216 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18218 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18220 else if (unformat (i, "disable"))
18228 errmsg ("missing arc name");
18231 if (vec_len (arc_name) > 63)
18233 errmsg ("arc name too long");
18236 if (feature_name == 0)
18238 errmsg ("missing feature name");
18241 if (vec_len (feature_name) > 63)
18243 errmsg ("feature name too long");
18246 if (sw_if_index == ~0)
18248 errmsg ("missing interface name or sw_if_index");
18252 /* Construct the API message */
18253 M (FEATURE_ENABLE_DISABLE, mp);
18254 mp->sw_if_index = ntohl (sw_if_index);
18255 mp->enable = enable;
18256 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
18257 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
18258 vec_free (arc_name);
18259 vec_free (feature_name);
18267 api_sw_interface_tag_add_del (vat_main_t * vam)
18269 unformat_input_t *i = vam->input;
18270 vl_api_sw_interface_tag_add_del_t *mp;
18271 u32 sw_if_index = ~0;
18276 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18278 if (unformat (i, "tag %s", &tag))
18280 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18282 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18284 else if (unformat (i, "del"))
18290 if (sw_if_index == ~0)
18292 errmsg ("missing interface name or sw_if_index");
18296 if (enable && (tag == 0))
18298 errmsg ("no tag specified");
18302 /* Construct the API message */
18303 M (SW_INTERFACE_TAG_ADD_DEL, mp);
18304 mp->sw_if_index = ntohl (sw_if_index);
18305 mp->is_add = enable;
18307 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
18315 static void vl_api_l2_xconnect_details_t_handler
18316 (vl_api_l2_xconnect_details_t * mp)
18318 vat_main_t *vam = &vat_main;
18320 print (vam->ofp, "%15d%15d",
18321 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
18324 static void vl_api_l2_xconnect_details_t_handler_json
18325 (vl_api_l2_xconnect_details_t * mp)
18327 vat_main_t *vam = &vat_main;
18328 vat_json_node_t *node = NULL;
18330 if (VAT_JSON_ARRAY != vam->json_tree.type)
18332 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18333 vat_json_init_array (&vam->json_tree);
18335 node = vat_json_array_add (&vam->json_tree);
18337 vat_json_init_object (node);
18338 vat_json_object_add_uint (node, "rx_sw_if_index",
18339 ntohl (mp->rx_sw_if_index));
18340 vat_json_object_add_uint (node, "tx_sw_if_index",
18341 ntohl (mp->tx_sw_if_index));
18345 api_l2_xconnect_dump (vat_main_t * vam)
18347 vl_api_l2_xconnect_dump_t *mp;
18348 vl_api_control_ping_t *mp_ping;
18351 if (!vam->json_output)
18353 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
18356 M (L2_XCONNECT_DUMP, mp);
18360 /* Use a control ping for synchronization */
18361 M (CONTROL_PING, mp_ping);
18369 api_sw_interface_set_mtu (vat_main_t * vam)
18371 unformat_input_t *i = vam->input;
18372 vl_api_sw_interface_set_mtu_t *mp;
18373 u32 sw_if_index = ~0;
18377 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18379 if (unformat (i, "mtu %d", &mtu))
18381 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18383 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18389 if (sw_if_index == ~0)
18391 errmsg ("missing interface name or sw_if_index");
18397 errmsg ("no mtu specified");
18401 /* Construct the API message */
18402 M (SW_INTERFACE_SET_MTU, mp);
18403 mp->sw_if_index = ntohl (sw_if_index);
18404 mp->mtu = ntohs ((u16) mtu);
18413 q_or_quit (vat_main_t * vam)
18415 #if VPP_API_TEST_BUILTIN == 0
18416 longjmp (vam->jump_buf, 1);
18418 return 0; /* not so much */
18422 q (vat_main_t * vam)
18424 return q_or_quit (vam);
18428 quit (vat_main_t * vam)
18430 return q_or_quit (vam);
18434 comment (vat_main_t * vam)
18440 cmd_cmp (void *a1, void *a2)
18445 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
18449 help (vat_main_t * vam)
18454 unformat_input_t *i = vam->input;
18457 if (unformat (i, "%s", &name))
18461 vec_add1 (name, 0);
18463 hs = hash_get_mem (vam->help_by_name, name);
18465 print (vam->ofp, "usage: %s %s", name, hs[0]);
18467 print (vam->ofp, "No such msg / command '%s'", name);
18472 print (vam->ofp, "Help is available for the following:");
18475 hash_foreach_pair (p, vam->function_by_name,
18477 vec_add1 (cmds, (u8 *)(p->key));
18481 vec_sort_with_function (cmds, cmd_cmp);
18483 for (j = 0; j < vec_len (cmds); j++)
18484 print (vam->ofp, "%s", cmds[j]);
18491 set (vat_main_t * vam)
18493 u8 *name = 0, *value = 0;
18494 unformat_input_t *i = vam->input;
18496 if (unformat (i, "%s", &name))
18498 /* The input buffer is a vector, not a string. */
18499 value = vec_dup (i->buffer);
18500 vec_delete (value, i->index, 0);
18501 /* Almost certainly has a trailing newline */
18502 if (value[vec_len (value) - 1] == '\n')
18503 value[vec_len (value) - 1] = 0;
18504 /* Make sure it's a proper string, one way or the other */
18505 vec_add1 (value, 0);
18506 (void) clib_macro_set_value (&vam->macro_main,
18507 (char *) name, (char *) value);
18510 errmsg ("usage: set <name> <value>");
18518 unset (vat_main_t * vam)
18522 if (unformat (vam->input, "%s", &name))
18523 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
18524 errmsg ("unset: %s wasn't set", name);
18537 macro_sort_cmp (void *a1, void *a2)
18539 macro_sort_t *s1 = a1;
18540 macro_sort_t *s2 = a2;
18542 return strcmp ((char *) (s1->name), (char *) (s2->name));
18546 dump_macro_table (vat_main_t * vam)
18548 macro_sort_t *sort_me = 0, *sm;
18553 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
18555 vec_add2 (sort_me, sm, 1);
18556 sm->name = (u8 *)(p->key);
18557 sm->value = (u8 *) (p->value[0]);
18561 vec_sort_with_function (sort_me, macro_sort_cmp);
18563 if (vec_len (sort_me))
18564 print (vam->ofp, "%-15s%s", "Name", "Value");
18566 print (vam->ofp, "The macro table is empty...");
18568 for (i = 0; i < vec_len (sort_me); i++)
18569 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
18574 dump_node_table (vat_main_t * vam)
18577 vlib_node_t *node, *next_node;
18579 if (vec_len (vam->graph_nodes) == 0)
18581 print (vam->ofp, "Node table empty, issue get_node_graph...");
18585 for (i = 0; i < vec_len (vam->graph_nodes); i++)
18587 node = vam->graph_nodes[i];
18588 print (vam->ofp, "[%d] %s", i, node->name);
18589 for (j = 0; j < vec_len (node->next_nodes); j++)
18591 if (node->next_nodes[j] != ~0)
18593 next_node = vam->graph_nodes[node->next_nodes[j]];
18594 print (vam->ofp, " [%d] %s", j, next_node->name);
18602 value_sort_cmp (void *a1, void *a2)
18604 name_sort_t *n1 = a1;
18605 name_sort_t *n2 = a2;
18607 if (n1->value < n2->value)
18609 if (n1->value > n2->value)
18616 dump_msg_api_table (vat_main_t * vam)
18618 api_main_t *am = &api_main;
18619 name_sort_t *nses = 0, *ns;
18624 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
18626 vec_add2 (nses, ns, 1);
18627 ns->name = (u8 *)(hp->key);
18628 ns->value = (u32) hp->value[0];
18632 vec_sort_with_function (nses, value_sort_cmp);
18634 for (i = 0; i < vec_len (nses); i++)
18635 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
18641 get_msg_id (vat_main_t * vam)
18646 if (unformat (vam->input, "%s", &name_and_crc))
18648 message_index = vl_api_get_msg_index (name_and_crc);
18649 if (message_index == ~0)
18651 print (vam->ofp, " '%s' not found", name_and_crc);
18654 print (vam->ofp, " '%s' has message index %d",
18655 name_and_crc, message_index);
18658 errmsg ("name_and_crc required...");
18663 search_node_table (vat_main_t * vam)
18665 unformat_input_t *line_input = vam->input;
18668 vlib_node_t *node, *next_node;
18671 if (vam->graph_node_index_by_name == 0)
18673 print (vam->ofp, "Node table empty, issue get_node_graph...");
18677 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
18679 if (unformat (line_input, "%s", &node_to_find))
18681 vec_add1 (node_to_find, 0);
18682 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
18685 print (vam->ofp, "%s not found...", node_to_find);
18688 node = vam->graph_nodes[p[0]];
18689 print (vam->ofp, "[%d] %s", p[0], node->name);
18690 for (j = 0; j < vec_len (node->next_nodes); j++)
18692 if (node->next_nodes[j] != ~0)
18694 next_node = vam->graph_nodes[node->next_nodes[j]];
18695 print (vam->ofp, " [%d] %s", j, next_node->name);
18702 clib_warning ("parse error '%U'", format_unformat_error,
18708 vec_free (node_to_find);
18717 script (vat_main_t * vam)
18719 #if (VPP_API_TEST_BUILTIN==0)
18721 char *save_current_file;
18722 unformat_input_t save_input;
18723 jmp_buf save_jump_buf;
18724 u32 save_line_number;
18726 FILE *new_fp, *save_ifp;
18728 if (unformat (vam->input, "%s", &s))
18730 new_fp = fopen ((char *) s, "r");
18733 errmsg ("Couldn't open script file %s", s);
18740 errmsg ("Missing script name");
18744 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
18745 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
18746 save_ifp = vam->ifp;
18747 save_line_number = vam->input_line_number;
18748 save_current_file = (char *) vam->current_file;
18750 vam->input_line_number = 0;
18752 vam->current_file = s;
18755 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
18756 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
18757 vam->ifp = save_ifp;
18758 vam->input_line_number = save_line_number;
18759 vam->current_file = (u8 *) save_current_file;
18764 clib_warning ("use the exec command...");
18770 echo (vat_main_t * vam)
18772 print (vam->ofp, "%v", vam->input->buffer);
18776 /* List of API message constructors, CLI names map to api_xxx */
18777 #define foreach_vpe_api_msg \
18778 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
18779 _(sw_interface_dump,"") \
18780 _(sw_interface_set_flags, \
18781 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
18782 _(sw_interface_add_del_address, \
18783 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
18784 _(sw_interface_set_table, \
18785 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
18786 _(sw_interface_set_mpls_enable, \
18787 "<intfc> | sw_if_index [disable | dis]") \
18788 _(sw_interface_set_vpath, \
18789 "<intfc> | sw_if_index <id> enable | disable") \
18790 _(sw_interface_set_vxlan_bypass, \
18791 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
18792 _(sw_interface_set_l2_xconnect, \
18793 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18794 "enable | disable") \
18795 _(sw_interface_set_l2_bridge, \
18796 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
18797 "[shg <split-horizon-group>] [bvi]\n" \
18798 "enable | disable") \
18799 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
18800 _(bridge_domain_add_del, \
18801 "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") \
18802 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
18804 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
18805 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
18806 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
18808 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
18810 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
18812 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
18814 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
18816 "<vpp-if-name> | sw_if_index <id>") \
18817 _(sw_interface_tap_dump, "") \
18818 _(ip_add_del_route, \
18819 "<addr>/<mask> via <addr> [table-id <n>]\n" \
18820 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18821 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18822 "[multipath] [count <n>]") \
18823 _(ip_mroute_add_del, \
18824 "<src> <grp>/<mask> [table-id <n>]\n" \
18825 "[<intfc> | sw_if_index <id>] [local] [del]") \
18826 _(mpls_route_add_del, \
18827 "<label> <eos> via <addr> [table-id <n>]\n" \
18828 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18829 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18830 "[multipath] [count <n>]") \
18831 _(mpls_ip_bind_unbind, \
18832 "<label> <addr/len>") \
18833 _(mpls_tunnel_add_del, \
18834 " via <addr> [table-id <n>]\n" \
18835 "sw_if_index <id>] [l2] [del]") \
18836 _(proxy_arp_add_del, \
18837 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
18838 _(proxy_arp_intfc_enable_disable, \
18839 "<intfc> | sw_if_index <id> enable | disable") \
18840 _(sw_interface_set_unnumbered, \
18841 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
18842 _(ip_neighbor_add_del, \
18843 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
18844 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
18845 _(reset_vrf, "vrf <id> [ipv6]") \
18846 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
18847 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
18848 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
18849 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
18850 "[outer_vlan_id_any][inner_vlan_id_any]") \
18851 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
18852 _(reset_fib, "vrf <n> [ipv6]") \
18853 _(dhcp_proxy_config, \
18854 "svr <v46-address> src <v46-address>\n" \
18855 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
18856 _(dhcp_proxy_set_vss, \
18857 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
18858 _(dhcp_proxy_dump, "ip6") \
18859 _(dhcp_client_config, \
18860 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
18861 _(set_ip_flow_hash, \
18862 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
18863 _(sw_interface_ip6_enable_disable, \
18864 "<intfc> | sw_if_index <id> enable | disable") \
18865 _(sw_interface_ip6_set_link_local_address, \
18866 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
18867 _(ip6nd_proxy_add_del, \
18868 "<intfc> | sw_if_index <id> <ip6-address>") \
18869 _(ip6nd_proxy_dump, "") \
18870 _(sw_interface_ip6nd_ra_prefix, \
18871 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
18872 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
18873 "[nolink] [isno]") \
18874 _(sw_interface_ip6nd_ra_config, \
18875 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
18876 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
18877 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
18878 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
18879 _(l2_patch_add_del, \
18880 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18881 "enable | disable") \
18882 _(sr_localsid_add_del, \
18883 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
18884 "fib-table <num> (end.psp) sw_if_index <num>") \
18885 _(classify_add_del_table, \
18886 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
18887 " [del] [del-chain] mask <mask-value>\n" \
18888 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
18889 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
18890 _(classify_add_del_session, \
18891 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
18892 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
18893 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
18894 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
18895 _(classify_set_interface_ip_table, \
18896 "<intfc> | sw_if_index <nn> table <nn>") \
18897 _(classify_set_interface_l2_tables, \
18898 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18899 " [other-table <nn>]") \
18900 _(get_node_index, "node <node-name") \
18901 _(add_node_next, "node <node-name> next <next-node-name>") \
18902 _(l2tpv3_create_tunnel, \
18903 "client_address <ip6-addr> our_address <ip6-addr>\n" \
18904 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
18905 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
18906 _(l2tpv3_set_tunnel_cookies, \
18907 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
18908 "[new_remote_cookie <nn>]\n") \
18909 _(l2tpv3_interface_enable_disable, \
18910 "<intfc> | sw_if_index <nn> enable | disable") \
18911 _(l2tpv3_set_lookup_key, \
18912 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
18913 _(sw_if_l2tpv3_tunnel_dump, "") \
18914 _(vxlan_add_del_tunnel, \
18915 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
18916 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
18917 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
18918 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18919 _(gre_add_del_tunnel, \
18920 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
18921 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18922 _(l2_fib_clear_table, "") \
18923 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
18924 _(l2_interface_vlan_tag_rewrite, \
18925 "<intfc> | sw_if_index <nn> \n" \
18926 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
18927 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
18928 _(create_vhost_user_if, \
18929 "socket <filename> [server] [renumber <dev_instance>] " \
18930 "[mac <mac_address>] " \
18931 "[mode <interrupt | polling>]") \
18932 _(modify_vhost_user_if, \
18933 "<intfc> | sw_if_index <nn> socket <filename>\n" \
18934 "[server] [renumber <dev_instance>] " \
18935 "[mode <interrupt | polling>]") \
18936 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
18937 _(sw_interface_vhost_user_dump, "") \
18938 _(show_version, "") \
18939 _(vxlan_gpe_add_del_tunnel, \
18940 "local <addr> remote <addr> vni <nn>\n" \
18941 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
18942 "[next-ethernet] [next-nsh]\n") \
18943 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18944 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
18945 _(interface_name_renumber, \
18946 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
18947 _(input_acl_set_interface, \
18948 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18949 " [l2-table <nn>] [del]") \
18950 _(want_ip4_arp_events, "address <ip4-address> [del]") \
18951 _(want_ip6_nd_events, "address <ip6-address> [del]") \
18952 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
18953 _(ip_dump, "ipv4 | ipv6") \
18954 _(ipsec_spd_add_del, "spd_id <n> [del]") \
18955 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
18957 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
18958 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
18959 " integ_alg <alg> integ_key <hex>") \
18960 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
18961 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
18962 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
18963 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
18964 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
18965 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
18966 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
18967 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
18968 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
18969 _(ikev2_profile_add_del, "name <profile_name> [del]") \
18970 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
18971 "(auth_data 0x<data> | auth_data <data>)") \
18972 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
18973 "(id_data 0x<data> | id_data <data>) (local|remote)") \
18974 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
18975 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
18976 "(local|remote)") \
18977 _(ikev2_set_local_key, "file <absolute_file_path>") \
18978 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
18979 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18980 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18981 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
18982 _(ikev2_initiate_sa_init, "<profile_name>") \
18983 _(ikev2_initiate_del_ike_sa, "<ispi>") \
18984 _(ikev2_initiate_del_child_sa, "<ispi>") \
18985 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
18986 _(delete_loopback,"sw_if_index <nn>") \
18987 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
18988 _(map_add_domain, \
18989 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
18990 "ip6-src <ip6addr> " \
18991 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
18992 _(map_del_domain, "index <n>") \
18993 _(map_add_del_rule, \
18994 "index <n> psid <n> dst <ip6addr> [del]") \
18995 _(map_domain_dump, "") \
18996 _(map_rule_dump, "index <map-domain>") \
18997 _(want_interface_events, "enable|disable") \
18998 _(want_stats,"enable|disable") \
18999 _(get_first_msg_id, "client <name>") \
19000 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
19001 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
19002 "fib-id <nn> [ip4][ip6][default]") \
19003 _(get_node_graph, " ") \
19004 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
19005 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
19006 _(ioam_disable, "") \
19007 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
19008 " sw_if_index <sw_if_index> p <priority> " \
19009 "w <weight>] [del]") \
19010 _(one_add_del_locator, "locator-set <locator_name> " \
19011 "iface <intf> | sw_if_index <sw_if_index> " \
19012 "p <priority> w <weight> [del]") \
19013 _(one_add_del_local_eid,"vni <vni> eid " \
19014 "<ipv4|ipv6>/<prefix> | <L2 address> " \
19015 "locator-set <locator_name> [del]" \
19016 "[key-id sha1|sha256 secret-key <secret-key>]")\
19017 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
19018 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
19019 _(one_enable_disable, "enable|disable") \
19020 _(one_map_register_enable_disable, "enable|disable") \
19021 _(one_rloc_probe_enable_disable, "enable|disable") \
19022 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
19024 "rloc <locator> p <prio> " \
19025 "w <weight> [rloc <loc> ... ] " \
19026 "action <action> [del-all]") \
19027 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
19029 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
19030 _(one_use_petr, "ip-address> | disable") \
19031 _(one_map_request_mode, "src-dst|dst-only") \
19032 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
19033 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
19034 _(one_locator_set_dump, "[local | remote]") \
19035 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
19036 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
19037 "[local] | [remote]") \
19038 _(one_stats_enable_disable, "enable|disalbe") \
19039 _(show_one_stats_enable_disable, "") \
19040 _(one_eid_table_vni_dump, "") \
19041 _(one_eid_table_map_dump, "l2|l3") \
19042 _(one_map_resolver_dump, "") \
19043 _(one_map_server_dump, "") \
19044 _(one_adjacencies_get, "vni <vni>") \
19045 _(show_one_rloc_probe_state, "") \
19046 _(show_one_map_register_state, "") \
19047 _(show_one_status, "") \
19048 _(one_stats_dump, "") \
19049 _(one_stats_flush, "") \
19050 _(one_get_map_request_itr_rlocs, "") \
19051 _(show_one_pitr, "") \
19052 _(show_one_use_petr, "") \
19053 _(show_one_map_request_mode, "") \
19054 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
19055 " sw_if_index <sw_if_index> p <priority> " \
19056 "w <weight>] [del]") \
19057 _(lisp_add_del_locator, "locator-set <locator_name> " \
19058 "iface <intf> | sw_if_index <sw_if_index> " \
19059 "p <priority> w <weight> [del]") \
19060 _(lisp_add_del_local_eid,"vni <vni> eid " \
19061 "<ipv4|ipv6>/<prefix> | <L2 address> " \
19062 "locator-set <locator_name> [del]" \
19063 "[key-id sha1|sha256 secret-key <secret-key>]") \
19064 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
19065 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
19066 _(lisp_enable_disable, "enable|disable") \
19067 _(lisp_map_register_enable_disable, "enable|disable") \
19068 _(lisp_rloc_probe_enable_disable, "enable|disable") \
19069 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
19071 "rloc <locator> p <prio> " \
19072 "w <weight> [rloc <loc> ... ] " \
19073 "action <action> [del-all]") \
19074 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
19076 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
19077 _(lisp_use_petr, "<ip-address> | disable") \
19078 _(lisp_map_request_mode, "src-dst|dst-only") \
19079 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
19080 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
19081 _(lisp_locator_set_dump, "[local | remote]") \
19082 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
19083 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
19084 "[local] | [remote]") \
19085 _(lisp_eid_table_vni_dump, "") \
19086 _(lisp_eid_table_map_dump, "l2|l3") \
19087 _(lisp_map_resolver_dump, "") \
19088 _(lisp_map_server_dump, "") \
19089 _(lisp_adjacencies_get, "vni <vni>") \
19090 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
19091 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
19092 _(gpe_set_encap_mode, "lisp|vxlan") \
19093 _(gpe_get_encap_mode, "") \
19094 _(lisp_gpe_add_del_iface, "up|down") \
19095 _(lisp_gpe_enable_disable, "enable|disable") \
19096 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
19097 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
19098 _(show_lisp_rloc_probe_state, "") \
19099 _(show_lisp_map_register_state, "") \
19100 _(show_lisp_status, "") \
19101 _(lisp_get_map_request_itr_rlocs, "") \
19102 _(show_lisp_pitr, "") \
19103 _(show_lisp_use_petr, "") \
19104 _(show_lisp_map_request_mode, "") \
19105 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
19106 _(af_packet_delete, "name <host interface name>") \
19107 _(policer_add_del, "name <policer name> <params> [del]") \
19108 _(policer_dump, "[name <policer name>]") \
19109 _(policer_classify_set_interface, \
19110 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19111 " [l2-table <nn>] [del]") \
19112 _(policer_classify_dump, "type [ip4|ip6|l2]") \
19113 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
19114 "[master|slave]") \
19115 _(netmap_delete, "name <interface name>") \
19116 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
19117 _(mpls_fib_dump, "") \
19118 _(classify_table_ids, "") \
19119 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
19120 _(classify_table_info, "table_id <nn>") \
19121 _(classify_session_dump, "table_id <nn>") \
19122 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
19123 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
19124 "[template_interval <nn>] [udp_checksum]") \
19125 _(ipfix_exporter_dump, "") \
19126 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
19127 _(ipfix_classify_stream_dump, "") \
19128 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
19129 _(ipfix_classify_table_dump, "") \
19130 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
19131 _(sw_interface_span_dump, "") \
19132 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
19133 _(pg_create_interface, "if_id <nn>") \
19134 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
19135 _(pg_enable_disable, "[stream <id>] disable") \
19136 _(ip_source_and_port_range_check_add_del, \
19137 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
19138 _(ip_source_and_port_range_check_interface_add_del, \
19139 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
19140 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
19141 _(ipsec_gre_add_del_tunnel, \
19142 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
19143 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
19144 _(delete_subif,"<intfc> | sw_if_index <nn>") \
19145 _(l2_interface_pbb_tag_rewrite, \
19146 "<intfc> | sw_if_index <nn> \n" \
19147 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
19148 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
19149 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
19150 _(flow_classify_set_interface, \
19151 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
19152 _(flow_classify_dump, "type [ip4|ip6]") \
19153 _(ip_fib_dump, "") \
19154 _(ip_mfib_dump, "") \
19155 _(ip6_fib_dump, "") \
19156 _(ip6_mfib_dump, "") \
19157 _(feature_enable_disable, "arc_name <arc_name> " \
19158 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
19159 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
19161 _(l2_xconnect_dump, "") \
19162 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
19163 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
19164 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
19166 /* List of command functions, CLI names map directly to functions */
19167 #define foreach_cli_function \
19168 _(comment, "usage: comment <ignore-rest-of-line>") \
19169 _(dump_interface_table, "usage: dump_interface_table") \
19170 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
19171 _(dump_ipv4_table, "usage: dump_ipv4_table") \
19172 _(dump_ipv6_table, "usage: dump_ipv6_table") \
19173 _(dump_stats_table, "usage: dump_stats_table") \
19174 _(dump_macro_table, "usage: dump_macro_table ") \
19175 _(dump_node_table, "usage: dump_node_table") \
19176 _(dump_msg_api_table, "usage: dump_msg_api_table") \
19177 _(get_msg_id, "usage: get_msg_id name_and_crc") \
19178 _(echo, "usage: echo <message>") \
19179 _(exec, "usage: exec <vpe-debug-CLI-command>") \
19180 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
19181 _(help, "usage: help") \
19182 _(q, "usage: quit") \
19183 _(quit, "usage: quit") \
19184 _(search_node_table, "usage: search_node_table <name>...") \
19185 _(set, "usage: set <variable-name> <value>") \
19186 _(script, "usage: script <file-name>") \
19187 _(unset, "usage: unset <variable-name>")
19190 static void vl_api_##n##_t_handler_uni \
19191 (vl_api_##n##_t * mp) \
19193 vat_main_t * vam = &vat_main; \
19194 if (vam->json_output) { \
19195 vl_api_##n##_t_handler_json(mp); \
19197 vl_api_##n##_t_handler(mp); \
19200 foreach_vpe_api_reply_msg;
19201 #if VPP_API_TEST_BUILTIN == 0
19202 foreach_standalone_reply_msg;
19207 vat_api_hookup (vat_main_t * vam)
19210 vl_msg_api_set_handlers(VL_API_##N, #n, \
19211 vl_api_##n##_t_handler_uni, \
19213 vl_api_##n##_t_endian, \
19214 vl_api_##n##_t_print, \
19215 sizeof(vl_api_##n##_t), 1);
19216 foreach_vpe_api_reply_msg;
19217 #if VPP_API_TEST_BUILTIN == 0
19218 foreach_standalone_reply_msg;
19222 #if (VPP_API_TEST_BUILTIN==0)
19223 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
19225 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
19227 vam->function_by_name = hash_create_string (0, sizeof (uword));
19229 vam->help_by_name = hash_create_string (0, sizeof (uword));
19232 /* API messages we can send */
19233 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
19234 foreach_vpe_api_msg;
19238 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
19239 foreach_vpe_api_msg;
19242 /* CLI functions */
19243 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
19244 foreach_cli_function;
19248 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
19249 foreach_cli_function;
19253 #if VPP_API_TEST_BUILTIN
19254 static clib_error_t *
19255 vat_api_hookup_shim (vlib_main_t * vm)
19257 vat_api_hookup (&vat_main);
19261 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
19265 * fd.io coding-style-patch-verification: ON
19268 * eval: (c-set-style "gnu")