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);
2959 e->vni = clib_net_to_host_u32 (e->vni);
2963 gpe_fwd_entries_get_reply_t_net_to_host
2964 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2968 mp->count = clib_net_to_host_u32 (mp->count);
2969 for (i = 0; i < mp->count; i++)
2971 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
2976 format_gpe_encap_mode (u8 * s, va_list * args)
2978 u32 mode = va_arg (*args, u32);
2983 return format (s, "lisp");
2985 return format (s, "vxlan");
2991 vl_api_gpe_get_encap_mode_reply_t_handler
2992 (vl_api_gpe_get_encap_mode_reply_t * mp)
2994 vat_main_t *vam = &vat_main;
2996 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
2997 vam->retval = ntohl (mp->retval);
2998 vam->result_ready = 1;
3002 vl_api_gpe_get_encap_mode_reply_t_handler_json
3003 (vl_api_gpe_get_encap_mode_reply_t * mp)
3005 vat_main_t *vam = &vat_main;
3006 vat_json_node_t node;
3008 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3009 vec_add1 (encap_mode, 0);
3011 vat_json_init_object (&node);
3012 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3014 vec_free (encap_mode);
3015 vat_json_print (vam->ofp, &node);
3016 vat_json_free (&node);
3018 vam->retval = ntohl (mp->retval);
3019 vam->result_ready = 1;
3023 vl_api_gpe_fwd_entry_path_details_t_handler
3024 (vl_api_gpe_fwd_entry_path_details_t * mp)
3026 vat_main_t *vam = &vat_main;
3027 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3029 if (mp->lcl_loc.is_ip4)
3030 format_ip_address_fcn = format_ip4_address;
3032 format_ip_address_fcn = format_ip6_address;
3034 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3035 format_ip_address_fcn, &mp->lcl_loc,
3036 format_ip_address_fcn, &mp->rmt_loc);
3040 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3042 struct in6_addr ip6;
3047 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3048 vat_json_object_add_ip4 (n, "address", ip4);
3052 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3053 vat_json_object_add_ip6 (n, "address", ip6);
3055 vat_json_object_add_uint (n, "weight", loc->weight);
3059 vl_api_gpe_fwd_entry_path_details_t_handler_json
3060 (vl_api_gpe_fwd_entry_path_details_t * mp)
3062 vat_main_t *vam = &vat_main;
3063 vat_json_node_t *node = NULL;
3064 vat_json_node_t *loc_node;
3066 if (VAT_JSON_ARRAY != vam->json_tree.type)
3068 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3069 vat_json_init_array (&vam->json_tree);
3071 node = vat_json_array_add (&vam->json_tree);
3072 vat_json_init_object (node);
3074 loc_node = vat_json_object_add (node, "local_locator");
3075 vat_json_init_object (loc_node);
3076 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3078 loc_node = vat_json_object_add (node, "remote_locator");
3079 vat_json_init_object (loc_node);
3080 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3084 vl_api_gpe_fwd_entries_get_reply_t_handler
3085 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3087 vat_main_t *vam = &vat_main;
3089 int retval = clib_net_to_host_u32 (mp->retval);
3090 vl_api_gpe_fwd_entry_t *e;
3095 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3097 for (i = 0; i < mp->count; i++)
3099 e = &mp->entries[i];
3100 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3101 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3102 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3106 vam->retval = retval;
3107 vam->result_ready = 1;
3111 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3112 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3115 vat_main_t *vam = &vat_main;
3116 vat_json_node_t *e = 0, root;
3118 int retval = clib_net_to_host_u32 (mp->retval);
3119 vl_api_gpe_fwd_entry_t *fwd;
3124 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3125 vat_json_init_array (&root);
3127 for (i = 0; i < mp->count; i++)
3129 e = vat_json_array_add (&root);
3130 fwd = &mp->entries[i];
3132 vat_json_init_object (e);
3133 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3134 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3135 vat_json_object_add_int (e, "vni", fwd->vni);
3136 vat_json_object_add_int (e, "action", fwd->action);
3138 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3139 fwd->leid_prefix_len);
3141 vat_json_object_add_string_copy (e, "leid", s);
3144 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3145 fwd->reid_prefix_len);
3147 vat_json_object_add_string_copy (e, "reid", s);
3151 vat_json_print (vam->ofp, &root);
3152 vat_json_free (&root);
3155 vam->retval = retval;
3156 vam->result_ready = 1;
3160 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3161 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3163 vat_main_t *vam = &vat_main;
3165 int retval = clib_net_to_host_u32 (mp->retval);
3170 n = clib_net_to_host_u32 (mp->count);
3172 for (i = 0; i < n; i++)
3173 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3176 vam->retval = retval;
3177 vam->result_ready = 1;
3181 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3182 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3184 vat_main_t *vam = &vat_main;
3185 vat_json_node_t root;
3187 int retval = clib_net_to_host_u32 (mp->retval);
3192 n = clib_net_to_host_u32 (mp->count);
3193 vat_json_init_array (&root);
3195 for (i = 0; i < n; i++)
3196 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3198 vat_json_print (vam->ofp, &root);
3199 vat_json_free (&root);
3202 vam->retval = retval;
3203 vam->result_ready = 1;
3207 vl_api_one_adjacencies_get_reply_t_handler
3208 (vl_api_one_adjacencies_get_reply_t * mp)
3210 vat_main_t *vam = &vat_main;
3212 int retval = clib_net_to_host_u32 (mp->retval);
3213 vl_api_one_adjacency_t *a;
3218 n = clib_net_to_host_u32 (mp->count);
3220 for (i = 0; i < n; i++)
3222 a = &mp->adjacencies[i];
3223 print (vam->ofp, "%U %40U",
3224 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3225 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3229 vam->retval = retval;
3230 vam->result_ready = 1;
3234 vl_api_one_adjacencies_get_reply_t_handler_json
3235 (vl_api_one_adjacencies_get_reply_t * mp)
3238 vat_main_t *vam = &vat_main;
3239 vat_json_node_t *e = 0, root;
3241 int retval = clib_net_to_host_u32 (mp->retval);
3242 vl_api_one_adjacency_t *a;
3247 n = clib_net_to_host_u32 (mp->count);
3248 vat_json_init_array (&root);
3250 for (i = 0; i < n; i++)
3252 e = vat_json_array_add (&root);
3253 a = &mp->adjacencies[i];
3255 vat_json_init_object (e);
3256 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3257 a->leid_prefix_len);
3259 vat_json_object_add_string_copy (e, "leid", s);
3262 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3263 a->reid_prefix_len);
3265 vat_json_object_add_string_copy (e, "reid", s);
3269 vat_json_print (vam->ofp, &root);
3270 vat_json_free (&root);
3273 vam->retval = retval;
3274 vam->result_ready = 1;
3278 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3280 vat_main_t *vam = &vat_main;
3282 print (vam->ofp, "%=20U",
3283 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3288 vl_api_one_map_server_details_t_handler_json
3289 (vl_api_one_map_server_details_t * mp)
3291 vat_main_t *vam = &vat_main;
3292 vat_json_node_t *node = NULL;
3293 struct in6_addr ip6;
3296 if (VAT_JSON_ARRAY != vam->json_tree.type)
3298 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3299 vat_json_init_array (&vam->json_tree);
3301 node = vat_json_array_add (&vam->json_tree);
3303 vat_json_init_object (node);
3306 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3307 vat_json_object_add_ip6 (node, "map-server", ip6);
3311 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3312 vat_json_object_add_ip4 (node, "map-server", ip4);
3317 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3320 vat_main_t *vam = &vat_main;
3322 print (vam->ofp, "%=20U",
3323 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3328 vl_api_one_map_resolver_details_t_handler_json
3329 (vl_api_one_map_resolver_details_t * mp)
3331 vat_main_t *vam = &vat_main;
3332 vat_json_node_t *node = NULL;
3333 struct in6_addr ip6;
3336 if (VAT_JSON_ARRAY != vam->json_tree.type)
3338 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3339 vat_json_init_array (&vam->json_tree);
3341 node = vat_json_array_add (&vam->json_tree);
3343 vat_json_init_object (node);
3346 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3347 vat_json_object_add_ip6 (node, "map resolver", ip6);
3351 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3352 vat_json_object_add_ip4 (node, "map resolver", ip4);
3357 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3359 vat_main_t *vam = &vat_main;
3360 i32 retval = ntohl (mp->retval);
3364 print (vam->ofp, "feature: %s\ngpe: %s",
3365 mp->feature_status ? "enabled" : "disabled",
3366 mp->gpe_status ? "enabled" : "disabled");
3369 vam->retval = retval;
3370 vam->result_ready = 1;
3374 vl_api_show_one_status_reply_t_handler_json
3375 (vl_api_show_one_status_reply_t * mp)
3377 vat_main_t *vam = &vat_main;
3378 vat_json_node_t node;
3379 u8 *gpe_status = NULL;
3380 u8 *feature_status = NULL;
3382 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3383 feature_status = format (0, "%s",
3384 mp->feature_status ? "enabled" : "disabled");
3385 vec_add1 (gpe_status, 0);
3386 vec_add1 (feature_status, 0);
3388 vat_json_init_object (&node);
3389 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3390 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3392 vec_free (gpe_status);
3393 vec_free (feature_status);
3395 vat_json_print (vam->ofp, &node);
3396 vat_json_free (&node);
3398 vam->retval = ntohl (mp->retval);
3399 vam->result_ready = 1;
3403 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3404 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3406 vat_main_t *vam = &vat_main;
3407 i32 retval = ntohl (mp->retval);
3411 print (vam->ofp, "%=20s", mp->locator_set_name);
3414 vam->retval = retval;
3415 vam->result_ready = 1;
3419 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3420 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3422 vat_main_t *vam = &vat_main;
3423 vat_json_node_t *node = NULL;
3425 if (VAT_JSON_ARRAY != vam->json_tree.type)
3427 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3428 vat_json_init_array (&vam->json_tree);
3430 node = vat_json_array_add (&vam->json_tree);
3432 vat_json_init_object (node);
3433 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3435 vat_json_print (vam->ofp, node);
3436 vat_json_free (node);
3438 vam->retval = ntohl (mp->retval);
3439 vam->result_ready = 1;
3443 format_lisp_map_request_mode (u8 * s, va_list * args)
3445 u32 mode = va_arg (*args, u32);
3450 return format (0, "dst-only");
3452 return format (0, "src-dst");
3458 vl_api_show_one_map_request_mode_reply_t_handler
3459 (vl_api_show_one_map_request_mode_reply_t * mp)
3461 vat_main_t *vam = &vat_main;
3462 i32 retval = ntohl (mp->retval);
3466 u32 mode = mp->mode;
3467 print (vam->ofp, "map_request_mode: %U",
3468 format_lisp_map_request_mode, mode);
3471 vam->retval = retval;
3472 vam->result_ready = 1;
3476 vl_api_show_one_map_request_mode_reply_t_handler_json
3477 (vl_api_show_one_map_request_mode_reply_t * mp)
3479 vat_main_t *vam = &vat_main;
3480 vat_json_node_t node;
3485 s = format (0, "%U", format_lisp_map_request_mode, mode);
3488 vat_json_init_object (&node);
3489 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3490 vat_json_print (vam->ofp, &node);
3491 vat_json_free (&node);
3494 vam->retval = ntohl (mp->retval);
3495 vam->result_ready = 1;
3499 vl_api_show_one_use_petr_reply_t_handler
3500 (vl_api_show_one_use_petr_reply_t * mp)
3502 vat_main_t *vam = &vat_main;
3503 i32 retval = ntohl (mp->retval);
3507 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
3510 print (vam->ofp, "Proxy-ETR address; %U",
3511 mp->is_ip4 ? format_ip4_address : format_ip6_address,
3516 vam->retval = retval;
3517 vam->result_ready = 1;
3521 vl_api_show_one_use_petr_reply_t_handler_json
3522 (vl_api_show_one_use_petr_reply_t * mp)
3524 vat_main_t *vam = &vat_main;
3525 vat_json_node_t node;
3528 struct in6_addr ip6;
3530 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3531 vec_add1 (status, 0);
3533 vat_json_init_object (&node);
3534 vat_json_object_add_string_copy (&node, "status", status);
3539 clib_memcpy (&ip6, mp->address, sizeof (ip6));
3540 vat_json_object_add_ip6 (&node, "address", ip6);
3544 clib_memcpy (&ip4, mp->address, sizeof (ip4));
3545 vat_json_object_add_ip4 (&node, "address", ip4);
3551 vat_json_print (vam->ofp, &node);
3552 vat_json_free (&node);
3554 vam->retval = ntohl (mp->retval);
3555 vam->result_ready = 1;
3559 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3561 vat_main_t *vam = &vat_main;
3562 i32 retval = ntohl (mp->retval);
3566 print (vam->ofp, "%-20s%-16s",
3567 mp->status ? "enabled" : "disabled",
3568 mp->status ? (char *) mp->locator_set_name : "");
3571 vam->retval = retval;
3572 vam->result_ready = 1;
3576 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3578 vat_main_t *vam = &vat_main;
3579 vat_json_node_t node;
3582 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3583 vec_add1 (status, 0);
3585 vat_json_init_object (&node);
3586 vat_json_object_add_string_copy (&node, "status", status);
3589 vat_json_object_add_string_copy (&node, "locator_set",
3590 mp->locator_set_name);
3595 vat_json_print (vam->ofp, &node);
3596 vat_json_free (&node);
3598 vam->retval = ntohl (mp->retval);
3599 vam->result_ready = 1;
3603 format_policer_type (u8 * s, va_list * va)
3605 u32 i = va_arg (*va, u32);
3607 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3608 s = format (s, "1r2c");
3609 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3610 s = format (s, "1r3c");
3611 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3612 s = format (s, "2r3c-2698");
3613 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3614 s = format (s, "2r3c-4115");
3615 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3616 s = format (s, "2r3c-mef5cf1");
3618 s = format (s, "ILLEGAL");
3623 format_policer_rate_type (u8 * s, va_list * va)
3625 u32 i = va_arg (*va, u32);
3627 if (i == SSE2_QOS_RATE_KBPS)
3628 s = format (s, "kbps");
3629 else if (i == SSE2_QOS_RATE_PPS)
3630 s = format (s, "pps");
3632 s = format (s, "ILLEGAL");
3637 format_policer_round_type (u8 * s, va_list * va)
3639 u32 i = va_arg (*va, u32);
3641 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3642 s = format (s, "closest");
3643 else if (i == SSE2_QOS_ROUND_TO_UP)
3644 s = format (s, "up");
3645 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3646 s = format (s, "down");
3648 s = format (s, "ILLEGAL");
3653 format_policer_action_type (u8 * s, va_list * va)
3655 u32 i = va_arg (*va, u32);
3657 if (i == SSE2_QOS_ACTION_DROP)
3658 s = format (s, "drop");
3659 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3660 s = format (s, "transmit");
3661 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3662 s = format (s, "mark-and-transmit");
3664 s = format (s, "ILLEGAL");
3669 format_dscp (u8 * s, va_list * va)
3671 u32 i = va_arg (*va, u32);
3676 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3680 return format (s, "ILLEGAL");
3682 s = format (s, "%s", t);
3687 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3689 vat_main_t *vam = &vat_main;
3690 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3692 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3693 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3695 conform_dscp_str = format (0, "");
3697 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3698 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3700 exceed_dscp_str = format (0, "");
3702 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3703 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3705 violate_dscp_str = format (0, "");
3707 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3708 "rate type %U, round type %U, %s rate, %s color-aware, "
3709 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3710 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3711 "conform action %U%s, exceed action %U%s, violate action %U%s",
3713 format_policer_type, mp->type,
3716 clib_net_to_host_u64 (mp->cb),
3717 clib_net_to_host_u64 (mp->eb),
3718 format_policer_rate_type, mp->rate_type,
3719 format_policer_round_type, mp->round_type,
3720 mp->single_rate ? "single" : "dual",
3721 mp->color_aware ? "is" : "not",
3722 ntohl (mp->cir_tokens_per_period),
3723 ntohl (mp->pir_tokens_per_period),
3725 ntohl (mp->current_limit),
3726 ntohl (mp->current_bucket),
3727 ntohl (mp->extended_limit),
3728 ntohl (mp->extended_bucket),
3729 clib_net_to_host_u64 (mp->last_update_time),
3730 format_policer_action_type, mp->conform_action_type,
3732 format_policer_action_type, mp->exceed_action_type,
3734 format_policer_action_type, mp->violate_action_type,
3737 vec_free (conform_dscp_str);
3738 vec_free (exceed_dscp_str);
3739 vec_free (violate_dscp_str);
3742 static void vl_api_policer_details_t_handler_json
3743 (vl_api_policer_details_t * mp)
3745 vat_main_t *vam = &vat_main;
3746 vat_json_node_t *node;
3747 u8 *rate_type_str, *round_type_str, *type_str;
3748 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3750 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3752 format (0, "%U", format_policer_round_type, mp->round_type);
3753 type_str = format (0, "%U", format_policer_type, mp->type);
3754 conform_action_str = format (0, "%U", format_policer_action_type,
3755 mp->conform_action_type);
3756 exceed_action_str = format (0, "%U", format_policer_action_type,
3757 mp->exceed_action_type);
3758 violate_action_str = format (0, "%U", format_policer_action_type,
3759 mp->violate_action_type);
3761 if (VAT_JSON_ARRAY != vam->json_tree.type)
3763 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3764 vat_json_init_array (&vam->json_tree);
3766 node = vat_json_array_add (&vam->json_tree);
3768 vat_json_init_object (node);
3769 vat_json_object_add_string_copy (node, "name", mp->name);
3770 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3771 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3772 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
3773 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
3774 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3775 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3776 vat_json_object_add_string_copy (node, "type", type_str);
3777 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3778 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3779 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3780 vat_json_object_add_uint (node, "cir_tokens_per_period",
3781 ntohl (mp->cir_tokens_per_period));
3782 vat_json_object_add_uint (node, "eir_tokens_per_period",
3783 ntohl (mp->pir_tokens_per_period));
3784 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3785 vat_json_object_add_uint (node, "current_bucket",
3786 ntohl (mp->current_bucket));
3787 vat_json_object_add_uint (node, "extended_limit",
3788 ntohl (mp->extended_limit));
3789 vat_json_object_add_uint (node, "extended_bucket",
3790 ntohl (mp->extended_bucket));
3791 vat_json_object_add_uint (node, "last_update_time",
3792 ntohl (mp->last_update_time));
3793 vat_json_object_add_string_copy (node, "conform_action",
3794 conform_action_str);
3795 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3797 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3798 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3799 vec_free (dscp_str);
3801 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3802 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3804 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3805 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3806 vec_free (dscp_str);
3808 vat_json_object_add_string_copy (node, "violate_action",
3809 violate_action_str);
3810 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3812 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3813 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3814 vec_free (dscp_str);
3817 vec_free (rate_type_str);
3818 vec_free (round_type_str);
3819 vec_free (type_str);
3820 vec_free (conform_action_str);
3821 vec_free (exceed_action_str);
3822 vec_free (violate_action_str);
3826 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3829 vat_main_t *vam = &vat_main;
3830 int i, count = ntohl (mp->count);
3833 print (vam->ofp, "classify table ids (%d) : ", count);
3834 for (i = 0; i < count; i++)
3836 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3837 print (vam->ofp, (i < count - 1) ? "," : "");
3839 vam->retval = ntohl (mp->retval);
3840 vam->result_ready = 1;
3844 vl_api_classify_table_ids_reply_t_handler_json
3845 (vl_api_classify_table_ids_reply_t * mp)
3847 vat_main_t *vam = &vat_main;
3848 int i, count = ntohl (mp->count);
3852 vat_json_node_t node;
3854 vat_json_init_object (&node);
3855 for (i = 0; i < count; i++)
3857 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3859 vat_json_print (vam->ofp, &node);
3860 vat_json_free (&node);
3862 vam->retval = ntohl (mp->retval);
3863 vam->result_ready = 1;
3867 vl_api_classify_table_by_interface_reply_t_handler
3868 (vl_api_classify_table_by_interface_reply_t * mp)
3870 vat_main_t *vam = &vat_main;
3873 table_id = ntohl (mp->l2_table_id);
3875 print (vam->ofp, "l2 table id : %d", table_id);
3877 print (vam->ofp, "l2 table id : No input ACL tables configured");
3878 table_id = ntohl (mp->ip4_table_id);
3880 print (vam->ofp, "ip4 table id : %d", table_id);
3882 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3883 table_id = ntohl (mp->ip6_table_id);
3885 print (vam->ofp, "ip6 table id : %d", table_id);
3887 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3888 vam->retval = ntohl (mp->retval);
3889 vam->result_ready = 1;
3893 vl_api_classify_table_by_interface_reply_t_handler_json
3894 (vl_api_classify_table_by_interface_reply_t * mp)
3896 vat_main_t *vam = &vat_main;
3897 vat_json_node_t node;
3899 vat_json_init_object (&node);
3901 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3902 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3903 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3905 vat_json_print (vam->ofp, &node);
3906 vat_json_free (&node);
3908 vam->retval = ntohl (mp->retval);
3909 vam->result_ready = 1;
3912 static void vl_api_policer_add_del_reply_t_handler
3913 (vl_api_policer_add_del_reply_t * mp)
3915 vat_main_t *vam = &vat_main;
3916 i32 retval = ntohl (mp->retval);
3917 if (vam->async_mode)
3919 vam->async_errors += (retval < 0);
3923 vam->retval = retval;
3924 vam->result_ready = 1;
3925 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3927 * Note: this is just barely thread-safe, depends on
3928 * the main thread spinning waiting for an answer...
3930 errmsg ("policer index %d", ntohl (mp->policer_index));
3934 static void vl_api_policer_add_del_reply_t_handler_json
3935 (vl_api_policer_add_del_reply_t * mp)
3937 vat_main_t *vam = &vat_main;
3938 vat_json_node_t node;
3940 vat_json_init_object (&node);
3941 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3942 vat_json_object_add_uint (&node, "policer_index",
3943 ntohl (mp->policer_index));
3945 vat_json_print (vam->ofp, &node);
3946 vat_json_free (&node);
3948 vam->retval = ntohl (mp->retval);
3949 vam->result_ready = 1;
3952 /* Format hex dump. */
3954 format_hex_bytes (u8 * s, va_list * va)
3956 u8 *bytes = va_arg (*va, u8 *);
3957 int n_bytes = va_arg (*va, int);
3960 /* Print short or long form depending on byte count. */
3961 uword short_form = n_bytes <= 32;
3962 uword indent = format_get_indent (s);
3967 for (i = 0; i < n_bytes; i++)
3969 if (!short_form && (i % 32) == 0)
3970 s = format (s, "%08x: ", i);
3971 s = format (s, "%02x", bytes[i]);
3972 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3973 s = format (s, "\n%U", format_white_space, indent);
3980 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3983 vat_main_t *vam = &vat_main;
3984 i32 retval = ntohl (mp->retval);
3987 print (vam->ofp, "classify table info :");
3988 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3989 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3990 ntohl (mp->miss_next_index));
3991 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3992 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3993 ntohl (mp->match_n_vectors));
3994 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3995 ntohl (mp->mask_length));
3997 vam->retval = retval;
3998 vam->result_ready = 1;
4002 vl_api_classify_table_info_reply_t_handler_json
4003 (vl_api_classify_table_info_reply_t * mp)
4005 vat_main_t *vam = &vat_main;
4006 vat_json_node_t node;
4008 i32 retval = ntohl (mp->retval);
4011 vat_json_init_object (&node);
4013 vat_json_object_add_int (&node, "sessions",
4014 ntohl (mp->active_sessions));
4015 vat_json_object_add_int (&node, "nexttbl",
4016 ntohl (mp->next_table_index));
4017 vat_json_object_add_int (&node, "nextnode",
4018 ntohl (mp->miss_next_index));
4019 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4020 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4021 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4022 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4023 ntohl (mp->mask_length), 0);
4024 vat_json_object_add_string_copy (&node, "mask", s);
4026 vat_json_print (vam->ofp, &node);
4027 vat_json_free (&node);
4029 vam->retval = ntohl (mp->retval);
4030 vam->result_ready = 1;
4034 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4037 vat_main_t *vam = &vat_main;
4039 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4040 ntohl (mp->hit_next_index), ntohl (mp->advance),
4041 ntohl (mp->opaque_index));
4042 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4043 ntohl (mp->match_length));
4047 vl_api_classify_session_details_t_handler_json
4048 (vl_api_classify_session_details_t * mp)
4050 vat_main_t *vam = &vat_main;
4051 vat_json_node_t *node = NULL;
4053 if (VAT_JSON_ARRAY != vam->json_tree.type)
4055 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4056 vat_json_init_array (&vam->json_tree);
4058 node = vat_json_array_add (&vam->json_tree);
4060 vat_json_init_object (node);
4061 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4062 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4063 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4065 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4067 vat_json_object_add_string_copy (node, "match", s);
4070 static void vl_api_pg_create_interface_reply_t_handler
4071 (vl_api_pg_create_interface_reply_t * mp)
4073 vat_main_t *vam = &vat_main;
4075 vam->retval = ntohl (mp->retval);
4076 vam->result_ready = 1;
4079 static void vl_api_pg_create_interface_reply_t_handler_json
4080 (vl_api_pg_create_interface_reply_t * mp)
4082 vat_main_t *vam = &vat_main;
4083 vat_json_node_t node;
4085 i32 retval = ntohl (mp->retval);
4088 vat_json_init_object (&node);
4090 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4092 vat_json_print (vam->ofp, &node);
4093 vat_json_free (&node);
4095 vam->retval = ntohl (mp->retval);
4096 vam->result_ready = 1;
4099 static void vl_api_policer_classify_details_t_handler
4100 (vl_api_policer_classify_details_t * mp)
4102 vat_main_t *vam = &vat_main;
4104 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4105 ntohl (mp->table_index));
4108 static void vl_api_policer_classify_details_t_handler_json
4109 (vl_api_policer_classify_details_t * mp)
4111 vat_main_t *vam = &vat_main;
4112 vat_json_node_t *node;
4114 if (VAT_JSON_ARRAY != vam->json_tree.type)
4116 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4117 vat_json_init_array (&vam->json_tree);
4119 node = vat_json_array_add (&vam->json_tree);
4121 vat_json_init_object (node);
4122 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4123 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4126 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4127 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4129 vat_main_t *vam = &vat_main;
4130 i32 retval = ntohl (mp->retval);
4131 if (vam->async_mode)
4133 vam->async_errors += (retval < 0);
4137 vam->retval = retval;
4138 vam->sw_if_index = ntohl (mp->sw_if_index);
4139 vam->result_ready = 1;
4143 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4144 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4146 vat_main_t *vam = &vat_main;
4147 vat_json_node_t node;
4149 vat_json_init_object (&node);
4150 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4151 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4153 vat_json_print (vam->ofp, &node);
4154 vat_json_free (&node);
4156 vam->retval = ntohl (mp->retval);
4157 vam->result_ready = 1;
4160 static void vl_api_flow_classify_details_t_handler
4161 (vl_api_flow_classify_details_t * mp)
4163 vat_main_t *vam = &vat_main;
4165 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4166 ntohl (mp->table_index));
4169 static void vl_api_flow_classify_details_t_handler_json
4170 (vl_api_flow_classify_details_t * mp)
4172 vat_main_t *vam = &vat_main;
4173 vat_json_node_t *node;
4175 if (VAT_JSON_ARRAY != vam->json_tree.type)
4177 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4178 vat_json_init_array (&vam->json_tree);
4180 node = vat_json_array_add (&vam->json_tree);
4182 vat_json_init_object (node);
4183 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4184 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4187 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
4188 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
4189 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
4190 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
4191 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4192 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4193 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4194 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4195 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4196 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4197 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4198 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4199 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4200 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4203 * Generate boilerplate reply handlers, which
4204 * dig the return value out of the xxx_reply_t API message,
4205 * stick it into vam->retval, and set vam->result_ready
4207 * Could also do this by pointing N message decode slots at
4208 * a single function, but that could break in subtle ways.
4211 #define foreach_standard_reply_retval_handler \
4212 _(sw_interface_set_flags_reply) \
4213 _(sw_interface_add_del_address_reply) \
4214 _(sw_interface_set_table_reply) \
4215 _(sw_interface_set_mpls_enable_reply) \
4216 _(sw_interface_set_vpath_reply) \
4217 _(sw_interface_set_vxlan_bypass_reply) \
4218 _(sw_interface_set_l2_bridge_reply) \
4219 _(bridge_domain_add_del_reply) \
4220 _(sw_interface_set_l2_xconnect_reply) \
4221 _(l2fib_add_del_reply) \
4222 _(l2fib_flush_int_reply) \
4223 _(l2fib_flush_bd_reply) \
4224 _(ip_add_del_route_reply) \
4225 _(ip_mroute_add_del_reply) \
4226 _(mpls_route_add_del_reply) \
4227 _(mpls_ip_bind_unbind_reply) \
4228 _(proxy_arp_add_del_reply) \
4229 _(proxy_arp_intfc_enable_disable_reply) \
4230 _(sw_interface_set_unnumbered_reply) \
4231 _(ip_neighbor_add_del_reply) \
4232 _(reset_vrf_reply) \
4233 _(oam_add_del_reply) \
4234 _(reset_fib_reply) \
4235 _(dhcp_proxy_config_reply) \
4236 _(dhcp_proxy_set_vss_reply) \
4237 _(dhcp_client_config_reply) \
4238 _(set_ip_flow_hash_reply) \
4239 _(sw_interface_ip6_enable_disable_reply) \
4240 _(sw_interface_ip6_set_link_local_address_reply) \
4241 _(ip6nd_proxy_add_del_reply) \
4242 _(sw_interface_ip6nd_ra_prefix_reply) \
4243 _(sw_interface_ip6nd_ra_config_reply) \
4244 _(set_arp_neighbor_limit_reply) \
4245 _(l2_patch_add_del_reply) \
4246 _(sr_policy_add_reply) \
4247 _(sr_policy_mod_reply) \
4248 _(sr_policy_del_reply) \
4249 _(sr_localsid_add_del_reply) \
4250 _(sr_steering_add_del_reply) \
4251 _(classify_add_del_session_reply) \
4252 _(classify_set_interface_ip_table_reply) \
4253 _(classify_set_interface_l2_tables_reply) \
4254 _(l2tpv3_set_tunnel_cookies_reply) \
4255 _(l2tpv3_interface_enable_disable_reply) \
4256 _(l2tpv3_set_lookup_key_reply) \
4257 _(l2_fib_clear_table_reply) \
4258 _(l2_interface_efp_filter_reply) \
4259 _(l2_interface_vlan_tag_rewrite_reply) \
4260 _(modify_vhost_user_if_reply) \
4261 _(delete_vhost_user_if_reply) \
4262 _(want_ip4_arp_events_reply) \
4263 _(want_ip6_nd_events_reply) \
4264 _(input_acl_set_interface_reply) \
4265 _(ipsec_spd_add_del_reply) \
4266 _(ipsec_interface_add_del_spd_reply) \
4267 _(ipsec_spd_add_del_entry_reply) \
4268 _(ipsec_sad_add_del_entry_reply) \
4269 _(ipsec_sa_set_key_reply) \
4270 _(ipsec_tunnel_if_add_del_reply) \
4271 _(ikev2_profile_add_del_reply) \
4272 _(ikev2_profile_set_auth_reply) \
4273 _(ikev2_profile_set_id_reply) \
4274 _(ikev2_profile_set_ts_reply) \
4275 _(ikev2_set_local_key_reply) \
4276 _(ikev2_set_responder_reply) \
4277 _(ikev2_set_ike_transforms_reply) \
4278 _(ikev2_set_esp_transforms_reply) \
4279 _(ikev2_set_sa_lifetime_reply) \
4280 _(ikev2_initiate_sa_init_reply) \
4281 _(ikev2_initiate_del_ike_sa_reply) \
4282 _(ikev2_initiate_del_child_sa_reply) \
4283 _(ikev2_initiate_rekey_child_sa_reply) \
4284 _(delete_loopback_reply) \
4285 _(bd_ip_mac_add_del_reply) \
4286 _(map_del_domain_reply) \
4287 _(map_add_del_rule_reply) \
4288 _(want_interface_events_reply) \
4289 _(want_stats_reply) \
4290 _(cop_interface_enable_disable_reply) \
4291 _(cop_whitelist_enable_disable_reply) \
4292 _(sw_interface_clear_stats_reply) \
4293 _(ioam_enable_reply) \
4294 _(ioam_disable_reply) \
4295 _(one_add_del_locator_reply) \
4296 _(one_add_del_local_eid_reply) \
4297 _(one_add_del_remote_mapping_reply) \
4298 _(one_add_del_adjacency_reply) \
4299 _(one_add_del_map_resolver_reply) \
4300 _(one_add_del_map_server_reply) \
4301 _(one_enable_disable_reply) \
4302 _(one_rloc_probe_enable_disable_reply) \
4303 _(one_map_register_enable_disable_reply) \
4304 _(one_pitr_set_locator_set_reply) \
4305 _(one_map_request_mode_reply) \
4306 _(one_add_del_map_request_itr_rlocs_reply) \
4307 _(one_eid_table_add_del_map_reply) \
4308 _(one_use_petr_reply) \
4309 _(one_stats_enable_disable_reply) \
4310 _(one_stats_flush_reply) \
4311 _(gpe_add_del_fwd_entry_reply) \
4312 _(gpe_enable_disable_reply) \
4313 _(gpe_set_encap_mode_reply) \
4314 _(gpe_add_del_iface_reply) \
4315 _(vxlan_gpe_add_del_tunnel_reply) \
4316 _(af_packet_delete_reply) \
4317 _(policer_classify_set_interface_reply) \
4318 _(netmap_create_reply) \
4319 _(netmap_delete_reply) \
4320 _(set_ipfix_exporter_reply) \
4321 _(set_ipfix_classify_stream_reply) \
4322 _(ipfix_classify_table_add_del_reply) \
4323 _(flow_classify_set_interface_reply) \
4324 _(sw_interface_span_enable_disable_reply) \
4325 _(pg_capture_reply) \
4326 _(pg_enable_disable_reply) \
4327 _(ip_source_and_port_range_check_add_del_reply) \
4328 _(ip_source_and_port_range_check_interface_add_del_reply)\
4329 _(delete_subif_reply) \
4330 _(l2_interface_pbb_tag_rewrite_reply) \
4332 _(feature_enable_disable_reply) \
4333 _(sw_interface_tag_add_del_reply) \
4334 _(sw_interface_set_mtu_reply)
4337 static void vl_api_##n##_t_handler \
4338 (vl_api_##n##_t * mp) \
4340 vat_main_t * vam = &vat_main; \
4341 i32 retval = ntohl(mp->retval); \
4342 if (vam->async_mode) { \
4343 vam->async_errors += (retval < 0); \
4345 vam->retval = retval; \
4346 vam->result_ready = 1; \
4349 foreach_standard_reply_retval_handler;
4353 static void vl_api_##n##_t_handler_json \
4354 (vl_api_##n##_t * mp) \
4356 vat_main_t * vam = &vat_main; \
4357 vat_json_node_t node; \
4358 vat_json_init_object(&node); \
4359 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4360 vat_json_print(vam->ofp, &node); \
4361 vam->retval = ntohl(mp->retval); \
4362 vam->result_ready = 1; \
4364 foreach_standard_reply_retval_handler;
4368 * Table of message reply handlers, must include boilerplate handlers
4372 #define foreach_vpe_api_reply_msg \
4373 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4374 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4375 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4376 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4377 _(CONTROL_PING_REPLY, control_ping_reply) \
4378 _(CLI_REPLY, cli_reply) \
4379 _(CLI_INBAND_REPLY, cli_inband_reply) \
4380 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4381 sw_interface_add_del_address_reply) \
4382 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4383 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4384 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4385 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4386 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4387 sw_interface_set_l2_xconnect_reply) \
4388 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4389 sw_interface_set_l2_bridge_reply) \
4390 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4391 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4392 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
4393 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4394 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
4395 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
4396 _(L2_FLAGS_REPLY, l2_flags_reply) \
4397 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4398 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4399 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4400 _(TAP_DELETE_REPLY, tap_delete_reply) \
4401 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4402 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4403 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4404 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4405 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4406 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4407 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4408 proxy_arp_intfc_enable_disable_reply) \
4409 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4410 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4411 sw_interface_set_unnumbered_reply) \
4412 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4413 _(RESET_VRF_REPLY, reset_vrf_reply) \
4414 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4415 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4416 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4417 _(RESET_FIB_REPLY, reset_fib_reply) \
4418 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4419 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4420 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4421 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4422 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4423 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4424 sw_interface_ip6_enable_disable_reply) \
4425 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4426 sw_interface_ip6_set_link_local_address_reply) \
4427 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
4428 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
4429 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4430 sw_interface_ip6nd_ra_prefix_reply) \
4431 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4432 sw_interface_ip6nd_ra_config_reply) \
4433 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4434 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4435 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4436 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4437 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4438 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4439 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4440 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4441 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4442 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4443 classify_set_interface_ip_table_reply) \
4444 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4445 classify_set_interface_l2_tables_reply) \
4446 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4447 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4448 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4449 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4450 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4451 l2tpv3_interface_enable_disable_reply) \
4452 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4453 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4454 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4455 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4456 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4457 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4458 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4459 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4460 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4461 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4462 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4463 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4464 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4465 _(SHOW_VERSION_REPLY, show_version_reply) \
4466 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
4467 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4468 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4469 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4470 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4471 _(IP4_ARP_EVENT, ip4_arp_event) \
4472 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4473 _(IP6_ND_EVENT, ip6_nd_event) \
4474 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4475 _(IP_ADDRESS_DETAILS, ip_address_details) \
4476 _(IP_DETAILS, ip_details) \
4477 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4478 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4479 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4480 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4481 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4482 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
4483 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4484 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4485 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4486 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4487 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4488 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4489 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4490 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4491 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4492 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4493 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4494 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4495 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4496 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4497 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4498 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4499 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4500 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4501 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4502 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4503 _(MAP_RULE_DETAILS, map_rule_details) \
4504 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4505 _(WANT_STATS_REPLY, want_stats_reply) \
4506 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4507 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4508 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4509 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4510 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4511 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4512 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4513 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4514 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4515 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4516 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4517 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4518 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4519 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4520 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4521 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4522 one_map_register_enable_disable_reply) \
4523 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4524 one_rloc_probe_enable_disable_reply) \
4525 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4526 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
4527 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4528 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4529 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4530 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4531 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4532 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4533 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4534 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4535 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4536 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4537 _(ONE_STATS_DETAILS, one_stats_details) \
4538 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
4539 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
4540 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
4541 show_one_stats_enable_disable_reply) \
4542 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4543 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4544 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4545 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4546 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4547 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
4548 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4549 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4550 gpe_fwd_entry_path_details) \
4551 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4552 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4553 one_add_del_map_request_itr_rlocs_reply) \
4554 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4555 one_get_map_request_itr_rlocs_reply) \
4556 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4557 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
4558 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4559 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4560 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4561 show_one_map_register_state_reply) \
4562 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4563 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4564 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4565 _(POLICER_DETAILS, policer_details) \
4566 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4567 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4568 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4569 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4570 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4571 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4572 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4573 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4574 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4575 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4576 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4577 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4578 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4579 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4580 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4581 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4582 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4583 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4584 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4585 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4586 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4587 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4588 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4589 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4590 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4591 ip_source_and_port_range_check_add_del_reply) \
4592 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4593 ip_source_and_port_range_check_interface_add_del_reply) \
4594 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4595 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4596 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4597 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4598 _(PUNT_REPLY, punt_reply) \
4599 _(IP_FIB_DETAILS, ip_fib_details) \
4600 _(IP6_FIB_DETAILS, ip6_fib_details) \
4601 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4602 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4603 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4604 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4605 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4606 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4608 #define foreach_standalone_reply_msg \
4609 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4610 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
4611 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
4612 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4613 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4614 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4615 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
4624 #define STR_VTR_OP_CASE(op) \
4625 case L2_VTR_ ## op: \
4629 str_vtr_op (u32 vtr_op)
4633 STR_VTR_OP_CASE (DISABLED);
4634 STR_VTR_OP_CASE (PUSH_1);
4635 STR_VTR_OP_CASE (PUSH_2);
4636 STR_VTR_OP_CASE (POP_1);
4637 STR_VTR_OP_CASE (POP_2);
4638 STR_VTR_OP_CASE (TRANSLATE_1_1);
4639 STR_VTR_OP_CASE (TRANSLATE_1_2);
4640 STR_VTR_OP_CASE (TRANSLATE_2_1);
4641 STR_VTR_OP_CASE (TRANSLATE_2_2);
4648 dump_sub_interface_table (vat_main_t * vam)
4650 const sw_interface_subif_t *sub = NULL;
4652 if (vam->json_output)
4655 ("JSON output supported only for VPE API calls and dump_stats_table");
4660 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4661 "Interface", "sw_if_index",
4662 "sub id", "dot1ad", "tags", "outer id",
4663 "inner id", "exact", "default", "outer any", "inner any");
4665 vec_foreach (sub, vam->sw_if_subif_table)
4668 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4669 sub->interface_name,
4671 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4672 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4673 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4674 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4675 if (sub->vtr_op != L2_VTR_DISABLED)
4678 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4679 "tag1: %d tag2: %d ]",
4680 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4681 sub->vtr_tag1, sub->vtr_tag2);
4689 name_sort_cmp (void *a1, void *a2)
4691 name_sort_t *n1 = a1;
4692 name_sort_t *n2 = a2;
4694 return strcmp ((char *) n1->name, (char *) n2->name);
4698 dump_interface_table (vat_main_t * vam)
4701 name_sort_t *nses = 0, *ns;
4703 if (vam->json_output)
4706 ("JSON output supported only for VPE API calls and dump_stats_table");
4711 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4713 vec_add2 (nses, ns, 1);
4714 ns->name = (u8 *)(p->key);
4715 ns->value = (u32) p->value[0];
4719 vec_sort_with_function (nses, name_sort_cmp);
4721 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4722 vec_foreach (ns, nses)
4724 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4731 dump_ip_table (vat_main_t * vam, int is_ipv6)
4733 const ip_details_t *det = NULL;
4734 const ip_address_details_t *address = NULL;
4737 print (vam->ofp, "%-12s", "sw_if_index");
4739 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4746 print (vam->ofp, "%-12d", i);
4747 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4752 vec_foreach (address, det->addr)
4756 is_ipv6 ? format_ip6_address : format_ip4_address,
4757 address->ip, address->prefix_length);
4765 dump_ipv4_table (vat_main_t * vam)
4767 if (vam->json_output)
4770 ("JSON output supported only for VPE API calls and dump_stats_table");
4774 return dump_ip_table (vam, 0);
4778 dump_ipv6_table (vat_main_t * vam)
4780 if (vam->json_output)
4783 ("JSON output supported only for VPE API calls and dump_stats_table");
4787 return dump_ip_table (vam, 1);
4791 counter_type_to_str (u8 counter_type, u8 is_combined)
4795 switch (counter_type)
4797 case VNET_INTERFACE_COUNTER_DROP:
4799 case VNET_INTERFACE_COUNTER_PUNT:
4801 case VNET_INTERFACE_COUNTER_IP4:
4803 case VNET_INTERFACE_COUNTER_IP6:
4805 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4807 case VNET_INTERFACE_COUNTER_RX_MISS:
4809 case VNET_INTERFACE_COUNTER_RX_ERROR:
4811 case VNET_INTERFACE_COUNTER_TX_ERROR:
4814 return "INVALID-COUNTER-TYPE";
4819 switch (counter_type)
4821 case VNET_INTERFACE_COUNTER_RX:
4823 case VNET_INTERFACE_COUNTER_TX:
4826 return "INVALID-COUNTER-TYPE";
4832 dump_stats_table (vat_main_t * vam)
4834 vat_json_node_t node;
4835 vat_json_node_t *msg_array;
4836 vat_json_node_t *msg;
4837 vat_json_node_t *counter_array;
4838 vat_json_node_t *counter;
4839 interface_counter_t c;
4841 ip4_fib_counter_t *c4;
4842 ip6_fib_counter_t *c6;
4843 ip4_nbr_counter_t *n4;
4844 ip6_nbr_counter_t *n6;
4847 if (!vam->json_output)
4849 clib_warning ("dump_stats_table supported only in JSON format");
4853 vat_json_init_object (&node);
4855 /* interface counters */
4856 msg_array = vat_json_object_add (&node, "interface_counters");
4857 vat_json_init_array (msg_array);
4858 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4860 msg = vat_json_array_add (msg_array);
4861 vat_json_init_object (msg);
4862 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4863 (u8 *) counter_type_to_str (i, 0));
4864 vat_json_object_add_int (msg, "is_combined", 0);
4865 counter_array = vat_json_object_add (msg, "data");
4866 vat_json_init_array (counter_array);
4867 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4869 packets = vam->simple_interface_counters[i][j];
4870 vat_json_array_add_uint (counter_array, packets);
4873 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4875 msg = vat_json_array_add (msg_array);
4876 vat_json_init_object (msg);
4877 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4878 (u8 *) counter_type_to_str (i, 1));
4879 vat_json_object_add_int (msg, "is_combined", 1);
4880 counter_array = vat_json_object_add (msg, "data");
4881 vat_json_init_array (counter_array);
4882 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4884 c = vam->combined_interface_counters[i][j];
4885 counter = vat_json_array_add (counter_array);
4886 vat_json_init_object (counter);
4887 vat_json_object_add_uint (counter, "packets", c.packets);
4888 vat_json_object_add_uint (counter, "bytes", c.bytes);
4892 /* ip4 fib counters */
4893 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4894 vat_json_init_array (msg_array);
4895 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4897 msg = vat_json_array_add (msg_array);
4898 vat_json_init_object (msg);
4899 vat_json_object_add_uint (msg, "vrf_id",
4900 vam->ip4_fib_counters_vrf_id_by_index[i]);
4901 counter_array = vat_json_object_add (msg, "c");
4902 vat_json_init_array (counter_array);
4903 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4905 counter = vat_json_array_add (counter_array);
4906 vat_json_init_object (counter);
4907 c4 = &vam->ip4_fib_counters[i][j];
4908 vat_json_object_add_ip4 (counter, "address", c4->address);
4909 vat_json_object_add_uint (counter, "address_length",
4910 c4->address_length);
4911 vat_json_object_add_uint (counter, "packets", c4->packets);
4912 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4916 /* ip6 fib counters */
4917 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4918 vat_json_init_array (msg_array);
4919 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4921 msg = vat_json_array_add (msg_array);
4922 vat_json_init_object (msg);
4923 vat_json_object_add_uint (msg, "vrf_id",
4924 vam->ip6_fib_counters_vrf_id_by_index[i]);
4925 counter_array = vat_json_object_add (msg, "c");
4926 vat_json_init_array (counter_array);
4927 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4929 counter = vat_json_array_add (counter_array);
4930 vat_json_init_object (counter);
4931 c6 = &vam->ip6_fib_counters[i][j];
4932 vat_json_object_add_ip6 (counter, "address", c6->address);
4933 vat_json_object_add_uint (counter, "address_length",
4934 c6->address_length);
4935 vat_json_object_add_uint (counter, "packets", c6->packets);
4936 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4940 /* ip4 nbr counters */
4941 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4942 vat_json_init_array (msg_array);
4943 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4945 msg = vat_json_array_add (msg_array);
4946 vat_json_init_object (msg);
4947 vat_json_object_add_uint (msg, "sw_if_index", i);
4948 counter_array = vat_json_object_add (msg, "c");
4949 vat_json_init_array (counter_array);
4950 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4952 counter = vat_json_array_add (counter_array);
4953 vat_json_init_object (counter);
4954 n4 = &vam->ip4_nbr_counters[i][j];
4955 vat_json_object_add_ip4 (counter, "address", n4->address);
4956 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4957 vat_json_object_add_uint (counter, "packets", n4->packets);
4958 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4962 /* ip6 nbr counters */
4963 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4964 vat_json_init_array (msg_array);
4965 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4967 msg = vat_json_array_add (msg_array);
4968 vat_json_init_object (msg);
4969 vat_json_object_add_uint (msg, "sw_if_index", i);
4970 counter_array = vat_json_object_add (msg, "c");
4971 vat_json_init_array (counter_array);
4972 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4974 counter = vat_json_array_add (counter_array);
4975 vat_json_init_object (counter);
4976 n6 = &vam->ip6_nbr_counters[i][j];
4977 vat_json_object_add_ip6 (counter, "address", n6->address);
4978 vat_json_object_add_uint (counter, "packets", n6->packets);
4979 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4983 vat_json_print (vam->ofp, &node);
4984 vat_json_free (&node);
4990 exec (vat_main_t * vam)
4992 api_main_t *am = &api_main;
4997 unformat_input_t *i = vam->input;
4999 if (vec_len (i->buffer) == 0)
5002 if (vam->exec_mode == 0 && unformat (i, "mode"))
5007 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5017 * Copy cmd into shared memory.
5018 * In order for the CLI command to work, it
5019 * must be a vector ending in \n, not a C-string ending
5022 pthread_mutex_lock (&am->vlib_rp->mutex);
5023 oldheap = svm_push_data_heap (am->vlib_rp);
5025 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
5026 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
5028 svm_pop_heap (oldheap);
5029 pthread_mutex_unlock (&am->vlib_rp->mutex);
5031 mp->cmd_in_shmem = pointer_to_uword (cmd);
5033 timeout = vat_time_now (vam) + 10.0;
5035 while (vat_time_now (vam) < timeout)
5037 if (vam->result_ready == 1)
5040 if (vam->shmem_result != NULL)
5041 print (vam->ofp, "%s", vam->shmem_result);
5042 pthread_mutex_lock (&am->vlib_rp->mutex);
5043 oldheap = svm_push_data_heap (am->vlib_rp);
5045 free_me = (u8 *) vam->shmem_result;
5048 svm_pop_heap (oldheap);
5049 pthread_mutex_unlock (&am->vlib_rp->mutex);
5057 * Future replacement of exec() that passes CLI buffers directly in
5058 * the API messages instead of an additional shared memory area.
5061 exec_inband (vat_main_t * vam)
5063 vl_api_cli_inband_t *mp;
5064 unformat_input_t *i = vam->input;
5067 if (vec_len (i->buffer) == 0)
5070 if (vam->exec_mode == 0 && unformat (i, "mode"))
5075 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5082 * In order for the CLI command to work, it
5083 * must be a vector ending in \n, not a C-string ending
5086 u32 len = vec_len (vam->input->buffer);
5087 M2 (CLI_INBAND, mp, len);
5088 clib_memcpy (mp->cmd, vam->input->buffer, len);
5089 mp->length = htonl (len);
5092 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
5097 api_create_loopback (vat_main_t * vam)
5099 unformat_input_t *i = vam->input;
5100 vl_api_create_loopback_t *mp;
5101 vl_api_create_loopback_instance_t *mp_lbi;
5104 u8 is_specified = 0;
5105 u32 user_instance = 0;
5108 memset (mac_address, 0, sizeof (mac_address));
5110 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5112 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5114 if (unformat (i, "instance %d", &user_instance))
5122 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5123 mp_lbi->is_specified = is_specified;
5125 mp_lbi->user_instance = htonl (user_instance);
5127 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5132 /* Construct the API message */
5133 M (CREATE_LOOPBACK, mp);
5135 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5144 api_delete_loopback (vat_main_t * vam)
5146 unformat_input_t *i = vam->input;
5147 vl_api_delete_loopback_t *mp;
5148 u32 sw_if_index = ~0;
5151 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5153 if (unformat (i, "sw_if_index %d", &sw_if_index))
5159 if (sw_if_index == ~0)
5161 errmsg ("missing sw_if_index");
5165 /* Construct the API message */
5166 M (DELETE_LOOPBACK, mp);
5167 mp->sw_if_index = ntohl (sw_if_index);
5175 api_want_stats (vat_main_t * vam)
5177 unformat_input_t *i = vam->input;
5178 vl_api_want_stats_t *mp;
5182 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5184 if (unformat (i, "enable"))
5186 else if (unformat (i, "disable"))
5194 errmsg ("missing enable|disable");
5199 mp->enable_disable = enable;
5207 api_want_interface_events (vat_main_t * vam)
5209 unformat_input_t *i = vam->input;
5210 vl_api_want_interface_events_t *mp;
5214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5216 if (unformat (i, "enable"))
5218 else if (unformat (i, "disable"))
5226 errmsg ("missing enable|disable");
5230 M (WANT_INTERFACE_EVENTS, mp);
5231 mp->enable_disable = enable;
5233 vam->interface_event_display = enable;
5241 /* Note: non-static, called once to set up the initial intfc table */
5243 api_sw_interface_dump (vat_main_t * vam)
5245 vl_api_sw_interface_dump_t *mp;
5246 vl_api_control_ping_t *mp_ping;
5248 name_sort_t *nses = 0, *ns;
5249 sw_interface_subif_t *sub = NULL;
5252 /* Toss the old name table */
5254 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5256 vec_add2 (nses, ns, 1);
5257 ns->name = (u8 *)(p->key);
5258 ns->value = (u32) p->value[0];
5262 hash_free (vam->sw_if_index_by_interface_name);
5264 vec_foreach (ns, nses) vec_free (ns->name);
5268 vec_foreach (sub, vam->sw_if_subif_table)
5270 vec_free (sub->interface_name);
5272 vec_free (vam->sw_if_subif_table);
5274 /* recreate the interface name hash table */
5275 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5277 /* Get list of ethernets */
5278 M (SW_INTERFACE_DUMP, mp);
5279 mp->name_filter_valid = 1;
5280 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
5283 /* and local / loopback interfaces */
5284 M (SW_INTERFACE_DUMP, mp);
5285 mp->name_filter_valid = 1;
5286 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
5289 /* and packet-generator interfaces */
5290 M (SW_INTERFACE_DUMP, mp);
5291 mp->name_filter_valid = 1;
5292 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
5295 /* and vxlan-gpe tunnel interfaces */
5296 M (SW_INTERFACE_DUMP, mp);
5297 mp->name_filter_valid = 1;
5298 strncpy ((char *) mp->name_filter, "vxlan_gpe",
5299 sizeof (mp->name_filter) - 1);
5302 /* and vxlan tunnel interfaces */
5303 M (SW_INTERFACE_DUMP, mp);
5304 mp->name_filter_valid = 1;
5305 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
5308 /* and host (af_packet) interfaces */
5309 M (SW_INTERFACE_DUMP, mp);
5310 mp->name_filter_valid = 1;
5311 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
5314 /* and l2tpv3 tunnel interfaces */
5315 M (SW_INTERFACE_DUMP, mp);
5316 mp->name_filter_valid = 1;
5317 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
5318 sizeof (mp->name_filter) - 1);
5321 /* and GRE tunnel interfaces */
5322 M (SW_INTERFACE_DUMP, mp);
5323 mp->name_filter_valid = 1;
5324 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
5327 /* and LISP-GPE interfaces */
5328 M (SW_INTERFACE_DUMP, mp);
5329 mp->name_filter_valid = 1;
5330 strncpy ((char *) mp->name_filter, "lisp_gpe",
5331 sizeof (mp->name_filter) - 1);
5334 /* and IPSEC tunnel interfaces */
5335 M (SW_INTERFACE_DUMP, mp);
5336 mp->name_filter_valid = 1;
5337 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
5340 /* Use a control ping for synchronization */
5341 M (CONTROL_PING, mp_ping);
5349 api_sw_interface_set_flags (vat_main_t * vam)
5351 unformat_input_t *i = vam->input;
5352 vl_api_sw_interface_set_flags_t *mp;
5354 u8 sw_if_index_set = 0;
5355 u8 admin_up = 0, link_up = 0;
5358 /* Parse args required to build the message */
5359 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5361 if (unformat (i, "admin-up"))
5363 else if (unformat (i, "admin-down"))
5365 else if (unformat (i, "link-up"))
5367 else if (unformat (i, "link-down"))
5370 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5371 sw_if_index_set = 1;
5372 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5373 sw_if_index_set = 1;
5378 if (sw_if_index_set == 0)
5380 errmsg ("missing interface name or sw_if_index");
5384 /* Construct the API message */
5385 M (SW_INTERFACE_SET_FLAGS, mp);
5386 mp->sw_if_index = ntohl (sw_if_index);
5387 mp->admin_up_down = admin_up;
5388 mp->link_up_down = link_up;
5393 /* Wait for a reply, return the good/bad news... */
5399 api_sw_interface_clear_stats (vat_main_t * vam)
5401 unformat_input_t *i = vam->input;
5402 vl_api_sw_interface_clear_stats_t *mp;
5404 u8 sw_if_index_set = 0;
5407 /* Parse args required to build the message */
5408 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5410 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5411 sw_if_index_set = 1;
5412 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5413 sw_if_index_set = 1;
5418 /* Construct the API message */
5419 M (SW_INTERFACE_CLEAR_STATS, mp);
5421 if (sw_if_index_set == 1)
5422 mp->sw_if_index = ntohl (sw_if_index);
5424 mp->sw_if_index = ~0;
5429 /* Wait for a reply, return the good/bad news... */
5435 api_sw_interface_add_del_address (vat_main_t * vam)
5437 unformat_input_t *i = vam->input;
5438 vl_api_sw_interface_add_del_address_t *mp;
5440 u8 sw_if_index_set = 0;
5441 u8 is_add = 1, del_all = 0;
5442 u32 address_length = 0;
5443 u8 v4_address_set = 0;
5444 u8 v6_address_set = 0;
5445 ip4_address_t v4address;
5446 ip6_address_t v6address;
5449 /* Parse args required to build the message */
5450 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5452 if (unformat (i, "del-all"))
5454 else if (unformat (i, "del"))
5457 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5458 sw_if_index_set = 1;
5459 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5460 sw_if_index_set = 1;
5461 else if (unformat (i, "%U/%d",
5462 unformat_ip4_address, &v4address, &address_length))
5464 else if (unformat (i, "%U/%d",
5465 unformat_ip6_address, &v6address, &address_length))
5471 if (sw_if_index_set == 0)
5473 errmsg ("missing interface name or sw_if_index");
5476 if (v4_address_set && v6_address_set)
5478 errmsg ("both v4 and v6 addresses set");
5481 if (!v4_address_set && !v6_address_set && !del_all)
5483 errmsg ("no addresses set");
5487 /* Construct the API message */
5488 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5490 mp->sw_if_index = ntohl (sw_if_index);
5491 mp->is_add = is_add;
5492 mp->del_all = del_all;
5496 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5500 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5502 mp->address_length = address_length;
5507 /* Wait for a reply, return good/bad news */
5513 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5515 unformat_input_t *i = vam->input;
5516 vl_api_sw_interface_set_mpls_enable_t *mp;
5518 u8 sw_if_index_set = 0;
5522 /* Parse args required to build the message */
5523 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5525 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5526 sw_if_index_set = 1;
5527 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5528 sw_if_index_set = 1;
5529 else if (unformat (i, "disable"))
5531 else if (unformat (i, "dis"))
5537 if (sw_if_index_set == 0)
5539 errmsg ("missing interface name or sw_if_index");
5543 /* Construct the API message */
5544 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5546 mp->sw_if_index = ntohl (sw_if_index);
5547 mp->enable = enable;
5552 /* Wait for a reply... */
5558 api_sw_interface_set_table (vat_main_t * vam)
5560 unformat_input_t *i = vam->input;
5561 vl_api_sw_interface_set_table_t *mp;
5562 u32 sw_if_index, vrf_id = 0;
5563 u8 sw_if_index_set = 0;
5567 /* Parse args required to build the message */
5568 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5570 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5571 sw_if_index_set = 1;
5572 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5573 sw_if_index_set = 1;
5574 else if (unformat (i, "vrf %d", &vrf_id))
5576 else if (unformat (i, "ipv6"))
5582 if (sw_if_index_set == 0)
5584 errmsg ("missing interface name or sw_if_index");
5588 /* Construct the API message */
5589 M (SW_INTERFACE_SET_TABLE, mp);
5591 mp->sw_if_index = ntohl (sw_if_index);
5592 mp->is_ipv6 = is_ipv6;
5593 mp->vrf_id = ntohl (vrf_id);
5598 /* Wait for a reply... */
5603 static void vl_api_sw_interface_get_table_reply_t_handler
5604 (vl_api_sw_interface_get_table_reply_t * mp)
5606 vat_main_t *vam = &vat_main;
5608 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5610 vam->retval = ntohl (mp->retval);
5611 vam->result_ready = 1;
5615 static void vl_api_sw_interface_get_table_reply_t_handler_json
5616 (vl_api_sw_interface_get_table_reply_t * mp)
5618 vat_main_t *vam = &vat_main;
5619 vat_json_node_t node;
5621 vat_json_init_object (&node);
5622 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5623 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5625 vat_json_print (vam->ofp, &node);
5626 vat_json_free (&node);
5628 vam->retval = ntohl (mp->retval);
5629 vam->result_ready = 1;
5633 api_sw_interface_get_table (vat_main_t * vam)
5635 unformat_input_t *i = vam->input;
5636 vl_api_sw_interface_get_table_t *mp;
5638 u8 sw_if_index_set = 0;
5642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5644 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5645 sw_if_index_set = 1;
5646 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5647 sw_if_index_set = 1;
5648 else if (unformat (i, "ipv6"))
5654 if (sw_if_index_set == 0)
5656 errmsg ("missing interface name or sw_if_index");
5660 M (SW_INTERFACE_GET_TABLE, mp);
5661 mp->sw_if_index = htonl (sw_if_index);
5662 mp->is_ipv6 = is_ipv6;
5670 api_sw_interface_set_vpath (vat_main_t * vam)
5672 unformat_input_t *i = vam->input;
5673 vl_api_sw_interface_set_vpath_t *mp;
5674 u32 sw_if_index = 0;
5675 u8 sw_if_index_set = 0;
5679 /* Parse args required to build the message */
5680 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5682 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5683 sw_if_index_set = 1;
5684 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5685 sw_if_index_set = 1;
5686 else if (unformat (i, "enable"))
5688 else if (unformat (i, "disable"))
5694 if (sw_if_index_set == 0)
5696 errmsg ("missing interface name or sw_if_index");
5700 /* Construct the API message */
5701 M (SW_INTERFACE_SET_VPATH, mp);
5703 mp->sw_if_index = ntohl (sw_if_index);
5704 mp->enable = is_enable;
5709 /* Wait for a reply... */
5715 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5717 unformat_input_t *i = vam->input;
5718 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5719 u32 sw_if_index = 0;
5720 u8 sw_if_index_set = 0;
5725 /* Parse args required to build the message */
5726 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5728 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5729 sw_if_index_set = 1;
5730 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5731 sw_if_index_set = 1;
5732 else if (unformat (i, "enable"))
5734 else if (unformat (i, "disable"))
5736 else if (unformat (i, "ip4"))
5738 else if (unformat (i, "ip6"))
5744 if (sw_if_index_set == 0)
5746 errmsg ("missing interface name or sw_if_index");
5750 /* Construct the API message */
5751 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5753 mp->sw_if_index = ntohl (sw_if_index);
5754 mp->enable = is_enable;
5755 mp->is_ipv6 = is_ipv6;
5760 /* Wait for a reply... */
5766 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5768 unformat_input_t *i = vam->input;
5769 vl_api_sw_interface_set_l2_xconnect_t *mp;
5771 u8 rx_sw_if_index_set = 0;
5773 u8 tx_sw_if_index_set = 0;
5777 /* Parse args required to build the message */
5778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5780 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5781 rx_sw_if_index_set = 1;
5782 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5783 tx_sw_if_index_set = 1;
5784 else if (unformat (i, "rx"))
5786 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5788 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5790 rx_sw_if_index_set = 1;
5795 else if (unformat (i, "tx"))
5797 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5799 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5801 tx_sw_if_index_set = 1;
5806 else if (unformat (i, "enable"))
5808 else if (unformat (i, "disable"))
5814 if (rx_sw_if_index_set == 0)
5816 errmsg ("missing rx interface name or rx_sw_if_index");
5820 if (enable && (tx_sw_if_index_set == 0))
5822 errmsg ("missing tx interface name or tx_sw_if_index");
5826 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5828 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5829 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5830 mp->enable = enable;
5838 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5840 unformat_input_t *i = vam->input;
5841 vl_api_sw_interface_set_l2_bridge_t *mp;
5843 u8 rx_sw_if_index_set = 0;
5851 /* Parse args required to build the message */
5852 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5854 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5855 rx_sw_if_index_set = 1;
5856 else if (unformat (i, "bd_id %d", &bd_id))
5860 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5861 rx_sw_if_index_set = 1;
5862 else if (unformat (i, "shg %d", &shg))
5864 else if (unformat (i, "bvi"))
5866 else if (unformat (i, "enable"))
5868 else if (unformat (i, "disable"))
5874 if (rx_sw_if_index_set == 0)
5876 errmsg ("missing rx interface name or sw_if_index");
5880 if (enable && (bd_id_set == 0))
5882 errmsg ("missing bridge domain");
5886 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
5888 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5889 mp->bd_id = ntohl (bd_id);
5892 mp->enable = enable;
5900 api_bridge_domain_dump (vat_main_t * vam)
5902 unformat_input_t *i = vam->input;
5903 vl_api_bridge_domain_dump_t *mp;
5904 vl_api_control_ping_t *mp_ping;
5908 /* Parse args required to build the message */
5909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5911 if (unformat (i, "bd_id %d", &bd_id))
5917 M (BRIDGE_DOMAIN_DUMP, mp);
5918 mp->bd_id = ntohl (bd_id);
5921 /* Use a control ping for synchronization */
5922 M (CONTROL_PING, mp_ping);
5930 api_bridge_domain_add_del (vat_main_t * vam)
5932 unformat_input_t *i = vam->input;
5933 vl_api_bridge_domain_add_del_t *mp;
5936 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5940 /* Parse args required to build the message */
5941 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5943 if (unformat (i, "bd_id %d", &bd_id))
5945 else if (unformat (i, "flood %d", &flood))
5947 else if (unformat (i, "uu-flood %d", &uu_flood))
5949 else if (unformat (i, "forward %d", &forward))
5951 else if (unformat (i, "learn %d", &learn))
5953 else if (unformat (i, "arp-term %d", &arp_term))
5955 else if (unformat (i, "mac-age %d", &mac_age))
5957 else if (unformat (i, "del"))
5960 flood = uu_flood = forward = learn = 0;
5968 errmsg ("missing bridge domain");
5974 errmsg ("mac age must be less than 256 ");
5978 M (BRIDGE_DOMAIN_ADD_DEL, mp);
5980 mp->bd_id = ntohl (bd_id);
5982 mp->uu_flood = uu_flood;
5983 mp->forward = forward;
5985 mp->arp_term = arp_term;
5986 mp->is_add = is_add;
5987 mp->mac_age = (u8) mac_age;
5995 api_l2fib_flush_bd (vat_main_t * vam)
5997 unformat_input_t *i = vam->input;
5998 vl_api_l2fib_flush_bd_t *mp;
6002 /* Parse args required to build the message */
6003 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6005 if (unformat (i, "bd_id %d", &bd_id));
6012 errmsg ("missing bridge domain");
6016 M (L2FIB_FLUSH_BD, mp);
6018 mp->bd_id = htonl (bd_id);
6026 api_l2fib_flush_int (vat_main_t * vam)
6028 unformat_input_t *i = vam->input;
6029 vl_api_l2fib_flush_int_t *mp;
6030 u32 sw_if_index = ~0;
6033 /* Parse args required to build the message */
6034 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6036 if (unformat (i, "sw_if_index %d", &sw_if_index));
6038 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6043 if (sw_if_index == ~0)
6045 errmsg ("missing interface name or sw_if_index");
6049 M (L2FIB_FLUSH_INT, mp);
6051 mp->sw_if_index = ntohl (sw_if_index);
6059 api_l2fib_add_del (vat_main_t * vam)
6061 unformat_input_t *i = vam->input;
6062 vl_api_l2fib_add_del_t *mp;
6068 u32 sw_if_index = ~0;
6069 u8 sw_if_index_set = 0;
6078 /* Parse args required to build the message */
6079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6081 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6083 else if (unformat (i, "bd_id %d", &bd_id))
6085 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6086 sw_if_index_set = 1;
6087 else if (unformat (i, "sw_if"))
6089 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6092 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6093 sw_if_index_set = 1;
6098 else if (unformat (i, "static"))
6100 else if (unformat (i, "filter"))
6105 else if (unformat (i, "bvi"))
6110 else if (unformat (i, "del"))
6112 else if (unformat (i, "count %d", &count))
6120 errmsg ("missing mac address");
6126 errmsg ("missing bridge domain");
6130 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6132 errmsg ("missing interface name or sw_if_index");
6138 /* Turn on async mode */
6139 vam->async_mode = 1;
6140 vam->async_errors = 0;
6141 before = vat_time_now (vam);
6144 for (j = 0; j < count; j++)
6146 M (L2FIB_ADD_DEL, mp);
6149 mp->bd_id = ntohl (bd_id);
6150 mp->is_add = is_add;
6154 mp->sw_if_index = ntohl (sw_if_index);
6155 mp->static_mac = static_mac;
6156 mp->filter_mac = filter_mac;
6157 mp->bvi_mac = bvi_mac;
6159 increment_mac_address (&mac);
6166 vl_api_control_ping_t *mp_ping;
6169 /* Shut off async mode */
6170 vam->async_mode = 0;
6172 M (CONTROL_PING, mp_ping);
6175 timeout = vat_time_now (vam) + 1.0;
6176 while (vat_time_now (vam) < timeout)
6177 if (vam->result_ready == 1)
6182 if (vam->retval == -99)
6185 if (vam->async_errors > 0)
6187 errmsg ("%d asynchronous errors", vam->async_errors);
6190 vam->async_errors = 0;
6191 after = vat_time_now (vam);
6193 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6194 count, after - before, count / (after - before));
6200 /* Wait for a reply... */
6204 /* Return the good/bad news */
6205 return (vam->retval);
6209 api_bridge_domain_set_mac_age (vat_main_t * vam)
6211 unformat_input_t *i = vam->input;
6212 vl_api_bridge_domain_set_mac_age_t *mp;
6217 /* Parse args required to build the message */
6218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6220 if (unformat (i, "bd_id %d", &bd_id));
6221 else if (unformat (i, "mac-age %d", &mac_age));
6228 errmsg ("missing bridge domain");
6234 errmsg ("mac age must be less than 256 ");
6238 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6240 mp->bd_id = htonl (bd_id);
6241 mp->mac_age = (u8) mac_age;
6249 api_l2_flags (vat_main_t * vam)
6251 unformat_input_t *i = vam->input;
6252 vl_api_l2_flags_t *mp;
6254 u32 feature_bitmap = 0;
6255 u8 sw_if_index_set = 0;
6258 /* Parse args required to build the message */
6259 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6261 if (unformat (i, "sw_if_index %d", &sw_if_index))
6262 sw_if_index_set = 1;
6263 else if (unformat (i, "sw_if"))
6265 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6268 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6269 sw_if_index_set = 1;
6274 else if (unformat (i, "learn"))
6275 feature_bitmap |= L2INPUT_FEAT_LEARN;
6276 else if (unformat (i, "forward"))
6277 feature_bitmap |= L2INPUT_FEAT_FWD;
6278 else if (unformat (i, "flood"))
6279 feature_bitmap |= L2INPUT_FEAT_FLOOD;
6280 else if (unformat (i, "uu-flood"))
6281 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
6286 if (sw_if_index_set == 0)
6288 errmsg ("missing interface name or sw_if_index");
6294 mp->sw_if_index = ntohl (sw_if_index);
6295 mp->feature_bitmap = ntohl (feature_bitmap);
6303 api_bridge_flags (vat_main_t * vam)
6305 unformat_input_t *i = vam->input;
6306 vl_api_bridge_flags_t *mp;
6313 /* Parse args required to build the message */
6314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6316 if (unformat (i, "bd_id %d", &bd_id))
6318 else if (unformat (i, "learn"))
6320 else if (unformat (i, "forward"))
6322 else if (unformat (i, "flood"))
6324 else if (unformat (i, "uu-flood"))
6325 flags |= L2_UU_FLOOD;
6326 else if (unformat (i, "arp-term"))
6327 flags |= L2_ARP_TERM;
6328 else if (unformat (i, "off"))
6330 else if (unformat (i, "disable"))
6338 errmsg ("missing bridge domain");
6342 M (BRIDGE_FLAGS, mp);
6344 mp->bd_id = ntohl (bd_id);
6345 mp->feature_bitmap = ntohl (flags);
6346 mp->is_set = is_set;
6354 api_bd_ip_mac_add_del (vat_main_t * vam)
6356 unformat_input_t *i = vam->input;
6357 vl_api_bd_ip_mac_add_del_t *mp;
6364 ip4_address_t v4addr;
6365 ip6_address_t v6addr;
6370 /* Parse args required to build the message */
6371 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6373 if (unformat (i, "bd_id %d", &bd_id))
6377 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6381 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6386 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6390 else if (unformat (i, "del"))
6398 errmsg ("missing bridge domain");
6401 else if (ip_set == 0)
6403 errmsg ("missing IP address");
6406 else if (mac_set == 0)
6408 errmsg ("missing MAC address");
6412 M (BD_IP_MAC_ADD_DEL, mp);
6414 mp->bd_id = ntohl (bd_id);
6415 mp->is_ipv6 = is_ipv6;
6416 mp->is_add = is_add;
6418 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6420 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6421 clib_memcpy (mp->mac_address, macaddr, 6);
6428 api_tap_connect (vat_main_t * vam)
6430 unformat_input_t *i = vam->input;
6431 vl_api_tap_connect_t *mp;
6437 ip4_address_t ip4_address;
6439 int ip4_address_set = 0;
6440 ip6_address_t ip6_address;
6442 int ip6_address_set = 0;
6445 memset (mac_address, 0, sizeof (mac_address));
6447 /* Parse args required to build the message */
6448 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6450 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6454 else if (unformat (i, "random-mac"))
6456 else if (unformat (i, "tapname %s", &tap_name))
6458 else if (unformat (i, "tag %s", &tag))
6460 else if (unformat (i, "address %U/%d",
6461 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6462 ip4_address_set = 1;
6463 else if (unformat (i, "address %U/%d",
6464 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6465 ip6_address_set = 1;
6472 errmsg ("missing tap name");
6475 if (vec_len (tap_name) > 63)
6477 errmsg ("tap name too long");
6480 vec_add1 (tap_name, 0);
6482 if (vec_len (tag) > 63)
6484 errmsg ("tag too long");
6488 /* Construct the API message */
6489 M (TAP_CONNECT, mp);
6491 mp->use_random_mac = random_mac;
6492 clib_memcpy (mp->mac_address, mac_address, 6);
6493 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6495 clib_memcpy (mp->tag, tag, vec_len (tag));
6497 if (ip4_address_set)
6499 mp->ip4_address_set = 1;
6500 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6501 mp->ip4_mask_width = ip4_mask_width;
6503 if (ip6_address_set)
6505 mp->ip6_address_set = 1;
6506 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6507 mp->ip6_mask_width = ip6_mask_width;
6510 vec_free (tap_name);
6516 /* Wait for a reply... */
6522 api_tap_modify (vat_main_t * vam)
6524 unformat_input_t *i = vam->input;
6525 vl_api_tap_modify_t *mp;
6530 u32 sw_if_index = ~0;
6531 u8 sw_if_index_set = 0;
6534 memset (mac_address, 0, sizeof (mac_address));
6536 /* Parse args required to build the message */
6537 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6539 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6540 sw_if_index_set = 1;
6541 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6542 sw_if_index_set = 1;
6543 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6547 else if (unformat (i, "random-mac"))
6549 else if (unformat (i, "tapname %s", &tap_name))
6555 if (sw_if_index_set == 0)
6557 errmsg ("missing vpp interface name");
6562 errmsg ("missing tap name");
6565 if (vec_len (tap_name) > 63)
6567 errmsg ("tap name too long");
6569 vec_add1 (tap_name, 0);
6571 /* Construct the API message */
6574 mp->use_random_mac = random_mac;
6575 mp->sw_if_index = ntohl (sw_if_index);
6576 clib_memcpy (mp->mac_address, mac_address, 6);
6577 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6578 vec_free (tap_name);
6583 /* Wait for a reply... */
6589 api_tap_delete (vat_main_t * vam)
6591 unformat_input_t *i = vam->input;
6592 vl_api_tap_delete_t *mp;
6593 u32 sw_if_index = ~0;
6594 u8 sw_if_index_set = 0;
6597 /* Parse args required to build the message */
6598 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6600 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6601 sw_if_index_set = 1;
6602 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6603 sw_if_index_set = 1;
6608 if (sw_if_index_set == 0)
6610 errmsg ("missing vpp interface name");
6614 /* Construct the API message */
6617 mp->sw_if_index = ntohl (sw_if_index);
6622 /* Wait for a reply... */
6628 api_ip_add_del_route (vat_main_t * vam)
6630 unformat_input_t *i = vam->input;
6631 vl_api_ip_add_del_route_t *mp;
6632 u32 sw_if_index = ~0, vrf_id = 0;
6634 u8 is_local = 0, is_drop = 0;
6635 u8 is_unreach = 0, is_prohibit = 0;
6636 u8 create_vrf_if_needed = 0;
6638 u32 next_hop_weight = 1;
6640 u8 is_multipath = 0;
6642 u8 address_length_set = 0;
6643 u32 next_hop_table_id = 0;
6644 u32 resolve_attempts = 0;
6645 u32 dst_address_length = 0;
6646 u8 next_hop_set = 0;
6647 ip4_address_t v4_dst_address, v4_next_hop_address;
6648 ip6_address_t v6_dst_address, v6_next_hop_address;
6652 u32 random_add_del = 0;
6653 u32 *random_vector = 0;
6655 u32 random_seed = 0xdeaddabe;
6656 u32 classify_table_index = ~0;
6658 u8 resolve_host = 0, resolve_attached = 0;
6659 mpls_label_t *next_hop_out_label_stack = NULL;
6660 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6661 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6663 /* Parse args required to build the message */
6664 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6666 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6668 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6670 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6675 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6680 else if (unformat (i, "/%d", &dst_address_length))
6682 address_length_set = 1;
6685 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6686 &v4_next_hop_address))
6690 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6691 &v6_next_hop_address))
6695 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6697 else if (unformat (i, "weight %d", &next_hop_weight))
6699 else if (unformat (i, "drop"))
6703 else if (unformat (i, "null-send-unreach"))
6707 else if (unformat (i, "null-send-prohibit"))
6711 else if (unformat (i, "local"))
6715 else if (unformat (i, "classify %d", &classify_table_index))
6719 else if (unformat (i, "del"))
6721 else if (unformat (i, "add"))
6723 else if (unformat (i, "not-last"))
6725 else if (unformat (i, "resolve-via-host"))
6727 else if (unformat (i, "resolve-via-attached"))
6728 resolve_attached = 1;
6729 else if (unformat (i, "multipath"))
6731 else if (unformat (i, "vrf %d", &vrf_id))
6733 else if (unformat (i, "create-vrf"))
6734 create_vrf_if_needed = 1;
6735 else if (unformat (i, "count %d", &count))
6737 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6739 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6741 else if (unformat (i, "out-label %d", &next_hop_out_label))
6742 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6743 else if (unformat (i, "via-label %d", &next_hop_via_label))
6745 else if (unformat (i, "random"))
6747 else if (unformat (i, "seed %d", &random_seed))
6751 clib_warning ("parse error '%U'", format_unformat_error, i);
6756 if (!next_hop_set && !is_drop && !is_local &&
6757 !is_classify && !is_unreach && !is_prohibit &&
6758 MPLS_LABEL_INVALID == next_hop_via_label)
6761 ("next hop / local / drop / unreach / prohibit / classify not set");
6765 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6767 errmsg ("next hop and next-hop via label set");
6770 if (address_set == 0)
6772 errmsg ("missing addresses");
6776 if (address_length_set == 0)
6778 errmsg ("missing address length");
6782 /* Generate a pile of unique, random routes */
6785 u32 this_random_address;
6786 random_hash = hash_create (count, sizeof (uword));
6788 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6789 for (j = 0; j <= count; j++)
6793 this_random_address = random_u32 (&random_seed);
6794 this_random_address =
6795 clib_host_to_net_u32 (this_random_address);
6797 while (hash_get (random_hash, this_random_address));
6798 vec_add1 (random_vector, this_random_address);
6799 hash_set (random_hash, this_random_address, 1);
6801 hash_free (random_hash);
6802 v4_dst_address.as_u32 = random_vector[0];
6807 /* Turn on async mode */
6808 vam->async_mode = 1;
6809 vam->async_errors = 0;
6810 before = vat_time_now (vam);
6813 for (j = 0; j < count; j++)
6815 /* Construct the API message */
6816 M2 (IP_ADD_DEL_ROUTE, mp,
6817 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6819 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6820 mp->table_id = ntohl (vrf_id);
6821 mp->create_vrf_if_needed = create_vrf_if_needed;
6823 mp->is_add = is_add;
6824 mp->is_drop = is_drop;
6825 mp->is_unreach = is_unreach;
6826 mp->is_prohibit = is_prohibit;
6827 mp->is_ipv6 = is_ipv6;
6828 mp->is_local = is_local;
6829 mp->is_classify = is_classify;
6830 mp->is_multipath = is_multipath;
6831 mp->is_resolve_host = resolve_host;
6832 mp->is_resolve_attached = resolve_attached;
6833 mp->not_last = not_last;
6834 mp->next_hop_weight = next_hop_weight;
6835 mp->dst_address_length = dst_address_length;
6836 mp->next_hop_table_id = ntohl (next_hop_table_id);
6837 mp->classify_table_index = ntohl (classify_table_index);
6838 mp->next_hop_via_label = ntohl (next_hop_via_label);
6839 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6840 if (0 != mp->next_hop_n_out_labels)
6842 memcpy (mp->next_hop_out_label_stack,
6843 next_hop_out_label_stack,
6844 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6845 vec_free (next_hop_out_label_stack);
6850 clib_memcpy (mp->dst_address, &v6_dst_address,
6851 sizeof (v6_dst_address));
6853 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6854 sizeof (v6_next_hop_address));
6855 increment_v6_address (&v6_dst_address);
6859 clib_memcpy (mp->dst_address, &v4_dst_address,
6860 sizeof (v4_dst_address));
6862 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6863 sizeof (v4_next_hop_address));
6865 v4_dst_address.as_u32 = random_vector[j + 1];
6867 increment_v4_address (&v4_dst_address);
6871 /* If we receive SIGTERM, stop now... */
6876 /* When testing multiple add/del ops, use a control-ping to sync */
6879 vl_api_control_ping_t *mp_ping;
6883 /* Shut off async mode */
6884 vam->async_mode = 0;
6886 M (CONTROL_PING, mp_ping);
6889 timeout = vat_time_now (vam) + 1.0;
6890 while (vat_time_now (vam) < timeout)
6891 if (vam->result_ready == 1)
6896 if (vam->retval == -99)
6899 if (vam->async_errors > 0)
6901 errmsg ("%d asynchronous errors", vam->async_errors);
6904 vam->async_errors = 0;
6905 after = vat_time_now (vam);
6907 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6911 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6912 count, after - before, count / (after - before));
6918 /* Wait for a reply... */
6923 /* Return the good/bad news */
6924 return (vam->retval);
6928 api_ip_mroute_add_del (vat_main_t * vam)
6930 unformat_input_t *i = vam->input;
6931 vl_api_ip_mroute_add_del_t *mp;
6932 u32 sw_if_index = ~0, vrf_id = 0;
6935 u8 create_vrf_if_needed = 0;
6938 u32 grp_address_length = 0;
6939 ip4_address_t v4_grp_address, v4_src_address;
6940 ip6_address_t v6_grp_address, v6_src_address;
6941 mfib_itf_flags_t iflags = 0;
6942 mfib_entry_flags_t eflags = 0;
6945 /* Parse args required to build the message */
6946 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6948 if (unformat (i, "sw_if_index %d", &sw_if_index))
6950 else if (unformat (i, "%U %U",
6951 unformat_ip4_address, &v4_src_address,
6952 unformat_ip4_address, &v4_grp_address))
6954 grp_address_length = 64;
6958 else if (unformat (i, "%U %U",
6959 unformat_ip6_address, &v6_src_address,
6960 unformat_ip6_address, &v6_grp_address))
6962 grp_address_length = 256;
6966 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
6968 memset (&v4_src_address, 0, sizeof (v4_src_address));
6969 grp_address_length = 32;
6973 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
6975 memset (&v6_src_address, 0, sizeof (v6_src_address));
6976 grp_address_length = 128;
6980 else if (unformat (i, "/%d", &grp_address_length))
6982 else if (unformat (i, "local"))
6986 else if (unformat (i, "del"))
6988 else if (unformat (i, "add"))
6990 else if (unformat (i, "vrf %d", &vrf_id))
6992 else if (unformat (i, "create-vrf"))
6993 create_vrf_if_needed = 1;
6994 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
6996 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7000 clib_warning ("parse error '%U'", format_unformat_error, i);
7005 if (address_set == 0)
7007 errmsg ("missing addresses\n");
7011 /* Construct the API message */
7012 M (IP_MROUTE_ADD_DEL, mp);
7014 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7015 mp->table_id = ntohl (vrf_id);
7016 mp->create_vrf_if_needed = create_vrf_if_needed;
7018 mp->is_add = is_add;
7019 mp->is_ipv6 = is_ipv6;
7020 mp->is_local = is_local;
7021 mp->itf_flags = ntohl (iflags);
7022 mp->entry_flags = ntohl (eflags);
7023 mp->grp_address_length = grp_address_length;
7024 mp->grp_address_length = ntohs (mp->grp_address_length);
7028 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7029 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7033 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7034 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7040 /* Wait for a reply... */
7046 api_mpls_route_add_del (vat_main_t * vam)
7048 unformat_input_t *i = vam->input;
7049 vl_api_mpls_route_add_del_t *mp;
7050 u32 sw_if_index = ~0, table_id = 0;
7051 u8 create_table_if_needed = 0;
7053 u32 next_hop_weight = 1;
7054 u8 is_multipath = 0;
7055 u32 next_hop_table_id = 0;
7056 u8 next_hop_set = 0;
7057 ip4_address_t v4_next_hop_address = {
7060 ip6_address_t v6_next_hop_address = { {0} };
7064 u32 classify_table_index = ~0;
7066 u8 resolve_host = 0, resolve_attached = 0;
7067 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7068 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7069 mpls_label_t *next_hop_out_label_stack = NULL;
7070 mpls_label_t local_label = MPLS_LABEL_INVALID;
7072 u8 next_hop_proto_is_ip4 = 1;
7074 /* Parse args required to build the message */
7075 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7077 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7079 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7081 else if (unformat (i, "%d", &local_label))
7083 else if (unformat (i, "eos"))
7085 else if (unformat (i, "non-eos"))
7087 else if (unformat (i, "via %U", unformat_ip4_address,
7088 &v4_next_hop_address))
7091 next_hop_proto_is_ip4 = 1;
7093 else if (unformat (i, "via %U", unformat_ip6_address,
7094 &v6_next_hop_address))
7097 next_hop_proto_is_ip4 = 0;
7099 else if (unformat (i, "weight %d", &next_hop_weight))
7101 else if (unformat (i, "create-table"))
7102 create_table_if_needed = 1;
7103 else if (unformat (i, "classify %d", &classify_table_index))
7107 else if (unformat (i, "del"))
7109 else if (unformat (i, "add"))
7111 else if (unformat (i, "resolve-via-host"))
7113 else if (unformat (i, "resolve-via-attached"))
7114 resolve_attached = 1;
7115 else if (unformat (i, "multipath"))
7117 else if (unformat (i, "count %d", &count))
7119 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
7122 next_hop_proto_is_ip4 = 1;
7124 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
7127 next_hop_proto_is_ip4 = 0;
7129 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7131 else if (unformat (i, "via-label %d", &next_hop_via_label))
7133 else if (unformat (i, "out-label %d", &next_hop_out_label))
7134 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7137 clib_warning ("parse error '%U'", format_unformat_error, i);
7142 if (!next_hop_set && !is_classify)
7144 errmsg ("next hop / classify not set");
7148 if (MPLS_LABEL_INVALID == local_label)
7150 errmsg ("missing label");
7156 /* Turn on async mode */
7157 vam->async_mode = 1;
7158 vam->async_errors = 0;
7159 before = vat_time_now (vam);
7162 for (j = 0; j < count; j++)
7164 /* Construct the API message */
7165 M2 (MPLS_ROUTE_ADD_DEL, mp,
7166 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7168 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
7169 mp->mr_table_id = ntohl (table_id);
7170 mp->mr_create_table_if_needed = create_table_if_needed;
7172 mp->mr_is_add = is_add;
7173 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7174 mp->mr_is_classify = is_classify;
7175 mp->mr_is_multipath = is_multipath;
7176 mp->mr_is_resolve_host = resolve_host;
7177 mp->mr_is_resolve_attached = resolve_attached;
7178 mp->mr_next_hop_weight = next_hop_weight;
7179 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
7180 mp->mr_classify_table_index = ntohl (classify_table_index);
7181 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
7182 mp->mr_label = ntohl (local_label);
7183 mp->mr_eos = is_eos;
7185 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7186 if (0 != mp->mr_next_hop_n_out_labels)
7188 memcpy (mp->mr_next_hop_out_label_stack,
7189 next_hop_out_label_stack,
7190 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7191 vec_free (next_hop_out_label_stack);
7196 if (next_hop_proto_is_ip4)
7198 clib_memcpy (mp->mr_next_hop,
7199 &v4_next_hop_address,
7200 sizeof (v4_next_hop_address));
7204 clib_memcpy (mp->mr_next_hop,
7205 &v6_next_hop_address,
7206 sizeof (v6_next_hop_address));
7213 /* If we receive SIGTERM, stop now... */
7218 /* When testing multiple add/del ops, use a control-ping to sync */
7221 vl_api_control_ping_t *mp_ping;
7225 /* Shut off async mode */
7226 vam->async_mode = 0;
7228 M (CONTROL_PING, mp_ping);
7231 timeout = vat_time_now (vam) + 1.0;
7232 while (vat_time_now (vam) < timeout)
7233 if (vam->result_ready == 1)
7238 if (vam->retval == -99)
7241 if (vam->async_errors > 0)
7243 errmsg ("%d asynchronous errors", vam->async_errors);
7246 vam->async_errors = 0;
7247 after = vat_time_now (vam);
7249 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7253 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7254 count, after - before, count / (after - before));
7260 /* Wait for a reply... */
7265 /* Return the good/bad news */
7266 return (vam->retval);
7270 api_mpls_ip_bind_unbind (vat_main_t * vam)
7272 unformat_input_t *i = vam->input;
7273 vl_api_mpls_ip_bind_unbind_t *mp;
7274 u32 ip_table_id = 0;
7275 u8 create_table_if_needed = 0;
7278 ip4_address_t v4_address;
7279 ip6_address_t v6_address;
7282 mpls_label_t local_label = MPLS_LABEL_INVALID;
7285 /* Parse args required to build the message */
7286 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7288 if (unformat (i, "%U/%d", unformat_ip4_address,
7289 &v4_address, &address_length))
7294 else if (unformat (i, "%U/%d", unformat_ip6_address,
7295 &v6_address, &address_length))
7300 else if (unformat (i, "%d", &local_label))
7302 else if (unformat (i, "create-table"))
7303 create_table_if_needed = 1;
7304 else if (unformat (i, "table-id %d", &ip_table_id))
7306 else if (unformat (i, "unbind"))
7308 else if (unformat (i, "bind"))
7312 clib_warning ("parse error '%U'", format_unformat_error, i);
7319 errmsg ("IP addres not set");
7323 if (MPLS_LABEL_INVALID == local_label)
7325 errmsg ("missing label");
7329 /* Construct the API message */
7330 M (MPLS_IP_BIND_UNBIND, mp);
7332 mp->mb_create_table_if_needed = create_table_if_needed;
7333 mp->mb_is_bind = is_bind;
7334 mp->mb_is_ip4 = is_ip4;
7335 mp->mb_ip_table_id = ntohl (ip_table_id);
7336 mp->mb_mpls_table_id = 0;
7337 mp->mb_label = ntohl (local_label);
7338 mp->mb_address_length = address_length;
7341 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7343 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7348 /* Wait for a reply... */
7354 api_proxy_arp_add_del (vat_main_t * vam)
7356 unformat_input_t *i = vam->input;
7357 vl_api_proxy_arp_add_del_t *mp;
7360 ip4_address_t lo, hi;
7364 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7366 if (unformat (i, "vrf %d", &vrf_id))
7368 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7369 unformat_ip4_address, &hi))
7371 else if (unformat (i, "del"))
7375 clib_warning ("parse error '%U'", format_unformat_error, i);
7382 errmsg ("address range not set");
7386 M (PROXY_ARP_ADD_DEL, mp);
7388 mp->vrf_id = ntohl (vrf_id);
7389 mp->is_add = is_add;
7390 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7391 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7399 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7401 unformat_input_t *i = vam->input;
7402 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7405 u8 sw_if_index_set = 0;
7408 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7410 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7411 sw_if_index_set = 1;
7412 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7413 sw_if_index_set = 1;
7414 else if (unformat (i, "enable"))
7416 else if (unformat (i, "disable"))
7420 clib_warning ("parse error '%U'", format_unformat_error, i);
7425 if (sw_if_index_set == 0)
7427 errmsg ("missing interface name or sw_if_index");
7431 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7433 mp->sw_if_index = ntohl (sw_if_index);
7434 mp->enable_disable = enable;
7442 api_mpls_tunnel_add_del (vat_main_t * vam)
7444 unformat_input_t *i = vam->input;
7445 vl_api_mpls_tunnel_add_del_t *mp;
7449 u32 sw_if_index = ~0;
7450 u32 next_hop_sw_if_index = ~0;
7451 u32 next_hop_proto_is_ip4 = 1;
7453 u32 next_hop_table_id = 0;
7454 ip4_address_t v4_next_hop_address = {
7457 ip6_address_t v6_next_hop_address = { {0} };
7458 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7461 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7463 if (unformat (i, "add"))
7465 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7467 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7469 else if (unformat (i, "via %U",
7470 unformat_ip4_address, &v4_next_hop_address))
7472 next_hop_proto_is_ip4 = 1;
7474 else if (unformat (i, "via %U",
7475 unformat_ip6_address, &v6_next_hop_address))
7477 next_hop_proto_is_ip4 = 0;
7479 else if (unformat (i, "l2-only"))
7481 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7483 else if (unformat (i, "out-label %d", &next_hop_out_label))
7484 vec_add1 (labels, ntohl (next_hop_out_label));
7487 clib_warning ("parse error '%U'", format_unformat_error, i);
7492 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7494 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7495 mp->mt_sw_if_index = ntohl (sw_if_index);
7496 mp->mt_is_add = is_add;
7497 mp->mt_l2_only = l2_only;
7498 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7499 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7501 mp->mt_next_hop_n_out_labels = vec_len (labels);
7503 if (0 != mp->mt_next_hop_n_out_labels)
7505 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7506 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7510 if (next_hop_proto_is_ip4)
7512 clib_memcpy (mp->mt_next_hop,
7513 &v4_next_hop_address, sizeof (v4_next_hop_address));
7517 clib_memcpy (mp->mt_next_hop,
7518 &v6_next_hop_address, sizeof (v6_next_hop_address));
7527 api_sw_interface_set_unnumbered (vat_main_t * vam)
7529 unformat_input_t *i = vam->input;
7530 vl_api_sw_interface_set_unnumbered_t *mp;
7532 u32 unnum_sw_index = ~0;
7534 u8 sw_if_index_set = 0;
7537 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7539 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7540 sw_if_index_set = 1;
7541 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7542 sw_if_index_set = 1;
7543 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7545 else if (unformat (i, "del"))
7549 clib_warning ("parse error '%U'", format_unformat_error, i);
7554 if (sw_if_index_set == 0)
7556 errmsg ("missing interface name or sw_if_index");
7560 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7562 mp->sw_if_index = ntohl (sw_if_index);
7563 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7564 mp->is_add = is_add;
7572 api_ip_neighbor_add_del (vat_main_t * vam)
7574 unformat_input_t *i = vam->input;
7575 vl_api_ip_neighbor_add_del_t *mp;
7577 u8 sw_if_index_set = 0;
7580 u8 is_no_fib_entry = 0;
7583 u8 v4_address_set = 0;
7584 u8 v6_address_set = 0;
7585 ip4_address_t v4address;
7586 ip6_address_t v6address;
7589 memset (mac_address, 0, sizeof (mac_address));
7591 /* Parse args required to build the message */
7592 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7594 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7598 else if (unformat (i, "del"))
7601 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7602 sw_if_index_set = 1;
7603 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7604 sw_if_index_set = 1;
7605 else if (unformat (i, "is_static"))
7607 else if (unformat (i, "no-fib-entry"))
7608 is_no_fib_entry = 1;
7609 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7611 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7615 clib_warning ("parse error '%U'", format_unformat_error, i);
7620 if (sw_if_index_set == 0)
7622 errmsg ("missing interface name or sw_if_index");
7625 if (v4_address_set && v6_address_set)
7627 errmsg ("both v4 and v6 addresses set");
7630 if (!v4_address_set && !v6_address_set)
7632 errmsg ("no address set");
7636 /* Construct the API message */
7637 M (IP_NEIGHBOR_ADD_DEL, mp);
7639 mp->sw_if_index = ntohl (sw_if_index);
7640 mp->is_add = is_add;
7641 mp->is_static = is_static;
7642 mp->is_no_adj_fib = is_no_fib_entry;
7644 clib_memcpy (mp->mac_address, mac_address, 6);
7648 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7652 /* mp->is_ipv6 = 0; via memset in M macro above */
7653 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7659 /* Wait for a reply, return good/bad news */
7665 api_reset_vrf (vat_main_t * vam)
7667 unformat_input_t *i = vam->input;
7668 vl_api_reset_vrf_t *mp;
7674 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7676 if (unformat (i, "vrf %d", &vrf_id))
7678 else if (unformat (i, "ipv6"))
7682 clib_warning ("parse error '%U'", format_unformat_error, i);
7687 if (vrf_id_set == 0)
7689 errmsg ("missing vrf id");
7695 mp->vrf_id = ntohl (vrf_id);
7696 mp->is_ipv6 = is_ipv6;
7704 api_create_vlan_subif (vat_main_t * vam)
7706 unformat_input_t *i = vam->input;
7707 vl_api_create_vlan_subif_t *mp;
7709 u8 sw_if_index_set = 0;
7714 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7716 if (unformat (i, "sw_if_index %d", &sw_if_index))
7717 sw_if_index_set = 1;
7719 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7720 sw_if_index_set = 1;
7721 else if (unformat (i, "vlan %d", &vlan_id))
7725 clib_warning ("parse error '%U'", format_unformat_error, i);
7730 if (sw_if_index_set == 0)
7732 errmsg ("missing interface name or sw_if_index");
7736 if (vlan_id_set == 0)
7738 errmsg ("missing vlan_id");
7741 M (CREATE_VLAN_SUBIF, mp);
7743 mp->sw_if_index = ntohl (sw_if_index);
7744 mp->vlan_id = ntohl (vlan_id);
7751 #define foreach_create_subif_bit \
7758 _(outer_vlan_id_any) \
7759 _(inner_vlan_id_any)
7762 api_create_subif (vat_main_t * vam)
7764 unformat_input_t *i = vam->input;
7765 vl_api_create_subif_t *mp;
7767 u8 sw_if_index_set = 0;
7774 u32 exact_match = 0;
7775 u32 default_sub = 0;
7776 u32 outer_vlan_id_any = 0;
7777 u32 inner_vlan_id_any = 0;
7779 u16 outer_vlan_id = 0;
7780 u16 inner_vlan_id = 0;
7783 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7785 if (unformat (i, "sw_if_index %d", &sw_if_index))
7786 sw_if_index_set = 1;
7788 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7789 sw_if_index_set = 1;
7790 else if (unformat (i, "sub_id %d", &sub_id))
7792 else if (unformat (i, "outer_vlan_id %d", &tmp))
7793 outer_vlan_id = tmp;
7794 else if (unformat (i, "inner_vlan_id %d", &tmp))
7795 inner_vlan_id = tmp;
7797 #define _(a) else if (unformat (i, #a)) a = 1 ;
7798 foreach_create_subif_bit
7802 clib_warning ("parse error '%U'", format_unformat_error, i);
7807 if (sw_if_index_set == 0)
7809 errmsg ("missing interface name or sw_if_index");
7813 if (sub_id_set == 0)
7815 errmsg ("missing sub_id");
7818 M (CREATE_SUBIF, mp);
7820 mp->sw_if_index = ntohl (sw_if_index);
7821 mp->sub_id = ntohl (sub_id);
7823 #define _(a) mp->a = a;
7824 foreach_create_subif_bit;
7827 mp->outer_vlan_id = ntohs (outer_vlan_id);
7828 mp->inner_vlan_id = ntohs (inner_vlan_id);
7836 api_oam_add_del (vat_main_t * vam)
7838 unformat_input_t *i = vam->input;
7839 vl_api_oam_add_del_t *mp;
7842 ip4_address_t src, dst;
7847 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7849 if (unformat (i, "vrf %d", &vrf_id))
7851 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7853 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7855 else if (unformat (i, "del"))
7859 clib_warning ("parse error '%U'", format_unformat_error, i);
7866 errmsg ("missing src addr");
7872 errmsg ("missing dst addr");
7876 M (OAM_ADD_DEL, mp);
7878 mp->vrf_id = ntohl (vrf_id);
7879 mp->is_add = is_add;
7880 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7881 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7889 api_reset_fib (vat_main_t * vam)
7891 unformat_input_t *i = vam->input;
7892 vl_api_reset_fib_t *mp;
7898 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7900 if (unformat (i, "vrf %d", &vrf_id))
7902 else if (unformat (i, "ipv6"))
7906 clib_warning ("parse error '%U'", format_unformat_error, i);
7911 if (vrf_id_set == 0)
7913 errmsg ("missing vrf id");
7919 mp->vrf_id = ntohl (vrf_id);
7920 mp->is_ipv6 = is_ipv6;
7928 api_dhcp_proxy_config (vat_main_t * vam)
7930 unformat_input_t *i = vam->input;
7931 vl_api_dhcp_proxy_config_t *mp;
7933 u32 server_vrf_id = 0;
7935 u8 v4_address_set = 0;
7936 u8 v6_address_set = 0;
7937 ip4_address_t v4address;
7938 ip6_address_t v6address;
7939 u8 v4_src_address_set = 0;
7940 u8 v6_src_address_set = 0;
7941 ip4_address_t v4srcaddress;
7942 ip6_address_t v6srcaddress;
7945 /* Parse args required to build the message */
7946 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7948 if (unformat (i, "del"))
7950 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7952 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7954 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7956 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7958 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7959 v4_src_address_set = 1;
7960 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7961 v6_src_address_set = 1;
7966 if (v4_address_set && v6_address_set)
7968 errmsg ("both v4 and v6 server addresses set");
7971 if (!v4_address_set && !v6_address_set)
7973 errmsg ("no server addresses set");
7977 if (v4_src_address_set && v6_src_address_set)
7979 errmsg ("both v4 and v6 src addresses set");
7982 if (!v4_src_address_set && !v6_src_address_set)
7984 errmsg ("no src addresses set");
7988 if (!(v4_src_address_set && v4_address_set) &&
7989 !(v6_src_address_set && v6_address_set))
7991 errmsg ("no matching server and src addresses set");
7995 /* Construct the API message */
7996 M (DHCP_PROXY_CONFIG, mp);
7998 mp->is_add = is_add;
7999 mp->rx_vrf_id = ntohl (rx_vrf_id);
8000 mp->server_vrf_id = ntohl (server_vrf_id);
8004 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
8005 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
8009 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
8010 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
8016 /* Wait for a reply, return good/bad news */
8021 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
8022 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
8025 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
8027 vat_main_t *vam = &vat_main;
8028 u32 i, count = mp->count;
8029 vl_api_dhcp_server_t *s;
8033 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8034 ntohl (mp->rx_vrf_id),
8035 format_ip6_address, mp->dhcp_src_address,
8036 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8039 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8040 ntohl (mp->rx_vrf_id),
8041 format_ip4_address, mp->dhcp_src_address,
8042 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8044 for (i = 0; i < count; i++)
8046 s = &mp->servers[i];
8050 " Server Table-ID %d, Server Address %U",
8051 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
8054 " Server Table-ID %d, Server Address %U",
8055 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
8059 static void vl_api_dhcp_proxy_details_t_handler_json
8060 (vl_api_dhcp_proxy_details_t * mp)
8062 vat_main_t *vam = &vat_main;
8063 vat_json_node_t *node = NULL;
8064 u32 i, count = mp->count;
8066 struct in6_addr ip6;
8067 vl_api_dhcp_server_t *s;
8069 if (VAT_JSON_ARRAY != vam->json_tree.type)
8071 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8072 vat_json_init_array (&vam->json_tree);
8074 node = vat_json_array_add (&vam->json_tree);
8076 vat_json_init_object (node);
8077 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
8078 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
8079 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
8083 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
8084 vat_json_object_add_ip6 (node, "src_address", ip6);
8088 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
8089 vat_json_object_add_ip4 (node, "src_address", ip4);
8092 for (i = 0; i < count; i++)
8094 s = &mp->servers[i];
8096 vat_json_object_add_uint (node, "server-table-id",
8097 ntohl (s->server_vrf_id));
8101 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
8102 vat_json_object_add_ip4 (node, "src_address", ip4);
8106 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
8107 vat_json_object_add_ip6 (node, "server_address", ip6);
8113 api_dhcp_proxy_dump (vat_main_t * vam)
8115 unformat_input_t *i = vam->input;
8116 vl_api_control_ping_t *mp_ping;
8117 vl_api_dhcp_proxy_dump_t *mp;
8121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8123 if (unformat (i, "ipv6"))
8127 clib_warning ("parse error '%U'", format_unformat_error, i);
8132 M (DHCP_PROXY_DUMP, mp);
8134 mp->is_ip6 = is_ipv6;
8137 /* Use a control ping for synchronization */
8138 M (CONTROL_PING, mp_ping);
8146 api_dhcp_proxy_set_vss (vat_main_t * vam)
8148 unformat_input_t *i = vam->input;
8149 vl_api_dhcp_proxy_set_vss_t *mp;
8160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8162 if (unformat (i, "tbl_id %d", &tbl_id))
8164 if (unformat (i, "fib_id %d", &fib_id))
8166 if (unformat (i, "oui %d", &oui))
8168 else if (unformat (i, "ipv6"))
8170 else if (unformat (i, "del"))
8174 clib_warning ("parse error '%U'", format_unformat_error, i);
8179 if (tbl_id_set == 0)
8181 errmsg ("missing tbl id");
8185 if (fib_id_set == 0)
8187 errmsg ("missing fib id");
8192 errmsg ("missing oui");
8196 M (DHCP_PROXY_SET_VSS, mp);
8197 mp->tbl_id = ntohl (tbl_id);
8198 mp->fib_id = ntohl (fib_id);
8199 mp->oui = ntohl (oui);
8200 mp->is_ipv6 = is_ipv6;
8201 mp->is_add = is_add;
8209 api_dhcp_client_config (vat_main_t * vam)
8211 unformat_input_t *i = vam->input;
8212 vl_api_dhcp_client_config_t *mp;
8214 u8 sw_if_index_set = 0;
8217 u8 disable_event = 0;
8220 /* Parse args required to build the message */
8221 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8223 if (unformat (i, "del"))
8226 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8227 sw_if_index_set = 1;
8228 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8229 sw_if_index_set = 1;
8230 else if (unformat (i, "hostname %s", &hostname))
8232 else if (unformat (i, "disable_event"))
8238 if (sw_if_index_set == 0)
8240 errmsg ("missing interface name or sw_if_index");
8244 if (vec_len (hostname) > 63)
8246 errmsg ("hostname too long");
8248 vec_add1 (hostname, 0);
8250 /* Construct the API message */
8251 M (DHCP_CLIENT_CONFIG, mp);
8253 mp->sw_if_index = htonl (sw_if_index);
8254 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
8255 vec_free (hostname);
8256 mp->is_add = is_add;
8257 mp->want_dhcp_event = disable_event ? 0 : 1;
8258 mp->pid = htonl (getpid ());
8263 /* Wait for a reply, return good/bad news */
8269 api_set_ip_flow_hash (vat_main_t * vam)
8271 unformat_input_t *i = vam->input;
8272 vl_api_set_ip_flow_hash_t *mp;
8284 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8286 if (unformat (i, "vrf %d", &vrf_id))
8288 else if (unformat (i, "ipv6"))
8290 else if (unformat (i, "src"))
8292 else if (unformat (i, "dst"))
8294 else if (unformat (i, "sport"))
8296 else if (unformat (i, "dport"))
8298 else if (unformat (i, "proto"))
8300 else if (unformat (i, "reverse"))
8305 clib_warning ("parse error '%U'", format_unformat_error, i);
8310 if (vrf_id_set == 0)
8312 errmsg ("missing vrf id");
8316 M (SET_IP_FLOW_HASH, mp);
8322 mp->reverse = reverse;
8323 mp->vrf_id = ntohl (vrf_id);
8324 mp->is_ipv6 = is_ipv6;
8332 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8334 unformat_input_t *i = vam->input;
8335 vl_api_sw_interface_ip6_enable_disable_t *mp;
8337 u8 sw_if_index_set = 0;
8341 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8343 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8344 sw_if_index_set = 1;
8345 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8346 sw_if_index_set = 1;
8347 else if (unformat (i, "enable"))
8349 else if (unformat (i, "disable"))
8353 clib_warning ("parse error '%U'", format_unformat_error, i);
8358 if (sw_if_index_set == 0)
8360 errmsg ("missing interface name or sw_if_index");
8364 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8366 mp->sw_if_index = ntohl (sw_if_index);
8367 mp->enable = enable;
8375 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8377 unformat_input_t *i = vam->input;
8378 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8380 u8 sw_if_index_set = 0;
8381 u8 v6_address_set = 0;
8382 ip6_address_t v6address;
8385 /* Parse args required to build the message */
8386 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8388 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8389 sw_if_index_set = 1;
8390 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8391 sw_if_index_set = 1;
8392 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8398 if (sw_if_index_set == 0)
8400 errmsg ("missing interface name or sw_if_index");
8403 if (!v6_address_set)
8405 errmsg ("no address set");
8409 /* Construct the API message */
8410 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8412 mp->sw_if_index = ntohl (sw_if_index);
8413 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8418 /* Wait for a reply, return good/bad news */
8424 api_ip6nd_proxy_add_del (vat_main_t * vam)
8426 unformat_input_t *i = vam->input;
8427 vl_api_ip6nd_proxy_add_del_t *mp;
8428 u32 sw_if_index = ~0;
8429 u8 v6_address_set = 0;
8430 ip6_address_t v6address;
8434 /* Parse args required to build the message */
8435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8437 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8439 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8441 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8443 if (unformat (i, "del"))
8447 clib_warning ("parse error '%U'", format_unformat_error, i);
8452 if (sw_if_index == ~0)
8454 errmsg ("missing interface name or sw_if_index");
8457 if (!v6_address_set)
8459 errmsg ("no address set");
8463 /* Construct the API message */
8464 M (IP6ND_PROXY_ADD_DEL, mp);
8466 mp->is_del = is_del;
8467 mp->sw_if_index = ntohl (sw_if_index);
8468 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8473 /* Wait for a reply, return good/bad news */
8479 api_ip6nd_proxy_dump (vat_main_t * vam)
8481 vl_api_ip6nd_proxy_dump_t *mp;
8482 vl_api_control_ping_t *mp_ping;
8485 M (IP6ND_PROXY_DUMP, mp);
8489 /* Use a control ping for synchronization */
8490 M (CONTROL_PING, mp_ping);
8497 static void vl_api_ip6nd_proxy_details_t_handler
8498 (vl_api_ip6nd_proxy_details_t * mp)
8500 vat_main_t *vam = &vat_main;
8502 print (vam->ofp, "host %U sw_if_index %d",
8503 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
8506 static void vl_api_ip6nd_proxy_details_t_handler_json
8507 (vl_api_ip6nd_proxy_details_t * mp)
8509 vat_main_t *vam = &vat_main;
8510 struct in6_addr ip6;
8511 vat_json_node_t *node = NULL;
8513 if (VAT_JSON_ARRAY != vam->json_tree.type)
8515 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8516 vat_json_init_array (&vam->json_tree);
8518 node = vat_json_array_add (&vam->json_tree);
8520 vat_json_init_object (node);
8521 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
8523 clib_memcpy (&ip6, mp->address, sizeof (ip6));
8524 vat_json_object_add_ip6 (node, "host", ip6);
8528 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8530 unformat_input_t *i = vam->input;
8531 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8533 u8 sw_if_index_set = 0;
8534 u32 address_length = 0;
8535 u8 v6_address_set = 0;
8536 ip6_address_t v6address;
8538 u8 no_advertise = 0;
8540 u8 no_autoconfig = 0;
8543 u32 val_lifetime = 0;
8544 u32 pref_lifetime = 0;
8547 /* Parse args required to build the message */
8548 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8550 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8551 sw_if_index_set = 1;
8552 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8553 sw_if_index_set = 1;
8554 else if (unformat (i, "%U/%d",
8555 unformat_ip6_address, &v6address, &address_length))
8557 else if (unformat (i, "val_life %d", &val_lifetime))
8559 else if (unformat (i, "pref_life %d", &pref_lifetime))
8561 else if (unformat (i, "def"))
8563 else if (unformat (i, "noadv"))
8565 else if (unformat (i, "offl"))
8567 else if (unformat (i, "noauto"))
8569 else if (unformat (i, "nolink"))
8571 else if (unformat (i, "isno"))
8575 clib_warning ("parse error '%U'", format_unformat_error, i);
8580 if (sw_if_index_set == 0)
8582 errmsg ("missing interface name or sw_if_index");
8585 if (!v6_address_set)
8587 errmsg ("no address set");
8591 /* Construct the API message */
8592 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8594 mp->sw_if_index = ntohl (sw_if_index);
8595 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8596 mp->address_length = address_length;
8597 mp->use_default = use_default;
8598 mp->no_advertise = no_advertise;
8599 mp->off_link = off_link;
8600 mp->no_autoconfig = no_autoconfig;
8601 mp->no_onlink = no_onlink;
8603 mp->val_lifetime = ntohl (val_lifetime);
8604 mp->pref_lifetime = ntohl (pref_lifetime);
8609 /* Wait for a reply, return good/bad news */
8615 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8617 unformat_input_t *i = vam->input;
8618 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8620 u8 sw_if_index_set = 0;
8625 u8 send_unicast = 0;
8628 u8 default_router = 0;
8629 u32 max_interval = 0;
8630 u32 min_interval = 0;
8632 u32 initial_count = 0;
8633 u32 initial_interval = 0;
8637 /* Parse args required to build the message */
8638 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8640 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8641 sw_if_index_set = 1;
8642 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8643 sw_if_index_set = 1;
8644 else if (unformat (i, "maxint %d", &max_interval))
8646 else if (unformat (i, "minint %d", &min_interval))
8648 else if (unformat (i, "life %d", &lifetime))
8650 else if (unformat (i, "count %d", &initial_count))
8652 else if (unformat (i, "interval %d", &initial_interval))
8654 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8656 else if (unformat (i, "managed"))
8658 else if (unformat (i, "other"))
8660 else if (unformat (i, "ll"))
8662 else if (unformat (i, "send"))
8664 else if (unformat (i, "cease"))
8666 else if (unformat (i, "isno"))
8668 else if (unformat (i, "def"))
8672 clib_warning ("parse error '%U'", format_unformat_error, i);
8677 if (sw_if_index_set == 0)
8679 errmsg ("missing interface name or sw_if_index");
8683 /* Construct the API message */
8684 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8686 mp->sw_if_index = ntohl (sw_if_index);
8687 mp->max_interval = ntohl (max_interval);
8688 mp->min_interval = ntohl (min_interval);
8689 mp->lifetime = ntohl (lifetime);
8690 mp->initial_count = ntohl (initial_count);
8691 mp->initial_interval = ntohl (initial_interval);
8692 mp->suppress = suppress;
8693 mp->managed = managed;
8695 mp->ll_option = ll_option;
8696 mp->send_unicast = send_unicast;
8699 mp->default_router = default_router;
8704 /* Wait for a reply, return good/bad news */
8710 api_set_arp_neighbor_limit (vat_main_t * vam)
8712 unformat_input_t *i = vam->input;
8713 vl_api_set_arp_neighbor_limit_t *mp;
8719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8721 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8723 else if (unformat (i, "ipv6"))
8727 clib_warning ("parse error '%U'", format_unformat_error, i);
8734 errmsg ("missing limit value");
8738 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8740 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8741 mp->is_ipv6 = is_ipv6;
8749 api_l2_patch_add_del (vat_main_t * vam)
8751 unformat_input_t *i = vam->input;
8752 vl_api_l2_patch_add_del_t *mp;
8754 u8 rx_sw_if_index_set = 0;
8756 u8 tx_sw_if_index_set = 0;
8760 /* Parse args required to build the message */
8761 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8763 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8764 rx_sw_if_index_set = 1;
8765 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8766 tx_sw_if_index_set = 1;
8767 else if (unformat (i, "rx"))
8769 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8771 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8773 rx_sw_if_index_set = 1;
8778 else if (unformat (i, "tx"))
8780 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8782 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8784 tx_sw_if_index_set = 1;
8789 else if (unformat (i, "del"))
8795 if (rx_sw_if_index_set == 0)
8797 errmsg ("missing rx interface name or rx_sw_if_index");
8801 if (tx_sw_if_index_set == 0)
8803 errmsg ("missing tx interface name or tx_sw_if_index");
8807 M (L2_PATCH_ADD_DEL, mp);
8809 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8810 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8811 mp->is_add = is_add;
8819 u8 localsid_addr[16];
8828 api_sr_localsid_add_del (vat_main_t * vam)
8830 unformat_input_t *i = vam->input;
8831 vl_api_sr_localsid_add_del_t *mp;
8834 ip6_address_t localsid;
8838 u32 fib_table = ~(u32) 0;
8839 ip6_address_t next_hop;
8841 bool nexthop_set = 0;
8845 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8847 if (unformat (i, "del"))
8849 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
8850 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
8852 else if (unformat (i, "behavior %u", &behavior));
8853 else if (unformat (i, "sw_if_index %u", &sw_if_index));
8854 else if (unformat (i, "fib-table %u", &fib_table));
8855 else if (unformat (i, "end.psp %u", &behavior));
8860 M (SR_LOCALSID_ADD_DEL, mp);
8862 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
8864 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
8865 mp->behavior = behavior;
8866 mp->sw_if_index = ntohl (sw_if_index);
8867 mp->fib_table = ntohl (fib_table);
8868 mp->end_psp = end_psp;
8869 mp->is_del = is_del;
8877 api_ioam_enable (vat_main_t * vam)
8879 unformat_input_t *input = vam->input;
8880 vl_api_ioam_enable_t *mp;
8882 int has_trace_option = 0;
8883 int has_pot_option = 0;
8884 int has_seqno_option = 0;
8885 int has_analyse_option = 0;
8888 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8890 if (unformat (input, "trace"))
8891 has_trace_option = 1;
8892 else if (unformat (input, "pot"))
8894 else if (unformat (input, "seqno"))
8895 has_seqno_option = 1;
8896 else if (unformat (input, "analyse"))
8897 has_analyse_option = 1;
8901 M (IOAM_ENABLE, mp);
8902 mp->id = htons (id);
8903 mp->seqno = has_seqno_option;
8904 mp->analyse = has_analyse_option;
8905 mp->pot_enable = has_pot_option;
8906 mp->trace_enable = has_trace_option;
8915 api_ioam_disable (vat_main_t * vam)
8917 vl_api_ioam_disable_t *mp;
8920 M (IOAM_DISABLE, mp);
8926 #define foreach_tcp_proto_field \
8930 #define foreach_udp_proto_field \
8934 #define foreach_ip4_proto_field \
8946 u16 src_port, dst_port;
8949 #if VPP_API_TEST_BUILTIN == 0
8951 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8953 u8 **maskp = va_arg (*args, u8 **);
8955 u8 found_something = 0;
8958 #define _(a) u8 a=0;
8959 foreach_tcp_proto_field;
8962 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8965 #define _(a) else if (unformat (input, #a)) a=1;
8966 foreach_tcp_proto_field
8972 #define _(a) found_something += a;
8973 foreach_tcp_proto_field;
8976 if (found_something == 0)
8979 vec_validate (mask, sizeof (*tcp) - 1);
8981 tcp = (tcp_header_t *) mask;
8983 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8984 foreach_tcp_proto_field;
8992 unformat_udp_mask (unformat_input_t * input, va_list * args)
8994 u8 **maskp = va_arg (*args, u8 **);
8996 u8 found_something = 0;
8999 #define _(a) u8 a=0;
9000 foreach_udp_proto_field;
9003 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9006 #define _(a) else if (unformat (input, #a)) a=1;
9007 foreach_udp_proto_field
9013 #define _(a) found_something += a;
9014 foreach_udp_proto_field;
9017 if (found_something == 0)
9020 vec_validate (mask, sizeof (*udp) - 1);
9022 udp = (udp_header_t *) mask;
9024 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
9025 foreach_udp_proto_field;
9033 unformat_l4_mask (unformat_input_t * input, va_list * args)
9035 u8 **maskp = va_arg (*args, u8 **);
9036 u16 src_port = 0, dst_port = 0;
9037 tcpudp_header_t *tcpudp;
9039 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9041 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9043 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9045 else if (unformat (input, "src_port"))
9047 else if (unformat (input, "dst_port"))
9053 if (!src_port && !dst_port)
9057 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9059 tcpudp = (tcpudp_header_t *) mask;
9060 tcpudp->src_port = src_port;
9061 tcpudp->dst_port = dst_port;
9069 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9071 u8 **maskp = va_arg (*args, u8 **);
9073 u8 found_something = 0;
9076 #define _(a) u8 a=0;
9077 foreach_ip4_proto_field;
9083 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9085 if (unformat (input, "version"))
9087 else if (unformat (input, "hdr_length"))
9089 else if (unformat (input, "src"))
9091 else if (unformat (input, "dst"))
9093 else if (unformat (input, "proto"))
9096 #define _(a) else if (unformat (input, #a)) a=1;
9097 foreach_ip4_proto_field
9103 #define _(a) found_something += a;
9104 foreach_ip4_proto_field;
9107 if (found_something == 0)
9110 vec_validate (mask, sizeof (*ip) - 1);
9112 ip = (ip4_header_t *) mask;
9114 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9115 foreach_ip4_proto_field;
9118 ip->ip_version_and_header_length = 0;
9121 ip->ip_version_and_header_length |= 0xF0;
9124 ip->ip_version_and_header_length |= 0x0F;
9130 #define foreach_ip6_proto_field \
9138 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9140 u8 **maskp = va_arg (*args, u8 **);
9142 u8 found_something = 0;
9144 u32 ip_version_traffic_class_and_flow_label;
9146 #define _(a) u8 a=0;
9147 foreach_ip6_proto_field;
9150 u8 traffic_class = 0;
9153 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9155 if (unformat (input, "version"))
9157 else if (unformat (input, "traffic-class"))
9159 else if (unformat (input, "flow-label"))
9161 else if (unformat (input, "src"))
9163 else if (unformat (input, "dst"))
9165 else if (unformat (input, "proto"))
9168 #define _(a) else if (unformat (input, #a)) a=1;
9169 foreach_ip6_proto_field
9175 #define _(a) found_something += a;
9176 foreach_ip6_proto_field;
9179 if (found_something == 0)
9182 vec_validate (mask, sizeof (*ip) - 1);
9184 ip = (ip6_header_t *) mask;
9186 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9187 foreach_ip6_proto_field;
9190 ip_version_traffic_class_and_flow_label = 0;
9193 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9196 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9199 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9201 ip->ip_version_traffic_class_and_flow_label =
9202 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9209 unformat_l3_mask (unformat_input_t * input, va_list * args)
9211 u8 **maskp = va_arg (*args, u8 **);
9213 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9215 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9217 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9226 unformat_l2_mask (unformat_input_t * input, va_list * args)
9228 u8 **maskp = va_arg (*args, u8 **);
9243 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9245 if (unformat (input, "src"))
9247 else if (unformat (input, "dst"))
9249 else if (unformat (input, "proto"))
9251 else if (unformat (input, "tag1"))
9253 else if (unformat (input, "tag2"))
9255 else if (unformat (input, "ignore-tag1"))
9257 else if (unformat (input, "ignore-tag2"))
9259 else if (unformat (input, "cos1"))
9261 else if (unformat (input, "cos2"))
9263 else if (unformat (input, "dot1q"))
9265 else if (unformat (input, "dot1ad"))
9270 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9271 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9274 if (tag1 || ignore_tag1 || cos1 || dot1q)
9276 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9279 vec_validate (mask, len - 1);
9282 memset (mask, 0xff, 6);
9285 memset (mask + 6, 0xff, 6);
9289 /* inner vlan tag */
9298 mask[21] = mask[20] = 0xff;
9319 mask[16] = mask[17] = 0xff;
9329 mask[12] = mask[13] = 0xff;
9336 unformat_classify_mask (unformat_input_t * input, va_list * args)
9338 u8 **maskp = va_arg (*args, u8 **);
9339 u32 *skipp = va_arg (*args, u32 *);
9340 u32 *matchp = va_arg (*args, u32 *);
9348 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9350 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9352 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9354 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9356 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9370 if (mask || l2 || l3 || l4)
9374 /* "With a free Ethernet header in every package" */
9376 vec_validate (l2, 13);
9380 vec_append (mask, l3);
9385 vec_append (mask, l4);
9390 /* Scan forward looking for the first significant mask octet */
9391 for (i = 0; i < vec_len (mask); i++)
9395 /* compute (skip, match) params */
9396 *skipp = i / sizeof (u32x4);
9397 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9399 /* Pad mask to an even multiple of the vector size */
9400 while (vec_len (mask) % sizeof (u32x4))
9403 match = vec_len (mask) / sizeof (u32x4);
9405 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9407 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9408 if (*tmp || *(tmp + 1))
9413 clib_warning ("BUG: match 0");
9415 _vec_len (mask) = match * sizeof (u32x4);
9425 #endif /* VPP_API_TEST_BUILTIN */
9427 #define foreach_l2_next \
9429 _(ethernet, ETHERNET_INPUT) \
9434 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9436 u32 *miss_next_indexp = va_arg (*args, u32 *);
9441 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9445 if (unformat (input, "%d", &tmp))
9454 *miss_next_indexp = next_index;
9458 #define foreach_ip_next \
9464 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9466 u32 *miss_next_indexp = va_arg (*args, u32 *);
9471 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9475 if (unformat (input, "%d", &tmp))
9484 *miss_next_indexp = next_index;
9488 #define foreach_acl_next \
9492 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9494 u32 *miss_next_indexp = va_arg (*args, u32 *);
9499 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9503 if (unformat (input, "permit"))
9508 else if (unformat (input, "%d", &tmp))
9517 *miss_next_indexp = next_index;
9522 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9524 u32 *r = va_arg (*args, u32 *);
9526 if (unformat (input, "conform-color"))
9527 *r = POLICE_CONFORM;
9528 else if (unformat (input, "exceed-color"))
9537 api_classify_add_del_table (vat_main_t * vam)
9539 unformat_input_t *i = vam->input;
9540 vl_api_classify_add_del_table_t *mp;
9547 u32 table_index = ~0;
9548 u32 next_table_index = ~0;
9549 u32 miss_next_index = ~0;
9550 u32 memory_size = 32 << 20;
9552 u32 current_data_flag = 0;
9553 int current_data_offset = 0;
9556 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9558 if (unformat (i, "del"))
9560 else if (unformat (i, "del-chain"))
9565 else if (unformat (i, "buckets %d", &nbuckets))
9567 else if (unformat (i, "memory_size %d", &memory_size))
9569 else if (unformat (i, "skip %d", &skip))
9571 else if (unformat (i, "match %d", &match))
9573 else if (unformat (i, "table %d", &table_index))
9575 else if (unformat (i, "mask %U", unformat_classify_mask,
9576 &mask, &skip, &match))
9578 else if (unformat (i, "next-table %d", &next_table_index))
9580 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9583 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9586 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9589 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9591 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9597 if (is_add && mask == 0)
9599 errmsg ("Mask required");
9603 if (is_add && skip == ~0)
9605 errmsg ("skip count required");
9609 if (is_add && match == ~0)
9611 errmsg ("match count required");
9615 if (!is_add && table_index == ~0)
9617 errmsg ("table index required for delete");
9621 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9623 mp->is_add = is_add;
9624 mp->del_chain = del_chain;
9625 mp->table_index = ntohl (table_index);
9626 mp->nbuckets = ntohl (nbuckets);
9627 mp->memory_size = ntohl (memory_size);
9628 mp->skip_n_vectors = ntohl (skip);
9629 mp->match_n_vectors = ntohl (match);
9630 mp->next_table_index = ntohl (next_table_index);
9631 mp->miss_next_index = ntohl (miss_next_index);
9632 mp->current_data_flag = ntohl (current_data_flag);
9633 mp->current_data_offset = ntohl (current_data_offset);
9634 clib_memcpy (mp->mask, mask, vec_len (mask));
9643 #if VPP_API_TEST_BUILTIN == 0
9645 unformat_l4_match (unformat_input_t * input, va_list * args)
9647 u8 **matchp = va_arg (*args, u8 **);
9649 u8 *proto_header = 0;
9655 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9657 if (unformat (input, "src_port %d", &src_port))
9659 else if (unformat (input, "dst_port %d", &dst_port))
9665 h.src_port = clib_host_to_net_u16 (src_port);
9666 h.dst_port = clib_host_to_net_u16 (dst_port);
9667 vec_validate (proto_header, sizeof (h) - 1);
9668 memcpy (proto_header, &h, sizeof (h));
9670 *matchp = proto_header;
9676 unformat_ip4_match (unformat_input_t * input, va_list * args)
9678 u8 **matchp = va_arg (*args, u8 **);
9685 int src = 0, dst = 0;
9686 ip4_address_t src_val, dst_val;
9693 int fragment_id = 0;
9694 u32 fragment_id_val;
9700 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9702 if (unformat (input, "version %d", &version_val))
9704 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9706 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9708 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9710 else if (unformat (input, "proto %d", &proto_val))
9712 else if (unformat (input, "tos %d", &tos_val))
9714 else if (unformat (input, "length %d", &length_val))
9716 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9718 else if (unformat (input, "ttl %d", &ttl_val))
9720 else if (unformat (input, "checksum %d", &checksum_val))
9726 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9727 + ttl + checksum == 0)
9731 * Aligned because we use the real comparison functions
9733 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9735 ip = (ip4_header_t *) match;
9737 /* These are realistically matched in practice */
9739 ip->src_address.as_u32 = src_val.as_u32;
9742 ip->dst_address.as_u32 = dst_val.as_u32;
9745 ip->protocol = proto_val;
9748 /* These are not, but they're included for completeness */
9750 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9753 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9759 ip->length = clib_host_to_net_u16 (length_val);
9765 ip->checksum = clib_host_to_net_u16 (checksum_val);
9772 unformat_ip6_match (unformat_input_t * input, va_list * args)
9774 u8 **matchp = va_arg (*args, u8 **);
9779 u8 traffic_class = 0;
9780 u32 traffic_class_val = 0;
9783 int src = 0, dst = 0;
9784 ip6_address_t src_val, dst_val;
9787 int payload_length = 0;
9788 u32 payload_length_val;
9791 u32 ip_version_traffic_class_and_flow_label;
9793 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9795 if (unformat (input, "version %d", &version_val))
9797 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9799 else if (unformat (input, "flow_label %d", &flow_label_val))
9801 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9803 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9805 else if (unformat (input, "proto %d", &proto_val))
9807 else if (unformat (input, "payload_length %d", &payload_length_val))
9809 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9815 if (version + traffic_class + flow_label + src + dst + proto +
9816 payload_length + hop_limit == 0)
9820 * Aligned because we use the real comparison functions
9822 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9824 ip = (ip6_header_t *) match;
9827 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9830 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9833 ip->protocol = proto_val;
9835 ip_version_traffic_class_and_flow_label = 0;
9838 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9841 ip_version_traffic_class_and_flow_label |=
9842 (traffic_class_val & 0xFF) << 20;
9845 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9847 ip->ip_version_traffic_class_and_flow_label =
9848 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9851 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9854 ip->hop_limit = hop_limit_val;
9861 unformat_l3_match (unformat_input_t * input, va_list * args)
9863 u8 **matchp = va_arg (*args, u8 **);
9865 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9867 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9869 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9878 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9880 u8 *tagp = va_arg (*args, u8 *);
9883 if (unformat (input, "%d", &tag))
9885 tagp[0] = (tag >> 8) & 0x0F;
9886 tagp[1] = tag & 0xFF;
9894 unformat_l2_match (unformat_input_t * input, va_list * args)
9896 u8 **matchp = va_arg (*args, u8 **);
9916 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9918 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9921 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9923 else if (unformat (input, "proto %U",
9924 unformat_ethernet_type_host_byte_order, &proto_val))
9926 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9928 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9930 else if (unformat (input, "ignore-tag1"))
9932 else if (unformat (input, "ignore-tag2"))
9934 else if (unformat (input, "cos1 %d", &cos1_val))
9936 else if (unformat (input, "cos2 %d", &cos2_val))
9941 if ((src + dst + proto + tag1 + tag2 +
9942 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9945 if (tag1 || ignore_tag1 || cos1)
9947 if (tag2 || ignore_tag2 || cos2)
9950 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9953 clib_memcpy (match, dst_val, 6);
9956 clib_memcpy (match + 6, src_val, 6);
9960 /* inner vlan tag */
9961 match[19] = tag2_val[1];
9962 match[18] = tag2_val[0];
9964 match[18] |= (cos2_val & 0x7) << 5;
9967 match[21] = proto_val & 0xff;
9968 match[20] = proto_val >> 8;
9972 match[15] = tag1_val[1];
9973 match[14] = tag1_val[0];
9976 match[14] |= (cos1_val & 0x7) << 5;
9982 match[15] = tag1_val[1];
9983 match[14] = tag1_val[0];
9986 match[17] = proto_val & 0xff;
9987 match[16] = proto_val >> 8;
9990 match[14] |= (cos1_val & 0x7) << 5;
9996 match[18] |= (cos2_val & 0x7) << 5;
9998 match[14] |= (cos1_val & 0x7) << 5;
10001 match[13] = proto_val & 0xff;
10002 match[12] = proto_val >> 8;
10011 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10013 u8 **matchp = va_arg (*args, u8 **);
10014 u32 skip_n_vectors = va_arg (*args, u32);
10015 u32 match_n_vectors = va_arg (*args, u32);
10022 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10024 if (unformat (input, "hex %U", unformat_hex_string, &match))
10026 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10028 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10030 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10044 if (match || l2 || l3 || l4)
10046 if (l2 || l3 || l4)
10048 /* "Win a free Ethernet header in every packet" */
10050 vec_validate_aligned (l2, 13, sizeof (u32x4));
10054 vec_append_aligned (match, l3, sizeof (u32x4));
10059 vec_append_aligned (match, l4, sizeof (u32x4));
10064 /* Make sure the vector is big enough even if key is all 0's */
10065 vec_validate_aligned
10066 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10069 /* Set size, include skipped vectors */
10070 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10081 api_classify_add_del_session (vat_main_t * vam)
10083 unformat_input_t *i = vam->input;
10084 vl_api_classify_add_del_session_t *mp;
10086 u32 table_index = ~0;
10087 u32 hit_next_index = ~0;
10088 u32 opaque_index = ~0;
10091 u32 skip_n_vectors = 0;
10092 u32 match_n_vectors = 0;
10098 * Warning: you have to supply skip_n and match_n
10099 * because the API client cant simply look at the classify
10103 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10105 if (unformat (i, "del"))
10107 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10110 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10113 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10116 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10118 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10120 else if (unformat (i, "opaque-index %d", &opaque_index))
10122 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10124 else if (unformat (i, "match_n %d", &match_n_vectors))
10126 else if (unformat (i, "match %U", api_unformat_classify_match,
10127 &match, skip_n_vectors, match_n_vectors))
10129 else if (unformat (i, "advance %d", &advance))
10131 else if (unformat (i, "table-index %d", &table_index))
10133 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10135 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10137 else if (unformat (i, "action %d", &action))
10139 else if (unformat (i, "metadata %d", &metadata))
10145 if (table_index == ~0)
10147 errmsg ("Table index required");
10151 if (is_add && match == 0)
10153 errmsg ("Match value required");
10157 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10159 mp->is_add = is_add;
10160 mp->table_index = ntohl (table_index);
10161 mp->hit_next_index = ntohl (hit_next_index);
10162 mp->opaque_index = ntohl (opaque_index);
10163 mp->advance = ntohl (advance);
10164 mp->action = action;
10165 mp->metadata = ntohl (metadata);
10166 clib_memcpy (mp->match, match, vec_len (match));
10175 api_classify_set_interface_ip_table (vat_main_t * vam)
10177 unformat_input_t *i = vam->input;
10178 vl_api_classify_set_interface_ip_table_t *mp;
10180 int sw_if_index_set;
10181 u32 table_index = ~0;
10185 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10187 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10188 sw_if_index_set = 1;
10189 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10190 sw_if_index_set = 1;
10191 else if (unformat (i, "table %d", &table_index))
10195 clib_warning ("parse error '%U'", format_unformat_error, i);
10200 if (sw_if_index_set == 0)
10202 errmsg ("missing interface name or sw_if_index");
10207 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10209 mp->sw_if_index = ntohl (sw_if_index);
10210 mp->table_index = ntohl (table_index);
10211 mp->is_ipv6 = is_ipv6;
10219 api_classify_set_interface_l2_tables (vat_main_t * vam)
10221 unformat_input_t *i = vam->input;
10222 vl_api_classify_set_interface_l2_tables_t *mp;
10224 int sw_if_index_set;
10225 u32 ip4_table_index = ~0;
10226 u32 ip6_table_index = ~0;
10227 u32 other_table_index = ~0;
10231 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10233 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10234 sw_if_index_set = 1;
10235 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10236 sw_if_index_set = 1;
10237 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10239 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10241 else if (unformat (i, "other-table %d", &other_table_index))
10243 else if (unformat (i, "is-input %d", &is_input))
10247 clib_warning ("parse error '%U'", format_unformat_error, i);
10252 if (sw_if_index_set == 0)
10254 errmsg ("missing interface name or sw_if_index");
10259 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10261 mp->sw_if_index = ntohl (sw_if_index);
10262 mp->ip4_table_index = ntohl (ip4_table_index);
10263 mp->ip6_table_index = ntohl (ip6_table_index);
10264 mp->other_table_index = ntohl (other_table_index);
10265 mp->is_input = (u8) is_input;
10273 api_set_ipfix_exporter (vat_main_t * vam)
10275 unformat_input_t *i = vam->input;
10276 vl_api_set_ipfix_exporter_t *mp;
10277 ip4_address_t collector_address;
10278 u8 collector_address_set = 0;
10279 u32 collector_port = ~0;
10280 ip4_address_t src_address;
10281 u8 src_address_set = 0;
10284 u32 template_interval = ~0;
10285 u8 udp_checksum = 0;
10288 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10290 if (unformat (i, "collector_address %U", unformat_ip4_address,
10291 &collector_address))
10292 collector_address_set = 1;
10293 else if (unformat (i, "collector_port %d", &collector_port))
10295 else if (unformat (i, "src_address %U", unformat_ip4_address,
10297 src_address_set = 1;
10298 else if (unformat (i, "vrf_id %d", &vrf_id))
10300 else if (unformat (i, "path_mtu %d", &path_mtu))
10302 else if (unformat (i, "template_interval %d", &template_interval))
10304 else if (unformat (i, "udp_checksum"))
10310 if (collector_address_set == 0)
10312 errmsg ("collector_address required");
10316 if (src_address_set == 0)
10318 errmsg ("src_address required");
10322 M (SET_IPFIX_EXPORTER, mp);
10324 memcpy (mp->collector_address, collector_address.data,
10325 sizeof (collector_address.data));
10326 mp->collector_port = htons ((u16) collector_port);
10327 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10328 mp->vrf_id = htonl (vrf_id);
10329 mp->path_mtu = htonl (path_mtu);
10330 mp->template_interval = htonl (template_interval);
10331 mp->udp_checksum = udp_checksum;
10339 api_set_ipfix_classify_stream (vat_main_t * vam)
10341 unformat_input_t *i = vam->input;
10342 vl_api_set_ipfix_classify_stream_t *mp;
10344 u32 src_port = UDP_DST_PORT_ipfix;
10347 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10349 if (unformat (i, "domain %d", &domain_id))
10351 else if (unformat (i, "src_port %d", &src_port))
10355 errmsg ("unknown input `%U'", format_unformat_error, i);
10360 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10362 mp->domain_id = htonl (domain_id);
10363 mp->src_port = htons ((u16) src_port);
10371 api_ipfix_classify_table_add_del (vat_main_t * vam)
10373 unformat_input_t *i = vam->input;
10374 vl_api_ipfix_classify_table_add_del_t *mp;
10376 u32 classify_table_index = ~0;
10378 u8 transport_protocol = 255;
10381 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10383 if (unformat (i, "add"))
10385 else if (unformat (i, "del"))
10387 else if (unformat (i, "table %d", &classify_table_index))
10389 else if (unformat (i, "ip4"))
10391 else if (unformat (i, "ip6"))
10393 else if (unformat (i, "tcp"))
10394 transport_protocol = 6;
10395 else if (unformat (i, "udp"))
10396 transport_protocol = 17;
10399 errmsg ("unknown input `%U'", format_unformat_error, i);
10406 errmsg ("expecting: add|del");
10409 if (classify_table_index == ~0)
10411 errmsg ("classifier table not specified");
10414 if (ip_version == 0)
10416 errmsg ("IP version not specified");
10420 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10422 mp->is_add = is_add;
10423 mp->table_id = htonl (classify_table_index);
10424 mp->ip_version = ip_version;
10425 mp->transport_protocol = transport_protocol;
10433 api_get_node_index (vat_main_t * vam)
10435 unformat_input_t *i = vam->input;
10436 vl_api_get_node_index_t *mp;
10440 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10442 if (unformat (i, "node %s", &name))
10449 errmsg ("node name required");
10452 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10454 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10458 M (GET_NODE_INDEX, mp);
10459 clib_memcpy (mp->node_name, name, vec_len (name));
10468 api_get_next_index (vat_main_t * vam)
10470 unformat_input_t *i = vam->input;
10471 vl_api_get_next_index_t *mp;
10472 u8 *node_name = 0, *next_node_name = 0;
10475 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10477 if (unformat (i, "node-name %s", &node_name))
10479 else if (unformat (i, "next-node-name %s", &next_node_name))
10483 if (node_name == 0)
10485 errmsg ("node name required");
10488 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10490 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10494 if (next_node_name == 0)
10496 errmsg ("next node name required");
10499 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10501 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10505 M (GET_NEXT_INDEX, mp);
10506 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10507 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10508 vec_free (node_name);
10509 vec_free (next_node_name);
10517 api_add_node_next (vat_main_t * vam)
10519 unformat_input_t *i = vam->input;
10520 vl_api_add_node_next_t *mp;
10525 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10527 if (unformat (i, "node %s", &name))
10529 else if (unformat (i, "next %s", &next))
10536 errmsg ("node name required");
10539 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10541 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10546 errmsg ("next node required");
10549 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10551 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10555 M (ADD_NODE_NEXT, mp);
10556 clib_memcpy (mp->node_name, name, vec_len (name));
10557 clib_memcpy (mp->next_name, next, vec_len (next));
10567 api_l2tpv3_create_tunnel (vat_main_t * vam)
10569 unformat_input_t *i = vam->input;
10570 ip6_address_t client_address, our_address;
10571 int client_address_set = 0;
10572 int our_address_set = 0;
10573 u32 local_session_id = 0;
10574 u32 remote_session_id = 0;
10575 u64 local_cookie = 0;
10576 u64 remote_cookie = 0;
10577 u8 l2_sublayer_present = 0;
10578 vl_api_l2tpv3_create_tunnel_t *mp;
10581 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10583 if (unformat (i, "client_address %U", unformat_ip6_address,
10585 client_address_set = 1;
10586 else if (unformat (i, "our_address %U", unformat_ip6_address,
10588 our_address_set = 1;
10589 else if (unformat (i, "local_session_id %d", &local_session_id))
10591 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10593 else if (unformat (i, "local_cookie %lld", &local_cookie))
10595 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10597 else if (unformat (i, "l2-sublayer-present"))
10598 l2_sublayer_present = 1;
10603 if (client_address_set == 0)
10605 errmsg ("client_address required");
10609 if (our_address_set == 0)
10611 errmsg ("our_address required");
10615 M (L2TPV3_CREATE_TUNNEL, mp);
10617 clib_memcpy (mp->client_address, client_address.as_u8,
10618 sizeof (mp->client_address));
10620 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10622 mp->local_session_id = ntohl (local_session_id);
10623 mp->remote_session_id = ntohl (remote_session_id);
10624 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10625 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10626 mp->l2_sublayer_present = l2_sublayer_present;
10635 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10637 unformat_input_t *i = vam->input;
10639 u8 sw_if_index_set = 0;
10640 u64 new_local_cookie = 0;
10641 u64 new_remote_cookie = 0;
10642 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10645 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10647 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10648 sw_if_index_set = 1;
10649 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10650 sw_if_index_set = 1;
10651 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10653 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10659 if (sw_if_index_set == 0)
10661 errmsg ("missing interface name or sw_if_index");
10665 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10667 mp->sw_if_index = ntohl (sw_if_index);
10668 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10669 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10677 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10679 unformat_input_t *i = vam->input;
10680 vl_api_l2tpv3_interface_enable_disable_t *mp;
10682 u8 sw_if_index_set = 0;
10683 u8 enable_disable = 1;
10686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10688 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10689 sw_if_index_set = 1;
10690 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10691 sw_if_index_set = 1;
10692 else if (unformat (i, "enable"))
10693 enable_disable = 1;
10694 else if (unformat (i, "disable"))
10695 enable_disable = 0;
10700 if (sw_if_index_set == 0)
10702 errmsg ("missing interface name or sw_if_index");
10706 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10708 mp->sw_if_index = ntohl (sw_if_index);
10709 mp->enable_disable = enable_disable;
10717 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10719 unformat_input_t *i = vam->input;
10720 vl_api_l2tpv3_set_lookup_key_t *mp;
10724 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10726 if (unformat (i, "lookup_v6_src"))
10727 key = L2T_LOOKUP_SRC_ADDRESS;
10728 else if (unformat (i, "lookup_v6_dst"))
10729 key = L2T_LOOKUP_DST_ADDRESS;
10730 else if (unformat (i, "lookup_session_id"))
10731 key = L2T_LOOKUP_SESSION_ID;
10736 if (key == (u8) ~ 0)
10738 errmsg ("l2tp session lookup key unset");
10742 M (L2TPV3_SET_LOOKUP_KEY, mp);
10751 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10752 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10754 vat_main_t *vam = &vat_main;
10756 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10757 format_ip6_address, mp->our_address,
10758 format_ip6_address, mp->client_address,
10759 clib_net_to_host_u32 (mp->sw_if_index));
10762 " local cookies %016llx %016llx remote cookie %016llx",
10763 clib_net_to_host_u64 (mp->local_cookie[0]),
10764 clib_net_to_host_u64 (mp->local_cookie[1]),
10765 clib_net_to_host_u64 (mp->remote_cookie));
10767 print (vam->ofp, " local session-id %d remote session-id %d",
10768 clib_net_to_host_u32 (mp->local_session_id),
10769 clib_net_to_host_u32 (mp->remote_session_id));
10771 print (vam->ofp, " l2 specific sublayer %s\n",
10772 mp->l2_sublayer_present ? "preset" : "absent");
10776 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10777 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10779 vat_main_t *vam = &vat_main;
10780 vat_json_node_t *node = NULL;
10781 struct in6_addr addr;
10783 if (VAT_JSON_ARRAY != vam->json_tree.type)
10785 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10786 vat_json_init_array (&vam->json_tree);
10788 node = vat_json_array_add (&vam->json_tree);
10790 vat_json_init_object (node);
10792 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10793 vat_json_object_add_ip6 (node, "our_address", addr);
10794 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10795 vat_json_object_add_ip6 (node, "client_address", addr);
10797 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10798 vat_json_init_array (lc);
10799 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10800 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10801 vat_json_object_add_uint (node, "remote_cookie",
10802 clib_net_to_host_u64 (mp->remote_cookie));
10804 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10805 vat_json_object_add_uint (node, "local_session_id",
10806 clib_net_to_host_u32 (mp->local_session_id));
10807 vat_json_object_add_uint (node, "remote_session_id",
10808 clib_net_to_host_u32 (mp->remote_session_id));
10809 vat_json_object_add_string_copy (node, "l2_sublayer",
10810 mp->l2_sublayer_present ? (u8 *) "present"
10811 : (u8 *) "absent");
10815 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10817 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10818 vl_api_control_ping_t *mp_ping;
10821 /* Get list of l2tpv3-tunnel interfaces */
10822 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10825 /* Use a control ping for synchronization */
10826 M (CONTROL_PING, mp_ping);
10834 static void vl_api_sw_interface_tap_details_t_handler
10835 (vl_api_sw_interface_tap_details_t * mp)
10837 vat_main_t *vam = &vat_main;
10839 print (vam->ofp, "%-16s %d",
10840 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10843 static void vl_api_sw_interface_tap_details_t_handler_json
10844 (vl_api_sw_interface_tap_details_t * mp)
10846 vat_main_t *vam = &vat_main;
10847 vat_json_node_t *node = NULL;
10849 if (VAT_JSON_ARRAY != vam->json_tree.type)
10851 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10852 vat_json_init_array (&vam->json_tree);
10854 node = vat_json_array_add (&vam->json_tree);
10856 vat_json_init_object (node);
10857 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10858 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10862 api_sw_interface_tap_dump (vat_main_t * vam)
10864 vl_api_sw_interface_tap_dump_t *mp;
10865 vl_api_control_ping_t *mp_ping;
10868 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10869 /* Get list of tap interfaces */
10870 M (SW_INTERFACE_TAP_DUMP, mp);
10873 /* Use a control ping for synchronization */
10874 M (CONTROL_PING, mp_ping);
10881 static uword unformat_vxlan_decap_next
10882 (unformat_input_t * input, va_list * args)
10884 u32 *result = va_arg (*args, u32 *);
10887 if (unformat (input, "l2"))
10888 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10889 else if (unformat (input, "%d", &tmp))
10897 api_vxlan_add_del_tunnel (vat_main_t * vam)
10899 unformat_input_t *line_input = vam->input;
10900 vl_api_vxlan_add_del_tunnel_t *mp;
10901 ip46_address_t src, dst;
10903 u8 ipv4_set = 0, ipv6_set = 0;
10907 u32 mcast_sw_if_index = ~0;
10908 u32 encap_vrf_id = 0;
10909 u32 decap_next_index = ~0;
10913 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10914 memset (&src, 0, sizeof src);
10915 memset (&dst, 0, sizeof dst);
10917 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10919 if (unformat (line_input, "del"))
10922 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10928 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10934 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10940 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10945 else if (unformat (line_input, "group %U %U",
10946 unformat_ip4_address, &dst.ip4,
10947 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10949 grp_set = dst_set = 1;
10952 else if (unformat (line_input, "group %U",
10953 unformat_ip4_address, &dst.ip4))
10955 grp_set = dst_set = 1;
10958 else if (unformat (line_input, "group %U %U",
10959 unformat_ip6_address, &dst.ip6,
10960 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10962 grp_set = dst_set = 1;
10965 else if (unformat (line_input, "group %U",
10966 unformat_ip6_address, &dst.ip6))
10968 grp_set = dst_set = 1;
10972 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10974 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10976 else if (unformat (line_input, "decap-next %U",
10977 unformat_vxlan_decap_next, &decap_next_index))
10979 else if (unformat (line_input, "vni %d", &vni))
10983 errmsg ("parse error '%U'", format_unformat_error, line_input);
10990 errmsg ("tunnel src address not specified");
10995 errmsg ("tunnel dst address not specified");
10999 if (grp_set && !ip46_address_is_multicast (&dst))
11001 errmsg ("tunnel group address not multicast");
11004 if (grp_set && mcast_sw_if_index == ~0)
11006 errmsg ("tunnel nonexistent multicast device");
11009 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11011 errmsg ("tunnel dst address must be unicast");
11016 if (ipv4_set && ipv6_set)
11018 errmsg ("both IPv4 and IPv6 addresses specified");
11022 if ((vni == 0) || (vni >> 24))
11024 errmsg ("vni not specified or out of range");
11028 M (VXLAN_ADD_DEL_TUNNEL, mp);
11032 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
11033 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
11037 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
11038 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
11040 mp->encap_vrf_id = ntohl (encap_vrf_id);
11041 mp->decap_next_index = ntohl (decap_next_index);
11042 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11043 mp->vni = ntohl (vni);
11044 mp->is_add = is_add;
11045 mp->is_ipv6 = ipv6_set;
11052 static void vl_api_vxlan_tunnel_details_t_handler
11053 (vl_api_vxlan_tunnel_details_t * mp)
11055 vat_main_t *vam = &vat_main;
11056 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
11057 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
11059 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
11060 ntohl (mp->sw_if_index),
11061 format_ip46_address, &src, IP46_TYPE_ANY,
11062 format_ip46_address, &dst, IP46_TYPE_ANY,
11063 ntohl (mp->encap_vrf_id),
11064 ntohl (mp->decap_next_index), ntohl (mp->vni),
11065 ntohl (mp->mcast_sw_if_index));
11068 static void vl_api_vxlan_tunnel_details_t_handler_json
11069 (vl_api_vxlan_tunnel_details_t * mp)
11071 vat_main_t *vam = &vat_main;
11072 vat_json_node_t *node = NULL;
11074 if (VAT_JSON_ARRAY != vam->json_tree.type)
11076 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11077 vat_json_init_array (&vam->json_tree);
11079 node = vat_json_array_add (&vam->json_tree);
11081 vat_json_init_object (node);
11082 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11085 struct in6_addr ip6;
11087 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
11088 vat_json_object_add_ip6 (node, "src_address", ip6);
11089 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
11090 vat_json_object_add_ip6 (node, "dst_address", ip6);
11094 struct in_addr ip4;
11096 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
11097 vat_json_object_add_ip4 (node, "src_address", ip4);
11098 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
11099 vat_json_object_add_ip4 (node, "dst_address", ip4);
11101 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11102 vat_json_object_add_uint (node, "decap_next_index",
11103 ntohl (mp->decap_next_index));
11104 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11105 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11106 vat_json_object_add_uint (node, "mcast_sw_if_index",
11107 ntohl (mp->mcast_sw_if_index));
11111 api_vxlan_tunnel_dump (vat_main_t * vam)
11113 unformat_input_t *i = vam->input;
11114 vl_api_vxlan_tunnel_dump_t *mp;
11115 vl_api_control_ping_t *mp_ping;
11117 u8 sw_if_index_set = 0;
11120 /* Parse args required to build the message */
11121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11123 if (unformat (i, "sw_if_index %d", &sw_if_index))
11124 sw_if_index_set = 1;
11129 if (sw_if_index_set == 0)
11134 if (!vam->json_output)
11136 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
11137 "sw_if_index", "src_address", "dst_address",
11138 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11141 /* Get list of vxlan-tunnel interfaces */
11142 M (VXLAN_TUNNEL_DUMP, mp);
11144 mp->sw_if_index = htonl (sw_if_index);
11148 /* Use a control ping for synchronization */
11149 M (CONTROL_PING, mp_ping);
11157 api_gre_add_del_tunnel (vat_main_t * vam)
11159 unformat_input_t *line_input = vam->input;
11160 vl_api_gre_add_del_tunnel_t *mp;
11161 ip4_address_t src4, dst4;
11162 ip6_address_t src6, dst6;
11169 u32 outer_fib_id = 0;
11172 memset (&src4, 0, sizeof src4);
11173 memset (&dst4, 0, sizeof dst4);
11174 memset (&src6, 0, sizeof src6);
11175 memset (&dst6, 0, sizeof dst6);
11177 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11179 if (unformat (line_input, "del"))
11181 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
11186 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
11191 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
11196 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
11201 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
11203 else if (unformat (line_input, "teb"))
11207 errmsg ("parse error '%U'", format_unformat_error, line_input);
11214 errmsg ("tunnel src address not specified");
11219 errmsg ("tunnel dst address not specified");
11222 if (ipv4_set && ipv6_set)
11224 errmsg ("both IPv4 and IPv6 addresses specified");
11229 M (GRE_ADD_DEL_TUNNEL, mp);
11233 clib_memcpy (&mp->src_address, &src4, 4);
11234 clib_memcpy (&mp->dst_address, &dst4, 4);
11238 clib_memcpy (&mp->src_address, &src6, 16);
11239 clib_memcpy (&mp->dst_address, &dst6, 16);
11241 mp->outer_fib_id = ntohl (outer_fib_id);
11242 mp->is_add = is_add;
11244 mp->is_ipv6 = ipv6_set;
11251 static void vl_api_gre_tunnel_details_t_handler
11252 (vl_api_gre_tunnel_details_t * mp)
11254 vat_main_t *vam = &vat_main;
11255 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
11256 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
11258 print (vam->ofp, "%11d%24U%24U%6d%14d",
11259 ntohl (mp->sw_if_index),
11260 format_ip46_address, &src, IP46_TYPE_ANY,
11261 format_ip46_address, &dst, IP46_TYPE_ANY,
11262 mp->teb, ntohl (mp->outer_fib_id));
11265 static void vl_api_gre_tunnel_details_t_handler_json
11266 (vl_api_gre_tunnel_details_t * mp)
11268 vat_main_t *vam = &vat_main;
11269 vat_json_node_t *node = NULL;
11270 struct in_addr ip4;
11271 struct in6_addr ip6;
11273 if (VAT_JSON_ARRAY != vam->json_tree.type)
11275 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11276 vat_json_init_array (&vam->json_tree);
11278 node = vat_json_array_add (&vam->json_tree);
11280 vat_json_init_object (node);
11281 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11284 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11285 vat_json_object_add_ip4 (node, "src_address", ip4);
11286 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11287 vat_json_object_add_ip4 (node, "dst_address", ip4);
11291 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
11292 vat_json_object_add_ip6 (node, "src_address", ip6);
11293 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
11294 vat_json_object_add_ip6 (node, "dst_address", ip6);
11296 vat_json_object_add_uint (node, "teb", mp->teb);
11297 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11298 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
11302 api_gre_tunnel_dump (vat_main_t * vam)
11304 unformat_input_t *i = vam->input;
11305 vl_api_gre_tunnel_dump_t *mp;
11306 vl_api_control_ping_t *mp_ping;
11308 u8 sw_if_index_set = 0;
11311 /* Parse args required to build the message */
11312 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11314 if (unformat (i, "sw_if_index %d", &sw_if_index))
11315 sw_if_index_set = 1;
11320 if (sw_if_index_set == 0)
11325 if (!vam->json_output)
11327 print (vam->ofp, "%11s%24s%24s%6s%14s",
11328 "sw_if_index", "src_address", "dst_address", "teb",
11332 /* Get list of gre-tunnel interfaces */
11333 M (GRE_TUNNEL_DUMP, mp);
11335 mp->sw_if_index = htonl (sw_if_index);
11339 /* Use a control ping for synchronization */
11340 M (CONTROL_PING, mp_ping);
11348 api_l2_fib_clear_table (vat_main_t * vam)
11350 // unformat_input_t * i = vam->input;
11351 vl_api_l2_fib_clear_table_t *mp;
11354 M (L2_FIB_CLEAR_TABLE, mp);
11362 api_l2_interface_efp_filter (vat_main_t * vam)
11364 unformat_input_t *i = vam->input;
11365 vl_api_l2_interface_efp_filter_t *mp;
11368 u8 sw_if_index_set = 0;
11371 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11373 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11374 sw_if_index_set = 1;
11375 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11376 sw_if_index_set = 1;
11377 else if (unformat (i, "enable"))
11379 else if (unformat (i, "disable"))
11383 clib_warning ("parse error '%U'", format_unformat_error, i);
11388 if (sw_if_index_set == 0)
11390 errmsg ("missing sw_if_index");
11394 M (L2_INTERFACE_EFP_FILTER, mp);
11396 mp->sw_if_index = ntohl (sw_if_index);
11397 mp->enable_disable = enable;
11404 #define foreach_vtr_op \
11405 _("disable", L2_VTR_DISABLED) \
11406 _("push-1", L2_VTR_PUSH_1) \
11407 _("push-2", L2_VTR_PUSH_2) \
11408 _("pop-1", L2_VTR_POP_1) \
11409 _("pop-2", L2_VTR_POP_2) \
11410 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11411 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11412 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11413 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11416 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11418 unformat_input_t *i = vam->input;
11419 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11421 u8 sw_if_index_set = 0;
11424 u32 push_dot1q = 1;
11429 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11431 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11432 sw_if_index_set = 1;
11433 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11434 sw_if_index_set = 1;
11435 else if (unformat (i, "vtr_op %d", &vtr_op))
11437 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11440 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11442 else if (unformat (i, "tag1 %d", &tag1))
11444 else if (unformat (i, "tag2 %d", &tag2))
11448 clib_warning ("parse error '%U'", format_unformat_error, i);
11453 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11455 errmsg ("missing vtr operation or sw_if_index");
11459 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11460 mp->sw_if_index = ntohl (sw_if_index);
11461 mp->vtr_op = ntohl (vtr_op);
11462 mp->push_dot1q = ntohl (push_dot1q);
11463 mp->tag1 = ntohl (tag1);
11464 mp->tag2 = ntohl (tag2);
11472 api_create_vhost_user_if (vat_main_t * vam)
11474 unformat_input_t *i = vam->input;
11475 vl_api_create_vhost_user_if_t *mp;
11478 u8 file_name_set = 0;
11479 u32 custom_dev_instance = ~0;
11481 u8 use_custom_mac = 0;
11484 u8 operation_mode = VHOST_USER_POLLING_MODE;
11486 /* Shut up coverity */
11487 memset (hwaddr, 0, sizeof (hwaddr));
11489 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11491 if (unformat (i, "socket %s", &file_name))
11495 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11497 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11498 use_custom_mac = 1;
11499 else if (unformat (i, "server"))
11501 else if (unformat (i, "tag %s", &tag))
11503 else if (unformat (i, "mode %U",
11504 api_unformat_vhost_user_operation_mode,
11511 if (file_name_set == 0)
11513 errmsg ("missing socket file name");
11517 if (vec_len (file_name) > 255)
11519 errmsg ("socket file name too long");
11522 vec_add1 (file_name, 0);
11524 M (CREATE_VHOST_USER_IF, mp);
11526 mp->operation_mode = operation_mode;
11527 mp->is_server = is_server;
11528 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11529 vec_free (file_name);
11530 if (custom_dev_instance != ~0)
11533 mp->custom_dev_instance = ntohl (custom_dev_instance);
11535 mp->use_custom_mac = use_custom_mac;
11536 clib_memcpy (mp->mac_address, hwaddr, 6);
11538 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11547 api_modify_vhost_user_if (vat_main_t * vam)
11549 unformat_input_t *i = vam->input;
11550 vl_api_modify_vhost_user_if_t *mp;
11553 u8 file_name_set = 0;
11554 u32 custom_dev_instance = ~0;
11555 u8 sw_if_index_set = 0;
11556 u32 sw_if_index = (u32) ~ 0;
11558 u8 operation_mode = VHOST_USER_POLLING_MODE;
11560 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11562 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11563 sw_if_index_set = 1;
11564 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11565 sw_if_index_set = 1;
11566 else if (unformat (i, "socket %s", &file_name))
11570 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11572 else if (unformat (i, "server"))
11574 else if (unformat (i, "mode %U",
11575 api_unformat_vhost_user_operation_mode,
11582 if (sw_if_index_set == 0)
11584 errmsg ("missing sw_if_index or interface name");
11588 if (file_name_set == 0)
11590 errmsg ("missing socket file name");
11594 if (vec_len (file_name) > 255)
11596 errmsg ("socket file name too long");
11599 vec_add1 (file_name, 0);
11601 M (MODIFY_VHOST_USER_IF, mp);
11603 mp->operation_mode = operation_mode;
11604 mp->sw_if_index = ntohl (sw_if_index);
11605 mp->is_server = is_server;
11606 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11607 vec_free (file_name);
11608 if (custom_dev_instance != ~0)
11611 mp->custom_dev_instance = ntohl (custom_dev_instance);
11620 api_delete_vhost_user_if (vat_main_t * vam)
11622 unformat_input_t *i = vam->input;
11623 vl_api_delete_vhost_user_if_t *mp;
11624 u32 sw_if_index = ~0;
11625 u8 sw_if_index_set = 0;
11628 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11630 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11631 sw_if_index_set = 1;
11632 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11633 sw_if_index_set = 1;
11638 if (sw_if_index_set == 0)
11640 errmsg ("missing sw_if_index or interface name");
11645 M (DELETE_VHOST_USER_IF, mp);
11647 mp->sw_if_index = ntohl (sw_if_index);
11654 static void vl_api_sw_interface_vhost_user_details_t_handler
11655 (vl_api_sw_interface_vhost_user_details_t * mp)
11657 vat_main_t *vam = &vat_main;
11659 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %U %s",
11660 (char *) mp->interface_name,
11661 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11662 clib_net_to_host_u64 (mp->features), mp->is_server,
11663 ntohl (mp->num_regions), api_format_vhost_user_operation_mode,
11664 mp->operation_mode, (char *) mp->sock_filename);
11665 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11668 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11669 (vl_api_sw_interface_vhost_user_details_t * mp)
11671 vat_main_t *vam = &vat_main;
11672 vat_json_node_t *node = NULL;
11674 if (VAT_JSON_ARRAY != vam->json_tree.type)
11676 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11677 vat_json_init_array (&vam->json_tree);
11679 node = vat_json_array_add (&vam->json_tree);
11681 vat_json_init_object (node);
11682 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11683 vat_json_object_add_string_copy (node, "interface_name",
11684 mp->interface_name);
11685 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11686 ntohl (mp->virtio_net_hdr_sz));
11687 vat_json_object_add_uint (node, "features",
11688 clib_net_to_host_u64 (mp->features));
11689 vat_json_object_add_uint (node, "is_server", mp->is_server);
11690 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11691 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11692 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11693 vat_json_object_add_uint (node, "mode", mp->operation_mode);
11697 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11699 vl_api_sw_interface_vhost_user_dump_t *mp;
11700 vl_api_control_ping_t *mp_ping;
11703 "Interface name idx hdr_sz features server regions mode"
11706 /* Get list of vhost-user interfaces */
11707 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11710 /* Use a control ping for synchronization */
11711 M (CONTROL_PING, mp_ping);
11719 api_show_version (vat_main_t * vam)
11721 vl_api_show_version_t *mp;
11724 M (SHOW_VERSION, mp);
11733 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11735 unformat_input_t *line_input = vam->input;
11736 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11737 ip4_address_t local4, remote4;
11738 ip6_address_t local6, remote6;
11740 u8 ipv4_set = 0, ipv6_set = 0;
11743 u32 encap_vrf_id = 0;
11744 u32 decap_vrf_id = 0;
11750 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11752 if (unformat (line_input, "del"))
11754 else if (unformat (line_input, "local %U",
11755 unformat_ip4_address, &local4))
11760 else if (unformat (line_input, "remote %U",
11761 unformat_ip4_address, &remote4))
11766 else if (unformat (line_input, "local %U",
11767 unformat_ip6_address, &local6))
11772 else if (unformat (line_input, "remote %U",
11773 unformat_ip6_address, &remote6))
11778 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11780 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11782 else if (unformat (line_input, "vni %d", &vni))
11784 else if (unformat (line_input, "next-ip4"))
11786 else if (unformat (line_input, "next-ip6"))
11788 else if (unformat (line_input, "next-ethernet"))
11790 else if (unformat (line_input, "next-nsh"))
11794 errmsg ("parse error '%U'", format_unformat_error, line_input);
11799 if (local_set == 0)
11801 errmsg ("tunnel local address not specified");
11804 if (remote_set == 0)
11806 errmsg ("tunnel remote address not specified");
11809 if (ipv4_set && ipv6_set)
11811 errmsg ("both IPv4 and IPv6 addresses specified");
11817 errmsg ("vni not specified");
11821 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11826 clib_memcpy (&mp->local, &local6, sizeof (local6));
11827 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11831 clib_memcpy (&mp->local, &local4, sizeof (local4));
11832 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11835 mp->encap_vrf_id = ntohl (encap_vrf_id);
11836 mp->decap_vrf_id = ntohl (decap_vrf_id);
11837 mp->protocol = protocol;
11838 mp->vni = ntohl (vni);
11839 mp->is_add = is_add;
11840 mp->is_ipv6 = ipv6_set;
11847 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11848 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11850 vat_main_t *vam = &vat_main;
11852 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11853 ntohl (mp->sw_if_index),
11854 format_ip46_address, &(mp->local[0]),
11855 format_ip46_address, &(mp->remote[0]),
11857 ntohl (mp->protocol),
11858 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11861 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11862 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11864 vat_main_t *vam = &vat_main;
11865 vat_json_node_t *node = NULL;
11866 struct in_addr ip4;
11867 struct in6_addr ip6;
11869 if (VAT_JSON_ARRAY != vam->json_tree.type)
11871 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11872 vat_json_init_array (&vam->json_tree);
11874 node = vat_json_array_add (&vam->json_tree);
11876 vat_json_init_object (node);
11877 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11880 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11881 vat_json_object_add_ip6 (node, "local", ip6);
11882 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11883 vat_json_object_add_ip6 (node, "remote", ip6);
11887 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11888 vat_json_object_add_ip4 (node, "local", ip4);
11889 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11890 vat_json_object_add_ip4 (node, "remote", ip4);
11892 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11893 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11894 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11895 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11896 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11900 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11902 unformat_input_t *i = vam->input;
11903 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11904 vl_api_control_ping_t *mp_ping;
11906 u8 sw_if_index_set = 0;
11909 /* Parse args required to build the message */
11910 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11912 if (unformat (i, "sw_if_index %d", &sw_if_index))
11913 sw_if_index_set = 1;
11918 if (sw_if_index_set == 0)
11923 if (!vam->json_output)
11925 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11926 "sw_if_index", "local", "remote", "vni",
11927 "protocol", "encap_vrf_id", "decap_vrf_id");
11930 /* Get list of vxlan-tunnel interfaces */
11931 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11933 mp->sw_if_index = htonl (sw_if_index);
11937 /* Use a control ping for synchronization */
11938 M (CONTROL_PING, mp_ping);
11946 format_l2_fib_mac_address (u8 * s, va_list * args)
11948 u8 *a = va_arg (*args, u8 *);
11950 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11951 a[2], a[3], a[4], a[5], a[6], a[7]);
11954 static void vl_api_l2_fib_table_details_t_handler
11955 (vl_api_l2_fib_table_details_t * mp)
11957 vat_main_t *vam = &vat_main;
11959 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11961 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11962 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11966 static void vl_api_l2_fib_table_details_t_handler_json
11967 (vl_api_l2_fib_table_details_t * mp)
11969 vat_main_t *vam = &vat_main;
11970 vat_json_node_t *node = NULL;
11972 if (VAT_JSON_ARRAY != vam->json_tree.type)
11974 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11975 vat_json_init_array (&vam->json_tree);
11977 node = vat_json_array_add (&vam->json_tree);
11979 vat_json_init_object (node);
11980 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11981 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11982 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11983 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11984 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11985 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11989 api_l2_fib_table_dump (vat_main_t * vam)
11991 unformat_input_t *i = vam->input;
11992 vl_api_l2_fib_table_dump_t *mp;
11993 vl_api_control_ping_t *mp_ping;
11998 /* Parse args required to build the message */
11999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12001 if (unformat (i, "bd_id %d", &bd_id))
12007 if (bd_id_set == 0)
12009 errmsg ("missing bridge domain");
12013 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
12015 /* Get list of l2 fib entries */
12016 M (L2_FIB_TABLE_DUMP, mp);
12018 mp->bd_id = ntohl (bd_id);
12021 /* Use a control ping for synchronization */
12022 M (CONTROL_PING, mp_ping);
12031 api_interface_name_renumber (vat_main_t * vam)
12033 unformat_input_t *line_input = vam->input;
12034 vl_api_interface_name_renumber_t *mp;
12035 u32 sw_if_index = ~0;
12036 u32 new_show_dev_instance = ~0;
12039 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12041 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
12044 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12046 else if (unformat (line_input, "new_show_dev_instance %d",
12047 &new_show_dev_instance))
12053 if (sw_if_index == ~0)
12055 errmsg ("missing interface name or sw_if_index");
12059 if (new_show_dev_instance == ~0)
12061 errmsg ("missing new_show_dev_instance");
12065 M (INTERFACE_NAME_RENUMBER, mp);
12067 mp->sw_if_index = ntohl (sw_if_index);
12068 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
12076 api_want_ip4_arp_events (vat_main_t * vam)
12078 unformat_input_t *line_input = vam->input;
12079 vl_api_want_ip4_arp_events_t *mp;
12080 ip4_address_t address;
12081 int address_set = 0;
12082 u32 enable_disable = 1;
12085 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12087 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
12089 else if (unformat (line_input, "del"))
12090 enable_disable = 0;
12095 if (address_set == 0)
12097 errmsg ("missing addresses");
12101 M (WANT_IP4_ARP_EVENTS, mp);
12102 mp->enable_disable = enable_disable;
12103 mp->pid = htonl (getpid ());
12104 mp->address = address.as_u32;
12112 api_want_ip6_nd_events (vat_main_t * vam)
12114 unformat_input_t *line_input = vam->input;
12115 vl_api_want_ip6_nd_events_t *mp;
12116 ip6_address_t address;
12117 int address_set = 0;
12118 u32 enable_disable = 1;
12121 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12123 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
12125 else if (unformat (line_input, "del"))
12126 enable_disable = 0;
12131 if (address_set == 0)
12133 errmsg ("missing addresses");
12137 M (WANT_IP6_ND_EVENTS, mp);
12138 mp->enable_disable = enable_disable;
12139 mp->pid = htonl (getpid ());
12140 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
12148 api_input_acl_set_interface (vat_main_t * vam)
12150 unformat_input_t *i = vam->input;
12151 vl_api_input_acl_set_interface_t *mp;
12153 int sw_if_index_set;
12154 u32 ip4_table_index = ~0;
12155 u32 ip6_table_index = ~0;
12156 u32 l2_table_index = ~0;
12160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12162 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12163 sw_if_index_set = 1;
12164 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12165 sw_if_index_set = 1;
12166 else if (unformat (i, "del"))
12168 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12170 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12172 else if (unformat (i, "l2-table %d", &l2_table_index))
12176 clib_warning ("parse error '%U'", format_unformat_error, i);
12181 if (sw_if_index_set == 0)
12183 errmsg ("missing interface name or sw_if_index");
12187 M (INPUT_ACL_SET_INTERFACE, mp);
12189 mp->sw_if_index = ntohl (sw_if_index);
12190 mp->ip4_table_index = ntohl (ip4_table_index);
12191 mp->ip6_table_index = ntohl (ip6_table_index);
12192 mp->l2_table_index = ntohl (l2_table_index);
12193 mp->is_add = is_add;
12201 api_ip_address_dump (vat_main_t * vam)
12203 unformat_input_t *i = vam->input;
12204 vl_api_ip_address_dump_t *mp;
12205 vl_api_control_ping_t *mp_ping;
12206 u32 sw_if_index = ~0;
12207 u8 sw_if_index_set = 0;
12212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12214 if (unformat (i, "sw_if_index %d", &sw_if_index))
12215 sw_if_index_set = 1;
12217 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12218 sw_if_index_set = 1;
12219 else if (unformat (i, "ipv4"))
12221 else if (unformat (i, "ipv6"))
12227 if (ipv4_set && ipv6_set)
12229 errmsg ("ipv4 and ipv6 flags cannot be both set");
12233 if ((!ipv4_set) && (!ipv6_set))
12235 errmsg ("no ipv4 nor ipv6 flag set");
12239 if (sw_if_index_set == 0)
12241 errmsg ("missing interface name or sw_if_index");
12245 vam->current_sw_if_index = sw_if_index;
12246 vam->is_ipv6 = ipv6_set;
12248 M (IP_ADDRESS_DUMP, mp);
12249 mp->sw_if_index = ntohl (sw_if_index);
12250 mp->is_ipv6 = ipv6_set;
12253 /* Use a control ping for synchronization */
12254 M (CONTROL_PING, mp_ping);
12262 api_ip_dump (vat_main_t * vam)
12264 vl_api_ip_dump_t *mp;
12265 vl_api_control_ping_t *mp_ping;
12266 unformat_input_t *in = vam->input;
12273 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
12275 if (unformat (in, "ipv4"))
12277 else if (unformat (in, "ipv6"))
12283 if (ipv4_set && ipv6_set)
12285 errmsg ("ipv4 and ipv6 flags cannot be both set");
12289 if ((!ipv4_set) && (!ipv6_set))
12291 errmsg ("no ipv4 nor ipv6 flag set");
12295 is_ipv6 = ipv6_set;
12296 vam->is_ipv6 = is_ipv6;
12298 /* free old data */
12299 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12301 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12303 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12306 mp->is_ipv6 = ipv6_set;
12309 /* Use a control ping for synchronization */
12310 M (CONTROL_PING, mp_ping);
12318 api_ipsec_spd_add_del (vat_main_t * vam)
12320 unformat_input_t *i = vam->input;
12321 vl_api_ipsec_spd_add_del_t *mp;
12326 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12328 if (unformat (i, "spd_id %d", &spd_id))
12330 else if (unformat (i, "del"))
12334 clib_warning ("parse error '%U'", format_unformat_error, i);
12340 errmsg ("spd_id must be set");
12344 M (IPSEC_SPD_ADD_DEL, mp);
12346 mp->spd_id = ntohl (spd_id);
12347 mp->is_add = is_add;
12355 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12357 unformat_input_t *i = vam->input;
12358 vl_api_ipsec_interface_add_del_spd_t *mp;
12360 u8 sw_if_index_set = 0;
12361 u32 spd_id = (u32) ~ 0;
12365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12367 if (unformat (i, "del"))
12369 else if (unformat (i, "spd_id %d", &spd_id))
12372 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12373 sw_if_index_set = 1;
12374 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12375 sw_if_index_set = 1;
12378 clib_warning ("parse error '%U'", format_unformat_error, i);
12384 if (spd_id == (u32) ~ 0)
12386 errmsg ("spd_id must be set");
12390 if (sw_if_index_set == 0)
12392 errmsg ("missing interface name or sw_if_index");
12396 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12398 mp->spd_id = ntohl (spd_id);
12399 mp->sw_if_index = ntohl (sw_if_index);
12400 mp->is_add = is_add;
12408 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12410 unformat_input_t *i = vam->input;
12411 vl_api_ipsec_spd_add_del_entry_t *mp;
12412 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12413 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12415 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12416 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12417 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12418 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12421 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12422 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12423 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12424 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12425 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12426 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12428 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12430 if (unformat (i, "del"))
12432 if (unformat (i, "outbound"))
12434 if (unformat (i, "inbound"))
12436 else if (unformat (i, "spd_id %d", &spd_id))
12438 else if (unformat (i, "sa_id %d", &sa_id))
12440 else if (unformat (i, "priority %d", &priority))
12442 else if (unformat (i, "protocol %d", &protocol))
12444 else if (unformat (i, "lport_start %d", &lport_start))
12446 else if (unformat (i, "lport_stop %d", &lport_stop))
12448 else if (unformat (i, "rport_start %d", &rport_start))
12450 else if (unformat (i, "rport_stop %d", &rport_stop))
12454 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12460 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12467 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12473 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12480 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12486 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12493 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12499 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12505 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12507 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12509 clib_warning ("unsupported action: 'resolve'");
12515 clib_warning ("parse error '%U'", format_unformat_error, i);
12521 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12523 mp->spd_id = ntohl (spd_id);
12524 mp->priority = ntohl (priority);
12525 mp->is_outbound = is_outbound;
12527 mp->is_ipv6 = is_ipv6;
12528 if (is_ipv6 || is_ip_any)
12530 clib_memcpy (mp->remote_address_start, &raddr6_start,
12531 sizeof (ip6_address_t));
12532 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12533 sizeof (ip6_address_t));
12534 clib_memcpy (mp->local_address_start, &laddr6_start,
12535 sizeof (ip6_address_t));
12536 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12537 sizeof (ip6_address_t));
12541 clib_memcpy (mp->remote_address_start, &raddr4_start,
12542 sizeof (ip4_address_t));
12543 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12544 sizeof (ip4_address_t));
12545 clib_memcpy (mp->local_address_start, &laddr4_start,
12546 sizeof (ip4_address_t));
12547 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12548 sizeof (ip4_address_t));
12550 mp->protocol = (u8) protocol;
12551 mp->local_port_start = ntohs ((u16) lport_start);
12552 mp->local_port_stop = ntohs ((u16) lport_stop);
12553 mp->remote_port_start = ntohs ((u16) rport_start);
12554 mp->remote_port_stop = ntohs ((u16) rport_stop);
12555 mp->policy = (u8) policy;
12556 mp->sa_id = ntohl (sa_id);
12557 mp->is_add = is_add;
12558 mp->is_ip_any = is_ip_any;
12565 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12567 unformat_input_t *i = vam->input;
12568 vl_api_ipsec_sad_add_del_entry_t *mp;
12569 u32 sad_id = 0, spi = 0;
12570 u8 *ck = 0, *ik = 0;
12573 u8 protocol = IPSEC_PROTOCOL_AH;
12574 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12575 u32 crypto_alg = 0, integ_alg = 0;
12576 ip4_address_t tun_src4;
12577 ip4_address_t tun_dst4;
12578 ip6_address_t tun_src6;
12579 ip6_address_t tun_dst6;
12582 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12584 if (unformat (i, "del"))
12586 else if (unformat (i, "sad_id %d", &sad_id))
12588 else if (unformat (i, "spi %d", &spi))
12590 else if (unformat (i, "esp"))
12591 protocol = IPSEC_PROTOCOL_ESP;
12592 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12595 is_tunnel_ipv6 = 0;
12597 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12600 is_tunnel_ipv6 = 0;
12602 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12605 is_tunnel_ipv6 = 1;
12607 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12610 is_tunnel_ipv6 = 1;
12614 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12616 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12617 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12619 clib_warning ("unsupported crypto-alg: '%U'",
12620 format_ipsec_crypto_alg, crypto_alg);
12624 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12628 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12630 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12631 integ_alg >= IPSEC_INTEG_N_ALG)
12633 clib_warning ("unsupported integ-alg: '%U'",
12634 format_ipsec_integ_alg, integ_alg);
12638 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12642 clib_warning ("parse error '%U'", format_unformat_error, i);
12648 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12650 mp->sad_id = ntohl (sad_id);
12651 mp->is_add = is_add;
12652 mp->protocol = protocol;
12653 mp->spi = ntohl (spi);
12654 mp->is_tunnel = is_tunnel;
12655 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12656 mp->crypto_algorithm = crypto_alg;
12657 mp->integrity_algorithm = integ_alg;
12658 mp->crypto_key_length = vec_len (ck);
12659 mp->integrity_key_length = vec_len (ik);
12661 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12662 mp->crypto_key_length = sizeof (mp->crypto_key);
12664 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12665 mp->integrity_key_length = sizeof (mp->integrity_key);
12668 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12670 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12674 if (is_tunnel_ipv6)
12676 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12677 sizeof (ip6_address_t));
12678 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12679 sizeof (ip6_address_t));
12683 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12684 sizeof (ip4_address_t));
12685 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12686 sizeof (ip4_address_t));
12696 api_ipsec_sa_set_key (vat_main_t * vam)
12698 unformat_input_t *i = vam->input;
12699 vl_api_ipsec_sa_set_key_t *mp;
12701 u8 *ck = 0, *ik = 0;
12704 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12706 if (unformat (i, "sa_id %d", &sa_id))
12708 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12710 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12714 clib_warning ("parse error '%U'", format_unformat_error, i);
12719 M (IPSEC_SA_SET_KEY, mp);
12721 mp->sa_id = ntohl (sa_id);
12722 mp->crypto_key_length = vec_len (ck);
12723 mp->integrity_key_length = vec_len (ik);
12725 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12726 mp->crypto_key_length = sizeof (mp->crypto_key);
12728 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12729 mp->integrity_key_length = sizeof (mp->integrity_key);
12732 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12734 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12742 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
12744 unformat_input_t *i = vam->input;
12745 vl_api_ipsec_tunnel_if_add_del_t *mp;
12746 u32 local_spi = 0, remote_spi = 0;
12747 u32 crypto_alg = 0, integ_alg = 0;
12748 u8 *lck = NULL, *rck = NULL;
12749 u8 *lik = NULL, *rik = NULL;
12750 ip4_address_t local_ip = { {0} };
12751 ip4_address_t remote_ip = { {0} };
12754 u8 anti_replay = 0;
12757 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12759 if (unformat (i, "del"))
12761 else if (unformat (i, "esn"))
12763 else if (unformat (i, "anti_replay"))
12765 else if (unformat (i, "local_spi %d", &local_spi))
12767 else if (unformat (i, "remote_spi %d", &remote_spi))
12769 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
12771 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
12773 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
12776 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
12778 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
12780 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
12784 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12786 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12787 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12789 errmsg ("unsupported crypto-alg: '%U'\n",
12790 format_ipsec_crypto_alg, crypto_alg);
12796 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12798 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12799 integ_alg >= IPSEC_INTEG_N_ALG)
12801 errmsg ("unsupported integ-alg: '%U'\n",
12802 format_ipsec_integ_alg, integ_alg);
12808 errmsg ("parse error '%U'\n", format_unformat_error, i);
12813 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
12815 mp->is_add = is_add;
12817 mp->anti_replay = anti_replay;
12819 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
12820 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
12822 mp->local_spi = htonl (local_spi);
12823 mp->remote_spi = htonl (remote_spi);
12824 mp->crypto_alg = (u8) crypto_alg;
12826 mp->local_crypto_key_len = 0;
12829 mp->local_crypto_key_len = vec_len (lck);
12830 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
12831 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
12832 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
12835 mp->remote_crypto_key_len = 0;
12838 mp->remote_crypto_key_len = vec_len (rck);
12839 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
12840 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
12841 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
12844 mp->integ_alg = (u8) integ_alg;
12846 mp->local_integ_key_len = 0;
12849 mp->local_integ_key_len = vec_len (lik);
12850 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
12851 mp->local_integ_key_len = sizeof (mp->local_integ_key);
12852 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
12855 mp->remote_integ_key_len = 0;
12858 mp->remote_integ_key_len = vec_len (rik);
12859 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
12860 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
12861 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
12870 api_ikev2_profile_add_del (vat_main_t * vam)
12872 unformat_input_t *i = vam->input;
12873 vl_api_ikev2_profile_add_del_t *mp;
12878 const char *valid_chars = "a-zA-Z0-9_";
12880 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12882 if (unformat (i, "del"))
12884 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12885 vec_add1 (name, 0);
12888 errmsg ("parse error '%U'", format_unformat_error, i);
12893 if (!vec_len (name))
12895 errmsg ("profile name must be specified");
12899 if (vec_len (name) > 64)
12901 errmsg ("profile name too long");
12905 M (IKEV2_PROFILE_ADD_DEL, mp);
12907 clib_memcpy (mp->name, name, vec_len (name));
12908 mp->is_add = is_add;
12917 api_ikev2_profile_set_auth (vat_main_t * vam)
12919 unformat_input_t *i = vam->input;
12920 vl_api_ikev2_profile_set_auth_t *mp;
12923 u32 auth_method = 0;
12927 const char *valid_chars = "a-zA-Z0-9_";
12929 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12931 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12932 vec_add1 (name, 0);
12933 else if (unformat (i, "auth_method %U",
12934 unformat_ikev2_auth_method, &auth_method))
12936 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12938 else if (unformat (i, "auth_data %v", &data))
12942 errmsg ("parse error '%U'", format_unformat_error, i);
12947 if (!vec_len (name))
12949 errmsg ("profile name must be specified");
12953 if (vec_len (name) > 64)
12955 errmsg ("profile name too long");
12959 if (!vec_len (data))
12961 errmsg ("auth_data must be specified");
12967 errmsg ("auth_method must be specified");
12971 M (IKEV2_PROFILE_SET_AUTH, mp);
12973 mp->is_hex = is_hex;
12974 mp->auth_method = (u8) auth_method;
12975 mp->data_len = vec_len (data);
12976 clib_memcpy (mp->name, name, vec_len (name));
12977 clib_memcpy (mp->data, data, vec_len (data));
12987 api_ikev2_profile_set_id (vat_main_t * vam)
12989 unformat_input_t *i = vam->input;
12990 vl_api_ikev2_profile_set_id_t *mp;
12998 const char *valid_chars = "a-zA-Z0-9_";
13000 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13002 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13003 vec_add1 (name, 0);
13004 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
13006 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
13008 data = vec_new (u8, 4);
13009 clib_memcpy (data, ip4.as_u8, 4);
13011 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
13013 else if (unformat (i, "id_data %v", &data))
13015 else if (unformat (i, "local"))
13017 else if (unformat (i, "remote"))
13021 errmsg ("parse error '%U'", format_unformat_error, i);
13026 if (!vec_len (name))
13028 errmsg ("profile name must be specified");
13032 if (vec_len (name) > 64)
13034 errmsg ("profile name too long");
13038 if (!vec_len (data))
13040 errmsg ("id_data must be specified");
13046 errmsg ("id_type must be specified");
13050 M (IKEV2_PROFILE_SET_ID, mp);
13052 mp->is_local = is_local;
13053 mp->id_type = (u8) id_type;
13054 mp->data_len = vec_len (data);
13055 clib_memcpy (mp->name, name, vec_len (name));
13056 clib_memcpy (mp->data, data, vec_len (data));
13066 api_ikev2_profile_set_ts (vat_main_t * vam)
13068 unformat_input_t *i = vam->input;
13069 vl_api_ikev2_profile_set_ts_t *mp;
13072 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
13073 ip4_address_t start_addr, end_addr;
13075 const char *valid_chars = "a-zA-Z0-9_";
13078 start_addr.as_u32 = 0;
13079 end_addr.as_u32 = (u32) ~ 0;
13081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13083 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13084 vec_add1 (name, 0);
13085 else if (unformat (i, "protocol %d", &proto))
13087 else if (unformat (i, "start_port %d", &start_port))
13089 else if (unformat (i, "end_port %d", &end_port))
13092 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
13094 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
13096 else if (unformat (i, "local"))
13098 else if (unformat (i, "remote"))
13102 errmsg ("parse error '%U'", format_unformat_error, i);
13107 if (!vec_len (name))
13109 errmsg ("profile name must be specified");
13113 if (vec_len (name) > 64)
13115 errmsg ("profile name too long");
13119 M (IKEV2_PROFILE_SET_TS, mp);
13121 mp->is_local = is_local;
13122 mp->proto = (u8) proto;
13123 mp->start_port = (u16) start_port;
13124 mp->end_port = (u16) end_port;
13125 mp->start_addr = start_addr.as_u32;
13126 mp->end_addr = end_addr.as_u32;
13127 clib_memcpy (mp->name, name, vec_len (name));
13136 api_ikev2_set_local_key (vat_main_t * vam)
13138 unformat_input_t *i = vam->input;
13139 vl_api_ikev2_set_local_key_t *mp;
13143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13145 if (unformat (i, "file %v", &file))
13146 vec_add1 (file, 0);
13149 errmsg ("parse error '%U'", format_unformat_error, i);
13154 if (!vec_len (file))
13156 errmsg ("RSA key file must be specified");
13160 if (vec_len (file) > 256)
13162 errmsg ("file name too long");
13166 M (IKEV2_SET_LOCAL_KEY, mp);
13168 clib_memcpy (mp->key_file, file, vec_len (file));
13177 api_ikev2_set_responder (vat_main_t * vam)
13179 unformat_input_t *i = vam->input;
13180 vl_api_ikev2_set_responder_t *mp;
13183 u32 sw_if_index = ~0;
13184 ip4_address_t address;
13186 const char *valid_chars = "a-zA-Z0-9_";
13188 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13191 (i, "%U interface %d address %U", unformat_token, valid_chars,
13192 &name, &sw_if_index, unformat_ip4_address, &address))
13193 vec_add1 (name, 0);
13196 errmsg ("parse error '%U'", format_unformat_error, i);
13201 if (!vec_len (name))
13203 errmsg ("profile name must be specified");
13207 if (vec_len (name) > 64)
13209 errmsg ("profile name too long");
13213 M (IKEV2_SET_RESPONDER, mp);
13215 clib_memcpy (mp->name, name, vec_len (name));
13218 mp->sw_if_index = sw_if_index;
13219 clib_memcpy (mp->address, &address, sizeof (address));
13227 api_ikev2_set_ike_transforms (vat_main_t * vam)
13229 unformat_input_t *i = vam->input;
13230 vl_api_ikev2_set_ike_transforms_t *mp;
13233 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13235 const char *valid_chars = "a-zA-Z0-9_";
13237 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13239 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13240 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13241 vec_add1 (name, 0);
13244 errmsg ("parse error '%U'", format_unformat_error, i);
13249 if (!vec_len (name))
13251 errmsg ("profile name must be specified");
13255 if (vec_len (name) > 64)
13257 errmsg ("profile name too long");
13261 M (IKEV2_SET_IKE_TRANSFORMS, mp);
13263 clib_memcpy (mp->name, name, vec_len (name));
13265 mp->crypto_alg = crypto_alg;
13266 mp->crypto_key_size = crypto_key_size;
13267 mp->integ_alg = integ_alg;
13268 mp->dh_group = dh_group;
13277 api_ikev2_set_esp_transforms (vat_main_t * vam)
13279 unformat_input_t *i = vam->input;
13280 vl_api_ikev2_set_esp_transforms_t *mp;
13283 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13285 const char *valid_chars = "a-zA-Z0-9_";
13287 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13289 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13290 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
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_ESP_TRANSFORMS, mp);
13313 clib_memcpy (mp->name, name, vec_len (name));
13315 mp->crypto_alg = crypto_alg;
13316 mp->crypto_key_size = crypto_key_size;
13317 mp->integ_alg = integ_alg;
13318 mp->dh_group = dh_group;
13326 api_ikev2_set_sa_lifetime (vat_main_t * vam)
13328 unformat_input_t *i = vam->input;
13329 vl_api_ikev2_set_sa_lifetime_t *mp;
13332 u64 lifetime, lifetime_maxdata;
13333 u32 lifetime_jitter, handover;
13335 const char *valid_chars = "a-zA-Z0-9_";
13337 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13339 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
13340 &lifetime, &lifetime_jitter, &handover,
13341 &lifetime_maxdata))
13342 vec_add1 (name, 0);
13345 errmsg ("parse error '%U'", format_unformat_error, i);
13350 if (!vec_len (name))
13352 errmsg ("profile name must be specified");
13356 if (vec_len (name) > 64)
13358 errmsg ("profile name too long");
13362 M (IKEV2_SET_SA_LIFETIME, mp);
13364 clib_memcpy (mp->name, name, vec_len (name));
13366 mp->lifetime = lifetime;
13367 mp->lifetime_jitter = lifetime_jitter;
13368 mp->handover = handover;
13369 mp->lifetime_maxdata = lifetime_maxdata;
13377 api_ikev2_initiate_sa_init (vat_main_t * vam)
13379 unformat_input_t *i = vam->input;
13380 vl_api_ikev2_initiate_sa_init_t *mp;
13384 const char *valid_chars = "a-zA-Z0-9_";
13386 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13388 if (unformat (i, "%U", unformat_token, valid_chars, &name))
13389 vec_add1 (name, 0);
13392 errmsg ("parse error '%U'", format_unformat_error, i);
13397 if (!vec_len (name))
13399 errmsg ("profile name must be specified");
13403 if (vec_len (name) > 64)
13405 errmsg ("profile name too long");
13409 M (IKEV2_INITIATE_SA_INIT, mp);
13411 clib_memcpy (mp->name, name, vec_len (name));
13420 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
13422 unformat_input_t *i = vam->input;
13423 vl_api_ikev2_initiate_del_ike_sa_t *mp;
13428 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13430 if (unformat (i, "%lx", &ispi))
13434 errmsg ("parse error '%U'", format_unformat_error, i);
13439 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
13449 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13451 unformat_input_t *i = vam->input;
13452 vl_api_ikev2_initiate_del_child_sa_t *mp;
13457 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13459 if (unformat (i, "%x", &ispi))
13463 errmsg ("parse error '%U'", format_unformat_error, i);
13468 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13478 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13480 unformat_input_t *i = vam->input;
13481 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13486 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13488 if (unformat (i, "%x", &ispi))
13492 errmsg ("parse error '%U'", format_unformat_error, i);
13497 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
13510 api_map_add_domain (vat_main_t * vam)
13512 unformat_input_t *i = vam->input;
13513 vl_api_map_add_domain_t *mp;
13515 ip4_address_t ip4_prefix;
13516 ip6_address_t ip6_prefix;
13517 ip6_address_t ip6_src;
13518 u32 num_m_args = 0;
13519 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
13520 0, psid_length = 0;
13521 u8 is_translation = 0;
13523 u32 ip6_src_len = 128;
13526 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13528 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
13529 &ip4_prefix, &ip4_prefix_len))
13531 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
13532 &ip6_prefix, &ip6_prefix_len))
13536 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
13539 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
13541 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
13543 else if (unformat (i, "psid-offset %d", &psid_offset))
13545 else if (unformat (i, "psid-len %d", &psid_length))
13547 else if (unformat (i, "mtu %d", &mtu))
13549 else if (unformat (i, "map-t"))
13550 is_translation = 1;
13553 clib_warning ("parse error '%U'", format_unformat_error, i);
13558 if (num_m_args < 3)
13560 errmsg ("mandatory argument(s) missing");
13564 /* Construct the API message */
13565 M (MAP_ADD_DOMAIN, mp);
13567 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
13568 mp->ip4_prefix_len = ip4_prefix_len;
13570 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
13571 mp->ip6_prefix_len = ip6_prefix_len;
13573 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
13574 mp->ip6_src_prefix_len = ip6_src_len;
13576 mp->ea_bits_len = ea_bits_len;
13577 mp->psid_offset = psid_offset;
13578 mp->psid_length = psid_length;
13579 mp->is_translation = is_translation;
13580 mp->mtu = htons (mtu);
13585 /* Wait for a reply, return good/bad news */
13591 api_map_del_domain (vat_main_t * vam)
13593 unformat_input_t *i = vam->input;
13594 vl_api_map_del_domain_t *mp;
13596 u32 num_m_args = 0;
13600 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13602 if (unformat (i, "index %d", &index))
13606 clib_warning ("parse error '%U'", format_unformat_error, i);
13611 if (num_m_args != 1)
13613 errmsg ("mandatory argument(s) missing");
13617 /* Construct the API message */
13618 M (MAP_DEL_DOMAIN, mp);
13620 mp->index = ntohl (index);
13625 /* Wait for a reply, return good/bad news */
13631 api_map_add_del_rule (vat_main_t * vam)
13633 unformat_input_t *i = vam->input;
13634 vl_api_map_add_del_rule_t *mp;
13636 ip6_address_t ip6_dst;
13637 u32 num_m_args = 0, index, psid = 0;
13640 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13642 if (unformat (i, "index %d", &index))
13644 else if (unformat (i, "psid %d", &psid))
13646 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13648 else if (unformat (i, "del"))
13654 clib_warning ("parse error '%U'", format_unformat_error, i);
13659 /* Construct the API message */
13660 M (MAP_ADD_DEL_RULE, mp);
13662 mp->index = ntohl (index);
13663 mp->is_add = is_add;
13664 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13665 mp->psid = ntohs (psid);
13670 /* Wait for a reply, return good/bad news */
13676 api_map_domain_dump (vat_main_t * vam)
13678 vl_api_map_domain_dump_t *mp;
13679 vl_api_control_ping_t *mp_ping;
13682 /* Construct the API message */
13683 M (MAP_DOMAIN_DUMP, mp);
13688 /* Use a control ping for synchronization */
13689 M (CONTROL_PING, mp_ping);
13697 api_map_rule_dump (vat_main_t * vam)
13699 unformat_input_t *i = vam->input;
13700 vl_api_map_rule_dump_t *mp;
13701 vl_api_control_ping_t *mp_ping;
13702 u32 domain_index = ~0;
13705 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13707 if (unformat (i, "index %u", &domain_index))
13713 if (domain_index == ~0)
13715 clib_warning ("parse error: domain index expected");
13719 /* Construct the API message */
13720 M (MAP_RULE_DUMP, mp);
13722 mp->domain_index = htonl (domain_index);
13727 /* Use a control ping for synchronization */
13728 M (CONTROL_PING, mp_ping);
13735 static void vl_api_map_add_domain_reply_t_handler
13736 (vl_api_map_add_domain_reply_t * mp)
13738 vat_main_t *vam = &vat_main;
13739 i32 retval = ntohl (mp->retval);
13741 if (vam->async_mode)
13743 vam->async_errors += (retval < 0);
13747 vam->retval = retval;
13748 vam->result_ready = 1;
13752 static void vl_api_map_add_domain_reply_t_handler_json
13753 (vl_api_map_add_domain_reply_t * mp)
13755 vat_main_t *vam = &vat_main;
13756 vat_json_node_t node;
13758 vat_json_init_object (&node);
13759 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13760 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13762 vat_json_print (vam->ofp, &node);
13763 vat_json_free (&node);
13765 vam->retval = ntohl (mp->retval);
13766 vam->result_ready = 1;
13770 api_get_first_msg_id (vat_main_t * vam)
13772 vl_api_get_first_msg_id_t *mp;
13773 unformat_input_t *i = vam->input;
13778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13780 if (unformat (i, "client %s", &name))
13788 errmsg ("missing client name");
13791 vec_add1 (name, 0);
13793 if (vec_len (name) > 63)
13795 errmsg ("client name too long");
13799 M (GET_FIRST_MSG_ID, mp);
13800 clib_memcpy (mp->name, name, vec_len (name));
13807 api_cop_interface_enable_disable (vat_main_t * vam)
13809 unformat_input_t *line_input = vam->input;
13810 vl_api_cop_interface_enable_disable_t *mp;
13811 u32 sw_if_index = ~0;
13812 u8 enable_disable = 1;
13815 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13817 if (unformat (line_input, "disable"))
13818 enable_disable = 0;
13819 if (unformat (line_input, "enable"))
13820 enable_disable = 1;
13821 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13822 vam, &sw_if_index))
13824 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13830 if (sw_if_index == ~0)
13832 errmsg ("missing interface name or sw_if_index");
13836 /* Construct the API message */
13837 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13838 mp->sw_if_index = ntohl (sw_if_index);
13839 mp->enable_disable = enable_disable;
13843 /* Wait for the reply */
13849 api_cop_whitelist_enable_disable (vat_main_t * vam)
13851 unformat_input_t *line_input = vam->input;
13852 vl_api_cop_whitelist_enable_disable_t *mp;
13853 u32 sw_if_index = ~0;
13854 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13858 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13860 if (unformat (line_input, "ip4"))
13862 else if (unformat (line_input, "ip6"))
13864 else if (unformat (line_input, "default"))
13866 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13867 vam, &sw_if_index))
13869 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13871 else if (unformat (line_input, "fib-id %d", &fib_id))
13877 if (sw_if_index == ~0)
13879 errmsg ("missing interface name or sw_if_index");
13883 /* Construct the API message */
13884 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13885 mp->sw_if_index = ntohl (sw_if_index);
13886 mp->fib_id = ntohl (fib_id);
13889 mp->default_cop = default_cop;
13893 /* Wait for the reply */
13899 api_get_node_graph (vat_main_t * vam)
13901 vl_api_get_node_graph_t *mp;
13904 M (GET_NODE_GRAPH, mp);
13908 /* Wait for the reply */
13914 /** Used for parsing LISP eids */
13915 typedef CLIB_PACKED(struct{
13916 u8 addr[16]; /**< eid address */
13917 u32 len; /**< prefix length if IP */
13918 u8 type; /**< type of eid */
13923 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13925 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13927 memset (a, 0, sizeof (a[0]));
13929 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13931 a->type = 0; /* ipv4 type */
13933 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13935 a->type = 1; /* ipv6 type */
13937 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13939 a->type = 2; /* mac type */
13946 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13955 lisp_eid_size_vat (u8 type)
13970 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13972 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13976 api_one_add_del_locator_set (vat_main_t * vam)
13978 unformat_input_t *input = vam->input;
13979 vl_api_one_add_del_locator_set_t *mp;
13981 u8 *locator_set_name = NULL;
13982 u8 locator_set_name_set = 0;
13983 vl_api_local_locator_t locator, *locators = 0;
13984 u32 sw_if_index, priority, weight;
13988 /* Parse args required to build the message */
13989 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13991 if (unformat (input, "del"))
13995 else if (unformat (input, "locator-set %s", &locator_set_name))
13997 locator_set_name_set = 1;
13999 else if (unformat (input, "sw_if_index %u p %u w %u",
14000 &sw_if_index, &priority, &weight))
14002 locator.sw_if_index = htonl (sw_if_index);
14003 locator.priority = priority;
14004 locator.weight = weight;
14005 vec_add1 (locators, locator);
14009 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14010 &sw_if_index, &priority, &weight))
14012 locator.sw_if_index = htonl (sw_if_index);
14013 locator.priority = priority;
14014 locator.weight = weight;
14015 vec_add1 (locators, locator);
14021 if (locator_set_name_set == 0)
14023 errmsg ("missing locator-set name");
14024 vec_free (locators);
14028 if (vec_len (locator_set_name) > 64)
14030 errmsg ("locator-set name too long");
14031 vec_free (locator_set_name);
14032 vec_free (locators);
14035 vec_add1 (locator_set_name, 0);
14037 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14039 /* Construct the API message */
14040 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14042 mp->is_add = is_add;
14043 clib_memcpy (mp->locator_set_name, locator_set_name,
14044 vec_len (locator_set_name));
14045 vec_free (locator_set_name);
14047 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14049 clib_memcpy (mp->locators, locators, data_len);
14050 vec_free (locators);
14055 /* Wait for a reply... */
14060 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14063 api_one_add_del_locator (vat_main_t * vam)
14065 unformat_input_t *input = vam->input;
14066 vl_api_one_add_del_locator_t *mp;
14067 u32 tmp_if_index = ~0;
14068 u32 sw_if_index = ~0;
14069 u8 sw_if_index_set = 0;
14070 u8 sw_if_index_if_name_set = 0;
14072 u8 priority_set = 0;
14076 u8 *locator_set_name = NULL;
14077 u8 locator_set_name_set = 0;
14080 /* Parse args required to build the message */
14081 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14083 if (unformat (input, "del"))
14087 else if (unformat (input, "locator-set %s", &locator_set_name))
14089 locator_set_name_set = 1;
14091 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14094 sw_if_index_if_name_set = 1;
14095 sw_if_index = tmp_if_index;
14097 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14099 sw_if_index_set = 1;
14100 sw_if_index = tmp_if_index;
14102 else if (unformat (input, "p %d", &priority))
14106 else if (unformat (input, "w %d", &weight))
14114 if (locator_set_name_set == 0)
14116 errmsg ("missing locator-set name");
14120 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14122 errmsg ("missing sw_if_index");
14123 vec_free (locator_set_name);
14127 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14129 errmsg ("cannot use both params interface name and sw_if_index");
14130 vec_free (locator_set_name);
14134 if (priority_set == 0)
14136 errmsg ("missing locator-set priority");
14137 vec_free (locator_set_name);
14141 if (weight_set == 0)
14143 errmsg ("missing locator-set weight");
14144 vec_free (locator_set_name);
14148 if (vec_len (locator_set_name) > 64)
14150 errmsg ("locator-set name too long");
14151 vec_free (locator_set_name);
14154 vec_add1 (locator_set_name, 0);
14156 /* Construct the API message */
14157 M (ONE_ADD_DEL_LOCATOR, mp);
14159 mp->is_add = is_add;
14160 mp->sw_if_index = ntohl (sw_if_index);
14161 mp->priority = priority;
14162 mp->weight = weight;
14163 clib_memcpy (mp->locator_set_name, locator_set_name,
14164 vec_len (locator_set_name));
14165 vec_free (locator_set_name);
14170 /* Wait for a reply... */
14175 #define api_lisp_add_del_locator api_one_add_del_locator
14178 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14180 u32 *key_id = va_arg (*args, u32 *);
14183 if (unformat (input, "%s", &s))
14185 if (!strcmp ((char *) s, "sha1"))
14186 key_id[0] = HMAC_SHA_1_96;
14187 else if (!strcmp ((char *) s, "sha256"))
14188 key_id[0] = HMAC_SHA_256_128;
14191 clib_warning ("invalid key_id: '%s'", s);
14192 key_id[0] = HMAC_NO_KEY;
14203 api_one_add_del_local_eid (vat_main_t * vam)
14205 unformat_input_t *input = vam->input;
14206 vl_api_one_add_del_local_eid_t *mp;
14209 lisp_eid_vat_t _eid, *eid = &_eid;
14210 u8 *locator_set_name = 0;
14211 u8 locator_set_name_set = 0;
14217 /* Parse args required to build the message */
14218 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14220 if (unformat (input, "del"))
14224 else if (unformat (input, "vni %d", &vni))
14228 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14232 else if (unformat (input, "locator-set %s", &locator_set_name))
14234 locator_set_name_set = 1;
14236 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14238 else if (unformat (input, "secret-key %_%v%_", &key))
14244 if (locator_set_name_set == 0)
14246 errmsg ("missing locator-set name");
14252 errmsg ("EID address not set!");
14253 vec_free (locator_set_name);
14257 if (key && (0 == key_id))
14259 errmsg ("invalid key_id!");
14263 if (vec_len (key) > 64)
14265 errmsg ("key too long");
14270 if (vec_len (locator_set_name) > 64)
14272 errmsg ("locator-set name too long");
14273 vec_free (locator_set_name);
14276 vec_add1 (locator_set_name, 0);
14278 /* Construct the API message */
14279 M (ONE_ADD_DEL_LOCAL_EID, mp);
14281 mp->is_add = is_add;
14282 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14283 mp->eid_type = eid->type;
14284 mp->prefix_len = eid->len;
14285 mp->vni = clib_host_to_net_u32 (vni);
14286 mp->key_id = clib_host_to_net_u16 (key_id);
14287 clib_memcpy (mp->locator_set_name, locator_set_name,
14288 vec_len (locator_set_name));
14289 clib_memcpy (mp->key, key, vec_len (key));
14291 vec_free (locator_set_name);
14297 /* Wait for a reply... */
14302 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14305 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14307 u32 dp_table = 0, vni = 0;;
14308 unformat_input_t *input = vam->input;
14309 vl_api_gpe_add_del_fwd_entry_t *mp;
14311 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14312 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14313 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14314 u32 action = ~0, w;
14315 ip4_address_t rmt_rloc4, lcl_rloc4;
14316 ip6_address_t rmt_rloc6, lcl_rloc6;
14317 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14320 memset (&rloc, 0, sizeof (rloc));
14322 /* Parse args required to build the message */
14323 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14325 if (unformat (input, "del"))
14327 else if (unformat (input, "add"))
14329 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14333 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14337 else if (unformat (input, "vrf %d", &dp_table))
14339 else if (unformat (input, "bd %d", &dp_table))
14341 else if (unformat (input, "vni %d", &vni))
14343 else if (unformat (input, "w %d", &w))
14347 errmsg ("No RLOC configured for setting priority/weight!");
14350 curr_rloc->weight = w;
14352 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14353 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14357 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
14359 vec_add1 (lcl_locs, rloc);
14361 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
14362 vec_add1 (rmt_locs, rloc);
14363 /* weight saved in rmt loc */
14364 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14366 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14367 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14370 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
14372 vec_add1 (lcl_locs, rloc);
14374 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
14375 vec_add1 (rmt_locs, rloc);
14376 /* weight saved in rmt loc */
14377 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14379 else if (unformat (input, "action %d", &action))
14385 clib_warning ("parse error '%U'", format_unformat_error, input);
14392 errmsg ("remote eid addresses not set");
14396 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14398 errmsg ("eid types don't match");
14402 if (0 == rmt_locs && (u32) ~ 0 == action)
14404 errmsg ("action not set for negative mapping");
14408 /* Construct the API message */
14409 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14410 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14412 mp->is_add = is_add;
14413 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14414 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14415 mp->eid_type = rmt_eid->type;
14416 mp->dp_table = clib_host_to_net_u32 (dp_table);
14417 mp->vni = clib_host_to_net_u32 (vni);
14418 mp->rmt_len = rmt_eid->len;
14419 mp->lcl_len = lcl_eid->len;
14420 mp->action = action;
14422 if (0 != rmt_locs && 0 != lcl_locs)
14424 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14425 clib_memcpy (mp->locs, lcl_locs,
14426 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14428 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14429 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14430 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14432 vec_free (lcl_locs);
14433 vec_free (rmt_locs);
14438 /* Wait for a reply... */
14444 api_one_add_del_map_server (vat_main_t * vam)
14446 unformat_input_t *input = vam->input;
14447 vl_api_one_add_del_map_server_t *mp;
14451 ip4_address_t ipv4;
14452 ip6_address_t ipv6;
14455 /* Parse args required to build the message */
14456 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14458 if (unformat (input, "del"))
14462 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14466 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14474 if (ipv4_set && ipv6_set)
14476 errmsg ("both eid v4 and v6 addresses set");
14480 if (!ipv4_set && !ipv6_set)
14482 errmsg ("eid addresses not set");
14486 /* Construct the API message */
14487 M (ONE_ADD_DEL_MAP_SERVER, mp);
14489 mp->is_add = is_add;
14493 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14498 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14504 /* Wait for a reply... */
14509 #define api_lisp_add_del_map_server api_one_add_del_map_server
14512 api_one_add_del_map_resolver (vat_main_t * vam)
14514 unformat_input_t *input = vam->input;
14515 vl_api_one_add_del_map_resolver_t *mp;
14519 ip4_address_t ipv4;
14520 ip6_address_t ipv6;
14523 /* Parse args required to build the message */
14524 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14526 if (unformat (input, "del"))
14530 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14534 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14542 if (ipv4_set && ipv6_set)
14544 errmsg ("both eid v4 and v6 addresses set");
14548 if (!ipv4_set && !ipv6_set)
14550 errmsg ("eid addresses not set");
14554 /* Construct the API message */
14555 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14557 mp->is_add = is_add;
14561 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14566 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14572 /* Wait for a reply... */
14577 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14580 api_lisp_gpe_enable_disable (vat_main_t * vam)
14582 unformat_input_t *input = vam->input;
14583 vl_api_gpe_enable_disable_t *mp;
14588 /* Parse args required to build the message */
14589 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14591 if (unformat (input, "enable"))
14596 else if (unformat (input, "disable"))
14607 errmsg ("Value not set");
14611 /* Construct the API message */
14612 M (GPE_ENABLE_DISABLE, mp);
14619 /* Wait for a reply... */
14625 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14627 unformat_input_t *input = vam->input;
14628 vl_api_one_rloc_probe_enable_disable_t *mp;
14633 /* Parse args required to build the message */
14634 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14636 if (unformat (input, "enable"))
14641 else if (unformat (input, "disable"))
14649 errmsg ("Value not set");
14653 /* Construct the API message */
14654 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14656 mp->is_enabled = is_en;
14661 /* Wait for a reply... */
14666 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14669 api_one_map_register_enable_disable (vat_main_t * vam)
14671 unformat_input_t *input = vam->input;
14672 vl_api_one_map_register_enable_disable_t *mp;
14677 /* Parse args required to build the message */
14678 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14680 if (unformat (input, "enable"))
14685 else if (unformat (input, "disable"))
14693 errmsg ("Value not set");
14697 /* Construct the API message */
14698 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14700 mp->is_enabled = is_en;
14705 /* Wait for a reply... */
14710 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14713 api_one_enable_disable (vat_main_t * vam)
14715 unformat_input_t *input = vam->input;
14716 vl_api_one_enable_disable_t *mp;
14721 /* Parse args required to build the message */
14722 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14724 if (unformat (input, "enable"))
14729 else if (unformat (input, "disable"))
14739 errmsg ("Value not set");
14743 /* Construct the API message */
14744 M (ONE_ENABLE_DISABLE, mp);
14751 /* Wait for a reply... */
14756 #define api_lisp_enable_disable api_one_enable_disable
14759 api_show_one_map_register_state (vat_main_t * vam)
14761 vl_api_show_one_map_register_state_t *mp;
14764 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14769 /* wait for reply */
14774 #define api_show_lisp_map_register_state api_show_one_map_register_state
14777 api_show_one_rloc_probe_state (vat_main_t * vam)
14779 vl_api_show_one_rloc_probe_state_t *mp;
14782 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14787 /* wait for reply */
14792 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14795 api_one_stats_enable_disable (vat_main_t * vam)
14797 vl_api_one_stats_enable_disable_t *mp;
14798 unformat_input_t *input = vam->input;
14803 /* Parse args required to build the message */
14804 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14806 if (unformat (input, "enable"))
14811 else if (unformat (input, "disable"))
14821 errmsg ("Value not set");
14825 M (ONE_STATS_ENABLE_DISABLE, mp);
14831 /* wait for reply */
14837 api_show_one_stats_enable_disable (vat_main_t * vam)
14839 vl_api_show_one_stats_enable_disable_t *mp;
14842 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
14847 /* wait for reply */
14853 api_show_one_map_request_mode (vat_main_t * vam)
14855 vl_api_show_one_map_request_mode_t *mp;
14858 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
14863 /* wait for reply */
14868 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
14871 api_one_map_request_mode (vat_main_t * vam)
14873 unformat_input_t *input = vam->input;
14874 vl_api_one_map_request_mode_t *mp;
14878 /* Parse args required to build the message */
14879 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14881 if (unformat (input, "dst-only"))
14883 else if (unformat (input, "src-dst"))
14887 errmsg ("parse error '%U'", format_unformat_error, input);
14892 M (ONE_MAP_REQUEST_MODE, mp);
14899 /* wait for reply */
14904 #define api_lisp_map_request_mode api_one_map_request_mode
14907 * Enable/disable ONE proxy ITR.
14909 * @param vam vpp API test context
14910 * @return return code
14913 api_one_pitr_set_locator_set (vat_main_t * vam)
14915 u8 ls_name_set = 0;
14916 unformat_input_t *input = vam->input;
14917 vl_api_one_pitr_set_locator_set_t *mp;
14922 /* Parse args required to build the message */
14923 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14925 if (unformat (input, "del"))
14927 else if (unformat (input, "locator-set %s", &ls_name))
14931 errmsg ("parse error '%U'", format_unformat_error, input);
14938 errmsg ("locator-set name not set!");
14942 M (ONE_PITR_SET_LOCATOR_SET, mp);
14944 mp->is_add = is_add;
14945 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14946 vec_free (ls_name);
14951 /* wait for reply */
14956 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
14959 api_show_one_pitr (vat_main_t * vam)
14961 vl_api_show_one_pitr_t *mp;
14964 if (!vam->json_output)
14966 print (vam->ofp, "%=20s", "lisp status:");
14969 M (SHOW_ONE_PITR, mp);
14973 /* Wait for a reply... */
14978 #define api_show_lisp_pitr api_show_one_pitr
14981 api_one_use_petr (vat_main_t * vam)
14983 unformat_input_t *input = vam->input;
14984 vl_api_one_use_petr_t *mp;
14989 memset (&ip, 0, sizeof (ip));
14991 /* Parse args required to build the message */
14992 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14994 if (unformat (input, "disable"))
14997 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
15000 ip_addr_version (&ip) = IP4;
15003 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
15006 ip_addr_version (&ip) = IP6;
15010 errmsg ("parse error '%U'", format_unformat_error, input);
15015 M (ONE_USE_PETR, mp);
15017 mp->is_add = is_add;
15020 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
15022 clib_memcpy (mp->address, &ip, 4);
15024 clib_memcpy (mp->address, &ip, 16);
15030 /* wait for reply */
15035 #define api_lisp_use_petr api_one_use_petr
15038 api_show_one_use_petr (vat_main_t * vam)
15040 vl_api_show_one_use_petr_t *mp;
15043 if (!vam->json_output)
15045 print (vam->ofp, "%=20s", "Proxy-ETR status:");
15048 M (SHOW_ONE_USE_PETR, mp);
15052 /* Wait for a reply... */
15057 #define api_show_lisp_use_petr api_show_one_use_petr
15060 * Add/delete mapping between vni and vrf
15063 api_one_eid_table_add_del_map (vat_main_t * vam)
15065 unformat_input_t *input = vam->input;
15066 vl_api_one_eid_table_add_del_map_t *mp;
15067 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15068 u32 vni, vrf, bd_index;
15071 /* Parse args required to build the message */
15072 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15074 if (unformat (input, "del"))
15076 else if (unformat (input, "vrf %d", &vrf))
15078 else if (unformat (input, "bd_index %d", &bd_index))
15080 else if (unformat (input, "vni %d", &vni))
15086 if (!vni_set || (!vrf_set && !bd_index_set))
15088 errmsg ("missing arguments!");
15092 if (vrf_set && bd_index_set)
15094 errmsg ("error: both vrf and bd entered!");
15098 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15100 mp->is_add = is_add;
15101 mp->vni = htonl (vni);
15102 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15103 mp->is_l2 = bd_index_set;
15108 /* wait for reply */
15113 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15116 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15118 u32 *action = va_arg (*args, u32 *);
15121 if (unformat (input, "%s", &s))
15123 if (!strcmp ((char *) s, "no-action"))
15125 else if (!strcmp ((char *) s, "natively-forward"))
15127 else if (!strcmp ((char *) s, "send-map-request"))
15129 else if (!strcmp ((char *) s, "drop"))
15133 clib_warning ("invalid action: '%s'", s);
15145 * Add/del remote mapping to/from ONE control plane
15147 * @param vam vpp API test context
15148 * @return return code
15151 api_one_add_del_remote_mapping (vat_main_t * vam)
15153 unformat_input_t *input = vam->input;
15154 vl_api_one_add_del_remote_mapping_t *mp;
15156 lisp_eid_vat_t _eid, *eid = &_eid;
15157 lisp_eid_vat_t _seid, *seid = &_seid;
15158 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15159 u32 action = ~0, p, w, data_len;
15160 ip4_address_t rloc4;
15161 ip6_address_t rloc6;
15162 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15165 memset (&rloc, 0, sizeof (rloc));
15167 /* Parse args required to build the message */
15168 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15170 if (unformat (input, "del-all"))
15174 else if (unformat (input, "del"))
15178 else if (unformat (input, "add"))
15182 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15186 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15190 else if (unformat (input, "vni %d", &vni))
15194 else if (unformat (input, "p %d w %d", &p, &w))
15198 errmsg ("No RLOC configured for setting priority/weight!");
15201 curr_rloc->priority = p;
15202 curr_rloc->weight = w;
15204 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15207 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
15208 vec_add1 (rlocs, rloc);
15209 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15211 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15214 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
15215 vec_add1 (rlocs, rloc);
15216 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15218 else if (unformat (input, "action %U",
15219 unformat_negative_mapping_action, &action))
15225 clib_warning ("parse error '%U'", format_unformat_error, input);
15232 errmsg ("missing params!");
15236 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15238 errmsg ("no action set for negative map-reply!");
15242 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15244 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15245 mp->is_add = is_add;
15246 mp->vni = htonl (vni);
15247 mp->action = (u8) action;
15248 mp->is_src_dst = seid_set;
15249 mp->eid_len = eid->len;
15250 mp->seid_len = seid->len;
15251 mp->del_all = del_all;
15252 mp->eid_type = eid->type;
15253 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15254 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
15256 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15257 clib_memcpy (mp->rlocs, rlocs, data_len);
15263 /* Wait for a reply... */
15268 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15271 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15272 * forwarding entries in data-plane accordingly.
15274 * @param vam vpp API test context
15275 * @return return code
15278 api_one_add_del_adjacency (vat_main_t * vam)
15280 unformat_input_t *input = vam->input;
15281 vl_api_one_add_del_adjacency_t *mp;
15283 ip4_address_t leid4, reid4;
15284 ip6_address_t leid6, reid6;
15285 u8 reid_mac[6] = { 0 };
15286 u8 leid_mac[6] = { 0 };
15287 u8 reid_type, leid_type;
15288 u32 leid_len = 0, reid_len = 0, len;
15292 leid_type = reid_type = (u8) ~ 0;
15294 /* Parse args required to build the message */
15295 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15297 if (unformat (input, "del"))
15301 else if (unformat (input, "add"))
15305 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
15308 reid_type = 0; /* ipv4 */
15311 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
15314 reid_type = 1; /* ipv6 */
15317 else if (unformat (input, "reid %U", unformat_ethernet_address,
15320 reid_type = 2; /* mac */
15322 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
15325 leid_type = 0; /* ipv4 */
15328 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
15331 leid_type = 1; /* ipv6 */
15334 else if (unformat (input, "leid %U", unformat_ethernet_address,
15337 leid_type = 2; /* mac */
15339 else if (unformat (input, "vni %d", &vni))
15345 errmsg ("parse error '%U'", format_unformat_error, input);
15350 if ((u8) ~ 0 == reid_type)
15352 errmsg ("missing params!");
15356 if (leid_type != reid_type)
15358 errmsg ("remote and local EIDs are of different types!");
15362 M (ONE_ADD_DEL_ADJACENCY, mp);
15363 mp->is_add = is_add;
15364 mp->vni = htonl (vni);
15365 mp->leid_len = leid_len;
15366 mp->reid_len = reid_len;
15367 mp->eid_type = reid_type;
15369 switch (mp->eid_type)
15372 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
15373 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
15376 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
15377 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
15380 clib_memcpy (mp->leid, leid_mac, 6);
15381 clib_memcpy (mp->reid, reid_mac, 6);
15384 errmsg ("unknown EID type %d!", mp->eid_type);
15391 /* Wait for a reply... */
15396 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
15399 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
15401 u32 *mode = va_arg (*args, u32 *);
15403 if (unformat (input, "lisp"))
15405 else if (unformat (input, "vxlan"))
15414 api_gpe_get_encap_mode (vat_main_t * vam)
15416 vl_api_gpe_get_encap_mode_t *mp;
15419 /* Construct the API message */
15420 M (GPE_GET_ENCAP_MODE, mp);
15425 /* Wait for a reply... */
15431 api_gpe_set_encap_mode (vat_main_t * vam)
15433 unformat_input_t *input = vam->input;
15434 vl_api_gpe_set_encap_mode_t *mp;
15438 /* Parse args required to build the message */
15439 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15441 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
15447 /* Construct the API message */
15448 M (GPE_SET_ENCAP_MODE, mp);
15455 /* Wait for a reply... */
15461 api_lisp_gpe_add_del_iface (vat_main_t * vam)
15463 unformat_input_t *input = vam->input;
15464 vl_api_gpe_add_del_iface_t *mp;
15465 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
15466 u32 dp_table = 0, vni = 0;
15469 /* Parse args required to build the message */
15470 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15472 if (unformat (input, "up"))
15477 else if (unformat (input, "down"))
15482 else if (unformat (input, "table_id %d", &dp_table))
15486 else if (unformat (input, "bd_id %d", &dp_table))
15491 else if (unformat (input, "vni %d", &vni))
15499 if (action_set == 0)
15501 errmsg ("Action not set");
15504 if (dp_table_set == 0 || vni_set == 0)
15506 errmsg ("vni and dp_table must be set");
15510 /* Construct the API message */
15511 M (GPE_ADD_DEL_IFACE, mp);
15513 mp->is_add = is_add;
15514 mp->dp_table = dp_table;
15521 /* Wait for a reply... */
15527 * Add/del map request itr rlocs from ONE control plane and updates
15529 * @param vam vpp API test context
15530 * @return return code
15533 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
15535 unformat_input_t *input = vam->input;
15536 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
15537 u8 *locator_set_name = 0;
15538 u8 locator_set_name_set = 0;
15542 /* Parse args required to build the message */
15543 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15545 if (unformat (input, "del"))
15549 else if (unformat (input, "%_%v%_", &locator_set_name))
15551 locator_set_name_set = 1;
15555 clib_warning ("parse error '%U'", format_unformat_error, input);
15560 if (is_add && !locator_set_name_set)
15562 errmsg ("itr-rloc is not set!");
15566 if (is_add && vec_len (locator_set_name) > 64)
15568 errmsg ("itr-rloc locator-set name too long");
15569 vec_free (locator_set_name);
15573 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
15574 mp->is_add = is_add;
15577 clib_memcpy (mp->locator_set_name, locator_set_name,
15578 vec_len (locator_set_name));
15582 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
15584 vec_free (locator_set_name);
15589 /* Wait for a reply... */
15594 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
15597 api_one_locator_dump (vat_main_t * vam)
15599 unformat_input_t *input = vam->input;
15600 vl_api_one_locator_dump_t *mp;
15601 vl_api_control_ping_t *mp_ping;
15602 u8 is_index_set = 0, is_name_set = 0;
15607 /* Parse args required to build the message */
15608 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15610 if (unformat (input, "ls_name %_%v%_", &ls_name))
15614 else if (unformat (input, "ls_index %d", &ls_index))
15620 errmsg ("parse error '%U'", format_unformat_error, input);
15625 if (!is_index_set && !is_name_set)
15627 errmsg ("error: expected one of index or name!");
15631 if (is_index_set && is_name_set)
15633 errmsg ("error: only one param expected!");
15637 if (vec_len (ls_name) > 62)
15639 errmsg ("error: locator set name too long!");
15643 if (!vam->json_output)
15645 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
15648 M (ONE_LOCATOR_DUMP, mp);
15649 mp->is_index_set = is_index_set;
15652 mp->ls_index = clib_host_to_net_u32 (ls_index);
15655 vec_add1 (ls_name, 0);
15656 strncpy ((char *) mp->ls_name, (char *) ls_name,
15657 sizeof (mp->ls_name) - 1);
15663 /* Use a control ping for synchronization */
15664 M (CONTROL_PING, mp_ping);
15667 /* Wait for a reply... */
15672 #define api_lisp_locator_dump api_one_locator_dump
15675 api_one_locator_set_dump (vat_main_t * vam)
15677 vl_api_one_locator_set_dump_t *mp;
15678 vl_api_control_ping_t *mp_ping;
15679 unformat_input_t *input = vam->input;
15683 /* Parse args required to build the message */
15684 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15686 if (unformat (input, "local"))
15690 else if (unformat (input, "remote"))
15696 errmsg ("parse error '%U'", format_unformat_error, input);
15701 if (!vam->json_output)
15703 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
15706 M (ONE_LOCATOR_SET_DUMP, mp);
15708 mp->filter = filter;
15713 /* Use a control ping for synchronization */
15714 M (CONTROL_PING, mp_ping);
15717 /* Wait for a reply... */
15722 #define api_lisp_locator_set_dump api_one_locator_set_dump
15725 api_one_eid_table_map_dump (vat_main_t * vam)
15729 unformat_input_t *input = vam->input;
15730 vl_api_one_eid_table_map_dump_t *mp;
15731 vl_api_control_ping_t *mp_ping;
15734 /* Parse args required to build the message */
15735 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15737 if (unformat (input, "l2"))
15742 else if (unformat (input, "l3"))
15749 errmsg ("parse error '%U'", format_unformat_error, input);
15756 errmsg ("expected one of 'l2' or 'l3' parameter!");
15760 if (!vam->json_output)
15762 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
15765 M (ONE_EID_TABLE_MAP_DUMP, mp);
15771 /* Use a control ping for synchronization */
15772 M (CONTROL_PING, mp_ping);
15775 /* Wait for a reply... */
15780 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
15783 api_one_eid_table_vni_dump (vat_main_t * vam)
15785 vl_api_one_eid_table_vni_dump_t *mp;
15786 vl_api_control_ping_t *mp_ping;
15789 if (!vam->json_output)
15791 print (vam->ofp, "VNI");
15794 M (ONE_EID_TABLE_VNI_DUMP, mp);
15799 /* Use a control ping for synchronization */
15800 M (CONTROL_PING, mp_ping);
15803 /* Wait for a reply... */
15808 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
15811 api_one_eid_table_dump (vat_main_t * vam)
15813 unformat_input_t *i = vam->input;
15814 vl_api_one_eid_table_dump_t *mp;
15815 vl_api_control_ping_t *mp_ping;
15816 struct in_addr ip4;
15817 struct in6_addr ip6;
15819 u8 eid_type = ~0, eid_set = 0;
15820 u32 prefix_length = ~0, t, vni = 0;
15824 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15826 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
15832 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
15838 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
15843 else if (unformat (i, "vni %d", &t))
15847 else if (unformat (i, "local"))
15851 else if (unformat (i, "remote"))
15857 errmsg ("parse error '%U'", format_unformat_error, i);
15862 if (!vam->json_output)
15864 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
15865 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
15868 M (ONE_EID_TABLE_DUMP, mp);
15870 mp->filter = filter;
15874 mp->vni = htonl (vni);
15875 mp->eid_type = eid_type;
15879 mp->prefix_length = prefix_length;
15880 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
15883 mp->prefix_length = prefix_length;
15884 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
15887 clib_memcpy (mp->eid, mac, sizeof (mac));
15890 errmsg ("unknown EID type %d!", eid_type);
15898 /* Use a control ping for synchronization */
15899 M (CONTROL_PING, mp_ping);
15902 /* Wait for a reply... */
15907 #define api_lisp_eid_table_dump api_one_eid_table_dump
15910 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
15912 unformat_input_t *i = vam->input;
15913 vl_api_gpe_fwd_entries_get_t *mp;
15918 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15920 if (unformat (i, "vni %d", &vni))
15926 errmsg ("parse error '%U'", format_unformat_error, i);
15933 errmsg ("vni not set!");
15937 if (!vam->json_output)
15939 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15943 M (GPE_FWD_ENTRIES_GET, mp);
15944 mp->vni = clib_host_to_net_u32 (vni);
15949 /* Wait for a reply... */
15954 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
15955 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
15956 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15957 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15958 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15959 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
15962 api_one_adjacencies_get (vat_main_t * vam)
15964 unformat_input_t *i = vam->input;
15965 vl_api_one_adjacencies_get_t *mp;
15970 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15972 if (unformat (i, "vni %d", &vni))
15978 errmsg ("parse error '%U'", format_unformat_error, i);
15985 errmsg ("vni not set!");
15989 if (!vam->json_output)
15991 print (vam->ofp, "%s %40s", "leid", "reid");
15994 M (ONE_ADJACENCIES_GET, mp);
15995 mp->vni = clib_host_to_net_u32 (vni);
16000 /* Wait for a reply... */
16005 #define api_lisp_adjacencies_get api_one_adjacencies_get
16008 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
16010 vl_api_gpe_fwd_entry_vnis_get_t *mp;
16013 if (!vam->json_output)
16015 print (vam->ofp, "VNIs");
16018 M (GPE_FWD_ENTRY_VNIS_GET, mp);
16023 /* Wait for a reply... */
16029 api_one_map_server_dump (vat_main_t * vam)
16031 vl_api_one_map_server_dump_t *mp;
16032 vl_api_control_ping_t *mp_ping;
16035 if (!vam->json_output)
16037 print (vam->ofp, "%=20s", "Map server");
16040 M (ONE_MAP_SERVER_DUMP, mp);
16044 /* Use a control ping for synchronization */
16045 M (CONTROL_PING, mp_ping);
16048 /* Wait for a reply... */
16053 #define api_lisp_map_server_dump api_one_map_server_dump
16056 api_one_map_resolver_dump (vat_main_t * vam)
16058 vl_api_one_map_resolver_dump_t *mp;
16059 vl_api_control_ping_t *mp_ping;
16062 if (!vam->json_output)
16064 print (vam->ofp, "%=20s", "Map resolver");
16067 M (ONE_MAP_RESOLVER_DUMP, mp);
16071 /* Use a control ping for synchronization */
16072 M (CONTROL_PING, mp_ping);
16075 /* Wait for a reply... */
16080 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
16083 api_one_stats_flush (vat_main_t * vam)
16085 vl_api_one_stats_flush_t *mp;
16088 M (ONE_STATS_FLUSH, mp);
16095 api_one_stats_dump (vat_main_t * vam)
16097 vl_api_one_stats_dump_t *mp;
16098 vl_api_control_ping_t *mp_ping;
16101 M (ONE_STATS_DUMP, mp);
16105 /* Use a control ping for synchronization */
16106 M (CONTROL_PING, mp_ping);
16109 /* Wait for a reply... */
16115 api_show_one_status (vat_main_t * vam)
16117 vl_api_show_one_status_t *mp;
16120 if (!vam->json_output)
16122 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
16125 M (SHOW_ONE_STATUS, mp);
16128 /* Wait for a reply... */
16133 #define api_show_lisp_status api_show_one_status
16136 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
16138 vl_api_gpe_fwd_entry_path_dump_t *mp;
16139 vl_api_control_ping_t *mp_ping;
16140 unformat_input_t *i = vam->input;
16141 u32 fwd_entry_index = ~0;
16144 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16146 if (unformat (i, "index %d", &fwd_entry_index))
16152 if (~0 == fwd_entry_index)
16154 errmsg ("no index specified!");
16158 if (!vam->json_output)
16160 print (vam->ofp, "first line");
16163 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
16167 /* Use a control ping for synchronization */
16168 M (CONTROL_PING, mp_ping);
16171 /* Wait for a reply... */
16177 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
16179 vl_api_one_get_map_request_itr_rlocs_t *mp;
16182 if (!vam->json_output)
16184 print (vam->ofp, "%=20s", "itr-rlocs:");
16187 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
16190 /* Wait for a reply... */
16195 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
16198 api_af_packet_create (vat_main_t * vam)
16200 unformat_input_t *i = vam->input;
16201 vl_api_af_packet_create_t *mp;
16202 u8 *host_if_name = 0;
16204 u8 random_hw_addr = 1;
16207 memset (hw_addr, 0, sizeof (hw_addr));
16209 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16211 if (unformat (i, "name %s", &host_if_name))
16212 vec_add1 (host_if_name, 0);
16213 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16214 random_hw_addr = 0;
16219 if (!vec_len (host_if_name))
16221 errmsg ("host-interface name must be specified");
16225 if (vec_len (host_if_name) > 64)
16227 errmsg ("host-interface name too long");
16231 M (AF_PACKET_CREATE, mp);
16233 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16234 clib_memcpy (mp->hw_addr, hw_addr, 6);
16235 mp->use_random_hw_addr = random_hw_addr;
16236 vec_free (host_if_name);
16244 fprintf (vam->ofp ? vam->ofp : stderr,
16245 " new sw_if_index = %d\n", vam->sw_if_index);
16252 api_af_packet_delete (vat_main_t * vam)
16254 unformat_input_t *i = vam->input;
16255 vl_api_af_packet_delete_t *mp;
16256 u8 *host_if_name = 0;
16259 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16261 if (unformat (i, "name %s", &host_if_name))
16262 vec_add1 (host_if_name, 0);
16267 if (!vec_len (host_if_name))
16269 errmsg ("host-interface name must be specified");
16273 if (vec_len (host_if_name) > 64)
16275 errmsg ("host-interface name too long");
16279 M (AF_PACKET_DELETE, mp);
16281 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
16282 vec_free (host_if_name);
16290 api_policer_add_del (vat_main_t * vam)
16292 unformat_input_t *i = vam->input;
16293 vl_api_policer_add_del_t *mp;
16303 u8 color_aware = 0;
16304 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
16307 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
16308 conform_action.dscp = 0;
16309 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
16310 exceed_action.dscp = 0;
16311 violate_action.action_type = SSE2_QOS_ACTION_DROP;
16312 violate_action.dscp = 0;
16314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16316 if (unformat (i, "del"))
16318 else if (unformat (i, "name %s", &name))
16319 vec_add1 (name, 0);
16320 else if (unformat (i, "cir %u", &cir))
16322 else if (unformat (i, "eir %u", &eir))
16324 else if (unformat (i, "cb %u", &cb))
16326 else if (unformat (i, "eb %u", &eb))
16328 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
16331 else if (unformat (i, "round_type %U", unformat_policer_round_type,
16334 else if (unformat (i, "type %U", unformat_policer_type, &type))
16336 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
16339 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
16342 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
16345 else if (unformat (i, "color-aware"))
16351 if (!vec_len (name))
16353 errmsg ("policer name must be specified");
16357 if (vec_len (name) > 64)
16359 errmsg ("policer name too long");
16363 M (POLICER_ADD_DEL, mp);
16365 clib_memcpy (mp->name, name, vec_len (name));
16367 mp->is_add = is_add;
16372 mp->rate_type = rate_type;
16373 mp->round_type = round_type;
16375 mp->conform_action_type = conform_action.action_type;
16376 mp->conform_dscp = conform_action.dscp;
16377 mp->exceed_action_type = exceed_action.action_type;
16378 mp->exceed_dscp = exceed_action.dscp;
16379 mp->violate_action_type = violate_action.action_type;
16380 mp->violate_dscp = violate_action.dscp;
16381 mp->color_aware = color_aware;
16389 api_policer_dump (vat_main_t * vam)
16391 unformat_input_t *i = vam->input;
16392 vl_api_policer_dump_t *mp;
16393 vl_api_control_ping_t *mp_ping;
16394 u8 *match_name = 0;
16395 u8 match_name_valid = 0;
16398 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16400 if (unformat (i, "name %s", &match_name))
16402 vec_add1 (match_name, 0);
16403 match_name_valid = 1;
16409 M (POLICER_DUMP, mp);
16410 mp->match_name_valid = match_name_valid;
16411 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
16412 vec_free (match_name);
16416 /* Use a control ping for synchronization */
16417 M (CONTROL_PING, mp_ping);
16420 /* Wait for a reply... */
16426 api_policer_classify_set_interface (vat_main_t * vam)
16428 unformat_input_t *i = vam->input;
16429 vl_api_policer_classify_set_interface_t *mp;
16431 int sw_if_index_set;
16432 u32 ip4_table_index = ~0;
16433 u32 ip6_table_index = ~0;
16434 u32 l2_table_index = ~0;
16438 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16440 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16441 sw_if_index_set = 1;
16442 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16443 sw_if_index_set = 1;
16444 else if (unformat (i, "del"))
16446 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16448 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16450 else if (unformat (i, "l2-table %d", &l2_table_index))
16454 clib_warning ("parse error '%U'", format_unformat_error, i);
16459 if (sw_if_index_set == 0)
16461 errmsg ("missing interface name or sw_if_index");
16465 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
16467 mp->sw_if_index = ntohl (sw_if_index);
16468 mp->ip4_table_index = ntohl (ip4_table_index);
16469 mp->ip6_table_index = ntohl (ip6_table_index);
16470 mp->l2_table_index = ntohl (l2_table_index);
16471 mp->is_add = is_add;
16479 api_policer_classify_dump (vat_main_t * vam)
16481 unformat_input_t *i = vam->input;
16482 vl_api_policer_classify_dump_t *mp;
16483 vl_api_control_ping_t *mp_ping;
16484 u8 type = POLICER_CLASSIFY_N_TABLES;
16487 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
16491 errmsg ("classify table type must be specified");
16495 if (!vam->json_output)
16497 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
16500 M (POLICER_CLASSIFY_DUMP, mp);
16505 /* Use a control ping for synchronization */
16506 M (CONTROL_PING, mp_ping);
16509 /* Wait for a reply... */
16515 api_netmap_create (vat_main_t * vam)
16517 unformat_input_t *i = vam->input;
16518 vl_api_netmap_create_t *mp;
16521 u8 random_hw_addr = 1;
16526 memset (hw_addr, 0, sizeof (hw_addr));
16528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16530 if (unformat (i, "name %s", &if_name))
16531 vec_add1 (if_name, 0);
16532 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16533 random_hw_addr = 0;
16534 else if (unformat (i, "pipe"))
16536 else if (unformat (i, "master"))
16538 else if (unformat (i, "slave"))
16544 if (!vec_len (if_name))
16546 errmsg ("interface name must be specified");
16550 if (vec_len (if_name) > 64)
16552 errmsg ("interface name too long");
16556 M (NETMAP_CREATE, mp);
16558 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16559 clib_memcpy (mp->hw_addr, hw_addr, 6);
16560 mp->use_random_hw_addr = random_hw_addr;
16561 mp->is_pipe = is_pipe;
16562 mp->is_master = is_master;
16563 vec_free (if_name);
16571 api_netmap_delete (vat_main_t * vam)
16573 unformat_input_t *i = vam->input;
16574 vl_api_netmap_delete_t *mp;
16578 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16580 if (unformat (i, "name %s", &if_name))
16581 vec_add1 (if_name, 0);
16586 if (!vec_len (if_name))
16588 errmsg ("interface name must be specified");
16592 if (vec_len (if_name) > 64)
16594 errmsg ("interface name too long");
16598 M (NETMAP_DELETE, mp);
16600 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16601 vec_free (if_name);
16609 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
16611 if (fp->afi == IP46_TYPE_IP6)
16613 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16614 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16615 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16616 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16617 format_ip6_address, fp->next_hop);
16618 else if (fp->afi == IP46_TYPE_IP4)
16620 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16621 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16622 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16623 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16624 format_ip4_address, fp->next_hop);
16628 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
16629 vl_api_fib_path2_t * fp)
16631 struct in_addr ip4;
16632 struct in6_addr ip6;
16634 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16635 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16636 vat_json_object_add_uint (node, "is_local", fp->is_local);
16637 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16638 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16639 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16640 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16641 if (fp->afi == IP46_TYPE_IP4)
16643 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16644 vat_json_object_add_ip4 (node, "next_hop", ip4);
16646 else if (fp->afi == IP46_TYPE_IP6)
16648 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16649 vat_json_object_add_ip6 (node, "next_hop", ip6);
16654 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
16656 vat_main_t *vam = &vat_main;
16657 int count = ntohl (mp->mt_count);
16658 vl_api_fib_path2_t *fp;
16661 print (vam->ofp, "[%d]: sw_if_index %d via:",
16662 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
16664 for (i = 0; i < count; i++)
16666 vl_api_mpls_fib_path_print (vam, fp);
16670 print (vam->ofp, "");
16673 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
16674 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
16677 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
16679 vat_main_t *vam = &vat_main;
16680 vat_json_node_t *node = NULL;
16681 int count = ntohl (mp->mt_count);
16682 vl_api_fib_path2_t *fp;
16685 if (VAT_JSON_ARRAY != vam->json_tree.type)
16687 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16688 vat_json_init_array (&vam->json_tree);
16690 node = vat_json_array_add (&vam->json_tree);
16692 vat_json_init_object (node);
16693 vat_json_object_add_uint (node, "tunnel_index",
16694 ntohl (mp->mt_tunnel_index));
16695 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
16697 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
16700 for (i = 0; i < count; i++)
16702 vl_api_mpls_fib_path_json_print (node, fp);
16708 api_mpls_tunnel_dump (vat_main_t * vam)
16710 vl_api_mpls_tunnel_dump_t *mp;
16711 vl_api_control_ping_t *mp_ping;
16715 /* Parse args required to build the message */
16716 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
16718 if (!unformat (vam->input, "tunnel_index %d", &index))
16725 print (vam->ofp, " tunnel_index %d", index);
16727 M (MPLS_TUNNEL_DUMP, mp);
16728 mp->tunnel_index = htonl (index);
16731 /* Use a control ping for synchronization */
16732 M (CONTROL_PING, mp_ping);
16739 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
16740 #define vl_api_mpls_fib_details_t_print vl_noop_handler
16744 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
16746 vat_main_t *vam = &vat_main;
16747 int count = ntohl (mp->count);
16748 vl_api_fib_path2_t *fp;
16752 "table-id %d, label %u, ess_bit %u",
16753 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
16755 for (i = 0; i < count; i++)
16757 vl_api_mpls_fib_path_print (vam, fp);
16762 static void vl_api_mpls_fib_details_t_handler_json
16763 (vl_api_mpls_fib_details_t * mp)
16765 vat_main_t *vam = &vat_main;
16766 int count = ntohl (mp->count);
16767 vat_json_node_t *node = NULL;
16768 vl_api_fib_path2_t *fp;
16771 if (VAT_JSON_ARRAY != vam->json_tree.type)
16773 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16774 vat_json_init_array (&vam->json_tree);
16776 node = vat_json_array_add (&vam->json_tree);
16778 vat_json_init_object (node);
16779 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16780 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
16781 vat_json_object_add_uint (node, "label", ntohl (mp->label));
16782 vat_json_object_add_uint (node, "path_count", count);
16784 for (i = 0; i < count; i++)
16786 vl_api_mpls_fib_path_json_print (node, fp);
16792 api_mpls_fib_dump (vat_main_t * vam)
16794 vl_api_mpls_fib_dump_t *mp;
16795 vl_api_control_ping_t *mp_ping;
16798 M (MPLS_FIB_DUMP, mp);
16801 /* Use a control ping for synchronization */
16802 M (CONTROL_PING, mp_ping);
16809 #define vl_api_ip_fib_details_t_endian vl_noop_handler
16810 #define vl_api_ip_fib_details_t_print vl_noop_handler
16813 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
16815 vat_main_t *vam = &vat_main;
16816 int count = ntohl (mp->count);
16817 vl_api_fib_path_t *fp;
16821 "table-id %d, prefix %U/%d",
16822 ntohl (mp->table_id), format_ip4_address, mp->address,
16823 mp->address_length);
16825 for (i = 0; i < count; i++)
16827 if (fp->afi == IP46_TYPE_IP6)
16829 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16830 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16831 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16832 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16833 format_ip6_address, fp->next_hop);
16834 else if (fp->afi == IP46_TYPE_IP4)
16836 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16837 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16838 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16839 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16840 format_ip4_address, fp->next_hop);
16845 static void vl_api_ip_fib_details_t_handler_json
16846 (vl_api_ip_fib_details_t * mp)
16848 vat_main_t *vam = &vat_main;
16849 int count = ntohl (mp->count);
16850 vat_json_node_t *node = NULL;
16851 struct in_addr ip4;
16852 struct in6_addr ip6;
16853 vl_api_fib_path_t *fp;
16856 if (VAT_JSON_ARRAY != vam->json_tree.type)
16858 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16859 vat_json_init_array (&vam->json_tree);
16861 node = vat_json_array_add (&vam->json_tree);
16863 vat_json_init_object (node);
16864 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16865 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
16866 vat_json_object_add_ip4 (node, "prefix", ip4);
16867 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16868 vat_json_object_add_uint (node, "path_count", count);
16870 for (i = 0; i < count; i++)
16872 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16873 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16874 vat_json_object_add_uint (node, "is_local", fp->is_local);
16875 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16876 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16877 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16878 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16879 if (fp->afi == IP46_TYPE_IP4)
16881 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16882 vat_json_object_add_ip4 (node, "next_hop", ip4);
16884 else if (fp->afi == IP46_TYPE_IP6)
16886 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16887 vat_json_object_add_ip6 (node, "next_hop", ip6);
16893 api_ip_fib_dump (vat_main_t * vam)
16895 vl_api_ip_fib_dump_t *mp;
16896 vl_api_control_ping_t *mp_ping;
16899 M (IP_FIB_DUMP, mp);
16902 /* Use a control ping for synchronization */
16903 M (CONTROL_PING, mp_ping);
16911 api_ip_mfib_dump (vat_main_t * vam)
16913 vl_api_ip_mfib_dump_t *mp;
16914 vl_api_control_ping_t *mp_ping;
16917 M (IP_MFIB_DUMP, mp);
16920 /* Use a control ping for synchronization */
16921 M (CONTROL_PING, mp_ping);
16928 static void vl_api_ip_neighbor_details_t_handler
16929 (vl_api_ip_neighbor_details_t * mp)
16931 vat_main_t *vam = &vat_main;
16933 print (vam->ofp, "%c %U %U",
16934 (mp->is_static) ? 'S' : 'D',
16935 format_ethernet_address, &mp->mac_address,
16936 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
16940 static void vl_api_ip_neighbor_details_t_handler_json
16941 (vl_api_ip_neighbor_details_t * mp)
16944 vat_main_t *vam = &vat_main;
16945 vat_json_node_t *node;
16946 struct in_addr ip4;
16947 struct in6_addr ip6;
16949 if (VAT_JSON_ARRAY != vam->json_tree.type)
16951 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16952 vat_json_init_array (&vam->json_tree);
16954 node = vat_json_array_add (&vam->json_tree);
16956 vat_json_init_object (node);
16957 vat_json_object_add_string_copy (node, "flag",
16958 (mp->is_static) ? (u8 *) "static" : (u8 *)
16961 vat_json_object_add_string_copy (node, "link_layer",
16962 format (0, "%U", format_ethernet_address,
16963 &mp->mac_address));
16967 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
16968 vat_json_object_add_ip6 (node, "ip_address", ip6);
16972 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
16973 vat_json_object_add_ip4 (node, "ip_address", ip4);
16978 api_ip_neighbor_dump (vat_main_t * vam)
16980 unformat_input_t *i = vam->input;
16981 vl_api_ip_neighbor_dump_t *mp;
16982 vl_api_control_ping_t *mp_ping;
16984 u32 sw_if_index = ~0;
16987 /* Parse args required to build the message */
16988 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16990 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16992 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16994 else if (unformat (i, "ip6"))
17000 if (sw_if_index == ~0)
17002 errmsg ("missing interface name or sw_if_index");
17006 M (IP_NEIGHBOR_DUMP, mp);
17007 mp->is_ipv6 = (u8) is_ipv6;
17008 mp->sw_if_index = ntohl (sw_if_index);
17011 /* Use a control ping for synchronization */
17012 M (CONTROL_PING, mp_ping);
17019 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
17020 #define vl_api_ip6_fib_details_t_print vl_noop_handler
17023 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
17025 vat_main_t *vam = &vat_main;
17026 int count = ntohl (mp->count);
17027 vl_api_fib_path_t *fp;
17031 "table-id %d, prefix %U/%d",
17032 ntohl (mp->table_id), format_ip6_address, mp->address,
17033 mp->address_length);
17035 for (i = 0; i < count; i++)
17037 if (fp->afi == IP46_TYPE_IP6)
17039 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17040 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17041 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17042 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17043 format_ip6_address, fp->next_hop);
17044 else if (fp->afi == IP46_TYPE_IP4)
17046 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17047 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17048 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17049 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17050 format_ip4_address, fp->next_hop);
17055 static void vl_api_ip6_fib_details_t_handler_json
17056 (vl_api_ip6_fib_details_t * mp)
17058 vat_main_t *vam = &vat_main;
17059 int count = ntohl (mp->count);
17060 vat_json_node_t *node = NULL;
17061 struct in_addr ip4;
17062 struct in6_addr ip6;
17063 vl_api_fib_path_t *fp;
17066 if (VAT_JSON_ARRAY != vam->json_tree.type)
17068 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17069 vat_json_init_array (&vam->json_tree);
17071 node = vat_json_array_add (&vam->json_tree);
17073 vat_json_init_object (node);
17074 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17075 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
17076 vat_json_object_add_ip6 (node, "prefix", ip6);
17077 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17078 vat_json_object_add_uint (node, "path_count", count);
17080 for (i = 0; i < count; i++)
17082 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17083 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17084 vat_json_object_add_uint (node, "is_local", fp->is_local);
17085 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17086 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17087 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17088 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17089 if (fp->afi == IP46_TYPE_IP4)
17091 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17092 vat_json_object_add_ip4 (node, "next_hop", ip4);
17094 else if (fp->afi == IP46_TYPE_IP6)
17096 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17097 vat_json_object_add_ip6 (node, "next_hop", ip6);
17103 api_ip6_fib_dump (vat_main_t * vam)
17105 vl_api_ip6_fib_dump_t *mp;
17106 vl_api_control_ping_t *mp_ping;
17109 M (IP6_FIB_DUMP, mp);
17112 /* Use a control ping for synchronization */
17113 M (CONTROL_PING, mp_ping);
17121 api_ip6_mfib_dump (vat_main_t * vam)
17123 vl_api_ip6_mfib_dump_t *mp;
17124 vl_api_control_ping_t *mp_ping;
17127 M (IP6_MFIB_DUMP, mp);
17130 /* Use a control ping for synchronization */
17131 M (CONTROL_PING, mp_ping);
17139 api_classify_table_ids (vat_main_t * vam)
17141 vl_api_classify_table_ids_t *mp;
17144 /* Construct the API message */
17145 M (CLASSIFY_TABLE_IDS, mp);
17154 api_classify_table_by_interface (vat_main_t * vam)
17156 unformat_input_t *input = vam->input;
17157 vl_api_classify_table_by_interface_t *mp;
17159 u32 sw_if_index = ~0;
17161 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17163 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17165 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17170 if (sw_if_index == ~0)
17172 errmsg ("missing interface name or sw_if_index");
17176 /* Construct the API message */
17177 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
17179 mp->sw_if_index = ntohl (sw_if_index);
17187 api_classify_table_info (vat_main_t * vam)
17189 unformat_input_t *input = vam->input;
17190 vl_api_classify_table_info_t *mp;
17194 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17196 if (unformat (input, "table_id %d", &table_id))
17201 if (table_id == ~0)
17203 errmsg ("missing table id");
17207 /* Construct the API message */
17208 M (CLASSIFY_TABLE_INFO, mp);
17210 mp->table_id = ntohl (table_id);
17218 api_classify_session_dump (vat_main_t * vam)
17220 unformat_input_t *input = vam->input;
17221 vl_api_classify_session_dump_t *mp;
17222 vl_api_control_ping_t *mp_ping;
17226 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17228 if (unformat (input, "table_id %d", &table_id))
17233 if (table_id == ~0)
17235 errmsg ("missing table id");
17239 /* Construct the API message */
17240 M (CLASSIFY_SESSION_DUMP, mp);
17242 mp->table_id = ntohl (table_id);
17245 /* Use a control ping for synchronization */
17246 M (CONTROL_PING, mp_ping);
17254 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
17256 vat_main_t *vam = &vat_main;
17258 print (vam->ofp, "collector_address %U, collector_port %d, "
17259 "src_address %U, vrf_id %d, path_mtu %u, "
17260 "template_interval %u, udp_checksum %d",
17261 format_ip4_address, mp->collector_address,
17262 ntohs (mp->collector_port),
17263 format_ip4_address, mp->src_address,
17264 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
17265 ntohl (mp->template_interval), mp->udp_checksum);
17268 vam->result_ready = 1;
17272 vl_api_ipfix_exporter_details_t_handler_json
17273 (vl_api_ipfix_exporter_details_t * mp)
17275 vat_main_t *vam = &vat_main;
17276 vat_json_node_t node;
17277 struct in_addr collector_address;
17278 struct in_addr src_address;
17280 vat_json_init_object (&node);
17281 clib_memcpy (&collector_address, &mp->collector_address,
17282 sizeof (collector_address));
17283 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
17284 vat_json_object_add_uint (&node, "collector_port",
17285 ntohs (mp->collector_port));
17286 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
17287 vat_json_object_add_ip4 (&node, "src_address", src_address);
17288 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
17289 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
17290 vat_json_object_add_uint (&node, "template_interval",
17291 ntohl (mp->template_interval));
17292 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
17294 vat_json_print (vam->ofp, &node);
17295 vat_json_free (&node);
17297 vam->result_ready = 1;
17301 api_ipfix_exporter_dump (vat_main_t * vam)
17303 vl_api_ipfix_exporter_dump_t *mp;
17306 /* Construct the API message */
17307 M (IPFIX_EXPORTER_DUMP, mp);
17316 api_ipfix_classify_stream_dump (vat_main_t * vam)
17318 vl_api_ipfix_classify_stream_dump_t *mp;
17321 /* Construct the API message */
17322 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
17333 vl_api_ipfix_classify_stream_details_t_handler
17334 (vl_api_ipfix_classify_stream_details_t * mp)
17336 vat_main_t *vam = &vat_main;
17337 print (vam->ofp, "domain_id %d, src_port %d",
17338 ntohl (mp->domain_id), ntohs (mp->src_port));
17340 vam->result_ready = 1;
17344 vl_api_ipfix_classify_stream_details_t_handler_json
17345 (vl_api_ipfix_classify_stream_details_t * mp)
17347 vat_main_t *vam = &vat_main;
17348 vat_json_node_t node;
17350 vat_json_init_object (&node);
17351 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
17352 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
17354 vat_json_print (vam->ofp, &node);
17355 vat_json_free (&node);
17357 vam->result_ready = 1;
17361 api_ipfix_classify_table_dump (vat_main_t * vam)
17363 vl_api_ipfix_classify_table_dump_t *mp;
17364 vl_api_control_ping_t *mp_ping;
17367 if (!vam->json_output)
17369 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
17370 "transport_protocol");
17373 /* Construct the API message */
17374 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
17379 /* Use a control ping for synchronization */
17380 M (CONTROL_PING, mp_ping);
17388 vl_api_ipfix_classify_table_details_t_handler
17389 (vl_api_ipfix_classify_table_details_t * mp)
17391 vat_main_t *vam = &vat_main;
17392 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
17393 mp->transport_protocol);
17397 vl_api_ipfix_classify_table_details_t_handler_json
17398 (vl_api_ipfix_classify_table_details_t * mp)
17400 vat_json_node_t *node = NULL;
17401 vat_main_t *vam = &vat_main;
17403 if (VAT_JSON_ARRAY != vam->json_tree.type)
17405 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17406 vat_json_init_array (&vam->json_tree);
17409 node = vat_json_array_add (&vam->json_tree);
17410 vat_json_init_object (node);
17412 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
17413 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
17414 vat_json_object_add_uint (node, "transport_protocol",
17415 mp->transport_protocol);
17419 api_sw_interface_span_enable_disable (vat_main_t * vam)
17421 unformat_input_t *i = vam->input;
17422 vl_api_sw_interface_span_enable_disable_t *mp;
17423 u32 src_sw_if_index = ~0;
17424 u32 dst_sw_if_index = ~0;
17428 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17431 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
17433 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
17437 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
17439 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
17441 else if (unformat (i, "disable"))
17443 else if (unformat (i, "rx"))
17445 else if (unformat (i, "tx"))
17447 else if (unformat (i, "both"))
17453 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
17455 mp->sw_if_index_from = htonl (src_sw_if_index);
17456 mp->sw_if_index_to = htonl (dst_sw_if_index);
17465 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
17468 vat_main_t *vam = &vat_main;
17469 u8 *sw_if_from_name = 0;
17470 u8 *sw_if_to_name = 0;
17471 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17472 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17473 char *states[] = { "none", "rx", "tx", "both" };
17477 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17479 if ((u32) p->value[0] == sw_if_index_from)
17481 sw_if_from_name = (u8 *)(p->key);
17485 if ((u32) p->value[0] == sw_if_index_to)
17487 sw_if_to_name = (u8 *)(p->key);
17488 if (sw_if_from_name)
17493 print (vam->ofp, "%20s => %20s (%s)",
17494 sw_if_from_name, sw_if_to_name, states[mp->state]);
17498 vl_api_sw_interface_span_details_t_handler_json
17499 (vl_api_sw_interface_span_details_t * mp)
17501 vat_main_t *vam = &vat_main;
17502 vat_json_node_t *node = NULL;
17503 u8 *sw_if_from_name = 0;
17504 u8 *sw_if_to_name = 0;
17505 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17506 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17510 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17512 if ((u32) p->value[0] == sw_if_index_from)
17514 sw_if_from_name = (u8 *)(p->key);
17518 if ((u32) p->value[0] == sw_if_index_to)
17520 sw_if_to_name = (u8 *)(p->key);
17521 if (sw_if_from_name)
17527 if (VAT_JSON_ARRAY != vam->json_tree.type)
17529 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17530 vat_json_init_array (&vam->json_tree);
17532 node = vat_json_array_add (&vam->json_tree);
17534 vat_json_init_object (node);
17535 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
17536 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
17537 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
17538 if (0 != sw_if_to_name)
17540 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
17542 vat_json_object_add_uint (node, "state", mp->state);
17546 api_sw_interface_span_dump (vat_main_t * vam)
17548 vl_api_sw_interface_span_dump_t *mp;
17549 vl_api_control_ping_t *mp_ping;
17552 M (SW_INTERFACE_SPAN_DUMP, mp);
17555 /* Use a control ping for synchronization */
17556 M (CONTROL_PING, mp_ping);
17564 api_pg_create_interface (vat_main_t * vam)
17566 unformat_input_t *input = vam->input;
17567 vl_api_pg_create_interface_t *mp;
17571 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17573 if (unformat (input, "if_id %d", &if_id))
17580 errmsg ("missing pg interface index");
17584 /* Construct the API message */
17585 M (PG_CREATE_INTERFACE, mp);
17587 mp->interface_id = ntohl (if_id);
17595 api_pg_capture (vat_main_t * vam)
17597 unformat_input_t *input = vam->input;
17598 vl_api_pg_capture_t *mp;
17603 u8 pcap_file_set = 0;
17606 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17608 if (unformat (input, "if_id %d", &if_id))
17610 else if (unformat (input, "pcap %s", &pcap_file))
17612 else if (unformat (input, "count %d", &count))
17614 else if (unformat (input, "disable"))
17621 errmsg ("missing pg interface index");
17624 if (pcap_file_set > 0)
17626 if (vec_len (pcap_file) > 255)
17628 errmsg ("pcap file name is too long");
17633 u32 name_len = vec_len (pcap_file);
17634 /* Construct the API message */
17635 M (PG_CAPTURE, mp);
17637 mp->interface_id = ntohl (if_id);
17638 mp->is_enabled = enable;
17639 mp->count = ntohl (count);
17640 mp->pcap_name_length = ntohl (name_len);
17641 if (pcap_file_set != 0)
17643 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
17645 vec_free (pcap_file);
17653 api_pg_enable_disable (vat_main_t * vam)
17655 unformat_input_t *input = vam->input;
17656 vl_api_pg_enable_disable_t *mp;
17659 u8 stream_name_set = 0;
17660 u8 *stream_name = 0;
17662 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17664 if (unformat (input, "stream %s", &stream_name))
17665 stream_name_set = 1;
17666 else if (unformat (input, "disable"))
17672 if (stream_name_set > 0)
17674 if (vec_len (stream_name) > 255)
17676 errmsg ("stream name too long");
17681 u32 name_len = vec_len (stream_name);
17682 /* Construct the API message */
17683 M (PG_ENABLE_DISABLE, mp);
17685 mp->is_enabled = enable;
17686 if (stream_name_set != 0)
17688 mp->stream_name_length = ntohl (name_len);
17689 clib_memcpy (mp->stream_name, stream_name, name_len);
17691 vec_free (stream_name);
17699 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
17701 unformat_input_t *input = vam->input;
17702 vl_api_ip_source_and_port_range_check_add_del_t *mp;
17704 u16 *low_ports = 0;
17705 u16 *high_ports = 0;
17708 ip4_address_t ip4_addr;
17709 ip6_address_t ip6_addr;
17718 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17720 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
17726 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
17731 else if (unformat (input, "vrf %d", &vrf_id))
17733 else if (unformat (input, "del"))
17735 else if (unformat (input, "port %d", &tmp))
17737 if (tmp == 0 || tmp > 65535)
17739 errmsg ("port %d out of range", tmp);
17743 this_hi = this_low + 1;
17744 vec_add1 (low_ports, this_low);
17745 vec_add1 (high_ports, this_hi);
17747 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
17749 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
17751 errmsg ("incorrect range parameters");
17755 /* Note: in debug CLI +1 is added to high before
17756 passing to real fn that does "the work"
17757 (ip_source_and_port_range_check_add_del).
17758 This fn is a wrapper around the binary API fn a
17759 control plane will call, which expects this increment
17760 to have occurred. Hence letting the binary API control
17761 plane fn do the increment for consistency between VAT
17762 and other control planes.
17765 vec_add1 (low_ports, this_low);
17766 vec_add1 (high_ports, this_hi);
17772 if (prefix_set == 0)
17774 errmsg ("<address>/<mask> not specified");
17780 errmsg ("VRF ID required, not specified");
17787 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17791 if (vec_len (low_ports) == 0)
17793 errmsg ("At least one port or port range required");
17797 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
17799 mp->is_add = is_add;
17804 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
17809 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
17812 mp->mask_length = length;
17813 mp->number_of_ranges = vec_len (low_ports);
17815 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
17816 vec_free (low_ports);
17818 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
17819 vec_free (high_ports);
17821 mp->vrf_id = ntohl (vrf_id);
17829 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
17831 unformat_input_t *input = vam->input;
17832 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
17833 u32 sw_if_index = ~0;
17835 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
17836 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
17840 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17842 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17844 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17846 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
17848 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
17850 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
17852 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
17854 else if (unformat (input, "del"))
17860 if (sw_if_index == ~0)
17862 errmsg ("Interface required but not specified");
17868 errmsg ("VRF ID required but not specified");
17872 if (tcp_out_vrf_id == 0
17873 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
17876 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17880 /* Construct the API message */
17881 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
17883 mp->sw_if_index = ntohl (sw_if_index);
17884 mp->is_add = is_add;
17885 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
17886 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
17887 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
17888 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
17893 /* Wait for a reply... */
17899 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
17901 unformat_input_t *i = vam->input;
17902 vl_api_ipsec_gre_add_del_tunnel_t *mp;
17903 u32 local_sa_id = 0;
17904 u32 remote_sa_id = 0;
17905 ip4_address_t src_address;
17906 ip4_address_t dst_address;
17910 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17912 if (unformat (i, "local_sa %d", &local_sa_id))
17914 else if (unformat (i, "remote_sa %d", &remote_sa_id))
17916 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
17918 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
17920 else if (unformat (i, "del"))
17924 clib_warning ("parse error '%U'", format_unformat_error, i);
17929 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
17931 mp->local_sa_id = ntohl (local_sa_id);
17932 mp->remote_sa_id = ntohl (remote_sa_id);
17933 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
17934 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
17935 mp->is_add = is_add;
17943 api_punt (vat_main_t * vam)
17945 unformat_input_t *i = vam->input;
17953 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17955 if (unformat (i, "ip %d", &ipv))
17957 else if (unformat (i, "protocol %d", &protocol))
17959 else if (unformat (i, "port %d", &port))
17961 else if (unformat (i, "del"))
17965 clib_warning ("parse error '%U'", format_unformat_error, i);
17972 mp->is_add = (u8) is_add;
17973 mp->ipv = (u8) ipv;
17974 mp->l4_protocol = (u8) protocol;
17975 mp->l4_port = htons ((u16) port);
17982 static void vl_api_ipsec_gre_tunnel_details_t_handler
17983 (vl_api_ipsec_gre_tunnel_details_t * mp)
17985 vat_main_t *vam = &vat_main;
17987 print (vam->ofp, "%11d%15U%15U%14d%14d",
17988 ntohl (mp->sw_if_index),
17989 format_ip4_address, &mp->src_address,
17990 format_ip4_address, &mp->dst_address,
17991 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
17994 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
17995 (vl_api_ipsec_gre_tunnel_details_t * mp)
17997 vat_main_t *vam = &vat_main;
17998 vat_json_node_t *node = NULL;
17999 struct in_addr ip4;
18001 if (VAT_JSON_ARRAY != vam->json_tree.type)
18003 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18004 vat_json_init_array (&vam->json_tree);
18006 node = vat_json_array_add (&vam->json_tree);
18008 vat_json_init_object (node);
18009 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18010 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
18011 vat_json_object_add_ip4 (node, "src_address", ip4);
18012 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
18013 vat_json_object_add_ip4 (node, "dst_address", ip4);
18014 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
18015 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
18019 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
18021 unformat_input_t *i = vam->input;
18022 vl_api_ipsec_gre_tunnel_dump_t *mp;
18023 vl_api_control_ping_t *mp_ping;
18025 u8 sw_if_index_set = 0;
18028 /* Parse args required to build the message */
18029 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18031 if (unformat (i, "sw_if_index %d", &sw_if_index))
18032 sw_if_index_set = 1;
18037 if (sw_if_index_set == 0)
18042 if (!vam->json_output)
18044 print (vam->ofp, "%11s%15s%15s%14s%14s",
18045 "sw_if_index", "src_address", "dst_address",
18046 "local_sa_id", "remote_sa_id");
18049 /* Get list of gre-tunnel interfaces */
18050 M (IPSEC_GRE_TUNNEL_DUMP, mp);
18052 mp->sw_if_index = htonl (sw_if_index);
18056 /* Use a control ping for synchronization */
18057 M (CONTROL_PING, mp_ping);
18065 api_delete_subif (vat_main_t * vam)
18067 unformat_input_t *i = vam->input;
18068 vl_api_delete_subif_t *mp;
18069 u32 sw_if_index = ~0;
18072 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18074 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18076 if (unformat (i, "sw_if_index %d", &sw_if_index))
18082 if (sw_if_index == ~0)
18084 errmsg ("missing sw_if_index");
18088 /* Construct the API message */
18089 M (DELETE_SUBIF, mp);
18090 mp->sw_if_index = ntohl (sw_if_index);
18097 #define foreach_pbb_vtr_op \
18098 _("disable", L2_VTR_DISABLED) \
18099 _("pop", L2_VTR_POP_2) \
18100 _("push", L2_VTR_PUSH_2)
18103 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
18105 unformat_input_t *i = vam->input;
18106 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
18107 u32 sw_if_index = ~0, vtr_op = ~0;
18108 u16 outer_tag = ~0;
18109 u8 dmac[6], smac[6];
18110 u8 dmac_set = 0, smac_set = 0;
18116 /* Shut up coverity */
18117 memset (dmac, 0, sizeof (dmac));
18118 memset (smac, 0, sizeof (smac));
18120 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18122 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18124 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18126 else if (unformat (i, "vtr_op %d", &vtr_op))
18128 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
18131 else if (unformat (i, "translate_pbb_stag"))
18133 if (unformat (i, "%d", &tmp))
18135 vtr_op = L2_VTR_TRANSLATE_2_1;
18141 ("translate_pbb_stag operation requires outer tag definition");
18145 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
18147 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
18149 else if (unformat (i, "sid %d", &sid))
18151 else if (unformat (i, "vlanid %d", &tmp))
18155 clib_warning ("parse error '%U'", format_unformat_error, i);
18160 if ((sw_if_index == ~0) || (vtr_op == ~0))
18162 errmsg ("missing sw_if_index or vtr operation");
18165 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
18166 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
18169 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
18173 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
18174 mp->sw_if_index = ntohl (sw_if_index);
18175 mp->vtr_op = ntohl (vtr_op);
18176 mp->outer_tag = ntohs (outer_tag);
18177 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
18178 clib_memcpy (mp->b_smac, smac, sizeof (smac));
18179 mp->b_vlanid = ntohs (vlanid);
18180 mp->i_sid = ntohl (sid);
18188 api_flow_classify_set_interface (vat_main_t * vam)
18190 unformat_input_t *i = vam->input;
18191 vl_api_flow_classify_set_interface_t *mp;
18193 int sw_if_index_set;
18194 u32 ip4_table_index = ~0;
18195 u32 ip6_table_index = ~0;
18199 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18201 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18202 sw_if_index_set = 1;
18203 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18204 sw_if_index_set = 1;
18205 else if (unformat (i, "del"))
18207 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18209 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18213 clib_warning ("parse error '%U'", format_unformat_error, i);
18218 if (sw_if_index_set == 0)
18220 errmsg ("missing interface name or sw_if_index");
18224 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
18226 mp->sw_if_index = ntohl (sw_if_index);
18227 mp->ip4_table_index = ntohl (ip4_table_index);
18228 mp->ip6_table_index = ntohl (ip6_table_index);
18229 mp->is_add = is_add;
18237 api_flow_classify_dump (vat_main_t * vam)
18239 unformat_input_t *i = vam->input;
18240 vl_api_flow_classify_dump_t *mp;
18241 vl_api_control_ping_t *mp_ping;
18242 u8 type = FLOW_CLASSIFY_N_TABLES;
18245 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
18249 errmsg ("classify table type must be specified");
18253 if (!vam->json_output)
18255 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18258 M (FLOW_CLASSIFY_DUMP, mp);
18263 /* Use a control ping for synchronization */
18264 M (CONTROL_PING, mp_ping);
18267 /* Wait for a reply... */
18273 api_feature_enable_disable (vat_main_t * vam)
18275 unformat_input_t *i = vam->input;
18276 vl_api_feature_enable_disable_t *mp;
18278 u8 *feature_name = 0;
18279 u32 sw_if_index = ~0;
18283 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18285 if (unformat (i, "arc_name %s", &arc_name))
18287 else if (unformat (i, "feature_name %s", &feature_name))
18290 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18292 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18294 else if (unformat (i, "disable"))
18302 errmsg ("missing arc name");
18305 if (vec_len (arc_name) > 63)
18307 errmsg ("arc name too long");
18310 if (feature_name == 0)
18312 errmsg ("missing feature name");
18315 if (vec_len (feature_name) > 63)
18317 errmsg ("feature name too long");
18320 if (sw_if_index == ~0)
18322 errmsg ("missing interface name or sw_if_index");
18326 /* Construct the API message */
18327 M (FEATURE_ENABLE_DISABLE, mp);
18328 mp->sw_if_index = ntohl (sw_if_index);
18329 mp->enable = enable;
18330 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
18331 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
18332 vec_free (arc_name);
18333 vec_free (feature_name);
18341 api_sw_interface_tag_add_del (vat_main_t * vam)
18343 unformat_input_t *i = vam->input;
18344 vl_api_sw_interface_tag_add_del_t *mp;
18345 u32 sw_if_index = ~0;
18350 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18352 if (unformat (i, "tag %s", &tag))
18354 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18356 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18358 else if (unformat (i, "del"))
18364 if (sw_if_index == ~0)
18366 errmsg ("missing interface name or sw_if_index");
18370 if (enable && (tag == 0))
18372 errmsg ("no tag specified");
18376 /* Construct the API message */
18377 M (SW_INTERFACE_TAG_ADD_DEL, mp);
18378 mp->sw_if_index = ntohl (sw_if_index);
18379 mp->is_add = enable;
18381 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
18389 static void vl_api_l2_xconnect_details_t_handler
18390 (vl_api_l2_xconnect_details_t * mp)
18392 vat_main_t *vam = &vat_main;
18394 print (vam->ofp, "%15d%15d",
18395 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
18398 static void vl_api_l2_xconnect_details_t_handler_json
18399 (vl_api_l2_xconnect_details_t * mp)
18401 vat_main_t *vam = &vat_main;
18402 vat_json_node_t *node = NULL;
18404 if (VAT_JSON_ARRAY != vam->json_tree.type)
18406 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18407 vat_json_init_array (&vam->json_tree);
18409 node = vat_json_array_add (&vam->json_tree);
18411 vat_json_init_object (node);
18412 vat_json_object_add_uint (node, "rx_sw_if_index",
18413 ntohl (mp->rx_sw_if_index));
18414 vat_json_object_add_uint (node, "tx_sw_if_index",
18415 ntohl (mp->tx_sw_if_index));
18419 api_l2_xconnect_dump (vat_main_t * vam)
18421 vl_api_l2_xconnect_dump_t *mp;
18422 vl_api_control_ping_t *mp_ping;
18425 if (!vam->json_output)
18427 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
18430 M (L2_XCONNECT_DUMP, mp);
18434 /* Use a control ping for synchronization */
18435 M (CONTROL_PING, mp_ping);
18443 api_sw_interface_set_mtu (vat_main_t * vam)
18445 unformat_input_t *i = vam->input;
18446 vl_api_sw_interface_set_mtu_t *mp;
18447 u32 sw_if_index = ~0;
18451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18453 if (unformat (i, "mtu %d", &mtu))
18455 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18457 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18463 if (sw_if_index == ~0)
18465 errmsg ("missing interface name or sw_if_index");
18471 errmsg ("no mtu specified");
18475 /* Construct the API message */
18476 M (SW_INTERFACE_SET_MTU, mp);
18477 mp->sw_if_index = ntohl (sw_if_index);
18478 mp->mtu = ntohs ((u16) mtu);
18487 q_or_quit (vat_main_t * vam)
18489 #if VPP_API_TEST_BUILTIN == 0
18490 longjmp (vam->jump_buf, 1);
18492 return 0; /* not so much */
18496 q (vat_main_t * vam)
18498 return q_or_quit (vam);
18502 quit (vat_main_t * vam)
18504 return q_or_quit (vam);
18508 comment (vat_main_t * vam)
18514 cmd_cmp (void *a1, void *a2)
18519 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
18523 help (vat_main_t * vam)
18528 unformat_input_t *i = vam->input;
18531 if (unformat (i, "%s", &name))
18535 vec_add1 (name, 0);
18537 hs = hash_get_mem (vam->help_by_name, name);
18539 print (vam->ofp, "usage: %s %s", name, hs[0]);
18541 print (vam->ofp, "No such msg / command '%s'", name);
18546 print (vam->ofp, "Help is available for the following:");
18549 hash_foreach_pair (p, vam->function_by_name,
18551 vec_add1 (cmds, (u8 *)(p->key));
18555 vec_sort_with_function (cmds, cmd_cmp);
18557 for (j = 0; j < vec_len (cmds); j++)
18558 print (vam->ofp, "%s", cmds[j]);
18565 set (vat_main_t * vam)
18567 u8 *name = 0, *value = 0;
18568 unformat_input_t *i = vam->input;
18570 if (unformat (i, "%s", &name))
18572 /* The input buffer is a vector, not a string. */
18573 value = vec_dup (i->buffer);
18574 vec_delete (value, i->index, 0);
18575 /* Almost certainly has a trailing newline */
18576 if (value[vec_len (value) - 1] == '\n')
18577 value[vec_len (value) - 1] = 0;
18578 /* Make sure it's a proper string, one way or the other */
18579 vec_add1 (value, 0);
18580 (void) clib_macro_set_value (&vam->macro_main,
18581 (char *) name, (char *) value);
18584 errmsg ("usage: set <name> <value>");
18592 unset (vat_main_t * vam)
18596 if (unformat (vam->input, "%s", &name))
18597 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
18598 errmsg ("unset: %s wasn't set", name);
18611 macro_sort_cmp (void *a1, void *a2)
18613 macro_sort_t *s1 = a1;
18614 macro_sort_t *s2 = a2;
18616 return strcmp ((char *) (s1->name), (char *) (s2->name));
18620 dump_macro_table (vat_main_t * vam)
18622 macro_sort_t *sort_me = 0, *sm;
18627 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
18629 vec_add2 (sort_me, sm, 1);
18630 sm->name = (u8 *)(p->key);
18631 sm->value = (u8 *) (p->value[0]);
18635 vec_sort_with_function (sort_me, macro_sort_cmp);
18637 if (vec_len (sort_me))
18638 print (vam->ofp, "%-15s%s", "Name", "Value");
18640 print (vam->ofp, "The macro table is empty...");
18642 for (i = 0; i < vec_len (sort_me); i++)
18643 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
18648 dump_node_table (vat_main_t * vam)
18651 vlib_node_t *node, *next_node;
18653 if (vec_len (vam->graph_nodes) == 0)
18655 print (vam->ofp, "Node table empty, issue get_node_graph...");
18659 for (i = 0; i < vec_len (vam->graph_nodes); i++)
18661 node = vam->graph_nodes[i];
18662 print (vam->ofp, "[%d] %s", i, node->name);
18663 for (j = 0; j < vec_len (node->next_nodes); j++)
18665 if (node->next_nodes[j] != ~0)
18667 next_node = vam->graph_nodes[node->next_nodes[j]];
18668 print (vam->ofp, " [%d] %s", j, next_node->name);
18676 value_sort_cmp (void *a1, void *a2)
18678 name_sort_t *n1 = a1;
18679 name_sort_t *n2 = a2;
18681 if (n1->value < n2->value)
18683 if (n1->value > n2->value)
18690 dump_msg_api_table (vat_main_t * vam)
18692 api_main_t *am = &api_main;
18693 name_sort_t *nses = 0, *ns;
18698 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
18700 vec_add2 (nses, ns, 1);
18701 ns->name = (u8 *)(hp->key);
18702 ns->value = (u32) hp->value[0];
18706 vec_sort_with_function (nses, value_sort_cmp);
18708 for (i = 0; i < vec_len (nses); i++)
18709 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
18715 get_msg_id (vat_main_t * vam)
18720 if (unformat (vam->input, "%s", &name_and_crc))
18722 message_index = vl_api_get_msg_index (name_and_crc);
18723 if (message_index == ~0)
18725 print (vam->ofp, " '%s' not found", name_and_crc);
18728 print (vam->ofp, " '%s' has message index %d",
18729 name_and_crc, message_index);
18732 errmsg ("name_and_crc required...");
18737 search_node_table (vat_main_t * vam)
18739 unformat_input_t *line_input = vam->input;
18742 vlib_node_t *node, *next_node;
18745 if (vam->graph_node_index_by_name == 0)
18747 print (vam->ofp, "Node table empty, issue get_node_graph...");
18751 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
18753 if (unformat (line_input, "%s", &node_to_find))
18755 vec_add1 (node_to_find, 0);
18756 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
18759 print (vam->ofp, "%s not found...", node_to_find);
18762 node = vam->graph_nodes[p[0]];
18763 print (vam->ofp, "[%d] %s", p[0], node->name);
18764 for (j = 0; j < vec_len (node->next_nodes); j++)
18766 if (node->next_nodes[j] != ~0)
18768 next_node = vam->graph_nodes[node->next_nodes[j]];
18769 print (vam->ofp, " [%d] %s", j, next_node->name);
18776 clib_warning ("parse error '%U'", format_unformat_error,
18782 vec_free (node_to_find);
18791 script (vat_main_t * vam)
18793 #if (VPP_API_TEST_BUILTIN==0)
18795 char *save_current_file;
18796 unformat_input_t save_input;
18797 jmp_buf save_jump_buf;
18798 u32 save_line_number;
18800 FILE *new_fp, *save_ifp;
18802 if (unformat (vam->input, "%s", &s))
18804 new_fp = fopen ((char *) s, "r");
18807 errmsg ("Couldn't open script file %s", s);
18814 errmsg ("Missing script name");
18818 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
18819 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
18820 save_ifp = vam->ifp;
18821 save_line_number = vam->input_line_number;
18822 save_current_file = (char *) vam->current_file;
18824 vam->input_line_number = 0;
18826 vam->current_file = s;
18829 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
18830 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
18831 vam->ifp = save_ifp;
18832 vam->input_line_number = save_line_number;
18833 vam->current_file = (u8 *) save_current_file;
18838 clib_warning ("use the exec command...");
18844 echo (vat_main_t * vam)
18846 print (vam->ofp, "%v", vam->input->buffer);
18850 /* List of API message constructors, CLI names map to api_xxx */
18851 #define foreach_vpe_api_msg \
18852 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
18853 _(sw_interface_dump,"") \
18854 _(sw_interface_set_flags, \
18855 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
18856 _(sw_interface_add_del_address, \
18857 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
18858 _(sw_interface_set_table, \
18859 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
18860 _(sw_interface_set_mpls_enable, \
18861 "<intfc> | sw_if_index [disable | dis]") \
18862 _(sw_interface_set_vpath, \
18863 "<intfc> | sw_if_index <id> enable | disable") \
18864 _(sw_interface_set_vxlan_bypass, \
18865 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
18866 _(sw_interface_set_l2_xconnect, \
18867 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18868 "enable | disable") \
18869 _(sw_interface_set_l2_bridge, \
18870 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
18871 "[shg <split-horizon-group>] [bvi]\n" \
18872 "enable | disable") \
18873 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
18874 _(bridge_domain_add_del, \
18875 "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") \
18876 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
18878 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
18879 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
18880 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
18882 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
18884 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
18886 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
18888 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
18890 "<vpp-if-name> | sw_if_index <id>") \
18891 _(sw_interface_tap_dump, "") \
18892 _(ip_add_del_route, \
18893 "<addr>/<mask> via <addr> [table-id <n>]\n" \
18894 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18895 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18896 "[multipath] [count <n>]") \
18897 _(ip_mroute_add_del, \
18898 "<src> <grp>/<mask> [table-id <n>]\n" \
18899 "[<intfc> | sw_if_index <id>] [local] [del]") \
18900 _(mpls_route_add_del, \
18901 "<label> <eos> via <addr> [table-id <n>]\n" \
18902 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18903 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18904 "[multipath] [count <n>]") \
18905 _(mpls_ip_bind_unbind, \
18906 "<label> <addr/len>") \
18907 _(mpls_tunnel_add_del, \
18908 " via <addr> [table-id <n>]\n" \
18909 "sw_if_index <id>] [l2] [del]") \
18910 _(proxy_arp_add_del, \
18911 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
18912 _(proxy_arp_intfc_enable_disable, \
18913 "<intfc> | sw_if_index <id> enable | disable") \
18914 _(sw_interface_set_unnumbered, \
18915 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
18916 _(ip_neighbor_add_del, \
18917 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
18918 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
18919 _(reset_vrf, "vrf <id> [ipv6]") \
18920 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
18921 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
18922 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
18923 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
18924 "[outer_vlan_id_any][inner_vlan_id_any]") \
18925 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
18926 _(reset_fib, "vrf <n> [ipv6]") \
18927 _(dhcp_proxy_config, \
18928 "svr <v46-address> src <v46-address>\n" \
18929 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
18930 _(dhcp_proxy_set_vss, \
18931 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
18932 _(dhcp_proxy_dump, "ip6") \
18933 _(dhcp_client_config, \
18934 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
18935 _(set_ip_flow_hash, \
18936 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
18937 _(sw_interface_ip6_enable_disable, \
18938 "<intfc> | sw_if_index <id> enable | disable") \
18939 _(sw_interface_ip6_set_link_local_address, \
18940 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
18941 _(ip6nd_proxy_add_del, \
18942 "<intfc> | sw_if_index <id> <ip6-address>") \
18943 _(ip6nd_proxy_dump, "") \
18944 _(sw_interface_ip6nd_ra_prefix, \
18945 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
18946 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
18947 "[nolink] [isno]") \
18948 _(sw_interface_ip6nd_ra_config, \
18949 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
18950 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
18951 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
18952 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
18953 _(l2_patch_add_del, \
18954 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18955 "enable | disable") \
18956 _(sr_localsid_add_del, \
18957 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
18958 "fib-table <num> (end.psp) sw_if_index <num>") \
18959 _(classify_add_del_table, \
18960 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
18961 " [del] [del-chain] mask <mask-value>\n" \
18962 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
18963 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
18964 _(classify_add_del_session, \
18965 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
18966 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
18967 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
18968 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
18969 _(classify_set_interface_ip_table, \
18970 "<intfc> | sw_if_index <nn> table <nn>") \
18971 _(classify_set_interface_l2_tables, \
18972 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18973 " [other-table <nn>]") \
18974 _(get_node_index, "node <node-name") \
18975 _(add_node_next, "node <node-name> next <next-node-name>") \
18976 _(l2tpv3_create_tunnel, \
18977 "client_address <ip6-addr> our_address <ip6-addr>\n" \
18978 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
18979 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
18980 _(l2tpv3_set_tunnel_cookies, \
18981 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
18982 "[new_remote_cookie <nn>]\n") \
18983 _(l2tpv3_interface_enable_disable, \
18984 "<intfc> | sw_if_index <nn> enable | disable") \
18985 _(l2tpv3_set_lookup_key, \
18986 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
18987 _(sw_if_l2tpv3_tunnel_dump, "") \
18988 _(vxlan_add_del_tunnel, \
18989 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
18990 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
18991 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
18992 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18993 _(gre_add_del_tunnel, \
18994 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
18995 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18996 _(l2_fib_clear_table, "") \
18997 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
18998 _(l2_interface_vlan_tag_rewrite, \
18999 "<intfc> | sw_if_index <nn> \n" \
19000 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
19001 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
19002 _(create_vhost_user_if, \
19003 "socket <filename> [server] [renumber <dev_instance>] " \
19004 "[mac <mac_address>] " \
19005 "[mode <interrupt | polling>]") \
19006 _(modify_vhost_user_if, \
19007 "<intfc> | sw_if_index <nn> socket <filename>\n" \
19008 "[server] [renumber <dev_instance>] " \
19009 "[mode <interrupt | polling>]") \
19010 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
19011 _(sw_interface_vhost_user_dump, "") \
19012 _(show_version, "") \
19013 _(vxlan_gpe_add_del_tunnel, \
19014 "local <addr> remote <addr> vni <nn>\n" \
19015 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
19016 "[next-ethernet] [next-nsh]\n") \
19017 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
19018 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
19019 _(interface_name_renumber, \
19020 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
19021 _(input_acl_set_interface, \
19022 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19023 " [l2-table <nn>] [del]") \
19024 _(want_ip4_arp_events, "address <ip4-address> [del]") \
19025 _(want_ip6_nd_events, "address <ip6-address> [del]") \
19026 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
19027 _(ip_dump, "ipv4 | ipv6") \
19028 _(ipsec_spd_add_del, "spd_id <n> [del]") \
19029 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
19031 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
19032 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
19033 " integ_alg <alg> integ_key <hex>") \
19034 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
19035 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
19036 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
19037 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
19038 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
19039 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
19040 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
19041 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
19042 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
19043 _(ikev2_profile_add_del, "name <profile_name> [del]") \
19044 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
19045 "(auth_data 0x<data> | auth_data <data>)") \
19046 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
19047 "(id_data 0x<data> | id_data <data>) (local|remote)") \
19048 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
19049 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
19050 "(local|remote)") \
19051 _(ikev2_set_local_key, "file <absolute_file_path>") \
19052 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
19053 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
19054 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
19055 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
19056 _(ikev2_initiate_sa_init, "<profile_name>") \
19057 _(ikev2_initiate_del_ike_sa, "<ispi>") \
19058 _(ikev2_initiate_del_child_sa, "<ispi>") \
19059 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
19060 _(delete_loopback,"sw_if_index <nn>") \
19061 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
19062 _(map_add_domain, \
19063 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
19064 "ip6-src <ip6addr> " \
19065 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
19066 _(map_del_domain, "index <n>") \
19067 _(map_add_del_rule, \
19068 "index <n> psid <n> dst <ip6addr> [del]") \
19069 _(map_domain_dump, "") \
19070 _(map_rule_dump, "index <map-domain>") \
19071 _(want_interface_events, "enable|disable") \
19072 _(want_stats,"enable|disable") \
19073 _(get_first_msg_id, "client <name>") \
19074 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
19075 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
19076 "fib-id <nn> [ip4][ip6][default]") \
19077 _(get_node_graph, " ") \
19078 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
19079 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
19080 _(ioam_disable, "") \
19081 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
19082 " sw_if_index <sw_if_index> p <priority> " \
19083 "w <weight>] [del]") \
19084 _(one_add_del_locator, "locator-set <locator_name> " \
19085 "iface <intf> | sw_if_index <sw_if_index> " \
19086 "p <priority> w <weight> [del]") \
19087 _(one_add_del_local_eid,"vni <vni> eid " \
19088 "<ipv4|ipv6>/<prefix> | <L2 address> " \
19089 "locator-set <locator_name> [del]" \
19090 "[key-id sha1|sha256 secret-key <secret-key>]")\
19091 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
19092 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
19093 _(one_enable_disable, "enable|disable") \
19094 _(one_map_register_enable_disable, "enable|disable") \
19095 _(one_rloc_probe_enable_disable, "enable|disable") \
19096 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
19098 "rloc <locator> p <prio> " \
19099 "w <weight> [rloc <loc> ... ] " \
19100 "action <action> [del-all]") \
19101 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
19103 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
19104 _(one_use_petr, "ip-address> | disable") \
19105 _(one_map_request_mode, "src-dst|dst-only") \
19106 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
19107 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
19108 _(one_locator_set_dump, "[local | remote]") \
19109 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
19110 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
19111 "[local] | [remote]") \
19112 _(one_stats_enable_disable, "enable|disalbe") \
19113 _(show_one_stats_enable_disable, "") \
19114 _(one_eid_table_vni_dump, "") \
19115 _(one_eid_table_map_dump, "l2|l3") \
19116 _(one_map_resolver_dump, "") \
19117 _(one_map_server_dump, "") \
19118 _(one_adjacencies_get, "vni <vni>") \
19119 _(show_one_rloc_probe_state, "") \
19120 _(show_one_map_register_state, "") \
19121 _(show_one_status, "") \
19122 _(one_stats_dump, "") \
19123 _(one_stats_flush, "") \
19124 _(one_get_map_request_itr_rlocs, "") \
19125 _(show_one_pitr, "") \
19126 _(show_one_use_petr, "") \
19127 _(show_one_map_request_mode, "") \
19128 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
19129 " sw_if_index <sw_if_index> p <priority> " \
19130 "w <weight>] [del]") \
19131 _(lisp_add_del_locator, "locator-set <locator_name> " \
19132 "iface <intf> | sw_if_index <sw_if_index> " \
19133 "p <priority> w <weight> [del]") \
19134 _(lisp_add_del_local_eid,"vni <vni> eid " \
19135 "<ipv4|ipv6>/<prefix> | <L2 address> " \
19136 "locator-set <locator_name> [del]" \
19137 "[key-id sha1|sha256 secret-key <secret-key>]") \
19138 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
19139 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
19140 _(lisp_enable_disable, "enable|disable") \
19141 _(lisp_map_register_enable_disable, "enable|disable") \
19142 _(lisp_rloc_probe_enable_disable, "enable|disable") \
19143 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
19145 "rloc <locator> p <prio> " \
19146 "w <weight> [rloc <loc> ... ] " \
19147 "action <action> [del-all]") \
19148 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
19150 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
19151 _(lisp_use_petr, "<ip-address> | disable") \
19152 _(lisp_map_request_mode, "src-dst|dst-only") \
19153 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
19154 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
19155 _(lisp_locator_set_dump, "[local | remote]") \
19156 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
19157 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
19158 "[local] | [remote]") \
19159 _(lisp_eid_table_vni_dump, "") \
19160 _(lisp_eid_table_map_dump, "l2|l3") \
19161 _(lisp_map_resolver_dump, "") \
19162 _(lisp_map_server_dump, "") \
19163 _(lisp_adjacencies_get, "vni <vni>") \
19164 _(gpe_fwd_entry_vnis_get, "") \
19165 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
19166 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
19167 _(gpe_set_encap_mode, "lisp|vxlan") \
19168 _(gpe_get_encap_mode, "") \
19169 _(lisp_gpe_add_del_iface, "up|down") \
19170 _(lisp_gpe_enable_disable, "enable|disable") \
19171 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
19172 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
19173 _(show_lisp_rloc_probe_state, "") \
19174 _(show_lisp_map_register_state, "") \
19175 _(show_lisp_status, "") \
19176 _(lisp_get_map_request_itr_rlocs, "") \
19177 _(show_lisp_pitr, "") \
19178 _(show_lisp_use_petr, "") \
19179 _(show_lisp_map_request_mode, "") \
19180 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
19181 _(af_packet_delete, "name <host interface name>") \
19182 _(policer_add_del, "name <policer name> <params> [del]") \
19183 _(policer_dump, "[name <policer name>]") \
19184 _(policer_classify_set_interface, \
19185 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
19186 " [l2-table <nn>] [del]") \
19187 _(policer_classify_dump, "type [ip4|ip6|l2]") \
19188 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
19189 "[master|slave]") \
19190 _(netmap_delete, "name <interface name>") \
19191 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
19192 _(mpls_fib_dump, "") \
19193 _(classify_table_ids, "") \
19194 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
19195 _(classify_table_info, "table_id <nn>") \
19196 _(classify_session_dump, "table_id <nn>") \
19197 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
19198 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
19199 "[template_interval <nn>] [udp_checksum]") \
19200 _(ipfix_exporter_dump, "") \
19201 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
19202 _(ipfix_classify_stream_dump, "") \
19203 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
19204 _(ipfix_classify_table_dump, "") \
19205 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
19206 _(sw_interface_span_dump, "") \
19207 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
19208 _(pg_create_interface, "if_id <nn>") \
19209 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
19210 _(pg_enable_disable, "[stream <id>] disable") \
19211 _(ip_source_and_port_range_check_add_del, \
19212 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
19213 _(ip_source_and_port_range_check_interface_add_del, \
19214 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
19215 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
19216 _(ipsec_gre_add_del_tunnel, \
19217 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
19218 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
19219 _(delete_subif,"<intfc> | sw_if_index <nn>") \
19220 _(l2_interface_pbb_tag_rewrite, \
19221 "<intfc> | sw_if_index <nn> \n" \
19222 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
19223 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
19224 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
19225 _(flow_classify_set_interface, \
19226 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
19227 _(flow_classify_dump, "type [ip4|ip6]") \
19228 _(ip_fib_dump, "") \
19229 _(ip_mfib_dump, "") \
19230 _(ip6_fib_dump, "") \
19231 _(ip6_mfib_dump, "") \
19232 _(feature_enable_disable, "arc_name <arc_name> " \
19233 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
19234 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
19236 _(l2_xconnect_dump, "") \
19237 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
19238 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
19239 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
19241 /* List of command functions, CLI names map directly to functions */
19242 #define foreach_cli_function \
19243 _(comment, "usage: comment <ignore-rest-of-line>") \
19244 _(dump_interface_table, "usage: dump_interface_table") \
19245 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
19246 _(dump_ipv4_table, "usage: dump_ipv4_table") \
19247 _(dump_ipv6_table, "usage: dump_ipv6_table") \
19248 _(dump_stats_table, "usage: dump_stats_table") \
19249 _(dump_macro_table, "usage: dump_macro_table ") \
19250 _(dump_node_table, "usage: dump_node_table") \
19251 _(dump_msg_api_table, "usage: dump_msg_api_table") \
19252 _(get_msg_id, "usage: get_msg_id name_and_crc") \
19253 _(echo, "usage: echo <message>") \
19254 _(exec, "usage: exec <vpe-debug-CLI-command>") \
19255 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
19256 _(help, "usage: help") \
19257 _(q, "usage: quit") \
19258 _(quit, "usage: quit") \
19259 _(search_node_table, "usage: search_node_table <name>...") \
19260 _(set, "usage: set <variable-name> <value>") \
19261 _(script, "usage: script <file-name>") \
19262 _(unset, "usage: unset <variable-name>")
19265 static void vl_api_##n##_t_handler_uni \
19266 (vl_api_##n##_t * mp) \
19268 vat_main_t * vam = &vat_main; \
19269 if (vam->json_output) { \
19270 vl_api_##n##_t_handler_json(mp); \
19272 vl_api_##n##_t_handler(mp); \
19275 foreach_vpe_api_reply_msg;
19276 #if VPP_API_TEST_BUILTIN == 0
19277 foreach_standalone_reply_msg;
19282 vat_api_hookup (vat_main_t * vam)
19285 vl_msg_api_set_handlers(VL_API_##N, #n, \
19286 vl_api_##n##_t_handler_uni, \
19288 vl_api_##n##_t_endian, \
19289 vl_api_##n##_t_print, \
19290 sizeof(vl_api_##n##_t), 1);
19291 foreach_vpe_api_reply_msg;
19292 #if VPP_API_TEST_BUILTIN == 0
19293 foreach_standalone_reply_msg;
19297 #if (VPP_API_TEST_BUILTIN==0)
19298 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
19300 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
19302 vam->function_by_name = hash_create_string (0, sizeof (uword));
19304 vam->help_by_name = hash_create_string (0, sizeof (uword));
19307 /* API messages we can send */
19308 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
19309 foreach_vpe_api_msg;
19313 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
19314 foreach_vpe_api_msg;
19317 /* CLI functions */
19318 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
19319 foreach_cli_function;
19323 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
19324 foreach_cli_function;
19328 #if VPP_API_TEST_BUILTIN
19329 static clib_error_t *
19330 vat_api_hookup_shim (vlib_main_t * vm)
19332 vat_api_hookup (&vat_main);
19336 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
19340 * fd.io coding-style-patch-verification: ON
19343 * eval: (c-set-style "gnu")