2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vlibapi/api.h>
22 #include <vlibmemory/api.h>
23 #include <vlibsocket/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/l2/l2_input.h>
26 #include <vnet/l2tp/l2tp.h>
27 #include <vnet/vxlan/vxlan.h>
28 #include <vnet/gre/gre.h>
29 #include <vnet/vxlan-gpe/vxlan_gpe.h>
30 #include <vnet/lisp-gpe/lisp_gpe.h>
32 #include <vpp/api/vpe_msg_enum.h>
33 #include <vnet/l2/l2_classify.h>
34 #include <vnet/l2/l2_vtr.h>
35 #include <vnet/classify/input_acl.h>
36 #include <vnet/classify/policer_classify.h>
37 #include <vnet/classify/flow_classify.h>
38 #include <vnet/mpls/mpls.h>
39 #include <vnet/ipsec/ipsec.h>
40 #include <vnet/ipsec/ikev2.h>
42 #include <vnet/map/map.h>
43 #include <vnet/cop/cop.h>
44 #include <vnet/ip/ip6_hop_by_hop.h>
45 #include <vnet/ip/ip_source_and_port_range_check.h>
46 #include <vnet/policer/xlate.h>
47 #include <vnet/span/span.h>
48 #include <vnet/policer/policer.h>
49 #include <vnet/policer/police.h>
50 #include <vnet/mfib/mfib_types.h>
52 #include "vat/json_format.h"
57 #define vl_typedefs /* define message structures */
58 #include <vpp/api/vpe_all_api_h.h>
61 /* declare message handlers for each api */
63 #define vl_endianfun /* define message structures */
64 #include <vpp/api/vpe_all_api_h.h>
67 /* instantiate all the print functions we know about */
68 #define vl_print(handle, ...)
70 #include <vpp/api/vpe_all_api_h.h>
73 #define __plugin_msg_base 0
74 #include <vlibapi/vat_helper_macros.h>
77 vat_time_now (vat_main_t * vam)
79 #if VPP_API_TEST_BUILTIN
80 return vlib_time_now (vam->vlib_main);
82 return clib_time_now (&vam->clib_time);
87 errmsg (char *fmt, ...)
89 vat_main_t *vam = &vat_main;
94 s = va_format (0, fmt, &va);
99 #if VPP_API_TEST_BUILTIN
100 vlib_cli_output (vam->vlib_main, (char *) s);
103 if (vam->ifp != stdin)
104 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
105 vam->input_line_number);
106 fformat (vam->ofp, (char *) s);
114 #if VPP_API_TEST_BUILTIN == 0
116 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
118 vat_main_t *vam = va_arg (*args, vat_main_t *);
119 u32 *result = va_arg (*args, u32 *);
123 if (!unformat (input, "%s", &if_name))
126 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
133 /* Parse an IP4 address %d.%d.%d.%d. */
135 unformat_ip4_address (unformat_input_t * input, va_list * args)
137 u8 *result = va_arg (*args, u8 *);
140 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
143 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
155 unformat_ethernet_address (unformat_input_t * input, va_list * args)
157 u8 *result = va_arg (*args, u8 *);
160 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
161 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
165 for (i = 0; i < 6; i++)
166 if (a[i] >= (1 << 8))
169 for (i = 0; i < 6; i++)
175 /* Returns ethernet type as an int in host byte order. */
177 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
180 u16 *result = va_arg (*args, u16 *);
184 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
186 if (type >= (1 << 16))
194 /* Parse an IP6 address. */
196 unformat_ip6_address (unformat_input_t * input, va_list * args)
198 ip6_address_t *result = va_arg (*args, ip6_address_t *);
200 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
201 uword c, n_colon, double_colon_index;
203 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
204 double_colon_index = ARRAY_LEN (hex_quads);
205 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
208 if (c >= '0' && c <= '9')
210 else if (c >= 'a' && c <= 'f')
211 hex_digit = c + 10 - 'a';
212 else if (c >= 'A' && c <= 'F')
213 hex_digit = c + 10 - 'A';
214 else if (c == ':' && n_colon < 2)
218 unformat_put_input (input);
222 /* Too many hex quads. */
223 if (n_hex_quads >= ARRAY_LEN (hex_quads))
228 hex_quad = (hex_quad << 4) | hex_digit;
230 /* Hex quad must fit in 16 bits. */
231 if (n_hex_digits >= 4)
238 /* Save position of :: */
241 /* More than one :: ? */
242 if (double_colon_index < ARRAY_LEN (hex_quads))
244 double_colon_index = n_hex_quads;
247 if (n_colon > 0 && n_hex_digits > 0)
249 hex_quads[n_hex_quads++] = hex_quad;
255 if (n_hex_digits > 0)
256 hex_quads[n_hex_quads++] = hex_quad;
261 /* Expand :: to appropriate number of zero hex quads. */
262 if (double_colon_index < ARRAY_LEN (hex_quads))
264 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
266 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
267 hex_quads[n_zero + i] = hex_quads[i];
269 for (i = 0; i < n_zero; i++)
270 hex_quads[double_colon_index + i] = 0;
272 n_hex_quads = ARRAY_LEN (hex_quads);
275 /* Too few hex quads given. */
276 if (n_hex_quads < ARRAY_LEN (hex_quads))
279 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
280 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
287 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
289 u32 *r = va_arg (*args, u32 *);
292 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
293 foreach_ipsec_policy_action
301 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
303 u32 *r = va_arg (*args, u32 *);
306 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
307 foreach_ipsec_crypto_alg
315 format_ipsec_crypto_alg (u8 * s, va_list * args)
317 u32 i = va_arg (*args, u32);
322 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
323 foreach_ipsec_crypto_alg
326 return format (s, "unknown");
328 return format (s, "%s", t);
332 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
334 u32 *r = va_arg (*args, u32 *);
337 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
338 foreach_ipsec_integ_alg
346 format_ipsec_integ_alg (u8 * s, va_list * args)
348 u32 i = va_arg (*args, u32);
353 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
354 foreach_ipsec_integ_alg
357 return format (s, "unknown");
359 return format (s, "%s", t);
363 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
365 u32 *r = va_arg (*args, u32 *);
368 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
369 foreach_ikev2_auth_method
377 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
379 u32 *r = va_arg (*args, u32 *);
382 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
383 foreach_ikev2_id_type
389 #else /* VPP_API_TEST_BUILTIN == 1 */
391 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
393 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
394 vnet_main_t *vnm = vnet_get_main ();
395 u32 *result = va_arg (*args, u32 *);
398 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
401 *result = sw_if_index;
404 #endif /* VPP_API_TEST_BUILTIN */
406 #define VHOST_USER_POLLING_MODE 0
407 #define VHOST_USER_INTERRUPT_MODE 1
408 #define VHOST_USER_ADAPTIVE_MODE 2
411 api_format_vhost_user_operation_mode (u8 * s, va_list * va)
413 int operation_mode = va_arg (*va, int);
415 switch (operation_mode)
417 case VHOST_USER_POLLING_MODE:
418 s = format (s, "%-9s", "polling");
420 case VHOST_USER_INTERRUPT_MODE:
421 s = format (s, "%-9s", "interrupt");
424 s = format (s, "%-9s", "invalid");
430 api_unformat_vhost_user_operation_mode (unformat_input_t * input,
433 u8 *operation_mode = va_arg (*args, u8 *);
436 if (unformat (input, "interrupt"))
437 *operation_mode = VHOST_USER_INTERRUPT_MODE;
438 else if (unformat (input, "polling"))
439 *operation_mode = VHOST_USER_POLLING_MODE;
447 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
449 u8 *r = va_arg (*args, u8 *);
451 if (unformat (input, "kbps"))
452 *r = SSE2_QOS_RATE_KBPS;
453 else if (unformat (input, "pps"))
454 *r = SSE2_QOS_RATE_PPS;
461 unformat_policer_round_type (unformat_input_t * input, va_list * args)
463 u8 *r = va_arg (*args, u8 *);
465 if (unformat (input, "closest"))
466 *r = SSE2_QOS_ROUND_TO_CLOSEST;
467 else if (unformat (input, "up"))
468 *r = SSE2_QOS_ROUND_TO_UP;
469 else if (unformat (input, "down"))
470 *r = SSE2_QOS_ROUND_TO_DOWN;
477 unformat_policer_type (unformat_input_t * input, va_list * args)
479 u8 *r = va_arg (*args, u8 *);
481 if (unformat (input, "1r2c"))
482 *r = SSE2_QOS_POLICER_TYPE_1R2C;
483 else if (unformat (input, "1r3c"))
484 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
485 else if (unformat (input, "2r3c-2698"))
486 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
487 else if (unformat (input, "2r3c-4115"))
488 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
489 else if (unformat (input, "2r3c-mef5cf1"))
490 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
497 unformat_dscp (unformat_input_t * input, va_list * va)
499 u8 *r = va_arg (*va, u8 *);
502 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
511 unformat_policer_action_type (unformat_input_t * input, va_list * va)
513 sse2_qos_pol_action_params_st *a
514 = va_arg (*va, sse2_qos_pol_action_params_st *);
516 if (unformat (input, "drop"))
517 a->action_type = SSE2_QOS_ACTION_DROP;
518 else if (unformat (input, "transmit"))
519 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
520 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
521 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
528 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
530 u32 *r = va_arg (*va, u32 *);
533 if (unformat (input, "ip4"))
534 tid = POLICER_CLASSIFY_TABLE_IP4;
535 else if (unformat (input, "ip6"))
536 tid = POLICER_CLASSIFY_TABLE_IP6;
537 else if (unformat (input, "l2"))
538 tid = POLICER_CLASSIFY_TABLE_L2;
547 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
549 u32 *r = va_arg (*va, u32 *);
552 if (unformat (input, "ip4"))
553 tid = FLOW_CLASSIFY_TABLE_IP4;
554 else if (unformat (input, "ip6"))
555 tid = FLOW_CLASSIFY_TABLE_IP6;
563 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
564 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
565 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
566 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
568 #if (VPP_API_TEST_BUILTIN==0)
570 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
572 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
573 mfib_itf_attribute_t attr;
576 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
578 if (unformat (input, mfib_itf_flag_long_names[attr]))
579 *iflags |= (1 << attr);
581 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
583 if (unformat (input, mfib_itf_flag_names[attr]))
584 *iflags |= (1 << attr);
587 return (old == *iflags ? 0 : 1);
591 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
593 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
594 mfib_entry_attribute_t attr;
597 FOR_EACH_MFIB_ATTRIBUTE (attr)
599 if (unformat (input, mfib_flag_long_names[attr]))
600 *eflags |= (1 << attr);
602 FOR_EACH_MFIB_ATTRIBUTE (attr)
604 if (unformat (input, mfib_flag_names[attr]))
605 *eflags |= (1 << attr);
608 return (old == *eflags ? 0 : 1);
612 format_ip4_address (u8 * s, va_list * args)
614 u8 *a = va_arg (*args, u8 *);
615 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
619 format_ip6_address (u8 * s, va_list * args)
621 ip6_address_t *a = va_arg (*args, ip6_address_t *);
622 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
624 i_max_n_zero = ARRAY_LEN (a->as_u16);
626 i_first_zero = i_max_n_zero;
628 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
630 u32 is_zero = a->as_u16[i] == 0;
631 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
637 if ((!is_zero && n_zeros > max_n_zeros)
638 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
640 i_max_n_zero = i_first_zero;
641 max_n_zeros = n_zeros;
642 i_first_zero = ARRAY_LEN (a->as_u16);
647 last_double_colon = 0;
648 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
650 if (i == i_max_n_zero && max_n_zeros > 1)
652 s = format (s, "::");
653 i += max_n_zeros - 1;
654 last_double_colon = 1;
658 s = format (s, "%s%x",
659 (last_double_colon || i == 0) ? "" : ":",
660 clib_net_to_host_u16 (a->as_u16[i]));
661 last_double_colon = 0;
668 /* Format an IP46 address. */
670 format_ip46_address (u8 * s, va_list * args)
672 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
673 ip46_type_t type = va_arg (*args, ip46_type_t);
679 is_ip4 = ip46_address_is_ip4 (ip46);
690 format (s, "%U", format_ip4_address, &ip46->ip4) :
691 format (s, "%U", format_ip6_address, &ip46->ip6);
695 format_ethernet_address (u8 * s, va_list * args)
697 u8 *a = va_arg (*args, u8 *);
699 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
700 a[0], a[1], a[2], a[3], a[4], a[5]);
705 increment_v4_address (ip4_address_t * a)
709 v = ntohl (a->as_u32) + 1;
710 a->as_u32 = ntohl (v);
714 increment_v6_address (ip6_address_t * a)
718 v0 = clib_net_to_host_u64 (a->as_u64[0]);
719 v1 = clib_net_to_host_u64 (a->as_u64[1]);
724 a->as_u64[0] = clib_net_to_host_u64 (v0);
725 a->as_u64[1] = clib_net_to_host_u64 (v1);
729 increment_mac_address (u64 * mac)
733 tmp = clib_net_to_host_u64 (tmp);
734 tmp += 1 << 16; /* skip unused (least significant) octets */
735 tmp = clib_host_to_net_u64 (tmp);
739 static void vl_api_create_loopback_reply_t_handler
740 (vl_api_create_loopback_reply_t * mp)
742 vat_main_t *vam = &vat_main;
743 i32 retval = ntohl (mp->retval);
745 vam->retval = retval;
746 vam->regenerate_interface_table = 1;
747 vam->sw_if_index = ntohl (mp->sw_if_index);
748 vam->result_ready = 1;
751 static void vl_api_create_loopback_reply_t_handler_json
752 (vl_api_create_loopback_reply_t * mp)
754 vat_main_t *vam = &vat_main;
755 vat_json_node_t node;
757 vat_json_init_object (&node);
758 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
759 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
761 vat_json_print (vam->ofp, &node);
762 vat_json_free (&node);
763 vam->retval = ntohl (mp->retval);
764 vam->result_ready = 1;
767 static void vl_api_create_loopback_instance_reply_t_handler
768 (vl_api_create_loopback_instance_reply_t * mp)
770 vat_main_t *vam = &vat_main;
771 i32 retval = ntohl (mp->retval);
773 vam->retval = retval;
774 vam->regenerate_interface_table = 1;
775 vam->sw_if_index = ntohl (mp->sw_if_index);
776 vam->result_ready = 1;
779 static void vl_api_create_loopback_instance_reply_t_handler_json
780 (vl_api_create_loopback_instance_reply_t * mp)
782 vat_main_t *vam = &vat_main;
783 vat_json_node_t node;
785 vat_json_init_object (&node);
786 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
787 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
789 vat_json_print (vam->ofp, &node);
790 vat_json_free (&node);
791 vam->retval = ntohl (mp->retval);
792 vam->result_ready = 1;
795 static void vl_api_af_packet_create_reply_t_handler
796 (vl_api_af_packet_create_reply_t * mp)
798 vat_main_t *vam = &vat_main;
799 i32 retval = ntohl (mp->retval);
801 vam->retval = retval;
802 vam->regenerate_interface_table = 1;
803 vam->sw_if_index = ntohl (mp->sw_if_index);
804 vam->result_ready = 1;
807 static void vl_api_af_packet_create_reply_t_handler_json
808 (vl_api_af_packet_create_reply_t * mp)
810 vat_main_t *vam = &vat_main;
811 vat_json_node_t node;
813 vat_json_init_object (&node);
814 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
815 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
817 vat_json_print (vam->ofp, &node);
818 vat_json_free (&node);
820 vam->retval = ntohl (mp->retval);
821 vam->result_ready = 1;
824 static void vl_api_create_vlan_subif_reply_t_handler
825 (vl_api_create_vlan_subif_reply_t * mp)
827 vat_main_t *vam = &vat_main;
828 i32 retval = ntohl (mp->retval);
830 vam->retval = retval;
831 vam->regenerate_interface_table = 1;
832 vam->sw_if_index = ntohl (mp->sw_if_index);
833 vam->result_ready = 1;
836 static void vl_api_create_vlan_subif_reply_t_handler_json
837 (vl_api_create_vlan_subif_reply_t * mp)
839 vat_main_t *vam = &vat_main;
840 vat_json_node_t node;
842 vat_json_init_object (&node);
843 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
844 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
846 vat_json_print (vam->ofp, &node);
847 vat_json_free (&node);
849 vam->retval = ntohl (mp->retval);
850 vam->result_ready = 1;
853 static void vl_api_create_subif_reply_t_handler
854 (vl_api_create_subif_reply_t * mp)
856 vat_main_t *vam = &vat_main;
857 i32 retval = ntohl (mp->retval);
859 vam->retval = retval;
860 vam->regenerate_interface_table = 1;
861 vam->sw_if_index = ntohl (mp->sw_if_index);
862 vam->result_ready = 1;
865 static void vl_api_create_subif_reply_t_handler_json
866 (vl_api_create_subif_reply_t * mp)
868 vat_main_t *vam = &vat_main;
869 vat_json_node_t node;
871 vat_json_init_object (&node);
872 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
873 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
875 vat_json_print (vam->ofp, &node);
876 vat_json_free (&node);
878 vam->retval = ntohl (mp->retval);
879 vam->result_ready = 1;
882 static void vl_api_interface_name_renumber_reply_t_handler
883 (vl_api_interface_name_renumber_reply_t * mp)
885 vat_main_t *vam = &vat_main;
886 i32 retval = ntohl (mp->retval);
888 vam->retval = retval;
889 vam->regenerate_interface_table = 1;
890 vam->result_ready = 1;
893 static void vl_api_interface_name_renumber_reply_t_handler_json
894 (vl_api_interface_name_renumber_reply_t * mp)
896 vat_main_t *vam = &vat_main;
897 vat_json_node_t node;
899 vat_json_init_object (&node);
900 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
902 vat_json_print (vam->ofp, &node);
903 vat_json_free (&node);
905 vam->retval = ntohl (mp->retval);
906 vam->result_ready = 1;
910 * Special-case: build the interface table, maintain
911 * the next loopback sw_if_index vbl.
913 static void vl_api_sw_interface_details_t_handler
914 (vl_api_sw_interface_details_t * mp)
916 vat_main_t *vam = &vat_main;
917 u8 *s = format (0, "%s%c", mp->interface_name, 0);
919 hash_set_mem (vam->sw_if_index_by_interface_name, s,
920 ntohl (mp->sw_if_index));
922 /* In sub interface case, fill the sub interface table entry */
923 if (mp->sw_if_index != mp->sup_sw_if_index)
925 sw_interface_subif_t *sub = NULL;
927 vec_add2 (vam->sw_if_subif_table, sub, 1);
929 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
930 strncpy ((char *) sub->interface_name, (char *) s,
931 vec_len (sub->interface_name));
932 sub->sw_if_index = ntohl (mp->sw_if_index);
933 sub->sub_id = ntohl (mp->sub_id);
935 sub->sub_dot1ad = mp->sub_dot1ad;
936 sub->sub_number_of_tags = mp->sub_number_of_tags;
937 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
938 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
939 sub->sub_exact_match = mp->sub_exact_match;
940 sub->sub_default = mp->sub_default;
941 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
942 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
944 /* vlan tag rewrite */
945 sub->vtr_op = ntohl (mp->vtr_op);
946 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
947 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
948 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
952 static void vl_api_sw_interface_details_t_handler_json
953 (vl_api_sw_interface_details_t * mp)
955 vat_main_t *vam = &vat_main;
956 vat_json_node_t *node = NULL;
958 if (VAT_JSON_ARRAY != vam->json_tree.type)
960 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
961 vat_json_init_array (&vam->json_tree);
963 node = vat_json_array_add (&vam->json_tree);
965 vat_json_init_object (node);
966 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
967 vat_json_object_add_uint (node, "sup_sw_if_index",
968 ntohl (mp->sup_sw_if_index));
969 vat_json_object_add_uint (node, "l2_address_length",
970 ntohl (mp->l2_address_length));
971 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
972 sizeof (mp->l2_address));
973 vat_json_object_add_string_copy (node, "interface_name",
975 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
976 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
977 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
978 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
979 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
980 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
981 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
982 vat_json_object_add_uint (node, "sub_number_of_tags",
983 mp->sub_number_of_tags);
984 vat_json_object_add_uint (node, "sub_outer_vlan_id",
985 ntohs (mp->sub_outer_vlan_id));
986 vat_json_object_add_uint (node, "sub_inner_vlan_id",
987 ntohs (mp->sub_inner_vlan_id));
988 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
989 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
990 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
991 mp->sub_outer_vlan_id_any);
992 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
993 mp->sub_inner_vlan_id_any);
994 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
995 vat_json_object_add_uint (node, "vtr_push_dot1q",
996 ntohl (mp->vtr_push_dot1q));
997 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
998 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1001 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1003 format_ethernet_address,
1005 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1007 format_ethernet_address,
1009 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1010 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1014 #if VPP_API_TEST_BUILTIN == 0
1015 static void vl_api_sw_interface_set_flags_t_handler
1016 (vl_api_sw_interface_set_flags_t * mp)
1018 vat_main_t *vam = &vat_main;
1019 if (vam->interface_event_display)
1020 errmsg ("interface flags: sw_if_index %d %s %s",
1021 ntohl (mp->sw_if_index),
1022 mp->admin_up_down ? "admin-up" : "admin-down",
1023 mp->link_up_down ? "link-up" : "link-down");
1027 static void vl_api_sw_interface_set_flags_t_handler_json
1028 (vl_api_sw_interface_set_flags_t * mp)
1030 /* JSON output not supported */
1034 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1036 vat_main_t *vam = &vat_main;
1037 i32 retval = ntohl (mp->retval);
1039 vam->retval = retval;
1040 vam->shmem_result = (u8 *) mp->reply_in_shmem;
1041 vam->result_ready = 1;
1045 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1047 vat_main_t *vam = &vat_main;
1048 vat_json_node_t node;
1049 api_main_t *am = &api_main;
1053 vat_json_init_object (&node);
1054 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1055 vat_json_object_add_uint (&node, "reply_in_shmem",
1056 ntohl (mp->reply_in_shmem));
1057 /* Toss the shared-memory original... */
1058 pthread_mutex_lock (&am->vlib_rp->mutex);
1059 oldheap = svm_push_data_heap (am->vlib_rp);
1061 reply = (u8 *) (mp->reply_in_shmem);
1064 svm_pop_heap (oldheap);
1065 pthread_mutex_unlock (&am->vlib_rp->mutex);
1067 vat_json_print (vam->ofp, &node);
1068 vat_json_free (&node);
1070 vam->retval = ntohl (mp->retval);
1071 vam->result_ready = 1;
1075 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1077 vat_main_t *vam = &vat_main;
1078 i32 retval = ntohl (mp->retval);
1080 vam->retval = retval;
1081 vam->cmd_reply = mp->reply;
1082 vam->result_ready = 1;
1086 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1088 vat_main_t *vam = &vat_main;
1089 vat_json_node_t node;
1091 vat_json_init_object (&node);
1092 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1093 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1095 vat_json_print (vam->ofp, &node);
1096 vat_json_free (&node);
1098 vam->retval = ntohl (mp->retval);
1099 vam->result_ready = 1;
1102 static void vl_api_classify_add_del_table_reply_t_handler
1103 (vl_api_classify_add_del_table_reply_t * mp)
1105 vat_main_t *vam = &vat_main;
1106 i32 retval = ntohl (mp->retval);
1107 if (vam->async_mode)
1109 vam->async_errors += (retval < 0);
1113 vam->retval = retval;
1115 ((mp->new_table_index != 0xFFFFFFFF) ||
1116 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1117 (mp->match_n_vectors != 0xFFFFFFFF)))
1119 * Note: this is just barely thread-safe, depends on
1120 * the main thread spinning waiting for an answer...
1122 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1123 ntohl (mp->new_table_index),
1124 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1125 vam->result_ready = 1;
1129 static void vl_api_classify_add_del_table_reply_t_handler_json
1130 (vl_api_classify_add_del_table_reply_t * mp)
1132 vat_main_t *vam = &vat_main;
1133 vat_json_node_t node;
1135 vat_json_init_object (&node);
1136 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1137 vat_json_object_add_uint (&node, "new_table_index",
1138 ntohl (mp->new_table_index));
1139 vat_json_object_add_uint (&node, "skip_n_vectors",
1140 ntohl (mp->skip_n_vectors));
1141 vat_json_object_add_uint (&node, "match_n_vectors",
1142 ntohl (mp->match_n_vectors));
1144 vat_json_print (vam->ofp, &node);
1145 vat_json_free (&node);
1147 vam->retval = ntohl (mp->retval);
1148 vam->result_ready = 1;
1151 static void vl_api_get_node_index_reply_t_handler
1152 (vl_api_get_node_index_reply_t * mp)
1154 vat_main_t *vam = &vat_main;
1155 i32 retval = ntohl (mp->retval);
1156 if (vam->async_mode)
1158 vam->async_errors += (retval < 0);
1162 vam->retval = retval;
1164 errmsg ("node index %d", ntohl (mp->node_index));
1165 vam->result_ready = 1;
1169 static void vl_api_get_node_index_reply_t_handler_json
1170 (vl_api_get_node_index_reply_t * mp)
1172 vat_main_t *vam = &vat_main;
1173 vat_json_node_t node;
1175 vat_json_init_object (&node);
1176 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1177 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1179 vat_json_print (vam->ofp, &node);
1180 vat_json_free (&node);
1182 vam->retval = ntohl (mp->retval);
1183 vam->result_ready = 1;
1186 static void vl_api_get_next_index_reply_t_handler
1187 (vl_api_get_next_index_reply_t * mp)
1189 vat_main_t *vam = &vat_main;
1190 i32 retval = ntohl (mp->retval);
1191 if (vam->async_mode)
1193 vam->async_errors += (retval < 0);
1197 vam->retval = retval;
1199 errmsg ("next node index %d", ntohl (mp->next_index));
1200 vam->result_ready = 1;
1204 static void vl_api_get_next_index_reply_t_handler_json
1205 (vl_api_get_next_index_reply_t * mp)
1207 vat_main_t *vam = &vat_main;
1208 vat_json_node_t node;
1210 vat_json_init_object (&node);
1211 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1212 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1214 vat_json_print (vam->ofp, &node);
1215 vat_json_free (&node);
1217 vam->retval = ntohl (mp->retval);
1218 vam->result_ready = 1;
1221 static void vl_api_add_node_next_reply_t_handler
1222 (vl_api_add_node_next_reply_t * mp)
1224 vat_main_t *vam = &vat_main;
1225 i32 retval = ntohl (mp->retval);
1226 if (vam->async_mode)
1228 vam->async_errors += (retval < 0);
1232 vam->retval = retval;
1234 errmsg ("next index %d", ntohl (mp->next_index));
1235 vam->result_ready = 1;
1239 static void vl_api_add_node_next_reply_t_handler_json
1240 (vl_api_add_node_next_reply_t * mp)
1242 vat_main_t *vam = &vat_main;
1243 vat_json_node_t node;
1245 vat_json_init_object (&node);
1246 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1247 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1249 vat_json_print (vam->ofp, &node);
1250 vat_json_free (&node);
1252 vam->retval = ntohl (mp->retval);
1253 vam->result_ready = 1;
1256 static void vl_api_show_version_reply_t_handler
1257 (vl_api_show_version_reply_t * mp)
1259 vat_main_t *vam = &vat_main;
1260 i32 retval = ntohl (mp->retval);
1264 errmsg (" program: %s", mp->program);
1265 errmsg (" version: %s", mp->version);
1266 errmsg (" build date: %s", mp->build_date);
1267 errmsg ("build directory: %s", mp->build_directory);
1269 vam->retval = retval;
1270 vam->result_ready = 1;
1273 static void vl_api_show_version_reply_t_handler_json
1274 (vl_api_show_version_reply_t * mp)
1276 vat_main_t *vam = &vat_main;
1277 vat_json_node_t node;
1279 vat_json_init_object (&node);
1280 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1281 vat_json_object_add_string_copy (&node, "program", mp->program);
1282 vat_json_object_add_string_copy (&node, "version", mp->version);
1283 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1284 vat_json_object_add_string_copy (&node, "build_directory",
1285 mp->build_directory);
1287 vat_json_print (vam->ofp, &node);
1288 vat_json_free (&node);
1290 vam->retval = ntohl (mp->retval);
1291 vam->result_ready = 1;
1295 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1297 u32 sw_if_index = ntohl (mp->sw_if_index);
1298 errmsg ("arp %s event: address %U new mac %U sw_if_index %d",
1299 mp->mac_ip ? "mac/ip binding" : "address resolution",
1300 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: address %U new mac %U sw_if_index %d",
1315 mp->mac_ip ? "mac/ip binding" : "address resolution",
1316 format_ip6_address, mp->address,
1317 format_ethernet_address, mp->new_mac, sw_if_index);
1321 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1323 /* JSON output not supported */
1327 * Special-case: build the bridge domain table, maintain
1328 * the next bd id vbl.
1330 static void vl_api_bridge_domain_details_t_handler
1331 (vl_api_bridge_domain_details_t * mp)
1333 vat_main_t *vam = &vat_main;
1334 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1336 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1337 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1339 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1340 ntohl (mp->bd_id), mp->learn, mp->forward,
1341 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1344 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG", "Interface Name");
1347 static void vl_api_bridge_domain_details_t_handler_json
1348 (vl_api_bridge_domain_details_t * mp)
1350 vat_main_t *vam = &vat_main;
1351 vat_json_node_t *node, *array = NULL;
1353 if (VAT_JSON_ARRAY != vam->json_tree.type)
1355 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1356 vat_json_init_array (&vam->json_tree);
1358 node = vat_json_array_add (&vam->json_tree);
1360 vat_json_init_object (node);
1361 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1362 vat_json_object_add_uint (node, "flood", mp->flood);
1363 vat_json_object_add_uint (node, "forward", mp->forward);
1364 vat_json_object_add_uint (node, "learn", mp->learn);
1365 vat_json_object_add_uint (node, "bvi_sw_if_index",
1366 ntohl (mp->bvi_sw_if_index));
1367 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1368 array = vat_json_object_add (node, "sw_if");
1369 vat_json_init_array (array);
1373 * Special-case: build the bridge domain sw if table.
1375 static void vl_api_bridge_domain_sw_if_details_t_handler
1376 (vl_api_bridge_domain_sw_if_details_t * mp)
1378 vat_main_t *vam = &vat_main;
1383 sw_if_index = ntohl (mp->sw_if_index);
1385 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1387 if ((u32) p->value[0] == sw_if_index)
1389 sw_if_name = (u8 *)(p->key);
1395 print (vam->ofp, "%7d %3d %s", sw_if_index,
1396 mp->shg, sw_if_name ? (char *) sw_if_name :
1397 "sw_if_index not found!");
1400 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1401 (vl_api_bridge_domain_sw_if_details_t * mp)
1403 vat_main_t *vam = &vat_main;
1404 vat_json_node_t *node = NULL;
1405 uword last_index = 0;
1407 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1408 ASSERT (vec_len (vam->json_tree.array) >= 1);
1409 last_index = vec_len (vam->json_tree.array) - 1;
1410 node = &vam->json_tree.array[last_index];
1411 node = vat_json_object_get_element (node, "sw_if");
1412 ASSERT (NULL != node);
1413 node = vat_json_array_add (node);
1415 vat_json_init_object (node);
1416 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1417 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1418 vat_json_object_add_uint (node, "shg", mp->shg);
1421 static void vl_api_control_ping_reply_t_handler
1422 (vl_api_control_ping_reply_t * mp)
1424 vat_main_t *vam = &vat_main;
1425 i32 retval = ntohl (mp->retval);
1426 if (vam->async_mode)
1428 vam->async_errors += (retval < 0);
1432 vam->retval = retval;
1433 vam->result_ready = 1;
1437 static void vl_api_control_ping_reply_t_handler_json
1438 (vl_api_control_ping_reply_t * mp)
1440 vat_main_t *vam = &vat_main;
1441 i32 retval = ntohl (mp->retval);
1443 if (VAT_JSON_NONE != vam->json_tree.type)
1445 vat_json_print (vam->ofp, &vam->json_tree);
1446 vat_json_free (&vam->json_tree);
1447 vam->json_tree.type = VAT_JSON_NONE;
1452 vat_json_init_array (&vam->json_tree);
1453 vat_json_print (vam->ofp, &vam->json_tree);
1454 vam->json_tree.type = VAT_JSON_NONE;
1457 vam->retval = retval;
1458 vam->result_ready = 1;
1462 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1464 vat_main_t *vam = &vat_main;
1465 i32 retval = ntohl (mp->retval);
1466 if (vam->async_mode)
1468 vam->async_errors += (retval < 0);
1472 vam->retval = retval;
1473 vam->result_ready = 1;
1477 static void vl_api_l2_flags_reply_t_handler_json
1478 (vl_api_l2_flags_reply_t * mp)
1480 vat_main_t *vam = &vat_main;
1481 vat_json_node_t node;
1483 vat_json_init_object (&node);
1484 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1485 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1486 ntohl (mp->resulting_feature_bitmap));
1488 vat_json_print (vam->ofp, &node);
1489 vat_json_free (&node);
1491 vam->retval = ntohl (mp->retval);
1492 vam->result_ready = 1;
1495 static void vl_api_bridge_flags_reply_t_handler
1496 (vl_api_bridge_flags_reply_t * mp)
1498 vat_main_t *vam = &vat_main;
1499 i32 retval = ntohl (mp->retval);
1500 if (vam->async_mode)
1502 vam->async_errors += (retval < 0);
1506 vam->retval = retval;
1507 vam->result_ready = 1;
1511 static void vl_api_bridge_flags_reply_t_handler_json
1512 (vl_api_bridge_flags_reply_t * mp)
1514 vat_main_t *vam = &vat_main;
1515 vat_json_node_t node;
1517 vat_json_init_object (&node);
1518 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1519 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1520 ntohl (mp->resulting_feature_bitmap));
1522 vat_json_print (vam->ofp, &node);
1523 vat_json_free (&node);
1525 vam->retval = ntohl (mp->retval);
1526 vam->result_ready = 1;
1529 static void vl_api_tap_connect_reply_t_handler
1530 (vl_api_tap_connect_reply_t * mp)
1532 vat_main_t *vam = &vat_main;
1533 i32 retval = ntohl (mp->retval);
1534 if (vam->async_mode)
1536 vam->async_errors += (retval < 0);
1540 vam->retval = retval;
1541 vam->sw_if_index = ntohl (mp->sw_if_index);
1542 vam->result_ready = 1;
1547 static void vl_api_tap_connect_reply_t_handler_json
1548 (vl_api_tap_connect_reply_t * mp)
1550 vat_main_t *vam = &vat_main;
1551 vat_json_node_t node;
1553 vat_json_init_object (&node);
1554 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1555 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1557 vat_json_print (vam->ofp, &node);
1558 vat_json_free (&node);
1560 vam->retval = ntohl (mp->retval);
1561 vam->result_ready = 1;
1566 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1568 vat_main_t *vam = &vat_main;
1569 i32 retval = ntohl (mp->retval);
1570 if (vam->async_mode)
1572 vam->async_errors += (retval < 0);
1576 vam->retval = retval;
1577 vam->sw_if_index = ntohl (mp->sw_if_index);
1578 vam->result_ready = 1;
1582 static void vl_api_tap_modify_reply_t_handler_json
1583 (vl_api_tap_modify_reply_t * mp)
1585 vat_main_t *vam = &vat_main;
1586 vat_json_node_t node;
1588 vat_json_init_object (&node);
1589 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1590 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1592 vat_json_print (vam->ofp, &node);
1593 vat_json_free (&node);
1595 vam->retval = ntohl (mp->retval);
1596 vam->result_ready = 1;
1600 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1602 vat_main_t *vam = &vat_main;
1603 i32 retval = ntohl (mp->retval);
1604 if (vam->async_mode)
1606 vam->async_errors += (retval < 0);
1610 vam->retval = retval;
1611 vam->result_ready = 1;
1615 static void vl_api_tap_delete_reply_t_handler_json
1616 (vl_api_tap_delete_reply_t * mp)
1618 vat_main_t *vam = &vat_main;
1619 vat_json_node_t node;
1621 vat_json_init_object (&node);
1622 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1624 vat_json_print (vam->ofp, &node);
1625 vat_json_free (&node);
1627 vam->retval = ntohl (mp->retval);
1628 vam->result_ready = 1;
1631 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1632 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1634 vat_main_t *vam = &vat_main;
1635 i32 retval = ntohl (mp->retval);
1636 if (vam->async_mode)
1638 vam->async_errors += (retval < 0);
1642 vam->retval = retval;
1643 vam->result_ready = 1;
1647 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1648 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1650 vat_main_t *vam = &vat_main;
1651 vat_json_node_t node;
1653 vat_json_init_object (&node);
1654 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1655 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1656 ntohl (mp->sw_if_index));
1658 vat_json_print (vam->ofp, &node);
1659 vat_json_free (&node);
1661 vam->retval = ntohl (mp->retval);
1662 vam->result_ready = 1;
1665 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1666 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1668 vat_main_t *vam = &vat_main;
1669 i32 retval = ntohl (mp->retval);
1670 if (vam->async_mode)
1672 vam->async_errors += (retval < 0);
1676 vam->retval = retval;
1677 vam->sw_if_index = ntohl (mp->sw_if_index);
1678 vam->result_ready = 1;
1682 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1683 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1685 vat_main_t *vam = &vat_main;
1686 vat_json_node_t node;
1688 vat_json_init_object (&node);
1689 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1690 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1692 vat_json_print (vam->ofp, &node);
1693 vat_json_free (&node);
1695 vam->retval = ntohl (mp->retval);
1696 vam->result_ready = 1;
1700 static void vl_api_one_add_del_locator_set_reply_t_handler
1701 (vl_api_one_add_del_locator_set_reply_t * mp)
1703 vat_main_t *vam = &vat_main;
1704 i32 retval = ntohl (mp->retval);
1705 if (vam->async_mode)
1707 vam->async_errors += (retval < 0);
1711 vam->retval = retval;
1712 vam->result_ready = 1;
1716 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1717 (vl_api_one_add_del_locator_set_reply_t * mp)
1719 vat_main_t *vam = &vat_main;
1720 vat_json_node_t node;
1722 vat_json_init_object (&node);
1723 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1724 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1726 vat_json_print (vam->ofp, &node);
1727 vat_json_free (&node);
1729 vam->retval = ntohl (mp->retval);
1730 vam->result_ready = 1;
1733 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1734 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1736 vat_main_t *vam = &vat_main;
1737 i32 retval = ntohl (mp->retval);
1738 if (vam->async_mode)
1740 vam->async_errors += (retval < 0);
1744 vam->retval = retval;
1745 vam->sw_if_index = ntohl (mp->sw_if_index);
1746 vam->result_ready = 1;
1750 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1751 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1753 vat_main_t *vam = &vat_main;
1754 vat_json_node_t node;
1756 vat_json_init_object (&node);
1757 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1758 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1760 vat_json_print (vam->ofp, &node);
1761 vat_json_free (&node);
1763 vam->retval = ntohl (mp->retval);
1764 vam->result_ready = 1;
1767 static void vl_api_gre_add_del_tunnel_reply_t_handler
1768 (vl_api_gre_add_del_tunnel_reply_t * mp)
1770 vat_main_t *vam = &vat_main;
1771 i32 retval = ntohl (mp->retval);
1772 if (vam->async_mode)
1774 vam->async_errors += (retval < 0);
1778 vam->retval = retval;
1779 vam->sw_if_index = ntohl (mp->sw_if_index);
1780 vam->result_ready = 1;
1784 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1785 (vl_api_gre_add_del_tunnel_reply_t * mp)
1787 vat_main_t *vam = &vat_main;
1788 vat_json_node_t node;
1790 vat_json_init_object (&node);
1791 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1792 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1794 vat_json_print (vam->ofp, &node);
1795 vat_json_free (&node);
1797 vam->retval = ntohl (mp->retval);
1798 vam->result_ready = 1;
1801 static void vl_api_create_vhost_user_if_reply_t_handler
1802 (vl_api_create_vhost_user_if_reply_t * mp)
1804 vat_main_t *vam = &vat_main;
1805 i32 retval = ntohl (mp->retval);
1806 if (vam->async_mode)
1808 vam->async_errors += (retval < 0);
1812 vam->retval = retval;
1813 vam->sw_if_index = ntohl (mp->sw_if_index);
1814 vam->result_ready = 1;
1818 static void vl_api_create_vhost_user_if_reply_t_handler_json
1819 (vl_api_create_vhost_user_if_reply_t * mp)
1821 vat_main_t *vam = &vat_main;
1822 vat_json_node_t node;
1824 vat_json_init_object (&node);
1825 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1826 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1828 vat_json_print (vam->ofp, &node);
1829 vat_json_free (&node);
1831 vam->retval = ntohl (mp->retval);
1832 vam->result_ready = 1;
1835 static void vl_api_ip_address_details_t_handler
1836 (vl_api_ip_address_details_t * mp)
1838 vat_main_t *vam = &vat_main;
1839 static ip_address_details_t empty_ip_address_details = { {0} };
1840 ip_address_details_t *address = NULL;
1841 ip_details_t *current_ip_details = NULL;
1842 ip_details_t *details = NULL;
1844 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1846 if (!details || vam->current_sw_if_index >= vec_len (details)
1847 || !details[vam->current_sw_if_index].present)
1849 errmsg ("ip address details arrived but not stored");
1850 errmsg ("ip_dump should be called first");
1854 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1856 #define addresses (current_ip_details->addr)
1858 vec_validate_init_empty (addresses, vec_len (addresses),
1859 empty_ip_address_details);
1861 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1863 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1864 address->prefix_length = mp->prefix_length;
1868 static void vl_api_ip_address_details_t_handler_json
1869 (vl_api_ip_address_details_t * mp)
1871 vat_main_t *vam = &vat_main;
1872 vat_json_node_t *node = NULL;
1873 struct in6_addr ip6;
1876 if (VAT_JSON_ARRAY != vam->json_tree.type)
1878 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1879 vat_json_init_array (&vam->json_tree);
1881 node = vat_json_array_add (&vam->json_tree);
1883 vat_json_init_object (node);
1886 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1887 vat_json_object_add_ip6 (node, "ip", ip6);
1891 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1892 vat_json_object_add_ip4 (node, "ip", ip4);
1894 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1898 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1900 vat_main_t *vam = &vat_main;
1901 static ip_details_t empty_ip_details = { 0 };
1902 ip_details_t *ip = NULL;
1903 u32 sw_if_index = ~0;
1905 sw_if_index = ntohl (mp->sw_if_index);
1907 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1908 sw_if_index, empty_ip_details);
1910 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1917 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1919 vat_main_t *vam = &vat_main;
1921 if (VAT_JSON_ARRAY != vam->json_tree.type)
1923 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1924 vat_json_init_array (&vam->json_tree);
1926 vat_json_array_add_uint (&vam->json_tree,
1927 clib_net_to_host_u32 (mp->sw_if_index));
1930 static void vl_api_map_domain_details_t_handler_json
1931 (vl_api_map_domain_details_t * mp)
1933 vat_json_node_t *node = NULL;
1934 vat_main_t *vam = &vat_main;
1935 struct in6_addr ip6;
1938 if (VAT_JSON_ARRAY != vam->json_tree.type)
1940 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1941 vat_json_init_array (&vam->json_tree);
1944 node = vat_json_array_add (&vam->json_tree);
1945 vat_json_init_object (node);
1947 vat_json_object_add_uint (node, "domain_index",
1948 clib_net_to_host_u32 (mp->domain_index));
1949 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1950 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1951 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1952 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1953 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1954 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1955 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1956 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1957 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1958 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1959 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1960 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1961 vat_json_object_add_uint (node, "flags", mp->flags);
1962 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1963 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1966 static void vl_api_map_domain_details_t_handler
1967 (vl_api_map_domain_details_t * mp)
1969 vat_main_t *vam = &vat_main;
1971 if (mp->is_translation)
1974 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
1975 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1976 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1977 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1978 clib_net_to_host_u32 (mp->domain_index));
1983 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
1984 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1985 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1986 format_ip6_address, mp->ip6_src,
1987 clib_net_to_host_u32 (mp->domain_index));
1989 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
1990 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1991 mp->is_translation ? "map-t" : "");
1994 static void vl_api_map_rule_details_t_handler_json
1995 (vl_api_map_rule_details_t * mp)
1997 struct in6_addr ip6;
1998 vat_json_node_t *node = NULL;
1999 vat_main_t *vam = &vat_main;
2001 if (VAT_JSON_ARRAY != vam->json_tree.type)
2003 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2004 vat_json_init_array (&vam->json_tree);
2007 node = vat_json_array_add (&vam->json_tree);
2008 vat_json_init_object (node);
2010 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2011 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2012 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2016 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2018 vat_main_t *vam = &vat_main;
2019 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2020 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2024 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2026 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2027 "router_addr %U host_mac %U",
2028 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2029 format_ip4_address, &mp->host_address,
2030 format_ip4_address, &mp->router_address,
2031 format_ethernet_address, mp->host_mac);
2034 static void vl_api_dhcp_compl_event_t_handler_json
2035 (vl_api_dhcp_compl_event_t * mp)
2037 /* JSON output not supported */
2041 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2044 vat_main_t *vam = &vat_main;
2045 static u64 default_counter = 0;
2047 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2049 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2050 sw_if_index, default_counter);
2051 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2055 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2056 interface_counter_t counter)
2058 vat_main_t *vam = &vat_main;
2059 static interface_counter_t default_counter = { 0, };
2061 vec_validate_init_empty (vam->combined_interface_counters,
2062 vnet_counter_type, NULL);
2063 vec_validate_init_empty (vam->combined_interface_counters
2064 [vnet_counter_type], sw_if_index, default_counter);
2065 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2068 static void vl_api_vnet_interface_counters_t_handler
2069 (vl_api_vnet_interface_counters_t * mp)
2074 static void vl_api_vnet_interface_counters_t_handler_json
2075 (vl_api_vnet_interface_counters_t * mp)
2077 interface_counter_t counter;
2082 u32 first_sw_if_index;
2085 count = ntohl (mp->count);
2086 first_sw_if_index = ntohl (mp->first_sw_if_index);
2088 if (!mp->is_combined)
2090 v_packets = (u64 *) & mp->data;
2091 for (i = 0; i < count; i++)
2094 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2095 set_simple_interface_counter (mp->vnet_counter_type,
2096 first_sw_if_index + i, packets);
2102 v = (vlib_counter_t *) & mp->data;
2103 for (i = 0; i < count; i++)
2106 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2108 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2109 set_combined_interface_counter (mp->vnet_counter_type,
2110 first_sw_if_index + i, counter);
2117 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2119 vat_main_t *vam = &vat_main;
2122 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2124 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2133 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2135 vat_main_t *vam = &vat_main;
2138 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2140 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2148 static void vl_api_vnet_ip4_fib_counters_t_handler
2149 (vl_api_vnet_ip4_fib_counters_t * mp)
2154 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2155 (vl_api_vnet_ip4_fib_counters_t * mp)
2157 vat_main_t *vam = &vat_main;
2158 vl_api_ip4_fib_counter_t *v;
2159 ip4_fib_counter_t *counter;
2166 vrf_id = ntohl (mp->vrf_id);
2167 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2168 if (~0 == vrf_index)
2170 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2171 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2172 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2173 vec_validate (vam->ip4_fib_counters, vrf_index);
2174 vam->ip4_fib_counters[vrf_index] = NULL;
2177 vec_free (vam->ip4_fib_counters[vrf_index]);
2178 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2179 count = ntohl (mp->count);
2180 for (i = 0; i < count; i++)
2182 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2183 counter = &vam->ip4_fib_counters[vrf_index][i];
2184 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2185 counter->address = ip4;
2186 counter->address_length = v->address_length;
2187 counter->packets = clib_net_to_host_u64 (v->packets);
2188 counter->bytes = clib_net_to_host_u64 (v->bytes);
2193 static void vl_api_vnet_ip4_nbr_counters_t_handler
2194 (vl_api_vnet_ip4_nbr_counters_t * mp)
2199 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2200 (vl_api_vnet_ip4_nbr_counters_t * mp)
2202 vat_main_t *vam = &vat_main;
2203 vl_api_ip4_nbr_counter_t *v;
2204 ip4_nbr_counter_t *counter;
2209 sw_if_index = ntohl (mp->sw_if_index);
2210 count = ntohl (mp->count);
2211 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2214 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2216 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2217 for (i = 0; i < count; i++)
2219 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2220 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2221 counter->address.s_addr = v->address;
2222 counter->packets = clib_net_to_host_u64 (v->packets);
2223 counter->bytes = clib_net_to_host_u64 (v->bytes);
2224 counter->linkt = v->link_type;
2229 static void vl_api_vnet_ip6_fib_counters_t_handler
2230 (vl_api_vnet_ip6_fib_counters_t * mp)
2235 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2236 (vl_api_vnet_ip6_fib_counters_t * mp)
2238 vat_main_t *vam = &vat_main;
2239 vl_api_ip6_fib_counter_t *v;
2240 ip6_fib_counter_t *counter;
2241 struct in6_addr ip6;
2247 vrf_id = ntohl (mp->vrf_id);
2248 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2249 if (~0 == vrf_index)
2251 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2252 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2253 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2254 vec_validate (vam->ip6_fib_counters, vrf_index);
2255 vam->ip6_fib_counters[vrf_index] = NULL;
2258 vec_free (vam->ip6_fib_counters[vrf_index]);
2259 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2260 count = ntohl (mp->count);
2261 for (i = 0; i < count; i++)
2263 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2264 counter = &vam->ip6_fib_counters[vrf_index][i];
2265 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2266 counter->address = ip6;
2267 counter->address_length = v->address_length;
2268 counter->packets = clib_net_to_host_u64 (v->packets);
2269 counter->bytes = clib_net_to_host_u64 (v->bytes);
2274 static void vl_api_vnet_ip6_nbr_counters_t_handler
2275 (vl_api_vnet_ip6_nbr_counters_t * mp)
2280 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2281 (vl_api_vnet_ip6_nbr_counters_t * mp)
2283 vat_main_t *vam = &vat_main;
2284 vl_api_ip6_nbr_counter_t *v;
2285 ip6_nbr_counter_t *counter;
2286 struct in6_addr ip6;
2291 sw_if_index = ntohl (mp->sw_if_index);
2292 count = ntohl (mp->count);
2293 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2296 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2298 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2299 for (i = 0; i < count; i++)
2301 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2302 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2303 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2304 counter->address = ip6;
2305 counter->packets = clib_net_to_host_u64 (v->packets);
2306 counter->bytes = clib_net_to_host_u64 (v->bytes);
2311 static void vl_api_get_first_msg_id_reply_t_handler
2312 (vl_api_get_first_msg_id_reply_t * mp)
2314 vat_main_t *vam = &vat_main;
2315 i32 retval = ntohl (mp->retval);
2317 if (vam->async_mode)
2319 vam->async_errors += (retval < 0);
2323 vam->retval = retval;
2324 vam->result_ready = 1;
2328 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2332 static void vl_api_get_first_msg_id_reply_t_handler_json
2333 (vl_api_get_first_msg_id_reply_t * mp)
2335 vat_main_t *vam = &vat_main;
2336 vat_json_node_t node;
2338 vat_json_init_object (&node);
2339 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2340 vat_json_object_add_uint (&node, "first_msg_id",
2341 (uint) ntohs (mp->first_msg_id));
2343 vat_json_print (vam->ofp, &node);
2344 vat_json_free (&node);
2346 vam->retval = ntohl (mp->retval);
2347 vam->result_ready = 1;
2350 static void vl_api_get_node_graph_reply_t_handler
2351 (vl_api_get_node_graph_reply_t * mp)
2353 vat_main_t *vam = &vat_main;
2354 api_main_t *am = &api_main;
2355 i32 retval = ntohl (mp->retval);
2356 u8 *pvt_copy, *reply;
2361 if (vam->async_mode)
2363 vam->async_errors += (retval < 0);
2367 vam->retval = retval;
2368 vam->result_ready = 1;
2371 /* "Should never happen..." */
2375 reply = (u8 *) (mp->reply_in_shmem);
2376 pvt_copy = vec_dup (reply);
2378 /* Toss the shared-memory original... */
2379 pthread_mutex_lock (&am->vlib_rp->mutex);
2380 oldheap = svm_push_data_heap (am->vlib_rp);
2384 svm_pop_heap (oldheap);
2385 pthread_mutex_unlock (&am->vlib_rp->mutex);
2387 if (vam->graph_nodes)
2389 hash_free (vam->graph_node_index_by_name);
2391 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2393 node = vam->graph_nodes[i];
2394 vec_free (node->name);
2395 vec_free (node->next_nodes);
2398 vec_free (vam->graph_nodes);
2401 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2402 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2403 vec_free (pvt_copy);
2405 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2407 node = vam->graph_nodes[i];
2408 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2412 static void vl_api_get_node_graph_reply_t_handler_json
2413 (vl_api_get_node_graph_reply_t * mp)
2415 vat_main_t *vam = &vat_main;
2416 api_main_t *am = &api_main;
2418 vat_json_node_t node;
2421 /* $$$$ make this real? */
2422 vat_json_init_object (&node);
2423 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2424 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2426 reply = (u8 *) (mp->reply_in_shmem);
2428 /* Toss the shared-memory original... */
2429 pthread_mutex_lock (&am->vlib_rp->mutex);
2430 oldheap = svm_push_data_heap (am->vlib_rp);
2434 svm_pop_heap (oldheap);
2435 pthread_mutex_unlock (&am->vlib_rp->mutex);
2437 vat_json_print (vam->ofp, &node);
2438 vat_json_free (&node);
2440 vam->retval = ntohl (mp->retval);
2441 vam->result_ready = 1;
2445 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2447 vat_main_t *vam = &vat_main;
2452 s = format (s, "%=16d%=16d%=16d",
2453 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2457 s = format (s, "%=16U%=16d%=16d",
2458 mp->is_ipv6 ? format_ip6_address :
2460 mp->ip_address, mp->priority, mp->weight);
2463 print (vam->ofp, "%v", s);
2468 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2470 vat_main_t *vam = &vat_main;
2471 vat_json_node_t *node = NULL;
2472 struct in6_addr ip6;
2475 if (VAT_JSON_ARRAY != vam->json_tree.type)
2477 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2478 vat_json_init_array (&vam->json_tree);
2480 node = vat_json_array_add (&vam->json_tree);
2481 vat_json_init_object (node);
2483 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2484 vat_json_object_add_uint (node, "priority", mp->priority);
2485 vat_json_object_add_uint (node, "weight", mp->weight);
2488 vat_json_object_add_uint (node, "sw_if_index",
2489 clib_net_to_host_u32 (mp->sw_if_index));
2494 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2495 vat_json_object_add_ip6 (node, "address", ip6);
2499 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2500 vat_json_object_add_ip4 (node, "address", ip4);
2506 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2509 vat_main_t *vam = &vat_main;
2512 ls_name = format (0, "%s", mp->ls_name);
2514 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2520 vl_api_one_locator_set_details_t_handler_json
2521 (vl_api_one_locator_set_details_t * mp)
2523 vat_main_t *vam = &vat_main;
2524 vat_json_node_t *node = 0;
2527 ls_name = format (0, "%s", mp->ls_name);
2528 vec_add1 (ls_name, 0);
2530 if (VAT_JSON_ARRAY != vam->json_tree.type)
2532 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2533 vat_json_init_array (&vam->json_tree);
2535 node = vat_json_array_add (&vam->json_tree);
2537 vat_json_init_object (node);
2538 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2539 vat_json_object_add_uint (node, "ls_index",
2540 clib_net_to_host_u32 (mp->ls_index));
2545 format_lisp_flat_eid (u8 * s, va_list * args)
2547 u32 type = va_arg (*args, u32);
2548 u8 *eid = va_arg (*args, u8 *);
2549 u32 eid_len = va_arg (*args, u32);
2554 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2556 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2558 return format (s, "%U", format_ethernet_address, eid);
2564 format_lisp_eid_vat (u8 * s, va_list * args)
2566 u32 type = va_arg (*args, u32);
2567 u8 *eid = va_arg (*args, u8 *);
2568 u32 eid_len = va_arg (*args, u32);
2569 u8 *seid = va_arg (*args, u8 *);
2570 u32 seid_len = va_arg (*args, u32);
2571 u32 is_src_dst = va_arg (*args, u32);
2574 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2576 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2582 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2584 vat_main_t *vam = &vat_main;
2585 u8 *s = 0, *eid = 0;
2587 if (~0 == mp->locator_set_index)
2588 s = format (0, "action: %d", mp->action);
2590 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2592 eid = format (0, "%U", format_lisp_eid_vat,
2596 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2599 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2600 clib_net_to_host_u32 (mp->vni),
2602 mp->is_local ? "local" : "remote",
2603 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2604 clib_net_to_host_u16 (mp->key_id), mp->key);
2611 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2614 vat_main_t *vam = &vat_main;
2615 vat_json_node_t *node = 0;
2618 if (VAT_JSON_ARRAY != vam->json_tree.type)
2620 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2621 vat_json_init_array (&vam->json_tree);
2623 node = vat_json_array_add (&vam->json_tree);
2625 vat_json_init_object (node);
2626 if (~0 == mp->locator_set_index)
2627 vat_json_object_add_uint (node, "action", mp->action);
2629 vat_json_object_add_uint (node, "locator_set_index",
2630 clib_net_to_host_u32 (mp->locator_set_index));
2632 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2633 eid = format (0, "%U", format_lisp_eid_vat,
2637 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2639 vat_json_object_add_string_copy (node, "eid", eid);
2640 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2641 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2642 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2646 vat_json_object_add_uint (node, "key_id",
2647 clib_net_to_host_u16 (mp->key_id));
2648 vat_json_object_add_string_copy (node, "key", mp->key);
2654 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
2656 vat_main_t *vam = &vat_main;
2657 u8 *seid = 0, *deid = 0;
2658 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2660 deid = format (0, "%U", format_lisp_eid_vat,
2661 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2663 seid = format (0, "%U", format_lisp_eid_vat,
2664 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2670 format_ip_address_fcn = format_ip4_address;
2672 format_ip_address_fcn = format_ip6_address;
2675 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
2676 clib_net_to_host_u32 (mp->vni),
2678 format_ip_address_fcn, mp->lloc,
2679 format_ip_address_fcn, mp->rloc,
2680 clib_net_to_host_u32 (mp->pkt_count),
2681 clib_net_to_host_u32 (mp->bytes));
2688 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
2690 struct in6_addr ip6;
2692 vat_main_t *vam = &vat_main;
2693 vat_json_node_t *node = 0;
2694 u8 *deid = 0, *seid = 0;
2696 if (VAT_JSON_ARRAY != vam->json_tree.type)
2698 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2699 vat_json_init_array (&vam->json_tree);
2701 node = vat_json_array_add (&vam->json_tree);
2703 vat_json_init_object (node);
2704 deid = format (0, "%U", format_lisp_eid_vat,
2705 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2707 seid = format (0, "%U", format_lisp_eid_vat,
2708 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2713 vat_json_object_add_string_copy (node, "seid", seid);
2714 vat_json_object_add_string_copy (node, "deid", deid);
2715 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2719 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
2720 vat_json_object_add_ip4 (node, "lloc", ip4);
2721 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
2722 vat_json_object_add_ip4 (node, "rloc", ip4);
2726 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
2727 vat_json_object_add_ip6 (node, "lloc", ip6);
2728 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
2729 vat_json_object_add_ip6 (node, "rloc", ip6);
2731 vat_json_object_add_uint (node, "pkt_count",
2732 clib_net_to_host_u32 (mp->pkt_count));
2733 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
2740 vl_api_one_eid_table_map_details_t_handler
2741 (vl_api_one_eid_table_map_details_t * mp)
2743 vat_main_t *vam = &vat_main;
2745 u8 *line = format (0, "%=10d%=10d",
2746 clib_net_to_host_u32 (mp->vni),
2747 clib_net_to_host_u32 (mp->dp_table));
2748 print (vam->ofp, "%v", line);
2753 vl_api_one_eid_table_map_details_t_handler_json
2754 (vl_api_one_eid_table_map_details_t * mp)
2756 vat_main_t *vam = &vat_main;
2757 vat_json_node_t *node = NULL;
2759 if (VAT_JSON_ARRAY != vam->json_tree.type)
2761 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2762 vat_json_init_array (&vam->json_tree);
2764 node = vat_json_array_add (&vam->json_tree);
2765 vat_json_init_object (node);
2766 vat_json_object_add_uint (node, "dp_table",
2767 clib_net_to_host_u32 (mp->dp_table));
2768 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2772 vl_api_one_eid_table_vni_details_t_handler
2773 (vl_api_one_eid_table_vni_details_t * mp)
2775 vat_main_t *vam = &vat_main;
2777 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2778 print (vam->ofp, "%v", line);
2783 vl_api_one_eid_table_vni_details_t_handler_json
2784 (vl_api_one_eid_table_vni_details_t * mp)
2786 vat_main_t *vam = &vat_main;
2787 vat_json_node_t *node = NULL;
2789 if (VAT_JSON_ARRAY != vam->json_tree.type)
2791 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2792 vat_json_init_array (&vam->json_tree);
2794 node = vat_json_array_add (&vam->json_tree);
2795 vat_json_init_object (node);
2796 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2800 vl_api_show_one_map_register_state_reply_t_handler
2801 (vl_api_show_one_map_register_state_reply_t * mp)
2803 vat_main_t *vam = &vat_main;
2804 int retval = clib_net_to_host_u32 (mp->retval);
2806 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2808 vam->retval = retval;
2809 vam->result_ready = 1;
2813 vl_api_show_one_map_register_state_reply_t_handler_json
2814 (vl_api_show_one_map_register_state_reply_t * mp)
2816 vat_main_t *vam = &vat_main;
2817 vat_json_node_t _node, *node = &_node;
2818 int retval = clib_net_to_host_u32 (mp->retval);
2820 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2822 vat_json_init_object (node);
2823 vat_json_object_add_string_copy (node, "state", s);
2825 vat_json_print (vam->ofp, node);
2826 vat_json_free (node);
2828 vam->retval = retval;
2829 vam->result_ready = 1;
2834 vl_api_show_one_rloc_probe_state_reply_t_handler
2835 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2837 vat_main_t *vam = &vat_main;
2838 int retval = clib_net_to_host_u32 (mp->retval);
2843 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2845 vam->retval = retval;
2846 vam->result_ready = 1;
2850 vl_api_show_one_rloc_probe_state_reply_t_handler_json
2851 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2853 vat_main_t *vam = &vat_main;
2854 vat_json_node_t _node, *node = &_node;
2855 int retval = clib_net_to_host_u32 (mp->retval);
2857 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2858 vat_json_init_object (node);
2859 vat_json_object_add_string_copy (node, "state", s);
2861 vat_json_print (vam->ofp, node);
2862 vat_json_free (node);
2864 vam->retval = retval;
2865 vam->result_ready = 1;
2870 vl_api_show_one_stats_enable_disable_reply_t_handler
2871 (vl_api_show_one_stats_enable_disable_reply_t * mp)
2873 vat_main_t *vam = &vat_main;
2874 int retval = clib_net_to_host_u32 (mp->retval);
2879 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
2881 vam->retval = retval;
2882 vam->result_ready = 1;
2886 vl_api_show_one_stats_enable_disable_reply_t_handler_json
2887 (vl_api_show_one_stats_enable_disable_reply_t * mp)
2889 vat_main_t *vam = &vat_main;
2890 vat_json_node_t _node, *node = &_node;
2891 int retval = clib_net_to_host_u32 (mp->retval);
2893 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
2894 vat_json_init_object (node);
2895 vat_json_object_add_string_copy (node, "state", s);
2897 vat_json_print (vam->ofp, node);
2898 vat_json_free (node);
2900 vam->retval = retval;
2901 vam->result_ready = 1;
2906 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
2908 e->dp_table = clib_net_to_host_u32 (e->dp_table);
2909 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
2913 gpe_fwd_entries_get_reply_t_net_to_host
2914 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2918 mp->count = clib_net_to_host_u32 (mp->count);
2919 for (i = 0; i < mp->count; i++)
2921 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
2926 format_gpe_encap_mode (u8 * s, va_list * args)
2928 u32 mode = va_arg (*args, u32);
2933 return format (s, "lisp");
2935 return format (s, "vxlan");
2941 vl_api_gpe_get_encap_mode_reply_t_handler
2942 (vl_api_gpe_get_encap_mode_reply_t * mp)
2944 vat_main_t *vam = &vat_main;
2946 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
2947 vam->retval = ntohl (mp->retval);
2948 vam->result_ready = 1;
2952 vl_api_gpe_get_encap_mode_reply_t_handler_json
2953 (vl_api_gpe_get_encap_mode_reply_t * mp)
2955 vat_main_t *vam = &vat_main;
2956 vat_json_node_t node;
2958 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
2959 vec_add1 (encap_mode, 0);
2961 vat_json_init_object (&node);
2962 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
2964 vec_free (encap_mode);
2965 vat_json_print (vam->ofp, &node);
2966 vat_json_free (&node);
2968 vam->retval = ntohl (mp->retval);
2969 vam->result_ready = 1;
2973 vl_api_gpe_fwd_entry_path_details_t_handler
2974 (vl_api_gpe_fwd_entry_path_details_t * mp)
2976 vat_main_t *vam = &vat_main;
2977 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2979 if (mp->lcl_loc.is_ip4)
2980 format_ip_address_fcn = format_ip4_address;
2982 format_ip_address_fcn = format_ip6_address;
2984 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
2985 format_ip_address_fcn, &mp->lcl_loc,
2986 format_ip_address_fcn, &mp->rmt_loc);
2990 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
2992 struct in6_addr ip6;
2997 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
2998 vat_json_object_add_ip4 (n, "address", ip4);
3002 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3003 vat_json_object_add_ip6 (n, "address", ip6);
3005 vat_json_object_add_uint (n, "weight", loc->weight);
3009 vl_api_gpe_fwd_entry_path_details_t_handler_json
3010 (vl_api_gpe_fwd_entry_path_details_t * mp)
3012 vat_main_t *vam = &vat_main;
3013 vat_json_node_t *node = NULL;
3014 vat_json_node_t *loc_node;
3016 if (VAT_JSON_ARRAY != vam->json_tree.type)
3018 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3019 vat_json_init_array (&vam->json_tree);
3021 node = vat_json_array_add (&vam->json_tree);
3022 vat_json_init_object (node);
3024 loc_node = vat_json_object_add (node, "local_locator");
3025 vat_json_init_object (loc_node);
3026 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3028 loc_node = vat_json_object_add (node, "remote_locator");
3029 vat_json_init_object (loc_node);
3030 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3034 vl_api_gpe_fwd_entries_get_reply_t_handler
3035 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3037 vat_main_t *vam = &vat_main;
3039 int retval = clib_net_to_host_u32 (mp->retval);
3040 vl_api_gpe_fwd_entry_t *e;
3045 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3047 for (i = 0; i < mp->count; i++)
3049 e = &mp->entries[i];
3050 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3051 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3052 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3056 vam->retval = retval;
3057 vam->result_ready = 1;
3061 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3062 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3065 vat_main_t *vam = &vat_main;
3066 vat_json_node_t *e = 0, root;
3068 int retval = clib_net_to_host_u32 (mp->retval);
3069 vl_api_gpe_fwd_entry_t *fwd;
3074 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3075 vat_json_init_array (&root);
3077 for (i = 0; i < mp->count; i++)
3079 e = vat_json_array_add (&root);
3080 fwd = &mp->entries[i];
3082 vat_json_init_object (e);
3083 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3084 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3086 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3087 fwd->leid_prefix_len);
3089 vat_json_object_add_string_copy (e, "leid", s);
3092 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3093 fwd->reid_prefix_len);
3095 vat_json_object_add_string_copy (e, "reid", s);
3099 vat_json_print (vam->ofp, &root);
3100 vat_json_free (&root);
3103 vam->retval = retval;
3104 vam->result_ready = 1;
3108 vl_api_one_adjacencies_get_reply_t_handler
3109 (vl_api_one_adjacencies_get_reply_t * mp)
3111 vat_main_t *vam = &vat_main;
3113 int retval = clib_net_to_host_u32 (mp->retval);
3114 vl_api_one_adjacency_t *a;
3119 n = clib_net_to_host_u32 (mp->count);
3121 for (i = 0; i < n; i++)
3123 a = &mp->adjacencies[i];
3124 print (vam->ofp, "%U %40U",
3125 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3126 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3130 vam->retval = retval;
3131 vam->result_ready = 1;
3135 vl_api_one_adjacencies_get_reply_t_handler_json
3136 (vl_api_one_adjacencies_get_reply_t * mp)
3139 vat_main_t *vam = &vat_main;
3140 vat_json_node_t *e = 0, root;
3142 int retval = clib_net_to_host_u32 (mp->retval);
3143 vl_api_one_adjacency_t *a;
3148 n = clib_net_to_host_u32 (mp->count);
3149 vat_json_init_array (&root);
3151 for (i = 0; i < n; i++)
3153 e = vat_json_array_add (&root);
3154 a = &mp->adjacencies[i];
3156 vat_json_init_object (e);
3157 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3158 a->leid_prefix_len);
3160 vat_json_object_add_string_copy (e, "leid", s);
3163 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3164 a->reid_prefix_len);
3166 vat_json_object_add_string_copy (e, "reid", s);
3170 vat_json_print (vam->ofp, &root);
3171 vat_json_free (&root);
3174 vam->retval = retval;
3175 vam->result_ready = 1;
3179 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3181 vat_main_t *vam = &vat_main;
3183 print (vam->ofp, "%=20U",
3184 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3189 vl_api_one_map_server_details_t_handler_json
3190 (vl_api_one_map_server_details_t * mp)
3192 vat_main_t *vam = &vat_main;
3193 vat_json_node_t *node = NULL;
3194 struct in6_addr ip6;
3197 if (VAT_JSON_ARRAY != vam->json_tree.type)
3199 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3200 vat_json_init_array (&vam->json_tree);
3202 node = vat_json_array_add (&vam->json_tree);
3204 vat_json_init_object (node);
3207 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3208 vat_json_object_add_ip6 (node, "map-server", ip6);
3212 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3213 vat_json_object_add_ip4 (node, "map-server", ip4);
3218 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3221 vat_main_t *vam = &vat_main;
3223 print (vam->ofp, "%=20U",
3224 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3229 vl_api_one_map_resolver_details_t_handler_json
3230 (vl_api_one_map_resolver_details_t * mp)
3232 vat_main_t *vam = &vat_main;
3233 vat_json_node_t *node = NULL;
3234 struct in6_addr ip6;
3237 if (VAT_JSON_ARRAY != vam->json_tree.type)
3239 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3240 vat_json_init_array (&vam->json_tree);
3242 node = vat_json_array_add (&vam->json_tree);
3244 vat_json_init_object (node);
3247 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3248 vat_json_object_add_ip6 (node, "map resolver", ip6);
3252 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3253 vat_json_object_add_ip4 (node, "map resolver", ip4);
3258 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3260 vat_main_t *vam = &vat_main;
3261 i32 retval = ntohl (mp->retval);
3265 print (vam->ofp, "feature: %s\ngpe: %s",
3266 mp->feature_status ? "enabled" : "disabled",
3267 mp->gpe_status ? "enabled" : "disabled");
3270 vam->retval = retval;
3271 vam->result_ready = 1;
3275 vl_api_show_one_status_reply_t_handler_json
3276 (vl_api_show_one_status_reply_t * mp)
3278 vat_main_t *vam = &vat_main;
3279 vat_json_node_t node;
3280 u8 *gpe_status = NULL;
3281 u8 *feature_status = NULL;
3283 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3284 feature_status = format (0, "%s",
3285 mp->feature_status ? "enabled" : "disabled");
3286 vec_add1 (gpe_status, 0);
3287 vec_add1 (feature_status, 0);
3289 vat_json_init_object (&node);
3290 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3291 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3293 vec_free (gpe_status);
3294 vec_free (feature_status);
3296 vat_json_print (vam->ofp, &node);
3297 vat_json_free (&node);
3299 vam->retval = ntohl (mp->retval);
3300 vam->result_ready = 1;
3304 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3305 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3307 vat_main_t *vam = &vat_main;
3308 i32 retval = ntohl (mp->retval);
3312 print (vam->ofp, "%=20s", mp->locator_set_name);
3315 vam->retval = retval;
3316 vam->result_ready = 1;
3320 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3321 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3323 vat_main_t *vam = &vat_main;
3324 vat_json_node_t *node = NULL;
3326 if (VAT_JSON_ARRAY != vam->json_tree.type)
3328 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3329 vat_json_init_array (&vam->json_tree);
3331 node = vat_json_array_add (&vam->json_tree);
3333 vat_json_init_object (node);
3334 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3336 vat_json_print (vam->ofp, node);
3337 vat_json_free (node);
3339 vam->retval = ntohl (mp->retval);
3340 vam->result_ready = 1;
3344 format_lisp_map_request_mode (u8 * s, va_list * args)
3346 u32 mode = va_arg (*args, u32);
3351 return format (0, "dst-only");
3353 return format (0, "src-dst");
3359 vl_api_show_one_map_request_mode_reply_t_handler
3360 (vl_api_show_one_map_request_mode_reply_t * mp)
3362 vat_main_t *vam = &vat_main;
3363 i32 retval = ntohl (mp->retval);
3367 u32 mode = mp->mode;
3368 print (vam->ofp, "map_request_mode: %U",
3369 format_lisp_map_request_mode, mode);
3372 vam->retval = retval;
3373 vam->result_ready = 1;
3377 vl_api_show_one_map_request_mode_reply_t_handler_json
3378 (vl_api_show_one_map_request_mode_reply_t * mp)
3380 vat_main_t *vam = &vat_main;
3381 vat_json_node_t node;
3386 s = format (0, "%U", format_lisp_map_request_mode, mode);
3389 vat_json_init_object (&node);
3390 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3391 vat_json_print (vam->ofp, &node);
3392 vat_json_free (&node);
3395 vam->retval = ntohl (mp->retval);
3396 vam->result_ready = 1;
3400 vl_api_show_one_use_petr_reply_t_handler
3401 (vl_api_show_one_use_petr_reply_t * mp)
3403 vat_main_t *vam = &vat_main;
3404 i32 retval = ntohl (mp->retval);
3408 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
3411 print (vam->ofp, "Proxy-ETR address; %U",
3412 mp->is_ip4 ? format_ip4_address : format_ip6_address,
3417 vam->retval = retval;
3418 vam->result_ready = 1;
3422 vl_api_show_one_use_petr_reply_t_handler_json
3423 (vl_api_show_one_use_petr_reply_t * mp)
3425 vat_main_t *vam = &vat_main;
3426 vat_json_node_t node;
3429 struct in6_addr ip6;
3431 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3432 vec_add1 (status, 0);
3434 vat_json_init_object (&node);
3435 vat_json_object_add_string_copy (&node, "status", status);
3440 clib_memcpy (&ip6, mp->address, sizeof (ip6));
3441 vat_json_object_add_ip6 (&node, "address", ip6);
3445 clib_memcpy (&ip4, mp->address, sizeof (ip4));
3446 vat_json_object_add_ip4 (&node, "address", ip4);
3452 vat_json_print (vam->ofp, &node);
3453 vat_json_free (&node);
3455 vam->retval = ntohl (mp->retval);
3456 vam->result_ready = 1;
3460 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3462 vat_main_t *vam = &vat_main;
3463 i32 retval = ntohl (mp->retval);
3467 print (vam->ofp, "%-20s%-16s",
3468 mp->status ? "enabled" : "disabled",
3469 mp->status ? (char *) mp->locator_set_name : "");
3472 vam->retval = retval;
3473 vam->result_ready = 1;
3477 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3479 vat_main_t *vam = &vat_main;
3480 vat_json_node_t node;
3483 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3484 vec_add1 (status, 0);
3486 vat_json_init_object (&node);
3487 vat_json_object_add_string_copy (&node, "status", status);
3490 vat_json_object_add_string_copy (&node, "locator_set",
3491 mp->locator_set_name);
3496 vat_json_print (vam->ofp, &node);
3497 vat_json_free (&node);
3499 vam->retval = ntohl (mp->retval);
3500 vam->result_ready = 1;
3504 format_policer_type (u8 * s, va_list * va)
3506 u32 i = va_arg (*va, u32);
3508 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3509 s = format (s, "1r2c");
3510 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3511 s = format (s, "1r3c");
3512 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3513 s = format (s, "2r3c-2698");
3514 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3515 s = format (s, "2r3c-4115");
3516 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3517 s = format (s, "2r3c-mef5cf1");
3519 s = format (s, "ILLEGAL");
3524 format_policer_rate_type (u8 * s, va_list * va)
3526 u32 i = va_arg (*va, u32);
3528 if (i == SSE2_QOS_RATE_KBPS)
3529 s = format (s, "kbps");
3530 else if (i == SSE2_QOS_RATE_PPS)
3531 s = format (s, "pps");
3533 s = format (s, "ILLEGAL");
3538 format_policer_round_type (u8 * s, va_list * va)
3540 u32 i = va_arg (*va, u32);
3542 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3543 s = format (s, "closest");
3544 else if (i == SSE2_QOS_ROUND_TO_UP)
3545 s = format (s, "up");
3546 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3547 s = format (s, "down");
3549 s = format (s, "ILLEGAL");
3554 format_policer_action_type (u8 * s, va_list * va)
3556 u32 i = va_arg (*va, u32);
3558 if (i == SSE2_QOS_ACTION_DROP)
3559 s = format (s, "drop");
3560 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3561 s = format (s, "transmit");
3562 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3563 s = format (s, "mark-and-transmit");
3565 s = format (s, "ILLEGAL");
3570 format_dscp (u8 * s, va_list * va)
3572 u32 i = va_arg (*va, u32);
3577 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3581 return format (s, "ILLEGAL");
3583 s = format (s, "%s", t);
3588 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3590 vat_main_t *vam = &vat_main;
3591 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3593 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3594 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3596 conform_dscp_str = format (0, "");
3598 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3599 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3601 exceed_dscp_str = format (0, "");
3603 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3604 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3606 violate_dscp_str = format (0, "");
3608 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3609 "rate type %U, round type %U, %s rate, %s color-aware, "
3610 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3611 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3612 "conform action %U%s, exceed action %U%s, violate action %U%s",
3614 format_policer_type, mp->type,
3617 clib_net_to_host_u64 (mp->cb),
3618 clib_net_to_host_u64 (mp->eb),
3619 format_policer_rate_type, mp->rate_type,
3620 format_policer_round_type, mp->round_type,
3621 mp->single_rate ? "single" : "dual",
3622 mp->color_aware ? "is" : "not",
3623 ntohl (mp->cir_tokens_per_period),
3624 ntohl (mp->pir_tokens_per_period),
3626 ntohl (mp->current_limit),
3627 ntohl (mp->current_bucket),
3628 ntohl (mp->extended_limit),
3629 ntohl (mp->extended_bucket),
3630 clib_net_to_host_u64 (mp->last_update_time),
3631 format_policer_action_type, mp->conform_action_type,
3633 format_policer_action_type, mp->exceed_action_type,
3635 format_policer_action_type, mp->violate_action_type,
3638 vec_free (conform_dscp_str);
3639 vec_free (exceed_dscp_str);
3640 vec_free (violate_dscp_str);
3643 static void vl_api_policer_details_t_handler_json
3644 (vl_api_policer_details_t * mp)
3646 vat_main_t *vam = &vat_main;
3647 vat_json_node_t *node;
3648 u8 *rate_type_str, *round_type_str, *type_str;
3649 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3651 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3653 format (0, "%U", format_policer_round_type, mp->round_type);
3654 type_str = format (0, "%U", format_policer_type, mp->type);
3655 conform_action_str = format (0, "%U", format_policer_action_type,
3656 mp->conform_action_type);
3657 exceed_action_str = format (0, "%U", format_policer_action_type,
3658 mp->exceed_action_type);
3659 violate_action_str = format (0, "%U", format_policer_action_type,
3660 mp->violate_action_type);
3662 if (VAT_JSON_ARRAY != vam->json_tree.type)
3664 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3665 vat_json_init_array (&vam->json_tree);
3667 node = vat_json_array_add (&vam->json_tree);
3669 vat_json_init_object (node);
3670 vat_json_object_add_string_copy (node, "name", mp->name);
3671 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3672 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3673 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
3674 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
3675 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3676 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3677 vat_json_object_add_string_copy (node, "type", type_str);
3678 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3679 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3680 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3681 vat_json_object_add_uint (node, "cir_tokens_per_period",
3682 ntohl (mp->cir_tokens_per_period));
3683 vat_json_object_add_uint (node, "eir_tokens_per_period",
3684 ntohl (mp->pir_tokens_per_period));
3685 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3686 vat_json_object_add_uint (node, "current_bucket",
3687 ntohl (mp->current_bucket));
3688 vat_json_object_add_uint (node, "extended_limit",
3689 ntohl (mp->extended_limit));
3690 vat_json_object_add_uint (node, "extended_bucket",
3691 ntohl (mp->extended_bucket));
3692 vat_json_object_add_uint (node, "last_update_time",
3693 ntohl (mp->last_update_time));
3694 vat_json_object_add_string_copy (node, "conform_action",
3695 conform_action_str);
3696 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3698 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3699 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3700 vec_free (dscp_str);
3702 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3703 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3705 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3706 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3707 vec_free (dscp_str);
3709 vat_json_object_add_string_copy (node, "violate_action",
3710 violate_action_str);
3711 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3713 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3714 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3715 vec_free (dscp_str);
3718 vec_free (rate_type_str);
3719 vec_free (round_type_str);
3720 vec_free (type_str);
3721 vec_free (conform_action_str);
3722 vec_free (exceed_action_str);
3723 vec_free (violate_action_str);
3727 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3730 vat_main_t *vam = &vat_main;
3731 int i, count = ntohl (mp->count);
3734 print (vam->ofp, "classify table ids (%d) : ", count);
3735 for (i = 0; i < count; i++)
3737 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3738 print (vam->ofp, (i < count - 1) ? "," : "");
3740 vam->retval = ntohl (mp->retval);
3741 vam->result_ready = 1;
3745 vl_api_classify_table_ids_reply_t_handler_json
3746 (vl_api_classify_table_ids_reply_t * mp)
3748 vat_main_t *vam = &vat_main;
3749 int i, count = ntohl (mp->count);
3753 vat_json_node_t node;
3755 vat_json_init_object (&node);
3756 for (i = 0; i < count; i++)
3758 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3760 vat_json_print (vam->ofp, &node);
3761 vat_json_free (&node);
3763 vam->retval = ntohl (mp->retval);
3764 vam->result_ready = 1;
3768 vl_api_classify_table_by_interface_reply_t_handler
3769 (vl_api_classify_table_by_interface_reply_t * mp)
3771 vat_main_t *vam = &vat_main;
3774 table_id = ntohl (mp->l2_table_id);
3776 print (vam->ofp, "l2 table id : %d", table_id);
3778 print (vam->ofp, "l2 table id : No input ACL tables configured");
3779 table_id = ntohl (mp->ip4_table_id);
3781 print (vam->ofp, "ip4 table id : %d", table_id);
3783 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3784 table_id = ntohl (mp->ip6_table_id);
3786 print (vam->ofp, "ip6 table id : %d", table_id);
3788 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3789 vam->retval = ntohl (mp->retval);
3790 vam->result_ready = 1;
3794 vl_api_classify_table_by_interface_reply_t_handler_json
3795 (vl_api_classify_table_by_interface_reply_t * mp)
3797 vat_main_t *vam = &vat_main;
3798 vat_json_node_t node;
3800 vat_json_init_object (&node);
3802 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3803 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3804 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3806 vat_json_print (vam->ofp, &node);
3807 vat_json_free (&node);
3809 vam->retval = ntohl (mp->retval);
3810 vam->result_ready = 1;
3813 static void vl_api_policer_add_del_reply_t_handler
3814 (vl_api_policer_add_del_reply_t * mp)
3816 vat_main_t *vam = &vat_main;
3817 i32 retval = ntohl (mp->retval);
3818 if (vam->async_mode)
3820 vam->async_errors += (retval < 0);
3824 vam->retval = retval;
3825 vam->result_ready = 1;
3826 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3828 * Note: this is just barely thread-safe, depends on
3829 * the main thread spinning waiting for an answer...
3831 errmsg ("policer index %d", ntohl (mp->policer_index));
3835 static void vl_api_policer_add_del_reply_t_handler_json
3836 (vl_api_policer_add_del_reply_t * mp)
3838 vat_main_t *vam = &vat_main;
3839 vat_json_node_t node;
3841 vat_json_init_object (&node);
3842 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3843 vat_json_object_add_uint (&node, "policer_index",
3844 ntohl (mp->policer_index));
3846 vat_json_print (vam->ofp, &node);
3847 vat_json_free (&node);
3849 vam->retval = ntohl (mp->retval);
3850 vam->result_ready = 1;
3853 /* Format hex dump. */
3855 format_hex_bytes (u8 * s, va_list * va)
3857 u8 *bytes = va_arg (*va, u8 *);
3858 int n_bytes = va_arg (*va, int);
3861 /* Print short or long form depending on byte count. */
3862 uword short_form = n_bytes <= 32;
3863 uword indent = format_get_indent (s);
3868 for (i = 0; i < n_bytes; i++)
3870 if (!short_form && (i % 32) == 0)
3871 s = format (s, "%08x: ", i);
3872 s = format (s, "%02x", bytes[i]);
3873 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3874 s = format (s, "\n%U", format_white_space, indent);
3881 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3884 vat_main_t *vam = &vat_main;
3885 i32 retval = ntohl (mp->retval);
3888 print (vam->ofp, "classify table info :");
3889 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3890 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3891 ntohl (mp->miss_next_index));
3892 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3893 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3894 ntohl (mp->match_n_vectors));
3895 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3896 ntohl (mp->mask_length));
3898 vam->retval = retval;
3899 vam->result_ready = 1;
3903 vl_api_classify_table_info_reply_t_handler_json
3904 (vl_api_classify_table_info_reply_t * mp)
3906 vat_main_t *vam = &vat_main;
3907 vat_json_node_t node;
3909 i32 retval = ntohl (mp->retval);
3912 vat_json_init_object (&node);
3914 vat_json_object_add_int (&node, "sessions",
3915 ntohl (mp->active_sessions));
3916 vat_json_object_add_int (&node, "nexttbl",
3917 ntohl (mp->next_table_index));
3918 vat_json_object_add_int (&node, "nextnode",
3919 ntohl (mp->miss_next_index));
3920 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3921 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3922 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3923 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3924 ntohl (mp->mask_length), 0);
3925 vat_json_object_add_string_copy (&node, "mask", s);
3927 vat_json_print (vam->ofp, &node);
3928 vat_json_free (&node);
3930 vam->retval = ntohl (mp->retval);
3931 vam->result_ready = 1;
3935 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3938 vat_main_t *vam = &vat_main;
3940 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3941 ntohl (mp->hit_next_index), ntohl (mp->advance),
3942 ntohl (mp->opaque_index));
3943 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3944 ntohl (mp->match_length));
3948 vl_api_classify_session_details_t_handler_json
3949 (vl_api_classify_session_details_t * mp)
3951 vat_main_t *vam = &vat_main;
3952 vat_json_node_t *node = NULL;
3954 if (VAT_JSON_ARRAY != vam->json_tree.type)
3956 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3957 vat_json_init_array (&vam->json_tree);
3959 node = vat_json_array_add (&vam->json_tree);
3961 vat_json_init_object (node);
3962 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3963 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3964 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3966 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3968 vat_json_object_add_string_copy (node, "match", s);
3971 static void vl_api_pg_create_interface_reply_t_handler
3972 (vl_api_pg_create_interface_reply_t * mp)
3974 vat_main_t *vam = &vat_main;
3976 vam->retval = ntohl (mp->retval);
3977 vam->result_ready = 1;
3980 static void vl_api_pg_create_interface_reply_t_handler_json
3981 (vl_api_pg_create_interface_reply_t * mp)
3983 vat_main_t *vam = &vat_main;
3984 vat_json_node_t node;
3986 i32 retval = ntohl (mp->retval);
3989 vat_json_init_object (&node);
3991 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3993 vat_json_print (vam->ofp, &node);
3994 vat_json_free (&node);
3996 vam->retval = ntohl (mp->retval);
3997 vam->result_ready = 1;
4000 static void vl_api_policer_classify_details_t_handler
4001 (vl_api_policer_classify_details_t * mp)
4003 vat_main_t *vam = &vat_main;
4005 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4006 ntohl (mp->table_index));
4009 static void vl_api_policer_classify_details_t_handler_json
4010 (vl_api_policer_classify_details_t * mp)
4012 vat_main_t *vam = &vat_main;
4013 vat_json_node_t *node;
4015 if (VAT_JSON_ARRAY != vam->json_tree.type)
4017 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4018 vat_json_init_array (&vam->json_tree);
4020 node = vat_json_array_add (&vam->json_tree);
4022 vat_json_init_object (node);
4023 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4024 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4027 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4028 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4030 vat_main_t *vam = &vat_main;
4031 i32 retval = ntohl (mp->retval);
4032 if (vam->async_mode)
4034 vam->async_errors += (retval < 0);
4038 vam->retval = retval;
4039 vam->sw_if_index = ntohl (mp->sw_if_index);
4040 vam->result_ready = 1;
4044 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4045 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4047 vat_main_t *vam = &vat_main;
4048 vat_json_node_t node;
4050 vat_json_init_object (&node);
4051 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4052 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4054 vat_json_print (vam->ofp, &node);
4055 vat_json_free (&node);
4057 vam->retval = ntohl (mp->retval);
4058 vam->result_ready = 1;
4061 static void vl_api_flow_classify_details_t_handler
4062 (vl_api_flow_classify_details_t * mp)
4064 vat_main_t *vam = &vat_main;
4066 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4067 ntohl (mp->table_index));
4070 static void vl_api_flow_classify_details_t_handler_json
4071 (vl_api_flow_classify_details_t * mp)
4073 vat_main_t *vam = &vat_main;
4074 vat_json_node_t *node;
4076 if (VAT_JSON_ARRAY != vam->json_tree.type)
4078 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4079 vat_json_init_array (&vam->json_tree);
4081 node = vat_json_array_add (&vam->json_tree);
4083 vat_json_init_object (node);
4084 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4085 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4090 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4091 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4092 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4093 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4094 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4095 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4096 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4097 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4098 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4099 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4102 * Generate boilerplate reply handlers, which
4103 * dig the return value out of the xxx_reply_t API message,
4104 * stick it into vam->retval, and set vam->result_ready
4106 * Could also do this by pointing N message decode slots at
4107 * a single function, but that could break in subtle ways.
4110 #define foreach_standard_reply_retval_handler \
4111 _(sw_interface_set_flags_reply) \
4112 _(sw_interface_add_del_address_reply) \
4113 _(sw_interface_set_table_reply) \
4114 _(sw_interface_set_mpls_enable_reply) \
4115 _(sw_interface_set_vpath_reply) \
4116 _(sw_interface_set_vxlan_bypass_reply) \
4117 _(sw_interface_set_l2_bridge_reply) \
4118 _(bridge_domain_add_del_reply) \
4119 _(sw_interface_set_l2_xconnect_reply) \
4120 _(l2fib_add_del_reply) \
4121 _(ip_add_del_route_reply) \
4122 _(ip_mroute_add_del_reply) \
4123 _(mpls_route_add_del_reply) \
4124 _(mpls_ip_bind_unbind_reply) \
4125 _(proxy_arp_add_del_reply) \
4126 _(proxy_arp_intfc_enable_disable_reply) \
4127 _(sw_interface_set_unnumbered_reply) \
4128 _(ip_neighbor_add_del_reply) \
4129 _(reset_vrf_reply) \
4130 _(oam_add_del_reply) \
4131 _(reset_fib_reply) \
4132 _(dhcp_proxy_config_reply) \
4133 _(dhcp_proxy_set_vss_reply) \
4134 _(dhcp_client_config_reply) \
4135 _(set_ip_flow_hash_reply) \
4136 _(sw_interface_ip6_enable_disable_reply) \
4137 _(sw_interface_ip6_set_link_local_address_reply) \
4138 _(ip6nd_proxy_add_del_reply) \
4139 _(sw_interface_ip6nd_ra_prefix_reply) \
4140 _(sw_interface_ip6nd_ra_config_reply) \
4141 _(set_arp_neighbor_limit_reply) \
4142 _(l2_patch_add_del_reply) \
4143 _(sr_policy_add_reply) \
4144 _(sr_policy_mod_reply) \
4145 _(sr_policy_del_reply) \
4146 _(sr_localsid_add_del_reply) \
4147 _(sr_steering_add_del_reply) \
4148 _(classify_add_del_session_reply) \
4149 _(classify_set_interface_ip_table_reply) \
4150 _(classify_set_interface_l2_tables_reply) \
4151 _(l2tpv3_set_tunnel_cookies_reply) \
4152 _(l2tpv3_interface_enable_disable_reply) \
4153 _(l2tpv3_set_lookup_key_reply) \
4154 _(l2_fib_clear_table_reply) \
4155 _(l2_interface_efp_filter_reply) \
4156 _(l2_interface_vlan_tag_rewrite_reply) \
4157 _(modify_vhost_user_if_reply) \
4158 _(delete_vhost_user_if_reply) \
4159 _(want_ip4_arp_events_reply) \
4160 _(want_ip6_nd_events_reply) \
4161 _(input_acl_set_interface_reply) \
4162 _(ipsec_spd_add_del_reply) \
4163 _(ipsec_interface_add_del_spd_reply) \
4164 _(ipsec_spd_add_del_entry_reply) \
4165 _(ipsec_sad_add_del_entry_reply) \
4166 _(ipsec_sa_set_key_reply) \
4167 _(ikev2_profile_add_del_reply) \
4168 _(ikev2_profile_set_auth_reply) \
4169 _(ikev2_profile_set_id_reply) \
4170 _(ikev2_profile_set_ts_reply) \
4171 _(ikev2_set_local_key_reply) \
4172 _(ikev2_set_responder_reply) \
4173 _(ikev2_set_ike_transforms_reply) \
4174 _(ikev2_set_esp_transforms_reply) \
4175 _(ikev2_set_sa_lifetime_reply) \
4176 _(ikev2_initiate_sa_init_reply) \
4177 _(ikev2_initiate_del_ike_sa_reply) \
4178 _(ikev2_initiate_del_child_sa_reply) \
4179 _(ikev2_initiate_rekey_child_sa_reply) \
4180 _(delete_loopback_reply) \
4181 _(bd_ip_mac_add_del_reply) \
4182 _(map_del_domain_reply) \
4183 _(map_add_del_rule_reply) \
4184 _(want_interface_events_reply) \
4185 _(want_stats_reply) \
4186 _(cop_interface_enable_disable_reply) \
4187 _(cop_whitelist_enable_disable_reply) \
4188 _(sw_interface_clear_stats_reply) \
4189 _(ioam_enable_reply) \
4190 _(ioam_disable_reply) \
4191 _(one_add_del_locator_reply) \
4192 _(one_add_del_local_eid_reply) \
4193 _(one_add_del_remote_mapping_reply) \
4194 _(one_add_del_adjacency_reply) \
4195 _(one_add_del_map_resolver_reply) \
4196 _(one_add_del_map_server_reply) \
4197 _(one_enable_disable_reply) \
4198 _(one_rloc_probe_enable_disable_reply) \
4199 _(one_map_register_enable_disable_reply) \
4200 _(one_pitr_set_locator_set_reply) \
4201 _(one_map_request_mode_reply) \
4202 _(one_add_del_map_request_itr_rlocs_reply) \
4203 _(one_eid_table_add_del_map_reply) \
4204 _(one_use_petr_reply) \
4205 _(one_stats_enable_disable_reply) \
4206 _(gpe_add_del_fwd_entry_reply) \
4207 _(gpe_enable_disable_reply) \
4208 _(gpe_set_encap_mode_reply) \
4209 _(gpe_add_del_iface_reply) \
4210 _(vxlan_gpe_add_del_tunnel_reply) \
4211 _(af_packet_delete_reply) \
4212 _(policer_classify_set_interface_reply) \
4213 _(netmap_create_reply) \
4214 _(netmap_delete_reply) \
4215 _(set_ipfix_exporter_reply) \
4216 _(set_ipfix_classify_stream_reply) \
4217 _(ipfix_classify_table_add_del_reply) \
4218 _(flow_classify_set_interface_reply) \
4219 _(sw_interface_span_enable_disable_reply) \
4220 _(pg_capture_reply) \
4221 _(pg_enable_disable_reply) \
4222 _(ip_source_and_port_range_check_add_del_reply) \
4223 _(ip_source_and_port_range_check_interface_add_del_reply)\
4224 _(delete_subif_reply) \
4225 _(l2_interface_pbb_tag_rewrite_reply) \
4227 _(feature_enable_disable_reply) \
4228 _(sw_interface_tag_add_del_reply) \
4229 _(sw_interface_set_mtu_reply)
4232 static void vl_api_##n##_t_handler \
4233 (vl_api_##n##_t * mp) \
4235 vat_main_t * vam = &vat_main; \
4236 i32 retval = ntohl(mp->retval); \
4237 if (vam->async_mode) { \
4238 vam->async_errors += (retval < 0); \
4240 vam->retval = retval; \
4241 vam->result_ready = 1; \
4244 foreach_standard_reply_retval_handler;
4248 static void vl_api_##n##_t_handler_json \
4249 (vl_api_##n##_t * mp) \
4251 vat_main_t * vam = &vat_main; \
4252 vat_json_node_t node; \
4253 vat_json_init_object(&node); \
4254 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4255 vat_json_print(vam->ofp, &node); \
4256 vam->retval = ntohl(mp->retval); \
4257 vam->result_ready = 1; \
4259 foreach_standard_reply_retval_handler;
4263 * Table of message reply handlers, must include boilerplate handlers
4267 #define foreach_vpe_api_reply_msg \
4268 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4269 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4270 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4271 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4272 _(CONTROL_PING_REPLY, control_ping_reply) \
4273 _(CLI_REPLY, cli_reply) \
4274 _(CLI_INBAND_REPLY, cli_inband_reply) \
4275 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4276 sw_interface_add_del_address_reply) \
4277 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4278 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4279 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4280 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4281 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4282 sw_interface_set_l2_xconnect_reply) \
4283 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4284 sw_interface_set_l2_bridge_reply) \
4285 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4286 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4287 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
4288 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4289 _(L2_FLAGS_REPLY, l2_flags_reply) \
4290 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4291 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4292 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4293 _(TAP_DELETE_REPLY, tap_delete_reply) \
4294 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4295 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4296 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4297 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4298 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4299 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4300 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4301 proxy_arp_intfc_enable_disable_reply) \
4302 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4303 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4304 sw_interface_set_unnumbered_reply) \
4305 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4306 _(RESET_VRF_REPLY, reset_vrf_reply) \
4307 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4308 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4309 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4310 _(RESET_FIB_REPLY, reset_fib_reply) \
4311 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4312 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4313 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4314 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4315 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4316 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4317 sw_interface_ip6_enable_disable_reply) \
4318 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4319 sw_interface_ip6_set_link_local_address_reply) \
4320 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
4321 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
4322 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4323 sw_interface_ip6nd_ra_prefix_reply) \
4324 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4325 sw_interface_ip6nd_ra_config_reply) \
4326 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4327 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4328 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4329 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4330 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4331 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4332 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4333 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4334 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4335 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4336 classify_set_interface_ip_table_reply) \
4337 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4338 classify_set_interface_l2_tables_reply) \
4339 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4340 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4341 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4342 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4343 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4344 l2tpv3_interface_enable_disable_reply) \
4345 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4346 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4347 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4348 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4349 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4350 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4351 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4352 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4353 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4354 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4355 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4356 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4357 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4358 _(SHOW_VERSION_REPLY, show_version_reply) \
4359 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
4360 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4361 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4362 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4363 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4364 _(IP4_ARP_EVENT, ip4_arp_event) \
4365 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4366 _(IP6_ND_EVENT, ip6_nd_event) \
4367 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4368 _(IP_ADDRESS_DETAILS, ip_address_details) \
4369 _(IP_DETAILS, ip_details) \
4370 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4371 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4372 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4373 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4374 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4375 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4376 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4377 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4378 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4379 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4380 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4381 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4382 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4383 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4384 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4385 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4386 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4387 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4388 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4389 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4390 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4391 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4392 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4393 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4394 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4395 _(MAP_RULE_DETAILS, map_rule_details) \
4396 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4397 _(WANT_STATS_REPLY, want_stats_reply) \
4398 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4399 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4400 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4401 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4402 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4403 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4404 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4405 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4406 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4407 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4408 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4409 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4410 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4411 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4412 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4413 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4414 one_map_register_enable_disable_reply) \
4415 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4416 one_rloc_probe_enable_disable_reply) \
4417 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4418 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
4419 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4420 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4421 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4422 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4423 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4424 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4425 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4426 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4427 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4428 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4429 _(ONE_STATS_DETAILS, one_stats_details) \
4430 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
4431 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
4432 show_one_stats_enable_disable_reply) \
4433 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4434 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4435 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4436 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4437 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4438 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4439 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4440 gpe_fwd_entry_path_details) \
4441 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4442 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4443 one_add_del_map_request_itr_rlocs_reply) \
4444 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4445 one_get_map_request_itr_rlocs_reply) \
4446 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4447 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
4448 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4449 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4450 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4451 show_one_map_register_state_reply) \
4452 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4453 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4454 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4455 _(POLICER_DETAILS, policer_details) \
4456 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4457 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4458 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4459 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4460 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4461 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4462 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4463 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4464 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4465 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4466 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4467 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4468 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4469 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4470 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4471 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4472 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4473 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4474 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4475 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4476 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4477 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4478 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4479 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4480 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4481 ip_source_and_port_range_check_add_del_reply) \
4482 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4483 ip_source_and_port_range_check_interface_add_del_reply) \
4484 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4485 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4486 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4487 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4488 _(PUNT_REPLY, punt_reply) \
4489 _(IP_FIB_DETAILS, ip_fib_details) \
4490 _(IP6_FIB_DETAILS, ip6_fib_details) \
4491 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4492 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4493 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4494 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4495 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4496 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4498 #define foreach_standalone_reply_msg \
4499 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4500 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
4501 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4502 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4503 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4504 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
4513 #define STR_VTR_OP_CASE(op) \
4514 case L2_VTR_ ## op: \
4518 str_vtr_op (u32 vtr_op)
4522 STR_VTR_OP_CASE (DISABLED);
4523 STR_VTR_OP_CASE (PUSH_1);
4524 STR_VTR_OP_CASE (PUSH_2);
4525 STR_VTR_OP_CASE (POP_1);
4526 STR_VTR_OP_CASE (POP_2);
4527 STR_VTR_OP_CASE (TRANSLATE_1_1);
4528 STR_VTR_OP_CASE (TRANSLATE_1_2);
4529 STR_VTR_OP_CASE (TRANSLATE_2_1);
4530 STR_VTR_OP_CASE (TRANSLATE_2_2);
4537 dump_sub_interface_table (vat_main_t * vam)
4539 const sw_interface_subif_t *sub = NULL;
4541 if (vam->json_output)
4544 ("JSON output supported only for VPE API calls and dump_stats_table");
4549 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4550 "Interface", "sw_if_index",
4551 "sub id", "dot1ad", "tags", "outer id",
4552 "inner id", "exact", "default", "outer any", "inner any");
4554 vec_foreach (sub, vam->sw_if_subif_table)
4557 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4558 sub->interface_name,
4560 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4561 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4562 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4563 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4564 if (sub->vtr_op != L2_VTR_DISABLED)
4567 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4568 "tag1: %d tag2: %d ]",
4569 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4570 sub->vtr_tag1, sub->vtr_tag2);
4578 name_sort_cmp (void *a1, void *a2)
4580 name_sort_t *n1 = a1;
4581 name_sort_t *n2 = a2;
4583 return strcmp ((char *) n1->name, (char *) n2->name);
4587 dump_interface_table (vat_main_t * vam)
4590 name_sort_t *nses = 0, *ns;
4592 if (vam->json_output)
4595 ("JSON output supported only for VPE API calls and dump_stats_table");
4600 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4602 vec_add2 (nses, ns, 1);
4603 ns->name = (u8 *)(p->key);
4604 ns->value = (u32) p->value[0];
4608 vec_sort_with_function (nses, name_sort_cmp);
4610 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4611 vec_foreach (ns, nses)
4613 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4620 dump_ip_table (vat_main_t * vam, int is_ipv6)
4622 const ip_details_t *det = NULL;
4623 const ip_address_details_t *address = NULL;
4626 print (vam->ofp, "%-12s", "sw_if_index");
4628 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4635 print (vam->ofp, "%-12d", i);
4636 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4641 vec_foreach (address, det->addr)
4645 is_ipv6 ? format_ip6_address : format_ip4_address,
4646 address->ip, address->prefix_length);
4654 dump_ipv4_table (vat_main_t * vam)
4656 if (vam->json_output)
4659 ("JSON output supported only for VPE API calls and dump_stats_table");
4663 return dump_ip_table (vam, 0);
4667 dump_ipv6_table (vat_main_t * vam)
4669 if (vam->json_output)
4672 ("JSON output supported only for VPE API calls and dump_stats_table");
4676 return dump_ip_table (vam, 1);
4680 counter_type_to_str (u8 counter_type, u8 is_combined)
4684 switch (counter_type)
4686 case VNET_INTERFACE_COUNTER_DROP:
4688 case VNET_INTERFACE_COUNTER_PUNT:
4690 case VNET_INTERFACE_COUNTER_IP4:
4692 case VNET_INTERFACE_COUNTER_IP6:
4694 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4696 case VNET_INTERFACE_COUNTER_RX_MISS:
4698 case VNET_INTERFACE_COUNTER_RX_ERROR:
4700 case VNET_INTERFACE_COUNTER_TX_ERROR:
4703 return "INVALID-COUNTER-TYPE";
4708 switch (counter_type)
4710 case VNET_INTERFACE_COUNTER_RX:
4712 case VNET_INTERFACE_COUNTER_TX:
4715 return "INVALID-COUNTER-TYPE";
4721 dump_stats_table (vat_main_t * vam)
4723 vat_json_node_t node;
4724 vat_json_node_t *msg_array;
4725 vat_json_node_t *msg;
4726 vat_json_node_t *counter_array;
4727 vat_json_node_t *counter;
4728 interface_counter_t c;
4730 ip4_fib_counter_t *c4;
4731 ip6_fib_counter_t *c6;
4732 ip4_nbr_counter_t *n4;
4733 ip6_nbr_counter_t *n6;
4736 if (!vam->json_output)
4738 clib_warning ("dump_stats_table supported only in JSON format");
4742 vat_json_init_object (&node);
4744 /* interface counters */
4745 msg_array = vat_json_object_add (&node, "interface_counters");
4746 vat_json_init_array (msg_array);
4747 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4749 msg = vat_json_array_add (msg_array);
4750 vat_json_init_object (msg);
4751 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4752 (u8 *) counter_type_to_str (i, 0));
4753 vat_json_object_add_int (msg, "is_combined", 0);
4754 counter_array = vat_json_object_add (msg, "data");
4755 vat_json_init_array (counter_array);
4756 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4758 packets = vam->simple_interface_counters[i][j];
4759 vat_json_array_add_uint (counter_array, packets);
4762 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4764 msg = vat_json_array_add (msg_array);
4765 vat_json_init_object (msg);
4766 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4767 (u8 *) counter_type_to_str (i, 1));
4768 vat_json_object_add_int (msg, "is_combined", 1);
4769 counter_array = vat_json_object_add (msg, "data");
4770 vat_json_init_array (counter_array);
4771 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4773 c = vam->combined_interface_counters[i][j];
4774 counter = vat_json_array_add (counter_array);
4775 vat_json_init_object (counter);
4776 vat_json_object_add_uint (counter, "packets", c.packets);
4777 vat_json_object_add_uint (counter, "bytes", c.bytes);
4781 /* ip4 fib counters */
4782 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4783 vat_json_init_array (msg_array);
4784 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4786 msg = vat_json_array_add (msg_array);
4787 vat_json_init_object (msg);
4788 vat_json_object_add_uint (msg, "vrf_id",
4789 vam->ip4_fib_counters_vrf_id_by_index[i]);
4790 counter_array = vat_json_object_add (msg, "c");
4791 vat_json_init_array (counter_array);
4792 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4794 counter = vat_json_array_add (counter_array);
4795 vat_json_init_object (counter);
4796 c4 = &vam->ip4_fib_counters[i][j];
4797 vat_json_object_add_ip4 (counter, "address", c4->address);
4798 vat_json_object_add_uint (counter, "address_length",
4799 c4->address_length);
4800 vat_json_object_add_uint (counter, "packets", c4->packets);
4801 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4805 /* ip6 fib counters */
4806 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4807 vat_json_init_array (msg_array);
4808 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4810 msg = vat_json_array_add (msg_array);
4811 vat_json_init_object (msg);
4812 vat_json_object_add_uint (msg, "vrf_id",
4813 vam->ip6_fib_counters_vrf_id_by_index[i]);
4814 counter_array = vat_json_object_add (msg, "c");
4815 vat_json_init_array (counter_array);
4816 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4818 counter = vat_json_array_add (counter_array);
4819 vat_json_init_object (counter);
4820 c6 = &vam->ip6_fib_counters[i][j];
4821 vat_json_object_add_ip6 (counter, "address", c6->address);
4822 vat_json_object_add_uint (counter, "address_length",
4823 c6->address_length);
4824 vat_json_object_add_uint (counter, "packets", c6->packets);
4825 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4829 /* ip4 nbr counters */
4830 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4831 vat_json_init_array (msg_array);
4832 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4834 msg = vat_json_array_add (msg_array);
4835 vat_json_init_object (msg);
4836 vat_json_object_add_uint (msg, "sw_if_index", i);
4837 counter_array = vat_json_object_add (msg, "c");
4838 vat_json_init_array (counter_array);
4839 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4841 counter = vat_json_array_add (counter_array);
4842 vat_json_init_object (counter);
4843 n4 = &vam->ip4_nbr_counters[i][j];
4844 vat_json_object_add_ip4 (counter, "address", n4->address);
4845 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4846 vat_json_object_add_uint (counter, "packets", n4->packets);
4847 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4851 /* ip6 nbr counters */
4852 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4853 vat_json_init_array (msg_array);
4854 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4856 msg = vat_json_array_add (msg_array);
4857 vat_json_init_object (msg);
4858 vat_json_object_add_uint (msg, "sw_if_index", i);
4859 counter_array = vat_json_object_add (msg, "c");
4860 vat_json_init_array (counter_array);
4861 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4863 counter = vat_json_array_add (counter_array);
4864 vat_json_init_object (counter);
4865 n6 = &vam->ip6_nbr_counters[i][j];
4866 vat_json_object_add_ip6 (counter, "address", n6->address);
4867 vat_json_object_add_uint (counter, "packets", n6->packets);
4868 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4872 vat_json_print (vam->ofp, &node);
4873 vat_json_free (&node);
4879 exec (vat_main_t * vam)
4881 api_main_t *am = &api_main;
4882 vl_api_cli_request_t *mp;
4886 unformat_input_t *i = vam->input;
4888 if (vec_len (i->buffer) == 0)
4891 if (vam->exec_mode == 0 && unformat (i, "mode"))
4896 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4903 M (CLI_REQUEST, mp);
4906 * Copy cmd into shared memory.
4907 * In order for the CLI command to work, it
4908 * must be a vector ending in \n, not a C-string ending
4911 pthread_mutex_lock (&am->vlib_rp->mutex);
4912 oldheap = svm_push_data_heap (am->vlib_rp);
4914 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4915 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4917 svm_pop_heap (oldheap);
4918 pthread_mutex_unlock (&am->vlib_rp->mutex);
4920 mp->cmd_in_shmem = (u64) cmd;
4922 timeout = vat_time_now (vam) + 10.0;
4924 while (vat_time_now (vam) < timeout)
4926 if (vam->result_ready == 1)
4929 if (vam->shmem_result != NULL)
4930 print (vam->ofp, "%s", vam->shmem_result);
4931 pthread_mutex_lock (&am->vlib_rp->mutex);
4932 oldheap = svm_push_data_heap (am->vlib_rp);
4934 free_me = (u8 *) vam->shmem_result;
4937 svm_pop_heap (oldheap);
4938 pthread_mutex_unlock (&am->vlib_rp->mutex);
4946 * Future replacement of exec() that passes CLI buffers directly in
4947 * the API messages instead of an additional shared memory area.
4950 exec_inband (vat_main_t * vam)
4952 vl_api_cli_inband_t *mp;
4953 unformat_input_t *i = vam->input;
4956 if (vec_len (i->buffer) == 0)
4959 if (vam->exec_mode == 0 && unformat (i, "mode"))
4964 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4971 * In order for the CLI command to work, it
4972 * must be a vector ending in \n, not a C-string ending
4975 u32 len = vec_len (vam->input->buffer);
4976 M2 (CLI_INBAND, mp, len);
4977 clib_memcpy (mp->cmd, vam->input->buffer, len);
4978 mp->length = htonl (len);
4981 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
4986 api_create_loopback (vat_main_t * vam)
4988 unformat_input_t *i = vam->input;
4989 vl_api_create_loopback_t *mp;
4990 vl_api_create_loopback_instance_t *mp_lbi;
4993 u8 is_specified = 0;
4994 u32 user_instance = 0;
4997 memset (mac_address, 0, sizeof (mac_address));
4999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5001 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5003 if (unformat (i, "instance %d", &user_instance))
5011 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5012 mp_lbi->is_specified = is_specified;
5014 mp_lbi->user_instance = htonl (user_instance);
5016 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5021 /* Construct the API message */
5022 M (CREATE_LOOPBACK, mp);
5024 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5033 api_delete_loopback (vat_main_t * vam)
5035 unformat_input_t *i = vam->input;
5036 vl_api_delete_loopback_t *mp;
5037 u32 sw_if_index = ~0;
5040 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5042 if (unformat (i, "sw_if_index %d", &sw_if_index))
5048 if (sw_if_index == ~0)
5050 errmsg ("missing sw_if_index");
5054 /* Construct the API message */
5055 M (DELETE_LOOPBACK, mp);
5056 mp->sw_if_index = ntohl (sw_if_index);
5064 api_want_stats (vat_main_t * vam)
5066 unformat_input_t *i = vam->input;
5067 vl_api_want_stats_t *mp;
5071 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5073 if (unformat (i, "enable"))
5075 else if (unformat (i, "disable"))
5083 errmsg ("missing enable|disable");
5088 mp->enable_disable = enable;
5096 api_want_interface_events (vat_main_t * vam)
5098 unformat_input_t *i = vam->input;
5099 vl_api_want_interface_events_t *mp;
5103 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5105 if (unformat (i, "enable"))
5107 else if (unformat (i, "disable"))
5115 errmsg ("missing enable|disable");
5119 M (WANT_INTERFACE_EVENTS, mp);
5120 mp->enable_disable = enable;
5122 vam->interface_event_display = enable;
5130 /* Note: non-static, called once to set up the initial intfc table */
5132 api_sw_interface_dump (vat_main_t * vam)
5134 vl_api_sw_interface_dump_t *mp;
5135 vl_api_control_ping_t *mp_ping;
5137 name_sort_t *nses = 0, *ns;
5138 sw_interface_subif_t *sub = NULL;
5141 /* Toss the old name table */
5143 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5145 vec_add2 (nses, ns, 1);
5146 ns->name = (u8 *)(p->key);
5147 ns->value = (u32) p->value[0];
5151 hash_free (vam->sw_if_index_by_interface_name);
5153 vec_foreach (ns, nses) vec_free (ns->name);
5157 vec_foreach (sub, vam->sw_if_subif_table)
5159 vec_free (sub->interface_name);
5161 vec_free (vam->sw_if_subif_table);
5163 /* recreate the interface name hash table */
5164 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5166 /* Get list of ethernets */
5167 M (SW_INTERFACE_DUMP, mp);
5168 mp->name_filter_valid = 1;
5169 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
5172 /* and local / loopback interfaces */
5173 M (SW_INTERFACE_DUMP, mp);
5174 mp->name_filter_valid = 1;
5175 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
5178 /* and packet-generator interfaces */
5179 M (SW_INTERFACE_DUMP, mp);
5180 mp->name_filter_valid = 1;
5181 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
5184 /* and vxlan-gpe tunnel interfaces */
5185 M (SW_INTERFACE_DUMP, mp);
5186 mp->name_filter_valid = 1;
5187 strncpy ((char *) mp->name_filter, "vxlan_gpe",
5188 sizeof (mp->name_filter) - 1);
5191 /* and vxlan tunnel interfaces */
5192 M (SW_INTERFACE_DUMP, mp);
5193 mp->name_filter_valid = 1;
5194 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
5197 /* and host (af_packet) interfaces */
5198 M (SW_INTERFACE_DUMP, mp);
5199 mp->name_filter_valid = 1;
5200 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
5203 /* and l2tpv3 tunnel interfaces */
5204 M (SW_INTERFACE_DUMP, mp);
5205 mp->name_filter_valid = 1;
5206 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
5207 sizeof (mp->name_filter) - 1);
5210 /* and GRE tunnel interfaces */
5211 M (SW_INTERFACE_DUMP, mp);
5212 mp->name_filter_valid = 1;
5213 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
5216 /* and LISP-GPE interfaces */
5217 M (SW_INTERFACE_DUMP, mp);
5218 mp->name_filter_valid = 1;
5219 strncpy ((char *) mp->name_filter, "lisp_gpe",
5220 sizeof (mp->name_filter) - 1);
5223 /* and IPSEC tunnel interfaces */
5224 M (SW_INTERFACE_DUMP, mp);
5225 mp->name_filter_valid = 1;
5226 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
5229 /* Use a control ping for synchronization */
5230 M (CONTROL_PING, mp_ping);
5238 api_sw_interface_set_flags (vat_main_t * vam)
5240 unformat_input_t *i = vam->input;
5241 vl_api_sw_interface_set_flags_t *mp;
5243 u8 sw_if_index_set = 0;
5244 u8 admin_up = 0, link_up = 0;
5247 /* Parse args required to build the message */
5248 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5250 if (unformat (i, "admin-up"))
5252 else if (unformat (i, "admin-down"))
5254 else if (unformat (i, "link-up"))
5256 else if (unformat (i, "link-down"))
5259 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5260 sw_if_index_set = 1;
5261 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5262 sw_if_index_set = 1;
5267 if (sw_if_index_set == 0)
5269 errmsg ("missing interface name or sw_if_index");
5273 /* Construct the API message */
5274 M (SW_INTERFACE_SET_FLAGS, mp);
5275 mp->sw_if_index = ntohl (sw_if_index);
5276 mp->admin_up_down = admin_up;
5277 mp->link_up_down = link_up;
5282 /* Wait for a reply, return the good/bad news... */
5288 api_sw_interface_clear_stats (vat_main_t * vam)
5290 unformat_input_t *i = vam->input;
5291 vl_api_sw_interface_clear_stats_t *mp;
5293 u8 sw_if_index_set = 0;
5296 /* Parse args required to build the message */
5297 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5299 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5300 sw_if_index_set = 1;
5301 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5302 sw_if_index_set = 1;
5307 /* Construct the API message */
5308 M (SW_INTERFACE_CLEAR_STATS, mp);
5310 if (sw_if_index_set == 1)
5311 mp->sw_if_index = ntohl (sw_if_index);
5313 mp->sw_if_index = ~0;
5318 /* Wait for a reply, return the good/bad news... */
5324 api_sw_interface_add_del_address (vat_main_t * vam)
5326 unformat_input_t *i = vam->input;
5327 vl_api_sw_interface_add_del_address_t *mp;
5329 u8 sw_if_index_set = 0;
5330 u8 is_add = 1, del_all = 0;
5331 u32 address_length = 0;
5332 u8 v4_address_set = 0;
5333 u8 v6_address_set = 0;
5334 ip4_address_t v4address;
5335 ip6_address_t v6address;
5338 /* Parse args required to build the message */
5339 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5341 if (unformat (i, "del-all"))
5343 else if (unformat (i, "del"))
5346 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5347 sw_if_index_set = 1;
5348 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5349 sw_if_index_set = 1;
5350 else if (unformat (i, "%U/%d",
5351 unformat_ip4_address, &v4address, &address_length))
5353 else if (unformat (i, "%U/%d",
5354 unformat_ip6_address, &v6address, &address_length))
5360 if (sw_if_index_set == 0)
5362 errmsg ("missing interface name or sw_if_index");
5365 if (v4_address_set && v6_address_set)
5367 errmsg ("both v4 and v6 addresses set");
5370 if (!v4_address_set && !v6_address_set && !del_all)
5372 errmsg ("no addresses set");
5376 /* Construct the API message */
5377 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5379 mp->sw_if_index = ntohl (sw_if_index);
5380 mp->is_add = is_add;
5381 mp->del_all = del_all;
5385 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5389 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5391 mp->address_length = address_length;
5396 /* Wait for a reply, return good/bad news */
5402 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5404 unformat_input_t *i = vam->input;
5405 vl_api_sw_interface_set_mpls_enable_t *mp;
5407 u8 sw_if_index_set = 0;
5411 /* Parse args required to build the message */
5412 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5414 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5415 sw_if_index_set = 1;
5416 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5417 sw_if_index_set = 1;
5418 else if (unformat (i, "disable"))
5420 else if (unformat (i, "dis"))
5426 if (sw_if_index_set == 0)
5428 errmsg ("missing interface name or sw_if_index");
5432 /* Construct the API message */
5433 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5435 mp->sw_if_index = ntohl (sw_if_index);
5436 mp->enable = enable;
5441 /* Wait for a reply... */
5447 api_sw_interface_set_table (vat_main_t * vam)
5449 unformat_input_t *i = vam->input;
5450 vl_api_sw_interface_set_table_t *mp;
5451 u32 sw_if_index, vrf_id = 0;
5452 u8 sw_if_index_set = 0;
5456 /* Parse args required to build the message */
5457 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5459 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5460 sw_if_index_set = 1;
5461 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5462 sw_if_index_set = 1;
5463 else if (unformat (i, "vrf %d", &vrf_id))
5465 else if (unformat (i, "ipv6"))
5471 if (sw_if_index_set == 0)
5473 errmsg ("missing interface name or sw_if_index");
5477 /* Construct the API message */
5478 M (SW_INTERFACE_SET_TABLE, mp);
5480 mp->sw_if_index = ntohl (sw_if_index);
5481 mp->is_ipv6 = is_ipv6;
5482 mp->vrf_id = ntohl (vrf_id);
5487 /* Wait for a reply... */
5492 static void vl_api_sw_interface_get_table_reply_t_handler
5493 (vl_api_sw_interface_get_table_reply_t * mp)
5495 vat_main_t *vam = &vat_main;
5497 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5499 vam->retval = ntohl (mp->retval);
5500 vam->result_ready = 1;
5504 static void vl_api_sw_interface_get_table_reply_t_handler_json
5505 (vl_api_sw_interface_get_table_reply_t * mp)
5507 vat_main_t *vam = &vat_main;
5508 vat_json_node_t node;
5510 vat_json_init_object (&node);
5511 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5512 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5514 vat_json_print (vam->ofp, &node);
5515 vat_json_free (&node);
5517 vam->retval = ntohl (mp->retval);
5518 vam->result_ready = 1;
5522 api_sw_interface_get_table (vat_main_t * vam)
5524 unformat_input_t *i = vam->input;
5525 vl_api_sw_interface_get_table_t *mp;
5527 u8 sw_if_index_set = 0;
5531 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5533 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5534 sw_if_index_set = 1;
5535 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5536 sw_if_index_set = 1;
5537 else if (unformat (i, "ipv6"))
5543 if (sw_if_index_set == 0)
5545 errmsg ("missing interface name or sw_if_index");
5549 M (SW_INTERFACE_GET_TABLE, mp);
5550 mp->sw_if_index = htonl (sw_if_index);
5551 mp->is_ipv6 = is_ipv6;
5559 api_sw_interface_set_vpath (vat_main_t * vam)
5561 unformat_input_t *i = vam->input;
5562 vl_api_sw_interface_set_vpath_t *mp;
5563 u32 sw_if_index = 0;
5564 u8 sw_if_index_set = 0;
5568 /* Parse args required to build the message */
5569 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5571 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5572 sw_if_index_set = 1;
5573 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5574 sw_if_index_set = 1;
5575 else if (unformat (i, "enable"))
5577 else if (unformat (i, "disable"))
5583 if (sw_if_index_set == 0)
5585 errmsg ("missing interface name or sw_if_index");
5589 /* Construct the API message */
5590 M (SW_INTERFACE_SET_VPATH, mp);
5592 mp->sw_if_index = ntohl (sw_if_index);
5593 mp->enable = is_enable;
5598 /* Wait for a reply... */
5604 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5606 unformat_input_t *i = vam->input;
5607 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5608 u32 sw_if_index = 0;
5609 u8 sw_if_index_set = 0;
5614 /* Parse args required to build the message */
5615 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5617 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5618 sw_if_index_set = 1;
5619 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5620 sw_if_index_set = 1;
5621 else if (unformat (i, "enable"))
5623 else if (unformat (i, "disable"))
5625 else if (unformat (i, "ip4"))
5627 else if (unformat (i, "ip6"))
5633 if (sw_if_index_set == 0)
5635 errmsg ("missing interface name or sw_if_index");
5639 /* Construct the API message */
5640 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5642 mp->sw_if_index = ntohl (sw_if_index);
5643 mp->enable = is_enable;
5644 mp->is_ipv6 = is_ipv6;
5649 /* Wait for a reply... */
5655 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5657 unformat_input_t *i = vam->input;
5658 vl_api_sw_interface_set_l2_xconnect_t *mp;
5660 u8 rx_sw_if_index_set = 0;
5662 u8 tx_sw_if_index_set = 0;
5666 /* Parse args required to build the message */
5667 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5669 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5670 rx_sw_if_index_set = 1;
5671 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5672 tx_sw_if_index_set = 1;
5673 else if (unformat (i, "rx"))
5675 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5677 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5679 rx_sw_if_index_set = 1;
5684 else if (unformat (i, "tx"))
5686 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5688 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5690 tx_sw_if_index_set = 1;
5695 else if (unformat (i, "enable"))
5697 else if (unformat (i, "disable"))
5703 if (rx_sw_if_index_set == 0)
5705 errmsg ("missing rx interface name or rx_sw_if_index");
5709 if (enable && (tx_sw_if_index_set == 0))
5711 errmsg ("missing tx interface name or tx_sw_if_index");
5715 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5717 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5718 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5719 mp->enable = enable;
5727 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5729 unformat_input_t *i = vam->input;
5730 vl_api_sw_interface_set_l2_bridge_t *mp;
5732 u8 rx_sw_if_index_set = 0;
5740 /* Parse args required to build the message */
5741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5743 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5744 rx_sw_if_index_set = 1;
5745 else if (unformat (i, "bd_id %d", &bd_id))
5749 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5750 rx_sw_if_index_set = 1;
5751 else if (unformat (i, "shg %d", &shg))
5753 else if (unformat (i, "bvi"))
5755 else if (unformat (i, "enable"))
5757 else if (unformat (i, "disable"))
5763 if (rx_sw_if_index_set == 0)
5765 errmsg ("missing rx interface name or sw_if_index");
5769 if (enable && (bd_id_set == 0))
5771 errmsg ("missing bridge domain");
5775 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
5777 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5778 mp->bd_id = ntohl (bd_id);
5781 mp->enable = enable;
5789 api_bridge_domain_dump (vat_main_t * vam)
5791 unformat_input_t *i = vam->input;
5792 vl_api_bridge_domain_dump_t *mp;
5793 vl_api_control_ping_t *mp_ping;
5797 /* Parse args required to build the message */
5798 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5800 if (unformat (i, "bd_id %d", &bd_id))
5806 M (BRIDGE_DOMAIN_DUMP, mp);
5807 mp->bd_id = ntohl (bd_id);
5810 /* Use a control ping for synchronization */
5811 M (CONTROL_PING, mp_ping);
5819 api_bridge_domain_add_del (vat_main_t * vam)
5821 unformat_input_t *i = vam->input;
5822 vl_api_bridge_domain_add_del_t *mp;
5825 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5829 /* Parse args required to build the message */
5830 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5832 if (unformat (i, "bd_id %d", &bd_id))
5834 else if (unformat (i, "flood %d", &flood))
5836 else if (unformat (i, "uu-flood %d", &uu_flood))
5838 else if (unformat (i, "forward %d", &forward))
5840 else if (unformat (i, "learn %d", &learn))
5842 else if (unformat (i, "arp-term %d", &arp_term))
5844 else if (unformat (i, "mac-age %d", &mac_age))
5846 else if (unformat (i, "del"))
5849 flood = uu_flood = forward = learn = 0;
5857 errmsg ("missing bridge domain");
5863 errmsg ("mac age must be less than 256 ");
5867 M (BRIDGE_DOMAIN_ADD_DEL, mp);
5869 mp->bd_id = ntohl (bd_id);
5871 mp->uu_flood = uu_flood;
5872 mp->forward = forward;
5874 mp->arp_term = arp_term;
5875 mp->is_add = is_add;
5876 mp->mac_age = (u8) mac_age;
5884 api_l2fib_add_del (vat_main_t * vam)
5886 unformat_input_t *i = vam->input;
5887 vl_api_l2fib_add_del_t *mp;
5893 u32 sw_if_index = ~0;
5894 u8 sw_if_index_set = 0;
5903 /* Parse args required to build the message */
5904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5906 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5908 else if (unformat (i, "bd_id %d", &bd_id))
5910 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5911 sw_if_index_set = 1;
5912 else if (unformat (i, "sw_if"))
5914 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5917 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5918 sw_if_index_set = 1;
5923 else if (unformat (i, "static"))
5925 else if (unformat (i, "filter"))
5930 else if (unformat (i, "bvi"))
5935 else if (unformat (i, "del"))
5937 else if (unformat (i, "count %d", &count))
5945 errmsg ("missing mac address");
5951 errmsg ("missing bridge domain");
5955 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5957 errmsg ("missing interface name or sw_if_index");
5963 /* Turn on async mode */
5964 vam->async_mode = 1;
5965 vam->async_errors = 0;
5966 before = vat_time_now (vam);
5969 for (j = 0; j < count; j++)
5971 M (L2FIB_ADD_DEL, mp);
5974 mp->bd_id = ntohl (bd_id);
5975 mp->is_add = is_add;
5979 mp->sw_if_index = ntohl (sw_if_index);
5980 mp->static_mac = static_mac;
5981 mp->filter_mac = filter_mac;
5982 mp->bvi_mac = bvi_mac;
5984 increment_mac_address (&mac);
5991 vl_api_control_ping_t *mp_ping;
5994 /* Shut off async mode */
5995 vam->async_mode = 0;
5997 M (CONTROL_PING, mp_ping);
6000 timeout = vat_time_now (vam) + 1.0;
6001 while (vat_time_now (vam) < timeout)
6002 if (vam->result_ready == 1)
6007 if (vam->retval == -99)
6010 if (vam->async_errors > 0)
6012 errmsg ("%d asynchronous errors", vam->async_errors);
6015 vam->async_errors = 0;
6016 after = vat_time_now (vam);
6018 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6019 count, after - before, count / (after - before));
6025 /* Wait for a reply... */
6029 /* Return the good/bad news */
6030 return (vam->retval);
6034 api_l2_flags (vat_main_t * vam)
6036 unformat_input_t *i = vam->input;
6037 vl_api_l2_flags_t *mp;
6039 u32 feature_bitmap = 0;
6040 u8 sw_if_index_set = 0;
6043 /* Parse args required to build the message */
6044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6046 if (unformat (i, "sw_if_index %d", &sw_if_index))
6047 sw_if_index_set = 1;
6048 else if (unformat (i, "sw_if"))
6050 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6053 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6054 sw_if_index_set = 1;
6059 else if (unformat (i, "learn"))
6060 feature_bitmap |= L2INPUT_FEAT_LEARN;
6061 else if (unformat (i, "forward"))
6062 feature_bitmap |= L2INPUT_FEAT_FWD;
6063 else if (unformat (i, "flood"))
6064 feature_bitmap |= L2INPUT_FEAT_FLOOD;
6065 else if (unformat (i, "uu-flood"))
6066 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
6071 if (sw_if_index_set == 0)
6073 errmsg ("missing interface name or sw_if_index");
6079 mp->sw_if_index = ntohl (sw_if_index);
6080 mp->feature_bitmap = ntohl (feature_bitmap);
6088 api_bridge_flags (vat_main_t * vam)
6090 unformat_input_t *i = vam->input;
6091 vl_api_bridge_flags_t *mp;
6098 /* Parse args required to build the message */
6099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6101 if (unformat (i, "bd_id %d", &bd_id))
6103 else if (unformat (i, "learn"))
6105 else if (unformat (i, "forward"))
6107 else if (unformat (i, "flood"))
6109 else if (unformat (i, "uu-flood"))
6110 flags |= L2_UU_FLOOD;
6111 else if (unformat (i, "arp-term"))
6112 flags |= L2_ARP_TERM;
6113 else if (unformat (i, "off"))
6115 else if (unformat (i, "disable"))
6123 errmsg ("missing bridge domain");
6127 M (BRIDGE_FLAGS, mp);
6129 mp->bd_id = ntohl (bd_id);
6130 mp->feature_bitmap = ntohl (flags);
6131 mp->is_set = is_set;
6139 api_bd_ip_mac_add_del (vat_main_t * vam)
6141 unformat_input_t *i = vam->input;
6142 vl_api_bd_ip_mac_add_del_t *mp;
6149 ip4_address_t v4addr;
6150 ip6_address_t v6addr;
6155 /* Parse args required to build the message */
6156 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6158 if (unformat (i, "bd_id %d", &bd_id))
6162 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6166 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6171 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6175 else if (unformat (i, "del"))
6183 errmsg ("missing bridge domain");
6186 else if (ip_set == 0)
6188 errmsg ("missing IP address");
6191 else if (mac_set == 0)
6193 errmsg ("missing MAC address");
6197 M (BD_IP_MAC_ADD_DEL, mp);
6199 mp->bd_id = ntohl (bd_id);
6200 mp->is_ipv6 = is_ipv6;
6201 mp->is_add = is_add;
6203 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6205 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6206 clib_memcpy (mp->mac_address, macaddr, 6);
6213 api_tap_connect (vat_main_t * vam)
6215 unformat_input_t *i = vam->input;
6216 vl_api_tap_connect_t *mp;
6222 ip4_address_t ip4_address;
6224 int ip4_address_set = 0;
6225 ip6_address_t ip6_address;
6227 int ip6_address_set = 0;
6230 memset (mac_address, 0, sizeof (mac_address));
6232 /* Parse args required to build the message */
6233 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6235 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6239 else if (unformat (i, "random-mac"))
6241 else if (unformat (i, "tapname %s", &tap_name))
6243 else if (unformat (i, "tag %s", &tag))
6245 else if (unformat (i, "address %U/%d",
6246 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6247 ip4_address_set = 1;
6248 else if (unformat (i, "address %U/%d",
6249 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6250 ip6_address_set = 1;
6257 errmsg ("missing tap name");
6260 if (vec_len (tap_name) > 63)
6262 errmsg ("tap name too long");
6265 vec_add1 (tap_name, 0);
6267 if (vec_len (tag) > 63)
6269 errmsg ("tag too long");
6273 /* Construct the API message */
6274 M (TAP_CONNECT, mp);
6276 mp->use_random_mac = random_mac;
6277 clib_memcpy (mp->mac_address, mac_address, 6);
6278 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6280 clib_memcpy (mp->tag, tag, vec_len (tag));
6282 if (ip4_address_set)
6284 mp->ip4_address_set = 1;
6285 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6286 mp->ip4_mask_width = ip4_mask_width;
6288 if (ip6_address_set)
6290 mp->ip6_address_set = 1;
6291 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6292 mp->ip6_mask_width = ip6_mask_width;
6295 vec_free (tap_name);
6301 /* Wait for a reply... */
6307 api_tap_modify (vat_main_t * vam)
6309 unformat_input_t *i = vam->input;
6310 vl_api_tap_modify_t *mp;
6315 u32 sw_if_index = ~0;
6316 u8 sw_if_index_set = 0;
6319 memset (mac_address, 0, sizeof (mac_address));
6321 /* Parse args required to build the message */
6322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6324 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6325 sw_if_index_set = 1;
6326 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6327 sw_if_index_set = 1;
6328 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6332 else if (unformat (i, "random-mac"))
6334 else if (unformat (i, "tapname %s", &tap_name))
6340 if (sw_if_index_set == 0)
6342 errmsg ("missing vpp interface name");
6347 errmsg ("missing tap name");
6350 if (vec_len (tap_name) > 63)
6352 errmsg ("tap name too long");
6354 vec_add1 (tap_name, 0);
6356 /* Construct the API message */
6359 mp->use_random_mac = random_mac;
6360 mp->sw_if_index = ntohl (sw_if_index);
6361 clib_memcpy (mp->mac_address, mac_address, 6);
6362 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6363 vec_free (tap_name);
6368 /* Wait for a reply... */
6374 api_tap_delete (vat_main_t * vam)
6376 unformat_input_t *i = vam->input;
6377 vl_api_tap_delete_t *mp;
6378 u32 sw_if_index = ~0;
6379 u8 sw_if_index_set = 0;
6382 /* Parse args required to build the message */
6383 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6385 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6386 sw_if_index_set = 1;
6387 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6388 sw_if_index_set = 1;
6393 if (sw_if_index_set == 0)
6395 errmsg ("missing vpp interface name");
6399 /* Construct the API message */
6402 mp->sw_if_index = ntohl (sw_if_index);
6407 /* Wait for a reply... */
6413 api_ip_add_del_route (vat_main_t * vam)
6415 unformat_input_t *i = vam->input;
6416 vl_api_ip_add_del_route_t *mp;
6417 u32 sw_if_index = ~0, vrf_id = 0;
6419 u8 is_local = 0, is_drop = 0;
6420 u8 is_unreach = 0, is_prohibit = 0;
6421 u8 create_vrf_if_needed = 0;
6423 u32 next_hop_weight = 1;
6425 u8 is_multipath = 0;
6427 u8 address_length_set = 0;
6428 u32 next_hop_table_id = 0;
6429 u32 resolve_attempts = 0;
6430 u32 dst_address_length = 0;
6431 u8 next_hop_set = 0;
6432 ip4_address_t v4_dst_address, v4_next_hop_address;
6433 ip6_address_t v6_dst_address, v6_next_hop_address;
6437 u32 random_add_del = 0;
6438 u32 *random_vector = 0;
6440 u32 random_seed = 0xdeaddabe;
6441 u32 classify_table_index = ~0;
6443 u8 resolve_host = 0, resolve_attached = 0;
6444 mpls_label_t *next_hop_out_label_stack = NULL;
6445 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6446 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6448 /* Parse args required to build the message */
6449 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6451 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6453 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6455 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6460 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6465 else if (unformat (i, "/%d", &dst_address_length))
6467 address_length_set = 1;
6470 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6471 &v4_next_hop_address))
6475 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6476 &v6_next_hop_address))
6480 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6482 else if (unformat (i, "weight %d", &next_hop_weight))
6484 else if (unformat (i, "drop"))
6488 else if (unformat (i, "null-send-unreach"))
6492 else if (unformat (i, "null-send-prohibit"))
6496 else if (unformat (i, "local"))
6500 else if (unformat (i, "classify %d", &classify_table_index))
6504 else if (unformat (i, "del"))
6506 else if (unformat (i, "add"))
6508 else if (unformat (i, "not-last"))
6510 else if (unformat (i, "resolve-via-host"))
6512 else if (unformat (i, "resolve-via-attached"))
6513 resolve_attached = 1;
6514 else if (unformat (i, "multipath"))
6516 else if (unformat (i, "vrf %d", &vrf_id))
6518 else if (unformat (i, "create-vrf"))
6519 create_vrf_if_needed = 1;
6520 else if (unformat (i, "count %d", &count))
6522 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6524 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6526 else if (unformat (i, "out-label %d", &next_hop_out_label))
6527 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6528 else if (unformat (i, "via-label %d", &next_hop_via_label))
6530 else if (unformat (i, "random"))
6532 else if (unformat (i, "seed %d", &random_seed))
6536 clib_warning ("parse error '%U'", format_unformat_error, i);
6541 if (!next_hop_set && !is_drop && !is_local &&
6542 !is_classify && !is_unreach && !is_prohibit &&
6543 MPLS_LABEL_INVALID == next_hop_via_label)
6546 ("next hop / local / drop / unreach / prohibit / classify not set");
6550 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6552 errmsg ("next hop and next-hop via label set");
6555 if (address_set == 0)
6557 errmsg ("missing addresses");
6561 if (address_length_set == 0)
6563 errmsg ("missing address length");
6567 /* Generate a pile of unique, random routes */
6570 u32 this_random_address;
6571 random_hash = hash_create (count, sizeof (uword));
6573 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6574 for (j = 0; j <= count; j++)
6578 this_random_address = random_u32 (&random_seed);
6579 this_random_address =
6580 clib_host_to_net_u32 (this_random_address);
6582 while (hash_get (random_hash, this_random_address));
6583 vec_add1 (random_vector, this_random_address);
6584 hash_set (random_hash, this_random_address, 1);
6586 hash_free (random_hash);
6587 v4_dst_address.as_u32 = random_vector[0];
6592 /* Turn on async mode */
6593 vam->async_mode = 1;
6594 vam->async_errors = 0;
6595 before = vat_time_now (vam);
6598 for (j = 0; j < count; j++)
6600 /* Construct the API message */
6601 M2 (IP_ADD_DEL_ROUTE, mp,
6602 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6604 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6605 mp->table_id = ntohl (vrf_id);
6606 mp->create_vrf_if_needed = create_vrf_if_needed;
6608 mp->is_add = is_add;
6609 mp->is_drop = is_drop;
6610 mp->is_unreach = is_unreach;
6611 mp->is_prohibit = is_prohibit;
6612 mp->is_ipv6 = is_ipv6;
6613 mp->is_local = is_local;
6614 mp->is_classify = is_classify;
6615 mp->is_multipath = is_multipath;
6616 mp->is_resolve_host = resolve_host;
6617 mp->is_resolve_attached = resolve_attached;
6618 mp->not_last = not_last;
6619 mp->next_hop_weight = next_hop_weight;
6620 mp->dst_address_length = dst_address_length;
6621 mp->next_hop_table_id = ntohl (next_hop_table_id);
6622 mp->classify_table_index = ntohl (classify_table_index);
6623 mp->next_hop_via_label = ntohl (next_hop_via_label);
6624 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6625 if (0 != mp->next_hop_n_out_labels)
6627 memcpy (mp->next_hop_out_label_stack,
6628 next_hop_out_label_stack,
6629 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6630 vec_free (next_hop_out_label_stack);
6635 clib_memcpy (mp->dst_address, &v6_dst_address,
6636 sizeof (v6_dst_address));
6638 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6639 sizeof (v6_next_hop_address));
6640 increment_v6_address (&v6_dst_address);
6644 clib_memcpy (mp->dst_address, &v4_dst_address,
6645 sizeof (v4_dst_address));
6647 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6648 sizeof (v4_next_hop_address));
6650 v4_dst_address.as_u32 = random_vector[j + 1];
6652 increment_v4_address (&v4_dst_address);
6656 /* If we receive SIGTERM, stop now... */
6661 /* When testing multiple add/del ops, use a control-ping to sync */
6664 vl_api_control_ping_t *mp_ping;
6668 /* Shut off async mode */
6669 vam->async_mode = 0;
6671 M (CONTROL_PING, mp_ping);
6674 timeout = vat_time_now (vam) + 1.0;
6675 while (vat_time_now (vam) < timeout)
6676 if (vam->result_ready == 1)
6681 if (vam->retval == -99)
6684 if (vam->async_errors > 0)
6686 errmsg ("%d asynchronous errors", vam->async_errors);
6689 vam->async_errors = 0;
6690 after = vat_time_now (vam);
6692 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6696 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6697 count, after - before, count / (after - before));
6703 /* Wait for a reply... */
6708 /* Return the good/bad news */
6709 return (vam->retval);
6713 api_ip_mroute_add_del (vat_main_t * vam)
6715 unformat_input_t *i = vam->input;
6716 vl_api_ip_mroute_add_del_t *mp;
6717 u32 sw_if_index = ~0, vrf_id = 0;
6720 u8 create_vrf_if_needed = 0;
6723 u32 grp_address_length = 0;
6724 ip4_address_t v4_grp_address, v4_src_address;
6725 ip6_address_t v6_grp_address, v6_src_address;
6726 mfib_itf_flags_t iflags = 0;
6727 mfib_entry_flags_t eflags = 0;
6730 /* Parse args required to build the message */
6731 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6733 if (unformat (i, "sw_if_index %d", &sw_if_index))
6735 else if (unformat (i, "%U %U",
6736 unformat_ip4_address, &v4_src_address,
6737 unformat_ip4_address, &v4_grp_address))
6739 grp_address_length = 64;
6743 else if (unformat (i, "%U %U",
6744 unformat_ip6_address, &v6_src_address,
6745 unformat_ip6_address, &v6_grp_address))
6747 grp_address_length = 256;
6751 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
6753 memset (&v4_src_address, 0, sizeof (v4_src_address));
6754 grp_address_length = 32;
6758 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
6760 memset (&v6_src_address, 0, sizeof (v6_src_address));
6761 grp_address_length = 128;
6765 else if (unformat (i, "/%d", &grp_address_length))
6767 else if (unformat (i, "local"))
6771 else if (unformat (i, "del"))
6773 else if (unformat (i, "add"))
6775 else if (unformat (i, "vrf %d", &vrf_id))
6777 else if (unformat (i, "create-vrf"))
6778 create_vrf_if_needed = 1;
6779 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
6781 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
6785 clib_warning ("parse error '%U'", format_unformat_error, i);
6790 if (address_set == 0)
6792 errmsg ("missing addresses\n");
6796 /* Construct the API message */
6797 M (IP_MROUTE_ADD_DEL, mp);
6799 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6800 mp->table_id = ntohl (vrf_id);
6801 mp->create_vrf_if_needed = create_vrf_if_needed;
6803 mp->is_add = is_add;
6804 mp->is_ipv6 = is_ipv6;
6805 mp->is_local = is_local;
6806 mp->itf_flags = ntohl (iflags);
6807 mp->entry_flags = ntohl (eflags);
6808 mp->grp_address_length = grp_address_length;
6809 mp->grp_address_length = ntohs (mp->grp_address_length);
6813 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
6814 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
6818 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
6819 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
6825 /* Wait for a reply... */
6831 api_mpls_route_add_del (vat_main_t * vam)
6833 unformat_input_t *i = vam->input;
6834 vl_api_mpls_route_add_del_t *mp;
6835 u32 sw_if_index = ~0, table_id = 0;
6836 u8 create_table_if_needed = 0;
6838 u32 next_hop_weight = 1;
6839 u8 is_multipath = 0;
6840 u32 next_hop_table_id = 0;
6841 u8 next_hop_set = 0;
6842 ip4_address_t v4_next_hop_address = {
6845 ip6_address_t v6_next_hop_address = { {0} };
6849 u32 classify_table_index = ~0;
6851 u8 resolve_host = 0, resolve_attached = 0;
6852 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6853 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6854 mpls_label_t *next_hop_out_label_stack = NULL;
6855 mpls_label_t local_label = MPLS_LABEL_INVALID;
6857 u8 next_hop_proto_is_ip4 = 1;
6859 /* Parse args required to build the message */
6860 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6862 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6864 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6866 else if (unformat (i, "%d", &local_label))
6868 else if (unformat (i, "eos"))
6870 else if (unformat (i, "non-eos"))
6872 else if (unformat (i, "via %U", unformat_ip4_address,
6873 &v4_next_hop_address))
6876 next_hop_proto_is_ip4 = 1;
6878 else if (unformat (i, "via %U", unformat_ip6_address,
6879 &v6_next_hop_address))
6882 next_hop_proto_is_ip4 = 0;
6884 else if (unformat (i, "weight %d", &next_hop_weight))
6886 else if (unformat (i, "create-table"))
6887 create_table_if_needed = 1;
6888 else if (unformat (i, "classify %d", &classify_table_index))
6892 else if (unformat (i, "del"))
6894 else if (unformat (i, "add"))
6896 else if (unformat (i, "resolve-via-host"))
6898 else if (unformat (i, "resolve-via-attached"))
6899 resolve_attached = 1;
6900 else if (unformat (i, "multipath"))
6902 else if (unformat (i, "count %d", &count))
6904 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6907 next_hop_proto_is_ip4 = 1;
6909 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6912 next_hop_proto_is_ip4 = 0;
6914 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6916 else if (unformat (i, "via-label %d", &next_hop_via_label))
6918 else if (unformat (i, "out-label %d", &next_hop_out_label))
6919 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6922 clib_warning ("parse error '%U'", format_unformat_error, i);
6927 if (!next_hop_set && !is_classify)
6929 errmsg ("next hop / classify not set");
6933 if (MPLS_LABEL_INVALID == local_label)
6935 errmsg ("missing label");
6941 /* Turn on async mode */
6942 vam->async_mode = 1;
6943 vam->async_errors = 0;
6944 before = vat_time_now (vam);
6947 for (j = 0; j < count; j++)
6949 /* Construct the API message */
6950 M2 (MPLS_ROUTE_ADD_DEL, mp,
6951 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6953 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6954 mp->mr_table_id = ntohl (table_id);
6955 mp->mr_create_table_if_needed = create_table_if_needed;
6957 mp->mr_is_add = is_add;
6958 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6959 mp->mr_is_classify = is_classify;
6960 mp->mr_is_multipath = is_multipath;
6961 mp->mr_is_resolve_host = resolve_host;
6962 mp->mr_is_resolve_attached = resolve_attached;
6963 mp->mr_next_hop_weight = next_hop_weight;
6964 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6965 mp->mr_classify_table_index = ntohl (classify_table_index);
6966 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6967 mp->mr_label = ntohl (local_label);
6968 mp->mr_eos = is_eos;
6970 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6971 if (0 != mp->mr_next_hop_n_out_labels)
6973 memcpy (mp->mr_next_hop_out_label_stack,
6974 next_hop_out_label_stack,
6975 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6976 vec_free (next_hop_out_label_stack);
6981 if (next_hop_proto_is_ip4)
6983 clib_memcpy (mp->mr_next_hop,
6984 &v4_next_hop_address,
6985 sizeof (v4_next_hop_address));
6989 clib_memcpy (mp->mr_next_hop,
6990 &v6_next_hop_address,
6991 sizeof (v6_next_hop_address));
6998 /* If we receive SIGTERM, stop now... */
7003 /* When testing multiple add/del ops, use a control-ping to sync */
7006 vl_api_control_ping_t *mp_ping;
7010 /* Shut off async mode */
7011 vam->async_mode = 0;
7013 M (CONTROL_PING, mp_ping);
7016 timeout = vat_time_now (vam) + 1.0;
7017 while (vat_time_now (vam) < timeout)
7018 if (vam->result_ready == 1)
7023 if (vam->retval == -99)
7026 if (vam->async_errors > 0)
7028 errmsg ("%d asynchronous errors", vam->async_errors);
7031 vam->async_errors = 0;
7032 after = vat_time_now (vam);
7034 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7038 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7039 count, after - before, count / (after - before));
7045 /* Wait for a reply... */
7050 /* Return the good/bad news */
7051 return (vam->retval);
7055 api_mpls_ip_bind_unbind (vat_main_t * vam)
7057 unformat_input_t *i = vam->input;
7058 vl_api_mpls_ip_bind_unbind_t *mp;
7059 u32 ip_table_id = 0;
7060 u8 create_table_if_needed = 0;
7063 ip4_address_t v4_address;
7064 ip6_address_t v6_address;
7067 mpls_label_t local_label = MPLS_LABEL_INVALID;
7070 /* Parse args required to build the message */
7071 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7073 if (unformat (i, "%U/%d", unformat_ip4_address,
7074 &v4_address, &address_length))
7079 else if (unformat (i, "%U/%d", unformat_ip6_address,
7080 &v6_address, &address_length))
7085 else if (unformat (i, "%d", &local_label))
7087 else if (unformat (i, "create-table"))
7088 create_table_if_needed = 1;
7089 else if (unformat (i, "table-id %d", &ip_table_id))
7091 else if (unformat (i, "unbind"))
7093 else if (unformat (i, "bind"))
7097 clib_warning ("parse error '%U'", format_unformat_error, i);
7104 errmsg ("IP addres not set");
7108 if (MPLS_LABEL_INVALID == local_label)
7110 errmsg ("missing label");
7114 /* Construct the API message */
7115 M (MPLS_IP_BIND_UNBIND, mp);
7117 mp->mb_create_table_if_needed = create_table_if_needed;
7118 mp->mb_is_bind = is_bind;
7119 mp->mb_is_ip4 = is_ip4;
7120 mp->mb_ip_table_id = ntohl (ip_table_id);
7121 mp->mb_mpls_table_id = 0;
7122 mp->mb_label = ntohl (local_label);
7123 mp->mb_address_length = address_length;
7126 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7128 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7133 /* Wait for a reply... */
7139 api_proxy_arp_add_del (vat_main_t * vam)
7141 unformat_input_t *i = vam->input;
7142 vl_api_proxy_arp_add_del_t *mp;
7145 ip4_address_t lo, hi;
7149 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7151 if (unformat (i, "vrf %d", &vrf_id))
7153 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7154 unformat_ip4_address, &hi))
7156 else if (unformat (i, "del"))
7160 clib_warning ("parse error '%U'", format_unformat_error, i);
7167 errmsg ("address range not set");
7171 M (PROXY_ARP_ADD_DEL, mp);
7173 mp->vrf_id = ntohl (vrf_id);
7174 mp->is_add = is_add;
7175 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7176 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7184 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7186 unformat_input_t *i = vam->input;
7187 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7190 u8 sw_if_index_set = 0;
7193 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7195 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7196 sw_if_index_set = 1;
7197 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7198 sw_if_index_set = 1;
7199 else if (unformat (i, "enable"))
7201 else if (unformat (i, "disable"))
7205 clib_warning ("parse error '%U'", format_unformat_error, i);
7210 if (sw_if_index_set == 0)
7212 errmsg ("missing interface name or sw_if_index");
7216 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7218 mp->sw_if_index = ntohl (sw_if_index);
7219 mp->enable_disable = enable;
7227 api_mpls_tunnel_add_del (vat_main_t * vam)
7229 unformat_input_t *i = vam->input;
7230 vl_api_mpls_tunnel_add_del_t *mp;
7234 u32 sw_if_index = ~0;
7235 u32 next_hop_sw_if_index = ~0;
7236 u32 next_hop_proto_is_ip4 = 1;
7238 u32 next_hop_table_id = 0;
7239 ip4_address_t v4_next_hop_address = {
7242 ip6_address_t v6_next_hop_address = { {0} };
7243 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7246 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7248 if (unformat (i, "add"))
7250 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7252 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7254 else if (unformat (i, "via %U",
7255 unformat_ip4_address, &v4_next_hop_address))
7257 next_hop_proto_is_ip4 = 1;
7259 else if (unformat (i, "via %U",
7260 unformat_ip6_address, &v6_next_hop_address))
7262 next_hop_proto_is_ip4 = 0;
7264 else if (unformat (i, "l2-only"))
7266 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7268 else if (unformat (i, "out-label %d", &next_hop_out_label))
7269 vec_add1 (labels, ntohl (next_hop_out_label));
7272 clib_warning ("parse error '%U'", format_unformat_error, i);
7277 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7279 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7280 mp->mt_sw_if_index = ntohl (sw_if_index);
7281 mp->mt_is_add = is_add;
7282 mp->mt_l2_only = l2_only;
7283 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7284 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7286 mp->mt_next_hop_n_out_labels = vec_len (labels);
7288 if (0 != mp->mt_next_hop_n_out_labels)
7290 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7291 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7295 if (next_hop_proto_is_ip4)
7297 clib_memcpy (mp->mt_next_hop,
7298 &v4_next_hop_address, sizeof (v4_next_hop_address));
7302 clib_memcpy (mp->mt_next_hop,
7303 &v6_next_hop_address, sizeof (v6_next_hop_address));
7312 api_sw_interface_set_unnumbered (vat_main_t * vam)
7314 unformat_input_t *i = vam->input;
7315 vl_api_sw_interface_set_unnumbered_t *mp;
7317 u32 unnum_sw_index = ~0;
7319 u8 sw_if_index_set = 0;
7322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7324 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7325 sw_if_index_set = 1;
7326 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7327 sw_if_index_set = 1;
7328 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7330 else if (unformat (i, "del"))
7334 clib_warning ("parse error '%U'", format_unformat_error, i);
7339 if (sw_if_index_set == 0)
7341 errmsg ("missing interface name or sw_if_index");
7345 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7347 mp->sw_if_index = ntohl (sw_if_index);
7348 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7349 mp->is_add = is_add;
7357 api_ip_neighbor_add_del (vat_main_t * vam)
7359 unformat_input_t *i = vam->input;
7360 vl_api_ip_neighbor_add_del_t *mp;
7362 u8 sw_if_index_set = 0;
7365 u8 is_no_fib_entry = 0;
7368 u8 v4_address_set = 0;
7369 u8 v6_address_set = 0;
7370 ip4_address_t v4address;
7371 ip6_address_t v6address;
7374 memset (mac_address, 0, sizeof (mac_address));
7376 /* Parse args required to build the message */
7377 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7379 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7383 else if (unformat (i, "del"))
7386 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7387 sw_if_index_set = 1;
7388 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7389 sw_if_index_set = 1;
7390 else if (unformat (i, "is_static"))
7392 else if (unformat (i, "no-fib-entry"))
7393 is_no_fib_entry = 1;
7394 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7396 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7400 clib_warning ("parse error '%U'", format_unformat_error, i);
7405 if (sw_if_index_set == 0)
7407 errmsg ("missing interface name or sw_if_index");
7410 if (v4_address_set && v6_address_set)
7412 errmsg ("both v4 and v6 addresses set");
7415 if (!v4_address_set && !v6_address_set)
7417 errmsg ("no address set");
7421 /* Construct the API message */
7422 M (IP_NEIGHBOR_ADD_DEL, mp);
7424 mp->sw_if_index = ntohl (sw_if_index);
7425 mp->is_add = is_add;
7426 mp->is_static = is_static;
7427 mp->is_no_adj_fib = is_no_fib_entry;
7429 clib_memcpy (mp->mac_address, mac_address, 6);
7433 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7437 /* mp->is_ipv6 = 0; via memset in M macro above */
7438 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7444 /* Wait for a reply, return good/bad news */
7450 api_reset_vrf (vat_main_t * vam)
7452 unformat_input_t *i = vam->input;
7453 vl_api_reset_vrf_t *mp;
7459 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7461 if (unformat (i, "vrf %d", &vrf_id))
7463 else if (unformat (i, "ipv6"))
7467 clib_warning ("parse error '%U'", format_unformat_error, i);
7472 if (vrf_id_set == 0)
7474 errmsg ("missing vrf id");
7480 mp->vrf_id = ntohl (vrf_id);
7481 mp->is_ipv6 = is_ipv6;
7489 api_create_vlan_subif (vat_main_t * vam)
7491 unformat_input_t *i = vam->input;
7492 vl_api_create_vlan_subif_t *mp;
7494 u8 sw_if_index_set = 0;
7499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7501 if (unformat (i, "sw_if_index %d", &sw_if_index))
7502 sw_if_index_set = 1;
7504 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7505 sw_if_index_set = 1;
7506 else if (unformat (i, "vlan %d", &vlan_id))
7510 clib_warning ("parse error '%U'", format_unformat_error, i);
7515 if (sw_if_index_set == 0)
7517 errmsg ("missing interface name or sw_if_index");
7521 if (vlan_id_set == 0)
7523 errmsg ("missing vlan_id");
7526 M (CREATE_VLAN_SUBIF, mp);
7528 mp->sw_if_index = ntohl (sw_if_index);
7529 mp->vlan_id = ntohl (vlan_id);
7536 #define foreach_create_subif_bit \
7543 _(outer_vlan_id_any) \
7544 _(inner_vlan_id_any)
7547 api_create_subif (vat_main_t * vam)
7549 unformat_input_t *i = vam->input;
7550 vl_api_create_subif_t *mp;
7552 u8 sw_if_index_set = 0;
7559 u32 exact_match = 0;
7560 u32 default_sub = 0;
7561 u32 outer_vlan_id_any = 0;
7562 u32 inner_vlan_id_any = 0;
7564 u16 outer_vlan_id = 0;
7565 u16 inner_vlan_id = 0;
7568 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7570 if (unformat (i, "sw_if_index %d", &sw_if_index))
7571 sw_if_index_set = 1;
7573 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7574 sw_if_index_set = 1;
7575 else if (unformat (i, "sub_id %d", &sub_id))
7577 else if (unformat (i, "outer_vlan_id %d", &tmp))
7578 outer_vlan_id = tmp;
7579 else if (unformat (i, "inner_vlan_id %d", &tmp))
7580 inner_vlan_id = tmp;
7582 #define _(a) else if (unformat (i, #a)) a = 1 ;
7583 foreach_create_subif_bit
7587 clib_warning ("parse error '%U'", format_unformat_error, i);
7592 if (sw_if_index_set == 0)
7594 errmsg ("missing interface name or sw_if_index");
7598 if (sub_id_set == 0)
7600 errmsg ("missing sub_id");
7603 M (CREATE_SUBIF, mp);
7605 mp->sw_if_index = ntohl (sw_if_index);
7606 mp->sub_id = ntohl (sub_id);
7608 #define _(a) mp->a = a;
7609 foreach_create_subif_bit;
7612 mp->outer_vlan_id = ntohs (outer_vlan_id);
7613 mp->inner_vlan_id = ntohs (inner_vlan_id);
7621 api_oam_add_del (vat_main_t * vam)
7623 unformat_input_t *i = vam->input;
7624 vl_api_oam_add_del_t *mp;
7627 ip4_address_t src, dst;
7632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7634 if (unformat (i, "vrf %d", &vrf_id))
7636 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7638 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7640 else if (unformat (i, "del"))
7644 clib_warning ("parse error '%U'", format_unformat_error, i);
7651 errmsg ("missing src addr");
7657 errmsg ("missing dst addr");
7661 M (OAM_ADD_DEL, mp);
7663 mp->vrf_id = ntohl (vrf_id);
7664 mp->is_add = is_add;
7665 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7666 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7674 api_reset_fib (vat_main_t * vam)
7676 unformat_input_t *i = vam->input;
7677 vl_api_reset_fib_t *mp;
7683 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7685 if (unformat (i, "vrf %d", &vrf_id))
7687 else if (unformat (i, "ipv6"))
7691 clib_warning ("parse error '%U'", format_unformat_error, i);
7696 if (vrf_id_set == 0)
7698 errmsg ("missing vrf id");
7704 mp->vrf_id = ntohl (vrf_id);
7705 mp->is_ipv6 = is_ipv6;
7713 api_dhcp_proxy_config (vat_main_t * vam)
7715 unformat_input_t *i = vam->input;
7716 vl_api_dhcp_proxy_config_t *mp;
7718 u32 server_vrf_id = 0;
7720 u8 v4_address_set = 0;
7721 u8 v6_address_set = 0;
7722 ip4_address_t v4address;
7723 ip6_address_t v6address;
7724 u8 v4_src_address_set = 0;
7725 u8 v6_src_address_set = 0;
7726 ip4_address_t v4srcaddress;
7727 ip6_address_t v6srcaddress;
7730 /* Parse args required to build the message */
7731 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7733 if (unformat (i, "del"))
7735 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7737 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7739 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7741 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7743 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7744 v4_src_address_set = 1;
7745 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7746 v6_src_address_set = 1;
7751 if (v4_address_set && v6_address_set)
7753 errmsg ("both v4 and v6 server addresses set");
7756 if (!v4_address_set && !v6_address_set)
7758 errmsg ("no server addresses set");
7762 if (v4_src_address_set && v6_src_address_set)
7764 errmsg ("both v4 and v6 src addresses set");
7767 if (!v4_src_address_set && !v6_src_address_set)
7769 errmsg ("no src addresses set");
7773 if (!(v4_src_address_set && v4_address_set) &&
7774 !(v6_src_address_set && v6_address_set))
7776 errmsg ("no matching server and src addresses set");
7780 /* Construct the API message */
7781 M (DHCP_PROXY_CONFIG, mp);
7783 mp->is_add = is_add;
7784 mp->rx_vrf_id = ntohl (rx_vrf_id);
7785 mp->server_vrf_id = ntohl (server_vrf_id);
7789 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7790 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7794 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7795 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7801 /* Wait for a reply, return good/bad news */
7806 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
7807 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
7810 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
7812 vat_main_t *vam = &vat_main;
7813 u32 i, count = mp->count;
7814 vl_api_dhcp_server_t *s;
7818 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7819 ntohl (mp->rx_vrf_id),
7820 format_ip6_address, mp->dhcp_src_address,
7821 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7824 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7825 ntohl (mp->rx_vrf_id),
7826 format_ip4_address, mp->dhcp_src_address,
7827 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7829 for (i = 0; i < count; i++)
7831 s = &mp->servers[i];
7835 " Server Table-ID %d, Server Address %U",
7836 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
7839 " Server Table-ID %d, Server Address %U",
7840 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
7844 static void vl_api_dhcp_proxy_details_t_handler_json
7845 (vl_api_dhcp_proxy_details_t * mp)
7847 vat_main_t *vam = &vat_main;
7848 vat_json_node_t *node = NULL;
7849 u32 i, count = mp->count;
7851 struct in6_addr ip6;
7852 vl_api_dhcp_server_t *s;
7854 if (VAT_JSON_ARRAY != vam->json_tree.type)
7856 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7857 vat_json_init_array (&vam->json_tree);
7859 node = vat_json_array_add (&vam->json_tree);
7861 vat_json_init_object (node);
7862 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
7863 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
7864 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
7868 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
7869 vat_json_object_add_ip6 (node, "src_address", ip6);
7873 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
7874 vat_json_object_add_ip4 (node, "src_address", ip4);
7877 for (i = 0; i < count; i++)
7879 s = &mp->servers[i];
7881 vat_json_object_add_uint (node, "server-table-id",
7882 ntohl (s->server_vrf_id));
7886 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
7887 vat_json_object_add_ip4 (node, "src_address", ip4);
7891 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
7892 vat_json_object_add_ip6 (node, "server_address", ip6);
7898 api_dhcp_proxy_dump (vat_main_t * vam)
7900 unformat_input_t *i = vam->input;
7901 vl_api_control_ping_t *mp_ping;
7902 vl_api_dhcp_proxy_dump_t *mp;
7906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7908 if (unformat (i, "ipv6"))
7912 clib_warning ("parse error '%U'", format_unformat_error, i);
7917 M (DHCP_PROXY_DUMP, mp);
7919 mp->is_ip6 = is_ipv6;
7922 /* Use a control ping for synchronization */
7923 M (CONTROL_PING, mp_ping);
7931 api_dhcp_proxy_set_vss (vat_main_t * vam)
7933 unformat_input_t *i = vam->input;
7934 vl_api_dhcp_proxy_set_vss_t *mp;
7945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7947 if (unformat (i, "tbl_id %d", &tbl_id))
7949 if (unformat (i, "fib_id %d", &fib_id))
7951 if (unformat (i, "oui %d", &oui))
7953 else if (unformat (i, "ipv6"))
7955 else if (unformat (i, "del"))
7959 clib_warning ("parse error '%U'", format_unformat_error, i);
7964 if (tbl_id_set == 0)
7966 errmsg ("missing tbl id");
7970 if (fib_id_set == 0)
7972 errmsg ("missing fib id");
7977 errmsg ("missing oui");
7981 M (DHCP_PROXY_SET_VSS, mp);
7982 mp->tbl_id = ntohl (tbl_id);
7983 mp->fib_id = ntohl (fib_id);
7984 mp->oui = ntohl (oui);
7985 mp->is_ipv6 = is_ipv6;
7986 mp->is_add = is_add;
7994 api_dhcp_client_config (vat_main_t * vam)
7996 unformat_input_t *i = vam->input;
7997 vl_api_dhcp_client_config_t *mp;
7999 u8 sw_if_index_set = 0;
8002 u8 disable_event = 0;
8005 /* Parse args required to build the message */
8006 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8008 if (unformat (i, "del"))
8011 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8012 sw_if_index_set = 1;
8013 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8014 sw_if_index_set = 1;
8015 else if (unformat (i, "hostname %s", &hostname))
8017 else if (unformat (i, "disable_event"))
8023 if (sw_if_index_set == 0)
8025 errmsg ("missing interface name or sw_if_index");
8029 if (vec_len (hostname) > 63)
8031 errmsg ("hostname too long");
8033 vec_add1 (hostname, 0);
8035 /* Construct the API message */
8036 M (DHCP_CLIENT_CONFIG, mp);
8038 mp->sw_if_index = ntohl (sw_if_index);
8039 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
8040 vec_free (hostname);
8041 mp->is_add = is_add;
8042 mp->want_dhcp_event = disable_event ? 0 : 1;
8043 mp->pid = getpid ();
8048 /* Wait for a reply, return good/bad news */
8054 api_set_ip_flow_hash (vat_main_t * vam)
8056 unformat_input_t *i = vam->input;
8057 vl_api_set_ip_flow_hash_t *mp;
8069 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8071 if (unformat (i, "vrf %d", &vrf_id))
8073 else if (unformat (i, "ipv6"))
8075 else if (unformat (i, "src"))
8077 else if (unformat (i, "dst"))
8079 else if (unformat (i, "sport"))
8081 else if (unformat (i, "dport"))
8083 else if (unformat (i, "proto"))
8085 else if (unformat (i, "reverse"))
8090 clib_warning ("parse error '%U'", format_unformat_error, i);
8095 if (vrf_id_set == 0)
8097 errmsg ("missing vrf id");
8101 M (SET_IP_FLOW_HASH, mp);
8107 mp->reverse = reverse;
8108 mp->vrf_id = ntohl (vrf_id);
8109 mp->is_ipv6 = is_ipv6;
8117 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8119 unformat_input_t *i = vam->input;
8120 vl_api_sw_interface_ip6_enable_disable_t *mp;
8122 u8 sw_if_index_set = 0;
8126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8128 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8129 sw_if_index_set = 1;
8130 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8131 sw_if_index_set = 1;
8132 else if (unformat (i, "enable"))
8134 else if (unformat (i, "disable"))
8138 clib_warning ("parse error '%U'", format_unformat_error, i);
8143 if (sw_if_index_set == 0)
8145 errmsg ("missing interface name or sw_if_index");
8149 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8151 mp->sw_if_index = ntohl (sw_if_index);
8152 mp->enable = enable;
8160 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8162 unformat_input_t *i = vam->input;
8163 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8165 u8 sw_if_index_set = 0;
8166 u8 v6_address_set = 0;
8167 ip6_address_t v6address;
8170 /* Parse args required to build the message */
8171 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8173 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8174 sw_if_index_set = 1;
8175 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8176 sw_if_index_set = 1;
8177 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8183 if (sw_if_index_set == 0)
8185 errmsg ("missing interface name or sw_if_index");
8188 if (!v6_address_set)
8190 errmsg ("no address set");
8194 /* Construct the API message */
8195 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8197 mp->sw_if_index = ntohl (sw_if_index);
8198 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8203 /* Wait for a reply, return good/bad news */
8209 api_ip6nd_proxy_add_del (vat_main_t * vam)
8211 unformat_input_t *i = vam->input;
8212 vl_api_ip6nd_proxy_add_del_t *mp;
8213 u32 sw_if_index = ~0;
8214 u8 v6_address_set = 0;
8215 ip6_address_t v6address;
8219 /* Parse args required to build the message */
8220 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8222 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8224 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8226 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8228 if (unformat (i, "del"))
8232 clib_warning ("parse error '%U'", format_unformat_error, i);
8237 if (sw_if_index == ~0)
8239 errmsg ("missing interface name or sw_if_index");
8242 if (!v6_address_set)
8244 errmsg ("no address set");
8248 /* Construct the API message */
8249 M (IP6ND_PROXY_ADD_DEL, mp);
8251 mp->is_del = is_del;
8252 mp->sw_if_index = ntohl (sw_if_index);
8253 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8258 /* Wait for a reply, return good/bad news */
8264 api_ip6nd_proxy_dump (vat_main_t * vam)
8266 vl_api_ip6nd_proxy_dump_t *mp;
8267 vl_api_control_ping_t *mp_ping;
8270 M (IP6ND_PROXY_DUMP, mp);
8274 /* Use a control ping for synchronization */
8275 M (CONTROL_PING, mp_ping);
8282 static void vl_api_ip6nd_proxy_details_t_handler
8283 (vl_api_ip6nd_proxy_details_t * mp)
8285 vat_main_t *vam = &vat_main;
8287 print (vam->ofp, "host %U sw_if_index %d",
8288 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
8291 static void vl_api_ip6nd_proxy_details_t_handler_json
8292 (vl_api_ip6nd_proxy_details_t * mp)
8294 vat_main_t *vam = &vat_main;
8295 struct in6_addr ip6;
8296 vat_json_node_t *node = NULL;
8298 if (VAT_JSON_ARRAY != vam->json_tree.type)
8300 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8301 vat_json_init_array (&vam->json_tree);
8303 node = vat_json_array_add (&vam->json_tree);
8305 vat_json_init_object (node);
8306 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
8308 clib_memcpy (&ip6, mp->address, sizeof (ip6));
8309 vat_json_object_add_ip6 (node, "host", ip6);
8313 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8315 unformat_input_t *i = vam->input;
8316 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8318 u8 sw_if_index_set = 0;
8319 u32 address_length = 0;
8320 u8 v6_address_set = 0;
8321 ip6_address_t v6address;
8323 u8 no_advertise = 0;
8325 u8 no_autoconfig = 0;
8328 u32 val_lifetime = 0;
8329 u32 pref_lifetime = 0;
8332 /* Parse args required to build the message */
8333 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8335 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8336 sw_if_index_set = 1;
8337 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8338 sw_if_index_set = 1;
8339 else if (unformat (i, "%U/%d",
8340 unformat_ip6_address, &v6address, &address_length))
8342 else if (unformat (i, "val_life %d", &val_lifetime))
8344 else if (unformat (i, "pref_life %d", &pref_lifetime))
8346 else if (unformat (i, "def"))
8348 else if (unformat (i, "noadv"))
8350 else if (unformat (i, "offl"))
8352 else if (unformat (i, "noauto"))
8354 else if (unformat (i, "nolink"))
8356 else if (unformat (i, "isno"))
8360 clib_warning ("parse error '%U'", format_unformat_error, i);
8365 if (sw_if_index_set == 0)
8367 errmsg ("missing interface name or sw_if_index");
8370 if (!v6_address_set)
8372 errmsg ("no address set");
8376 /* Construct the API message */
8377 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8379 mp->sw_if_index = ntohl (sw_if_index);
8380 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8381 mp->address_length = address_length;
8382 mp->use_default = use_default;
8383 mp->no_advertise = no_advertise;
8384 mp->off_link = off_link;
8385 mp->no_autoconfig = no_autoconfig;
8386 mp->no_onlink = no_onlink;
8388 mp->val_lifetime = ntohl (val_lifetime);
8389 mp->pref_lifetime = ntohl (pref_lifetime);
8394 /* Wait for a reply, return good/bad news */
8400 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8402 unformat_input_t *i = vam->input;
8403 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8405 u8 sw_if_index_set = 0;
8410 u8 send_unicast = 0;
8413 u8 default_router = 0;
8414 u32 max_interval = 0;
8415 u32 min_interval = 0;
8417 u32 initial_count = 0;
8418 u32 initial_interval = 0;
8422 /* Parse args required to build the message */
8423 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8425 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8426 sw_if_index_set = 1;
8427 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8428 sw_if_index_set = 1;
8429 else if (unformat (i, "maxint %d", &max_interval))
8431 else if (unformat (i, "minint %d", &min_interval))
8433 else if (unformat (i, "life %d", &lifetime))
8435 else if (unformat (i, "count %d", &initial_count))
8437 else if (unformat (i, "interval %d", &initial_interval))
8439 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8441 else if (unformat (i, "managed"))
8443 else if (unformat (i, "other"))
8445 else if (unformat (i, "ll"))
8447 else if (unformat (i, "send"))
8449 else if (unformat (i, "cease"))
8451 else if (unformat (i, "isno"))
8453 else if (unformat (i, "def"))
8457 clib_warning ("parse error '%U'", format_unformat_error, i);
8462 if (sw_if_index_set == 0)
8464 errmsg ("missing interface name or sw_if_index");
8468 /* Construct the API message */
8469 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8471 mp->sw_if_index = ntohl (sw_if_index);
8472 mp->max_interval = ntohl (max_interval);
8473 mp->min_interval = ntohl (min_interval);
8474 mp->lifetime = ntohl (lifetime);
8475 mp->initial_count = ntohl (initial_count);
8476 mp->initial_interval = ntohl (initial_interval);
8477 mp->suppress = suppress;
8478 mp->managed = managed;
8480 mp->ll_option = ll_option;
8481 mp->send_unicast = send_unicast;
8484 mp->default_router = default_router;
8489 /* Wait for a reply, return good/bad news */
8495 api_set_arp_neighbor_limit (vat_main_t * vam)
8497 unformat_input_t *i = vam->input;
8498 vl_api_set_arp_neighbor_limit_t *mp;
8504 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8506 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8508 else if (unformat (i, "ipv6"))
8512 clib_warning ("parse error '%U'", format_unformat_error, i);
8519 errmsg ("missing limit value");
8523 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8525 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8526 mp->is_ipv6 = is_ipv6;
8534 api_l2_patch_add_del (vat_main_t * vam)
8536 unformat_input_t *i = vam->input;
8537 vl_api_l2_patch_add_del_t *mp;
8539 u8 rx_sw_if_index_set = 0;
8541 u8 tx_sw_if_index_set = 0;
8545 /* Parse args required to build the message */
8546 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8548 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8549 rx_sw_if_index_set = 1;
8550 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8551 tx_sw_if_index_set = 1;
8552 else if (unformat (i, "rx"))
8554 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8556 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8558 rx_sw_if_index_set = 1;
8563 else if (unformat (i, "tx"))
8565 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8567 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8569 tx_sw_if_index_set = 1;
8574 else if (unformat (i, "del"))
8580 if (rx_sw_if_index_set == 0)
8582 errmsg ("missing rx interface name or rx_sw_if_index");
8586 if (tx_sw_if_index_set == 0)
8588 errmsg ("missing tx interface name or tx_sw_if_index");
8592 M (L2_PATCH_ADD_DEL, mp);
8594 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8595 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8596 mp->is_add = is_add;
8604 u8 localsid_addr[16];
8613 api_sr_localsid_add_del (vat_main_t * vam)
8615 unformat_input_t *i = vam->input;
8616 vl_api_sr_localsid_add_del_t *mp;
8619 ip6_address_t localsid;
8623 u32 fib_table = ~(u32) 0;
8624 ip6_address_t next_hop;
8626 bool nexthop_set = 0;
8630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8632 if (unformat (i, "del"))
8634 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
8635 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
8637 else if (unformat (i, "behavior %u", &behavior));
8638 else if (unformat (i, "sw_if_index %u", &sw_if_index));
8639 else if (unformat (i, "fib-table %u", &fib_table));
8640 else if (unformat (i, "end.psp %u", &behavior));
8645 M (SR_LOCALSID_ADD_DEL, mp);
8647 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
8649 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
8650 mp->behavior = behavior;
8651 mp->sw_if_index = ntohl (sw_if_index);
8652 mp->fib_table = ntohl (fib_table);
8653 mp->end_psp = end_psp;
8654 mp->is_del = is_del;
8662 api_ioam_enable (vat_main_t * vam)
8664 unformat_input_t *input = vam->input;
8665 vl_api_ioam_enable_t *mp;
8667 int has_trace_option = 0;
8668 int has_pot_option = 0;
8669 int has_seqno_option = 0;
8670 int has_analyse_option = 0;
8673 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8675 if (unformat (input, "trace"))
8676 has_trace_option = 1;
8677 else if (unformat (input, "pot"))
8679 else if (unformat (input, "seqno"))
8680 has_seqno_option = 1;
8681 else if (unformat (input, "analyse"))
8682 has_analyse_option = 1;
8686 M (IOAM_ENABLE, mp);
8687 mp->id = htons (id);
8688 mp->seqno = has_seqno_option;
8689 mp->analyse = has_analyse_option;
8690 mp->pot_enable = has_pot_option;
8691 mp->trace_enable = has_trace_option;
8700 api_ioam_disable (vat_main_t * vam)
8702 vl_api_ioam_disable_t *mp;
8705 M (IOAM_DISABLE, mp);
8711 #define foreach_tcp_proto_field \
8715 #define foreach_udp_proto_field \
8719 #define foreach_ip4_proto_field \
8731 u16 src_port, dst_port;
8734 #if VPP_API_TEST_BUILTIN == 0
8736 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8738 u8 **maskp = va_arg (*args, u8 **);
8740 u8 found_something = 0;
8743 #define _(a) u8 a=0;
8744 foreach_tcp_proto_field;
8747 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8750 #define _(a) else if (unformat (input, #a)) a=1;
8751 foreach_tcp_proto_field
8757 #define _(a) found_something += a;
8758 foreach_tcp_proto_field;
8761 if (found_something == 0)
8764 vec_validate (mask, sizeof (*tcp) - 1);
8766 tcp = (tcp_header_t *) mask;
8768 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8769 foreach_tcp_proto_field;
8777 unformat_udp_mask (unformat_input_t * input, va_list * args)
8779 u8 **maskp = va_arg (*args, u8 **);
8781 u8 found_something = 0;
8784 #define _(a) u8 a=0;
8785 foreach_udp_proto_field;
8788 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8791 #define _(a) else if (unformat (input, #a)) a=1;
8792 foreach_udp_proto_field
8798 #define _(a) found_something += a;
8799 foreach_udp_proto_field;
8802 if (found_something == 0)
8805 vec_validate (mask, sizeof (*udp) - 1);
8807 udp = (udp_header_t *) mask;
8809 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8810 foreach_udp_proto_field;
8818 unformat_l4_mask (unformat_input_t * input, va_list * args)
8820 u8 **maskp = va_arg (*args, u8 **);
8821 u16 src_port = 0, dst_port = 0;
8822 tcpudp_header_t *tcpudp;
8824 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8826 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8828 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8830 else if (unformat (input, "src_port"))
8832 else if (unformat (input, "dst_port"))
8838 if (!src_port && !dst_port)
8842 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8844 tcpudp = (tcpudp_header_t *) mask;
8845 tcpudp->src_port = src_port;
8846 tcpudp->dst_port = dst_port;
8854 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8856 u8 **maskp = va_arg (*args, u8 **);
8858 u8 found_something = 0;
8861 #define _(a) u8 a=0;
8862 foreach_ip4_proto_field;
8868 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8870 if (unformat (input, "version"))
8872 else if (unformat (input, "hdr_length"))
8874 else if (unformat (input, "src"))
8876 else if (unformat (input, "dst"))
8878 else if (unformat (input, "proto"))
8881 #define _(a) else if (unformat (input, #a)) a=1;
8882 foreach_ip4_proto_field
8888 #define _(a) found_something += a;
8889 foreach_ip4_proto_field;
8892 if (found_something == 0)
8895 vec_validate (mask, sizeof (*ip) - 1);
8897 ip = (ip4_header_t *) mask;
8899 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8900 foreach_ip4_proto_field;
8903 ip->ip_version_and_header_length = 0;
8906 ip->ip_version_and_header_length |= 0xF0;
8909 ip->ip_version_and_header_length |= 0x0F;
8915 #define foreach_ip6_proto_field \
8923 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8925 u8 **maskp = va_arg (*args, u8 **);
8927 u8 found_something = 0;
8929 u32 ip_version_traffic_class_and_flow_label;
8931 #define _(a) u8 a=0;
8932 foreach_ip6_proto_field;
8935 u8 traffic_class = 0;
8938 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8940 if (unformat (input, "version"))
8942 else if (unformat (input, "traffic-class"))
8944 else if (unformat (input, "flow-label"))
8946 else if (unformat (input, "src"))
8948 else if (unformat (input, "dst"))
8950 else if (unformat (input, "proto"))
8953 #define _(a) else if (unformat (input, #a)) a=1;
8954 foreach_ip6_proto_field
8960 #define _(a) found_something += a;
8961 foreach_ip6_proto_field;
8964 if (found_something == 0)
8967 vec_validate (mask, sizeof (*ip) - 1);
8969 ip = (ip6_header_t *) mask;
8971 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8972 foreach_ip6_proto_field;
8975 ip_version_traffic_class_and_flow_label = 0;
8978 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8981 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8984 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8986 ip->ip_version_traffic_class_and_flow_label =
8987 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8994 unformat_l3_mask (unformat_input_t * input, va_list * args)
8996 u8 **maskp = va_arg (*args, u8 **);
8998 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9000 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9002 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9011 unformat_l2_mask (unformat_input_t * input, va_list * args)
9013 u8 **maskp = va_arg (*args, u8 **);
9028 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9030 if (unformat (input, "src"))
9032 else if (unformat (input, "dst"))
9034 else if (unformat (input, "proto"))
9036 else if (unformat (input, "tag1"))
9038 else if (unformat (input, "tag2"))
9040 else if (unformat (input, "ignore-tag1"))
9042 else if (unformat (input, "ignore-tag2"))
9044 else if (unformat (input, "cos1"))
9046 else if (unformat (input, "cos2"))
9048 else if (unformat (input, "dot1q"))
9050 else if (unformat (input, "dot1ad"))
9055 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9056 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9059 if (tag1 || ignore_tag1 || cos1 || dot1q)
9061 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9064 vec_validate (mask, len - 1);
9067 memset (mask, 0xff, 6);
9070 memset (mask + 6, 0xff, 6);
9074 /* inner vlan tag */
9083 mask[21] = mask[20] = 0xff;
9104 mask[16] = mask[17] = 0xff;
9114 mask[12] = mask[13] = 0xff;
9121 unformat_classify_mask (unformat_input_t * input, va_list * args)
9123 u8 **maskp = va_arg (*args, u8 **);
9124 u32 *skipp = va_arg (*args, u32 *);
9125 u32 *matchp = va_arg (*args, u32 *);
9133 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9135 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9137 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9139 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9141 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9155 if (mask || l2 || l3 || l4)
9159 /* "With a free Ethernet header in every package" */
9161 vec_validate (l2, 13);
9165 vec_append (mask, l3);
9170 vec_append (mask, l4);
9175 /* Scan forward looking for the first significant mask octet */
9176 for (i = 0; i < vec_len (mask); i++)
9180 /* compute (skip, match) params */
9181 *skipp = i / sizeof (u32x4);
9182 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9184 /* Pad mask to an even multiple of the vector size */
9185 while (vec_len (mask) % sizeof (u32x4))
9188 match = vec_len (mask) / sizeof (u32x4);
9190 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9192 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9193 if (*tmp || *(tmp + 1))
9198 clib_warning ("BUG: match 0");
9200 _vec_len (mask) = match * sizeof (u32x4);
9210 #endif /* VPP_API_TEST_BUILTIN */
9212 #define foreach_l2_next \
9214 _(ethernet, ETHERNET_INPUT) \
9219 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9221 u32 *miss_next_indexp = va_arg (*args, u32 *);
9226 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9230 if (unformat (input, "%d", &tmp))
9239 *miss_next_indexp = next_index;
9243 #define foreach_ip_next \
9249 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9251 u32 *miss_next_indexp = va_arg (*args, u32 *);
9256 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9260 if (unformat (input, "%d", &tmp))
9269 *miss_next_indexp = next_index;
9273 #define foreach_acl_next \
9277 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9279 u32 *miss_next_indexp = va_arg (*args, u32 *);
9284 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9288 if (unformat (input, "permit"))
9293 else if (unformat (input, "%d", &tmp))
9302 *miss_next_indexp = next_index;
9307 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9309 u32 *r = va_arg (*args, u32 *);
9311 if (unformat (input, "conform-color"))
9312 *r = POLICE_CONFORM;
9313 else if (unformat (input, "exceed-color"))
9322 api_classify_add_del_table (vat_main_t * vam)
9324 unformat_input_t *i = vam->input;
9325 vl_api_classify_add_del_table_t *mp;
9332 u32 table_index = ~0;
9333 u32 next_table_index = ~0;
9334 u32 miss_next_index = ~0;
9335 u32 memory_size = 32 << 20;
9337 u32 current_data_flag = 0;
9338 int current_data_offset = 0;
9341 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9343 if (unformat (i, "del"))
9345 else if (unformat (i, "del-chain"))
9350 else if (unformat (i, "buckets %d", &nbuckets))
9352 else if (unformat (i, "memory_size %d", &memory_size))
9354 else if (unformat (i, "skip %d", &skip))
9356 else if (unformat (i, "match %d", &match))
9358 else if (unformat (i, "table %d", &table_index))
9360 else if (unformat (i, "mask %U", unformat_classify_mask,
9361 &mask, &skip, &match))
9363 else if (unformat (i, "next-table %d", &next_table_index))
9365 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9368 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9371 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9374 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9376 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9382 if (is_add && mask == 0)
9384 errmsg ("Mask required");
9388 if (is_add && skip == ~0)
9390 errmsg ("skip count required");
9394 if (is_add && match == ~0)
9396 errmsg ("match count required");
9400 if (!is_add && table_index == ~0)
9402 errmsg ("table index required for delete");
9406 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9408 mp->is_add = is_add;
9409 mp->del_chain = del_chain;
9410 mp->table_index = ntohl (table_index);
9411 mp->nbuckets = ntohl (nbuckets);
9412 mp->memory_size = ntohl (memory_size);
9413 mp->skip_n_vectors = ntohl (skip);
9414 mp->match_n_vectors = ntohl (match);
9415 mp->next_table_index = ntohl (next_table_index);
9416 mp->miss_next_index = ntohl (miss_next_index);
9417 mp->current_data_flag = ntohl (current_data_flag);
9418 mp->current_data_offset = ntohl (current_data_offset);
9419 clib_memcpy (mp->mask, mask, vec_len (mask));
9428 #if VPP_API_TEST_BUILTIN == 0
9430 unformat_l4_match (unformat_input_t * input, va_list * args)
9432 u8 **matchp = va_arg (*args, u8 **);
9434 u8 *proto_header = 0;
9440 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9442 if (unformat (input, "src_port %d", &src_port))
9444 else if (unformat (input, "dst_port %d", &dst_port))
9450 h.src_port = clib_host_to_net_u16 (src_port);
9451 h.dst_port = clib_host_to_net_u16 (dst_port);
9452 vec_validate (proto_header, sizeof (h) - 1);
9453 memcpy (proto_header, &h, sizeof (h));
9455 *matchp = proto_header;
9461 unformat_ip4_match (unformat_input_t * input, va_list * args)
9463 u8 **matchp = va_arg (*args, u8 **);
9470 int src = 0, dst = 0;
9471 ip4_address_t src_val, dst_val;
9478 int fragment_id = 0;
9479 u32 fragment_id_val;
9485 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9487 if (unformat (input, "version %d", &version_val))
9489 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9491 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9493 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9495 else if (unformat (input, "proto %d", &proto_val))
9497 else if (unformat (input, "tos %d", &tos_val))
9499 else if (unformat (input, "length %d", &length_val))
9501 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9503 else if (unformat (input, "ttl %d", &ttl_val))
9505 else if (unformat (input, "checksum %d", &checksum_val))
9511 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9512 + ttl + checksum == 0)
9516 * Aligned because we use the real comparison functions
9518 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9520 ip = (ip4_header_t *) match;
9522 /* These are realistically matched in practice */
9524 ip->src_address.as_u32 = src_val.as_u32;
9527 ip->dst_address.as_u32 = dst_val.as_u32;
9530 ip->protocol = proto_val;
9533 /* These are not, but they're included for completeness */
9535 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9538 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9544 ip->length = clib_host_to_net_u16 (length_val);
9550 ip->checksum = clib_host_to_net_u16 (checksum_val);
9557 unformat_ip6_match (unformat_input_t * input, va_list * args)
9559 u8 **matchp = va_arg (*args, u8 **);
9564 u8 traffic_class = 0;
9565 u32 traffic_class_val = 0;
9568 int src = 0, dst = 0;
9569 ip6_address_t src_val, dst_val;
9572 int payload_length = 0;
9573 u32 payload_length_val;
9576 u32 ip_version_traffic_class_and_flow_label;
9578 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9580 if (unformat (input, "version %d", &version_val))
9582 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9584 else if (unformat (input, "flow_label %d", &flow_label_val))
9586 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9588 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9590 else if (unformat (input, "proto %d", &proto_val))
9592 else if (unformat (input, "payload_length %d", &payload_length_val))
9594 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9600 if (version + traffic_class + flow_label + src + dst + proto +
9601 payload_length + hop_limit == 0)
9605 * Aligned because we use the real comparison functions
9607 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9609 ip = (ip6_header_t *) match;
9612 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9615 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9618 ip->protocol = proto_val;
9620 ip_version_traffic_class_and_flow_label = 0;
9623 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9626 ip_version_traffic_class_and_flow_label |=
9627 (traffic_class_val & 0xFF) << 20;
9630 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9632 ip->ip_version_traffic_class_and_flow_label =
9633 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9636 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9639 ip->hop_limit = hop_limit_val;
9646 unformat_l3_match (unformat_input_t * input, va_list * args)
9648 u8 **matchp = va_arg (*args, u8 **);
9650 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9652 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9654 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9663 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9665 u8 *tagp = va_arg (*args, u8 *);
9668 if (unformat (input, "%d", &tag))
9670 tagp[0] = (tag >> 8) & 0x0F;
9671 tagp[1] = tag & 0xFF;
9679 unformat_l2_match (unformat_input_t * input, va_list * args)
9681 u8 **matchp = va_arg (*args, u8 **);
9701 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9703 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9706 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9708 else if (unformat (input, "proto %U",
9709 unformat_ethernet_type_host_byte_order, &proto_val))
9711 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9713 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9715 else if (unformat (input, "ignore-tag1"))
9717 else if (unformat (input, "ignore-tag2"))
9719 else if (unformat (input, "cos1 %d", &cos1_val))
9721 else if (unformat (input, "cos2 %d", &cos2_val))
9726 if ((src + dst + proto + tag1 + tag2 +
9727 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9730 if (tag1 || ignore_tag1 || cos1)
9732 if (tag2 || ignore_tag2 || cos2)
9735 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9738 clib_memcpy (match, dst_val, 6);
9741 clib_memcpy (match + 6, src_val, 6);
9745 /* inner vlan tag */
9746 match[19] = tag2_val[1];
9747 match[18] = tag2_val[0];
9749 match[18] |= (cos2_val & 0x7) << 5;
9752 match[21] = proto_val & 0xff;
9753 match[20] = proto_val >> 8;
9757 match[15] = tag1_val[1];
9758 match[14] = tag1_val[0];
9761 match[14] |= (cos1_val & 0x7) << 5;
9767 match[15] = tag1_val[1];
9768 match[14] = tag1_val[0];
9771 match[17] = proto_val & 0xff;
9772 match[16] = proto_val >> 8;
9775 match[14] |= (cos1_val & 0x7) << 5;
9781 match[18] |= (cos2_val & 0x7) << 5;
9783 match[14] |= (cos1_val & 0x7) << 5;
9786 match[13] = proto_val & 0xff;
9787 match[12] = proto_val >> 8;
9796 api_unformat_classify_match (unformat_input_t * input, va_list * args)
9798 u8 **matchp = va_arg (*args, u8 **);
9799 u32 skip_n_vectors = va_arg (*args, u32);
9800 u32 match_n_vectors = va_arg (*args, u32);
9807 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9809 if (unformat (input, "hex %U", unformat_hex_string, &match))
9811 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9813 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9815 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9829 if (match || l2 || l3 || l4)
9833 /* "Win a free Ethernet header in every packet" */
9835 vec_validate_aligned (l2, 13, sizeof (u32x4));
9839 vec_append_aligned (match, l3, sizeof (u32x4));
9844 vec_append_aligned (match, l4, sizeof (u32x4));
9849 /* Make sure the vector is big enough even if key is all 0's */
9850 vec_validate_aligned
9851 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9854 /* Set size, include skipped vectors */
9855 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9866 api_classify_add_del_session (vat_main_t * vam)
9868 unformat_input_t *i = vam->input;
9869 vl_api_classify_add_del_session_t *mp;
9871 u32 table_index = ~0;
9872 u32 hit_next_index = ~0;
9873 u32 opaque_index = ~0;
9876 u32 skip_n_vectors = 0;
9877 u32 match_n_vectors = 0;
9883 * Warning: you have to supply skip_n and match_n
9884 * because the API client cant simply look at the classify
9888 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9890 if (unformat (i, "del"))
9892 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
9895 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9898 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
9901 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9903 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9905 else if (unformat (i, "opaque-index %d", &opaque_index))
9907 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9909 else if (unformat (i, "match_n %d", &match_n_vectors))
9911 else if (unformat (i, "match %U", api_unformat_classify_match,
9912 &match, skip_n_vectors, match_n_vectors))
9914 else if (unformat (i, "advance %d", &advance))
9916 else if (unformat (i, "table-index %d", &table_index))
9918 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9920 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9922 else if (unformat (i, "action %d", &action))
9924 else if (unformat (i, "metadata %d", &metadata))
9930 if (table_index == ~0)
9932 errmsg ("Table index required");
9936 if (is_add && match == 0)
9938 errmsg ("Match value required");
9942 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
9944 mp->is_add = is_add;
9945 mp->table_index = ntohl (table_index);
9946 mp->hit_next_index = ntohl (hit_next_index);
9947 mp->opaque_index = ntohl (opaque_index);
9948 mp->advance = ntohl (advance);
9949 mp->action = action;
9950 mp->metadata = ntohl (metadata);
9951 clib_memcpy (mp->match, match, vec_len (match));
9960 api_classify_set_interface_ip_table (vat_main_t * vam)
9962 unformat_input_t *i = vam->input;
9963 vl_api_classify_set_interface_ip_table_t *mp;
9965 int sw_if_index_set;
9966 u32 table_index = ~0;
9970 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9972 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9973 sw_if_index_set = 1;
9974 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9975 sw_if_index_set = 1;
9976 else if (unformat (i, "table %d", &table_index))
9980 clib_warning ("parse error '%U'", format_unformat_error, i);
9985 if (sw_if_index_set == 0)
9987 errmsg ("missing interface name or sw_if_index");
9992 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
9994 mp->sw_if_index = ntohl (sw_if_index);
9995 mp->table_index = ntohl (table_index);
9996 mp->is_ipv6 = is_ipv6;
10004 api_classify_set_interface_l2_tables (vat_main_t * vam)
10006 unformat_input_t *i = vam->input;
10007 vl_api_classify_set_interface_l2_tables_t *mp;
10009 int sw_if_index_set;
10010 u32 ip4_table_index = ~0;
10011 u32 ip6_table_index = ~0;
10012 u32 other_table_index = ~0;
10016 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10018 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10019 sw_if_index_set = 1;
10020 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10021 sw_if_index_set = 1;
10022 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10024 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10026 else if (unformat (i, "other-table %d", &other_table_index))
10028 else if (unformat (i, "is-input %d", &is_input))
10032 clib_warning ("parse error '%U'", format_unformat_error, i);
10037 if (sw_if_index_set == 0)
10039 errmsg ("missing interface name or sw_if_index");
10044 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10046 mp->sw_if_index = ntohl (sw_if_index);
10047 mp->ip4_table_index = ntohl (ip4_table_index);
10048 mp->ip6_table_index = ntohl (ip6_table_index);
10049 mp->other_table_index = ntohl (other_table_index);
10050 mp->is_input = (u8) is_input;
10058 api_set_ipfix_exporter (vat_main_t * vam)
10060 unformat_input_t *i = vam->input;
10061 vl_api_set_ipfix_exporter_t *mp;
10062 ip4_address_t collector_address;
10063 u8 collector_address_set = 0;
10064 u32 collector_port = ~0;
10065 ip4_address_t src_address;
10066 u8 src_address_set = 0;
10069 u32 template_interval = ~0;
10070 u8 udp_checksum = 0;
10073 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10075 if (unformat (i, "collector_address %U", unformat_ip4_address,
10076 &collector_address))
10077 collector_address_set = 1;
10078 else if (unformat (i, "collector_port %d", &collector_port))
10080 else if (unformat (i, "src_address %U", unformat_ip4_address,
10082 src_address_set = 1;
10083 else if (unformat (i, "vrf_id %d", &vrf_id))
10085 else if (unformat (i, "path_mtu %d", &path_mtu))
10087 else if (unformat (i, "template_interval %d", &template_interval))
10089 else if (unformat (i, "udp_checksum"))
10095 if (collector_address_set == 0)
10097 errmsg ("collector_address required");
10101 if (src_address_set == 0)
10103 errmsg ("src_address required");
10107 M (SET_IPFIX_EXPORTER, mp);
10109 memcpy (mp->collector_address, collector_address.data,
10110 sizeof (collector_address.data));
10111 mp->collector_port = htons ((u16) collector_port);
10112 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10113 mp->vrf_id = htonl (vrf_id);
10114 mp->path_mtu = htonl (path_mtu);
10115 mp->template_interval = htonl (template_interval);
10116 mp->udp_checksum = udp_checksum;
10124 api_set_ipfix_classify_stream (vat_main_t * vam)
10126 unformat_input_t *i = vam->input;
10127 vl_api_set_ipfix_classify_stream_t *mp;
10129 u32 src_port = UDP_DST_PORT_ipfix;
10132 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10134 if (unformat (i, "domain %d", &domain_id))
10136 else if (unformat (i, "src_port %d", &src_port))
10140 errmsg ("unknown input `%U'", format_unformat_error, i);
10145 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10147 mp->domain_id = htonl (domain_id);
10148 mp->src_port = htons ((u16) src_port);
10156 api_ipfix_classify_table_add_del (vat_main_t * vam)
10158 unformat_input_t *i = vam->input;
10159 vl_api_ipfix_classify_table_add_del_t *mp;
10161 u32 classify_table_index = ~0;
10163 u8 transport_protocol = 255;
10166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10168 if (unformat (i, "add"))
10170 else if (unformat (i, "del"))
10172 else if (unformat (i, "table %d", &classify_table_index))
10174 else if (unformat (i, "ip4"))
10176 else if (unformat (i, "ip6"))
10178 else if (unformat (i, "tcp"))
10179 transport_protocol = 6;
10180 else if (unformat (i, "udp"))
10181 transport_protocol = 17;
10184 errmsg ("unknown input `%U'", format_unformat_error, i);
10191 errmsg ("expecting: add|del");
10194 if (classify_table_index == ~0)
10196 errmsg ("classifier table not specified");
10199 if (ip_version == 0)
10201 errmsg ("IP version not specified");
10205 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10207 mp->is_add = is_add;
10208 mp->table_id = htonl (classify_table_index);
10209 mp->ip_version = ip_version;
10210 mp->transport_protocol = transport_protocol;
10218 api_get_node_index (vat_main_t * vam)
10220 unformat_input_t *i = vam->input;
10221 vl_api_get_node_index_t *mp;
10225 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10227 if (unformat (i, "node %s", &name))
10234 errmsg ("node name required");
10237 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10239 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10243 M (GET_NODE_INDEX, mp);
10244 clib_memcpy (mp->node_name, name, vec_len (name));
10253 api_get_next_index (vat_main_t * vam)
10255 unformat_input_t *i = vam->input;
10256 vl_api_get_next_index_t *mp;
10257 u8 *node_name = 0, *next_node_name = 0;
10260 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10262 if (unformat (i, "node-name %s", &node_name))
10264 else if (unformat (i, "next-node-name %s", &next_node_name))
10268 if (node_name == 0)
10270 errmsg ("node name required");
10273 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10275 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10279 if (next_node_name == 0)
10281 errmsg ("next node name required");
10284 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10286 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10290 M (GET_NEXT_INDEX, mp);
10291 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10292 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10293 vec_free (node_name);
10294 vec_free (next_node_name);
10302 api_add_node_next (vat_main_t * vam)
10304 unformat_input_t *i = vam->input;
10305 vl_api_add_node_next_t *mp;
10310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10312 if (unformat (i, "node %s", &name))
10314 else if (unformat (i, "next %s", &next))
10321 errmsg ("node name required");
10324 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10326 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10331 errmsg ("next node required");
10334 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10336 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10340 M (ADD_NODE_NEXT, mp);
10341 clib_memcpy (mp->node_name, name, vec_len (name));
10342 clib_memcpy (mp->next_name, next, vec_len (next));
10352 api_l2tpv3_create_tunnel (vat_main_t * vam)
10354 unformat_input_t *i = vam->input;
10355 ip6_address_t client_address, our_address;
10356 int client_address_set = 0;
10357 int our_address_set = 0;
10358 u32 local_session_id = 0;
10359 u32 remote_session_id = 0;
10360 u64 local_cookie = 0;
10361 u64 remote_cookie = 0;
10362 u8 l2_sublayer_present = 0;
10363 vl_api_l2tpv3_create_tunnel_t *mp;
10366 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10368 if (unformat (i, "client_address %U", unformat_ip6_address,
10370 client_address_set = 1;
10371 else if (unformat (i, "our_address %U", unformat_ip6_address,
10373 our_address_set = 1;
10374 else if (unformat (i, "local_session_id %d", &local_session_id))
10376 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10378 else if (unformat (i, "local_cookie %lld", &local_cookie))
10380 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10382 else if (unformat (i, "l2-sublayer-present"))
10383 l2_sublayer_present = 1;
10388 if (client_address_set == 0)
10390 errmsg ("client_address required");
10394 if (our_address_set == 0)
10396 errmsg ("our_address required");
10400 M (L2TPV3_CREATE_TUNNEL, mp);
10402 clib_memcpy (mp->client_address, client_address.as_u8,
10403 sizeof (mp->client_address));
10405 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10407 mp->local_session_id = ntohl (local_session_id);
10408 mp->remote_session_id = ntohl (remote_session_id);
10409 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10410 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10411 mp->l2_sublayer_present = l2_sublayer_present;
10420 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10422 unformat_input_t *i = vam->input;
10424 u8 sw_if_index_set = 0;
10425 u64 new_local_cookie = 0;
10426 u64 new_remote_cookie = 0;
10427 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10430 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10432 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10433 sw_if_index_set = 1;
10434 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10435 sw_if_index_set = 1;
10436 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10438 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10444 if (sw_if_index_set == 0)
10446 errmsg ("missing interface name or sw_if_index");
10450 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10452 mp->sw_if_index = ntohl (sw_if_index);
10453 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10454 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10462 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10464 unformat_input_t *i = vam->input;
10465 vl_api_l2tpv3_interface_enable_disable_t *mp;
10467 u8 sw_if_index_set = 0;
10468 u8 enable_disable = 1;
10471 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10473 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10474 sw_if_index_set = 1;
10475 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10476 sw_if_index_set = 1;
10477 else if (unformat (i, "enable"))
10478 enable_disable = 1;
10479 else if (unformat (i, "disable"))
10480 enable_disable = 0;
10485 if (sw_if_index_set == 0)
10487 errmsg ("missing interface name or sw_if_index");
10491 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10493 mp->sw_if_index = ntohl (sw_if_index);
10494 mp->enable_disable = enable_disable;
10502 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10504 unformat_input_t *i = vam->input;
10505 vl_api_l2tpv3_set_lookup_key_t *mp;
10509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10511 if (unformat (i, "lookup_v6_src"))
10512 key = L2T_LOOKUP_SRC_ADDRESS;
10513 else if (unformat (i, "lookup_v6_dst"))
10514 key = L2T_LOOKUP_DST_ADDRESS;
10515 else if (unformat (i, "lookup_session_id"))
10516 key = L2T_LOOKUP_SESSION_ID;
10521 if (key == (u8) ~ 0)
10523 errmsg ("l2tp session lookup key unset");
10527 M (L2TPV3_SET_LOOKUP_KEY, mp);
10536 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10537 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10539 vat_main_t *vam = &vat_main;
10541 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10542 format_ip6_address, mp->our_address,
10543 format_ip6_address, mp->client_address,
10544 clib_net_to_host_u32 (mp->sw_if_index));
10547 " local cookies %016llx %016llx remote cookie %016llx",
10548 clib_net_to_host_u64 (mp->local_cookie[0]),
10549 clib_net_to_host_u64 (mp->local_cookie[1]),
10550 clib_net_to_host_u64 (mp->remote_cookie));
10552 print (vam->ofp, " local session-id %d remote session-id %d",
10553 clib_net_to_host_u32 (mp->local_session_id),
10554 clib_net_to_host_u32 (mp->remote_session_id));
10556 print (vam->ofp, " l2 specific sublayer %s\n",
10557 mp->l2_sublayer_present ? "preset" : "absent");
10561 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10562 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10564 vat_main_t *vam = &vat_main;
10565 vat_json_node_t *node = NULL;
10566 struct in6_addr addr;
10568 if (VAT_JSON_ARRAY != vam->json_tree.type)
10570 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10571 vat_json_init_array (&vam->json_tree);
10573 node = vat_json_array_add (&vam->json_tree);
10575 vat_json_init_object (node);
10577 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10578 vat_json_object_add_ip6 (node, "our_address", addr);
10579 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10580 vat_json_object_add_ip6 (node, "client_address", addr);
10582 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10583 vat_json_init_array (lc);
10584 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10585 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10586 vat_json_object_add_uint (node, "remote_cookie",
10587 clib_net_to_host_u64 (mp->remote_cookie));
10589 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10590 vat_json_object_add_uint (node, "local_session_id",
10591 clib_net_to_host_u32 (mp->local_session_id));
10592 vat_json_object_add_uint (node, "remote_session_id",
10593 clib_net_to_host_u32 (mp->remote_session_id));
10594 vat_json_object_add_string_copy (node, "l2_sublayer",
10595 mp->l2_sublayer_present ? (u8 *) "present"
10596 : (u8 *) "absent");
10600 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10602 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10603 vl_api_control_ping_t *mp_ping;
10606 /* Get list of l2tpv3-tunnel interfaces */
10607 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10610 /* Use a control ping for synchronization */
10611 M (CONTROL_PING, mp_ping);
10619 static void vl_api_sw_interface_tap_details_t_handler
10620 (vl_api_sw_interface_tap_details_t * mp)
10622 vat_main_t *vam = &vat_main;
10624 print (vam->ofp, "%-16s %d",
10625 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10628 static void vl_api_sw_interface_tap_details_t_handler_json
10629 (vl_api_sw_interface_tap_details_t * mp)
10631 vat_main_t *vam = &vat_main;
10632 vat_json_node_t *node = NULL;
10634 if (VAT_JSON_ARRAY != vam->json_tree.type)
10636 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10637 vat_json_init_array (&vam->json_tree);
10639 node = vat_json_array_add (&vam->json_tree);
10641 vat_json_init_object (node);
10642 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10643 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10647 api_sw_interface_tap_dump (vat_main_t * vam)
10649 vl_api_sw_interface_tap_dump_t *mp;
10650 vl_api_control_ping_t *mp_ping;
10653 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10654 /* Get list of tap interfaces */
10655 M (SW_INTERFACE_TAP_DUMP, mp);
10658 /* Use a control ping for synchronization */
10659 M (CONTROL_PING, mp_ping);
10666 static uword unformat_vxlan_decap_next
10667 (unformat_input_t * input, va_list * args)
10669 u32 *result = va_arg (*args, u32 *);
10672 if (unformat (input, "l2"))
10673 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10674 else if (unformat (input, "%d", &tmp))
10682 api_vxlan_add_del_tunnel (vat_main_t * vam)
10684 unformat_input_t *line_input = vam->input;
10685 vl_api_vxlan_add_del_tunnel_t *mp;
10686 ip46_address_t src, dst;
10688 u8 ipv4_set = 0, ipv6_set = 0;
10692 u32 mcast_sw_if_index = ~0;
10693 u32 encap_vrf_id = 0;
10694 u32 decap_next_index = ~0;
10698 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10699 memset (&src, 0, sizeof src);
10700 memset (&dst, 0, sizeof dst);
10702 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10704 if (unformat (line_input, "del"))
10707 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10713 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10719 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10725 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10730 else if (unformat (line_input, "group %U %U",
10731 unformat_ip4_address, &dst.ip4,
10732 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10734 grp_set = dst_set = 1;
10737 else if (unformat (line_input, "group %U",
10738 unformat_ip4_address, &dst.ip4))
10740 grp_set = dst_set = 1;
10743 else if (unformat (line_input, "group %U %U",
10744 unformat_ip6_address, &dst.ip6,
10745 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10747 grp_set = dst_set = 1;
10750 else if (unformat (line_input, "group %U",
10751 unformat_ip6_address, &dst.ip6))
10753 grp_set = dst_set = 1;
10757 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10759 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10761 else if (unformat (line_input, "decap-next %U",
10762 unformat_vxlan_decap_next, &decap_next_index))
10764 else if (unformat (line_input, "vni %d", &vni))
10768 errmsg ("parse error '%U'", format_unformat_error, line_input);
10775 errmsg ("tunnel src address not specified");
10780 errmsg ("tunnel dst address not specified");
10784 if (grp_set && !ip46_address_is_multicast (&dst))
10786 errmsg ("tunnel group address not multicast");
10789 if (grp_set && mcast_sw_if_index == ~0)
10791 errmsg ("tunnel nonexistent multicast device");
10794 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10796 errmsg ("tunnel dst address must be unicast");
10801 if (ipv4_set && ipv6_set)
10803 errmsg ("both IPv4 and IPv6 addresses specified");
10807 if ((vni == 0) || (vni >> 24))
10809 errmsg ("vni not specified or out of range");
10813 M (VXLAN_ADD_DEL_TUNNEL, mp);
10817 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10818 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10822 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10823 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10825 mp->encap_vrf_id = ntohl (encap_vrf_id);
10826 mp->decap_next_index = ntohl (decap_next_index);
10827 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10828 mp->vni = ntohl (vni);
10829 mp->is_add = is_add;
10830 mp->is_ipv6 = ipv6_set;
10837 static void vl_api_vxlan_tunnel_details_t_handler
10838 (vl_api_vxlan_tunnel_details_t * mp)
10840 vat_main_t *vam = &vat_main;
10841 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
10842 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
10844 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10845 ntohl (mp->sw_if_index),
10846 format_ip46_address, &src, IP46_TYPE_ANY,
10847 format_ip46_address, &dst, IP46_TYPE_ANY,
10848 ntohl (mp->encap_vrf_id),
10849 ntohl (mp->decap_next_index), ntohl (mp->vni),
10850 ntohl (mp->mcast_sw_if_index));
10853 static void vl_api_vxlan_tunnel_details_t_handler_json
10854 (vl_api_vxlan_tunnel_details_t * mp)
10856 vat_main_t *vam = &vat_main;
10857 vat_json_node_t *node = NULL;
10859 if (VAT_JSON_ARRAY != vam->json_tree.type)
10861 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10862 vat_json_init_array (&vam->json_tree);
10864 node = vat_json_array_add (&vam->json_tree);
10866 vat_json_init_object (node);
10867 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10870 struct in6_addr ip6;
10872 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10873 vat_json_object_add_ip6 (node, "src_address", ip6);
10874 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10875 vat_json_object_add_ip6 (node, "dst_address", ip6);
10879 struct in_addr ip4;
10881 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10882 vat_json_object_add_ip4 (node, "src_address", ip4);
10883 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10884 vat_json_object_add_ip4 (node, "dst_address", ip4);
10886 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10887 vat_json_object_add_uint (node, "decap_next_index",
10888 ntohl (mp->decap_next_index));
10889 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10890 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10891 vat_json_object_add_uint (node, "mcast_sw_if_index",
10892 ntohl (mp->mcast_sw_if_index));
10896 api_vxlan_tunnel_dump (vat_main_t * vam)
10898 unformat_input_t *i = vam->input;
10899 vl_api_vxlan_tunnel_dump_t *mp;
10900 vl_api_control_ping_t *mp_ping;
10902 u8 sw_if_index_set = 0;
10905 /* Parse args required to build the message */
10906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10908 if (unformat (i, "sw_if_index %d", &sw_if_index))
10909 sw_if_index_set = 1;
10914 if (sw_if_index_set == 0)
10919 if (!vam->json_output)
10921 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10922 "sw_if_index", "src_address", "dst_address",
10923 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10926 /* Get list of vxlan-tunnel interfaces */
10927 M (VXLAN_TUNNEL_DUMP, mp);
10929 mp->sw_if_index = htonl (sw_if_index);
10933 /* Use a control ping for synchronization */
10934 M (CONTROL_PING, mp_ping);
10942 api_gre_add_del_tunnel (vat_main_t * vam)
10944 unformat_input_t *line_input = vam->input;
10945 vl_api_gre_add_del_tunnel_t *mp;
10946 ip4_address_t src4, dst4;
10951 u32 outer_fib_id = 0;
10954 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10956 if (unformat (line_input, "del"))
10958 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10960 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10962 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10964 else if (unformat (line_input, "teb"))
10968 errmsg ("parse error '%U'", format_unformat_error, line_input);
10975 errmsg ("tunnel src address not specified");
10980 errmsg ("tunnel dst address not specified");
10985 M (GRE_ADD_DEL_TUNNEL, mp);
10987 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10988 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10989 mp->outer_fib_id = ntohl (outer_fib_id);
10990 mp->is_add = is_add;
10998 static void vl_api_gre_tunnel_details_t_handler
10999 (vl_api_gre_tunnel_details_t * mp)
11001 vat_main_t *vam = &vat_main;
11003 print (vam->ofp, "%11d%15U%15U%6d%14d",
11004 ntohl (mp->sw_if_index),
11005 format_ip4_address, &mp->src_address,
11006 format_ip4_address, &mp->dst_address,
11007 mp->teb, ntohl (mp->outer_fib_id));
11010 static void vl_api_gre_tunnel_details_t_handler_json
11011 (vl_api_gre_tunnel_details_t * mp)
11013 vat_main_t *vam = &vat_main;
11014 vat_json_node_t *node = NULL;
11015 struct in_addr ip4;
11017 if (VAT_JSON_ARRAY != vam->json_tree.type)
11019 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11020 vat_json_init_array (&vam->json_tree);
11022 node = vat_json_array_add (&vam->json_tree);
11024 vat_json_init_object (node);
11025 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11026 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11027 vat_json_object_add_ip4 (node, "src_address", ip4);
11028 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11029 vat_json_object_add_ip4 (node, "dst_address", ip4);
11030 vat_json_object_add_uint (node, "teb", mp->teb);
11031 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11035 api_gre_tunnel_dump (vat_main_t * vam)
11037 unformat_input_t *i = vam->input;
11038 vl_api_gre_tunnel_dump_t *mp;
11039 vl_api_control_ping_t *mp_ping;
11041 u8 sw_if_index_set = 0;
11044 /* Parse args required to build the message */
11045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11047 if (unformat (i, "sw_if_index %d", &sw_if_index))
11048 sw_if_index_set = 1;
11053 if (sw_if_index_set == 0)
11058 if (!vam->json_output)
11060 print (vam->ofp, "%11s%15s%15s%6s%14s",
11061 "sw_if_index", "src_address", "dst_address", "teb",
11065 /* Get list of gre-tunnel interfaces */
11066 M (GRE_TUNNEL_DUMP, mp);
11068 mp->sw_if_index = htonl (sw_if_index);
11072 /* Use a control ping for synchronization */
11073 M (CONTROL_PING, mp_ping);
11081 api_l2_fib_clear_table (vat_main_t * vam)
11083 // unformat_input_t * i = vam->input;
11084 vl_api_l2_fib_clear_table_t *mp;
11087 M (L2_FIB_CLEAR_TABLE, mp);
11095 api_l2_interface_efp_filter (vat_main_t * vam)
11097 unformat_input_t *i = vam->input;
11098 vl_api_l2_interface_efp_filter_t *mp;
11101 u8 sw_if_index_set = 0;
11104 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11106 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11107 sw_if_index_set = 1;
11108 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11109 sw_if_index_set = 1;
11110 else if (unformat (i, "enable"))
11112 else if (unformat (i, "disable"))
11116 clib_warning ("parse error '%U'", format_unformat_error, i);
11121 if (sw_if_index_set == 0)
11123 errmsg ("missing sw_if_index");
11127 M (L2_INTERFACE_EFP_FILTER, mp);
11129 mp->sw_if_index = ntohl (sw_if_index);
11130 mp->enable_disable = enable;
11137 #define foreach_vtr_op \
11138 _("disable", L2_VTR_DISABLED) \
11139 _("push-1", L2_VTR_PUSH_1) \
11140 _("push-2", L2_VTR_PUSH_2) \
11141 _("pop-1", L2_VTR_POP_1) \
11142 _("pop-2", L2_VTR_POP_2) \
11143 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11144 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11145 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11146 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11149 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11151 unformat_input_t *i = vam->input;
11152 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11154 u8 sw_if_index_set = 0;
11157 u32 push_dot1q = 1;
11162 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11164 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11165 sw_if_index_set = 1;
11166 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11167 sw_if_index_set = 1;
11168 else if (unformat (i, "vtr_op %d", &vtr_op))
11170 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11173 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11175 else if (unformat (i, "tag1 %d", &tag1))
11177 else if (unformat (i, "tag2 %d", &tag2))
11181 clib_warning ("parse error '%U'", format_unformat_error, i);
11186 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11188 errmsg ("missing vtr operation or sw_if_index");
11192 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11193 mp->sw_if_index = ntohl (sw_if_index);
11194 mp->vtr_op = ntohl (vtr_op);
11195 mp->push_dot1q = ntohl (push_dot1q);
11196 mp->tag1 = ntohl (tag1);
11197 mp->tag2 = ntohl (tag2);
11205 api_create_vhost_user_if (vat_main_t * vam)
11207 unformat_input_t *i = vam->input;
11208 vl_api_create_vhost_user_if_t *mp;
11211 u8 file_name_set = 0;
11212 u32 custom_dev_instance = ~0;
11214 u8 use_custom_mac = 0;
11217 u8 operation_mode = VHOST_USER_POLLING_MODE;
11219 /* Shut up coverity */
11220 memset (hwaddr, 0, sizeof (hwaddr));
11222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11224 if (unformat (i, "socket %s", &file_name))
11228 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11230 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11231 use_custom_mac = 1;
11232 else if (unformat (i, "server"))
11234 else if (unformat (i, "tag %s", &tag))
11236 else if (unformat (i, "mode %U",
11237 api_unformat_vhost_user_operation_mode,
11244 if (file_name_set == 0)
11246 errmsg ("missing socket file name");
11250 if (vec_len (file_name) > 255)
11252 errmsg ("socket file name too long");
11255 vec_add1 (file_name, 0);
11257 M (CREATE_VHOST_USER_IF, mp);
11259 mp->operation_mode = operation_mode;
11260 mp->is_server = is_server;
11261 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11262 vec_free (file_name);
11263 if (custom_dev_instance != ~0)
11266 mp->custom_dev_instance = ntohl (custom_dev_instance);
11268 mp->use_custom_mac = use_custom_mac;
11269 clib_memcpy (mp->mac_address, hwaddr, 6);
11271 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11280 api_modify_vhost_user_if (vat_main_t * vam)
11282 unformat_input_t *i = vam->input;
11283 vl_api_modify_vhost_user_if_t *mp;
11286 u8 file_name_set = 0;
11287 u32 custom_dev_instance = ~0;
11288 u8 sw_if_index_set = 0;
11289 u32 sw_if_index = (u32) ~ 0;
11291 u8 operation_mode = VHOST_USER_POLLING_MODE;
11293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11295 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11296 sw_if_index_set = 1;
11297 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11298 sw_if_index_set = 1;
11299 else if (unformat (i, "socket %s", &file_name))
11303 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11305 else if (unformat (i, "server"))
11307 else if (unformat (i, "mode %U",
11308 api_unformat_vhost_user_operation_mode,
11315 if (sw_if_index_set == 0)
11317 errmsg ("missing sw_if_index or interface name");
11321 if (file_name_set == 0)
11323 errmsg ("missing socket file name");
11327 if (vec_len (file_name) > 255)
11329 errmsg ("socket file name too long");
11332 vec_add1 (file_name, 0);
11334 M (MODIFY_VHOST_USER_IF, mp);
11336 mp->operation_mode = operation_mode;
11337 mp->sw_if_index = ntohl (sw_if_index);
11338 mp->is_server = is_server;
11339 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11340 vec_free (file_name);
11341 if (custom_dev_instance != ~0)
11344 mp->custom_dev_instance = ntohl (custom_dev_instance);
11353 api_delete_vhost_user_if (vat_main_t * vam)
11355 unformat_input_t *i = vam->input;
11356 vl_api_delete_vhost_user_if_t *mp;
11357 u32 sw_if_index = ~0;
11358 u8 sw_if_index_set = 0;
11361 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11363 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11364 sw_if_index_set = 1;
11365 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11366 sw_if_index_set = 1;
11371 if (sw_if_index_set == 0)
11373 errmsg ("missing sw_if_index or interface name");
11378 M (DELETE_VHOST_USER_IF, mp);
11380 mp->sw_if_index = ntohl (sw_if_index);
11387 static void vl_api_sw_interface_vhost_user_details_t_handler
11388 (vl_api_sw_interface_vhost_user_details_t * mp)
11390 vat_main_t *vam = &vat_main;
11392 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %U %s",
11393 (char *) mp->interface_name,
11394 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11395 clib_net_to_host_u64 (mp->features), mp->is_server,
11396 ntohl (mp->num_regions), api_format_vhost_user_operation_mode,
11397 mp->operation_mode, (char *) mp->sock_filename);
11398 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11401 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11402 (vl_api_sw_interface_vhost_user_details_t * mp)
11404 vat_main_t *vam = &vat_main;
11405 vat_json_node_t *node = NULL;
11407 if (VAT_JSON_ARRAY != vam->json_tree.type)
11409 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11410 vat_json_init_array (&vam->json_tree);
11412 node = vat_json_array_add (&vam->json_tree);
11414 vat_json_init_object (node);
11415 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11416 vat_json_object_add_string_copy (node, "interface_name",
11417 mp->interface_name);
11418 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11419 ntohl (mp->virtio_net_hdr_sz));
11420 vat_json_object_add_uint (node, "features",
11421 clib_net_to_host_u64 (mp->features));
11422 vat_json_object_add_uint (node, "is_server", mp->is_server);
11423 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11424 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11425 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11426 vat_json_object_add_uint (node, "mode", mp->operation_mode);
11430 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11432 vl_api_sw_interface_vhost_user_dump_t *mp;
11433 vl_api_control_ping_t *mp_ping;
11436 "Interface name idx hdr_sz features server regions mode"
11439 /* Get list of vhost-user interfaces */
11440 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11443 /* Use a control ping for synchronization */
11444 M (CONTROL_PING, mp_ping);
11452 api_show_version (vat_main_t * vam)
11454 vl_api_show_version_t *mp;
11457 M (SHOW_VERSION, mp);
11466 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11468 unformat_input_t *line_input = vam->input;
11469 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11470 ip4_address_t local4, remote4;
11471 ip6_address_t local6, remote6;
11473 u8 ipv4_set = 0, ipv6_set = 0;
11476 u32 encap_vrf_id = 0;
11477 u32 decap_vrf_id = 0;
11483 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11485 if (unformat (line_input, "del"))
11487 else if (unformat (line_input, "local %U",
11488 unformat_ip4_address, &local4))
11493 else if (unformat (line_input, "remote %U",
11494 unformat_ip4_address, &remote4))
11499 else if (unformat (line_input, "local %U",
11500 unformat_ip6_address, &local6))
11505 else if (unformat (line_input, "remote %U",
11506 unformat_ip6_address, &remote6))
11511 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11513 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11515 else if (unformat (line_input, "vni %d", &vni))
11517 else if (unformat (line_input, "next-ip4"))
11519 else if (unformat (line_input, "next-ip6"))
11521 else if (unformat (line_input, "next-ethernet"))
11523 else if (unformat (line_input, "next-nsh"))
11527 errmsg ("parse error '%U'", format_unformat_error, line_input);
11532 if (local_set == 0)
11534 errmsg ("tunnel local address not specified");
11537 if (remote_set == 0)
11539 errmsg ("tunnel remote address not specified");
11542 if (ipv4_set && ipv6_set)
11544 errmsg ("both IPv4 and IPv6 addresses specified");
11550 errmsg ("vni not specified");
11554 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11559 clib_memcpy (&mp->local, &local6, sizeof (local6));
11560 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11564 clib_memcpy (&mp->local, &local4, sizeof (local4));
11565 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11568 mp->encap_vrf_id = ntohl (encap_vrf_id);
11569 mp->decap_vrf_id = ntohl (decap_vrf_id);
11570 mp->protocol = protocol;
11571 mp->vni = ntohl (vni);
11572 mp->is_add = is_add;
11573 mp->is_ipv6 = ipv6_set;
11580 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11581 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11583 vat_main_t *vam = &vat_main;
11585 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11586 ntohl (mp->sw_if_index),
11587 format_ip46_address, &(mp->local[0]),
11588 format_ip46_address, &(mp->remote[0]),
11590 ntohl (mp->protocol),
11591 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11594 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11595 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11597 vat_main_t *vam = &vat_main;
11598 vat_json_node_t *node = NULL;
11599 struct in_addr ip4;
11600 struct in6_addr ip6;
11602 if (VAT_JSON_ARRAY != vam->json_tree.type)
11604 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11605 vat_json_init_array (&vam->json_tree);
11607 node = vat_json_array_add (&vam->json_tree);
11609 vat_json_init_object (node);
11610 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11613 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11614 vat_json_object_add_ip6 (node, "local", ip6);
11615 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11616 vat_json_object_add_ip6 (node, "remote", ip6);
11620 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11621 vat_json_object_add_ip4 (node, "local", ip4);
11622 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11623 vat_json_object_add_ip4 (node, "remote", ip4);
11625 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11626 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11627 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11628 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11629 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11633 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11635 unformat_input_t *i = vam->input;
11636 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11637 vl_api_control_ping_t *mp_ping;
11639 u8 sw_if_index_set = 0;
11642 /* Parse args required to build the message */
11643 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11645 if (unformat (i, "sw_if_index %d", &sw_if_index))
11646 sw_if_index_set = 1;
11651 if (sw_if_index_set == 0)
11656 if (!vam->json_output)
11658 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11659 "sw_if_index", "local", "remote", "vni",
11660 "protocol", "encap_vrf_id", "decap_vrf_id");
11663 /* Get list of vxlan-tunnel interfaces */
11664 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11666 mp->sw_if_index = htonl (sw_if_index);
11670 /* Use a control ping for synchronization */
11671 M (CONTROL_PING, mp_ping);
11679 format_l2_fib_mac_address (u8 * s, va_list * args)
11681 u8 *a = va_arg (*args, u8 *);
11683 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11684 a[2], a[3], a[4], a[5], a[6], a[7]);
11687 static void vl_api_l2_fib_table_entry_t_handler
11688 (vl_api_l2_fib_table_entry_t * mp)
11690 vat_main_t *vam = &vat_main;
11692 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11694 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11695 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11699 static void vl_api_l2_fib_table_entry_t_handler_json
11700 (vl_api_l2_fib_table_entry_t * mp)
11702 vat_main_t *vam = &vat_main;
11703 vat_json_node_t *node = NULL;
11705 if (VAT_JSON_ARRAY != vam->json_tree.type)
11707 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11708 vat_json_init_array (&vam->json_tree);
11710 node = vat_json_array_add (&vam->json_tree);
11712 vat_json_init_object (node);
11713 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11714 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11715 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11716 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11717 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11718 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11722 api_l2_fib_table_dump (vat_main_t * vam)
11724 unformat_input_t *i = vam->input;
11725 vl_api_l2_fib_table_dump_t *mp;
11726 vl_api_control_ping_t *mp_ping;
11731 /* Parse args required to build the message */
11732 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11734 if (unformat (i, "bd_id %d", &bd_id))
11740 if (bd_id_set == 0)
11742 errmsg ("missing bridge domain");
11746 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11748 /* Get list of l2 fib entries */
11749 M (L2_FIB_TABLE_DUMP, mp);
11751 mp->bd_id = ntohl (bd_id);
11754 /* Use a control ping for synchronization */
11755 M (CONTROL_PING, mp_ping);
11764 api_interface_name_renumber (vat_main_t * vam)
11766 unformat_input_t *line_input = vam->input;
11767 vl_api_interface_name_renumber_t *mp;
11768 u32 sw_if_index = ~0;
11769 u32 new_show_dev_instance = ~0;
11772 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11774 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11777 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11779 else if (unformat (line_input, "new_show_dev_instance %d",
11780 &new_show_dev_instance))
11786 if (sw_if_index == ~0)
11788 errmsg ("missing interface name or sw_if_index");
11792 if (new_show_dev_instance == ~0)
11794 errmsg ("missing new_show_dev_instance");
11798 M (INTERFACE_NAME_RENUMBER, mp);
11800 mp->sw_if_index = ntohl (sw_if_index);
11801 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11809 api_want_ip4_arp_events (vat_main_t * vam)
11811 unformat_input_t *line_input = vam->input;
11812 vl_api_want_ip4_arp_events_t *mp;
11813 ip4_address_t address;
11814 int address_set = 0;
11815 u32 enable_disable = 1;
11818 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11820 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11822 else if (unformat (line_input, "del"))
11823 enable_disable = 0;
11828 if (address_set == 0)
11830 errmsg ("missing addresses");
11834 M (WANT_IP4_ARP_EVENTS, mp);
11835 mp->enable_disable = enable_disable;
11836 mp->pid = getpid ();
11837 mp->address = address.as_u32;
11845 api_want_ip6_nd_events (vat_main_t * vam)
11847 unformat_input_t *line_input = vam->input;
11848 vl_api_want_ip6_nd_events_t *mp;
11849 ip6_address_t address;
11850 int address_set = 0;
11851 u32 enable_disable = 1;
11854 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11856 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11858 else if (unformat (line_input, "del"))
11859 enable_disable = 0;
11864 if (address_set == 0)
11866 errmsg ("missing addresses");
11870 M (WANT_IP6_ND_EVENTS, mp);
11871 mp->enable_disable = enable_disable;
11872 mp->pid = getpid ();
11873 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11881 api_input_acl_set_interface (vat_main_t * vam)
11883 unformat_input_t *i = vam->input;
11884 vl_api_input_acl_set_interface_t *mp;
11886 int sw_if_index_set;
11887 u32 ip4_table_index = ~0;
11888 u32 ip6_table_index = ~0;
11889 u32 l2_table_index = ~0;
11893 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11895 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11896 sw_if_index_set = 1;
11897 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11898 sw_if_index_set = 1;
11899 else if (unformat (i, "del"))
11901 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11903 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11905 else if (unformat (i, "l2-table %d", &l2_table_index))
11909 clib_warning ("parse error '%U'", format_unformat_error, i);
11914 if (sw_if_index_set == 0)
11916 errmsg ("missing interface name or sw_if_index");
11920 M (INPUT_ACL_SET_INTERFACE, mp);
11922 mp->sw_if_index = ntohl (sw_if_index);
11923 mp->ip4_table_index = ntohl (ip4_table_index);
11924 mp->ip6_table_index = ntohl (ip6_table_index);
11925 mp->l2_table_index = ntohl (l2_table_index);
11926 mp->is_add = is_add;
11934 api_ip_address_dump (vat_main_t * vam)
11936 unformat_input_t *i = vam->input;
11937 vl_api_ip_address_dump_t *mp;
11938 vl_api_control_ping_t *mp_ping;
11939 u32 sw_if_index = ~0;
11940 u8 sw_if_index_set = 0;
11945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11947 if (unformat (i, "sw_if_index %d", &sw_if_index))
11948 sw_if_index_set = 1;
11950 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11951 sw_if_index_set = 1;
11952 else if (unformat (i, "ipv4"))
11954 else if (unformat (i, "ipv6"))
11960 if (ipv4_set && ipv6_set)
11962 errmsg ("ipv4 and ipv6 flags cannot be both set");
11966 if ((!ipv4_set) && (!ipv6_set))
11968 errmsg ("no ipv4 nor ipv6 flag set");
11972 if (sw_if_index_set == 0)
11974 errmsg ("missing interface name or sw_if_index");
11978 vam->current_sw_if_index = sw_if_index;
11979 vam->is_ipv6 = ipv6_set;
11981 M (IP_ADDRESS_DUMP, mp);
11982 mp->sw_if_index = ntohl (sw_if_index);
11983 mp->is_ipv6 = ipv6_set;
11986 /* Use a control ping for synchronization */
11987 M (CONTROL_PING, mp_ping);
11995 api_ip_dump (vat_main_t * vam)
11997 vl_api_ip_dump_t *mp;
11998 vl_api_control_ping_t *mp_ping;
11999 unformat_input_t *in = vam->input;
12006 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
12008 if (unformat (in, "ipv4"))
12010 else if (unformat (in, "ipv6"))
12016 if (ipv4_set && ipv6_set)
12018 errmsg ("ipv4 and ipv6 flags cannot be both set");
12022 if ((!ipv4_set) && (!ipv6_set))
12024 errmsg ("no ipv4 nor ipv6 flag set");
12028 is_ipv6 = ipv6_set;
12029 vam->is_ipv6 = is_ipv6;
12031 /* free old data */
12032 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12034 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12036 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12039 mp->is_ipv6 = ipv6_set;
12042 /* Use a control ping for synchronization */
12043 M (CONTROL_PING, mp_ping);
12051 api_ipsec_spd_add_del (vat_main_t * vam)
12053 unformat_input_t *i = vam->input;
12054 vl_api_ipsec_spd_add_del_t *mp;
12059 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12061 if (unformat (i, "spd_id %d", &spd_id))
12063 else if (unformat (i, "del"))
12067 clib_warning ("parse error '%U'", format_unformat_error, i);
12073 errmsg ("spd_id must be set");
12077 M (IPSEC_SPD_ADD_DEL, mp);
12079 mp->spd_id = ntohl (spd_id);
12080 mp->is_add = is_add;
12088 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12090 unformat_input_t *i = vam->input;
12091 vl_api_ipsec_interface_add_del_spd_t *mp;
12093 u8 sw_if_index_set = 0;
12094 u32 spd_id = (u32) ~ 0;
12098 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12100 if (unformat (i, "del"))
12102 else if (unformat (i, "spd_id %d", &spd_id))
12105 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12106 sw_if_index_set = 1;
12107 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12108 sw_if_index_set = 1;
12111 clib_warning ("parse error '%U'", format_unformat_error, i);
12117 if (spd_id == (u32) ~ 0)
12119 errmsg ("spd_id must be set");
12123 if (sw_if_index_set == 0)
12125 errmsg ("missing interface name or sw_if_index");
12129 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12131 mp->spd_id = ntohl (spd_id);
12132 mp->sw_if_index = ntohl (sw_if_index);
12133 mp->is_add = is_add;
12141 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12143 unformat_input_t *i = vam->input;
12144 vl_api_ipsec_spd_add_del_entry_t *mp;
12145 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12146 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12148 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12149 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12150 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12151 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12154 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12155 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12156 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12157 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12158 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12159 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12161 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12163 if (unformat (i, "del"))
12165 if (unformat (i, "outbound"))
12167 if (unformat (i, "inbound"))
12169 else if (unformat (i, "spd_id %d", &spd_id))
12171 else if (unformat (i, "sa_id %d", &sa_id))
12173 else if (unformat (i, "priority %d", &priority))
12175 else if (unformat (i, "protocol %d", &protocol))
12177 else if (unformat (i, "lport_start %d", &lport_start))
12179 else if (unformat (i, "lport_stop %d", &lport_stop))
12181 else if (unformat (i, "rport_start %d", &rport_start))
12183 else if (unformat (i, "rport_stop %d", &rport_stop))
12187 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12193 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12200 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12206 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12213 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12219 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12226 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12232 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12238 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12240 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12242 clib_warning ("unsupported action: 'resolve'");
12248 clib_warning ("parse error '%U'", format_unformat_error, i);
12254 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12256 mp->spd_id = ntohl (spd_id);
12257 mp->priority = ntohl (priority);
12258 mp->is_outbound = is_outbound;
12260 mp->is_ipv6 = is_ipv6;
12261 if (is_ipv6 || is_ip_any)
12263 clib_memcpy (mp->remote_address_start, &raddr6_start,
12264 sizeof (ip6_address_t));
12265 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12266 sizeof (ip6_address_t));
12267 clib_memcpy (mp->local_address_start, &laddr6_start,
12268 sizeof (ip6_address_t));
12269 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12270 sizeof (ip6_address_t));
12274 clib_memcpy (mp->remote_address_start, &raddr4_start,
12275 sizeof (ip4_address_t));
12276 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12277 sizeof (ip4_address_t));
12278 clib_memcpy (mp->local_address_start, &laddr4_start,
12279 sizeof (ip4_address_t));
12280 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12281 sizeof (ip4_address_t));
12283 mp->protocol = (u8) protocol;
12284 mp->local_port_start = ntohs ((u16) lport_start);
12285 mp->local_port_stop = ntohs ((u16) lport_stop);
12286 mp->remote_port_start = ntohs ((u16) rport_start);
12287 mp->remote_port_stop = ntohs ((u16) rport_stop);
12288 mp->policy = (u8) policy;
12289 mp->sa_id = ntohl (sa_id);
12290 mp->is_add = is_add;
12291 mp->is_ip_any = is_ip_any;
12298 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12300 unformat_input_t *i = vam->input;
12301 vl_api_ipsec_sad_add_del_entry_t *mp;
12302 u32 sad_id = 0, spi = 0;
12303 u8 *ck = 0, *ik = 0;
12306 u8 protocol = IPSEC_PROTOCOL_AH;
12307 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12308 u32 crypto_alg = 0, integ_alg = 0;
12309 ip4_address_t tun_src4;
12310 ip4_address_t tun_dst4;
12311 ip6_address_t tun_src6;
12312 ip6_address_t tun_dst6;
12315 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12317 if (unformat (i, "del"))
12319 else if (unformat (i, "sad_id %d", &sad_id))
12321 else if (unformat (i, "spi %d", &spi))
12323 else if (unformat (i, "esp"))
12324 protocol = IPSEC_PROTOCOL_ESP;
12325 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12328 is_tunnel_ipv6 = 0;
12330 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12333 is_tunnel_ipv6 = 0;
12335 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12338 is_tunnel_ipv6 = 1;
12340 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12343 is_tunnel_ipv6 = 1;
12347 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12349 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12350 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12352 clib_warning ("unsupported crypto-alg: '%U'",
12353 format_ipsec_crypto_alg, crypto_alg);
12357 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12361 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12363 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12364 integ_alg >= IPSEC_INTEG_N_ALG)
12366 clib_warning ("unsupported integ-alg: '%U'",
12367 format_ipsec_integ_alg, integ_alg);
12371 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12375 clib_warning ("parse error '%U'", format_unformat_error, i);
12381 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12383 mp->sad_id = ntohl (sad_id);
12384 mp->is_add = is_add;
12385 mp->protocol = protocol;
12386 mp->spi = ntohl (spi);
12387 mp->is_tunnel = is_tunnel;
12388 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12389 mp->crypto_algorithm = crypto_alg;
12390 mp->integrity_algorithm = integ_alg;
12391 mp->crypto_key_length = vec_len (ck);
12392 mp->integrity_key_length = vec_len (ik);
12394 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12395 mp->crypto_key_length = sizeof (mp->crypto_key);
12397 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12398 mp->integrity_key_length = sizeof (mp->integrity_key);
12401 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12403 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12407 if (is_tunnel_ipv6)
12409 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12410 sizeof (ip6_address_t));
12411 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12412 sizeof (ip6_address_t));
12416 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12417 sizeof (ip4_address_t));
12418 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12419 sizeof (ip4_address_t));
12429 api_ipsec_sa_set_key (vat_main_t * vam)
12431 unformat_input_t *i = vam->input;
12432 vl_api_ipsec_sa_set_key_t *mp;
12434 u8 *ck = 0, *ik = 0;
12437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12439 if (unformat (i, "sa_id %d", &sa_id))
12441 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12443 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12447 clib_warning ("parse error '%U'", format_unformat_error, i);
12452 M (IPSEC_SA_SET_KEY, mp);
12454 mp->sa_id = ntohl (sa_id);
12455 mp->crypto_key_length = vec_len (ck);
12456 mp->integrity_key_length = vec_len (ik);
12458 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12459 mp->crypto_key_length = sizeof (mp->crypto_key);
12461 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12462 mp->integrity_key_length = sizeof (mp->integrity_key);
12465 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12467 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12475 api_ikev2_profile_add_del (vat_main_t * vam)
12477 unformat_input_t *i = vam->input;
12478 vl_api_ikev2_profile_add_del_t *mp;
12483 const char *valid_chars = "a-zA-Z0-9_";
12485 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12487 if (unformat (i, "del"))
12489 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12490 vec_add1 (name, 0);
12493 errmsg ("parse error '%U'", format_unformat_error, i);
12498 if (!vec_len (name))
12500 errmsg ("profile name must be specified");
12504 if (vec_len (name) > 64)
12506 errmsg ("profile name too long");
12510 M (IKEV2_PROFILE_ADD_DEL, mp);
12512 clib_memcpy (mp->name, name, vec_len (name));
12513 mp->is_add = is_add;
12522 api_ikev2_profile_set_auth (vat_main_t * vam)
12524 unformat_input_t *i = vam->input;
12525 vl_api_ikev2_profile_set_auth_t *mp;
12528 u32 auth_method = 0;
12532 const char *valid_chars = "a-zA-Z0-9_";
12534 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12536 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12537 vec_add1 (name, 0);
12538 else if (unformat (i, "auth_method %U",
12539 unformat_ikev2_auth_method, &auth_method))
12541 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12543 else if (unformat (i, "auth_data %v", &data))
12547 errmsg ("parse error '%U'", format_unformat_error, i);
12552 if (!vec_len (name))
12554 errmsg ("profile name must be specified");
12558 if (vec_len (name) > 64)
12560 errmsg ("profile name too long");
12564 if (!vec_len (data))
12566 errmsg ("auth_data must be specified");
12572 errmsg ("auth_method must be specified");
12576 M (IKEV2_PROFILE_SET_AUTH, mp);
12578 mp->is_hex = is_hex;
12579 mp->auth_method = (u8) auth_method;
12580 mp->data_len = vec_len (data);
12581 clib_memcpy (mp->name, name, vec_len (name));
12582 clib_memcpy (mp->data, data, vec_len (data));
12592 api_ikev2_profile_set_id (vat_main_t * vam)
12594 unformat_input_t *i = vam->input;
12595 vl_api_ikev2_profile_set_id_t *mp;
12603 const char *valid_chars = "a-zA-Z0-9_";
12605 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12607 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12608 vec_add1 (name, 0);
12609 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12611 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12613 data = vec_new (u8, 4);
12614 clib_memcpy (data, ip4.as_u8, 4);
12616 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12618 else if (unformat (i, "id_data %v", &data))
12620 else if (unformat (i, "local"))
12622 else if (unformat (i, "remote"))
12626 errmsg ("parse error '%U'", format_unformat_error, i);
12631 if (!vec_len (name))
12633 errmsg ("profile name must be specified");
12637 if (vec_len (name) > 64)
12639 errmsg ("profile name too long");
12643 if (!vec_len (data))
12645 errmsg ("id_data must be specified");
12651 errmsg ("id_type must be specified");
12655 M (IKEV2_PROFILE_SET_ID, mp);
12657 mp->is_local = is_local;
12658 mp->id_type = (u8) id_type;
12659 mp->data_len = vec_len (data);
12660 clib_memcpy (mp->name, name, vec_len (name));
12661 clib_memcpy (mp->data, data, vec_len (data));
12671 api_ikev2_profile_set_ts (vat_main_t * vam)
12673 unformat_input_t *i = vam->input;
12674 vl_api_ikev2_profile_set_ts_t *mp;
12677 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12678 ip4_address_t start_addr, end_addr;
12680 const char *valid_chars = "a-zA-Z0-9_";
12683 start_addr.as_u32 = 0;
12684 end_addr.as_u32 = (u32) ~ 0;
12686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12688 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12689 vec_add1 (name, 0);
12690 else if (unformat (i, "protocol %d", &proto))
12692 else if (unformat (i, "start_port %d", &start_port))
12694 else if (unformat (i, "end_port %d", &end_port))
12697 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12699 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12701 else if (unformat (i, "local"))
12703 else if (unformat (i, "remote"))
12707 errmsg ("parse error '%U'", format_unformat_error, i);
12712 if (!vec_len (name))
12714 errmsg ("profile name must be specified");
12718 if (vec_len (name) > 64)
12720 errmsg ("profile name too long");
12724 M (IKEV2_PROFILE_SET_TS, mp);
12726 mp->is_local = is_local;
12727 mp->proto = (u8) proto;
12728 mp->start_port = (u16) start_port;
12729 mp->end_port = (u16) end_port;
12730 mp->start_addr = start_addr.as_u32;
12731 mp->end_addr = end_addr.as_u32;
12732 clib_memcpy (mp->name, name, vec_len (name));
12741 api_ikev2_set_local_key (vat_main_t * vam)
12743 unformat_input_t *i = vam->input;
12744 vl_api_ikev2_set_local_key_t *mp;
12748 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12750 if (unformat (i, "file %v", &file))
12751 vec_add1 (file, 0);
12754 errmsg ("parse error '%U'", format_unformat_error, i);
12759 if (!vec_len (file))
12761 errmsg ("RSA key file must be specified");
12765 if (vec_len (file) > 256)
12767 errmsg ("file name too long");
12771 M (IKEV2_SET_LOCAL_KEY, mp);
12773 clib_memcpy (mp->key_file, file, vec_len (file));
12782 api_ikev2_set_responder (vat_main_t * vam)
12784 unformat_input_t *i = vam->input;
12785 vl_api_ikev2_set_responder_t *mp;
12788 u32 sw_if_index = ~0;
12789 ip4_address_t address;
12791 const char *valid_chars = "a-zA-Z0-9_";
12793 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12796 (i, "%U interface %d address %U", unformat_token, valid_chars,
12797 &name, &sw_if_index, unformat_ip4_address, &address))
12798 vec_add1 (name, 0);
12801 errmsg ("parse error '%U'", format_unformat_error, i);
12806 if (!vec_len (name))
12808 errmsg ("profile name must be specified");
12812 if (vec_len (name) > 64)
12814 errmsg ("profile name too long");
12818 M (IKEV2_SET_RESPONDER, mp);
12820 clib_memcpy (mp->name, name, vec_len (name));
12823 mp->sw_if_index = sw_if_index;
12824 clib_memcpy (mp->address, &address, sizeof (address));
12832 api_ikev2_set_ike_transforms (vat_main_t * vam)
12834 unformat_input_t *i = vam->input;
12835 vl_api_ikev2_set_ike_transforms_t *mp;
12838 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12840 const char *valid_chars = "a-zA-Z0-9_";
12842 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12844 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12845 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12846 vec_add1 (name, 0);
12849 errmsg ("parse error '%U'", format_unformat_error, i);
12854 if (!vec_len (name))
12856 errmsg ("profile name must be specified");
12860 if (vec_len (name) > 64)
12862 errmsg ("profile name too long");
12866 M (IKEV2_SET_IKE_TRANSFORMS, mp);
12868 clib_memcpy (mp->name, name, vec_len (name));
12870 mp->crypto_alg = crypto_alg;
12871 mp->crypto_key_size = crypto_key_size;
12872 mp->integ_alg = integ_alg;
12873 mp->dh_group = dh_group;
12882 api_ikev2_set_esp_transforms (vat_main_t * vam)
12884 unformat_input_t *i = vam->input;
12885 vl_api_ikev2_set_esp_transforms_t *mp;
12888 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12890 const char *valid_chars = "a-zA-Z0-9_";
12892 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12894 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12895 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12896 vec_add1 (name, 0);
12899 errmsg ("parse error '%U'", format_unformat_error, i);
12904 if (!vec_len (name))
12906 errmsg ("profile name must be specified");
12910 if (vec_len (name) > 64)
12912 errmsg ("profile name too long");
12916 M (IKEV2_SET_ESP_TRANSFORMS, mp);
12918 clib_memcpy (mp->name, name, vec_len (name));
12920 mp->crypto_alg = crypto_alg;
12921 mp->crypto_key_size = crypto_key_size;
12922 mp->integ_alg = integ_alg;
12923 mp->dh_group = dh_group;
12931 api_ikev2_set_sa_lifetime (vat_main_t * vam)
12933 unformat_input_t *i = vam->input;
12934 vl_api_ikev2_set_sa_lifetime_t *mp;
12937 u64 lifetime, lifetime_maxdata;
12938 u32 lifetime_jitter, handover;
12940 const char *valid_chars = "a-zA-Z0-9_";
12942 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12944 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
12945 &lifetime, &lifetime_jitter, &handover,
12946 &lifetime_maxdata))
12947 vec_add1 (name, 0);
12950 errmsg ("parse error '%U'", format_unformat_error, i);
12955 if (!vec_len (name))
12957 errmsg ("profile name must be specified");
12961 if (vec_len (name) > 64)
12963 errmsg ("profile name too long");
12967 M (IKEV2_SET_SA_LIFETIME, mp);
12969 clib_memcpy (mp->name, name, vec_len (name));
12971 mp->lifetime = lifetime;
12972 mp->lifetime_jitter = lifetime_jitter;
12973 mp->handover = handover;
12974 mp->lifetime_maxdata = lifetime_maxdata;
12982 api_ikev2_initiate_sa_init (vat_main_t * vam)
12984 unformat_input_t *i = vam->input;
12985 vl_api_ikev2_initiate_sa_init_t *mp;
12989 const char *valid_chars = "a-zA-Z0-9_";
12991 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12993 if (unformat (i, "%U", unformat_token, valid_chars, &name))
12994 vec_add1 (name, 0);
12997 errmsg ("parse error '%U'", format_unformat_error, i);
13002 if (!vec_len (name))
13004 errmsg ("profile name must be specified");
13008 if (vec_len (name) > 64)
13010 errmsg ("profile name too long");
13014 M (IKEV2_INITIATE_SA_INIT, mp);
13016 clib_memcpy (mp->name, name, vec_len (name));
13025 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
13027 unformat_input_t *i = vam->input;
13028 vl_api_ikev2_initiate_del_ike_sa_t *mp;
13033 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13035 if (unformat (i, "%lx", &ispi))
13039 errmsg ("parse error '%U'", format_unformat_error, i);
13044 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
13054 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13056 unformat_input_t *i = vam->input;
13057 vl_api_ikev2_initiate_del_child_sa_t *mp;
13062 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13064 if (unformat (i, "%x", &ispi))
13068 errmsg ("parse error '%U'", format_unformat_error, i);
13073 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13083 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13085 unformat_input_t *i = vam->input;
13086 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13091 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13093 if (unformat (i, "%x", &ispi))
13097 errmsg ("parse error '%U'", format_unformat_error, i);
13102 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
13115 api_map_add_domain (vat_main_t * vam)
13117 unformat_input_t *i = vam->input;
13118 vl_api_map_add_domain_t *mp;
13120 ip4_address_t ip4_prefix;
13121 ip6_address_t ip6_prefix;
13122 ip6_address_t ip6_src;
13123 u32 num_m_args = 0;
13124 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
13125 0, psid_length = 0;
13126 u8 is_translation = 0;
13128 u32 ip6_src_len = 128;
13131 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13133 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
13134 &ip4_prefix, &ip4_prefix_len))
13136 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
13137 &ip6_prefix, &ip6_prefix_len))
13141 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
13144 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
13146 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
13148 else if (unformat (i, "psid-offset %d", &psid_offset))
13150 else if (unformat (i, "psid-len %d", &psid_length))
13152 else if (unformat (i, "mtu %d", &mtu))
13154 else if (unformat (i, "map-t"))
13155 is_translation = 1;
13158 clib_warning ("parse error '%U'", format_unformat_error, i);
13163 if (num_m_args < 3)
13165 errmsg ("mandatory argument(s) missing");
13169 /* Construct the API message */
13170 M (MAP_ADD_DOMAIN, mp);
13172 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
13173 mp->ip4_prefix_len = ip4_prefix_len;
13175 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
13176 mp->ip6_prefix_len = ip6_prefix_len;
13178 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
13179 mp->ip6_src_prefix_len = ip6_src_len;
13181 mp->ea_bits_len = ea_bits_len;
13182 mp->psid_offset = psid_offset;
13183 mp->psid_length = psid_length;
13184 mp->is_translation = is_translation;
13185 mp->mtu = htons (mtu);
13190 /* Wait for a reply, return good/bad news */
13196 api_map_del_domain (vat_main_t * vam)
13198 unformat_input_t *i = vam->input;
13199 vl_api_map_del_domain_t *mp;
13201 u32 num_m_args = 0;
13205 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13207 if (unformat (i, "index %d", &index))
13211 clib_warning ("parse error '%U'", format_unformat_error, i);
13216 if (num_m_args != 1)
13218 errmsg ("mandatory argument(s) missing");
13222 /* Construct the API message */
13223 M (MAP_DEL_DOMAIN, mp);
13225 mp->index = ntohl (index);
13230 /* Wait for a reply, return good/bad news */
13236 api_map_add_del_rule (vat_main_t * vam)
13238 unformat_input_t *i = vam->input;
13239 vl_api_map_add_del_rule_t *mp;
13241 ip6_address_t ip6_dst;
13242 u32 num_m_args = 0, index, psid = 0;
13245 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13247 if (unformat (i, "index %d", &index))
13249 else if (unformat (i, "psid %d", &psid))
13251 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13253 else if (unformat (i, "del"))
13259 clib_warning ("parse error '%U'", format_unformat_error, i);
13264 /* Construct the API message */
13265 M (MAP_ADD_DEL_RULE, mp);
13267 mp->index = ntohl (index);
13268 mp->is_add = is_add;
13269 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13270 mp->psid = ntohs (psid);
13275 /* Wait for a reply, return good/bad news */
13281 api_map_domain_dump (vat_main_t * vam)
13283 vl_api_map_domain_dump_t *mp;
13284 vl_api_control_ping_t *mp_ping;
13287 /* Construct the API message */
13288 M (MAP_DOMAIN_DUMP, mp);
13293 /* Use a control ping for synchronization */
13294 M (CONTROL_PING, mp_ping);
13302 api_map_rule_dump (vat_main_t * vam)
13304 unformat_input_t *i = vam->input;
13305 vl_api_map_rule_dump_t *mp;
13306 vl_api_control_ping_t *mp_ping;
13307 u32 domain_index = ~0;
13310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13312 if (unformat (i, "index %u", &domain_index))
13318 if (domain_index == ~0)
13320 clib_warning ("parse error: domain index expected");
13324 /* Construct the API message */
13325 M (MAP_RULE_DUMP, mp);
13327 mp->domain_index = htonl (domain_index);
13332 /* Use a control ping for synchronization */
13333 M (CONTROL_PING, mp_ping);
13340 static void vl_api_map_add_domain_reply_t_handler
13341 (vl_api_map_add_domain_reply_t * mp)
13343 vat_main_t *vam = &vat_main;
13344 i32 retval = ntohl (mp->retval);
13346 if (vam->async_mode)
13348 vam->async_errors += (retval < 0);
13352 vam->retval = retval;
13353 vam->result_ready = 1;
13357 static void vl_api_map_add_domain_reply_t_handler_json
13358 (vl_api_map_add_domain_reply_t * mp)
13360 vat_main_t *vam = &vat_main;
13361 vat_json_node_t node;
13363 vat_json_init_object (&node);
13364 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13365 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13367 vat_json_print (vam->ofp, &node);
13368 vat_json_free (&node);
13370 vam->retval = ntohl (mp->retval);
13371 vam->result_ready = 1;
13375 api_get_first_msg_id (vat_main_t * vam)
13377 vl_api_get_first_msg_id_t *mp;
13378 unformat_input_t *i = vam->input;
13383 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13385 if (unformat (i, "client %s", &name))
13393 errmsg ("missing client name");
13396 vec_add1 (name, 0);
13398 if (vec_len (name) > 63)
13400 errmsg ("client name too long");
13404 M (GET_FIRST_MSG_ID, mp);
13405 clib_memcpy (mp->name, name, vec_len (name));
13412 api_cop_interface_enable_disable (vat_main_t * vam)
13414 unformat_input_t *line_input = vam->input;
13415 vl_api_cop_interface_enable_disable_t *mp;
13416 u32 sw_if_index = ~0;
13417 u8 enable_disable = 1;
13420 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13422 if (unformat (line_input, "disable"))
13423 enable_disable = 0;
13424 if (unformat (line_input, "enable"))
13425 enable_disable = 1;
13426 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13427 vam, &sw_if_index))
13429 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13435 if (sw_if_index == ~0)
13437 errmsg ("missing interface name or sw_if_index");
13441 /* Construct the API message */
13442 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13443 mp->sw_if_index = ntohl (sw_if_index);
13444 mp->enable_disable = enable_disable;
13448 /* Wait for the reply */
13454 api_cop_whitelist_enable_disable (vat_main_t * vam)
13456 unformat_input_t *line_input = vam->input;
13457 vl_api_cop_whitelist_enable_disable_t *mp;
13458 u32 sw_if_index = ~0;
13459 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13463 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13465 if (unformat (line_input, "ip4"))
13467 else if (unformat (line_input, "ip6"))
13469 else if (unformat (line_input, "default"))
13471 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13472 vam, &sw_if_index))
13474 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13476 else if (unformat (line_input, "fib-id %d", &fib_id))
13482 if (sw_if_index == ~0)
13484 errmsg ("missing interface name or sw_if_index");
13488 /* Construct the API message */
13489 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13490 mp->sw_if_index = ntohl (sw_if_index);
13491 mp->fib_id = ntohl (fib_id);
13494 mp->default_cop = default_cop;
13498 /* Wait for the reply */
13504 api_get_node_graph (vat_main_t * vam)
13506 vl_api_get_node_graph_t *mp;
13509 M (GET_NODE_GRAPH, mp);
13513 /* Wait for the reply */
13519 /** Used for parsing LISP eids */
13520 typedef CLIB_PACKED(struct{
13521 u8 addr[16]; /**< eid address */
13522 u32 len; /**< prefix length if IP */
13523 u8 type; /**< type of eid */
13528 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13530 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13532 memset (a, 0, sizeof (a[0]));
13534 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13536 a->type = 0; /* ipv4 type */
13538 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13540 a->type = 1; /* ipv6 type */
13542 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13544 a->type = 2; /* mac type */
13551 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13560 lisp_eid_size_vat (u8 type)
13575 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13577 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13581 api_one_add_del_locator_set (vat_main_t * vam)
13583 unformat_input_t *input = vam->input;
13584 vl_api_one_add_del_locator_set_t *mp;
13586 u8 *locator_set_name = NULL;
13587 u8 locator_set_name_set = 0;
13588 vl_api_local_locator_t locator, *locators = 0;
13589 u32 sw_if_index, priority, weight;
13593 /* Parse args required to build the message */
13594 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13596 if (unformat (input, "del"))
13600 else if (unformat (input, "locator-set %s", &locator_set_name))
13602 locator_set_name_set = 1;
13604 else if (unformat (input, "sw_if_index %u p %u w %u",
13605 &sw_if_index, &priority, &weight))
13607 locator.sw_if_index = htonl (sw_if_index);
13608 locator.priority = priority;
13609 locator.weight = weight;
13610 vec_add1 (locators, locator);
13614 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13615 &sw_if_index, &priority, &weight))
13617 locator.sw_if_index = htonl (sw_if_index);
13618 locator.priority = priority;
13619 locator.weight = weight;
13620 vec_add1 (locators, locator);
13626 if (locator_set_name_set == 0)
13628 errmsg ("missing locator-set name");
13629 vec_free (locators);
13633 if (vec_len (locator_set_name) > 64)
13635 errmsg ("locator-set name too long");
13636 vec_free (locator_set_name);
13637 vec_free (locators);
13640 vec_add1 (locator_set_name, 0);
13642 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13644 /* Construct the API message */
13645 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
13647 mp->is_add = is_add;
13648 clib_memcpy (mp->locator_set_name, locator_set_name,
13649 vec_len (locator_set_name));
13650 vec_free (locator_set_name);
13652 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13654 clib_memcpy (mp->locators, locators, data_len);
13655 vec_free (locators);
13660 /* Wait for a reply... */
13665 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
13668 api_one_add_del_locator (vat_main_t * vam)
13670 unformat_input_t *input = vam->input;
13671 vl_api_one_add_del_locator_t *mp;
13672 u32 tmp_if_index = ~0;
13673 u32 sw_if_index = ~0;
13674 u8 sw_if_index_set = 0;
13675 u8 sw_if_index_if_name_set = 0;
13677 u8 priority_set = 0;
13681 u8 *locator_set_name = NULL;
13682 u8 locator_set_name_set = 0;
13685 /* Parse args required to build the message */
13686 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13688 if (unformat (input, "del"))
13692 else if (unformat (input, "locator-set %s", &locator_set_name))
13694 locator_set_name_set = 1;
13696 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13699 sw_if_index_if_name_set = 1;
13700 sw_if_index = tmp_if_index;
13702 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13704 sw_if_index_set = 1;
13705 sw_if_index = tmp_if_index;
13707 else if (unformat (input, "p %d", &priority))
13711 else if (unformat (input, "w %d", &weight))
13719 if (locator_set_name_set == 0)
13721 errmsg ("missing locator-set name");
13725 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13727 errmsg ("missing sw_if_index");
13728 vec_free (locator_set_name);
13732 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13734 errmsg ("cannot use both params interface name and sw_if_index");
13735 vec_free (locator_set_name);
13739 if (priority_set == 0)
13741 errmsg ("missing locator-set priority");
13742 vec_free (locator_set_name);
13746 if (weight_set == 0)
13748 errmsg ("missing locator-set weight");
13749 vec_free (locator_set_name);
13753 if (vec_len (locator_set_name) > 64)
13755 errmsg ("locator-set name too long");
13756 vec_free (locator_set_name);
13759 vec_add1 (locator_set_name, 0);
13761 /* Construct the API message */
13762 M (ONE_ADD_DEL_LOCATOR, mp);
13764 mp->is_add = is_add;
13765 mp->sw_if_index = ntohl (sw_if_index);
13766 mp->priority = priority;
13767 mp->weight = weight;
13768 clib_memcpy (mp->locator_set_name, locator_set_name,
13769 vec_len (locator_set_name));
13770 vec_free (locator_set_name);
13775 /* Wait for a reply... */
13780 #define api_lisp_add_del_locator api_one_add_del_locator
13783 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13785 u32 *key_id = va_arg (*args, u32 *);
13788 if (unformat (input, "%s", &s))
13790 if (!strcmp ((char *) s, "sha1"))
13791 key_id[0] = HMAC_SHA_1_96;
13792 else if (!strcmp ((char *) s, "sha256"))
13793 key_id[0] = HMAC_SHA_256_128;
13796 clib_warning ("invalid key_id: '%s'", s);
13797 key_id[0] = HMAC_NO_KEY;
13808 api_one_add_del_local_eid (vat_main_t * vam)
13810 unformat_input_t *input = vam->input;
13811 vl_api_one_add_del_local_eid_t *mp;
13814 lisp_eid_vat_t _eid, *eid = &_eid;
13815 u8 *locator_set_name = 0;
13816 u8 locator_set_name_set = 0;
13822 /* Parse args required to build the message */
13823 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13825 if (unformat (input, "del"))
13829 else if (unformat (input, "vni %d", &vni))
13833 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13837 else if (unformat (input, "locator-set %s", &locator_set_name))
13839 locator_set_name_set = 1;
13841 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13843 else if (unformat (input, "secret-key %_%v%_", &key))
13849 if (locator_set_name_set == 0)
13851 errmsg ("missing locator-set name");
13857 errmsg ("EID address not set!");
13858 vec_free (locator_set_name);
13862 if (key && (0 == key_id))
13864 errmsg ("invalid key_id!");
13868 if (vec_len (key) > 64)
13870 errmsg ("key too long");
13875 if (vec_len (locator_set_name) > 64)
13877 errmsg ("locator-set name too long");
13878 vec_free (locator_set_name);
13881 vec_add1 (locator_set_name, 0);
13883 /* Construct the API message */
13884 M (ONE_ADD_DEL_LOCAL_EID, mp);
13886 mp->is_add = is_add;
13887 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13888 mp->eid_type = eid->type;
13889 mp->prefix_len = eid->len;
13890 mp->vni = clib_host_to_net_u32 (vni);
13891 mp->key_id = clib_host_to_net_u16 (key_id);
13892 clib_memcpy (mp->locator_set_name, locator_set_name,
13893 vec_len (locator_set_name));
13894 clib_memcpy (mp->key, key, vec_len (key));
13896 vec_free (locator_set_name);
13902 /* Wait for a reply... */
13907 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
13910 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13912 u32 dp_table = 0, vni = 0;;
13913 unformat_input_t *input = vam->input;
13914 vl_api_gpe_add_del_fwd_entry_t *mp;
13916 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13917 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13918 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13919 u32 action = ~0, w;
13920 ip4_address_t rmt_rloc4, lcl_rloc4;
13921 ip6_address_t rmt_rloc6, lcl_rloc6;
13922 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13925 memset (&rloc, 0, sizeof (rloc));
13927 /* Parse args required to build the message */
13928 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13930 if (unformat (input, "del"))
13932 else if (unformat (input, "add"))
13934 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13938 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13942 else if (unformat (input, "vrf %d", &dp_table))
13944 else if (unformat (input, "bd %d", &dp_table))
13946 else if (unformat (input, "vni %d", &vni))
13948 else if (unformat (input, "w %d", &w))
13952 errmsg ("No RLOC configured for setting priority/weight!");
13955 curr_rloc->weight = w;
13957 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13958 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13962 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13964 vec_add1 (lcl_locs, rloc);
13966 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13967 vec_add1 (rmt_locs, rloc);
13968 /* weight saved in rmt loc */
13969 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13971 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13972 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13975 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13977 vec_add1 (lcl_locs, rloc);
13979 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13980 vec_add1 (rmt_locs, rloc);
13981 /* weight saved in rmt loc */
13982 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13984 else if (unformat (input, "action %d", &action))
13990 clib_warning ("parse error '%U'", format_unformat_error, input);
13997 errmsg ("remote eid addresses not set");
14001 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14003 errmsg ("eid types don't match");
14007 if (0 == rmt_locs && (u32) ~ 0 == action)
14009 errmsg ("action not set for negative mapping");
14013 /* Construct the API message */
14014 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14015 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14017 mp->is_add = is_add;
14018 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14019 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14020 mp->eid_type = rmt_eid->type;
14021 mp->dp_table = clib_host_to_net_u32 (dp_table);
14022 mp->vni = clib_host_to_net_u32 (vni);
14023 mp->rmt_len = rmt_eid->len;
14024 mp->lcl_len = lcl_eid->len;
14025 mp->action = action;
14027 if (0 != rmt_locs && 0 != lcl_locs)
14029 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14030 clib_memcpy (mp->locs, lcl_locs,
14031 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14033 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14034 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14035 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14037 vec_free (lcl_locs);
14038 vec_free (rmt_locs);
14043 /* Wait for a reply... */
14049 api_one_add_del_map_server (vat_main_t * vam)
14051 unformat_input_t *input = vam->input;
14052 vl_api_one_add_del_map_server_t *mp;
14056 ip4_address_t ipv4;
14057 ip6_address_t ipv6;
14060 /* Parse args required to build the message */
14061 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14063 if (unformat (input, "del"))
14067 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14071 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14079 if (ipv4_set && ipv6_set)
14081 errmsg ("both eid v4 and v6 addresses set");
14085 if (!ipv4_set && !ipv6_set)
14087 errmsg ("eid addresses not set");
14091 /* Construct the API message */
14092 M (ONE_ADD_DEL_MAP_SERVER, mp);
14094 mp->is_add = is_add;
14098 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14103 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14109 /* Wait for a reply... */
14114 #define api_lisp_add_del_map_server api_one_add_del_map_server
14117 api_one_add_del_map_resolver (vat_main_t * vam)
14119 unformat_input_t *input = vam->input;
14120 vl_api_one_add_del_map_resolver_t *mp;
14124 ip4_address_t ipv4;
14125 ip6_address_t ipv6;
14128 /* Parse args required to build the message */
14129 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14131 if (unformat (input, "del"))
14135 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14139 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14147 if (ipv4_set && ipv6_set)
14149 errmsg ("both eid v4 and v6 addresses set");
14153 if (!ipv4_set && !ipv6_set)
14155 errmsg ("eid addresses not set");
14159 /* Construct the API message */
14160 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14162 mp->is_add = is_add;
14166 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14171 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14177 /* Wait for a reply... */
14182 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14185 api_lisp_gpe_enable_disable (vat_main_t * vam)
14187 unformat_input_t *input = vam->input;
14188 vl_api_gpe_enable_disable_t *mp;
14193 /* Parse args required to build the message */
14194 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14196 if (unformat (input, "enable"))
14201 else if (unformat (input, "disable"))
14212 errmsg ("Value not set");
14216 /* Construct the API message */
14217 M (GPE_ENABLE_DISABLE, mp);
14224 /* Wait for a reply... */
14230 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14232 unformat_input_t *input = vam->input;
14233 vl_api_one_rloc_probe_enable_disable_t *mp;
14238 /* Parse args required to build the message */
14239 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14241 if (unformat (input, "enable"))
14246 else if (unformat (input, "disable"))
14254 errmsg ("Value not set");
14258 /* Construct the API message */
14259 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14261 mp->is_enabled = is_en;
14266 /* Wait for a reply... */
14271 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14274 api_one_map_register_enable_disable (vat_main_t * vam)
14276 unformat_input_t *input = vam->input;
14277 vl_api_one_map_register_enable_disable_t *mp;
14282 /* Parse args required to build the message */
14283 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14285 if (unformat (input, "enable"))
14290 else if (unformat (input, "disable"))
14298 errmsg ("Value not set");
14302 /* Construct the API message */
14303 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14305 mp->is_enabled = is_en;
14310 /* Wait for a reply... */
14315 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14318 api_one_enable_disable (vat_main_t * vam)
14320 unformat_input_t *input = vam->input;
14321 vl_api_one_enable_disable_t *mp;
14326 /* Parse args required to build the message */
14327 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14329 if (unformat (input, "enable"))
14334 else if (unformat (input, "disable"))
14344 errmsg ("Value not set");
14348 /* Construct the API message */
14349 M (ONE_ENABLE_DISABLE, mp);
14356 /* Wait for a reply... */
14361 #define api_lisp_enable_disable api_one_enable_disable
14364 api_show_one_map_register_state (vat_main_t * vam)
14366 vl_api_show_one_map_register_state_t *mp;
14369 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14374 /* wait for reply */
14379 #define api_show_lisp_map_register_state api_show_one_map_register_state
14382 api_show_one_rloc_probe_state (vat_main_t * vam)
14384 vl_api_show_one_rloc_probe_state_t *mp;
14387 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14392 /* wait for reply */
14397 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14400 api_one_stats_enable_disable (vat_main_t * vam)
14402 vl_api_one_stats_enable_disable_t *mp;
14403 unformat_input_t *input = vam->input;
14408 /* Parse args required to build the message */
14409 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14411 if (unformat (input, "enable"))
14416 else if (unformat (input, "disable"))
14426 errmsg ("Value not set");
14430 M (ONE_STATS_ENABLE_DISABLE, mp);
14436 /* wait for reply */
14442 api_show_one_stats_enable_disable (vat_main_t * vam)
14444 vl_api_show_one_stats_enable_disable_t *mp;
14447 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
14452 /* wait for reply */
14458 api_show_one_map_request_mode (vat_main_t * vam)
14460 vl_api_show_one_map_request_mode_t *mp;
14463 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
14468 /* wait for reply */
14473 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
14476 api_one_map_request_mode (vat_main_t * vam)
14478 unformat_input_t *input = vam->input;
14479 vl_api_one_map_request_mode_t *mp;
14483 /* Parse args required to build the message */
14484 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14486 if (unformat (input, "dst-only"))
14488 else if (unformat (input, "src-dst"))
14492 errmsg ("parse error '%U'", format_unformat_error, input);
14497 M (ONE_MAP_REQUEST_MODE, mp);
14504 /* wait for reply */
14509 #define api_lisp_map_request_mode api_one_map_request_mode
14512 * Enable/disable ONE proxy ITR.
14514 * @param vam vpp API test context
14515 * @return return code
14518 api_one_pitr_set_locator_set (vat_main_t * vam)
14520 u8 ls_name_set = 0;
14521 unformat_input_t *input = vam->input;
14522 vl_api_one_pitr_set_locator_set_t *mp;
14527 /* Parse args required to build the message */
14528 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14530 if (unformat (input, "del"))
14532 else if (unformat (input, "locator-set %s", &ls_name))
14536 errmsg ("parse error '%U'", format_unformat_error, input);
14543 errmsg ("locator-set name not set!");
14547 M (ONE_PITR_SET_LOCATOR_SET, mp);
14549 mp->is_add = is_add;
14550 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14551 vec_free (ls_name);
14556 /* wait for reply */
14561 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
14564 api_show_one_pitr (vat_main_t * vam)
14566 vl_api_show_one_pitr_t *mp;
14569 if (!vam->json_output)
14571 print (vam->ofp, "%=20s", "lisp status:");
14574 M (SHOW_ONE_PITR, mp);
14578 /* Wait for a reply... */
14583 #define api_show_lisp_pitr api_show_one_pitr
14586 api_one_use_petr (vat_main_t * vam)
14588 unformat_input_t *input = vam->input;
14589 vl_api_one_use_petr_t *mp;
14594 memset (&ip, 0, sizeof (ip));
14596 /* Parse args required to build the message */
14597 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14599 if (unformat (input, "disable"))
14602 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
14605 ip_addr_version (&ip) = IP4;
14608 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
14611 ip_addr_version (&ip) = IP6;
14615 errmsg ("parse error '%U'", format_unformat_error, input);
14620 M (ONE_USE_PETR, mp);
14622 mp->is_add = is_add;
14625 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
14627 clib_memcpy (mp->address, &ip, 4);
14629 clib_memcpy (mp->address, &ip, 16);
14635 /* wait for reply */
14640 #define api_lisp_use_petr api_one_use_petr
14643 api_show_one_use_petr (vat_main_t * vam)
14645 vl_api_show_one_use_petr_t *mp;
14648 if (!vam->json_output)
14650 print (vam->ofp, "%=20s", "Proxy-ETR status:");
14653 M (SHOW_ONE_USE_PETR, mp);
14657 /* Wait for a reply... */
14662 #define api_show_lisp_use_petr api_show_one_use_petr
14665 * Add/delete mapping between vni and vrf
14668 api_one_eid_table_add_del_map (vat_main_t * vam)
14670 unformat_input_t *input = vam->input;
14671 vl_api_one_eid_table_add_del_map_t *mp;
14672 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
14673 u32 vni, vrf, bd_index;
14676 /* Parse args required to build the message */
14677 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14679 if (unformat (input, "del"))
14681 else if (unformat (input, "vrf %d", &vrf))
14683 else if (unformat (input, "bd_index %d", &bd_index))
14685 else if (unformat (input, "vni %d", &vni))
14691 if (!vni_set || (!vrf_set && !bd_index_set))
14693 errmsg ("missing arguments!");
14697 if (vrf_set && bd_index_set)
14699 errmsg ("error: both vrf and bd entered!");
14703 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
14705 mp->is_add = is_add;
14706 mp->vni = htonl (vni);
14707 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
14708 mp->is_l2 = bd_index_set;
14713 /* wait for reply */
14718 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
14721 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
14723 u32 *action = va_arg (*args, u32 *);
14726 if (unformat (input, "%s", &s))
14728 if (!strcmp ((char *) s, "no-action"))
14730 else if (!strcmp ((char *) s, "natively-forward"))
14732 else if (!strcmp ((char *) s, "send-map-request"))
14734 else if (!strcmp ((char *) s, "drop"))
14738 clib_warning ("invalid action: '%s'", s);
14750 * Add/del remote mapping to/from ONE control plane
14752 * @param vam vpp API test context
14753 * @return return code
14756 api_one_add_del_remote_mapping (vat_main_t * vam)
14758 unformat_input_t *input = vam->input;
14759 vl_api_one_add_del_remote_mapping_t *mp;
14761 lisp_eid_vat_t _eid, *eid = &_eid;
14762 lisp_eid_vat_t _seid, *seid = &_seid;
14763 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
14764 u32 action = ~0, p, w, data_len;
14765 ip4_address_t rloc4;
14766 ip6_address_t rloc6;
14767 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
14770 memset (&rloc, 0, sizeof (rloc));
14772 /* Parse args required to build the message */
14773 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14775 if (unformat (input, "del-all"))
14779 else if (unformat (input, "del"))
14783 else if (unformat (input, "add"))
14787 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14791 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14795 else if (unformat (input, "vni %d", &vni))
14799 else if (unformat (input, "p %d w %d", &p, &w))
14803 errmsg ("No RLOC configured for setting priority/weight!");
14806 curr_rloc->priority = p;
14807 curr_rloc->weight = w;
14809 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14812 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14813 vec_add1 (rlocs, rloc);
14814 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14816 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14819 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14820 vec_add1 (rlocs, rloc);
14821 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14823 else if (unformat (input, "action %U",
14824 unformat_negative_mapping_action, &action))
14830 clib_warning ("parse error '%U'", format_unformat_error, input);
14837 errmsg ("missing params!");
14841 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14843 errmsg ("no action set for negative map-reply!");
14847 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
14849 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
14850 mp->is_add = is_add;
14851 mp->vni = htonl (vni);
14852 mp->action = (u8) action;
14853 mp->is_src_dst = seid_set;
14854 mp->eid_len = eid->len;
14855 mp->seid_len = seid->len;
14856 mp->del_all = del_all;
14857 mp->eid_type = eid->type;
14858 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14859 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14861 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14862 clib_memcpy (mp->rlocs, rlocs, data_len);
14868 /* Wait for a reply... */
14873 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
14876 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
14877 * forwarding entries in data-plane accordingly.
14879 * @param vam vpp API test context
14880 * @return return code
14883 api_one_add_del_adjacency (vat_main_t * vam)
14885 unformat_input_t *input = vam->input;
14886 vl_api_one_add_del_adjacency_t *mp;
14888 ip4_address_t leid4, reid4;
14889 ip6_address_t leid6, reid6;
14890 u8 reid_mac[6] = { 0 };
14891 u8 leid_mac[6] = { 0 };
14892 u8 reid_type, leid_type;
14893 u32 leid_len = 0, reid_len = 0, len;
14897 leid_type = reid_type = (u8) ~ 0;
14899 /* Parse args required to build the message */
14900 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14902 if (unformat (input, "del"))
14906 else if (unformat (input, "add"))
14910 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14913 reid_type = 0; /* ipv4 */
14916 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14919 reid_type = 1; /* ipv6 */
14922 else if (unformat (input, "reid %U", unformat_ethernet_address,
14925 reid_type = 2; /* mac */
14927 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14930 leid_type = 0; /* ipv4 */
14933 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14936 leid_type = 1; /* ipv6 */
14939 else if (unformat (input, "leid %U", unformat_ethernet_address,
14942 leid_type = 2; /* mac */
14944 else if (unformat (input, "vni %d", &vni))
14950 errmsg ("parse error '%U'", format_unformat_error, input);
14955 if ((u8) ~ 0 == reid_type)
14957 errmsg ("missing params!");
14961 if (leid_type != reid_type)
14963 errmsg ("remote and local EIDs are of different types!");
14967 M (ONE_ADD_DEL_ADJACENCY, mp);
14968 mp->is_add = is_add;
14969 mp->vni = htonl (vni);
14970 mp->leid_len = leid_len;
14971 mp->reid_len = reid_len;
14972 mp->eid_type = reid_type;
14974 switch (mp->eid_type)
14977 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14978 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14981 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14982 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14985 clib_memcpy (mp->leid, leid_mac, 6);
14986 clib_memcpy (mp->reid, reid_mac, 6);
14989 errmsg ("unknown EID type %d!", mp->eid_type);
14996 /* Wait for a reply... */
15001 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
15004 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
15006 u32 *mode = va_arg (*args, u32 *);
15008 if (unformat (input, "lisp"))
15010 else if (unformat (input, "vxlan"))
15019 api_gpe_get_encap_mode (vat_main_t * vam)
15021 vl_api_gpe_get_encap_mode_t *mp;
15024 /* Construct the API message */
15025 M (GPE_GET_ENCAP_MODE, mp);
15030 /* Wait for a reply... */
15036 api_gpe_set_encap_mode (vat_main_t * vam)
15038 unformat_input_t *input = vam->input;
15039 vl_api_gpe_set_encap_mode_t *mp;
15043 /* Parse args required to build the message */
15044 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15046 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
15052 /* Construct the API message */
15053 M (GPE_SET_ENCAP_MODE, mp);
15060 /* Wait for a reply... */
15066 api_lisp_gpe_add_del_iface (vat_main_t * vam)
15068 unformat_input_t *input = vam->input;
15069 vl_api_gpe_add_del_iface_t *mp;
15070 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
15071 u32 dp_table = 0, vni = 0;
15074 /* Parse args required to build the message */
15075 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15077 if (unformat (input, "up"))
15082 else if (unformat (input, "down"))
15087 else if (unformat (input, "table_id %d", &dp_table))
15091 else if (unformat (input, "bd_id %d", &dp_table))
15096 else if (unformat (input, "vni %d", &vni))
15104 if (action_set == 0)
15106 errmsg ("Action not set");
15109 if (dp_table_set == 0 || vni_set == 0)
15111 errmsg ("vni and dp_table must be set");
15115 /* Construct the API message */
15116 M (GPE_ADD_DEL_IFACE, mp);
15118 mp->is_add = is_add;
15119 mp->dp_table = dp_table;
15126 /* Wait for a reply... */
15132 * Add/del map request itr rlocs from ONE control plane and updates
15134 * @param vam vpp API test context
15135 * @return return code
15138 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
15140 unformat_input_t *input = vam->input;
15141 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
15142 u8 *locator_set_name = 0;
15143 u8 locator_set_name_set = 0;
15147 /* Parse args required to build the message */
15148 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15150 if (unformat (input, "del"))
15154 else if (unformat (input, "%_%v%_", &locator_set_name))
15156 locator_set_name_set = 1;
15160 clib_warning ("parse error '%U'", format_unformat_error, input);
15165 if (is_add && !locator_set_name_set)
15167 errmsg ("itr-rloc is not set!");
15171 if (is_add && vec_len (locator_set_name) > 64)
15173 errmsg ("itr-rloc locator-set name too long");
15174 vec_free (locator_set_name);
15178 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
15179 mp->is_add = is_add;
15182 clib_memcpy (mp->locator_set_name, locator_set_name,
15183 vec_len (locator_set_name));
15187 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
15189 vec_free (locator_set_name);
15194 /* Wait for a reply... */
15199 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
15202 api_one_locator_dump (vat_main_t * vam)
15204 unformat_input_t *input = vam->input;
15205 vl_api_one_locator_dump_t *mp;
15206 vl_api_control_ping_t *mp_ping;
15207 u8 is_index_set = 0, is_name_set = 0;
15212 /* Parse args required to build the message */
15213 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15215 if (unformat (input, "ls_name %_%v%_", &ls_name))
15219 else if (unformat (input, "ls_index %d", &ls_index))
15225 errmsg ("parse error '%U'", format_unformat_error, input);
15230 if (!is_index_set && !is_name_set)
15232 errmsg ("error: expected one of index or name!");
15236 if (is_index_set && is_name_set)
15238 errmsg ("error: only one param expected!");
15242 if (vec_len (ls_name) > 62)
15244 errmsg ("error: locator set name too long!");
15248 if (!vam->json_output)
15250 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
15253 M (ONE_LOCATOR_DUMP, mp);
15254 mp->is_index_set = is_index_set;
15257 mp->ls_index = clib_host_to_net_u32 (ls_index);
15260 vec_add1 (ls_name, 0);
15261 strncpy ((char *) mp->ls_name, (char *) ls_name,
15262 sizeof (mp->ls_name) - 1);
15268 /* Use a control ping for synchronization */
15269 M (CONTROL_PING, mp_ping);
15272 /* Wait for a reply... */
15277 #define api_lisp_locator_dump api_one_locator_dump
15280 api_one_locator_set_dump (vat_main_t * vam)
15282 vl_api_one_locator_set_dump_t *mp;
15283 vl_api_control_ping_t *mp_ping;
15284 unformat_input_t *input = vam->input;
15288 /* Parse args required to build the message */
15289 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15291 if (unformat (input, "local"))
15295 else if (unformat (input, "remote"))
15301 errmsg ("parse error '%U'", format_unformat_error, input);
15306 if (!vam->json_output)
15308 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
15311 M (ONE_LOCATOR_SET_DUMP, mp);
15313 mp->filter = filter;
15318 /* Use a control ping for synchronization */
15319 M (CONTROL_PING, mp_ping);
15322 /* Wait for a reply... */
15327 #define api_lisp_locator_set_dump api_one_locator_set_dump
15330 api_one_eid_table_map_dump (vat_main_t * vam)
15334 unformat_input_t *input = vam->input;
15335 vl_api_one_eid_table_map_dump_t *mp;
15336 vl_api_control_ping_t *mp_ping;
15339 /* Parse args required to build the message */
15340 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15342 if (unformat (input, "l2"))
15347 else if (unformat (input, "l3"))
15354 errmsg ("parse error '%U'", format_unformat_error, input);
15361 errmsg ("expected one of 'l2' or 'l3' parameter!");
15365 if (!vam->json_output)
15367 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
15370 M (ONE_EID_TABLE_MAP_DUMP, mp);
15376 /* Use a control ping for synchronization */
15377 M (CONTROL_PING, mp_ping);
15380 /* Wait for a reply... */
15385 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
15388 api_one_eid_table_vni_dump (vat_main_t * vam)
15390 vl_api_one_eid_table_vni_dump_t *mp;
15391 vl_api_control_ping_t *mp_ping;
15394 if (!vam->json_output)
15396 print (vam->ofp, "VNI");
15399 M (ONE_EID_TABLE_VNI_DUMP, mp);
15404 /* Use a control ping for synchronization */
15405 M (CONTROL_PING, mp_ping);
15408 /* Wait for a reply... */
15413 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
15416 api_one_eid_table_dump (vat_main_t * vam)
15418 unformat_input_t *i = vam->input;
15419 vl_api_one_eid_table_dump_t *mp;
15420 vl_api_control_ping_t *mp_ping;
15421 struct in_addr ip4;
15422 struct in6_addr ip6;
15424 u8 eid_type = ~0, eid_set = 0;
15425 u32 prefix_length = ~0, t, vni = 0;
15429 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15431 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
15437 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
15443 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
15448 else if (unformat (i, "vni %d", &t))
15452 else if (unformat (i, "local"))
15456 else if (unformat (i, "remote"))
15462 errmsg ("parse error '%U'", format_unformat_error, i);
15467 if (!vam->json_output)
15469 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
15470 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
15473 M (ONE_EID_TABLE_DUMP, mp);
15475 mp->filter = filter;
15479 mp->vni = htonl (vni);
15480 mp->eid_type = eid_type;
15484 mp->prefix_length = prefix_length;
15485 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
15488 mp->prefix_length = prefix_length;
15489 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
15492 clib_memcpy (mp->eid, mac, sizeof (mac));
15495 errmsg ("unknown EID type %d!", eid_type);
15503 /* Use a control ping for synchronization */
15504 M (CONTROL_PING, mp_ping);
15507 /* Wait for a reply... */
15512 #define api_lisp_eid_table_dump api_one_eid_table_dump
15515 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
15517 unformat_input_t *i = vam->input;
15518 vl_api_gpe_fwd_entries_get_t *mp;
15523 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15525 if (unformat (i, "vni %d", &vni))
15531 errmsg ("parse error '%U'", format_unformat_error, i);
15538 errmsg ("vni not set!");
15542 if (!vam->json_output)
15544 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15548 M (GPE_FWD_ENTRIES_GET, mp);
15549 mp->vni = clib_host_to_net_u32 (vni);
15554 /* Wait for a reply... */
15559 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15560 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15561 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15562 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
15565 api_one_adjacencies_get (vat_main_t * vam)
15567 unformat_input_t *i = vam->input;
15568 vl_api_one_adjacencies_get_t *mp;
15573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15575 if (unformat (i, "vni %d", &vni))
15581 errmsg ("parse error '%U'", format_unformat_error, i);
15588 errmsg ("vni not set!");
15592 if (!vam->json_output)
15594 print (vam->ofp, "%s %40s", "leid", "reid");
15597 M (ONE_ADJACENCIES_GET, mp);
15598 mp->vni = clib_host_to_net_u32 (vni);
15603 /* Wait for a reply... */
15608 #define api_lisp_adjacencies_get api_one_adjacencies_get
15611 api_one_map_server_dump (vat_main_t * vam)
15613 vl_api_one_map_server_dump_t *mp;
15614 vl_api_control_ping_t *mp_ping;
15617 if (!vam->json_output)
15619 print (vam->ofp, "%=20s", "Map server");
15622 M (ONE_MAP_SERVER_DUMP, mp);
15626 /* Use a control ping for synchronization */
15627 M (CONTROL_PING, mp_ping);
15630 /* Wait for a reply... */
15635 #define api_lisp_map_server_dump api_one_map_server_dump
15638 api_one_map_resolver_dump (vat_main_t * vam)
15640 vl_api_one_map_resolver_dump_t *mp;
15641 vl_api_control_ping_t *mp_ping;
15644 if (!vam->json_output)
15646 print (vam->ofp, "%=20s", "Map resolver");
15649 M (ONE_MAP_RESOLVER_DUMP, mp);
15653 /* Use a control ping for synchronization */
15654 M (CONTROL_PING, mp_ping);
15657 /* Wait for a reply... */
15662 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
15665 api_one_stats_dump (vat_main_t * vam)
15667 vl_api_one_stats_dump_t *mp;
15668 vl_api_control_ping_t *mp_ping;
15671 M (ONE_STATS_DUMP, mp);
15675 /* Use a control ping for synchronization */
15676 M (CONTROL_PING, mp_ping);
15679 /* Wait for a reply... */
15685 api_show_one_status (vat_main_t * vam)
15687 vl_api_show_one_status_t *mp;
15690 if (!vam->json_output)
15692 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
15695 M (SHOW_ONE_STATUS, mp);
15698 /* Wait for a reply... */
15703 #define api_show_lisp_status api_show_one_status
15706 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
15708 vl_api_gpe_fwd_entry_path_dump_t *mp;
15709 vl_api_control_ping_t *mp_ping;
15710 unformat_input_t *i = vam->input;
15711 u32 fwd_entry_index = ~0;
15714 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15716 if (unformat (i, "index %d", &fwd_entry_index))
15722 if (~0 == fwd_entry_index)
15724 errmsg ("no index specified!");
15728 if (!vam->json_output)
15730 print (vam->ofp, "first line");
15733 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
15737 /* Use a control ping for synchronization */
15738 M (CONTROL_PING, mp_ping);
15741 /* Wait for a reply... */
15747 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
15749 vl_api_one_get_map_request_itr_rlocs_t *mp;
15752 if (!vam->json_output)
15754 print (vam->ofp, "%=20s", "itr-rlocs:");
15757 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
15760 /* Wait for a reply... */
15765 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
15768 api_af_packet_create (vat_main_t * vam)
15770 unformat_input_t *i = vam->input;
15771 vl_api_af_packet_create_t *mp;
15772 u8 *host_if_name = 0;
15774 u8 random_hw_addr = 1;
15777 memset (hw_addr, 0, sizeof (hw_addr));
15779 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15781 if (unformat (i, "name %s", &host_if_name))
15782 vec_add1 (host_if_name, 0);
15783 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15784 random_hw_addr = 0;
15789 if (!vec_len (host_if_name))
15791 errmsg ("host-interface name must be specified");
15795 if (vec_len (host_if_name) > 64)
15797 errmsg ("host-interface name too long");
15801 M (AF_PACKET_CREATE, mp);
15803 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15804 clib_memcpy (mp->hw_addr, hw_addr, 6);
15805 mp->use_random_hw_addr = random_hw_addr;
15806 vec_free (host_if_name);
15814 fprintf (vam->ofp ? vam->ofp : stderr,
15815 " new sw_if_index = %d\n", vam->sw_if_index);
15822 api_af_packet_delete (vat_main_t * vam)
15824 unformat_input_t *i = vam->input;
15825 vl_api_af_packet_delete_t *mp;
15826 u8 *host_if_name = 0;
15829 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15831 if (unformat (i, "name %s", &host_if_name))
15832 vec_add1 (host_if_name, 0);
15837 if (!vec_len (host_if_name))
15839 errmsg ("host-interface name must be specified");
15843 if (vec_len (host_if_name) > 64)
15845 errmsg ("host-interface name too long");
15849 M (AF_PACKET_DELETE, mp);
15851 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15852 vec_free (host_if_name);
15860 api_policer_add_del (vat_main_t * vam)
15862 unformat_input_t *i = vam->input;
15863 vl_api_policer_add_del_t *mp;
15873 u8 color_aware = 0;
15874 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
15877 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
15878 conform_action.dscp = 0;
15879 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
15880 exceed_action.dscp = 0;
15881 violate_action.action_type = SSE2_QOS_ACTION_DROP;
15882 violate_action.dscp = 0;
15884 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15886 if (unformat (i, "del"))
15888 else if (unformat (i, "name %s", &name))
15889 vec_add1 (name, 0);
15890 else if (unformat (i, "cir %u", &cir))
15892 else if (unformat (i, "eir %u", &eir))
15894 else if (unformat (i, "cb %u", &cb))
15896 else if (unformat (i, "eb %u", &eb))
15898 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
15901 else if (unformat (i, "round_type %U", unformat_policer_round_type,
15904 else if (unformat (i, "type %U", unformat_policer_type, &type))
15906 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
15909 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
15912 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
15915 else if (unformat (i, "color-aware"))
15921 if (!vec_len (name))
15923 errmsg ("policer name must be specified");
15927 if (vec_len (name) > 64)
15929 errmsg ("policer name too long");
15933 M (POLICER_ADD_DEL, mp);
15935 clib_memcpy (mp->name, name, vec_len (name));
15937 mp->is_add = is_add;
15942 mp->rate_type = rate_type;
15943 mp->round_type = round_type;
15945 mp->conform_action_type = conform_action.action_type;
15946 mp->conform_dscp = conform_action.dscp;
15947 mp->exceed_action_type = exceed_action.action_type;
15948 mp->exceed_dscp = exceed_action.dscp;
15949 mp->violate_action_type = violate_action.action_type;
15950 mp->violate_dscp = violate_action.dscp;
15951 mp->color_aware = color_aware;
15959 api_policer_dump (vat_main_t * vam)
15961 unformat_input_t *i = vam->input;
15962 vl_api_policer_dump_t *mp;
15963 vl_api_control_ping_t *mp_ping;
15964 u8 *match_name = 0;
15965 u8 match_name_valid = 0;
15968 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15970 if (unformat (i, "name %s", &match_name))
15972 vec_add1 (match_name, 0);
15973 match_name_valid = 1;
15979 M (POLICER_DUMP, mp);
15980 mp->match_name_valid = match_name_valid;
15981 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15982 vec_free (match_name);
15986 /* Use a control ping for synchronization */
15987 M (CONTROL_PING, mp_ping);
15990 /* Wait for a reply... */
15996 api_policer_classify_set_interface (vat_main_t * vam)
15998 unformat_input_t *i = vam->input;
15999 vl_api_policer_classify_set_interface_t *mp;
16001 int sw_if_index_set;
16002 u32 ip4_table_index = ~0;
16003 u32 ip6_table_index = ~0;
16004 u32 l2_table_index = ~0;
16008 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16010 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16011 sw_if_index_set = 1;
16012 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16013 sw_if_index_set = 1;
16014 else if (unformat (i, "del"))
16016 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16018 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16020 else if (unformat (i, "l2-table %d", &l2_table_index))
16024 clib_warning ("parse error '%U'", format_unformat_error, i);
16029 if (sw_if_index_set == 0)
16031 errmsg ("missing interface name or sw_if_index");
16035 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
16037 mp->sw_if_index = ntohl (sw_if_index);
16038 mp->ip4_table_index = ntohl (ip4_table_index);
16039 mp->ip6_table_index = ntohl (ip6_table_index);
16040 mp->l2_table_index = ntohl (l2_table_index);
16041 mp->is_add = is_add;
16049 api_policer_classify_dump (vat_main_t * vam)
16051 unformat_input_t *i = vam->input;
16052 vl_api_policer_classify_dump_t *mp;
16053 vl_api_control_ping_t *mp_ping;
16054 u8 type = POLICER_CLASSIFY_N_TABLES;
16057 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
16061 errmsg ("classify table type must be specified");
16065 if (!vam->json_output)
16067 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
16070 M (POLICER_CLASSIFY_DUMP, mp);
16075 /* Use a control ping for synchronization */
16076 M (CONTROL_PING, mp_ping);
16079 /* Wait for a reply... */
16085 api_netmap_create (vat_main_t * vam)
16087 unformat_input_t *i = vam->input;
16088 vl_api_netmap_create_t *mp;
16091 u8 random_hw_addr = 1;
16096 memset (hw_addr, 0, sizeof (hw_addr));
16098 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16100 if (unformat (i, "name %s", &if_name))
16101 vec_add1 (if_name, 0);
16102 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
16103 random_hw_addr = 0;
16104 else if (unformat (i, "pipe"))
16106 else if (unformat (i, "master"))
16108 else if (unformat (i, "slave"))
16114 if (!vec_len (if_name))
16116 errmsg ("interface name must be specified");
16120 if (vec_len (if_name) > 64)
16122 errmsg ("interface name too long");
16126 M (NETMAP_CREATE, mp);
16128 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16129 clib_memcpy (mp->hw_addr, hw_addr, 6);
16130 mp->use_random_hw_addr = random_hw_addr;
16131 mp->is_pipe = is_pipe;
16132 mp->is_master = is_master;
16133 vec_free (if_name);
16141 api_netmap_delete (vat_main_t * vam)
16143 unformat_input_t *i = vam->input;
16144 vl_api_netmap_delete_t *mp;
16148 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16150 if (unformat (i, "name %s", &if_name))
16151 vec_add1 (if_name, 0);
16156 if (!vec_len (if_name))
16158 errmsg ("interface name must be specified");
16162 if (vec_len (if_name) > 64)
16164 errmsg ("interface name too long");
16168 M (NETMAP_DELETE, mp);
16170 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16171 vec_free (if_name);
16178 static void vl_api_mpls_tunnel_details_t_handler
16179 (vl_api_mpls_tunnel_details_t * mp)
16181 vat_main_t *vam = &vat_main;
16182 i32 len = mp->mt_next_hop_n_labels;
16185 print (vam->ofp, "[%d]: via %U %d labels ",
16187 format_ip4_address, mp->mt_next_hop,
16188 ntohl (mp->mt_next_hop_sw_if_index));
16189 for (i = 0; i < len; i++)
16191 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
16193 print (vam->ofp, "");
16196 static void vl_api_mpls_tunnel_details_t_handler_json
16197 (vl_api_mpls_tunnel_details_t * mp)
16199 vat_main_t *vam = &vat_main;
16200 vat_json_node_t *node = NULL;
16201 struct in_addr ip4;
16203 i32 len = mp->mt_next_hop_n_labels;
16205 if (VAT_JSON_ARRAY != vam->json_tree.type)
16207 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16208 vat_json_init_array (&vam->json_tree);
16210 node = vat_json_array_add (&vam->json_tree);
16212 vat_json_init_object (node);
16213 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
16214 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
16215 vat_json_object_add_ip4 (node, "next_hop", ip4);
16216 vat_json_object_add_uint (node, "next_hop_sw_if_index",
16217 ntohl (mp->mt_next_hop_sw_if_index));
16218 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
16219 vat_json_object_add_uint (node, "label_count", len);
16220 for (i = 0; i < len; i++)
16222 vat_json_object_add_uint (node, "label",
16223 ntohl (mp->mt_next_hop_out_labels[i]));
16228 api_mpls_tunnel_dump (vat_main_t * vam)
16230 vl_api_mpls_tunnel_dump_t *mp;
16231 vl_api_control_ping_t *mp_ping;
16235 /* Parse args required to build the message */
16236 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
16238 if (!unformat (vam->input, "tunnel_index %d", &index))
16245 print (vam->ofp, " tunnel_index %d", index);
16247 M (MPLS_TUNNEL_DUMP, mp);
16248 mp->tunnel_index = htonl (index);
16251 /* Use a control ping for synchronization */
16252 M (CONTROL_PING, mp_ping);
16259 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
16260 #define vl_api_mpls_fib_details_t_print vl_noop_handler
16263 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
16265 vat_main_t *vam = &vat_main;
16266 int count = ntohl (mp->count);
16267 vl_api_fib_path2_t *fp;
16271 "table-id %d, label %u, ess_bit %u",
16272 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
16274 for (i = 0; i < count; i++)
16276 if (fp->afi == IP46_TYPE_IP6)
16278 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16279 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16280 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16281 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16282 format_ip6_address, fp->next_hop);
16283 else if (fp->afi == IP46_TYPE_IP4)
16285 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16286 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16287 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16288 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16289 format_ip4_address, fp->next_hop);
16294 static void vl_api_mpls_fib_details_t_handler_json
16295 (vl_api_mpls_fib_details_t * mp)
16297 vat_main_t *vam = &vat_main;
16298 int count = ntohl (mp->count);
16299 vat_json_node_t *node = NULL;
16300 struct in_addr ip4;
16301 struct in6_addr ip6;
16302 vl_api_fib_path2_t *fp;
16305 if (VAT_JSON_ARRAY != vam->json_tree.type)
16307 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16308 vat_json_init_array (&vam->json_tree);
16310 node = vat_json_array_add (&vam->json_tree);
16312 vat_json_init_object (node);
16313 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16314 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
16315 vat_json_object_add_uint (node, "label", ntohl (mp->label));
16316 vat_json_object_add_uint (node, "path_count", count);
16318 for (i = 0; i < count; i++)
16320 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16321 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16322 vat_json_object_add_uint (node, "is_local", fp->is_local);
16323 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16324 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16325 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16326 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16327 if (fp->afi == IP46_TYPE_IP4)
16329 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16330 vat_json_object_add_ip4 (node, "next_hop", ip4);
16332 else if (fp->afi == IP46_TYPE_IP6)
16334 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16335 vat_json_object_add_ip6 (node, "next_hop", ip6);
16341 api_mpls_fib_dump (vat_main_t * vam)
16343 vl_api_mpls_fib_dump_t *mp;
16344 vl_api_control_ping_t *mp_ping;
16347 M (MPLS_FIB_DUMP, mp);
16350 /* Use a control ping for synchronization */
16351 M (CONTROL_PING, mp_ping);
16358 #define vl_api_ip_fib_details_t_endian vl_noop_handler
16359 #define vl_api_ip_fib_details_t_print vl_noop_handler
16362 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
16364 vat_main_t *vam = &vat_main;
16365 int count = ntohl (mp->count);
16366 vl_api_fib_path_t *fp;
16370 "table-id %d, prefix %U/%d",
16371 ntohl (mp->table_id), format_ip4_address, mp->address,
16372 mp->address_length);
16374 for (i = 0; i < count; i++)
16376 if (fp->afi == IP46_TYPE_IP6)
16378 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16379 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16380 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16381 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16382 format_ip6_address, fp->next_hop);
16383 else if (fp->afi == IP46_TYPE_IP4)
16385 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16386 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16387 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16388 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16389 format_ip4_address, fp->next_hop);
16394 static void vl_api_ip_fib_details_t_handler_json
16395 (vl_api_ip_fib_details_t * mp)
16397 vat_main_t *vam = &vat_main;
16398 int count = ntohl (mp->count);
16399 vat_json_node_t *node = NULL;
16400 struct in_addr ip4;
16401 struct in6_addr ip6;
16402 vl_api_fib_path_t *fp;
16405 if (VAT_JSON_ARRAY != vam->json_tree.type)
16407 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16408 vat_json_init_array (&vam->json_tree);
16410 node = vat_json_array_add (&vam->json_tree);
16412 vat_json_init_object (node);
16413 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16414 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
16415 vat_json_object_add_ip4 (node, "prefix", ip4);
16416 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16417 vat_json_object_add_uint (node, "path_count", count);
16419 for (i = 0; i < count; i++)
16421 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16422 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16423 vat_json_object_add_uint (node, "is_local", fp->is_local);
16424 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16425 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16426 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16427 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16428 if (fp->afi == IP46_TYPE_IP4)
16430 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16431 vat_json_object_add_ip4 (node, "next_hop", ip4);
16433 else if (fp->afi == IP46_TYPE_IP6)
16435 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16436 vat_json_object_add_ip6 (node, "next_hop", ip6);
16442 api_ip_fib_dump (vat_main_t * vam)
16444 vl_api_ip_fib_dump_t *mp;
16445 vl_api_control_ping_t *mp_ping;
16448 M (IP_FIB_DUMP, mp);
16451 /* Use a control ping for synchronization */
16452 M (CONTROL_PING, mp_ping);
16460 api_ip_mfib_dump (vat_main_t * vam)
16462 vl_api_ip_mfib_dump_t *mp;
16463 vl_api_control_ping_t *mp_ping;
16466 M (IP_MFIB_DUMP, mp);
16469 /* Use a control ping for synchronization */
16470 M (CONTROL_PING, mp_ping);
16477 static void vl_api_ip_neighbor_details_t_handler
16478 (vl_api_ip_neighbor_details_t * mp)
16480 vat_main_t *vam = &vat_main;
16482 print (vam->ofp, "%c %U %U",
16483 (mp->is_static) ? 'S' : 'D',
16484 format_ethernet_address, &mp->mac_address,
16485 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
16489 static void vl_api_ip_neighbor_details_t_handler_json
16490 (vl_api_ip_neighbor_details_t * mp)
16493 vat_main_t *vam = &vat_main;
16494 vat_json_node_t *node;
16495 struct in_addr ip4;
16496 struct in6_addr ip6;
16498 if (VAT_JSON_ARRAY != vam->json_tree.type)
16500 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16501 vat_json_init_array (&vam->json_tree);
16503 node = vat_json_array_add (&vam->json_tree);
16505 vat_json_init_object (node);
16506 vat_json_object_add_string_copy (node, "flag",
16507 (mp->is_static) ? (u8 *) "static" : (u8 *)
16510 vat_json_object_add_string_copy (node, "link_layer",
16511 format (0, "%U", format_ethernet_address,
16512 &mp->mac_address));
16516 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
16517 vat_json_object_add_ip6 (node, "ip_address", ip6);
16521 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
16522 vat_json_object_add_ip4 (node, "ip_address", ip4);
16527 api_ip_neighbor_dump (vat_main_t * vam)
16529 unformat_input_t *i = vam->input;
16530 vl_api_ip_neighbor_dump_t *mp;
16531 vl_api_control_ping_t *mp_ping;
16533 u32 sw_if_index = ~0;
16536 /* Parse args required to build the message */
16537 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16539 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16541 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16543 else if (unformat (i, "ip6"))
16549 if (sw_if_index == ~0)
16551 errmsg ("missing interface name or sw_if_index");
16555 M (IP_NEIGHBOR_DUMP, mp);
16556 mp->is_ipv6 = (u8) is_ipv6;
16557 mp->sw_if_index = ntohl (sw_if_index);
16560 /* Use a control ping for synchronization */
16561 M (CONTROL_PING, mp_ping);
16568 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
16569 #define vl_api_ip6_fib_details_t_print vl_noop_handler
16572 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
16574 vat_main_t *vam = &vat_main;
16575 int count = ntohl (mp->count);
16576 vl_api_fib_path_t *fp;
16580 "table-id %d, prefix %U/%d",
16581 ntohl (mp->table_id), format_ip6_address, mp->address,
16582 mp->address_length);
16584 for (i = 0; i < count; i++)
16586 if (fp->afi == IP46_TYPE_IP6)
16588 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16589 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16590 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16591 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16592 format_ip6_address, fp->next_hop);
16593 else if (fp->afi == IP46_TYPE_IP4)
16595 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16596 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16597 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16598 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16599 format_ip4_address, fp->next_hop);
16604 static void vl_api_ip6_fib_details_t_handler_json
16605 (vl_api_ip6_fib_details_t * mp)
16607 vat_main_t *vam = &vat_main;
16608 int count = ntohl (mp->count);
16609 vat_json_node_t *node = NULL;
16610 struct in_addr ip4;
16611 struct in6_addr ip6;
16612 vl_api_fib_path_t *fp;
16615 if (VAT_JSON_ARRAY != vam->json_tree.type)
16617 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16618 vat_json_init_array (&vam->json_tree);
16620 node = vat_json_array_add (&vam->json_tree);
16622 vat_json_init_object (node);
16623 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16624 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
16625 vat_json_object_add_ip6 (node, "prefix", ip6);
16626 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16627 vat_json_object_add_uint (node, "path_count", count);
16629 for (i = 0; i < count; i++)
16631 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16632 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16633 vat_json_object_add_uint (node, "is_local", fp->is_local);
16634 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16635 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16636 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16637 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16638 if (fp->afi == IP46_TYPE_IP4)
16640 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16641 vat_json_object_add_ip4 (node, "next_hop", ip4);
16643 else if (fp->afi == IP46_TYPE_IP6)
16645 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16646 vat_json_object_add_ip6 (node, "next_hop", ip6);
16652 api_ip6_fib_dump (vat_main_t * vam)
16654 vl_api_ip6_fib_dump_t *mp;
16655 vl_api_control_ping_t *mp_ping;
16658 M (IP6_FIB_DUMP, mp);
16661 /* Use a control ping for synchronization */
16662 M (CONTROL_PING, mp_ping);
16670 api_ip6_mfib_dump (vat_main_t * vam)
16672 vl_api_ip6_mfib_dump_t *mp;
16673 vl_api_control_ping_t *mp_ping;
16676 M (IP6_MFIB_DUMP, mp);
16679 /* Use a control ping for synchronization */
16680 M (CONTROL_PING, mp_ping);
16688 api_classify_table_ids (vat_main_t * vam)
16690 vl_api_classify_table_ids_t *mp;
16693 /* Construct the API message */
16694 M (CLASSIFY_TABLE_IDS, mp);
16703 api_classify_table_by_interface (vat_main_t * vam)
16705 unformat_input_t *input = vam->input;
16706 vl_api_classify_table_by_interface_t *mp;
16708 u32 sw_if_index = ~0;
16710 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16712 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16714 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16719 if (sw_if_index == ~0)
16721 errmsg ("missing interface name or sw_if_index");
16725 /* Construct the API message */
16726 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
16728 mp->sw_if_index = ntohl (sw_if_index);
16736 api_classify_table_info (vat_main_t * vam)
16738 unformat_input_t *input = vam->input;
16739 vl_api_classify_table_info_t *mp;
16743 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16745 if (unformat (input, "table_id %d", &table_id))
16750 if (table_id == ~0)
16752 errmsg ("missing table id");
16756 /* Construct the API message */
16757 M (CLASSIFY_TABLE_INFO, mp);
16759 mp->table_id = ntohl (table_id);
16767 api_classify_session_dump (vat_main_t * vam)
16769 unformat_input_t *input = vam->input;
16770 vl_api_classify_session_dump_t *mp;
16771 vl_api_control_ping_t *mp_ping;
16775 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16777 if (unformat (input, "table_id %d", &table_id))
16782 if (table_id == ~0)
16784 errmsg ("missing table id");
16788 /* Construct the API message */
16789 M (CLASSIFY_SESSION_DUMP, mp);
16791 mp->table_id = ntohl (table_id);
16794 /* Use a control ping for synchronization */
16795 M (CONTROL_PING, mp_ping);
16803 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
16805 vat_main_t *vam = &vat_main;
16807 print (vam->ofp, "collector_address %U, collector_port %d, "
16808 "src_address %U, vrf_id %d, path_mtu %u, "
16809 "template_interval %u, udp_checksum %d",
16810 format_ip4_address, mp->collector_address,
16811 ntohs (mp->collector_port),
16812 format_ip4_address, mp->src_address,
16813 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
16814 ntohl (mp->template_interval), mp->udp_checksum);
16817 vam->result_ready = 1;
16821 vl_api_ipfix_exporter_details_t_handler_json
16822 (vl_api_ipfix_exporter_details_t * mp)
16824 vat_main_t *vam = &vat_main;
16825 vat_json_node_t node;
16826 struct in_addr collector_address;
16827 struct in_addr src_address;
16829 vat_json_init_object (&node);
16830 clib_memcpy (&collector_address, &mp->collector_address,
16831 sizeof (collector_address));
16832 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
16833 vat_json_object_add_uint (&node, "collector_port",
16834 ntohs (mp->collector_port));
16835 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
16836 vat_json_object_add_ip4 (&node, "src_address", src_address);
16837 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
16838 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
16839 vat_json_object_add_uint (&node, "template_interval",
16840 ntohl (mp->template_interval));
16841 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
16843 vat_json_print (vam->ofp, &node);
16844 vat_json_free (&node);
16846 vam->result_ready = 1;
16850 api_ipfix_exporter_dump (vat_main_t * vam)
16852 vl_api_ipfix_exporter_dump_t *mp;
16855 /* Construct the API message */
16856 M (IPFIX_EXPORTER_DUMP, mp);
16865 api_ipfix_classify_stream_dump (vat_main_t * vam)
16867 vl_api_ipfix_classify_stream_dump_t *mp;
16870 /* Construct the API message */
16871 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
16882 vl_api_ipfix_classify_stream_details_t_handler
16883 (vl_api_ipfix_classify_stream_details_t * mp)
16885 vat_main_t *vam = &vat_main;
16886 print (vam->ofp, "domain_id %d, src_port %d",
16887 ntohl (mp->domain_id), ntohs (mp->src_port));
16889 vam->result_ready = 1;
16893 vl_api_ipfix_classify_stream_details_t_handler_json
16894 (vl_api_ipfix_classify_stream_details_t * mp)
16896 vat_main_t *vam = &vat_main;
16897 vat_json_node_t node;
16899 vat_json_init_object (&node);
16900 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
16901 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
16903 vat_json_print (vam->ofp, &node);
16904 vat_json_free (&node);
16906 vam->result_ready = 1;
16910 api_ipfix_classify_table_dump (vat_main_t * vam)
16912 vl_api_ipfix_classify_table_dump_t *mp;
16913 vl_api_control_ping_t *mp_ping;
16916 if (!vam->json_output)
16918 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
16919 "transport_protocol");
16922 /* Construct the API message */
16923 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
16928 /* Use a control ping for synchronization */
16929 M (CONTROL_PING, mp_ping);
16937 vl_api_ipfix_classify_table_details_t_handler
16938 (vl_api_ipfix_classify_table_details_t * mp)
16940 vat_main_t *vam = &vat_main;
16941 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
16942 mp->transport_protocol);
16946 vl_api_ipfix_classify_table_details_t_handler_json
16947 (vl_api_ipfix_classify_table_details_t * mp)
16949 vat_json_node_t *node = NULL;
16950 vat_main_t *vam = &vat_main;
16952 if (VAT_JSON_ARRAY != vam->json_tree.type)
16954 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16955 vat_json_init_array (&vam->json_tree);
16958 node = vat_json_array_add (&vam->json_tree);
16959 vat_json_init_object (node);
16961 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
16962 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
16963 vat_json_object_add_uint (node, "transport_protocol",
16964 mp->transport_protocol);
16968 api_sw_interface_span_enable_disable (vat_main_t * vam)
16970 unformat_input_t *i = vam->input;
16971 vl_api_sw_interface_span_enable_disable_t *mp;
16972 u32 src_sw_if_index = ~0;
16973 u32 dst_sw_if_index = ~0;
16977 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16980 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
16982 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
16986 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
16988 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16990 else if (unformat (i, "disable"))
16992 else if (unformat (i, "rx"))
16994 else if (unformat (i, "tx"))
16996 else if (unformat (i, "both"))
17002 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
17004 mp->sw_if_index_from = htonl (src_sw_if_index);
17005 mp->sw_if_index_to = htonl (dst_sw_if_index);
17014 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
17017 vat_main_t *vam = &vat_main;
17018 u8 *sw_if_from_name = 0;
17019 u8 *sw_if_to_name = 0;
17020 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17021 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17022 char *states[] = { "none", "rx", "tx", "both" };
17026 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17028 if ((u32) p->value[0] == sw_if_index_from)
17030 sw_if_from_name = (u8 *)(p->key);
17034 if ((u32) p->value[0] == sw_if_index_to)
17036 sw_if_to_name = (u8 *)(p->key);
17037 if (sw_if_from_name)
17042 print (vam->ofp, "%20s => %20s (%s)",
17043 sw_if_from_name, sw_if_to_name, states[mp->state]);
17047 vl_api_sw_interface_span_details_t_handler_json
17048 (vl_api_sw_interface_span_details_t * mp)
17050 vat_main_t *vam = &vat_main;
17051 vat_json_node_t *node = NULL;
17052 u8 *sw_if_from_name = 0;
17053 u8 *sw_if_to_name = 0;
17054 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
17055 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
17059 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
17061 if ((u32) p->value[0] == sw_if_index_from)
17063 sw_if_from_name = (u8 *)(p->key);
17067 if ((u32) p->value[0] == sw_if_index_to)
17069 sw_if_to_name = (u8 *)(p->key);
17070 if (sw_if_from_name)
17076 if (VAT_JSON_ARRAY != vam->json_tree.type)
17078 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17079 vat_json_init_array (&vam->json_tree);
17081 node = vat_json_array_add (&vam->json_tree);
17083 vat_json_init_object (node);
17084 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
17085 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
17086 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
17087 if (0 != sw_if_to_name)
17089 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
17091 vat_json_object_add_uint (node, "state", mp->state);
17095 api_sw_interface_span_dump (vat_main_t * vam)
17097 vl_api_sw_interface_span_dump_t *mp;
17098 vl_api_control_ping_t *mp_ping;
17101 M (SW_INTERFACE_SPAN_DUMP, mp);
17104 /* Use a control ping for synchronization */
17105 M (CONTROL_PING, mp_ping);
17113 api_pg_create_interface (vat_main_t * vam)
17115 unformat_input_t *input = vam->input;
17116 vl_api_pg_create_interface_t *mp;
17120 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17122 if (unformat (input, "if_id %d", &if_id))
17129 errmsg ("missing pg interface index");
17133 /* Construct the API message */
17134 M (PG_CREATE_INTERFACE, mp);
17136 mp->interface_id = ntohl (if_id);
17144 api_pg_capture (vat_main_t * vam)
17146 unformat_input_t *input = vam->input;
17147 vl_api_pg_capture_t *mp;
17152 u8 pcap_file_set = 0;
17155 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17157 if (unformat (input, "if_id %d", &if_id))
17159 else if (unformat (input, "pcap %s", &pcap_file))
17161 else if (unformat (input, "count %d", &count))
17163 else if (unformat (input, "disable"))
17170 errmsg ("missing pg interface index");
17173 if (pcap_file_set > 0)
17175 if (vec_len (pcap_file) > 255)
17177 errmsg ("pcap file name is too long");
17182 u32 name_len = vec_len (pcap_file);
17183 /* Construct the API message */
17184 M (PG_CAPTURE, mp);
17186 mp->interface_id = ntohl (if_id);
17187 mp->is_enabled = enable;
17188 mp->count = ntohl (count);
17189 mp->pcap_name_length = ntohl (name_len);
17190 if (pcap_file_set != 0)
17192 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
17194 vec_free (pcap_file);
17202 api_pg_enable_disable (vat_main_t * vam)
17204 unformat_input_t *input = vam->input;
17205 vl_api_pg_enable_disable_t *mp;
17208 u8 stream_name_set = 0;
17209 u8 *stream_name = 0;
17211 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17213 if (unformat (input, "stream %s", &stream_name))
17214 stream_name_set = 1;
17215 else if (unformat (input, "disable"))
17221 if (stream_name_set > 0)
17223 if (vec_len (stream_name) > 255)
17225 errmsg ("stream name too long");
17230 u32 name_len = vec_len (stream_name);
17231 /* Construct the API message */
17232 M (PG_ENABLE_DISABLE, mp);
17234 mp->is_enabled = enable;
17235 if (stream_name_set != 0)
17237 mp->stream_name_length = ntohl (name_len);
17238 clib_memcpy (mp->stream_name, stream_name, name_len);
17240 vec_free (stream_name);
17248 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
17250 unformat_input_t *input = vam->input;
17251 vl_api_ip_source_and_port_range_check_add_del_t *mp;
17253 u16 *low_ports = 0;
17254 u16 *high_ports = 0;
17257 ip4_address_t ip4_addr;
17258 ip6_address_t ip6_addr;
17267 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17269 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
17275 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
17280 else if (unformat (input, "vrf %d", &vrf_id))
17282 else if (unformat (input, "del"))
17284 else if (unformat (input, "port %d", &tmp))
17286 if (tmp == 0 || tmp > 65535)
17288 errmsg ("port %d out of range", tmp);
17292 this_hi = this_low + 1;
17293 vec_add1 (low_ports, this_low);
17294 vec_add1 (high_ports, this_hi);
17296 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
17298 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
17300 errmsg ("incorrect range parameters");
17304 /* Note: in debug CLI +1 is added to high before
17305 passing to real fn that does "the work"
17306 (ip_source_and_port_range_check_add_del).
17307 This fn is a wrapper around the binary API fn a
17308 control plane will call, which expects this increment
17309 to have occurred. Hence letting the binary API control
17310 plane fn do the increment for consistency between VAT
17311 and other control planes.
17314 vec_add1 (low_ports, this_low);
17315 vec_add1 (high_ports, this_hi);
17321 if (prefix_set == 0)
17323 errmsg ("<address>/<mask> not specified");
17329 errmsg ("VRF ID required, not specified");
17336 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17340 if (vec_len (low_ports) == 0)
17342 errmsg ("At least one port or port range required");
17346 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
17348 mp->is_add = is_add;
17353 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
17358 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
17361 mp->mask_length = length;
17362 mp->number_of_ranges = vec_len (low_ports);
17364 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
17365 vec_free (low_ports);
17367 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
17368 vec_free (high_ports);
17370 mp->vrf_id = ntohl (vrf_id);
17378 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
17380 unformat_input_t *input = vam->input;
17381 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
17382 u32 sw_if_index = ~0;
17384 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
17385 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
17389 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17391 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17393 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17395 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
17397 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
17399 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
17401 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
17403 else if (unformat (input, "del"))
17409 if (sw_if_index == ~0)
17411 errmsg ("Interface required but not specified");
17417 errmsg ("VRF ID required but not specified");
17421 if (tcp_out_vrf_id == 0
17422 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
17425 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17429 /* Construct the API message */
17430 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
17432 mp->sw_if_index = ntohl (sw_if_index);
17433 mp->is_add = is_add;
17434 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
17435 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
17436 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
17437 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
17442 /* Wait for a reply... */
17448 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
17450 unformat_input_t *i = vam->input;
17451 vl_api_ipsec_gre_add_del_tunnel_t *mp;
17452 u32 local_sa_id = 0;
17453 u32 remote_sa_id = 0;
17454 ip4_address_t src_address;
17455 ip4_address_t dst_address;
17459 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17461 if (unformat (i, "local_sa %d", &local_sa_id))
17463 else if (unformat (i, "remote_sa %d", &remote_sa_id))
17465 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
17467 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
17469 else if (unformat (i, "del"))
17473 clib_warning ("parse error '%U'", format_unformat_error, i);
17478 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
17480 mp->local_sa_id = ntohl (local_sa_id);
17481 mp->remote_sa_id = ntohl (remote_sa_id);
17482 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
17483 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
17484 mp->is_add = is_add;
17492 api_punt (vat_main_t * vam)
17494 unformat_input_t *i = vam->input;
17502 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17504 if (unformat (i, "ip %d", &ipv))
17506 else if (unformat (i, "protocol %d", &protocol))
17508 else if (unformat (i, "port %d", &port))
17510 else if (unformat (i, "del"))
17514 clib_warning ("parse error '%U'", format_unformat_error, i);
17521 mp->is_add = (u8) is_add;
17522 mp->ipv = (u8) ipv;
17523 mp->l4_protocol = (u8) protocol;
17524 mp->l4_port = htons ((u16) port);
17531 static void vl_api_ipsec_gre_tunnel_details_t_handler
17532 (vl_api_ipsec_gre_tunnel_details_t * mp)
17534 vat_main_t *vam = &vat_main;
17536 print (vam->ofp, "%11d%15U%15U%14d%14d",
17537 ntohl (mp->sw_if_index),
17538 format_ip4_address, &mp->src_address,
17539 format_ip4_address, &mp->dst_address,
17540 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
17543 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
17544 (vl_api_ipsec_gre_tunnel_details_t * mp)
17546 vat_main_t *vam = &vat_main;
17547 vat_json_node_t *node = NULL;
17548 struct in_addr ip4;
17550 if (VAT_JSON_ARRAY != vam->json_tree.type)
17552 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17553 vat_json_init_array (&vam->json_tree);
17555 node = vat_json_array_add (&vam->json_tree);
17557 vat_json_init_object (node);
17558 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17559 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
17560 vat_json_object_add_ip4 (node, "src_address", ip4);
17561 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
17562 vat_json_object_add_ip4 (node, "dst_address", ip4);
17563 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
17564 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
17568 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
17570 unformat_input_t *i = vam->input;
17571 vl_api_ipsec_gre_tunnel_dump_t *mp;
17572 vl_api_control_ping_t *mp_ping;
17574 u8 sw_if_index_set = 0;
17577 /* Parse args required to build the message */
17578 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17580 if (unformat (i, "sw_if_index %d", &sw_if_index))
17581 sw_if_index_set = 1;
17586 if (sw_if_index_set == 0)
17591 if (!vam->json_output)
17593 print (vam->ofp, "%11s%15s%15s%14s%14s",
17594 "sw_if_index", "src_address", "dst_address",
17595 "local_sa_id", "remote_sa_id");
17598 /* Get list of gre-tunnel interfaces */
17599 M (IPSEC_GRE_TUNNEL_DUMP, mp);
17601 mp->sw_if_index = htonl (sw_if_index);
17605 /* Use a control ping for synchronization */
17606 M (CONTROL_PING, mp_ping);
17614 api_delete_subif (vat_main_t * vam)
17616 unformat_input_t *i = vam->input;
17617 vl_api_delete_subif_t *mp;
17618 u32 sw_if_index = ~0;
17621 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17623 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17625 if (unformat (i, "sw_if_index %d", &sw_if_index))
17631 if (sw_if_index == ~0)
17633 errmsg ("missing sw_if_index");
17637 /* Construct the API message */
17638 M (DELETE_SUBIF, mp);
17639 mp->sw_if_index = ntohl (sw_if_index);
17646 #define foreach_pbb_vtr_op \
17647 _("disable", L2_VTR_DISABLED) \
17648 _("pop", L2_VTR_POP_2) \
17649 _("push", L2_VTR_PUSH_2)
17652 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
17654 unformat_input_t *i = vam->input;
17655 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
17656 u32 sw_if_index = ~0, vtr_op = ~0;
17657 u16 outer_tag = ~0;
17658 u8 dmac[6], smac[6];
17659 u8 dmac_set = 0, smac_set = 0;
17665 /* Shut up coverity */
17666 memset (dmac, 0, sizeof (dmac));
17667 memset (smac, 0, sizeof (smac));
17669 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17671 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17673 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17675 else if (unformat (i, "vtr_op %d", &vtr_op))
17677 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
17680 else if (unformat (i, "translate_pbb_stag"))
17682 if (unformat (i, "%d", &tmp))
17684 vtr_op = L2_VTR_TRANSLATE_2_1;
17690 ("translate_pbb_stag operation requires outer tag definition");
17694 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
17696 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
17698 else if (unformat (i, "sid %d", &sid))
17700 else if (unformat (i, "vlanid %d", &tmp))
17704 clib_warning ("parse error '%U'", format_unformat_error, i);
17709 if ((sw_if_index == ~0) || (vtr_op == ~0))
17711 errmsg ("missing sw_if_index or vtr operation");
17714 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
17715 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
17718 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
17722 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
17723 mp->sw_if_index = ntohl (sw_if_index);
17724 mp->vtr_op = ntohl (vtr_op);
17725 mp->outer_tag = ntohs (outer_tag);
17726 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
17727 clib_memcpy (mp->b_smac, smac, sizeof (smac));
17728 mp->b_vlanid = ntohs (vlanid);
17729 mp->i_sid = ntohl (sid);
17737 api_flow_classify_set_interface (vat_main_t * vam)
17739 unformat_input_t *i = vam->input;
17740 vl_api_flow_classify_set_interface_t *mp;
17742 int sw_if_index_set;
17743 u32 ip4_table_index = ~0;
17744 u32 ip6_table_index = ~0;
17748 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17750 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17751 sw_if_index_set = 1;
17752 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17753 sw_if_index_set = 1;
17754 else if (unformat (i, "del"))
17756 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17758 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17762 clib_warning ("parse error '%U'", format_unformat_error, i);
17767 if (sw_if_index_set == 0)
17769 errmsg ("missing interface name or sw_if_index");
17773 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
17775 mp->sw_if_index = ntohl (sw_if_index);
17776 mp->ip4_table_index = ntohl (ip4_table_index);
17777 mp->ip6_table_index = ntohl (ip6_table_index);
17778 mp->is_add = is_add;
17786 api_flow_classify_dump (vat_main_t * vam)
17788 unformat_input_t *i = vam->input;
17789 vl_api_flow_classify_dump_t *mp;
17790 vl_api_control_ping_t *mp_ping;
17791 u8 type = FLOW_CLASSIFY_N_TABLES;
17794 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
17798 errmsg ("classify table type must be specified");
17802 if (!vam->json_output)
17804 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17807 M (FLOW_CLASSIFY_DUMP, mp);
17812 /* Use a control ping for synchronization */
17813 M (CONTROL_PING, mp_ping);
17816 /* Wait for a reply... */
17822 api_feature_enable_disable (vat_main_t * vam)
17824 unformat_input_t *i = vam->input;
17825 vl_api_feature_enable_disable_t *mp;
17827 u8 *feature_name = 0;
17828 u32 sw_if_index = ~0;
17832 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17834 if (unformat (i, "arc_name %s", &arc_name))
17836 else if (unformat (i, "feature_name %s", &feature_name))
17839 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17841 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17843 else if (unformat (i, "disable"))
17851 errmsg ("missing arc name");
17854 if (vec_len (arc_name) > 63)
17856 errmsg ("arc name too long");
17859 if (feature_name == 0)
17861 errmsg ("missing feature name");
17864 if (vec_len (feature_name) > 63)
17866 errmsg ("feature name too long");
17869 if (sw_if_index == ~0)
17871 errmsg ("missing interface name or sw_if_index");
17875 /* Construct the API message */
17876 M (FEATURE_ENABLE_DISABLE, mp);
17877 mp->sw_if_index = ntohl (sw_if_index);
17878 mp->enable = enable;
17879 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
17880 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
17881 vec_free (arc_name);
17882 vec_free (feature_name);
17890 api_sw_interface_tag_add_del (vat_main_t * vam)
17892 unformat_input_t *i = vam->input;
17893 vl_api_sw_interface_tag_add_del_t *mp;
17894 u32 sw_if_index = ~0;
17899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17901 if (unformat (i, "tag %s", &tag))
17903 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17905 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17907 else if (unformat (i, "del"))
17913 if (sw_if_index == ~0)
17915 errmsg ("missing interface name or sw_if_index");
17919 if (enable && (tag == 0))
17921 errmsg ("no tag specified");
17925 /* Construct the API message */
17926 M (SW_INTERFACE_TAG_ADD_DEL, mp);
17927 mp->sw_if_index = ntohl (sw_if_index);
17928 mp->is_add = enable;
17930 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
17938 static void vl_api_l2_xconnect_details_t_handler
17939 (vl_api_l2_xconnect_details_t * mp)
17941 vat_main_t *vam = &vat_main;
17943 print (vam->ofp, "%15d%15d",
17944 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
17947 static void vl_api_l2_xconnect_details_t_handler_json
17948 (vl_api_l2_xconnect_details_t * mp)
17950 vat_main_t *vam = &vat_main;
17951 vat_json_node_t *node = NULL;
17953 if (VAT_JSON_ARRAY != vam->json_tree.type)
17955 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17956 vat_json_init_array (&vam->json_tree);
17958 node = vat_json_array_add (&vam->json_tree);
17960 vat_json_init_object (node);
17961 vat_json_object_add_uint (node, "rx_sw_if_index",
17962 ntohl (mp->rx_sw_if_index));
17963 vat_json_object_add_uint (node, "tx_sw_if_index",
17964 ntohl (mp->tx_sw_if_index));
17968 api_l2_xconnect_dump (vat_main_t * vam)
17970 vl_api_l2_xconnect_dump_t *mp;
17971 vl_api_control_ping_t *mp_ping;
17974 if (!vam->json_output)
17976 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
17979 M (L2_XCONNECT_DUMP, mp);
17983 /* Use a control ping for synchronization */
17984 M (CONTROL_PING, mp_ping);
17992 api_sw_interface_set_mtu (vat_main_t * vam)
17994 unformat_input_t *i = vam->input;
17995 vl_api_sw_interface_set_mtu_t *mp;
17996 u32 sw_if_index = ~0;
18000 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18002 if (unformat (i, "mtu %d", &mtu))
18004 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18006 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18012 if (sw_if_index == ~0)
18014 errmsg ("missing interface name or sw_if_index");
18020 errmsg ("no mtu specified");
18024 /* Construct the API message */
18025 M (SW_INTERFACE_SET_MTU, mp);
18026 mp->sw_if_index = ntohl (sw_if_index);
18027 mp->mtu = ntohs ((u16) mtu);
18036 q_or_quit (vat_main_t * vam)
18038 #if VPP_API_TEST_BUILTIN == 0
18039 longjmp (vam->jump_buf, 1);
18041 return 0; /* not so much */
18045 q (vat_main_t * vam)
18047 return q_or_quit (vam);
18051 quit (vat_main_t * vam)
18053 return q_or_quit (vam);
18057 comment (vat_main_t * vam)
18063 cmd_cmp (void *a1, void *a2)
18068 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
18072 help (vat_main_t * vam)
18077 unformat_input_t *i = vam->input;
18080 if (unformat (i, "%s", &name))
18084 vec_add1 (name, 0);
18086 hs = hash_get_mem (vam->help_by_name, name);
18088 print (vam->ofp, "usage: %s %s", name, hs[0]);
18090 print (vam->ofp, "No such msg / command '%s'", name);
18095 print (vam->ofp, "Help is available for the following:");
18098 hash_foreach_pair (p, vam->function_by_name,
18100 vec_add1 (cmds, (u8 *)(p->key));
18104 vec_sort_with_function (cmds, cmd_cmp);
18106 for (j = 0; j < vec_len (cmds); j++)
18107 print (vam->ofp, "%s", cmds[j]);
18114 set (vat_main_t * vam)
18116 u8 *name = 0, *value = 0;
18117 unformat_input_t *i = vam->input;
18119 if (unformat (i, "%s", &name))
18121 /* The input buffer is a vector, not a string. */
18122 value = vec_dup (i->buffer);
18123 vec_delete (value, i->index, 0);
18124 /* Almost certainly has a trailing newline */
18125 if (value[vec_len (value) - 1] == '\n')
18126 value[vec_len (value) - 1] = 0;
18127 /* Make sure it's a proper string, one way or the other */
18128 vec_add1 (value, 0);
18129 (void) clib_macro_set_value (&vam->macro_main,
18130 (char *) name, (char *) value);
18133 errmsg ("usage: set <name> <value>");
18141 unset (vat_main_t * vam)
18145 if (unformat (vam->input, "%s", &name))
18146 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
18147 errmsg ("unset: %s wasn't set", name);
18160 macro_sort_cmp (void *a1, void *a2)
18162 macro_sort_t *s1 = a1;
18163 macro_sort_t *s2 = a2;
18165 return strcmp ((char *) (s1->name), (char *) (s2->name));
18169 dump_macro_table (vat_main_t * vam)
18171 macro_sort_t *sort_me = 0, *sm;
18176 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
18178 vec_add2 (sort_me, sm, 1);
18179 sm->name = (u8 *)(p->key);
18180 sm->value = (u8 *) (p->value[0]);
18184 vec_sort_with_function (sort_me, macro_sort_cmp);
18186 if (vec_len (sort_me))
18187 print (vam->ofp, "%-15s%s", "Name", "Value");
18189 print (vam->ofp, "The macro table is empty...");
18191 for (i = 0; i < vec_len (sort_me); i++)
18192 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
18197 dump_node_table (vat_main_t * vam)
18200 vlib_node_t *node, *next_node;
18202 if (vec_len (vam->graph_nodes) == 0)
18204 print (vam->ofp, "Node table empty, issue get_node_graph...");
18208 for (i = 0; i < vec_len (vam->graph_nodes); i++)
18210 node = vam->graph_nodes[i];
18211 print (vam->ofp, "[%d] %s", i, node->name);
18212 for (j = 0; j < vec_len (node->next_nodes); j++)
18214 if (node->next_nodes[j] != ~0)
18216 next_node = vam->graph_nodes[node->next_nodes[j]];
18217 print (vam->ofp, " [%d] %s", j, next_node->name);
18225 value_sort_cmp (void *a1, void *a2)
18227 name_sort_t *n1 = a1;
18228 name_sort_t *n2 = a2;
18230 if (n1->value < n2->value)
18232 if (n1->value > n2->value)
18239 dump_msg_api_table (vat_main_t * vam)
18241 api_main_t *am = &api_main;
18242 name_sort_t *nses = 0, *ns;
18247 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
18249 vec_add2 (nses, ns, 1);
18250 ns->name = (u8 *)(hp->key);
18251 ns->value = (u32) hp->value[0];
18255 vec_sort_with_function (nses, value_sort_cmp);
18257 for (i = 0; i < vec_len (nses); i++)
18258 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
18264 get_msg_id (vat_main_t * vam)
18269 if (unformat (vam->input, "%s", &name_and_crc))
18271 message_index = vl_api_get_msg_index (name_and_crc);
18272 if (message_index == ~0)
18274 print (vam->ofp, " '%s' not found", name_and_crc);
18277 print (vam->ofp, " '%s' has message index %d",
18278 name_and_crc, message_index);
18281 errmsg ("name_and_crc required...");
18286 search_node_table (vat_main_t * vam)
18288 unformat_input_t *line_input = vam->input;
18291 vlib_node_t *node, *next_node;
18294 if (vam->graph_node_index_by_name == 0)
18296 print (vam->ofp, "Node table empty, issue get_node_graph...");
18300 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
18302 if (unformat (line_input, "%s", &node_to_find))
18304 vec_add1 (node_to_find, 0);
18305 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
18308 print (vam->ofp, "%s not found...", node_to_find);
18311 node = vam->graph_nodes[p[0]];
18312 print (vam->ofp, "[%d] %s", p[0], node->name);
18313 for (j = 0; j < vec_len (node->next_nodes); j++)
18315 if (node->next_nodes[j] != ~0)
18317 next_node = vam->graph_nodes[node->next_nodes[j]];
18318 print (vam->ofp, " [%d] %s", j, next_node->name);
18325 clib_warning ("parse error '%U'", format_unformat_error,
18331 vec_free (node_to_find);
18340 script (vat_main_t * vam)
18342 #if (VPP_API_TEST_BUILTIN==0)
18344 char *save_current_file;
18345 unformat_input_t save_input;
18346 jmp_buf save_jump_buf;
18347 u32 save_line_number;
18349 FILE *new_fp, *save_ifp;
18351 if (unformat (vam->input, "%s", &s))
18353 new_fp = fopen ((char *) s, "r");
18356 errmsg ("Couldn't open script file %s", s);
18363 errmsg ("Missing script name");
18367 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
18368 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
18369 save_ifp = vam->ifp;
18370 save_line_number = vam->input_line_number;
18371 save_current_file = (char *) vam->current_file;
18373 vam->input_line_number = 0;
18375 vam->current_file = s;
18378 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
18379 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
18380 vam->ifp = save_ifp;
18381 vam->input_line_number = save_line_number;
18382 vam->current_file = (u8 *) save_current_file;
18387 clib_warning ("use the exec command...");
18393 echo (vat_main_t * vam)
18395 print (vam->ofp, "%v", vam->input->buffer);
18399 /* List of API message constructors, CLI names map to api_xxx */
18400 #define foreach_vpe_api_msg \
18401 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
18402 _(sw_interface_dump,"") \
18403 _(sw_interface_set_flags, \
18404 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
18405 _(sw_interface_add_del_address, \
18406 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
18407 _(sw_interface_set_table, \
18408 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
18409 _(sw_interface_set_mpls_enable, \
18410 "<intfc> | sw_if_index [disable | dis]") \
18411 _(sw_interface_set_vpath, \
18412 "<intfc> | sw_if_index <id> enable | disable") \
18413 _(sw_interface_set_vxlan_bypass, \
18414 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
18415 _(sw_interface_set_l2_xconnect, \
18416 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18417 "enable | disable") \
18418 _(sw_interface_set_l2_bridge, \
18419 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
18420 "[shg <split-horizon-group>] [bvi]\n" \
18421 "enable | disable") \
18422 _(bridge_domain_add_del, \
18423 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
18424 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
18426 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
18428 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
18430 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
18432 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
18434 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
18436 "<vpp-if-name> | sw_if_index <id>") \
18437 _(sw_interface_tap_dump, "") \
18438 _(ip_add_del_route, \
18439 "<addr>/<mask> via <addr> [table-id <n>]\n" \
18440 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18441 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18442 "[multipath] [count <n>]") \
18443 _(ip_mroute_add_del, \
18444 "<src> <grp>/<mask> [table-id <n>]\n" \
18445 "[<intfc> | sw_if_index <id>] [local] [del]") \
18446 _(mpls_route_add_del, \
18447 "<label> <eos> via <addr> [table-id <n>]\n" \
18448 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18449 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18450 "[multipath] [count <n>]") \
18451 _(mpls_ip_bind_unbind, \
18452 "<label> <addr/len>") \
18453 _(mpls_tunnel_add_del, \
18454 " via <addr> [table-id <n>]\n" \
18455 "sw_if_index <id>] [l2] [del]") \
18456 _(proxy_arp_add_del, \
18457 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
18458 _(proxy_arp_intfc_enable_disable, \
18459 "<intfc> | sw_if_index <id> enable | disable") \
18460 _(sw_interface_set_unnumbered, \
18461 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
18462 _(ip_neighbor_add_del, \
18463 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
18464 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
18465 _(reset_vrf, "vrf <id> [ipv6]") \
18466 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
18467 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
18468 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
18469 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
18470 "[outer_vlan_id_any][inner_vlan_id_any]") \
18471 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
18472 _(reset_fib, "vrf <n> [ipv6]") \
18473 _(dhcp_proxy_config, \
18474 "svr <v46-address> src <v46-address>\n" \
18475 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
18476 _(dhcp_proxy_set_vss, \
18477 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
18478 _(dhcp_proxy_dump, "ip6") \
18479 _(dhcp_client_config, \
18480 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
18481 _(set_ip_flow_hash, \
18482 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
18483 _(sw_interface_ip6_enable_disable, \
18484 "<intfc> | sw_if_index <id> enable | disable") \
18485 _(sw_interface_ip6_set_link_local_address, \
18486 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
18487 _(ip6nd_proxy_add_del, \
18488 "<intfc> | sw_if_index <id> <ip6-address>") \
18489 _(ip6nd_proxy_dump, "") \
18490 _(sw_interface_ip6nd_ra_prefix, \
18491 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
18492 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
18493 "[nolink] [isno]") \
18494 _(sw_interface_ip6nd_ra_config, \
18495 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
18496 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
18497 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
18498 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
18499 _(l2_patch_add_del, \
18500 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18501 "enable | disable") \
18502 _(sr_localsid_add_del, \
18503 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
18504 "fib-table <num> (end.psp) sw_if_index <num>") \
18505 _(classify_add_del_table, \
18506 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
18507 " [del] [del-chain] mask <mask-value>\n" \
18508 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
18509 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
18510 _(classify_add_del_session, \
18511 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
18512 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
18513 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
18514 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
18515 _(classify_set_interface_ip_table, \
18516 "<intfc> | sw_if_index <nn> table <nn>") \
18517 _(classify_set_interface_l2_tables, \
18518 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18519 " [other-table <nn>]") \
18520 _(get_node_index, "node <node-name") \
18521 _(add_node_next, "node <node-name> next <next-node-name>") \
18522 _(l2tpv3_create_tunnel, \
18523 "client_address <ip6-addr> our_address <ip6-addr>\n" \
18524 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
18525 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
18526 _(l2tpv3_set_tunnel_cookies, \
18527 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
18528 "[new_remote_cookie <nn>]\n") \
18529 _(l2tpv3_interface_enable_disable, \
18530 "<intfc> | sw_if_index <nn> enable | disable") \
18531 _(l2tpv3_set_lookup_key, \
18532 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
18533 _(sw_if_l2tpv3_tunnel_dump, "") \
18534 _(vxlan_add_del_tunnel, \
18535 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
18536 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
18537 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
18538 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18539 _(gre_add_del_tunnel, \
18540 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
18541 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18542 _(l2_fib_clear_table, "") \
18543 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
18544 _(l2_interface_vlan_tag_rewrite, \
18545 "<intfc> | sw_if_index <nn> \n" \
18546 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
18547 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
18548 _(create_vhost_user_if, \
18549 "socket <filename> [server] [renumber <dev_instance>] " \
18550 "[mac <mac_address>] " \
18551 "[mode <interrupt | polling>]") \
18552 _(modify_vhost_user_if, \
18553 "<intfc> | sw_if_index <nn> socket <filename>\n" \
18554 "[server] [renumber <dev_instance>] " \
18555 "[mode <interrupt | polling>]") \
18556 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
18557 _(sw_interface_vhost_user_dump, "") \
18558 _(show_version, "") \
18559 _(vxlan_gpe_add_del_tunnel, \
18560 "local <addr> remote <addr> vni <nn>\n" \
18561 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
18562 "[next-ethernet] [next-nsh]\n") \
18563 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18564 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
18565 _(interface_name_renumber, \
18566 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
18567 _(input_acl_set_interface, \
18568 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18569 " [l2-table <nn>] [del]") \
18570 _(want_ip4_arp_events, "address <ip4-address> [del]") \
18571 _(want_ip6_nd_events, "address <ip6-address> [del]") \
18572 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
18573 _(ip_dump, "ipv4 | ipv6") \
18574 _(ipsec_spd_add_del, "spd_id <n> [del]") \
18575 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
18577 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
18578 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
18579 " integ_alg <alg> integ_key <hex>") \
18580 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
18581 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
18582 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
18583 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
18584 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
18585 _(ikev2_profile_add_del, "name <profile_name> [del]") \
18586 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
18587 "(auth_data 0x<data> | auth_data <data>)") \
18588 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
18589 "(id_data 0x<data> | id_data <data>) (local|remote)") \
18590 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
18591 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
18592 "(local|remote)") \
18593 _(ikev2_set_local_key, "file <absolute_file_path>") \
18594 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
18595 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18596 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18597 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
18598 _(ikev2_initiate_sa_init, "<profile_name>") \
18599 _(ikev2_initiate_del_ike_sa, "<ispi>") \
18600 _(ikev2_initiate_del_child_sa, "<ispi>") \
18601 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
18602 _(delete_loopback,"sw_if_index <nn>") \
18603 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
18604 _(map_add_domain, \
18605 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
18606 "ip6-src <ip6addr> " \
18607 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
18608 _(map_del_domain, "index <n>") \
18609 _(map_add_del_rule, \
18610 "index <n> psid <n> dst <ip6addr> [del]") \
18611 _(map_domain_dump, "") \
18612 _(map_rule_dump, "index <map-domain>") \
18613 _(want_interface_events, "enable|disable") \
18614 _(want_stats,"enable|disable") \
18615 _(get_first_msg_id, "client <name>") \
18616 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
18617 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
18618 "fib-id <nn> [ip4][ip6][default]") \
18619 _(get_node_graph, " ") \
18620 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
18621 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
18622 _(ioam_disable, "") \
18623 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
18624 " sw_if_index <sw_if_index> p <priority> " \
18625 "w <weight>] [del]") \
18626 _(one_add_del_locator, "locator-set <locator_name> " \
18627 "iface <intf> | sw_if_index <sw_if_index> " \
18628 "p <priority> w <weight> [del]") \
18629 _(one_add_del_local_eid,"vni <vni> eid " \
18630 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18631 "locator-set <locator_name> [del]" \
18632 "[key-id sha1|sha256 secret-key <secret-key>]")\
18633 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
18634 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
18635 _(one_enable_disable, "enable|disable") \
18636 _(one_map_register_enable_disable, "enable|disable") \
18637 _(one_rloc_probe_enable_disable, "enable|disable") \
18638 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18640 "rloc <locator> p <prio> " \
18641 "w <weight> [rloc <loc> ... ] " \
18642 "action <action> [del-all]") \
18643 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18645 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18646 _(one_use_petr, "ip-address> | disable") \
18647 _(one_map_request_mode, "src-dst|dst-only") \
18648 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18649 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18650 _(one_locator_set_dump, "[local | remote]") \
18651 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
18652 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18653 "[local] | [remote]") \
18654 _(one_stats_enable_disable, "enable|disalbe") \
18655 _(show_one_stats_enable_disable, "") \
18656 _(one_eid_table_vni_dump, "") \
18657 _(one_eid_table_map_dump, "l2|l3") \
18658 _(one_map_resolver_dump, "") \
18659 _(one_map_server_dump, "") \
18660 _(one_adjacencies_get, "vni <vni>") \
18661 _(show_one_rloc_probe_state, "") \
18662 _(show_one_map_register_state, "") \
18663 _(show_one_status, "") \
18664 _(one_stats_dump, "") \
18665 _(one_get_map_request_itr_rlocs, "") \
18666 _(show_one_pitr, "") \
18667 _(show_one_use_petr, "") \
18668 _(show_one_map_request_mode, "") \
18669 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
18670 " sw_if_index <sw_if_index> p <priority> " \
18671 "w <weight>] [del]") \
18672 _(lisp_add_del_locator, "locator-set <locator_name> " \
18673 "iface <intf> | sw_if_index <sw_if_index> " \
18674 "p <priority> w <weight> [del]") \
18675 _(lisp_add_del_local_eid,"vni <vni> eid " \
18676 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18677 "locator-set <locator_name> [del]" \
18678 "[key-id sha1|sha256 secret-key <secret-key>]") \
18679 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
18680 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
18681 _(lisp_enable_disable, "enable|disable") \
18682 _(lisp_map_register_enable_disable, "enable|disable") \
18683 _(lisp_rloc_probe_enable_disable, "enable|disable") \
18684 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18686 "rloc <locator> p <prio> " \
18687 "w <weight> [rloc <loc> ... ] " \
18688 "action <action> [del-all]") \
18689 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18691 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18692 _(lisp_use_petr, "<ip-address> | disable") \
18693 _(lisp_map_request_mode, "src-dst|dst-only") \
18694 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18695 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18696 _(lisp_locator_set_dump, "[local | remote]") \
18697 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
18698 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18699 "[local] | [remote]") \
18700 _(lisp_eid_table_vni_dump, "") \
18701 _(lisp_eid_table_map_dump, "l2|l3") \
18702 _(lisp_map_resolver_dump, "") \
18703 _(lisp_map_server_dump, "") \
18704 _(lisp_adjacencies_get, "vni <vni>") \
18705 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
18706 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
18707 _(gpe_set_encap_mode, "lisp|vxlan") \
18708 _(gpe_get_encap_mode, "") \
18709 _(lisp_gpe_add_del_iface, "up|down") \
18710 _(lisp_gpe_enable_disable, "enable|disable") \
18711 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
18712 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
18713 _(show_lisp_rloc_probe_state, "") \
18714 _(show_lisp_map_register_state, "") \
18715 _(show_lisp_status, "") \
18716 _(lisp_get_map_request_itr_rlocs, "") \
18717 _(show_lisp_pitr, "") \
18718 _(show_lisp_use_petr, "") \
18719 _(show_lisp_map_request_mode, "") \
18720 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
18721 _(af_packet_delete, "name <host interface name>") \
18722 _(policer_add_del, "name <policer name> <params> [del]") \
18723 _(policer_dump, "[name <policer name>]") \
18724 _(policer_classify_set_interface, \
18725 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18726 " [l2-table <nn>] [del]") \
18727 _(policer_classify_dump, "type [ip4|ip6|l2]") \
18728 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
18729 "[master|slave]") \
18730 _(netmap_delete, "name <interface name>") \
18731 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
18732 _(mpls_fib_dump, "") \
18733 _(classify_table_ids, "") \
18734 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
18735 _(classify_table_info, "table_id <nn>") \
18736 _(classify_session_dump, "table_id <nn>") \
18737 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
18738 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
18739 "[template_interval <nn>] [udp_checksum]") \
18740 _(ipfix_exporter_dump, "") \
18741 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
18742 _(ipfix_classify_stream_dump, "") \
18743 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
18744 _(ipfix_classify_table_dump, "") \
18745 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
18746 _(sw_interface_span_dump, "") \
18747 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
18748 _(pg_create_interface, "if_id <nn>") \
18749 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
18750 _(pg_enable_disable, "[stream <id>] disable") \
18751 _(ip_source_and_port_range_check_add_del, \
18752 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
18753 _(ip_source_and_port_range_check_interface_add_del, \
18754 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
18755 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
18756 _(ipsec_gre_add_del_tunnel, \
18757 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
18758 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
18759 _(delete_subif,"<intfc> | sw_if_index <nn>") \
18760 _(l2_interface_pbb_tag_rewrite, \
18761 "<intfc> | sw_if_index <nn> \n" \
18762 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
18763 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
18764 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
18765 _(flow_classify_set_interface, \
18766 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
18767 _(flow_classify_dump, "type [ip4|ip6]") \
18768 _(ip_fib_dump, "") \
18769 _(ip_mfib_dump, "") \
18770 _(ip6_fib_dump, "") \
18771 _(ip6_mfib_dump, "") \
18772 _(feature_enable_disable, "arc_name <arc_name> " \
18773 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
18774 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
18776 _(l2_xconnect_dump, "") \
18777 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
18778 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
18779 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
18781 /* List of command functions, CLI names map directly to functions */
18782 #define foreach_cli_function \
18783 _(comment, "usage: comment <ignore-rest-of-line>") \
18784 _(dump_interface_table, "usage: dump_interface_table") \
18785 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
18786 _(dump_ipv4_table, "usage: dump_ipv4_table") \
18787 _(dump_ipv6_table, "usage: dump_ipv6_table") \
18788 _(dump_stats_table, "usage: dump_stats_table") \
18789 _(dump_macro_table, "usage: dump_macro_table ") \
18790 _(dump_node_table, "usage: dump_node_table") \
18791 _(dump_msg_api_table, "usage: dump_msg_api_table") \
18792 _(get_msg_id, "usage: get_msg_id name_and_crc") \
18793 _(echo, "usage: echo <message>") \
18794 _(exec, "usage: exec <vpe-debug-CLI-command>") \
18795 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
18796 _(help, "usage: help") \
18797 _(q, "usage: quit") \
18798 _(quit, "usage: quit") \
18799 _(search_node_table, "usage: search_node_table <name>...") \
18800 _(set, "usage: set <variable-name> <value>") \
18801 _(script, "usage: script <file-name>") \
18802 _(unset, "usage: unset <variable-name>")
18805 static void vl_api_##n##_t_handler_uni \
18806 (vl_api_##n##_t * mp) \
18808 vat_main_t * vam = &vat_main; \
18809 if (vam->json_output) { \
18810 vl_api_##n##_t_handler_json(mp); \
18812 vl_api_##n##_t_handler(mp); \
18815 foreach_vpe_api_reply_msg;
18816 #if VPP_API_TEST_BUILTIN == 0
18817 foreach_standalone_reply_msg;
18822 vat_api_hookup (vat_main_t * vam)
18825 vl_msg_api_set_handlers(VL_API_##N, #n, \
18826 vl_api_##n##_t_handler_uni, \
18828 vl_api_##n##_t_endian, \
18829 vl_api_##n##_t_print, \
18830 sizeof(vl_api_##n##_t), 1);
18831 foreach_vpe_api_reply_msg;
18832 #if VPP_API_TEST_BUILTIN == 0
18833 foreach_standalone_reply_msg;
18837 #if (VPP_API_TEST_BUILTIN==0)
18838 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
18840 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
18842 vam->function_by_name = hash_create_string (0, sizeof (uword));
18844 vam->help_by_name = hash_create_string (0, sizeof (uword));
18847 /* API messages we can send */
18848 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18849 foreach_vpe_api_msg;
18853 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18854 foreach_vpe_api_msg;
18857 /* CLI functions */
18858 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
18859 foreach_cli_function;
18863 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18864 foreach_cli_function;
18868 #if VPP_API_TEST_BUILTIN
18869 static clib_error_t *
18870 vat_api_hookup_shim (vlib_main_t * vm)
18872 vat_api_hookup (&vat_main);
18876 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
18880 * fd.io coding-style-patch-verification: ON
18883 * eval: (c-set-style "gnu")