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 <vppinfra/socket.h>
22 #include <svm/memfd.h>
23 #include <vlibapi/api.h>
24 #include <vlibmemory/api.h>
25 #include <vnet/ip/ip.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2tp/l2tp.h>
28 #include <vnet/vxlan/vxlan.h>
29 #include <vnet/gre/gre.h>
30 #include <vnet/vxlan-gpe/vxlan_gpe.h>
31 #include <vnet/lisp-gpe/lisp_gpe.h>
33 #include <vpp/api/vpe_msg_enum.h>
34 #include <vnet/l2/l2_classify.h>
35 #include <vnet/l2/l2_vtr.h>
36 #include <vnet/classify/input_acl.h>
37 #include <vnet/classify/policer_classify.h>
38 #include <vnet/classify/flow_classify.h>
39 #include <vnet/mpls/mpls.h>
40 #include <vnet/ipsec/ipsec.h>
41 #include <vnet/ipsec/ikev2.h>
43 #include <vnet/map/map.h>
44 #include <vnet/cop/cop.h>
45 #include <vnet/ip/ip6_hop_by_hop.h>
46 #include <vnet/ip/ip_source_and_port_range_check.h>
47 #include <vnet/policer/xlate.h>
48 #include <vnet/span/span.h>
49 #include <vnet/policer/policer.h>
50 #include <vnet/policer/police.h>
51 #include <vnet/mfib/mfib_types.h>
53 #include "vat/json_format.h"
58 #define vl_typedefs /* define message structures */
59 #include <vpp/api/vpe_all_api_h.h>
62 /* declare message handlers for each api */
64 #define vl_endianfun /* define message structures */
65 #include <vpp/api/vpe_all_api_h.h>
68 /* instantiate all the print functions we know about */
69 #define vl_print(handle, ...)
71 #include <vpp/api/vpe_all_api_h.h>
74 #define __plugin_msg_base 0
75 #include <vlibapi/vat_helper_macros.h>
77 #if VPP_API_TEST_BUILTIN == 0
87 vat_socket_connect (vat_main_t * vam)
89 return vl_socket_client_connect
90 (&vam->socket_client_main, (char *) vam->socket_name,
91 "vpp_api_test(s)", 0 /* default socket rx, tx buffer */ );
93 #else /* vpp built-in case, we don't do sockets... */
95 vat_socket_connect (vat_main_t * vam)
101 vl_socket_client_read_reply (socket_client_main_t * scm)
108 vat_time_now (vat_main_t * vam)
110 #if VPP_API_TEST_BUILTIN
111 return vlib_time_now (vam->vlib_main);
113 return clib_time_now (&vam->clib_time);
118 errmsg (char *fmt, ...)
120 vat_main_t *vam = &vat_main;
125 s = va_format (0, fmt, &va);
130 #if VPP_API_TEST_BUILTIN
131 vlib_cli_output (vam->vlib_main, (char *) s);
134 if (vam->ifp != stdin)
135 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
136 vam->input_line_number);
137 fformat (vam->ofp, (char *) s);
145 #if VPP_API_TEST_BUILTIN == 0
147 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
149 vat_main_t *vam = va_arg (*args, vat_main_t *);
150 u32 *result = va_arg (*args, u32 *);
154 if (!unformat (input, "%s", &if_name))
157 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
164 /* Parse an IP4 address %d.%d.%d.%d. */
166 unformat_ip4_address (unformat_input_t * input, va_list * args)
168 u8 *result = va_arg (*args, u8 *);
171 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
174 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
186 unformat_ethernet_address (unformat_input_t * input, va_list * args)
188 u8 *result = va_arg (*args, u8 *);
191 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
192 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
196 for (i = 0; i < 6; i++)
197 if (a[i] >= (1 << 8))
200 for (i = 0; i < 6; i++)
206 /* Returns ethernet type as an int in host byte order. */
208 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
211 u16 *result = va_arg (*args, u16 *);
215 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
217 if (type >= (1 << 16))
225 /* Parse an IP6 address. */
227 unformat_ip6_address (unformat_input_t * input, va_list * args)
229 ip6_address_t *result = va_arg (*args, ip6_address_t *);
231 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
232 uword c, n_colon, double_colon_index;
234 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
235 double_colon_index = ARRAY_LEN (hex_quads);
236 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
239 if (c >= '0' && c <= '9')
241 else if (c >= 'a' && c <= 'f')
242 hex_digit = c + 10 - 'a';
243 else if (c >= 'A' && c <= 'F')
244 hex_digit = c + 10 - 'A';
245 else if (c == ':' && n_colon < 2)
249 unformat_put_input (input);
253 /* Too many hex quads. */
254 if (n_hex_quads >= ARRAY_LEN (hex_quads))
259 hex_quad = (hex_quad << 4) | hex_digit;
261 /* Hex quad must fit in 16 bits. */
262 if (n_hex_digits >= 4)
269 /* Save position of :: */
272 /* More than one :: ? */
273 if (double_colon_index < ARRAY_LEN (hex_quads))
275 double_colon_index = n_hex_quads;
278 if (n_colon > 0 && n_hex_digits > 0)
280 hex_quads[n_hex_quads++] = hex_quad;
286 if (n_hex_digits > 0)
287 hex_quads[n_hex_quads++] = hex_quad;
292 /* Expand :: to appropriate number of zero hex quads. */
293 if (double_colon_index < ARRAY_LEN (hex_quads))
295 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
297 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
298 hex_quads[n_zero + i] = hex_quads[i];
300 for (i = 0; i < n_zero; i++)
301 hex_quads[double_colon_index + i] = 0;
303 n_hex_quads = ARRAY_LEN (hex_quads);
306 /* Too few hex quads given. */
307 if (n_hex_quads < ARRAY_LEN (hex_quads))
310 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
311 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
318 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
320 u32 *r = va_arg (*args, u32 *);
323 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
324 foreach_ipsec_policy_action
332 unformat_ipsec_crypto_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_CRYPTO_ALG_##f;
338 foreach_ipsec_crypto_alg
346 format_ipsec_crypto_alg (u8 * s, va_list * args)
348 u32 i = va_arg (*args, u32);
353 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
354 foreach_ipsec_crypto_alg
357 return format (s, "unknown");
359 return format (s, "%s", t);
363 unformat_ipsec_integ_alg (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 = IPSEC_INTEG_ALG_##f;
369 foreach_ipsec_integ_alg
377 format_ipsec_integ_alg (u8 * s, va_list * args)
379 u32 i = va_arg (*args, u32);
384 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
385 foreach_ipsec_integ_alg
388 return format (s, "unknown");
390 return format (s, "%s", t);
394 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
396 u32 *r = va_arg (*args, u32 *);
399 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
400 foreach_ikev2_auth_method
408 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
410 u32 *r = va_arg (*args, u32 *);
413 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
414 foreach_ikev2_id_type
420 #else /* VPP_API_TEST_BUILTIN == 1 */
422 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
424 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
425 vnet_main_t *vnm = vnet_get_main ();
426 u32 *result = va_arg (*args, u32 *);
429 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
432 *result = sw_if_index;
435 #endif /* VPP_API_TEST_BUILTIN */
438 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
440 u8 *r = va_arg (*args, u8 *);
442 if (unformat (input, "kbps"))
443 *r = SSE2_QOS_RATE_KBPS;
444 else if (unformat (input, "pps"))
445 *r = SSE2_QOS_RATE_PPS;
452 unformat_policer_round_type (unformat_input_t * input, va_list * args)
454 u8 *r = va_arg (*args, u8 *);
456 if (unformat (input, "closest"))
457 *r = SSE2_QOS_ROUND_TO_CLOSEST;
458 else if (unformat (input, "up"))
459 *r = SSE2_QOS_ROUND_TO_UP;
460 else if (unformat (input, "down"))
461 *r = SSE2_QOS_ROUND_TO_DOWN;
468 unformat_policer_type (unformat_input_t * input, va_list * args)
470 u8 *r = va_arg (*args, u8 *);
472 if (unformat (input, "1r2c"))
473 *r = SSE2_QOS_POLICER_TYPE_1R2C;
474 else if (unformat (input, "1r3c"))
475 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
476 else if (unformat (input, "2r3c-2698"))
477 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
478 else if (unformat (input, "2r3c-4115"))
479 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
480 else if (unformat (input, "2r3c-mef5cf1"))
481 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
488 unformat_dscp (unformat_input_t * input, va_list * va)
490 u8 *r = va_arg (*va, u8 *);
493 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
502 unformat_policer_action_type (unformat_input_t * input, va_list * va)
504 sse2_qos_pol_action_params_st *a
505 = va_arg (*va, sse2_qos_pol_action_params_st *);
507 if (unformat (input, "drop"))
508 a->action_type = SSE2_QOS_ACTION_DROP;
509 else if (unformat (input, "transmit"))
510 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
511 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
512 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
519 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
521 u32 *r = va_arg (*va, u32 *);
524 if (unformat (input, "ip4"))
525 tid = POLICER_CLASSIFY_TABLE_IP4;
526 else if (unformat (input, "ip6"))
527 tid = POLICER_CLASSIFY_TABLE_IP6;
528 else if (unformat (input, "l2"))
529 tid = POLICER_CLASSIFY_TABLE_L2;
538 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
540 u32 *r = va_arg (*va, u32 *);
543 if (unformat (input, "ip4"))
544 tid = FLOW_CLASSIFY_TABLE_IP4;
545 else if (unformat (input, "ip6"))
546 tid = FLOW_CLASSIFY_TABLE_IP6;
554 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
555 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
556 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
557 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
559 #if (VPP_API_TEST_BUILTIN==0)
561 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
563 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
564 mfib_itf_attribute_t attr;
567 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
569 if (unformat (input, mfib_itf_flag_long_names[attr]))
570 *iflags |= (1 << attr);
572 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
574 if (unformat (input, mfib_itf_flag_names[attr]))
575 *iflags |= (1 << attr);
578 return (old == *iflags ? 0 : 1);
582 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
584 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
585 mfib_entry_attribute_t attr;
588 FOR_EACH_MFIB_ATTRIBUTE (attr)
590 if (unformat (input, mfib_flag_long_names[attr]))
591 *eflags |= (1 << attr);
593 FOR_EACH_MFIB_ATTRIBUTE (attr)
595 if (unformat (input, mfib_flag_names[attr]))
596 *eflags |= (1 << attr);
599 return (old == *eflags ? 0 : 1);
603 format_ip4_address (u8 * s, va_list * args)
605 u8 *a = va_arg (*args, u8 *);
606 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
610 format_ip6_address (u8 * s, va_list * args)
612 ip6_address_t *a = va_arg (*args, ip6_address_t *);
613 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
615 i_max_n_zero = ARRAY_LEN (a->as_u16);
617 i_first_zero = i_max_n_zero;
619 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
621 u32 is_zero = a->as_u16[i] == 0;
622 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
628 if ((!is_zero && n_zeros > max_n_zeros)
629 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
631 i_max_n_zero = i_first_zero;
632 max_n_zeros = n_zeros;
633 i_first_zero = ARRAY_LEN (a->as_u16);
638 last_double_colon = 0;
639 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
641 if (i == i_max_n_zero && max_n_zeros > 1)
643 s = format (s, "::");
644 i += max_n_zeros - 1;
645 last_double_colon = 1;
649 s = format (s, "%s%x",
650 (last_double_colon || i == 0) ? "" : ":",
651 clib_net_to_host_u16 (a->as_u16[i]));
652 last_double_colon = 0;
659 /* Format an IP46 address. */
661 format_ip46_address (u8 * s, va_list * args)
663 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
664 ip46_type_t type = va_arg (*args, ip46_type_t);
670 is_ip4 = ip46_address_is_ip4 (ip46);
681 format (s, "%U", format_ip4_address, &ip46->ip4) :
682 format (s, "%U", format_ip6_address, &ip46->ip6);
686 format_ethernet_address (u8 * s, va_list * args)
688 u8 *a = va_arg (*args, u8 *);
690 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
691 a[0], a[1], a[2], a[3], a[4], a[5]);
696 increment_v4_address (ip4_address_t * a)
700 v = ntohl (a->as_u32) + 1;
701 a->as_u32 = ntohl (v);
705 increment_v6_address (ip6_address_t * a)
709 v0 = clib_net_to_host_u64 (a->as_u64[0]);
710 v1 = clib_net_to_host_u64 (a->as_u64[1]);
715 a->as_u64[0] = clib_net_to_host_u64 (v0);
716 a->as_u64[1] = clib_net_to_host_u64 (v1);
720 increment_mac_address (u64 * mac)
724 tmp = clib_net_to_host_u64 (tmp);
725 tmp += 1 << 16; /* skip unused (least significant) octets */
726 tmp = clib_host_to_net_u64 (tmp);
730 static void vl_api_create_loopback_reply_t_handler
731 (vl_api_create_loopback_reply_t * mp)
733 vat_main_t *vam = &vat_main;
734 i32 retval = ntohl (mp->retval);
736 vam->retval = retval;
737 vam->regenerate_interface_table = 1;
738 vam->sw_if_index = ntohl (mp->sw_if_index);
739 vam->result_ready = 1;
742 static void vl_api_create_loopback_reply_t_handler_json
743 (vl_api_create_loopback_reply_t * mp)
745 vat_main_t *vam = &vat_main;
746 vat_json_node_t node;
748 vat_json_init_object (&node);
749 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
750 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
752 vat_json_print (vam->ofp, &node);
753 vat_json_free (&node);
754 vam->retval = ntohl (mp->retval);
755 vam->result_ready = 1;
758 static void vl_api_create_loopback_instance_reply_t_handler
759 (vl_api_create_loopback_instance_reply_t * mp)
761 vat_main_t *vam = &vat_main;
762 i32 retval = ntohl (mp->retval);
764 vam->retval = retval;
765 vam->regenerate_interface_table = 1;
766 vam->sw_if_index = ntohl (mp->sw_if_index);
767 vam->result_ready = 1;
770 static void vl_api_create_loopback_instance_reply_t_handler_json
771 (vl_api_create_loopback_instance_reply_t * mp)
773 vat_main_t *vam = &vat_main;
774 vat_json_node_t node;
776 vat_json_init_object (&node);
777 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
778 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
780 vat_json_print (vam->ofp, &node);
781 vat_json_free (&node);
782 vam->retval = ntohl (mp->retval);
783 vam->result_ready = 1;
786 static void vl_api_af_packet_create_reply_t_handler
787 (vl_api_af_packet_create_reply_t * mp)
789 vat_main_t *vam = &vat_main;
790 i32 retval = ntohl (mp->retval);
792 vam->retval = retval;
793 vam->regenerate_interface_table = 1;
794 vam->sw_if_index = ntohl (mp->sw_if_index);
795 vam->result_ready = 1;
798 static void vl_api_af_packet_create_reply_t_handler_json
799 (vl_api_af_packet_create_reply_t * mp)
801 vat_main_t *vam = &vat_main;
802 vat_json_node_t node;
804 vat_json_init_object (&node);
805 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
806 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
808 vat_json_print (vam->ofp, &node);
809 vat_json_free (&node);
811 vam->retval = ntohl (mp->retval);
812 vam->result_ready = 1;
815 static void vl_api_create_vlan_subif_reply_t_handler
816 (vl_api_create_vlan_subif_reply_t * mp)
818 vat_main_t *vam = &vat_main;
819 i32 retval = ntohl (mp->retval);
821 vam->retval = retval;
822 vam->regenerate_interface_table = 1;
823 vam->sw_if_index = ntohl (mp->sw_if_index);
824 vam->result_ready = 1;
827 static void vl_api_create_vlan_subif_reply_t_handler_json
828 (vl_api_create_vlan_subif_reply_t * mp)
830 vat_main_t *vam = &vat_main;
831 vat_json_node_t node;
833 vat_json_init_object (&node);
834 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
835 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
837 vat_json_print (vam->ofp, &node);
838 vat_json_free (&node);
840 vam->retval = ntohl (mp->retval);
841 vam->result_ready = 1;
844 static void vl_api_create_subif_reply_t_handler
845 (vl_api_create_subif_reply_t * mp)
847 vat_main_t *vam = &vat_main;
848 i32 retval = ntohl (mp->retval);
850 vam->retval = retval;
851 vam->regenerate_interface_table = 1;
852 vam->sw_if_index = ntohl (mp->sw_if_index);
853 vam->result_ready = 1;
856 static void vl_api_create_subif_reply_t_handler_json
857 (vl_api_create_subif_reply_t * mp)
859 vat_main_t *vam = &vat_main;
860 vat_json_node_t node;
862 vat_json_init_object (&node);
863 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
864 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
866 vat_json_print (vam->ofp, &node);
867 vat_json_free (&node);
869 vam->retval = ntohl (mp->retval);
870 vam->result_ready = 1;
873 static void vl_api_interface_name_renumber_reply_t_handler
874 (vl_api_interface_name_renumber_reply_t * mp)
876 vat_main_t *vam = &vat_main;
877 i32 retval = ntohl (mp->retval);
879 vam->retval = retval;
880 vam->regenerate_interface_table = 1;
881 vam->result_ready = 1;
884 static void vl_api_interface_name_renumber_reply_t_handler_json
885 (vl_api_interface_name_renumber_reply_t * mp)
887 vat_main_t *vam = &vat_main;
888 vat_json_node_t node;
890 vat_json_init_object (&node);
891 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
893 vat_json_print (vam->ofp, &node);
894 vat_json_free (&node);
896 vam->retval = ntohl (mp->retval);
897 vam->result_ready = 1;
901 * Special-case: build the interface table, maintain
902 * the next loopback sw_if_index vbl.
904 static void vl_api_sw_interface_details_t_handler
905 (vl_api_sw_interface_details_t * mp)
907 vat_main_t *vam = &vat_main;
908 u8 *s = format (0, "%s%c", mp->interface_name, 0);
910 hash_set_mem (vam->sw_if_index_by_interface_name, s,
911 ntohl (mp->sw_if_index));
913 /* In sub interface case, fill the sub interface table entry */
914 if (mp->sw_if_index != mp->sup_sw_if_index)
916 sw_interface_subif_t *sub = NULL;
918 vec_add2 (vam->sw_if_subif_table, sub, 1);
920 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
921 strncpy ((char *) sub->interface_name, (char *) s,
922 vec_len (sub->interface_name));
923 sub->sw_if_index = ntohl (mp->sw_if_index);
924 sub->sub_id = ntohl (mp->sub_id);
926 sub->sub_dot1ad = mp->sub_dot1ad;
927 sub->sub_number_of_tags = mp->sub_number_of_tags;
928 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
929 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
930 sub->sub_exact_match = mp->sub_exact_match;
931 sub->sub_default = mp->sub_default;
932 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
933 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
935 /* vlan tag rewrite */
936 sub->vtr_op = ntohl (mp->vtr_op);
937 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
938 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
939 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
943 static void vl_api_sw_interface_details_t_handler_json
944 (vl_api_sw_interface_details_t * mp)
946 vat_main_t *vam = &vat_main;
947 vat_json_node_t *node = NULL;
949 if (VAT_JSON_ARRAY != vam->json_tree.type)
951 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
952 vat_json_init_array (&vam->json_tree);
954 node = vat_json_array_add (&vam->json_tree);
956 vat_json_init_object (node);
957 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
958 vat_json_object_add_uint (node, "sup_sw_if_index",
959 ntohl (mp->sup_sw_if_index));
960 vat_json_object_add_uint (node, "l2_address_length",
961 ntohl (mp->l2_address_length));
962 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
963 sizeof (mp->l2_address));
964 vat_json_object_add_string_copy (node, "interface_name",
966 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
967 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
968 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
969 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
970 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
971 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
972 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
973 vat_json_object_add_uint (node, "sub_number_of_tags",
974 mp->sub_number_of_tags);
975 vat_json_object_add_uint (node, "sub_outer_vlan_id",
976 ntohs (mp->sub_outer_vlan_id));
977 vat_json_object_add_uint (node, "sub_inner_vlan_id",
978 ntohs (mp->sub_inner_vlan_id));
979 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
980 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
981 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
982 mp->sub_outer_vlan_id_any);
983 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
984 mp->sub_inner_vlan_id_any);
985 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
986 vat_json_object_add_uint (node, "vtr_push_dot1q",
987 ntohl (mp->vtr_push_dot1q));
988 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
989 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
992 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
994 format_ethernet_address,
996 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
998 format_ethernet_address,
1000 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1001 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1005 #if VPP_API_TEST_BUILTIN == 0
1006 static void vl_api_sw_interface_event_t_handler
1007 (vl_api_sw_interface_event_t * mp)
1009 vat_main_t *vam = &vat_main;
1010 if (vam->interface_event_display)
1011 errmsg ("interface flags: sw_if_index %d %s %s",
1012 ntohl (mp->sw_if_index),
1013 mp->admin_up_down ? "admin-up" : "admin-down",
1014 mp->link_up_down ? "link-up" : "link-down");
1018 static void vl_api_sw_interface_event_t_handler_json
1019 (vl_api_sw_interface_event_t * mp)
1021 /* JSON output not supported */
1025 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1027 vat_main_t *vam = &vat_main;
1028 i32 retval = ntohl (mp->retval);
1030 vam->retval = retval;
1031 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1032 vam->result_ready = 1;
1036 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1038 vat_main_t *vam = &vat_main;
1039 vat_json_node_t node;
1040 api_main_t *am = &api_main;
1044 vat_json_init_object (&node);
1045 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1046 vat_json_object_add_uint (&node, "reply_in_shmem",
1047 ntohl (mp->reply_in_shmem));
1048 /* Toss the shared-memory original... */
1049 pthread_mutex_lock (&am->vlib_rp->mutex);
1050 oldheap = svm_push_data_heap (am->vlib_rp);
1052 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1055 svm_pop_heap (oldheap);
1056 pthread_mutex_unlock (&am->vlib_rp->mutex);
1058 vat_json_print (vam->ofp, &node);
1059 vat_json_free (&node);
1061 vam->retval = ntohl (mp->retval);
1062 vam->result_ready = 1;
1066 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1068 vat_main_t *vam = &vat_main;
1069 i32 retval = ntohl (mp->retval);
1070 u32 length = ntohl (mp->length);
1072 vec_reset_length (vam->cmd_reply);
1074 vam->retval = retval;
1077 vec_validate (vam->cmd_reply, length);
1078 clib_memcpy ((char *) (vam->cmd_reply), mp->reply, length);
1079 vam->cmd_reply[length] = 0;
1081 vam->result_ready = 1;
1085 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1087 vat_main_t *vam = &vat_main;
1088 vat_json_node_t node;
1090 vec_reset_length (vam->cmd_reply);
1092 vat_json_init_object (&node);
1093 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1094 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1096 vat_json_print (vam->ofp, &node);
1097 vat_json_free (&node);
1099 vam->retval = ntohl (mp->retval);
1100 vam->result_ready = 1;
1103 static void vl_api_classify_add_del_table_reply_t_handler
1104 (vl_api_classify_add_del_table_reply_t * mp)
1106 vat_main_t *vam = &vat_main;
1107 i32 retval = ntohl (mp->retval);
1108 if (vam->async_mode)
1110 vam->async_errors += (retval < 0);
1114 vam->retval = retval;
1116 ((mp->new_table_index != 0xFFFFFFFF) ||
1117 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1118 (mp->match_n_vectors != 0xFFFFFFFF)))
1120 * Note: this is just barely thread-safe, depends on
1121 * the main thread spinning waiting for an answer...
1123 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1124 ntohl (mp->new_table_index),
1125 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1126 vam->result_ready = 1;
1130 static void vl_api_classify_add_del_table_reply_t_handler_json
1131 (vl_api_classify_add_del_table_reply_t * mp)
1133 vat_main_t *vam = &vat_main;
1134 vat_json_node_t node;
1136 vat_json_init_object (&node);
1137 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1138 vat_json_object_add_uint (&node, "new_table_index",
1139 ntohl (mp->new_table_index));
1140 vat_json_object_add_uint (&node, "skip_n_vectors",
1141 ntohl (mp->skip_n_vectors));
1142 vat_json_object_add_uint (&node, "match_n_vectors",
1143 ntohl (mp->match_n_vectors));
1145 vat_json_print (vam->ofp, &node);
1146 vat_json_free (&node);
1148 vam->retval = ntohl (mp->retval);
1149 vam->result_ready = 1;
1152 static void vl_api_get_node_index_reply_t_handler
1153 (vl_api_get_node_index_reply_t * mp)
1155 vat_main_t *vam = &vat_main;
1156 i32 retval = ntohl (mp->retval);
1157 if (vam->async_mode)
1159 vam->async_errors += (retval < 0);
1163 vam->retval = retval;
1165 errmsg ("node index %d", ntohl (mp->node_index));
1166 vam->result_ready = 1;
1170 static void vl_api_get_node_index_reply_t_handler_json
1171 (vl_api_get_node_index_reply_t * mp)
1173 vat_main_t *vam = &vat_main;
1174 vat_json_node_t node;
1176 vat_json_init_object (&node);
1177 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1178 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1180 vat_json_print (vam->ofp, &node);
1181 vat_json_free (&node);
1183 vam->retval = ntohl (mp->retval);
1184 vam->result_ready = 1;
1187 static void vl_api_get_next_index_reply_t_handler
1188 (vl_api_get_next_index_reply_t * mp)
1190 vat_main_t *vam = &vat_main;
1191 i32 retval = ntohl (mp->retval);
1192 if (vam->async_mode)
1194 vam->async_errors += (retval < 0);
1198 vam->retval = retval;
1200 errmsg ("next node index %d", ntohl (mp->next_index));
1201 vam->result_ready = 1;
1205 static void vl_api_get_next_index_reply_t_handler_json
1206 (vl_api_get_next_index_reply_t * mp)
1208 vat_main_t *vam = &vat_main;
1209 vat_json_node_t node;
1211 vat_json_init_object (&node);
1212 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1213 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1215 vat_json_print (vam->ofp, &node);
1216 vat_json_free (&node);
1218 vam->retval = ntohl (mp->retval);
1219 vam->result_ready = 1;
1222 static void vl_api_add_node_next_reply_t_handler
1223 (vl_api_add_node_next_reply_t * mp)
1225 vat_main_t *vam = &vat_main;
1226 i32 retval = ntohl (mp->retval);
1227 if (vam->async_mode)
1229 vam->async_errors += (retval < 0);
1233 vam->retval = retval;
1235 errmsg ("next index %d", ntohl (mp->next_index));
1236 vam->result_ready = 1;
1240 static void vl_api_add_node_next_reply_t_handler_json
1241 (vl_api_add_node_next_reply_t * mp)
1243 vat_main_t *vam = &vat_main;
1244 vat_json_node_t node;
1246 vat_json_init_object (&node);
1247 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1248 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1250 vat_json_print (vam->ofp, &node);
1251 vat_json_free (&node);
1253 vam->retval = ntohl (mp->retval);
1254 vam->result_ready = 1;
1257 static void vl_api_show_version_reply_t_handler
1258 (vl_api_show_version_reply_t * mp)
1260 vat_main_t *vam = &vat_main;
1261 i32 retval = ntohl (mp->retval);
1265 errmsg (" program: %s", mp->program);
1266 errmsg (" version: %s", mp->version);
1267 errmsg (" build date: %s", mp->build_date);
1268 errmsg ("build directory: %s", mp->build_directory);
1270 vam->retval = retval;
1271 vam->result_ready = 1;
1274 static void vl_api_show_version_reply_t_handler_json
1275 (vl_api_show_version_reply_t * mp)
1277 vat_main_t *vam = &vat_main;
1278 vat_json_node_t node;
1280 vat_json_init_object (&node);
1281 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1282 vat_json_object_add_string_copy (&node, "program", mp->program);
1283 vat_json_object_add_string_copy (&node, "version", mp->version);
1284 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1285 vat_json_object_add_string_copy (&node, "build_directory",
1286 mp->build_directory);
1288 vat_json_print (vam->ofp, &node);
1289 vat_json_free (&node);
1291 vam->retval = ntohl (mp->retval);
1292 vam->result_ready = 1;
1296 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1298 u32 sw_if_index = ntohl (mp->sw_if_index);
1299 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1300 mp->mac_ip ? "mac/ip binding" : "address resolution",
1301 ntohl (mp->pid), format_ip4_address, &mp->address,
1302 format_ethernet_address, mp->new_mac, sw_if_index);
1306 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1308 /* JSON output not supported */
1312 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1314 u32 sw_if_index = ntohl (mp->sw_if_index);
1315 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1316 mp->mac_ip ? "mac/ip binding" : "address resolution",
1317 ntohl (mp->pid), format_ip6_address, mp->address,
1318 format_ethernet_address, mp->new_mac, sw_if_index);
1322 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1324 /* JSON output not supported */
1328 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1330 u32 n_macs = ntohl (mp->n_macs);
1331 errmsg ("L2MAC event recived with pid %d cl-idx %d for %d macs: \n",
1332 ntohl (mp->pid), mp->client_index, n_macs);
1334 for (i = 0; i < n_macs; i++)
1336 vl_api_mac_entry_t *mac = &mp->mac[i];
1337 errmsg (" [%d] sw_if_index %d mac_addr %U is_del %d \n",
1338 i + 1, ntohl (mac->sw_if_index),
1339 format_ethernet_address, mac->mac_addr, mac->is_del);
1346 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1348 /* JSON output not supported */
1351 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1352 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1355 * Special-case: build the bridge domain table, maintain
1356 * the next bd id vbl.
1358 static void vl_api_bridge_domain_details_t_handler
1359 (vl_api_bridge_domain_details_t * mp)
1361 vat_main_t *vam = &vat_main;
1362 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1365 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1366 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1368 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1369 ntohl (mp->bd_id), mp->learn, mp->forward,
1370 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1374 vl_api_bridge_domain_sw_if_t *sw_ifs;
1375 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1378 sw_ifs = mp->sw_if_details;
1379 for (i = 0; i < n_sw_ifs; i++)
1385 sw_if_index = ntohl (sw_ifs->sw_if_index);
1388 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1390 if ((u32) p->value[0] == sw_if_index)
1392 sw_if_name = (u8 *)(p->key);
1397 print (vam->ofp, "%7d %3d %s", sw_if_index,
1398 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1399 "sw_if_index not found!");
1406 static void vl_api_bridge_domain_details_t_handler_json
1407 (vl_api_bridge_domain_details_t * mp)
1409 vat_main_t *vam = &vat_main;
1410 vat_json_node_t *node, *array = NULL;
1411 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1413 if (VAT_JSON_ARRAY != vam->json_tree.type)
1415 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1416 vat_json_init_array (&vam->json_tree);
1418 node = vat_json_array_add (&vam->json_tree);
1420 vat_json_init_object (node);
1421 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1422 vat_json_object_add_uint (node, "flood", mp->flood);
1423 vat_json_object_add_uint (node, "forward", mp->forward);
1424 vat_json_object_add_uint (node, "learn", mp->learn);
1425 vat_json_object_add_uint (node, "bvi_sw_if_index",
1426 ntohl (mp->bvi_sw_if_index));
1427 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1428 array = vat_json_object_add (node, "sw_if");
1429 vat_json_init_array (array);
1435 vl_api_bridge_domain_sw_if_t *sw_ifs;
1438 sw_ifs = mp->sw_if_details;
1439 for (i = 0; i < n_sw_ifs; i++)
1441 node = vat_json_array_add (array);
1442 vat_json_init_object (node);
1443 vat_json_object_add_uint (node, "sw_if_index",
1444 ntohl (sw_ifs->sw_if_index));
1445 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1451 static void vl_api_control_ping_reply_t_handler
1452 (vl_api_control_ping_reply_t * mp)
1454 vat_main_t *vam = &vat_main;
1455 i32 retval = ntohl (mp->retval);
1456 if (vam->async_mode)
1458 vam->async_errors += (retval < 0);
1462 vam->retval = retval;
1463 vam->result_ready = 1;
1465 vam->socket_client_main.control_pings_outstanding--;
1468 static void vl_api_control_ping_reply_t_handler_json
1469 (vl_api_control_ping_reply_t * mp)
1471 vat_main_t *vam = &vat_main;
1472 i32 retval = ntohl (mp->retval);
1474 if (VAT_JSON_NONE != vam->json_tree.type)
1476 vat_json_print (vam->ofp, &vam->json_tree);
1477 vat_json_free (&vam->json_tree);
1478 vam->json_tree.type = VAT_JSON_NONE;
1483 vat_json_init_array (&vam->json_tree);
1484 vat_json_print (vam->ofp, &vam->json_tree);
1485 vam->json_tree.type = VAT_JSON_NONE;
1488 vam->retval = retval;
1489 vam->result_ready = 1;
1493 vl_api_bridge_domain_set_mac_age_reply_t_handler
1494 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1496 vat_main_t *vam = &vat_main;
1497 i32 retval = ntohl (mp->retval);
1498 if (vam->async_mode)
1500 vam->async_errors += (retval < 0);
1504 vam->retval = retval;
1505 vam->result_ready = 1;
1509 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1510 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1512 vat_main_t *vam = &vat_main;
1513 vat_json_node_t node;
1515 vat_json_init_object (&node);
1516 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1518 vat_json_print (vam->ofp, &node);
1519 vat_json_free (&node);
1521 vam->retval = ntohl (mp->retval);
1522 vam->result_ready = 1;
1526 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1528 vat_main_t *vam = &vat_main;
1529 i32 retval = ntohl (mp->retval);
1530 if (vam->async_mode)
1532 vam->async_errors += (retval < 0);
1536 vam->retval = retval;
1537 vam->result_ready = 1;
1541 static void vl_api_l2_flags_reply_t_handler_json
1542 (vl_api_l2_flags_reply_t * mp)
1544 vat_main_t *vam = &vat_main;
1545 vat_json_node_t node;
1547 vat_json_init_object (&node);
1548 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1549 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1550 ntohl (mp->resulting_feature_bitmap));
1552 vat_json_print (vam->ofp, &node);
1553 vat_json_free (&node);
1555 vam->retval = ntohl (mp->retval);
1556 vam->result_ready = 1;
1559 static void vl_api_bridge_flags_reply_t_handler
1560 (vl_api_bridge_flags_reply_t * mp)
1562 vat_main_t *vam = &vat_main;
1563 i32 retval = ntohl (mp->retval);
1564 if (vam->async_mode)
1566 vam->async_errors += (retval < 0);
1570 vam->retval = retval;
1571 vam->result_ready = 1;
1575 static void vl_api_bridge_flags_reply_t_handler_json
1576 (vl_api_bridge_flags_reply_t * mp)
1578 vat_main_t *vam = &vat_main;
1579 vat_json_node_t node;
1581 vat_json_init_object (&node);
1582 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1583 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1584 ntohl (mp->resulting_feature_bitmap));
1586 vat_json_print (vam->ofp, &node);
1587 vat_json_free (&node);
1589 vam->retval = ntohl (mp->retval);
1590 vam->result_ready = 1;
1593 static void vl_api_tap_connect_reply_t_handler
1594 (vl_api_tap_connect_reply_t * mp)
1596 vat_main_t *vam = &vat_main;
1597 i32 retval = ntohl (mp->retval);
1598 if (vam->async_mode)
1600 vam->async_errors += (retval < 0);
1604 vam->retval = retval;
1605 vam->sw_if_index = ntohl (mp->sw_if_index);
1606 vam->result_ready = 1;
1611 static void vl_api_tap_connect_reply_t_handler_json
1612 (vl_api_tap_connect_reply_t * mp)
1614 vat_main_t *vam = &vat_main;
1615 vat_json_node_t node;
1617 vat_json_init_object (&node);
1618 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1619 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1621 vat_json_print (vam->ofp, &node);
1622 vat_json_free (&node);
1624 vam->retval = ntohl (mp->retval);
1625 vam->result_ready = 1;
1630 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1632 vat_main_t *vam = &vat_main;
1633 i32 retval = ntohl (mp->retval);
1634 if (vam->async_mode)
1636 vam->async_errors += (retval < 0);
1640 vam->retval = retval;
1641 vam->sw_if_index = ntohl (mp->sw_if_index);
1642 vam->result_ready = 1;
1646 static void vl_api_tap_modify_reply_t_handler_json
1647 (vl_api_tap_modify_reply_t * mp)
1649 vat_main_t *vam = &vat_main;
1650 vat_json_node_t node;
1652 vat_json_init_object (&node);
1653 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1654 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1656 vat_json_print (vam->ofp, &node);
1657 vat_json_free (&node);
1659 vam->retval = ntohl (mp->retval);
1660 vam->result_ready = 1;
1664 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1666 vat_main_t *vam = &vat_main;
1667 i32 retval = ntohl (mp->retval);
1668 if (vam->async_mode)
1670 vam->async_errors += (retval < 0);
1674 vam->retval = retval;
1675 vam->result_ready = 1;
1679 static void vl_api_tap_delete_reply_t_handler_json
1680 (vl_api_tap_delete_reply_t * mp)
1682 vat_main_t *vam = &vat_main;
1683 vat_json_node_t node;
1685 vat_json_init_object (&node);
1686 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1688 vat_json_print (vam->ofp, &node);
1689 vat_json_free (&node);
1691 vam->retval = ntohl (mp->retval);
1692 vam->result_ready = 1;
1695 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1696 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1698 vat_main_t *vam = &vat_main;
1699 i32 retval = ntohl (mp->retval);
1700 if (vam->async_mode)
1702 vam->async_errors += (retval < 0);
1706 vam->retval = retval;
1707 vam->result_ready = 1;
1711 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1712 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1714 vat_main_t *vam = &vat_main;
1715 vat_json_node_t node;
1717 vat_json_init_object (&node);
1718 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1719 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1720 ntohl (mp->sw_if_index));
1722 vat_json_print (vam->ofp, &node);
1723 vat_json_free (&node);
1725 vam->retval = ntohl (mp->retval);
1726 vam->result_ready = 1;
1729 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1730 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1732 vat_main_t *vam = &vat_main;
1733 i32 retval = ntohl (mp->retval);
1734 if (vam->async_mode)
1736 vam->async_errors += (retval < 0);
1740 vam->retval = retval;
1741 vam->sw_if_index = ntohl (mp->sw_if_index);
1742 vam->result_ready = 1;
1746 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1747 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1749 vat_main_t *vam = &vat_main;
1750 vat_json_node_t node;
1752 vat_json_init_object (&node);
1753 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1754 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1756 vat_json_print (vam->ofp, &node);
1757 vat_json_free (&node);
1759 vam->retval = ntohl (mp->retval);
1760 vam->result_ready = 1;
1763 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
1764 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1766 vat_main_t *vam = &vat_main;
1767 i32 retval = ntohl (mp->retval);
1768 if (vam->async_mode)
1770 vam->async_errors += (retval < 0);
1774 vam->retval = retval;
1775 vam->result_ready = 1;
1779 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
1780 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1782 vat_main_t *vam = &vat_main;
1783 vat_json_node_t node;
1785 vat_json_init_object (&node);
1786 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1787 vat_json_object_add_uint (&node, "fwd_entry_index",
1788 clib_net_to_host_u32 (mp->fwd_entry_index));
1790 vat_json_print (vam->ofp, &node);
1791 vat_json_free (&node);
1793 vam->retval = ntohl (mp->retval);
1794 vam->result_ready = 1;
1798 format_lisp_transport_protocol (u8 * s, va_list * args)
1800 u32 proto = va_arg (*args, u32);
1805 return format (s, "udp");
1807 return format (s, "api");
1814 static void vl_api_one_get_transport_protocol_reply_t_handler
1815 (vl_api_one_get_transport_protocol_reply_t * mp)
1817 vat_main_t *vam = &vat_main;
1818 i32 retval = ntohl (mp->retval);
1819 if (vam->async_mode)
1821 vam->async_errors += (retval < 0);
1825 u32 proto = mp->protocol;
1826 print (vam->ofp, "Transport protocol: %U",
1827 format_lisp_transport_protocol, proto);
1828 vam->retval = retval;
1829 vam->result_ready = 1;
1833 static void vl_api_one_get_transport_protocol_reply_t_handler_json
1834 (vl_api_one_get_transport_protocol_reply_t * mp)
1836 vat_main_t *vam = &vat_main;
1837 vat_json_node_t node;
1840 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
1843 vat_json_init_object (&node);
1844 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1845 vat_json_object_add_string_copy (&node, "transport-protocol", s);
1848 vat_json_print (vam->ofp, &node);
1849 vat_json_free (&node);
1851 vam->retval = ntohl (mp->retval);
1852 vam->result_ready = 1;
1855 static void vl_api_one_add_del_locator_set_reply_t_handler
1856 (vl_api_one_add_del_locator_set_reply_t * mp)
1858 vat_main_t *vam = &vat_main;
1859 i32 retval = ntohl (mp->retval);
1860 if (vam->async_mode)
1862 vam->async_errors += (retval < 0);
1866 vam->retval = retval;
1867 vam->result_ready = 1;
1871 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1872 (vl_api_one_add_del_locator_set_reply_t * mp)
1874 vat_main_t *vam = &vat_main;
1875 vat_json_node_t node;
1877 vat_json_init_object (&node);
1878 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1879 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1881 vat_json_print (vam->ofp, &node);
1882 vat_json_free (&node);
1884 vam->retval = ntohl (mp->retval);
1885 vam->result_ready = 1;
1888 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1889 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1891 vat_main_t *vam = &vat_main;
1892 i32 retval = ntohl (mp->retval);
1893 if (vam->async_mode)
1895 vam->async_errors += (retval < 0);
1899 vam->retval = retval;
1900 vam->sw_if_index = ntohl (mp->sw_if_index);
1901 vam->result_ready = 1;
1905 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1906 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1908 vat_main_t *vam = &vat_main;
1909 vat_json_node_t node;
1911 vat_json_init_object (&node);
1912 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1913 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1915 vat_json_print (vam->ofp, &node);
1916 vat_json_free (&node);
1918 vam->retval = ntohl (mp->retval);
1919 vam->result_ready = 1;
1922 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
1923 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1925 vat_main_t *vam = &vat_main;
1926 i32 retval = ntohl (mp->retval);
1927 if (vam->async_mode)
1929 vam->async_errors += (retval < 0);
1933 vam->retval = retval;
1934 vam->sw_if_index = ntohl (mp->sw_if_index);
1935 vam->result_ready = 1;
1939 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
1940 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1942 vat_main_t *vam = &vat_main;
1943 vat_json_node_t node;
1945 vat_json_init_object (&node);
1946 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1947 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1949 vat_json_print (vam->ofp, &node);
1950 vat_json_free (&node);
1952 vam->retval = ntohl (mp->retval);
1953 vam->result_ready = 1;
1956 static void vl_api_gre_add_del_tunnel_reply_t_handler
1957 (vl_api_gre_add_del_tunnel_reply_t * mp)
1959 vat_main_t *vam = &vat_main;
1960 i32 retval = ntohl (mp->retval);
1961 if (vam->async_mode)
1963 vam->async_errors += (retval < 0);
1967 vam->retval = retval;
1968 vam->sw_if_index = ntohl (mp->sw_if_index);
1969 vam->result_ready = 1;
1973 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1974 (vl_api_gre_add_del_tunnel_reply_t * mp)
1976 vat_main_t *vam = &vat_main;
1977 vat_json_node_t node;
1979 vat_json_init_object (&node);
1980 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1981 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1983 vat_json_print (vam->ofp, &node);
1984 vat_json_free (&node);
1986 vam->retval = ntohl (mp->retval);
1987 vam->result_ready = 1;
1990 static void vl_api_create_vhost_user_if_reply_t_handler
1991 (vl_api_create_vhost_user_if_reply_t * mp)
1993 vat_main_t *vam = &vat_main;
1994 i32 retval = ntohl (mp->retval);
1995 if (vam->async_mode)
1997 vam->async_errors += (retval < 0);
2001 vam->retval = retval;
2002 vam->sw_if_index = ntohl (mp->sw_if_index);
2003 vam->result_ready = 1;
2007 static void vl_api_create_vhost_user_if_reply_t_handler_json
2008 (vl_api_create_vhost_user_if_reply_t * mp)
2010 vat_main_t *vam = &vat_main;
2011 vat_json_node_t node;
2013 vat_json_init_object (&node);
2014 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2015 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2017 vat_json_print (vam->ofp, &node);
2018 vat_json_free (&node);
2020 vam->retval = ntohl (mp->retval);
2021 vam->result_ready = 1;
2024 static clib_error_t *
2025 receive_fd_msg (int socket_fd, int *my_fd)
2028 char ctl[CMSG_SPACE (sizeof (int)) + CMSG_SPACE (sizeof (struct ucred))];
2029 struct msghdr mh = { 0 };
2030 struct iovec iov[1];
2032 struct ucred *cr = 0;
2033 struct cmsghdr *cmsg;
2034 pid_t pid __attribute__ ((unused));
2035 uid_t uid __attribute__ ((unused));
2036 gid_t gid __attribute__ ((unused));
2038 iov[0].iov_base = msgbuf;
2042 mh.msg_control = ctl;
2043 mh.msg_controllen = sizeof (ctl);
2045 memset (ctl, 0, sizeof (ctl));
2047 /* receive the incoming message */
2048 size = recvmsg (socket_fd, &mh, 0);
2051 return (size == 0) ? clib_error_return (0, "disconnected") :
2052 clib_error_return_unix (0, "recvmsg: malformed message (fd %d)",
2056 cmsg = CMSG_FIRSTHDR (&mh);
2059 if (cmsg->cmsg_level == SOL_SOCKET)
2061 if (cmsg->cmsg_type == SCM_CREDENTIALS)
2063 cr = (struct ucred *) CMSG_DATA (cmsg);
2068 else if (cmsg->cmsg_type == SCM_RIGHTS)
2070 clib_memcpy (my_fd, CMSG_DATA (cmsg), sizeof (int));
2073 cmsg = CMSG_NXTHDR (&mh, cmsg);
2078 static void vl_api_memfd_segment_create_reply_t_handler
2079 (vl_api_memfd_segment_create_reply_t * mp)
2081 /* Dont bother in the builtin version */
2082 #if VPP_API_TEST_BUILTIN == 0
2083 vat_main_t *vam = &vat_main;
2084 api_main_t *am = &api_main;
2085 socket_client_main_t *scm = &vam->socket_client_main;
2087 clib_error_t *error;
2088 memfd_private_t memfd;
2089 i32 retval = ntohl (mp->retval);
2093 error = receive_fd_msg (scm->socket_fd, &my_fd);
2100 memset (&memfd, 0, sizeof (memfd));
2103 vam->client_index_invalid = 1;
2105 retval = memfd_slave_init (&memfd);
2107 clib_warning ("WARNING: segment map returned %d", retval);
2109 /* Pivot to the memory client segment that vpp just created */
2111 am->vlib_rp = (void *) (memfd.requested_va + MMAP_PAGESIZE);
2113 am->shmem_hdr = (void *) am->vlib_rp->user_ctx;
2115 vl_client_install_client_message_handlers ();
2117 vl_client_connect_to_vlib_no_map ("pvt",
2119 32 /* input_queue_length */ );
2120 if (close (my_fd) < 0)
2121 clib_unix_warning ("close memfd fd pivot");
2122 vam->vl_input_queue = am->shmem_hdr->vl_input_queue;
2124 vl_socket_client_enable_disable (&vam->socket_client_main,
2125 0 /* disable socket */ );
2129 if (vam->async_mode)
2131 vam->async_errors += (retval < 0);
2135 vam->retval = retval;
2136 vam->result_ready = 1;
2141 static void vl_api_memfd_segment_create_reply_t_handler_json
2142 (vl_api_memfd_segment_create_reply_t * mp)
2144 clib_warning ("no");
2148 static void vl_api_ip_address_details_t_handler
2149 (vl_api_ip_address_details_t * mp)
2151 vat_main_t *vam = &vat_main;
2152 static ip_address_details_t empty_ip_address_details = { {0} };
2153 ip_address_details_t *address = NULL;
2154 ip_details_t *current_ip_details = NULL;
2155 ip_details_t *details = NULL;
2157 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2159 if (!details || vam->current_sw_if_index >= vec_len (details)
2160 || !details[vam->current_sw_if_index].present)
2162 errmsg ("ip address details arrived but not stored");
2163 errmsg ("ip_dump should be called first");
2167 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2169 #define addresses (current_ip_details->addr)
2171 vec_validate_init_empty (addresses, vec_len (addresses),
2172 empty_ip_address_details);
2174 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2176 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2177 address->prefix_length = mp->prefix_length;
2181 static void vl_api_ip_address_details_t_handler_json
2182 (vl_api_ip_address_details_t * mp)
2184 vat_main_t *vam = &vat_main;
2185 vat_json_node_t *node = NULL;
2186 struct in6_addr ip6;
2189 if (VAT_JSON_ARRAY != vam->json_tree.type)
2191 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2192 vat_json_init_array (&vam->json_tree);
2194 node = vat_json_array_add (&vam->json_tree);
2196 vat_json_init_object (node);
2199 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2200 vat_json_object_add_ip6 (node, "ip", ip6);
2204 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2205 vat_json_object_add_ip4 (node, "ip", ip4);
2207 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2211 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2213 vat_main_t *vam = &vat_main;
2214 static ip_details_t empty_ip_details = { 0 };
2215 ip_details_t *ip = NULL;
2216 u32 sw_if_index = ~0;
2218 sw_if_index = ntohl (mp->sw_if_index);
2220 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2221 sw_if_index, empty_ip_details);
2223 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2230 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2232 vat_main_t *vam = &vat_main;
2234 if (VAT_JSON_ARRAY != vam->json_tree.type)
2236 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2237 vat_json_init_array (&vam->json_tree);
2239 vat_json_array_add_uint (&vam->json_tree,
2240 clib_net_to_host_u32 (mp->sw_if_index));
2243 static void vl_api_map_domain_details_t_handler_json
2244 (vl_api_map_domain_details_t * mp)
2246 vat_json_node_t *node = NULL;
2247 vat_main_t *vam = &vat_main;
2248 struct in6_addr ip6;
2251 if (VAT_JSON_ARRAY != vam->json_tree.type)
2253 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2254 vat_json_init_array (&vam->json_tree);
2257 node = vat_json_array_add (&vam->json_tree);
2258 vat_json_init_object (node);
2260 vat_json_object_add_uint (node, "domain_index",
2261 clib_net_to_host_u32 (mp->domain_index));
2262 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2263 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2264 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2265 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2266 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2267 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2268 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2269 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2270 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2271 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2272 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2273 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2274 vat_json_object_add_uint (node, "flags", mp->flags);
2275 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2276 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2279 static void vl_api_map_domain_details_t_handler
2280 (vl_api_map_domain_details_t * mp)
2282 vat_main_t *vam = &vat_main;
2284 if (mp->is_translation)
2287 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2288 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2289 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2290 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2291 clib_net_to_host_u32 (mp->domain_index));
2296 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2297 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2298 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2299 format_ip6_address, mp->ip6_src,
2300 clib_net_to_host_u32 (mp->domain_index));
2302 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2303 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2304 mp->is_translation ? "map-t" : "");
2307 static void vl_api_map_rule_details_t_handler_json
2308 (vl_api_map_rule_details_t * mp)
2310 struct in6_addr ip6;
2311 vat_json_node_t *node = NULL;
2312 vat_main_t *vam = &vat_main;
2314 if (VAT_JSON_ARRAY != vam->json_tree.type)
2316 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2317 vat_json_init_array (&vam->json_tree);
2320 node = vat_json_array_add (&vam->json_tree);
2321 vat_json_init_object (node);
2323 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2324 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2325 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2329 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2331 vat_main_t *vam = &vat_main;
2332 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2333 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2337 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2339 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2340 "router_addr %U host_mac %U",
2341 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2342 format_ip4_address, &mp->host_address,
2343 format_ip4_address, &mp->router_address,
2344 format_ethernet_address, mp->host_mac);
2347 static void vl_api_dhcp_compl_event_t_handler_json
2348 (vl_api_dhcp_compl_event_t * mp)
2350 /* JSON output not supported */
2354 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2357 vat_main_t *vam = &vat_main;
2358 static u64 default_counter = 0;
2360 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2362 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2363 sw_if_index, default_counter);
2364 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2368 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2369 interface_counter_t counter)
2371 vat_main_t *vam = &vat_main;
2372 static interface_counter_t default_counter = { 0, };
2374 vec_validate_init_empty (vam->combined_interface_counters,
2375 vnet_counter_type, NULL);
2376 vec_validate_init_empty (vam->combined_interface_counters
2377 [vnet_counter_type], sw_if_index, default_counter);
2378 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2381 static void vl_api_vnet_interface_simple_counters_t_handler
2382 (vl_api_vnet_interface_simple_counters_t * mp)
2387 static void vl_api_vnet_interface_combined_counters_t_handler
2388 (vl_api_vnet_interface_combined_counters_t * mp)
2393 static void vl_api_vnet_interface_simple_counters_t_handler_json
2394 (vl_api_vnet_interface_simple_counters_t * mp)
2399 u32 first_sw_if_index;
2402 count = ntohl (mp->count);
2403 first_sw_if_index = ntohl (mp->first_sw_if_index);
2405 v_packets = (u64 *) & mp->data;
2406 for (i = 0; i < count; i++)
2408 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2409 set_simple_interface_counter (mp->vnet_counter_type,
2410 first_sw_if_index + i, packets);
2415 static void vl_api_vnet_interface_combined_counters_t_handler_json
2416 (vl_api_vnet_interface_combined_counters_t * mp)
2418 interface_counter_t counter;
2420 u32 first_sw_if_index;
2424 count = ntohl (mp->count);
2425 first_sw_if_index = ntohl (mp->first_sw_if_index);
2427 v = (vlib_counter_t *) & mp->data;
2428 for (i = 0; i < count; i++)
2431 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2433 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2434 set_combined_interface_counter (mp->vnet_counter_type,
2435 first_sw_if_index + i, counter);
2441 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2443 vat_main_t *vam = &vat_main;
2446 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2448 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2457 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2459 vat_main_t *vam = &vat_main;
2462 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2464 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2472 static void vl_api_vnet_ip4_fib_counters_t_handler
2473 (vl_api_vnet_ip4_fib_counters_t * mp)
2478 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2479 (vl_api_vnet_ip4_fib_counters_t * mp)
2481 vat_main_t *vam = &vat_main;
2482 vl_api_ip4_fib_counter_t *v;
2483 ip4_fib_counter_t *counter;
2490 vrf_id = ntohl (mp->vrf_id);
2491 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2492 if (~0 == vrf_index)
2494 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2495 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2496 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2497 vec_validate (vam->ip4_fib_counters, vrf_index);
2498 vam->ip4_fib_counters[vrf_index] = NULL;
2501 vec_free (vam->ip4_fib_counters[vrf_index]);
2502 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2503 count = ntohl (mp->count);
2504 for (i = 0; i < count; i++)
2506 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2507 counter = &vam->ip4_fib_counters[vrf_index][i];
2508 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2509 counter->address = ip4;
2510 counter->address_length = v->address_length;
2511 counter->packets = clib_net_to_host_u64 (v->packets);
2512 counter->bytes = clib_net_to_host_u64 (v->bytes);
2517 static void vl_api_vnet_ip4_nbr_counters_t_handler
2518 (vl_api_vnet_ip4_nbr_counters_t * mp)
2523 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2524 (vl_api_vnet_ip4_nbr_counters_t * mp)
2526 vat_main_t *vam = &vat_main;
2527 vl_api_ip4_nbr_counter_t *v;
2528 ip4_nbr_counter_t *counter;
2533 sw_if_index = ntohl (mp->sw_if_index);
2534 count = ntohl (mp->count);
2535 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2538 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2540 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2541 for (i = 0; i < count; i++)
2543 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2544 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2545 counter->address.s_addr = v->address;
2546 counter->packets = clib_net_to_host_u64 (v->packets);
2547 counter->bytes = clib_net_to_host_u64 (v->bytes);
2548 counter->linkt = v->link_type;
2553 static void vl_api_vnet_ip6_fib_counters_t_handler
2554 (vl_api_vnet_ip6_fib_counters_t * mp)
2559 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2560 (vl_api_vnet_ip6_fib_counters_t * mp)
2562 vat_main_t *vam = &vat_main;
2563 vl_api_ip6_fib_counter_t *v;
2564 ip6_fib_counter_t *counter;
2565 struct in6_addr ip6;
2571 vrf_id = ntohl (mp->vrf_id);
2572 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2573 if (~0 == vrf_index)
2575 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2576 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2577 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2578 vec_validate (vam->ip6_fib_counters, vrf_index);
2579 vam->ip6_fib_counters[vrf_index] = NULL;
2582 vec_free (vam->ip6_fib_counters[vrf_index]);
2583 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2584 count = ntohl (mp->count);
2585 for (i = 0; i < count; i++)
2587 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2588 counter = &vam->ip6_fib_counters[vrf_index][i];
2589 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2590 counter->address = ip6;
2591 counter->address_length = v->address_length;
2592 counter->packets = clib_net_to_host_u64 (v->packets);
2593 counter->bytes = clib_net_to_host_u64 (v->bytes);
2598 static void vl_api_vnet_ip6_nbr_counters_t_handler
2599 (vl_api_vnet_ip6_nbr_counters_t * mp)
2604 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2605 (vl_api_vnet_ip6_nbr_counters_t * mp)
2607 vat_main_t *vam = &vat_main;
2608 vl_api_ip6_nbr_counter_t *v;
2609 ip6_nbr_counter_t *counter;
2610 struct in6_addr ip6;
2615 sw_if_index = ntohl (mp->sw_if_index);
2616 count = ntohl (mp->count);
2617 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2620 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2622 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2623 for (i = 0; i < count; i++)
2625 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2626 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2627 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2628 counter->address = ip6;
2629 counter->packets = clib_net_to_host_u64 (v->packets);
2630 counter->bytes = clib_net_to_host_u64 (v->bytes);
2635 static void vl_api_get_first_msg_id_reply_t_handler
2636 (vl_api_get_first_msg_id_reply_t * mp)
2638 vat_main_t *vam = &vat_main;
2639 i32 retval = ntohl (mp->retval);
2641 if (vam->async_mode)
2643 vam->async_errors += (retval < 0);
2647 vam->retval = retval;
2648 vam->result_ready = 1;
2652 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2656 static void vl_api_get_first_msg_id_reply_t_handler_json
2657 (vl_api_get_first_msg_id_reply_t * mp)
2659 vat_main_t *vam = &vat_main;
2660 vat_json_node_t node;
2662 vat_json_init_object (&node);
2663 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2664 vat_json_object_add_uint (&node, "first_msg_id",
2665 (uint) ntohs (mp->first_msg_id));
2667 vat_json_print (vam->ofp, &node);
2668 vat_json_free (&node);
2670 vam->retval = ntohl (mp->retval);
2671 vam->result_ready = 1;
2674 static void vl_api_get_node_graph_reply_t_handler
2675 (vl_api_get_node_graph_reply_t * mp)
2677 vat_main_t *vam = &vat_main;
2678 api_main_t *am = &api_main;
2679 i32 retval = ntohl (mp->retval);
2680 u8 *pvt_copy, *reply;
2685 if (vam->async_mode)
2687 vam->async_errors += (retval < 0);
2691 vam->retval = retval;
2692 vam->result_ready = 1;
2695 /* "Should never happen..." */
2699 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2700 pvt_copy = vec_dup (reply);
2702 /* Toss the shared-memory original... */
2703 pthread_mutex_lock (&am->vlib_rp->mutex);
2704 oldheap = svm_push_data_heap (am->vlib_rp);
2708 svm_pop_heap (oldheap);
2709 pthread_mutex_unlock (&am->vlib_rp->mutex);
2711 if (vam->graph_nodes)
2713 hash_free (vam->graph_node_index_by_name);
2715 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2717 node = vam->graph_nodes[i];
2718 vec_free (node->name);
2719 vec_free (node->next_nodes);
2722 vec_free (vam->graph_nodes);
2725 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2726 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2727 vec_free (pvt_copy);
2729 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2731 node = vam->graph_nodes[i];
2732 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2736 static void vl_api_get_node_graph_reply_t_handler_json
2737 (vl_api_get_node_graph_reply_t * mp)
2739 vat_main_t *vam = &vat_main;
2740 api_main_t *am = &api_main;
2742 vat_json_node_t node;
2745 /* $$$$ make this real? */
2746 vat_json_init_object (&node);
2747 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2748 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2750 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2752 /* Toss the shared-memory original... */
2753 pthread_mutex_lock (&am->vlib_rp->mutex);
2754 oldheap = svm_push_data_heap (am->vlib_rp);
2758 svm_pop_heap (oldheap);
2759 pthread_mutex_unlock (&am->vlib_rp->mutex);
2761 vat_json_print (vam->ofp, &node);
2762 vat_json_free (&node);
2764 vam->retval = ntohl (mp->retval);
2765 vam->result_ready = 1;
2769 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2771 vat_main_t *vam = &vat_main;
2776 s = format (s, "%=16d%=16d%=16d",
2777 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2781 s = format (s, "%=16U%=16d%=16d",
2782 mp->is_ipv6 ? format_ip6_address :
2784 mp->ip_address, mp->priority, mp->weight);
2787 print (vam->ofp, "%v", s);
2792 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2794 vat_main_t *vam = &vat_main;
2795 vat_json_node_t *node = NULL;
2796 struct in6_addr ip6;
2799 if (VAT_JSON_ARRAY != vam->json_tree.type)
2801 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2802 vat_json_init_array (&vam->json_tree);
2804 node = vat_json_array_add (&vam->json_tree);
2805 vat_json_init_object (node);
2807 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2808 vat_json_object_add_uint (node, "priority", mp->priority);
2809 vat_json_object_add_uint (node, "weight", mp->weight);
2812 vat_json_object_add_uint (node, "sw_if_index",
2813 clib_net_to_host_u32 (mp->sw_if_index));
2818 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2819 vat_json_object_add_ip6 (node, "address", ip6);
2823 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2824 vat_json_object_add_ip4 (node, "address", ip4);
2830 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2833 vat_main_t *vam = &vat_main;
2836 ls_name = format (0, "%s", mp->ls_name);
2838 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2844 vl_api_one_locator_set_details_t_handler_json
2845 (vl_api_one_locator_set_details_t * mp)
2847 vat_main_t *vam = &vat_main;
2848 vat_json_node_t *node = 0;
2851 ls_name = format (0, "%s", mp->ls_name);
2852 vec_add1 (ls_name, 0);
2854 if (VAT_JSON_ARRAY != vam->json_tree.type)
2856 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2857 vat_json_init_array (&vam->json_tree);
2859 node = vat_json_array_add (&vam->json_tree);
2861 vat_json_init_object (node);
2862 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2863 vat_json_object_add_uint (node, "ls_index",
2864 clib_net_to_host_u32 (mp->ls_index));
2872 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2875 unformat_nsh_address (unformat_input_t * input, va_list * args)
2877 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2878 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2882 format_nsh_address_vat (u8 * s, va_list * args)
2884 nsh_t *a = va_arg (*args, nsh_t *);
2885 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2889 format_lisp_flat_eid (u8 * s, va_list * args)
2891 u32 type = va_arg (*args, u32);
2892 u8 *eid = va_arg (*args, u8 *);
2893 u32 eid_len = va_arg (*args, u32);
2898 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2900 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2902 return format (s, "%U", format_ethernet_address, eid);
2904 return format (s, "%U", format_nsh_address_vat, eid);
2910 format_lisp_eid_vat (u8 * s, va_list * args)
2912 u32 type = va_arg (*args, u32);
2913 u8 *eid = va_arg (*args, u8 *);
2914 u32 eid_len = va_arg (*args, u32);
2915 u8 *seid = va_arg (*args, u8 *);
2916 u32 seid_len = va_arg (*args, u32);
2917 u32 is_src_dst = va_arg (*args, u32);
2920 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2922 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2928 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2930 vat_main_t *vam = &vat_main;
2931 u8 *s = 0, *eid = 0;
2933 if (~0 == mp->locator_set_index)
2934 s = format (0, "action: %d", mp->action);
2936 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2938 eid = format (0, "%U", format_lisp_eid_vat,
2942 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2945 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2946 clib_net_to_host_u32 (mp->vni),
2948 mp->is_local ? "local" : "remote",
2949 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2950 clib_net_to_host_u16 (mp->key_id), mp->key);
2957 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2960 vat_main_t *vam = &vat_main;
2961 vat_json_node_t *node = 0;
2964 if (VAT_JSON_ARRAY != vam->json_tree.type)
2966 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2967 vat_json_init_array (&vam->json_tree);
2969 node = vat_json_array_add (&vam->json_tree);
2971 vat_json_init_object (node);
2972 if (~0 == mp->locator_set_index)
2973 vat_json_object_add_uint (node, "action", mp->action);
2975 vat_json_object_add_uint (node, "locator_set_index",
2976 clib_net_to_host_u32 (mp->locator_set_index));
2978 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2979 if (mp->eid_type == 3)
2981 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
2982 vat_json_init_object (nsh_json);
2983 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
2984 vat_json_object_add_uint (nsh_json, "spi",
2985 clib_net_to_host_u32 (nsh->spi));
2986 vat_json_object_add_uint (nsh_json, "si", nsh->si);
2990 eid = format (0, "%U", format_lisp_eid_vat,
2994 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2996 vat_json_object_add_string_copy (node, "eid", eid);
2999 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3000 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3001 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3005 vat_json_object_add_uint (node, "key_id",
3006 clib_net_to_host_u16 (mp->key_id));
3007 vat_json_object_add_string_copy (node, "key", mp->key);
3012 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3014 vat_main_t *vam = &vat_main;
3015 u8 *seid = 0, *deid = 0;
3016 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3018 deid = format (0, "%U", format_lisp_eid_vat,
3019 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3021 seid = format (0, "%U", format_lisp_eid_vat,
3022 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3028 format_ip_address_fcn = format_ip4_address;
3030 format_ip_address_fcn = format_ip6_address;
3033 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3034 clib_net_to_host_u32 (mp->vni),
3036 format_ip_address_fcn, mp->lloc,
3037 format_ip_address_fcn, mp->rloc,
3038 clib_net_to_host_u32 (mp->pkt_count),
3039 clib_net_to_host_u32 (mp->bytes));
3046 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3048 struct in6_addr ip6;
3050 vat_main_t *vam = &vat_main;
3051 vat_json_node_t *node = 0;
3052 u8 *deid = 0, *seid = 0;
3054 if (VAT_JSON_ARRAY != vam->json_tree.type)
3056 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3057 vat_json_init_array (&vam->json_tree);
3059 node = vat_json_array_add (&vam->json_tree);
3061 vat_json_init_object (node);
3062 deid = format (0, "%U", format_lisp_eid_vat,
3063 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3065 seid = format (0, "%U", format_lisp_eid_vat,
3066 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3071 vat_json_object_add_string_copy (node, "seid", seid);
3072 vat_json_object_add_string_copy (node, "deid", deid);
3073 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3077 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3078 vat_json_object_add_ip4 (node, "lloc", ip4);
3079 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3080 vat_json_object_add_ip4 (node, "rloc", ip4);
3084 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3085 vat_json_object_add_ip6 (node, "lloc", ip6);
3086 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3087 vat_json_object_add_ip6 (node, "rloc", ip6);
3089 vat_json_object_add_uint (node, "pkt_count",
3090 clib_net_to_host_u32 (mp->pkt_count));
3091 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3098 vl_api_one_eid_table_map_details_t_handler
3099 (vl_api_one_eid_table_map_details_t * mp)
3101 vat_main_t *vam = &vat_main;
3103 u8 *line = format (0, "%=10d%=10d",
3104 clib_net_to_host_u32 (mp->vni),
3105 clib_net_to_host_u32 (mp->dp_table));
3106 print (vam->ofp, "%v", line);
3111 vl_api_one_eid_table_map_details_t_handler_json
3112 (vl_api_one_eid_table_map_details_t * mp)
3114 vat_main_t *vam = &vat_main;
3115 vat_json_node_t *node = NULL;
3117 if (VAT_JSON_ARRAY != vam->json_tree.type)
3119 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3120 vat_json_init_array (&vam->json_tree);
3122 node = vat_json_array_add (&vam->json_tree);
3123 vat_json_init_object (node);
3124 vat_json_object_add_uint (node, "dp_table",
3125 clib_net_to_host_u32 (mp->dp_table));
3126 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3130 vl_api_one_eid_table_vni_details_t_handler
3131 (vl_api_one_eid_table_vni_details_t * mp)
3133 vat_main_t *vam = &vat_main;
3135 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3136 print (vam->ofp, "%v", line);
3141 vl_api_one_eid_table_vni_details_t_handler_json
3142 (vl_api_one_eid_table_vni_details_t * mp)
3144 vat_main_t *vam = &vat_main;
3145 vat_json_node_t *node = NULL;
3147 if (VAT_JSON_ARRAY != vam->json_tree.type)
3149 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3150 vat_json_init_array (&vam->json_tree);
3152 node = vat_json_array_add (&vam->json_tree);
3153 vat_json_init_object (node);
3154 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3158 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3159 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3161 vat_main_t *vam = &vat_main;
3162 int retval = clib_net_to_host_u32 (mp->retval);
3164 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3165 print (vam->ofp, "fallback threshold value: %d", mp->value);
3167 vam->retval = retval;
3168 vam->result_ready = 1;
3172 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3173 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3175 vat_main_t *vam = &vat_main;
3176 vat_json_node_t _node, *node = &_node;
3177 int retval = clib_net_to_host_u32 (mp->retval);
3179 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3180 vat_json_init_object (node);
3181 vat_json_object_add_uint (node, "value", mp->value);
3183 vat_json_print (vam->ofp, node);
3184 vat_json_free (node);
3186 vam->retval = retval;
3187 vam->result_ready = 1;
3191 vl_api_show_one_map_register_state_reply_t_handler
3192 (vl_api_show_one_map_register_state_reply_t * mp)
3194 vat_main_t *vam = &vat_main;
3195 int retval = clib_net_to_host_u32 (mp->retval);
3197 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3199 vam->retval = retval;
3200 vam->result_ready = 1;
3204 vl_api_show_one_map_register_state_reply_t_handler_json
3205 (vl_api_show_one_map_register_state_reply_t * mp)
3207 vat_main_t *vam = &vat_main;
3208 vat_json_node_t _node, *node = &_node;
3209 int retval = clib_net_to_host_u32 (mp->retval);
3211 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3213 vat_json_init_object (node);
3214 vat_json_object_add_string_copy (node, "state", s);
3216 vat_json_print (vam->ofp, node);
3217 vat_json_free (node);
3219 vam->retval = retval;
3220 vam->result_ready = 1;
3225 vl_api_show_one_rloc_probe_state_reply_t_handler
3226 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3228 vat_main_t *vam = &vat_main;
3229 int retval = clib_net_to_host_u32 (mp->retval);
3234 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3236 vam->retval = retval;
3237 vam->result_ready = 1;
3241 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3242 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3244 vat_main_t *vam = &vat_main;
3245 vat_json_node_t _node, *node = &_node;
3246 int retval = clib_net_to_host_u32 (mp->retval);
3248 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3249 vat_json_init_object (node);
3250 vat_json_object_add_string_copy (node, "state", s);
3252 vat_json_print (vam->ofp, node);
3253 vat_json_free (node);
3255 vam->retval = retval;
3256 vam->result_ready = 1;
3261 vl_api_show_one_stats_enable_disable_reply_t_handler
3262 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3264 vat_main_t *vam = &vat_main;
3265 int retval = clib_net_to_host_u32 (mp->retval);
3270 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3272 vam->retval = retval;
3273 vam->result_ready = 1;
3277 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3278 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3280 vat_main_t *vam = &vat_main;
3281 vat_json_node_t _node, *node = &_node;
3282 int retval = clib_net_to_host_u32 (mp->retval);
3284 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3285 vat_json_init_object (node);
3286 vat_json_object_add_string_copy (node, "state", s);
3288 vat_json_print (vam->ofp, node);
3289 vat_json_free (node);
3291 vam->retval = retval;
3292 vam->result_ready = 1;
3297 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3299 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3300 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3301 e->vni = clib_net_to_host_u32 (e->vni);
3305 gpe_fwd_entries_get_reply_t_net_to_host
3306 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3310 mp->count = clib_net_to_host_u32 (mp->count);
3311 for (i = 0; i < mp->count; i++)
3313 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3318 format_gpe_encap_mode (u8 * s, va_list * args)
3320 u32 mode = va_arg (*args, u32);
3325 return format (s, "lisp");
3327 return format (s, "vxlan");
3333 vl_api_gpe_get_encap_mode_reply_t_handler
3334 (vl_api_gpe_get_encap_mode_reply_t * mp)
3336 vat_main_t *vam = &vat_main;
3338 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3339 vam->retval = ntohl (mp->retval);
3340 vam->result_ready = 1;
3344 vl_api_gpe_get_encap_mode_reply_t_handler_json
3345 (vl_api_gpe_get_encap_mode_reply_t * mp)
3347 vat_main_t *vam = &vat_main;
3348 vat_json_node_t node;
3350 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3351 vec_add1 (encap_mode, 0);
3353 vat_json_init_object (&node);
3354 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3356 vec_free (encap_mode);
3357 vat_json_print (vam->ofp, &node);
3358 vat_json_free (&node);
3360 vam->retval = ntohl (mp->retval);
3361 vam->result_ready = 1;
3365 vl_api_gpe_fwd_entry_path_details_t_handler
3366 (vl_api_gpe_fwd_entry_path_details_t * mp)
3368 vat_main_t *vam = &vat_main;
3369 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3371 if (mp->lcl_loc.is_ip4)
3372 format_ip_address_fcn = format_ip4_address;
3374 format_ip_address_fcn = format_ip6_address;
3376 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3377 format_ip_address_fcn, &mp->lcl_loc,
3378 format_ip_address_fcn, &mp->rmt_loc);
3382 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3384 struct in6_addr ip6;
3389 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3390 vat_json_object_add_ip4 (n, "address", ip4);
3394 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3395 vat_json_object_add_ip6 (n, "address", ip6);
3397 vat_json_object_add_uint (n, "weight", loc->weight);
3401 vl_api_gpe_fwd_entry_path_details_t_handler_json
3402 (vl_api_gpe_fwd_entry_path_details_t * mp)
3404 vat_main_t *vam = &vat_main;
3405 vat_json_node_t *node = NULL;
3406 vat_json_node_t *loc_node;
3408 if (VAT_JSON_ARRAY != vam->json_tree.type)
3410 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3411 vat_json_init_array (&vam->json_tree);
3413 node = vat_json_array_add (&vam->json_tree);
3414 vat_json_init_object (node);
3416 loc_node = vat_json_object_add (node, "local_locator");
3417 vat_json_init_object (loc_node);
3418 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3420 loc_node = vat_json_object_add (node, "remote_locator");
3421 vat_json_init_object (loc_node);
3422 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3426 vl_api_gpe_fwd_entries_get_reply_t_handler
3427 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3429 vat_main_t *vam = &vat_main;
3431 int retval = clib_net_to_host_u32 (mp->retval);
3432 vl_api_gpe_fwd_entry_t *e;
3437 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3439 for (i = 0; i < mp->count; i++)
3441 e = &mp->entries[i];
3442 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3443 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3444 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3448 vam->retval = retval;
3449 vam->result_ready = 1;
3453 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3454 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3457 vat_main_t *vam = &vat_main;
3458 vat_json_node_t *e = 0, root;
3460 int retval = clib_net_to_host_u32 (mp->retval);
3461 vl_api_gpe_fwd_entry_t *fwd;
3466 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3467 vat_json_init_array (&root);
3469 for (i = 0; i < mp->count; i++)
3471 e = vat_json_array_add (&root);
3472 fwd = &mp->entries[i];
3474 vat_json_init_object (e);
3475 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3476 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3477 vat_json_object_add_int (e, "vni", fwd->vni);
3478 vat_json_object_add_int (e, "action", fwd->action);
3480 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3481 fwd->leid_prefix_len);
3483 vat_json_object_add_string_copy (e, "leid", s);
3486 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3487 fwd->reid_prefix_len);
3489 vat_json_object_add_string_copy (e, "reid", s);
3493 vat_json_print (vam->ofp, &root);
3494 vat_json_free (&root);
3497 vam->retval = retval;
3498 vam->result_ready = 1;
3502 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3503 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3505 vat_main_t *vam = &vat_main;
3507 int retval = clib_net_to_host_u32 (mp->retval);
3508 vl_api_gpe_native_fwd_rpath_t *r;
3513 n = clib_net_to_host_u32 (mp->count);
3515 for (i = 0; i < n; i++)
3517 r = &mp->entries[i];
3518 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3519 clib_net_to_host_u32 (r->fib_index),
3520 clib_net_to_host_u32 (r->nh_sw_if_index),
3521 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3525 vam->retval = retval;
3526 vam->result_ready = 1;
3530 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3531 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3533 vat_main_t *vam = &vat_main;
3534 vat_json_node_t root, *e;
3536 int retval = clib_net_to_host_u32 (mp->retval);
3537 vl_api_gpe_native_fwd_rpath_t *r;
3543 n = clib_net_to_host_u32 (mp->count);
3544 vat_json_init_array (&root);
3546 for (i = 0; i < n; i++)
3548 e = vat_json_array_add (&root);
3549 vat_json_init_object (e);
3550 r = &mp->entries[i];
3552 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3555 vat_json_object_add_string_copy (e, "ip4", s);
3558 vat_json_object_add_uint (e, "fib_index",
3559 clib_net_to_host_u32 (r->fib_index));
3560 vat_json_object_add_uint (e, "nh_sw_if_index",
3561 clib_net_to_host_u32 (r->nh_sw_if_index));
3564 vat_json_print (vam->ofp, &root);
3565 vat_json_free (&root);
3568 vam->retval = retval;
3569 vam->result_ready = 1;
3573 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3574 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3576 vat_main_t *vam = &vat_main;
3578 int retval = clib_net_to_host_u32 (mp->retval);
3583 n = clib_net_to_host_u32 (mp->count);
3585 for (i = 0; i < n; i++)
3586 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3589 vam->retval = retval;
3590 vam->result_ready = 1;
3594 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3595 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3597 vat_main_t *vam = &vat_main;
3598 vat_json_node_t root;
3600 int retval = clib_net_to_host_u32 (mp->retval);
3605 n = clib_net_to_host_u32 (mp->count);
3606 vat_json_init_array (&root);
3608 for (i = 0; i < n; i++)
3609 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3611 vat_json_print (vam->ofp, &root);
3612 vat_json_free (&root);
3615 vam->retval = retval;
3616 vam->result_ready = 1;
3620 vl_api_one_ndp_entries_get_reply_t_handler
3621 (vl_api_one_ndp_entries_get_reply_t * mp)
3623 vat_main_t *vam = &vat_main;
3625 int retval = clib_net_to_host_u32 (mp->retval);
3630 n = clib_net_to_host_u32 (mp->count);
3632 for (i = 0; i < n; i++)
3633 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3634 format_ethernet_address, mp->entries[i].mac);
3637 vam->retval = retval;
3638 vam->result_ready = 1;
3642 vl_api_one_ndp_entries_get_reply_t_handler_json
3643 (vl_api_one_ndp_entries_get_reply_t * mp)
3646 vat_main_t *vam = &vat_main;
3647 vat_json_node_t *e = 0, root;
3649 int retval = clib_net_to_host_u32 (mp->retval);
3650 vl_api_one_ndp_entry_t *arp_entry;
3655 n = clib_net_to_host_u32 (mp->count);
3656 vat_json_init_array (&root);
3658 for (i = 0; i < n; i++)
3660 e = vat_json_array_add (&root);
3661 arp_entry = &mp->entries[i];
3663 vat_json_init_object (e);
3664 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3667 vat_json_object_add_string_copy (e, "mac", s);
3670 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3672 vat_json_object_add_string_copy (e, "ip6", s);
3676 vat_json_print (vam->ofp, &root);
3677 vat_json_free (&root);
3680 vam->retval = retval;
3681 vam->result_ready = 1;
3685 vl_api_one_l2_arp_entries_get_reply_t_handler
3686 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3688 vat_main_t *vam = &vat_main;
3690 int retval = clib_net_to_host_u32 (mp->retval);
3695 n = clib_net_to_host_u32 (mp->count);
3697 for (i = 0; i < n; i++)
3698 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3699 format_ethernet_address, mp->entries[i].mac);
3702 vam->retval = retval;
3703 vam->result_ready = 1;
3707 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3708 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3711 vat_main_t *vam = &vat_main;
3712 vat_json_node_t *e = 0, root;
3714 int retval = clib_net_to_host_u32 (mp->retval);
3715 vl_api_one_l2_arp_entry_t *arp_entry;
3720 n = clib_net_to_host_u32 (mp->count);
3721 vat_json_init_array (&root);
3723 for (i = 0; i < n; i++)
3725 e = vat_json_array_add (&root);
3726 arp_entry = &mp->entries[i];
3728 vat_json_init_object (e);
3729 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3732 vat_json_object_add_string_copy (e, "mac", s);
3735 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3737 vat_json_object_add_string_copy (e, "ip4", s);
3741 vat_json_print (vam->ofp, &root);
3742 vat_json_free (&root);
3745 vam->retval = retval;
3746 vam->result_ready = 1;
3750 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3752 vat_main_t *vam = &vat_main;
3754 int retval = clib_net_to_host_u32 (mp->retval);
3759 n = clib_net_to_host_u32 (mp->count);
3761 for (i = 0; i < n; i++)
3763 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3767 vam->retval = retval;
3768 vam->result_ready = 1;
3772 vl_api_one_ndp_bd_get_reply_t_handler_json
3773 (vl_api_one_ndp_bd_get_reply_t * mp)
3775 vat_main_t *vam = &vat_main;
3776 vat_json_node_t root;
3778 int retval = clib_net_to_host_u32 (mp->retval);
3783 n = clib_net_to_host_u32 (mp->count);
3784 vat_json_init_array (&root);
3786 for (i = 0; i < n; i++)
3788 vat_json_array_add_uint (&root,
3789 clib_net_to_host_u32 (mp->bridge_domains[i]));
3792 vat_json_print (vam->ofp, &root);
3793 vat_json_free (&root);
3796 vam->retval = retval;
3797 vam->result_ready = 1;
3801 vl_api_one_l2_arp_bd_get_reply_t_handler
3802 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3804 vat_main_t *vam = &vat_main;
3806 int retval = clib_net_to_host_u32 (mp->retval);
3811 n = clib_net_to_host_u32 (mp->count);
3813 for (i = 0; i < n; i++)
3815 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3819 vam->retval = retval;
3820 vam->result_ready = 1;
3824 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3825 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3827 vat_main_t *vam = &vat_main;
3828 vat_json_node_t root;
3830 int retval = clib_net_to_host_u32 (mp->retval);
3835 n = clib_net_to_host_u32 (mp->count);
3836 vat_json_init_array (&root);
3838 for (i = 0; i < n; i++)
3840 vat_json_array_add_uint (&root,
3841 clib_net_to_host_u32 (mp->bridge_domains[i]));
3844 vat_json_print (vam->ofp, &root);
3845 vat_json_free (&root);
3848 vam->retval = retval;
3849 vam->result_ready = 1;
3853 vl_api_one_adjacencies_get_reply_t_handler
3854 (vl_api_one_adjacencies_get_reply_t * mp)
3856 vat_main_t *vam = &vat_main;
3858 int retval = clib_net_to_host_u32 (mp->retval);
3859 vl_api_one_adjacency_t *a;
3864 n = clib_net_to_host_u32 (mp->count);
3866 for (i = 0; i < n; i++)
3868 a = &mp->adjacencies[i];
3869 print (vam->ofp, "%U %40U",
3870 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3871 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3875 vam->retval = retval;
3876 vam->result_ready = 1;
3880 vl_api_one_adjacencies_get_reply_t_handler_json
3881 (vl_api_one_adjacencies_get_reply_t * mp)
3884 vat_main_t *vam = &vat_main;
3885 vat_json_node_t *e = 0, root;
3887 int retval = clib_net_to_host_u32 (mp->retval);
3888 vl_api_one_adjacency_t *a;
3893 n = clib_net_to_host_u32 (mp->count);
3894 vat_json_init_array (&root);
3896 for (i = 0; i < n; i++)
3898 e = vat_json_array_add (&root);
3899 a = &mp->adjacencies[i];
3901 vat_json_init_object (e);
3902 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3903 a->leid_prefix_len);
3905 vat_json_object_add_string_copy (e, "leid", s);
3908 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3909 a->reid_prefix_len);
3911 vat_json_object_add_string_copy (e, "reid", s);
3915 vat_json_print (vam->ofp, &root);
3916 vat_json_free (&root);
3919 vam->retval = retval;
3920 vam->result_ready = 1;
3924 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3926 vat_main_t *vam = &vat_main;
3928 print (vam->ofp, "%=20U",
3929 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3934 vl_api_one_map_server_details_t_handler_json
3935 (vl_api_one_map_server_details_t * mp)
3937 vat_main_t *vam = &vat_main;
3938 vat_json_node_t *node = NULL;
3939 struct in6_addr ip6;
3942 if (VAT_JSON_ARRAY != vam->json_tree.type)
3944 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3945 vat_json_init_array (&vam->json_tree);
3947 node = vat_json_array_add (&vam->json_tree);
3949 vat_json_init_object (node);
3952 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3953 vat_json_object_add_ip6 (node, "map-server", ip6);
3957 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3958 vat_json_object_add_ip4 (node, "map-server", ip4);
3963 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3966 vat_main_t *vam = &vat_main;
3968 print (vam->ofp, "%=20U",
3969 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3974 vl_api_one_map_resolver_details_t_handler_json
3975 (vl_api_one_map_resolver_details_t * mp)
3977 vat_main_t *vam = &vat_main;
3978 vat_json_node_t *node = NULL;
3979 struct in6_addr ip6;
3982 if (VAT_JSON_ARRAY != vam->json_tree.type)
3984 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3985 vat_json_init_array (&vam->json_tree);
3987 node = vat_json_array_add (&vam->json_tree);
3989 vat_json_init_object (node);
3992 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3993 vat_json_object_add_ip6 (node, "map resolver", ip6);
3997 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3998 vat_json_object_add_ip4 (node, "map resolver", ip4);
4003 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4005 vat_main_t *vam = &vat_main;
4006 i32 retval = ntohl (mp->retval);
4010 print (vam->ofp, "feature: %s\ngpe: %s",
4011 mp->feature_status ? "enabled" : "disabled",
4012 mp->gpe_status ? "enabled" : "disabled");
4015 vam->retval = retval;
4016 vam->result_ready = 1;
4020 vl_api_show_one_status_reply_t_handler_json
4021 (vl_api_show_one_status_reply_t * mp)
4023 vat_main_t *vam = &vat_main;
4024 vat_json_node_t node;
4025 u8 *gpe_status = NULL;
4026 u8 *feature_status = NULL;
4028 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4029 feature_status = format (0, "%s",
4030 mp->feature_status ? "enabled" : "disabled");
4031 vec_add1 (gpe_status, 0);
4032 vec_add1 (feature_status, 0);
4034 vat_json_init_object (&node);
4035 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4036 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4038 vec_free (gpe_status);
4039 vec_free (feature_status);
4041 vat_json_print (vam->ofp, &node);
4042 vat_json_free (&node);
4044 vam->retval = ntohl (mp->retval);
4045 vam->result_ready = 1;
4049 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4050 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4052 vat_main_t *vam = &vat_main;
4053 i32 retval = ntohl (mp->retval);
4057 print (vam->ofp, "%=20s", mp->locator_set_name);
4060 vam->retval = retval;
4061 vam->result_ready = 1;
4065 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4066 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4068 vat_main_t *vam = &vat_main;
4069 vat_json_node_t *node = NULL;
4071 if (VAT_JSON_ARRAY != vam->json_tree.type)
4073 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4074 vat_json_init_array (&vam->json_tree);
4076 node = vat_json_array_add (&vam->json_tree);
4078 vat_json_init_object (node);
4079 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4081 vat_json_print (vam->ofp, node);
4082 vat_json_free (node);
4084 vam->retval = ntohl (mp->retval);
4085 vam->result_ready = 1;
4089 format_lisp_map_request_mode (u8 * s, va_list * args)
4091 u32 mode = va_arg (*args, u32);
4096 return format (0, "dst-only");
4098 return format (0, "src-dst");
4104 vl_api_show_one_map_request_mode_reply_t_handler
4105 (vl_api_show_one_map_request_mode_reply_t * mp)
4107 vat_main_t *vam = &vat_main;
4108 i32 retval = ntohl (mp->retval);
4112 u32 mode = mp->mode;
4113 print (vam->ofp, "map_request_mode: %U",
4114 format_lisp_map_request_mode, mode);
4117 vam->retval = retval;
4118 vam->result_ready = 1;
4122 vl_api_show_one_map_request_mode_reply_t_handler_json
4123 (vl_api_show_one_map_request_mode_reply_t * mp)
4125 vat_main_t *vam = &vat_main;
4126 vat_json_node_t node;
4131 s = format (0, "%U", format_lisp_map_request_mode, mode);
4134 vat_json_init_object (&node);
4135 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4136 vat_json_print (vam->ofp, &node);
4137 vat_json_free (&node);
4140 vam->retval = ntohl (mp->retval);
4141 vam->result_ready = 1;
4145 vl_api_show_one_use_petr_reply_t_handler
4146 (vl_api_show_one_use_petr_reply_t * mp)
4148 vat_main_t *vam = &vat_main;
4149 i32 retval = ntohl (mp->retval);
4153 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4156 print (vam->ofp, "Proxy-ETR address; %U",
4157 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4162 vam->retval = retval;
4163 vam->result_ready = 1;
4167 vl_api_show_one_use_petr_reply_t_handler_json
4168 (vl_api_show_one_use_petr_reply_t * mp)
4170 vat_main_t *vam = &vat_main;
4171 vat_json_node_t node;
4174 struct in6_addr ip6;
4176 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4177 vec_add1 (status, 0);
4179 vat_json_init_object (&node);
4180 vat_json_object_add_string_copy (&node, "status", status);
4185 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4186 vat_json_object_add_ip6 (&node, "address", ip6);
4190 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4191 vat_json_object_add_ip4 (&node, "address", ip4);
4197 vat_json_print (vam->ofp, &node);
4198 vat_json_free (&node);
4200 vam->retval = ntohl (mp->retval);
4201 vam->result_ready = 1;
4205 vl_api_show_one_nsh_mapping_reply_t_handler
4206 (vl_api_show_one_nsh_mapping_reply_t * mp)
4208 vat_main_t *vam = &vat_main;
4209 i32 retval = ntohl (mp->retval);
4213 print (vam->ofp, "%-20s%-16s",
4214 mp->is_set ? "set" : "not-set",
4215 mp->is_set ? (char *) mp->locator_set_name : "");
4218 vam->retval = retval;
4219 vam->result_ready = 1;
4223 vl_api_show_one_nsh_mapping_reply_t_handler_json
4224 (vl_api_show_one_nsh_mapping_reply_t * mp)
4226 vat_main_t *vam = &vat_main;
4227 vat_json_node_t node;
4230 status = format (0, "%s", mp->is_set ? "yes" : "no");
4231 vec_add1 (status, 0);
4233 vat_json_init_object (&node);
4234 vat_json_object_add_string_copy (&node, "is_set", status);
4237 vat_json_object_add_string_copy (&node, "locator_set",
4238 mp->locator_set_name);
4243 vat_json_print (vam->ofp, &node);
4244 vat_json_free (&node);
4246 vam->retval = ntohl (mp->retval);
4247 vam->result_ready = 1;
4251 vl_api_show_one_map_register_ttl_reply_t_handler
4252 (vl_api_show_one_map_register_ttl_reply_t * mp)
4254 vat_main_t *vam = &vat_main;
4255 i32 retval = ntohl (mp->retval);
4257 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4261 print (vam->ofp, "ttl: %u", mp->ttl);
4264 vam->retval = retval;
4265 vam->result_ready = 1;
4269 vl_api_show_one_map_register_ttl_reply_t_handler_json
4270 (vl_api_show_one_map_register_ttl_reply_t * mp)
4272 vat_main_t *vam = &vat_main;
4273 vat_json_node_t node;
4275 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4276 vat_json_init_object (&node);
4277 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4279 vat_json_print (vam->ofp, &node);
4280 vat_json_free (&node);
4282 vam->retval = ntohl (mp->retval);
4283 vam->result_ready = 1;
4287 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4289 vat_main_t *vam = &vat_main;
4290 i32 retval = ntohl (mp->retval);
4294 print (vam->ofp, "%-20s%-16s",
4295 mp->status ? "enabled" : "disabled",
4296 mp->status ? (char *) mp->locator_set_name : "");
4299 vam->retval = retval;
4300 vam->result_ready = 1;
4304 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4306 vat_main_t *vam = &vat_main;
4307 vat_json_node_t node;
4310 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4311 vec_add1 (status, 0);
4313 vat_json_init_object (&node);
4314 vat_json_object_add_string_copy (&node, "status", status);
4317 vat_json_object_add_string_copy (&node, "locator_set",
4318 mp->locator_set_name);
4323 vat_json_print (vam->ofp, &node);
4324 vat_json_free (&node);
4326 vam->retval = ntohl (mp->retval);
4327 vam->result_ready = 1;
4331 format_policer_type (u8 * s, va_list * va)
4333 u32 i = va_arg (*va, u32);
4335 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4336 s = format (s, "1r2c");
4337 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4338 s = format (s, "1r3c");
4339 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4340 s = format (s, "2r3c-2698");
4341 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4342 s = format (s, "2r3c-4115");
4343 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4344 s = format (s, "2r3c-mef5cf1");
4346 s = format (s, "ILLEGAL");
4351 format_policer_rate_type (u8 * s, va_list * va)
4353 u32 i = va_arg (*va, u32);
4355 if (i == SSE2_QOS_RATE_KBPS)
4356 s = format (s, "kbps");
4357 else if (i == SSE2_QOS_RATE_PPS)
4358 s = format (s, "pps");
4360 s = format (s, "ILLEGAL");
4365 format_policer_round_type (u8 * s, va_list * va)
4367 u32 i = va_arg (*va, u32);
4369 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4370 s = format (s, "closest");
4371 else if (i == SSE2_QOS_ROUND_TO_UP)
4372 s = format (s, "up");
4373 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4374 s = format (s, "down");
4376 s = format (s, "ILLEGAL");
4381 format_policer_action_type (u8 * s, va_list * va)
4383 u32 i = va_arg (*va, u32);
4385 if (i == SSE2_QOS_ACTION_DROP)
4386 s = format (s, "drop");
4387 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4388 s = format (s, "transmit");
4389 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4390 s = format (s, "mark-and-transmit");
4392 s = format (s, "ILLEGAL");
4397 format_dscp (u8 * s, va_list * va)
4399 u32 i = va_arg (*va, u32);
4404 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4408 return format (s, "ILLEGAL");
4410 s = format (s, "%s", t);
4415 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4417 vat_main_t *vam = &vat_main;
4418 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4420 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4421 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4423 conform_dscp_str = format (0, "");
4425 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4426 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4428 exceed_dscp_str = format (0, "");
4430 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4431 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4433 violate_dscp_str = format (0, "");
4435 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4436 "rate type %U, round type %U, %s rate, %s color-aware, "
4437 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4438 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4439 "conform action %U%s, exceed action %U%s, violate action %U%s",
4441 format_policer_type, mp->type,
4444 clib_net_to_host_u64 (mp->cb),
4445 clib_net_to_host_u64 (mp->eb),
4446 format_policer_rate_type, mp->rate_type,
4447 format_policer_round_type, mp->round_type,
4448 mp->single_rate ? "single" : "dual",
4449 mp->color_aware ? "is" : "not",
4450 ntohl (mp->cir_tokens_per_period),
4451 ntohl (mp->pir_tokens_per_period),
4453 ntohl (mp->current_limit),
4454 ntohl (mp->current_bucket),
4455 ntohl (mp->extended_limit),
4456 ntohl (mp->extended_bucket),
4457 clib_net_to_host_u64 (mp->last_update_time),
4458 format_policer_action_type, mp->conform_action_type,
4460 format_policer_action_type, mp->exceed_action_type,
4462 format_policer_action_type, mp->violate_action_type,
4465 vec_free (conform_dscp_str);
4466 vec_free (exceed_dscp_str);
4467 vec_free (violate_dscp_str);
4470 static void vl_api_policer_details_t_handler_json
4471 (vl_api_policer_details_t * mp)
4473 vat_main_t *vam = &vat_main;
4474 vat_json_node_t *node;
4475 u8 *rate_type_str, *round_type_str, *type_str;
4476 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4478 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4480 format (0, "%U", format_policer_round_type, mp->round_type);
4481 type_str = format (0, "%U", format_policer_type, mp->type);
4482 conform_action_str = format (0, "%U", format_policer_action_type,
4483 mp->conform_action_type);
4484 exceed_action_str = format (0, "%U", format_policer_action_type,
4485 mp->exceed_action_type);
4486 violate_action_str = format (0, "%U", format_policer_action_type,
4487 mp->violate_action_type);
4489 if (VAT_JSON_ARRAY != vam->json_tree.type)
4491 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4492 vat_json_init_array (&vam->json_tree);
4494 node = vat_json_array_add (&vam->json_tree);
4496 vat_json_init_object (node);
4497 vat_json_object_add_string_copy (node, "name", mp->name);
4498 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4499 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4500 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4501 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4502 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4503 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4504 vat_json_object_add_string_copy (node, "type", type_str);
4505 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4506 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4507 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4508 vat_json_object_add_uint (node, "cir_tokens_per_period",
4509 ntohl (mp->cir_tokens_per_period));
4510 vat_json_object_add_uint (node, "eir_tokens_per_period",
4511 ntohl (mp->pir_tokens_per_period));
4512 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4513 vat_json_object_add_uint (node, "current_bucket",
4514 ntohl (mp->current_bucket));
4515 vat_json_object_add_uint (node, "extended_limit",
4516 ntohl (mp->extended_limit));
4517 vat_json_object_add_uint (node, "extended_bucket",
4518 ntohl (mp->extended_bucket));
4519 vat_json_object_add_uint (node, "last_update_time",
4520 ntohl (mp->last_update_time));
4521 vat_json_object_add_string_copy (node, "conform_action",
4522 conform_action_str);
4523 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4525 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4526 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4527 vec_free (dscp_str);
4529 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4530 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4532 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4533 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4534 vec_free (dscp_str);
4536 vat_json_object_add_string_copy (node, "violate_action",
4537 violate_action_str);
4538 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4540 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4541 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4542 vec_free (dscp_str);
4545 vec_free (rate_type_str);
4546 vec_free (round_type_str);
4547 vec_free (type_str);
4548 vec_free (conform_action_str);
4549 vec_free (exceed_action_str);
4550 vec_free (violate_action_str);
4554 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4557 vat_main_t *vam = &vat_main;
4558 int i, count = ntohl (mp->count);
4561 print (vam->ofp, "classify table ids (%d) : ", count);
4562 for (i = 0; i < count; i++)
4564 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4565 print (vam->ofp, (i < count - 1) ? "," : "");
4567 vam->retval = ntohl (mp->retval);
4568 vam->result_ready = 1;
4572 vl_api_classify_table_ids_reply_t_handler_json
4573 (vl_api_classify_table_ids_reply_t * mp)
4575 vat_main_t *vam = &vat_main;
4576 int i, count = ntohl (mp->count);
4580 vat_json_node_t node;
4582 vat_json_init_object (&node);
4583 for (i = 0; i < count; i++)
4585 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4587 vat_json_print (vam->ofp, &node);
4588 vat_json_free (&node);
4590 vam->retval = ntohl (mp->retval);
4591 vam->result_ready = 1;
4595 vl_api_classify_table_by_interface_reply_t_handler
4596 (vl_api_classify_table_by_interface_reply_t * mp)
4598 vat_main_t *vam = &vat_main;
4601 table_id = ntohl (mp->l2_table_id);
4603 print (vam->ofp, "l2 table id : %d", table_id);
4605 print (vam->ofp, "l2 table id : No input ACL tables configured");
4606 table_id = ntohl (mp->ip4_table_id);
4608 print (vam->ofp, "ip4 table id : %d", table_id);
4610 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4611 table_id = ntohl (mp->ip6_table_id);
4613 print (vam->ofp, "ip6 table id : %d", table_id);
4615 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4616 vam->retval = ntohl (mp->retval);
4617 vam->result_ready = 1;
4621 vl_api_classify_table_by_interface_reply_t_handler_json
4622 (vl_api_classify_table_by_interface_reply_t * mp)
4624 vat_main_t *vam = &vat_main;
4625 vat_json_node_t node;
4627 vat_json_init_object (&node);
4629 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4630 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4631 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4633 vat_json_print (vam->ofp, &node);
4634 vat_json_free (&node);
4636 vam->retval = ntohl (mp->retval);
4637 vam->result_ready = 1;
4640 static void vl_api_policer_add_del_reply_t_handler
4641 (vl_api_policer_add_del_reply_t * mp)
4643 vat_main_t *vam = &vat_main;
4644 i32 retval = ntohl (mp->retval);
4645 if (vam->async_mode)
4647 vam->async_errors += (retval < 0);
4651 vam->retval = retval;
4652 vam->result_ready = 1;
4653 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4655 * Note: this is just barely thread-safe, depends on
4656 * the main thread spinning waiting for an answer...
4658 errmsg ("policer index %d", ntohl (mp->policer_index));
4662 static void vl_api_policer_add_del_reply_t_handler_json
4663 (vl_api_policer_add_del_reply_t * mp)
4665 vat_main_t *vam = &vat_main;
4666 vat_json_node_t node;
4668 vat_json_init_object (&node);
4669 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4670 vat_json_object_add_uint (&node, "policer_index",
4671 ntohl (mp->policer_index));
4673 vat_json_print (vam->ofp, &node);
4674 vat_json_free (&node);
4676 vam->retval = ntohl (mp->retval);
4677 vam->result_ready = 1;
4680 /* Format hex dump. */
4682 format_hex_bytes (u8 * s, va_list * va)
4684 u8 *bytes = va_arg (*va, u8 *);
4685 int n_bytes = va_arg (*va, int);
4688 /* Print short or long form depending on byte count. */
4689 uword short_form = n_bytes <= 32;
4690 uword indent = format_get_indent (s);
4695 for (i = 0; i < n_bytes; i++)
4697 if (!short_form && (i % 32) == 0)
4698 s = format (s, "%08x: ", i);
4699 s = format (s, "%02x", bytes[i]);
4700 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4701 s = format (s, "\n%U", format_white_space, indent);
4708 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4711 vat_main_t *vam = &vat_main;
4712 i32 retval = ntohl (mp->retval);
4715 print (vam->ofp, "classify table info :");
4716 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4717 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4718 ntohl (mp->miss_next_index));
4719 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4720 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4721 ntohl (mp->match_n_vectors));
4722 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4723 ntohl (mp->mask_length));
4725 vam->retval = retval;
4726 vam->result_ready = 1;
4730 vl_api_classify_table_info_reply_t_handler_json
4731 (vl_api_classify_table_info_reply_t * mp)
4733 vat_main_t *vam = &vat_main;
4734 vat_json_node_t node;
4736 i32 retval = ntohl (mp->retval);
4739 vat_json_init_object (&node);
4741 vat_json_object_add_int (&node, "sessions",
4742 ntohl (mp->active_sessions));
4743 vat_json_object_add_int (&node, "nexttbl",
4744 ntohl (mp->next_table_index));
4745 vat_json_object_add_int (&node, "nextnode",
4746 ntohl (mp->miss_next_index));
4747 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4748 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4749 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4750 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4751 ntohl (mp->mask_length), 0);
4752 vat_json_object_add_string_copy (&node, "mask", s);
4754 vat_json_print (vam->ofp, &node);
4755 vat_json_free (&node);
4757 vam->retval = ntohl (mp->retval);
4758 vam->result_ready = 1;
4762 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4765 vat_main_t *vam = &vat_main;
4767 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4768 ntohl (mp->hit_next_index), ntohl (mp->advance),
4769 ntohl (mp->opaque_index));
4770 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4771 ntohl (mp->match_length));
4775 vl_api_classify_session_details_t_handler_json
4776 (vl_api_classify_session_details_t * mp)
4778 vat_main_t *vam = &vat_main;
4779 vat_json_node_t *node = NULL;
4781 if (VAT_JSON_ARRAY != vam->json_tree.type)
4783 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4784 vat_json_init_array (&vam->json_tree);
4786 node = vat_json_array_add (&vam->json_tree);
4788 vat_json_init_object (node);
4789 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4790 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4791 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4793 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4795 vat_json_object_add_string_copy (node, "match", s);
4798 static void vl_api_pg_create_interface_reply_t_handler
4799 (vl_api_pg_create_interface_reply_t * mp)
4801 vat_main_t *vam = &vat_main;
4803 vam->retval = ntohl (mp->retval);
4804 vam->result_ready = 1;
4807 static void vl_api_pg_create_interface_reply_t_handler_json
4808 (vl_api_pg_create_interface_reply_t * mp)
4810 vat_main_t *vam = &vat_main;
4811 vat_json_node_t node;
4813 i32 retval = ntohl (mp->retval);
4816 vat_json_init_object (&node);
4818 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4820 vat_json_print (vam->ofp, &node);
4821 vat_json_free (&node);
4823 vam->retval = ntohl (mp->retval);
4824 vam->result_ready = 1;
4827 static void vl_api_policer_classify_details_t_handler
4828 (vl_api_policer_classify_details_t * mp)
4830 vat_main_t *vam = &vat_main;
4832 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4833 ntohl (mp->table_index));
4836 static void vl_api_policer_classify_details_t_handler_json
4837 (vl_api_policer_classify_details_t * mp)
4839 vat_main_t *vam = &vat_main;
4840 vat_json_node_t *node;
4842 if (VAT_JSON_ARRAY != vam->json_tree.type)
4844 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4845 vat_json_init_array (&vam->json_tree);
4847 node = vat_json_array_add (&vam->json_tree);
4849 vat_json_init_object (node);
4850 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4851 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4854 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4855 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4857 vat_main_t *vam = &vat_main;
4858 i32 retval = ntohl (mp->retval);
4859 if (vam->async_mode)
4861 vam->async_errors += (retval < 0);
4865 vam->retval = retval;
4866 vam->sw_if_index = ntohl (mp->sw_if_index);
4867 vam->result_ready = 1;
4871 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4872 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4874 vat_main_t *vam = &vat_main;
4875 vat_json_node_t node;
4877 vat_json_init_object (&node);
4878 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4879 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4881 vat_json_print (vam->ofp, &node);
4882 vat_json_free (&node);
4884 vam->retval = ntohl (mp->retval);
4885 vam->result_ready = 1;
4888 static void vl_api_flow_classify_details_t_handler
4889 (vl_api_flow_classify_details_t * mp)
4891 vat_main_t *vam = &vat_main;
4893 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4894 ntohl (mp->table_index));
4897 static void vl_api_flow_classify_details_t_handler_json
4898 (vl_api_flow_classify_details_t * mp)
4900 vat_main_t *vam = &vat_main;
4901 vat_json_node_t *node;
4903 if (VAT_JSON_ARRAY != vam->json_tree.type)
4905 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4906 vat_json_init_array (&vam->json_tree);
4908 node = vat_json_array_add (&vam->json_tree);
4910 vat_json_init_object (node);
4911 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4912 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4915 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
4916 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
4917 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
4918 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
4919 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4920 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4921 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4922 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4923 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4924 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4925 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4926 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4927 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4928 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4929 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
4930 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
4931 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
4932 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
4933 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
4934 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
4935 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
4936 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
4939 * Generate boilerplate reply handlers, which
4940 * dig the return value out of the xxx_reply_t API message,
4941 * stick it into vam->retval, and set vam->result_ready
4943 * Could also do this by pointing N message decode slots at
4944 * a single function, but that could break in subtle ways.
4947 #define foreach_standard_reply_retval_handler \
4948 _(sw_interface_set_flags_reply) \
4949 _(sw_interface_add_del_address_reply) \
4950 _(sw_interface_set_table_reply) \
4951 _(sw_interface_set_mpls_enable_reply) \
4952 _(sw_interface_set_vpath_reply) \
4953 _(sw_interface_set_vxlan_bypass_reply) \
4954 _(sw_interface_set_vxlan_gpe_bypass_reply) \
4955 _(sw_interface_set_l2_bridge_reply) \
4956 _(bridge_domain_add_del_reply) \
4957 _(sw_interface_set_l2_xconnect_reply) \
4958 _(l2fib_add_del_reply) \
4959 _(l2fib_flush_int_reply) \
4960 _(l2fib_flush_bd_reply) \
4961 _(ip_add_del_route_reply) \
4962 _(ip_table_add_del_reply) \
4963 _(ip_mroute_add_del_reply) \
4964 _(mpls_route_add_del_reply) \
4965 _(mpls_table_add_del_reply) \
4966 _(mpls_ip_bind_unbind_reply) \
4967 _(proxy_arp_add_del_reply) \
4968 _(proxy_arp_intfc_enable_disable_reply) \
4969 _(sw_interface_set_unnumbered_reply) \
4970 _(ip_neighbor_add_del_reply) \
4971 _(reset_vrf_reply) \
4972 _(oam_add_del_reply) \
4973 _(reset_fib_reply) \
4974 _(dhcp_proxy_config_reply) \
4975 _(dhcp_proxy_set_vss_reply) \
4976 _(dhcp_client_config_reply) \
4977 _(set_ip_flow_hash_reply) \
4978 _(sw_interface_ip6_enable_disable_reply) \
4979 _(sw_interface_ip6_set_link_local_address_reply) \
4980 _(ip6nd_proxy_add_del_reply) \
4981 _(sw_interface_ip6nd_ra_prefix_reply) \
4982 _(sw_interface_ip6nd_ra_config_reply) \
4983 _(set_arp_neighbor_limit_reply) \
4984 _(l2_patch_add_del_reply) \
4985 _(sr_policy_add_reply) \
4986 _(sr_policy_mod_reply) \
4987 _(sr_policy_del_reply) \
4988 _(sr_localsid_add_del_reply) \
4989 _(sr_steering_add_del_reply) \
4990 _(classify_add_del_session_reply) \
4991 _(classify_set_interface_ip_table_reply) \
4992 _(classify_set_interface_l2_tables_reply) \
4993 _(l2tpv3_set_tunnel_cookies_reply) \
4994 _(l2tpv3_interface_enable_disable_reply) \
4995 _(l2tpv3_set_lookup_key_reply) \
4996 _(l2_fib_clear_table_reply) \
4997 _(l2_interface_efp_filter_reply) \
4998 _(l2_interface_vlan_tag_rewrite_reply) \
4999 _(modify_vhost_user_if_reply) \
5000 _(delete_vhost_user_if_reply) \
5001 _(want_ip4_arp_events_reply) \
5002 _(want_ip6_nd_events_reply) \
5003 _(want_l2_macs_events_reply) \
5004 _(input_acl_set_interface_reply) \
5005 _(ipsec_spd_add_del_reply) \
5006 _(ipsec_interface_add_del_spd_reply) \
5007 _(ipsec_spd_add_del_entry_reply) \
5008 _(ipsec_sad_add_del_entry_reply) \
5009 _(ipsec_sa_set_key_reply) \
5010 _(ipsec_tunnel_if_add_del_reply) \
5011 _(ikev2_profile_add_del_reply) \
5012 _(ikev2_profile_set_auth_reply) \
5013 _(ikev2_profile_set_id_reply) \
5014 _(ikev2_profile_set_ts_reply) \
5015 _(ikev2_set_local_key_reply) \
5016 _(ikev2_set_responder_reply) \
5017 _(ikev2_set_ike_transforms_reply) \
5018 _(ikev2_set_esp_transforms_reply) \
5019 _(ikev2_set_sa_lifetime_reply) \
5020 _(ikev2_initiate_sa_init_reply) \
5021 _(ikev2_initiate_del_ike_sa_reply) \
5022 _(ikev2_initiate_del_child_sa_reply) \
5023 _(ikev2_initiate_rekey_child_sa_reply) \
5024 _(delete_loopback_reply) \
5025 _(bd_ip_mac_add_del_reply) \
5026 _(map_del_domain_reply) \
5027 _(map_add_del_rule_reply) \
5028 _(want_interface_events_reply) \
5029 _(want_stats_reply) \
5030 _(cop_interface_enable_disable_reply) \
5031 _(cop_whitelist_enable_disable_reply) \
5032 _(sw_interface_clear_stats_reply) \
5033 _(ioam_enable_reply) \
5034 _(ioam_disable_reply) \
5035 _(one_add_del_locator_reply) \
5036 _(one_add_del_local_eid_reply) \
5037 _(one_add_del_remote_mapping_reply) \
5038 _(one_add_del_adjacency_reply) \
5039 _(one_add_del_map_resolver_reply) \
5040 _(one_add_del_map_server_reply) \
5041 _(one_enable_disable_reply) \
5042 _(one_rloc_probe_enable_disable_reply) \
5043 _(one_map_register_enable_disable_reply) \
5044 _(one_map_register_set_ttl_reply) \
5045 _(one_set_transport_protocol_reply) \
5046 _(one_map_register_fallback_threshold_reply) \
5047 _(one_pitr_set_locator_set_reply) \
5048 _(one_map_request_mode_reply) \
5049 _(one_add_del_map_request_itr_rlocs_reply) \
5050 _(one_eid_table_add_del_map_reply) \
5051 _(one_use_petr_reply) \
5052 _(one_stats_enable_disable_reply) \
5053 _(one_add_del_l2_arp_entry_reply) \
5054 _(one_add_del_ndp_entry_reply) \
5055 _(one_stats_flush_reply) \
5056 _(gpe_enable_disable_reply) \
5057 _(gpe_set_encap_mode_reply) \
5058 _(gpe_add_del_iface_reply) \
5059 _(gpe_add_del_native_fwd_rpath_reply) \
5060 _(af_packet_delete_reply) \
5061 _(policer_classify_set_interface_reply) \
5062 _(netmap_create_reply) \
5063 _(netmap_delete_reply) \
5064 _(set_ipfix_exporter_reply) \
5065 _(set_ipfix_classify_stream_reply) \
5066 _(ipfix_classify_table_add_del_reply) \
5067 _(flow_classify_set_interface_reply) \
5068 _(sw_interface_span_enable_disable_reply) \
5069 _(pg_capture_reply) \
5070 _(pg_enable_disable_reply) \
5071 _(ip_source_and_port_range_check_add_del_reply) \
5072 _(ip_source_and_port_range_check_interface_add_del_reply)\
5073 _(delete_subif_reply) \
5074 _(l2_interface_pbb_tag_rewrite_reply) \
5076 _(feature_enable_disable_reply) \
5077 _(sw_interface_tag_add_del_reply) \
5078 _(sw_interface_set_mtu_reply) \
5079 _(p2p_ethernet_add_reply) \
5080 _(p2p_ethernet_del_reply) \
5081 _(lldp_config_reply) \
5082 _(sw_interface_set_lldp_reply) \
5083 _(tcp_configure_src_addresses_reply)
5086 static void vl_api_##n##_t_handler \
5087 (vl_api_##n##_t * mp) \
5089 vat_main_t * vam = &vat_main; \
5090 i32 retval = ntohl(mp->retval); \
5091 if (vam->async_mode) { \
5092 vam->async_errors += (retval < 0); \
5094 vam->retval = retval; \
5095 vam->result_ready = 1; \
5098 foreach_standard_reply_retval_handler;
5102 static void vl_api_##n##_t_handler_json \
5103 (vl_api_##n##_t * mp) \
5105 vat_main_t * vam = &vat_main; \
5106 vat_json_node_t node; \
5107 vat_json_init_object(&node); \
5108 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5109 vat_json_print(vam->ofp, &node); \
5110 vam->retval = ntohl(mp->retval); \
5111 vam->result_ready = 1; \
5113 foreach_standard_reply_retval_handler;
5117 * Table of message reply handlers, must include boilerplate handlers
5121 #define foreach_vpe_api_reply_msg \
5122 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5123 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5124 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5125 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5126 _(CONTROL_PING_REPLY, control_ping_reply) \
5127 _(CLI_REPLY, cli_reply) \
5128 _(CLI_INBAND_REPLY, cli_inband_reply) \
5129 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5130 sw_interface_add_del_address_reply) \
5131 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5132 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5133 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5134 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5135 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5136 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5137 sw_interface_set_l2_xconnect_reply) \
5138 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5139 sw_interface_set_l2_bridge_reply) \
5140 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5141 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5142 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5143 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5144 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5145 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5146 _(L2_FLAGS_REPLY, l2_flags_reply) \
5147 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5148 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5149 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5150 _(TAP_DELETE_REPLY, tap_delete_reply) \
5151 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5152 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5153 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5154 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5155 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5156 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5157 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5158 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5159 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5160 proxy_arp_intfc_enable_disable_reply) \
5161 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5162 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5163 sw_interface_set_unnumbered_reply) \
5164 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5165 _(RESET_VRF_REPLY, reset_vrf_reply) \
5166 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5167 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5168 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5169 _(RESET_FIB_REPLY, reset_fib_reply) \
5170 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5171 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5172 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5173 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5174 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5175 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5176 sw_interface_ip6_enable_disable_reply) \
5177 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5178 sw_interface_ip6_set_link_local_address_reply) \
5179 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5180 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5181 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5182 sw_interface_ip6nd_ra_prefix_reply) \
5183 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5184 sw_interface_ip6nd_ra_config_reply) \
5185 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5186 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5187 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5188 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5189 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5190 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5191 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5192 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5193 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5194 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5195 classify_set_interface_ip_table_reply) \
5196 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5197 classify_set_interface_l2_tables_reply) \
5198 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5199 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5200 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5201 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5202 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5203 l2tpv3_interface_enable_disable_reply) \
5204 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5205 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5206 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5207 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5208 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5209 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5210 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5211 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5212 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5213 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5214 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5215 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5216 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5217 _(SHOW_VERSION_REPLY, show_version_reply) \
5218 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5219 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5220 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5221 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5222 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5223 _(IP4_ARP_EVENT, ip4_arp_event) \
5224 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5225 _(IP6_ND_EVENT, ip6_nd_event) \
5226 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5227 _(L2_MACS_EVENT, l2_macs_event) \
5228 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5229 _(IP_ADDRESS_DETAILS, ip_address_details) \
5230 _(IP_DETAILS, ip_details) \
5231 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5232 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5233 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5234 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5235 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5236 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5237 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5238 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5239 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5240 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5241 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5242 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5243 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5244 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5245 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5246 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5247 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5248 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5249 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5250 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5251 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5252 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5253 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5254 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5255 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5256 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5257 _(MAP_RULE_DETAILS, map_rule_details) \
5258 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5259 _(WANT_STATS_REPLY, want_stats_reply) \
5260 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5261 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5262 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5263 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5264 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5265 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5266 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5267 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5268 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5269 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5270 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5271 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5272 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5273 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5274 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5275 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5276 one_map_register_enable_disable_reply) \
5277 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5278 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5279 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5280 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5281 one_map_register_fallback_threshold_reply) \
5282 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5283 one_rloc_probe_enable_disable_reply) \
5284 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5285 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5286 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5287 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5288 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5289 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5290 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5291 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5292 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5293 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5294 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5295 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5296 _(ONE_STATS_DETAILS, one_stats_details) \
5297 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5298 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5299 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5300 show_one_stats_enable_disable_reply) \
5301 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5302 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5303 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5304 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5305 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5306 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5307 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5308 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5309 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5310 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5311 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5312 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5313 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5314 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5315 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5316 gpe_add_del_native_fwd_rpath_reply) \
5317 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5318 gpe_fwd_entry_path_details) \
5319 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5320 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5321 one_add_del_map_request_itr_rlocs_reply) \
5322 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5323 one_get_map_request_itr_rlocs_reply) \
5324 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5325 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5326 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5327 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5328 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5329 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5330 show_one_map_register_state_reply) \
5331 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5332 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5333 show_one_map_register_fallback_threshold_reply) \
5334 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5335 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5336 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5337 _(POLICER_DETAILS, policer_details) \
5338 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5339 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5340 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5341 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5342 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5343 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5344 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5345 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5346 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5347 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5348 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5349 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5350 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5351 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5352 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5353 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5354 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5355 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5356 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5357 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5358 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5359 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5360 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5361 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5362 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5363 ip_source_and_port_range_check_add_del_reply) \
5364 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5365 ip_source_and_port_range_check_interface_add_del_reply) \
5366 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5367 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5368 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5369 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5370 _(PUNT_REPLY, punt_reply) \
5371 _(IP_FIB_DETAILS, ip_fib_details) \
5372 _(IP6_FIB_DETAILS, ip6_fib_details) \
5373 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5374 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5375 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5376 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5377 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5378 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5379 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5380 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5381 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5382 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5383 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply)
5385 #define foreach_standalone_reply_msg \
5386 _(SW_INTERFACE_EVENT, sw_interface_event) \
5387 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5388 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5389 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5390 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5391 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5392 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
5393 _(MEMFD_SEGMENT_CREATE_REPLY, memfd_segment_create_reply)
5402 #define STR_VTR_OP_CASE(op) \
5403 case L2_VTR_ ## op: \
5407 str_vtr_op (u32 vtr_op)
5411 STR_VTR_OP_CASE (DISABLED);
5412 STR_VTR_OP_CASE (PUSH_1);
5413 STR_VTR_OP_CASE (PUSH_2);
5414 STR_VTR_OP_CASE (POP_1);
5415 STR_VTR_OP_CASE (POP_2);
5416 STR_VTR_OP_CASE (TRANSLATE_1_1);
5417 STR_VTR_OP_CASE (TRANSLATE_1_2);
5418 STR_VTR_OP_CASE (TRANSLATE_2_1);
5419 STR_VTR_OP_CASE (TRANSLATE_2_2);
5426 dump_sub_interface_table (vat_main_t * vam)
5428 const sw_interface_subif_t *sub = NULL;
5430 if (vam->json_output)
5433 ("JSON output supported only for VPE API calls and dump_stats_table");
5438 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5439 "Interface", "sw_if_index",
5440 "sub id", "dot1ad", "tags", "outer id",
5441 "inner id", "exact", "default", "outer any", "inner any");
5443 vec_foreach (sub, vam->sw_if_subif_table)
5446 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5447 sub->interface_name,
5449 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5450 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5451 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5452 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5453 if (sub->vtr_op != L2_VTR_DISABLED)
5456 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5457 "tag1: %d tag2: %d ]",
5458 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5459 sub->vtr_tag1, sub->vtr_tag2);
5467 name_sort_cmp (void *a1, void *a2)
5469 name_sort_t *n1 = a1;
5470 name_sort_t *n2 = a2;
5472 return strcmp ((char *) n1->name, (char *) n2->name);
5476 dump_interface_table (vat_main_t * vam)
5479 name_sort_t *nses = 0, *ns;
5481 if (vam->json_output)
5484 ("JSON output supported only for VPE API calls and dump_stats_table");
5489 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5491 vec_add2 (nses, ns, 1);
5492 ns->name = (u8 *)(p->key);
5493 ns->value = (u32) p->value[0];
5497 vec_sort_with_function (nses, name_sort_cmp);
5499 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5500 vec_foreach (ns, nses)
5502 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5509 dump_ip_table (vat_main_t * vam, int is_ipv6)
5511 const ip_details_t *det = NULL;
5512 const ip_address_details_t *address = NULL;
5515 print (vam->ofp, "%-12s", "sw_if_index");
5517 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5524 print (vam->ofp, "%-12d", i);
5525 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5530 vec_foreach (address, det->addr)
5534 is_ipv6 ? format_ip6_address : format_ip4_address,
5535 address->ip, address->prefix_length);
5543 dump_ipv4_table (vat_main_t * vam)
5545 if (vam->json_output)
5548 ("JSON output supported only for VPE API calls and dump_stats_table");
5552 return dump_ip_table (vam, 0);
5556 dump_ipv6_table (vat_main_t * vam)
5558 if (vam->json_output)
5561 ("JSON output supported only for VPE API calls and dump_stats_table");
5565 return dump_ip_table (vam, 1);
5569 counter_type_to_str (u8 counter_type, u8 is_combined)
5573 switch (counter_type)
5575 case VNET_INTERFACE_COUNTER_DROP:
5577 case VNET_INTERFACE_COUNTER_PUNT:
5579 case VNET_INTERFACE_COUNTER_IP4:
5581 case VNET_INTERFACE_COUNTER_IP6:
5583 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5585 case VNET_INTERFACE_COUNTER_RX_MISS:
5587 case VNET_INTERFACE_COUNTER_RX_ERROR:
5589 case VNET_INTERFACE_COUNTER_TX_ERROR:
5592 return "INVALID-COUNTER-TYPE";
5597 switch (counter_type)
5599 case VNET_INTERFACE_COUNTER_RX:
5601 case VNET_INTERFACE_COUNTER_TX:
5604 return "INVALID-COUNTER-TYPE";
5610 dump_stats_table (vat_main_t * vam)
5612 vat_json_node_t node;
5613 vat_json_node_t *msg_array;
5614 vat_json_node_t *msg;
5615 vat_json_node_t *counter_array;
5616 vat_json_node_t *counter;
5617 interface_counter_t c;
5619 ip4_fib_counter_t *c4;
5620 ip6_fib_counter_t *c6;
5621 ip4_nbr_counter_t *n4;
5622 ip6_nbr_counter_t *n6;
5625 if (!vam->json_output)
5627 clib_warning ("dump_stats_table supported only in JSON format");
5631 vat_json_init_object (&node);
5633 /* interface counters */
5634 msg_array = vat_json_object_add (&node, "interface_counters");
5635 vat_json_init_array (msg_array);
5636 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5638 msg = vat_json_array_add (msg_array);
5639 vat_json_init_object (msg);
5640 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5641 (u8 *) counter_type_to_str (i, 0));
5642 vat_json_object_add_int (msg, "is_combined", 0);
5643 counter_array = vat_json_object_add (msg, "data");
5644 vat_json_init_array (counter_array);
5645 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5647 packets = vam->simple_interface_counters[i][j];
5648 vat_json_array_add_uint (counter_array, packets);
5651 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5653 msg = vat_json_array_add (msg_array);
5654 vat_json_init_object (msg);
5655 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5656 (u8 *) counter_type_to_str (i, 1));
5657 vat_json_object_add_int (msg, "is_combined", 1);
5658 counter_array = vat_json_object_add (msg, "data");
5659 vat_json_init_array (counter_array);
5660 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5662 c = vam->combined_interface_counters[i][j];
5663 counter = vat_json_array_add (counter_array);
5664 vat_json_init_object (counter);
5665 vat_json_object_add_uint (counter, "packets", c.packets);
5666 vat_json_object_add_uint (counter, "bytes", c.bytes);
5670 /* ip4 fib counters */
5671 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5672 vat_json_init_array (msg_array);
5673 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5675 msg = vat_json_array_add (msg_array);
5676 vat_json_init_object (msg);
5677 vat_json_object_add_uint (msg, "vrf_id",
5678 vam->ip4_fib_counters_vrf_id_by_index[i]);
5679 counter_array = vat_json_object_add (msg, "c");
5680 vat_json_init_array (counter_array);
5681 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5683 counter = vat_json_array_add (counter_array);
5684 vat_json_init_object (counter);
5685 c4 = &vam->ip4_fib_counters[i][j];
5686 vat_json_object_add_ip4 (counter, "address", c4->address);
5687 vat_json_object_add_uint (counter, "address_length",
5688 c4->address_length);
5689 vat_json_object_add_uint (counter, "packets", c4->packets);
5690 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5694 /* ip6 fib counters */
5695 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5696 vat_json_init_array (msg_array);
5697 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5699 msg = vat_json_array_add (msg_array);
5700 vat_json_init_object (msg);
5701 vat_json_object_add_uint (msg, "vrf_id",
5702 vam->ip6_fib_counters_vrf_id_by_index[i]);
5703 counter_array = vat_json_object_add (msg, "c");
5704 vat_json_init_array (counter_array);
5705 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5707 counter = vat_json_array_add (counter_array);
5708 vat_json_init_object (counter);
5709 c6 = &vam->ip6_fib_counters[i][j];
5710 vat_json_object_add_ip6 (counter, "address", c6->address);
5711 vat_json_object_add_uint (counter, "address_length",
5712 c6->address_length);
5713 vat_json_object_add_uint (counter, "packets", c6->packets);
5714 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5718 /* ip4 nbr counters */
5719 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5720 vat_json_init_array (msg_array);
5721 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5723 msg = vat_json_array_add (msg_array);
5724 vat_json_init_object (msg);
5725 vat_json_object_add_uint (msg, "sw_if_index", i);
5726 counter_array = vat_json_object_add (msg, "c");
5727 vat_json_init_array (counter_array);
5728 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5730 counter = vat_json_array_add (counter_array);
5731 vat_json_init_object (counter);
5732 n4 = &vam->ip4_nbr_counters[i][j];
5733 vat_json_object_add_ip4 (counter, "address", n4->address);
5734 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5735 vat_json_object_add_uint (counter, "packets", n4->packets);
5736 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5740 /* ip6 nbr counters */
5741 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5742 vat_json_init_array (msg_array);
5743 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5745 msg = vat_json_array_add (msg_array);
5746 vat_json_init_object (msg);
5747 vat_json_object_add_uint (msg, "sw_if_index", i);
5748 counter_array = vat_json_object_add (msg, "c");
5749 vat_json_init_array (counter_array);
5750 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5752 counter = vat_json_array_add (counter_array);
5753 vat_json_init_object (counter);
5754 n6 = &vam->ip6_nbr_counters[i][j];
5755 vat_json_object_add_ip6 (counter, "address", n6->address);
5756 vat_json_object_add_uint (counter, "packets", n6->packets);
5757 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5761 vat_json_print (vam->ofp, &node);
5762 vat_json_free (&node);
5768 * Pass CLI buffers directly in the CLI_INBAND API message,
5769 * instead of an additional shared memory area.
5772 exec_inband (vat_main_t * vam)
5774 vl_api_cli_inband_t *mp;
5775 unformat_input_t *i = vam->input;
5778 if (vec_len (i->buffer) == 0)
5781 if (vam->exec_mode == 0 && unformat (i, "mode"))
5786 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5793 * In order for the CLI command to work, it
5794 * must be a vector ending in \n, not a C-string ending
5797 u32 len = vec_len (vam->input->buffer);
5798 M2 (CLI_INBAND, mp, len);
5799 clib_memcpy (mp->cmd, vam->input->buffer, len);
5800 mp->length = htonl (len);
5804 /* json responses may or may not include a useful reply... */
5805 if (vec_len (vam->cmd_reply))
5806 print (vam->ofp, (char *) (vam->cmd_reply));
5811 exec (vat_main_t * vam)
5813 return exec_inband (vam);
5817 api_create_loopback (vat_main_t * vam)
5819 unformat_input_t *i = vam->input;
5820 vl_api_create_loopback_t *mp;
5821 vl_api_create_loopback_instance_t *mp_lbi;
5824 u8 is_specified = 0;
5825 u32 user_instance = 0;
5828 memset (mac_address, 0, sizeof (mac_address));
5830 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5832 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5834 if (unformat (i, "instance %d", &user_instance))
5842 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5843 mp_lbi->is_specified = is_specified;
5845 mp_lbi->user_instance = htonl (user_instance);
5847 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5852 /* Construct the API message */
5853 M (CREATE_LOOPBACK, mp);
5855 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5864 api_delete_loopback (vat_main_t * vam)
5866 unformat_input_t *i = vam->input;
5867 vl_api_delete_loopback_t *mp;
5868 u32 sw_if_index = ~0;
5871 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5873 if (unformat (i, "sw_if_index %d", &sw_if_index))
5879 if (sw_if_index == ~0)
5881 errmsg ("missing sw_if_index");
5885 /* Construct the API message */
5886 M (DELETE_LOOPBACK, mp);
5887 mp->sw_if_index = ntohl (sw_if_index);
5895 api_want_stats (vat_main_t * vam)
5897 unformat_input_t *i = vam->input;
5898 vl_api_want_stats_t *mp;
5902 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5904 if (unformat (i, "enable"))
5906 else if (unformat (i, "disable"))
5914 errmsg ("missing enable|disable");
5919 mp->enable_disable = enable;
5927 api_want_interface_events (vat_main_t * vam)
5929 unformat_input_t *i = vam->input;
5930 vl_api_want_interface_events_t *mp;
5934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5936 if (unformat (i, "enable"))
5938 else if (unformat (i, "disable"))
5946 errmsg ("missing enable|disable");
5950 M (WANT_INTERFACE_EVENTS, mp);
5951 mp->enable_disable = enable;
5953 vam->interface_event_display = enable;
5961 /* Note: non-static, called once to set up the initial intfc table */
5963 api_sw_interface_dump (vat_main_t * vam)
5965 vl_api_sw_interface_dump_t *mp;
5966 vl_api_control_ping_t *mp_ping;
5968 name_sort_t *nses = 0, *ns;
5969 sw_interface_subif_t *sub = NULL;
5972 /* Toss the old name table */
5974 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5976 vec_add2 (nses, ns, 1);
5977 ns->name = (u8 *)(p->key);
5978 ns->value = (u32) p->value[0];
5982 hash_free (vam->sw_if_index_by_interface_name);
5984 vec_foreach (ns, nses) vec_free (ns->name);
5988 vec_foreach (sub, vam->sw_if_subif_table)
5990 vec_free (sub->interface_name);
5992 vec_free (vam->sw_if_subif_table);
5994 /* recreate the interface name hash table */
5995 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5997 /* Get list of ethernets */
5998 M (SW_INTERFACE_DUMP, mp);
5999 mp->name_filter_valid = 1;
6000 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
6003 /* and local / loopback interfaces */
6004 M (SW_INTERFACE_DUMP, mp);
6005 mp->name_filter_valid = 1;
6006 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
6009 /* and packet-generator interfaces */
6010 M (SW_INTERFACE_DUMP, mp);
6011 mp->name_filter_valid = 1;
6012 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
6015 /* and vxlan-gpe tunnel interfaces */
6016 M (SW_INTERFACE_DUMP, mp);
6017 mp->name_filter_valid = 1;
6018 strncpy ((char *) mp->name_filter, "vxlan_gpe",
6019 sizeof (mp->name_filter) - 1);
6022 /* and vxlan tunnel interfaces */
6023 M (SW_INTERFACE_DUMP, mp);
6024 mp->name_filter_valid = 1;
6025 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
6028 /* and host (af_packet) interfaces */
6029 M (SW_INTERFACE_DUMP, mp);
6030 mp->name_filter_valid = 1;
6031 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
6034 /* and l2tpv3 tunnel interfaces */
6035 M (SW_INTERFACE_DUMP, mp);
6036 mp->name_filter_valid = 1;
6037 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
6038 sizeof (mp->name_filter) - 1);
6041 /* and GRE tunnel interfaces */
6042 M (SW_INTERFACE_DUMP, mp);
6043 mp->name_filter_valid = 1;
6044 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
6047 /* and LISP-GPE interfaces */
6048 M (SW_INTERFACE_DUMP, mp);
6049 mp->name_filter_valid = 1;
6050 strncpy ((char *) mp->name_filter, "lisp_gpe",
6051 sizeof (mp->name_filter) - 1);
6054 /* and IPSEC tunnel interfaces */
6055 M (SW_INTERFACE_DUMP, mp);
6056 mp->name_filter_valid = 1;
6057 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
6060 /* Use a control ping for synchronization */
6061 MPING (CONTROL_PING, mp_ping);
6069 api_sw_interface_set_flags (vat_main_t * vam)
6071 unformat_input_t *i = vam->input;
6072 vl_api_sw_interface_set_flags_t *mp;
6074 u8 sw_if_index_set = 0;
6078 /* Parse args required to build the message */
6079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6081 if (unformat (i, "admin-up"))
6083 else if (unformat (i, "admin-down"))
6086 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6087 sw_if_index_set = 1;
6088 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6089 sw_if_index_set = 1;
6094 if (sw_if_index_set == 0)
6096 errmsg ("missing interface name or sw_if_index");
6100 /* Construct the API message */
6101 M (SW_INTERFACE_SET_FLAGS, mp);
6102 mp->sw_if_index = ntohl (sw_if_index);
6103 mp->admin_up_down = admin_up;
6108 /* Wait for a reply, return the good/bad news... */
6114 api_sw_interface_clear_stats (vat_main_t * vam)
6116 unformat_input_t *i = vam->input;
6117 vl_api_sw_interface_clear_stats_t *mp;
6119 u8 sw_if_index_set = 0;
6122 /* Parse args required to build the message */
6123 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6125 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6126 sw_if_index_set = 1;
6127 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6128 sw_if_index_set = 1;
6133 /* Construct the API message */
6134 M (SW_INTERFACE_CLEAR_STATS, mp);
6136 if (sw_if_index_set == 1)
6137 mp->sw_if_index = ntohl (sw_if_index);
6139 mp->sw_if_index = ~0;
6144 /* Wait for a reply, return the good/bad news... */
6150 api_sw_interface_add_del_address (vat_main_t * vam)
6152 unformat_input_t *i = vam->input;
6153 vl_api_sw_interface_add_del_address_t *mp;
6155 u8 sw_if_index_set = 0;
6156 u8 is_add = 1, del_all = 0;
6157 u32 address_length = 0;
6158 u8 v4_address_set = 0;
6159 u8 v6_address_set = 0;
6160 ip4_address_t v4address;
6161 ip6_address_t v6address;
6164 /* Parse args required to build the message */
6165 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6167 if (unformat (i, "del-all"))
6169 else if (unformat (i, "del"))
6172 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6173 sw_if_index_set = 1;
6174 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6175 sw_if_index_set = 1;
6176 else if (unformat (i, "%U/%d",
6177 unformat_ip4_address, &v4address, &address_length))
6179 else if (unformat (i, "%U/%d",
6180 unformat_ip6_address, &v6address, &address_length))
6186 if (sw_if_index_set == 0)
6188 errmsg ("missing interface name or sw_if_index");
6191 if (v4_address_set && v6_address_set)
6193 errmsg ("both v4 and v6 addresses set");
6196 if (!v4_address_set && !v6_address_set && !del_all)
6198 errmsg ("no addresses set");
6202 /* Construct the API message */
6203 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6205 mp->sw_if_index = ntohl (sw_if_index);
6206 mp->is_add = is_add;
6207 mp->del_all = del_all;
6211 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6215 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6217 mp->address_length = address_length;
6222 /* Wait for a reply, return good/bad news */
6228 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6230 unformat_input_t *i = vam->input;
6231 vl_api_sw_interface_set_mpls_enable_t *mp;
6233 u8 sw_if_index_set = 0;
6237 /* Parse args required to build the message */
6238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6240 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6241 sw_if_index_set = 1;
6242 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6243 sw_if_index_set = 1;
6244 else if (unformat (i, "disable"))
6246 else if (unformat (i, "dis"))
6252 if (sw_if_index_set == 0)
6254 errmsg ("missing interface name or sw_if_index");
6258 /* Construct the API message */
6259 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6261 mp->sw_if_index = ntohl (sw_if_index);
6262 mp->enable = enable;
6267 /* Wait for a reply... */
6273 api_sw_interface_set_table (vat_main_t * vam)
6275 unformat_input_t *i = vam->input;
6276 vl_api_sw_interface_set_table_t *mp;
6277 u32 sw_if_index, vrf_id = 0;
6278 u8 sw_if_index_set = 0;
6282 /* Parse args required to build the message */
6283 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6285 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6286 sw_if_index_set = 1;
6287 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6288 sw_if_index_set = 1;
6289 else if (unformat (i, "vrf %d", &vrf_id))
6291 else if (unformat (i, "ipv6"))
6297 if (sw_if_index_set == 0)
6299 errmsg ("missing interface name or sw_if_index");
6303 /* Construct the API message */
6304 M (SW_INTERFACE_SET_TABLE, mp);
6306 mp->sw_if_index = ntohl (sw_if_index);
6307 mp->is_ipv6 = is_ipv6;
6308 mp->vrf_id = ntohl (vrf_id);
6313 /* Wait for a reply... */
6318 static void vl_api_sw_interface_get_table_reply_t_handler
6319 (vl_api_sw_interface_get_table_reply_t * mp)
6321 vat_main_t *vam = &vat_main;
6323 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6325 vam->retval = ntohl (mp->retval);
6326 vam->result_ready = 1;
6330 static void vl_api_sw_interface_get_table_reply_t_handler_json
6331 (vl_api_sw_interface_get_table_reply_t * mp)
6333 vat_main_t *vam = &vat_main;
6334 vat_json_node_t node;
6336 vat_json_init_object (&node);
6337 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6338 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6340 vat_json_print (vam->ofp, &node);
6341 vat_json_free (&node);
6343 vam->retval = ntohl (mp->retval);
6344 vam->result_ready = 1;
6348 api_sw_interface_get_table (vat_main_t * vam)
6350 unformat_input_t *i = vam->input;
6351 vl_api_sw_interface_get_table_t *mp;
6353 u8 sw_if_index_set = 0;
6357 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6359 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6360 sw_if_index_set = 1;
6361 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6362 sw_if_index_set = 1;
6363 else if (unformat (i, "ipv6"))
6369 if (sw_if_index_set == 0)
6371 errmsg ("missing interface name or sw_if_index");
6375 M (SW_INTERFACE_GET_TABLE, mp);
6376 mp->sw_if_index = htonl (sw_if_index);
6377 mp->is_ipv6 = is_ipv6;
6385 api_sw_interface_set_vpath (vat_main_t * vam)
6387 unformat_input_t *i = vam->input;
6388 vl_api_sw_interface_set_vpath_t *mp;
6389 u32 sw_if_index = 0;
6390 u8 sw_if_index_set = 0;
6394 /* Parse args required to build the message */
6395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6397 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6398 sw_if_index_set = 1;
6399 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6400 sw_if_index_set = 1;
6401 else if (unformat (i, "enable"))
6403 else if (unformat (i, "disable"))
6409 if (sw_if_index_set == 0)
6411 errmsg ("missing interface name or sw_if_index");
6415 /* Construct the API message */
6416 M (SW_INTERFACE_SET_VPATH, mp);
6418 mp->sw_if_index = ntohl (sw_if_index);
6419 mp->enable = is_enable;
6424 /* Wait for a reply... */
6430 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6432 unformat_input_t *i = vam->input;
6433 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6434 u32 sw_if_index = 0;
6435 u8 sw_if_index_set = 0;
6440 /* Parse args required to build the message */
6441 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6443 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6444 sw_if_index_set = 1;
6445 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6446 sw_if_index_set = 1;
6447 else if (unformat (i, "enable"))
6449 else if (unformat (i, "disable"))
6451 else if (unformat (i, "ip4"))
6453 else if (unformat (i, "ip6"))
6459 if (sw_if_index_set == 0)
6461 errmsg ("missing interface name or sw_if_index");
6465 /* Construct the API message */
6466 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6468 mp->sw_if_index = ntohl (sw_if_index);
6469 mp->enable = is_enable;
6470 mp->is_ipv6 = is_ipv6;
6475 /* Wait for a reply... */
6482 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6484 unformat_input_t *i = vam->input;
6485 vl_api_sw_interface_set_l2_xconnect_t *mp;
6487 u8 rx_sw_if_index_set = 0;
6489 u8 tx_sw_if_index_set = 0;
6493 /* Parse args required to build the message */
6494 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6496 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6497 rx_sw_if_index_set = 1;
6498 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6499 tx_sw_if_index_set = 1;
6500 else if (unformat (i, "rx"))
6502 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6504 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6506 rx_sw_if_index_set = 1;
6511 else if (unformat (i, "tx"))
6513 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6515 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6517 tx_sw_if_index_set = 1;
6522 else if (unformat (i, "enable"))
6524 else if (unformat (i, "disable"))
6530 if (rx_sw_if_index_set == 0)
6532 errmsg ("missing rx interface name or rx_sw_if_index");
6536 if (enable && (tx_sw_if_index_set == 0))
6538 errmsg ("missing tx interface name or tx_sw_if_index");
6542 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6544 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6545 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6546 mp->enable = enable;
6554 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6556 unformat_input_t *i = vam->input;
6557 vl_api_sw_interface_set_l2_bridge_t *mp;
6559 u8 rx_sw_if_index_set = 0;
6567 /* Parse args required to build the message */
6568 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6570 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6571 rx_sw_if_index_set = 1;
6572 else if (unformat (i, "bd_id %d", &bd_id))
6576 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6577 rx_sw_if_index_set = 1;
6578 else if (unformat (i, "shg %d", &shg))
6580 else if (unformat (i, "bvi"))
6582 else if (unformat (i, "enable"))
6584 else if (unformat (i, "disable"))
6590 if (rx_sw_if_index_set == 0)
6592 errmsg ("missing rx interface name or sw_if_index");
6596 if (enable && (bd_id_set == 0))
6598 errmsg ("missing bridge domain");
6602 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6604 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6605 mp->bd_id = ntohl (bd_id);
6608 mp->enable = enable;
6616 api_bridge_domain_dump (vat_main_t * vam)
6618 unformat_input_t *i = vam->input;
6619 vl_api_bridge_domain_dump_t *mp;
6620 vl_api_control_ping_t *mp_ping;
6624 /* Parse args required to build the message */
6625 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6627 if (unformat (i, "bd_id %d", &bd_id))
6633 M (BRIDGE_DOMAIN_DUMP, mp);
6634 mp->bd_id = ntohl (bd_id);
6637 /* Use a control ping for synchronization */
6638 MPING (CONTROL_PING, mp_ping);
6646 api_bridge_domain_add_del (vat_main_t * vam)
6648 unformat_input_t *i = vam->input;
6649 vl_api_bridge_domain_add_del_t *mp;
6652 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6657 /* Parse args required to build the message */
6658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6660 if (unformat (i, "bd_id %d", &bd_id))
6662 else if (unformat (i, "flood %d", &flood))
6664 else if (unformat (i, "uu-flood %d", &uu_flood))
6666 else if (unformat (i, "forward %d", &forward))
6668 else if (unformat (i, "learn %d", &learn))
6670 else if (unformat (i, "arp-term %d", &arp_term))
6672 else if (unformat (i, "mac-age %d", &mac_age))
6674 else if (unformat (i, "bd-tag %s", &bd_tag))
6676 else if (unformat (i, "del"))
6679 flood = uu_flood = forward = learn = 0;
6687 errmsg ("missing bridge domain");
6694 errmsg ("mac age must be less than 256 ");
6699 if ((bd_tag) && (strlen ((char *) bd_tag) > 63))
6701 errmsg ("bd-tag cannot be longer than 63");
6706 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6708 mp->bd_id = ntohl (bd_id);
6710 mp->uu_flood = uu_flood;
6711 mp->forward = forward;
6713 mp->arp_term = arp_term;
6714 mp->is_add = is_add;
6715 mp->mac_age = (u8) mac_age;
6717 strcpy ((char *) mp->bd_tag, (char *) bd_tag);
6728 api_l2fib_flush_bd (vat_main_t * vam)
6730 unformat_input_t *i = vam->input;
6731 vl_api_l2fib_flush_bd_t *mp;
6735 /* Parse args required to build the message */
6736 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6738 if (unformat (i, "bd_id %d", &bd_id));
6745 errmsg ("missing bridge domain");
6749 M (L2FIB_FLUSH_BD, mp);
6751 mp->bd_id = htonl (bd_id);
6759 api_l2fib_flush_int (vat_main_t * vam)
6761 unformat_input_t *i = vam->input;
6762 vl_api_l2fib_flush_int_t *mp;
6763 u32 sw_if_index = ~0;
6766 /* Parse args required to build the message */
6767 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6769 if (unformat (i, "sw_if_index %d", &sw_if_index));
6771 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6776 if (sw_if_index == ~0)
6778 errmsg ("missing interface name or sw_if_index");
6782 M (L2FIB_FLUSH_INT, mp);
6784 mp->sw_if_index = ntohl (sw_if_index);
6792 api_l2fib_add_del (vat_main_t * vam)
6794 unformat_input_t *i = vam->input;
6795 vl_api_l2fib_add_del_t *mp;
6801 u32 sw_if_index = ~0;
6802 u8 sw_if_index_set = 0;
6811 /* Parse args required to build the message */
6812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6814 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6816 else if (unformat (i, "bd_id %d", &bd_id))
6818 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6819 sw_if_index_set = 1;
6820 else if (unformat (i, "sw_if"))
6822 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6825 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6826 sw_if_index_set = 1;
6831 else if (unformat (i, "static"))
6833 else if (unformat (i, "filter"))
6838 else if (unformat (i, "bvi"))
6843 else if (unformat (i, "del"))
6845 else if (unformat (i, "count %d", &count))
6853 errmsg ("missing mac address");
6859 errmsg ("missing bridge domain");
6863 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6865 errmsg ("missing interface name or sw_if_index");
6871 /* Turn on async mode */
6872 vam->async_mode = 1;
6873 vam->async_errors = 0;
6874 before = vat_time_now (vam);
6877 for (j = 0; j < count; j++)
6879 M (L2FIB_ADD_DEL, mp);
6882 mp->bd_id = ntohl (bd_id);
6883 mp->is_add = is_add;
6887 mp->sw_if_index = ntohl (sw_if_index);
6888 mp->static_mac = static_mac;
6889 mp->filter_mac = filter_mac;
6890 mp->bvi_mac = bvi_mac;
6892 increment_mac_address (&mac);
6899 vl_api_control_ping_t *mp_ping;
6902 /* Shut off async mode */
6903 vam->async_mode = 0;
6905 MPING (CONTROL_PING, mp_ping);
6908 timeout = vat_time_now (vam) + 1.0;
6909 while (vat_time_now (vam) < timeout)
6910 if (vam->result_ready == 1)
6915 if (vam->retval == -99)
6918 if (vam->async_errors > 0)
6920 errmsg ("%d asynchronous errors", vam->async_errors);
6923 vam->async_errors = 0;
6924 after = vat_time_now (vam);
6926 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6927 count, after - before, count / (after - before));
6933 /* Wait for a reply... */
6937 /* Return the good/bad news */
6938 return (vam->retval);
6942 api_bridge_domain_set_mac_age (vat_main_t * vam)
6944 unformat_input_t *i = vam->input;
6945 vl_api_bridge_domain_set_mac_age_t *mp;
6950 /* Parse args required to build the message */
6951 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6953 if (unformat (i, "bd_id %d", &bd_id));
6954 else if (unformat (i, "mac-age %d", &mac_age));
6961 errmsg ("missing bridge domain");
6967 errmsg ("mac age must be less than 256 ");
6971 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6973 mp->bd_id = htonl (bd_id);
6974 mp->mac_age = (u8) mac_age;
6982 api_l2_flags (vat_main_t * vam)
6984 unformat_input_t *i = vam->input;
6985 vl_api_l2_flags_t *mp;
6988 u8 sw_if_index_set = 0;
6992 /* Parse args required to build the message */
6993 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6995 if (unformat (i, "sw_if_index %d", &sw_if_index))
6996 sw_if_index_set = 1;
6997 else if (unformat (i, "sw_if"))
6999 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7002 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7003 sw_if_index_set = 1;
7008 else if (unformat (i, "learn"))
7010 else if (unformat (i, "forward"))
7012 else if (unformat (i, "flood"))
7014 else if (unformat (i, "uu-flood"))
7015 flags |= L2_UU_FLOOD;
7016 else if (unformat (i, "arp-term"))
7017 flags |= L2_ARP_TERM;
7018 else if (unformat (i, "off"))
7020 else if (unformat (i, "disable"))
7026 if (sw_if_index_set == 0)
7028 errmsg ("missing interface name or sw_if_index");
7034 mp->sw_if_index = ntohl (sw_if_index);
7035 mp->feature_bitmap = ntohl (flags);
7036 mp->is_set = is_set;
7044 api_bridge_flags (vat_main_t * vam)
7046 unformat_input_t *i = vam->input;
7047 vl_api_bridge_flags_t *mp;
7054 /* Parse args required to build the message */
7055 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7057 if (unformat (i, "bd_id %d", &bd_id))
7059 else if (unformat (i, "learn"))
7061 else if (unformat (i, "forward"))
7063 else if (unformat (i, "flood"))
7065 else if (unformat (i, "uu-flood"))
7066 flags |= L2_UU_FLOOD;
7067 else if (unformat (i, "arp-term"))
7068 flags |= L2_ARP_TERM;
7069 else if (unformat (i, "off"))
7071 else if (unformat (i, "disable"))
7079 errmsg ("missing bridge domain");
7083 M (BRIDGE_FLAGS, mp);
7085 mp->bd_id = ntohl (bd_id);
7086 mp->feature_bitmap = ntohl (flags);
7087 mp->is_set = is_set;
7095 api_bd_ip_mac_add_del (vat_main_t * vam)
7097 unformat_input_t *i = vam->input;
7098 vl_api_bd_ip_mac_add_del_t *mp;
7105 ip4_address_t v4addr;
7106 ip6_address_t v6addr;
7111 /* Parse args required to build the message */
7112 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7114 if (unformat (i, "bd_id %d", &bd_id))
7118 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7122 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7127 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7131 else if (unformat (i, "del"))
7139 errmsg ("missing bridge domain");
7142 else if (ip_set == 0)
7144 errmsg ("missing IP address");
7147 else if (mac_set == 0)
7149 errmsg ("missing MAC address");
7153 M (BD_IP_MAC_ADD_DEL, mp);
7155 mp->bd_id = ntohl (bd_id);
7156 mp->is_ipv6 = is_ipv6;
7157 mp->is_add = is_add;
7159 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7161 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7162 clib_memcpy (mp->mac_address, macaddr, 6);
7169 api_tap_connect (vat_main_t * vam)
7171 unformat_input_t *i = vam->input;
7172 vl_api_tap_connect_t *mp;
7178 ip4_address_t ip4_address;
7180 int ip4_address_set = 0;
7181 ip6_address_t ip6_address;
7183 int ip6_address_set = 0;
7186 memset (mac_address, 0, sizeof (mac_address));
7188 /* Parse args required to build the message */
7189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7191 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7195 else if (unformat (i, "random-mac"))
7197 else if (unformat (i, "tapname %s", &tap_name))
7199 else if (unformat (i, "tag %s", &tag))
7201 else if (unformat (i, "address %U/%d",
7202 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7203 ip4_address_set = 1;
7204 else if (unformat (i, "address %U/%d",
7205 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7206 ip6_address_set = 1;
7213 errmsg ("missing tap name");
7216 if (vec_len (tap_name) > 63)
7218 errmsg ("tap name too long");
7221 vec_add1 (tap_name, 0);
7223 if (vec_len (tag) > 63)
7225 errmsg ("tag too long");
7229 /* Construct the API message */
7230 M (TAP_CONNECT, mp);
7232 mp->use_random_mac = random_mac;
7233 clib_memcpy (mp->mac_address, mac_address, 6);
7234 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7236 clib_memcpy (mp->tag, tag, vec_len (tag));
7238 if (ip4_address_set)
7240 mp->ip4_address_set = 1;
7241 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7242 mp->ip4_mask_width = ip4_mask_width;
7244 if (ip6_address_set)
7246 mp->ip6_address_set = 1;
7247 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7248 mp->ip6_mask_width = ip6_mask_width;
7251 vec_free (tap_name);
7257 /* Wait for a reply... */
7263 api_tap_modify (vat_main_t * vam)
7265 unformat_input_t *i = vam->input;
7266 vl_api_tap_modify_t *mp;
7271 u32 sw_if_index = ~0;
7272 u8 sw_if_index_set = 0;
7275 memset (mac_address, 0, sizeof (mac_address));
7277 /* Parse args required to build the message */
7278 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7280 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7281 sw_if_index_set = 1;
7282 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7283 sw_if_index_set = 1;
7284 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7288 else if (unformat (i, "random-mac"))
7290 else if (unformat (i, "tapname %s", &tap_name))
7296 if (sw_if_index_set == 0)
7298 errmsg ("missing vpp interface name");
7303 errmsg ("missing tap name");
7306 if (vec_len (tap_name) > 63)
7308 errmsg ("tap name too long");
7310 vec_add1 (tap_name, 0);
7312 /* Construct the API message */
7315 mp->use_random_mac = random_mac;
7316 mp->sw_if_index = ntohl (sw_if_index);
7317 clib_memcpy (mp->mac_address, mac_address, 6);
7318 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7319 vec_free (tap_name);
7324 /* Wait for a reply... */
7330 api_tap_delete (vat_main_t * vam)
7332 unformat_input_t *i = vam->input;
7333 vl_api_tap_delete_t *mp;
7334 u32 sw_if_index = ~0;
7335 u8 sw_if_index_set = 0;
7338 /* Parse args required to build the message */
7339 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7341 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7342 sw_if_index_set = 1;
7343 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7344 sw_if_index_set = 1;
7349 if (sw_if_index_set == 0)
7351 errmsg ("missing vpp interface name");
7355 /* Construct the API message */
7358 mp->sw_if_index = ntohl (sw_if_index);
7363 /* Wait for a reply... */
7369 api_ip_table_add_del (vat_main_t * vam)
7371 unformat_input_t *i = vam->input;
7372 vl_api_ip_table_add_del_t *mp;
7378 /* Parse args required to build the message */
7379 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7381 if (unformat (i, "ipv6"))
7383 else if (unformat (i, "del"))
7385 else if (unformat (i, "add"))
7387 else if (unformat (i, "table %d", &table_id))
7391 clib_warning ("parse error '%U'", format_unformat_error, i);
7398 errmsg ("missing table-ID");
7402 /* Construct the API message */
7403 M (IP_TABLE_ADD_DEL, mp);
7405 mp->table_id = ntohl (table_id);
7406 mp->is_ipv6 = is_ipv6;
7407 mp->is_add = is_add;
7412 /* Wait for a reply... */
7419 api_ip_add_del_route (vat_main_t * vam)
7421 unformat_input_t *i = vam->input;
7422 vl_api_ip_add_del_route_t *mp;
7423 u32 sw_if_index = ~0, vrf_id = 0;
7425 u8 is_local = 0, is_drop = 0;
7426 u8 is_unreach = 0, is_prohibit = 0;
7427 u8 create_vrf_if_needed = 0;
7429 u32 next_hop_weight = 1;
7431 u8 is_multipath = 0;
7433 u8 address_length_set = 0;
7434 u32 next_hop_table_id = 0;
7435 u32 resolve_attempts = 0;
7436 u32 dst_address_length = 0;
7437 u8 next_hop_set = 0;
7438 ip4_address_t v4_dst_address, v4_next_hop_address;
7439 ip6_address_t v6_dst_address, v6_next_hop_address;
7443 u32 random_add_del = 0;
7444 u32 *random_vector = 0;
7446 u32 random_seed = 0xdeaddabe;
7447 u32 classify_table_index = ~0;
7449 u8 resolve_host = 0, resolve_attached = 0;
7450 mpls_label_t *next_hop_out_label_stack = NULL;
7451 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7452 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7454 /* Parse args required to build the message */
7455 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7457 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7459 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7461 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
7466 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
7471 else if (unformat (i, "/%d", &dst_address_length))
7473 address_length_set = 1;
7476 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7477 &v4_next_hop_address))
7481 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7482 &v6_next_hop_address))
7486 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7488 else if (unformat (i, "weight %d", &next_hop_weight))
7490 else if (unformat (i, "drop"))
7494 else if (unformat (i, "null-send-unreach"))
7498 else if (unformat (i, "null-send-prohibit"))
7502 else if (unformat (i, "local"))
7506 else if (unformat (i, "classify %d", &classify_table_index))
7510 else if (unformat (i, "del"))
7512 else if (unformat (i, "add"))
7514 else if (unformat (i, "not-last"))
7516 else if (unformat (i, "resolve-via-host"))
7518 else if (unformat (i, "resolve-via-attached"))
7519 resolve_attached = 1;
7520 else if (unformat (i, "multipath"))
7522 else if (unformat (i, "vrf %d", &vrf_id))
7524 else if (unformat (i, "create-vrf"))
7525 create_vrf_if_needed = 1;
7526 else if (unformat (i, "count %d", &count))
7528 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7530 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7532 else if (unformat (i, "out-label %d", &next_hop_out_label))
7533 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7534 else if (unformat (i, "via-label %d", &next_hop_via_label))
7536 else if (unformat (i, "random"))
7538 else if (unformat (i, "seed %d", &random_seed))
7542 clib_warning ("parse error '%U'", format_unformat_error, i);
7547 if (!next_hop_set && !is_drop && !is_local &&
7548 !is_classify && !is_unreach && !is_prohibit &&
7549 MPLS_LABEL_INVALID == next_hop_via_label)
7552 ("next hop / local / drop / unreach / prohibit / classify not set");
7556 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7558 errmsg ("next hop and next-hop via label set");
7561 if (address_set == 0)
7563 errmsg ("missing addresses");
7567 if (address_length_set == 0)
7569 errmsg ("missing address length");
7573 /* Generate a pile of unique, random routes */
7576 u32 this_random_address;
7577 random_hash = hash_create (count, sizeof (uword));
7579 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7580 for (j = 0; j <= count; j++)
7584 this_random_address = random_u32 (&random_seed);
7585 this_random_address =
7586 clib_host_to_net_u32 (this_random_address);
7588 while (hash_get (random_hash, this_random_address));
7589 vec_add1 (random_vector, this_random_address);
7590 hash_set (random_hash, this_random_address, 1);
7592 hash_free (random_hash);
7593 v4_dst_address.as_u32 = random_vector[0];
7598 /* Turn on async mode */
7599 vam->async_mode = 1;
7600 vam->async_errors = 0;
7601 before = vat_time_now (vam);
7604 for (j = 0; j < count; j++)
7606 /* Construct the API message */
7607 M2 (IP_ADD_DEL_ROUTE, mp,
7608 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7610 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7611 mp->table_id = ntohl (vrf_id);
7612 mp->create_vrf_if_needed = create_vrf_if_needed;
7614 mp->is_add = is_add;
7615 mp->is_drop = is_drop;
7616 mp->is_unreach = is_unreach;
7617 mp->is_prohibit = is_prohibit;
7618 mp->is_ipv6 = is_ipv6;
7619 mp->is_local = is_local;
7620 mp->is_classify = is_classify;
7621 mp->is_multipath = is_multipath;
7622 mp->is_resolve_host = resolve_host;
7623 mp->is_resolve_attached = resolve_attached;
7624 mp->not_last = not_last;
7625 mp->next_hop_weight = next_hop_weight;
7626 mp->dst_address_length = dst_address_length;
7627 mp->next_hop_table_id = ntohl (next_hop_table_id);
7628 mp->classify_table_index = ntohl (classify_table_index);
7629 mp->next_hop_via_label = ntohl (next_hop_via_label);
7630 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7631 if (0 != mp->next_hop_n_out_labels)
7633 memcpy (mp->next_hop_out_label_stack,
7634 next_hop_out_label_stack,
7635 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7636 vec_free (next_hop_out_label_stack);
7641 clib_memcpy (mp->dst_address, &v6_dst_address,
7642 sizeof (v6_dst_address));
7644 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
7645 sizeof (v6_next_hop_address));
7646 increment_v6_address (&v6_dst_address);
7650 clib_memcpy (mp->dst_address, &v4_dst_address,
7651 sizeof (v4_dst_address));
7653 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
7654 sizeof (v4_next_hop_address));
7656 v4_dst_address.as_u32 = random_vector[j + 1];
7658 increment_v4_address (&v4_dst_address);
7662 /* If we receive SIGTERM, stop now... */
7667 /* When testing multiple add/del ops, use a control-ping to sync */
7670 vl_api_control_ping_t *mp_ping;
7674 /* Shut off async mode */
7675 vam->async_mode = 0;
7677 MPING (CONTROL_PING, mp_ping);
7680 timeout = vat_time_now (vam) + 1.0;
7681 while (vat_time_now (vam) < timeout)
7682 if (vam->result_ready == 1)
7687 if (vam->retval == -99)
7690 if (vam->async_errors > 0)
7692 errmsg ("%d asynchronous errors", vam->async_errors);
7695 vam->async_errors = 0;
7696 after = vat_time_now (vam);
7698 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7702 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7703 count, after - before, count / (after - before));
7709 /* Wait for a reply... */
7714 /* Return the good/bad news */
7715 return (vam->retval);
7719 api_ip_mroute_add_del (vat_main_t * vam)
7721 unformat_input_t *i = vam->input;
7722 vl_api_ip_mroute_add_del_t *mp;
7723 u32 sw_if_index = ~0, vrf_id = 0;
7726 u8 create_vrf_if_needed = 0;
7729 u32 grp_address_length = 0;
7730 ip4_address_t v4_grp_address, v4_src_address;
7731 ip6_address_t v6_grp_address, v6_src_address;
7732 mfib_itf_flags_t iflags = 0;
7733 mfib_entry_flags_t eflags = 0;
7736 /* Parse args required to build the message */
7737 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7739 if (unformat (i, "sw_if_index %d", &sw_if_index))
7741 else if (unformat (i, "%U %U",
7742 unformat_ip4_address, &v4_src_address,
7743 unformat_ip4_address, &v4_grp_address))
7745 grp_address_length = 64;
7749 else if (unformat (i, "%U %U",
7750 unformat_ip6_address, &v6_src_address,
7751 unformat_ip6_address, &v6_grp_address))
7753 grp_address_length = 256;
7757 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7759 memset (&v4_src_address, 0, sizeof (v4_src_address));
7760 grp_address_length = 32;
7764 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7766 memset (&v6_src_address, 0, sizeof (v6_src_address));
7767 grp_address_length = 128;
7771 else if (unformat (i, "/%d", &grp_address_length))
7773 else if (unformat (i, "local"))
7777 else if (unformat (i, "del"))
7779 else if (unformat (i, "add"))
7781 else if (unformat (i, "vrf %d", &vrf_id))
7783 else if (unformat (i, "create-vrf"))
7784 create_vrf_if_needed = 1;
7785 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7787 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7791 clib_warning ("parse error '%U'", format_unformat_error, i);
7796 if (address_set == 0)
7798 errmsg ("missing addresses\n");
7802 /* Construct the API message */
7803 M (IP_MROUTE_ADD_DEL, mp);
7805 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7806 mp->table_id = ntohl (vrf_id);
7807 mp->create_vrf_if_needed = create_vrf_if_needed;
7809 mp->is_add = is_add;
7810 mp->is_ipv6 = is_ipv6;
7811 mp->is_local = is_local;
7812 mp->itf_flags = ntohl (iflags);
7813 mp->entry_flags = ntohl (eflags);
7814 mp->grp_address_length = grp_address_length;
7815 mp->grp_address_length = ntohs (mp->grp_address_length);
7819 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7820 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7824 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7825 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7831 /* Wait for a reply... */
7837 api_mpls_table_add_del (vat_main_t * vam)
7839 unformat_input_t *i = vam->input;
7840 vl_api_mpls_table_add_del_t *mp;
7845 /* Parse args required to build the message */
7846 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7848 if (unformat (i, "table %d", &table_id))
7850 else if (unformat (i, "del"))
7852 else if (unformat (i, "add"))
7856 clib_warning ("parse error '%U'", format_unformat_error, i);
7863 errmsg ("missing table-ID");
7867 /* Construct the API message */
7868 M (MPLS_TABLE_ADD_DEL, mp);
7870 mp->mt_table_id = ntohl (table_id);
7871 mp->mt_is_add = is_add;
7876 /* Wait for a reply... */
7883 api_mpls_route_add_del (vat_main_t * vam)
7885 unformat_input_t *i = vam->input;
7886 vl_api_mpls_route_add_del_t *mp;
7887 u32 sw_if_index = ~0, table_id = 0;
7888 u8 create_table_if_needed = 0;
7890 u32 next_hop_weight = 1;
7891 u8 is_multipath = 0;
7892 u32 next_hop_table_id = 0;
7893 u8 next_hop_set = 0;
7894 ip4_address_t v4_next_hop_address = {
7897 ip6_address_t v6_next_hop_address = { {0} };
7901 u32 classify_table_index = ~0;
7903 u8 resolve_host = 0, resolve_attached = 0;
7904 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7905 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7906 mpls_label_t *next_hop_out_label_stack = NULL;
7907 mpls_label_t local_label = MPLS_LABEL_INVALID;
7909 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
7911 /* Parse args required to build the message */
7912 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7914 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7916 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7918 else if (unformat (i, "%d", &local_label))
7920 else if (unformat (i, "eos"))
7922 else if (unformat (i, "non-eos"))
7924 else if (unformat (i, "via %U", unformat_ip4_address,
7925 &v4_next_hop_address))
7928 next_hop_proto = DPO_PROTO_IP4;
7930 else if (unformat (i, "via %U", unformat_ip6_address,
7931 &v6_next_hop_address))
7934 next_hop_proto = DPO_PROTO_IP6;
7936 else if (unformat (i, "weight %d", &next_hop_weight))
7938 else if (unformat (i, "create-table"))
7939 create_table_if_needed = 1;
7940 else if (unformat (i, "classify %d", &classify_table_index))
7944 else if (unformat (i, "del"))
7946 else if (unformat (i, "add"))
7948 else if (unformat (i, "resolve-via-host"))
7950 else if (unformat (i, "resolve-via-attached"))
7951 resolve_attached = 1;
7952 else if (unformat (i, "multipath"))
7954 else if (unformat (i, "count %d", &count))
7956 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
7959 next_hop_proto = DPO_PROTO_IP4;
7961 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
7964 next_hop_proto = DPO_PROTO_IP6;
7966 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7968 else if (unformat (i, "via-label %d", &next_hop_via_label))
7970 else if (unformat (i, "out-label %d", &next_hop_out_label))
7971 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7974 clib_warning ("parse error '%U'", format_unformat_error, i);
7979 if (!next_hop_set && !is_classify)
7981 errmsg ("next hop / classify not set");
7985 if (MPLS_LABEL_INVALID == local_label)
7987 errmsg ("missing label");
7993 /* Turn on async mode */
7994 vam->async_mode = 1;
7995 vam->async_errors = 0;
7996 before = vat_time_now (vam);
7999 for (j = 0; j < count; j++)
8001 /* Construct the API message */
8002 M2 (MPLS_ROUTE_ADD_DEL, mp,
8003 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8005 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8006 mp->mr_table_id = ntohl (table_id);
8007 mp->mr_create_table_if_needed = create_table_if_needed;
8009 mp->mr_is_add = is_add;
8010 mp->mr_next_hop_proto = next_hop_proto;
8011 mp->mr_is_classify = is_classify;
8012 mp->mr_is_multipath = is_multipath;
8013 mp->mr_is_resolve_host = resolve_host;
8014 mp->mr_is_resolve_attached = resolve_attached;
8015 mp->mr_next_hop_weight = next_hop_weight;
8016 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8017 mp->mr_classify_table_index = ntohl (classify_table_index);
8018 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8019 mp->mr_label = ntohl (local_label);
8020 mp->mr_eos = is_eos;
8022 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8023 if (0 != mp->mr_next_hop_n_out_labels)
8025 memcpy (mp->mr_next_hop_out_label_stack,
8026 next_hop_out_label_stack,
8027 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8028 vec_free (next_hop_out_label_stack);
8033 if (DPO_PROTO_IP4 == next_hop_proto)
8035 clib_memcpy (mp->mr_next_hop,
8036 &v4_next_hop_address,
8037 sizeof (v4_next_hop_address));
8039 else if (DPO_PROTO_IP6 == next_hop_proto)
8042 clib_memcpy (mp->mr_next_hop,
8043 &v6_next_hop_address,
8044 sizeof (v6_next_hop_address));
8051 /* If we receive SIGTERM, stop now... */
8056 /* When testing multiple add/del ops, use a control-ping to sync */
8059 vl_api_control_ping_t *mp_ping;
8063 /* Shut off async mode */
8064 vam->async_mode = 0;
8066 MPING (CONTROL_PING, mp_ping);
8069 timeout = vat_time_now (vam) + 1.0;
8070 while (vat_time_now (vam) < timeout)
8071 if (vam->result_ready == 1)
8076 if (vam->retval == -99)
8079 if (vam->async_errors > 0)
8081 errmsg ("%d asynchronous errors", vam->async_errors);
8084 vam->async_errors = 0;
8085 after = vat_time_now (vam);
8087 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8091 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8092 count, after - before, count / (after - before));
8098 /* Wait for a reply... */
8103 /* Return the good/bad news */
8104 return (vam->retval);
8108 api_mpls_ip_bind_unbind (vat_main_t * vam)
8110 unformat_input_t *i = vam->input;
8111 vl_api_mpls_ip_bind_unbind_t *mp;
8112 u32 ip_table_id = 0;
8113 u8 create_table_if_needed = 0;
8116 ip4_address_t v4_address;
8117 ip6_address_t v6_address;
8120 mpls_label_t local_label = MPLS_LABEL_INVALID;
8123 /* Parse args required to build the message */
8124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8126 if (unformat (i, "%U/%d", unformat_ip4_address,
8127 &v4_address, &address_length))
8132 else if (unformat (i, "%U/%d", unformat_ip6_address,
8133 &v6_address, &address_length))
8138 else if (unformat (i, "%d", &local_label))
8140 else if (unformat (i, "create-table"))
8141 create_table_if_needed = 1;
8142 else if (unformat (i, "table-id %d", &ip_table_id))
8144 else if (unformat (i, "unbind"))
8146 else if (unformat (i, "bind"))
8150 clib_warning ("parse error '%U'", format_unformat_error, i);
8157 errmsg ("IP addres not set");
8161 if (MPLS_LABEL_INVALID == local_label)
8163 errmsg ("missing label");
8167 /* Construct the API message */
8168 M (MPLS_IP_BIND_UNBIND, mp);
8170 mp->mb_create_table_if_needed = create_table_if_needed;
8171 mp->mb_is_bind = is_bind;
8172 mp->mb_is_ip4 = is_ip4;
8173 mp->mb_ip_table_id = ntohl (ip_table_id);
8174 mp->mb_mpls_table_id = 0;
8175 mp->mb_label = ntohl (local_label);
8176 mp->mb_address_length = address_length;
8179 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8181 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8186 /* Wait for a reply... */
8192 api_proxy_arp_add_del (vat_main_t * vam)
8194 unformat_input_t *i = vam->input;
8195 vl_api_proxy_arp_add_del_t *mp;
8198 ip4_address_t lo, hi;
8202 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8204 if (unformat (i, "vrf %d", &vrf_id))
8206 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
8207 unformat_ip4_address, &hi))
8209 else if (unformat (i, "del"))
8213 clib_warning ("parse error '%U'", format_unformat_error, i);
8220 errmsg ("address range not set");
8224 M (PROXY_ARP_ADD_DEL, mp);
8226 mp->vrf_id = ntohl (vrf_id);
8227 mp->is_add = is_add;
8228 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
8229 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
8237 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8239 unformat_input_t *i = vam->input;
8240 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8243 u8 sw_if_index_set = 0;
8246 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8248 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8249 sw_if_index_set = 1;
8250 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8251 sw_if_index_set = 1;
8252 else if (unformat (i, "enable"))
8254 else if (unformat (i, "disable"))
8258 clib_warning ("parse error '%U'", format_unformat_error, i);
8263 if (sw_if_index_set == 0)
8265 errmsg ("missing interface name or sw_if_index");
8269 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8271 mp->sw_if_index = ntohl (sw_if_index);
8272 mp->enable_disable = enable;
8280 api_mpls_tunnel_add_del (vat_main_t * vam)
8282 unformat_input_t *i = vam->input;
8283 vl_api_mpls_tunnel_add_del_t *mp;
8287 u32 sw_if_index = ~0;
8288 u32 next_hop_sw_if_index = ~0;
8289 u32 next_hop_proto_is_ip4 = 1;
8291 u32 next_hop_table_id = 0;
8292 ip4_address_t v4_next_hop_address = {
8295 ip6_address_t v6_next_hop_address = { {0} };
8296 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
8299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8301 if (unformat (i, "add"))
8303 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8305 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
8307 else if (unformat (i, "via %U",
8308 unformat_ip4_address, &v4_next_hop_address))
8310 next_hop_proto_is_ip4 = 1;
8312 else if (unformat (i, "via %U",
8313 unformat_ip6_address, &v6_next_hop_address))
8315 next_hop_proto_is_ip4 = 0;
8317 else if (unformat (i, "l2-only"))
8319 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8321 else if (unformat (i, "out-label %d", &next_hop_out_label))
8322 vec_add1 (labels, ntohl (next_hop_out_label));
8325 clib_warning ("parse error '%U'", format_unformat_error, i);
8330 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
8332 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
8333 mp->mt_sw_if_index = ntohl (sw_if_index);
8334 mp->mt_is_add = is_add;
8335 mp->mt_l2_only = l2_only;
8336 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
8337 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
8339 mp->mt_next_hop_n_out_labels = vec_len (labels);
8341 if (0 != mp->mt_next_hop_n_out_labels)
8343 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
8344 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
8348 if (next_hop_proto_is_ip4)
8350 clib_memcpy (mp->mt_next_hop,
8351 &v4_next_hop_address, sizeof (v4_next_hop_address));
8355 clib_memcpy (mp->mt_next_hop,
8356 &v6_next_hop_address, sizeof (v6_next_hop_address));
8365 api_sw_interface_set_unnumbered (vat_main_t * vam)
8367 unformat_input_t *i = vam->input;
8368 vl_api_sw_interface_set_unnumbered_t *mp;
8370 u32 unnum_sw_index = ~0;
8372 u8 sw_if_index_set = 0;
8375 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8377 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8378 sw_if_index_set = 1;
8379 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8380 sw_if_index_set = 1;
8381 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8383 else if (unformat (i, "del"))
8387 clib_warning ("parse error '%U'", format_unformat_error, i);
8392 if (sw_if_index_set == 0)
8394 errmsg ("missing interface name or sw_if_index");
8398 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8400 mp->sw_if_index = ntohl (sw_if_index);
8401 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8402 mp->is_add = is_add;
8410 api_ip_neighbor_add_del (vat_main_t * vam)
8412 unformat_input_t *i = vam->input;
8413 vl_api_ip_neighbor_add_del_t *mp;
8415 u8 sw_if_index_set = 0;
8418 u8 is_no_fib_entry = 0;
8421 u8 v4_address_set = 0;
8422 u8 v6_address_set = 0;
8423 ip4_address_t v4address;
8424 ip6_address_t v6address;
8427 memset (mac_address, 0, sizeof (mac_address));
8429 /* Parse args required to build the message */
8430 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8432 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8436 else if (unformat (i, "del"))
8439 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8440 sw_if_index_set = 1;
8441 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8442 sw_if_index_set = 1;
8443 else if (unformat (i, "is_static"))
8445 else if (unformat (i, "no-fib-entry"))
8446 is_no_fib_entry = 1;
8447 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
8449 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
8453 clib_warning ("parse error '%U'", format_unformat_error, i);
8458 if (sw_if_index_set == 0)
8460 errmsg ("missing interface name or sw_if_index");
8463 if (v4_address_set && v6_address_set)
8465 errmsg ("both v4 and v6 addresses set");
8468 if (!v4_address_set && !v6_address_set)
8470 errmsg ("no address set");
8474 /* Construct the API message */
8475 M (IP_NEIGHBOR_ADD_DEL, mp);
8477 mp->sw_if_index = ntohl (sw_if_index);
8478 mp->is_add = is_add;
8479 mp->is_static = is_static;
8480 mp->is_no_adj_fib = is_no_fib_entry;
8482 clib_memcpy (mp->mac_address, mac_address, 6);
8486 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
8490 /* mp->is_ipv6 = 0; via memset in M macro above */
8491 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
8497 /* Wait for a reply, return good/bad news */
8503 api_reset_vrf (vat_main_t * vam)
8505 unformat_input_t *i = vam->input;
8506 vl_api_reset_vrf_t *mp;
8512 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8514 if (unformat (i, "vrf %d", &vrf_id))
8516 else if (unformat (i, "ipv6"))
8520 clib_warning ("parse error '%U'", format_unformat_error, i);
8525 if (vrf_id_set == 0)
8527 errmsg ("missing vrf id");
8533 mp->vrf_id = ntohl (vrf_id);
8534 mp->is_ipv6 = is_ipv6;
8542 api_create_vlan_subif (vat_main_t * vam)
8544 unformat_input_t *i = vam->input;
8545 vl_api_create_vlan_subif_t *mp;
8547 u8 sw_if_index_set = 0;
8552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8554 if (unformat (i, "sw_if_index %d", &sw_if_index))
8555 sw_if_index_set = 1;
8557 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8558 sw_if_index_set = 1;
8559 else if (unformat (i, "vlan %d", &vlan_id))
8563 clib_warning ("parse error '%U'", format_unformat_error, i);
8568 if (sw_if_index_set == 0)
8570 errmsg ("missing interface name or sw_if_index");
8574 if (vlan_id_set == 0)
8576 errmsg ("missing vlan_id");
8579 M (CREATE_VLAN_SUBIF, mp);
8581 mp->sw_if_index = ntohl (sw_if_index);
8582 mp->vlan_id = ntohl (vlan_id);
8589 #define foreach_create_subif_bit \
8596 _(outer_vlan_id_any) \
8597 _(inner_vlan_id_any)
8600 api_create_subif (vat_main_t * vam)
8602 unformat_input_t *i = vam->input;
8603 vl_api_create_subif_t *mp;
8605 u8 sw_if_index_set = 0;
8612 u32 exact_match = 0;
8613 u32 default_sub = 0;
8614 u32 outer_vlan_id_any = 0;
8615 u32 inner_vlan_id_any = 0;
8617 u16 outer_vlan_id = 0;
8618 u16 inner_vlan_id = 0;
8621 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8623 if (unformat (i, "sw_if_index %d", &sw_if_index))
8624 sw_if_index_set = 1;
8626 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8627 sw_if_index_set = 1;
8628 else if (unformat (i, "sub_id %d", &sub_id))
8630 else if (unformat (i, "outer_vlan_id %d", &tmp))
8631 outer_vlan_id = tmp;
8632 else if (unformat (i, "inner_vlan_id %d", &tmp))
8633 inner_vlan_id = tmp;
8635 #define _(a) else if (unformat (i, #a)) a = 1 ;
8636 foreach_create_subif_bit
8640 clib_warning ("parse error '%U'", format_unformat_error, i);
8645 if (sw_if_index_set == 0)
8647 errmsg ("missing interface name or sw_if_index");
8651 if (sub_id_set == 0)
8653 errmsg ("missing sub_id");
8656 M (CREATE_SUBIF, mp);
8658 mp->sw_if_index = ntohl (sw_if_index);
8659 mp->sub_id = ntohl (sub_id);
8661 #define _(a) mp->a = a;
8662 foreach_create_subif_bit;
8665 mp->outer_vlan_id = ntohs (outer_vlan_id);
8666 mp->inner_vlan_id = ntohs (inner_vlan_id);
8674 api_oam_add_del (vat_main_t * vam)
8676 unformat_input_t *i = vam->input;
8677 vl_api_oam_add_del_t *mp;
8680 ip4_address_t src, dst;
8685 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8687 if (unformat (i, "vrf %d", &vrf_id))
8689 else if (unformat (i, "src %U", unformat_ip4_address, &src))
8691 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
8693 else if (unformat (i, "del"))
8697 clib_warning ("parse error '%U'", format_unformat_error, i);
8704 errmsg ("missing src addr");
8710 errmsg ("missing dst addr");
8714 M (OAM_ADD_DEL, mp);
8716 mp->vrf_id = ntohl (vrf_id);
8717 mp->is_add = is_add;
8718 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
8719 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8727 api_reset_fib (vat_main_t * vam)
8729 unformat_input_t *i = vam->input;
8730 vl_api_reset_fib_t *mp;
8736 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8738 if (unformat (i, "vrf %d", &vrf_id))
8740 else if (unformat (i, "ipv6"))
8744 clib_warning ("parse error '%U'", format_unformat_error, i);
8749 if (vrf_id_set == 0)
8751 errmsg ("missing vrf id");
8757 mp->vrf_id = ntohl (vrf_id);
8758 mp->is_ipv6 = is_ipv6;
8766 api_dhcp_proxy_config (vat_main_t * vam)
8768 unformat_input_t *i = vam->input;
8769 vl_api_dhcp_proxy_config_t *mp;
8771 u32 server_vrf_id = 0;
8773 u8 v4_address_set = 0;
8774 u8 v6_address_set = 0;
8775 ip4_address_t v4address;
8776 ip6_address_t v6address;
8777 u8 v4_src_address_set = 0;
8778 u8 v6_src_address_set = 0;
8779 ip4_address_t v4srcaddress;
8780 ip6_address_t v6srcaddress;
8783 /* Parse args required to build the message */
8784 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8786 if (unformat (i, "del"))
8788 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8790 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8792 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8794 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8796 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8797 v4_src_address_set = 1;
8798 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8799 v6_src_address_set = 1;
8804 if (v4_address_set && v6_address_set)
8806 errmsg ("both v4 and v6 server addresses set");
8809 if (!v4_address_set && !v6_address_set)
8811 errmsg ("no server addresses set");
8815 if (v4_src_address_set && v6_src_address_set)
8817 errmsg ("both v4 and v6 src addresses set");
8820 if (!v4_src_address_set && !v6_src_address_set)
8822 errmsg ("no src addresses set");
8826 if (!(v4_src_address_set && v4_address_set) &&
8827 !(v6_src_address_set && v6_address_set))
8829 errmsg ("no matching server and src addresses set");
8833 /* Construct the API message */
8834 M (DHCP_PROXY_CONFIG, mp);
8836 mp->is_add = is_add;
8837 mp->rx_vrf_id = ntohl (rx_vrf_id);
8838 mp->server_vrf_id = ntohl (server_vrf_id);
8842 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
8843 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
8847 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
8848 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
8854 /* Wait for a reply, return good/bad news */
8859 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
8860 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
8863 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
8865 vat_main_t *vam = &vat_main;
8866 u32 i, count = mp->count;
8867 vl_api_dhcp_server_t *s;
8871 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8872 ntohl (mp->rx_vrf_id),
8873 format_ip6_address, mp->dhcp_src_address,
8874 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8877 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8878 ntohl (mp->rx_vrf_id),
8879 format_ip4_address, mp->dhcp_src_address,
8880 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8882 for (i = 0; i < count; i++)
8884 s = &mp->servers[i];
8888 " Server Table-ID %d, Server Address %U",
8889 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
8892 " Server Table-ID %d, Server Address %U",
8893 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
8897 static void vl_api_dhcp_proxy_details_t_handler_json
8898 (vl_api_dhcp_proxy_details_t * mp)
8900 vat_main_t *vam = &vat_main;
8901 vat_json_node_t *node = NULL;
8902 u32 i, count = mp->count;
8904 struct in6_addr ip6;
8905 vl_api_dhcp_server_t *s;
8907 if (VAT_JSON_ARRAY != vam->json_tree.type)
8909 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8910 vat_json_init_array (&vam->json_tree);
8912 node = vat_json_array_add (&vam->json_tree);
8914 vat_json_init_object (node);
8915 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
8916 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
8917 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
8921 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
8922 vat_json_object_add_ip6 (node, "src_address", ip6);
8926 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
8927 vat_json_object_add_ip4 (node, "src_address", ip4);
8930 for (i = 0; i < count; i++)
8932 s = &mp->servers[i];
8934 vat_json_object_add_uint (node, "server-table-id",
8935 ntohl (s->server_vrf_id));
8939 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
8940 vat_json_object_add_ip4 (node, "src_address", ip4);
8944 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
8945 vat_json_object_add_ip6 (node, "server_address", ip6);
8951 api_dhcp_proxy_dump (vat_main_t * vam)
8953 unformat_input_t *i = vam->input;
8954 vl_api_control_ping_t *mp_ping;
8955 vl_api_dhcp_proxy_dump_t *mp;
8959 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8961 if (unformat (i, "ipv6"))
8965 clib_warning ("parse error '%U'", format_unformat_error, i);
8970 M (DHCP_PROXY_DUMP, mp);
8972 mp->is_ip6 = is_ipv6;
8975 /* Use a control ping for synchronization */
8976 MPING (CONTROL_PING, mp_ping);
8984 api_dhcp_proxy_set_vss (vat_main_t * vam)
8986 unformat_input_t *i = vam->input;
8987 vl_api_dhcp_proxy_set_vss_t *mp;
8998 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9000 if (unformat (i, "tbl_id %d", &tbl_id))
9002 if (unformat (i, "fib_id %d", &fib_id))
9004 if (unformat (i, "oui %d", &oui))
9006 else if (unformat (i, "ipv6"))
9008 else if (unformat (i, "del"))
9012 clib_warning ("parse error '%U'", format_unformat_error, i);
9017 if (tbl_id_set == 0)
9019 errmsg ("missing tbl id");
9023 if (fib_id_set == 0)
9025 errmsg ("missing fib id");
9030 errmsg ("missing oui");
9034 M (DHCP_PROXY_SET_VSS, mp);
9035 mp->tbl_id = ntohl (tbl_id);
9036 mp->fib_id = ntohl (fib_id);
9037 mp->oui = ntohl (oui);
9038 mp->is_ipv6 = is_ipv6;
9039 mp->is_add = is_add;
9047 api_dhcp_client_config (vat_main_t * vam)
9049 unformat_input_t *i = vam->input;
9050 vl_api_dhcp_client_config_t *mp;
9052 u8 sw_if_index_set = 0;
9055 u8 disable_event = 0;
9058 /* Parse args required to build the message */
9059 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9061 if (unformat (i, "del"))
9064 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9065 sw_if_index_set = 1;
9066 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9067 sw_if_index_set = 1;
9068 else if (unformat (i, "hostname %s", &hostname))
9070 else if (unformat (i, "disable_event"))
9076 if (sw_if_index_set == 0)
9078 errmsg ("missing interface name or sw_if_index");
9082 if (vec_len (hostname) > 63)
9084 errmsg ("hostname too long");
9086 vec_add1 (hostname, 0);
9088 /* Construct the API message */
9089 M (DHCP_CLIENT_CONFIG, mp);
9091 mp->sw_if_index = htonl (sw_if_index);
9092 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
9093 vec_free (hostname);
9094 mp->is_add = is_add;
9095 mp->want_dhcp_event = disable_event ? 0 : 1;
9096 mp->pid = htonl (getpid ());
9101 /* Wait for a reply, return good/bad news */
9107 api_set_ip_flow_hash (vat_main_t * vam)
9109 unformat_input_t *i = vam->input;
9110 vl_api_set_ip_flow_hash_t *mp;
9122 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9124 if (unformat (i, "vrf %d", &vrf_id))
9126 else if (unformat (i, "ipv6"))
9128 else if (unformat (i, "src"))
9130 else if (unformat (i, "dst"))
9132 else if (unformat (i, "sport"))
9134 else if (unformat (i, "dport"))
9136 else if (unformat (i, "proto"))
9138 else if (unformat (i, "reverse"))
9143 clib_warning ("parse error '%U'", format_unformat_error, i);
9148 if (vrf_id_set == 0)
9150 errmsg ("missing vrf id");
9154 M (SET_IP_FLOW_HASH, mp);
9160 mp->reverse = reverse;
9161 mp->vrf_id = ntohl (vrf_id);
9162 mp->is_ipv6 = is_ipv6;
9170 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9172 unformat_input_t *i = vam->input;
9173 vl_api_sw_interface_ip6_enable_disable_t *mp;
9175 u8 sw_if_index_set = 0;
9179 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9181 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9182 sw_if_index_set = 1;
9183 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9184 sw_if_index_set = 1;
9185 else if (unformat (i, "enable"))
9187 else if (unformat (i, "disable"))
9191 clib_warning ("parse error '%U'", format_unformat_error, i);
9196 if (sw_if_index_set == 0)
9198 errmsg ("missing interface name or sw_if_index");
9202 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9204 mp->sw_if_index = ntohl (sw_if_index);
9205 mp->enable = enable;
9213 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
9215 unformat_input_t *i = vam->input;
9216 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
9218 u8 sw_if_index_set = 0;
9219 u8 v6_address_set = 0;
9220 ip6_address_t v6address;
9223 /* Parse args required to build the message */
9224 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9226 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9227 sw_if_index_set = 1;
9228 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9229 sw_if_index_set = 1;
9230 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9236 if (sw_if_index_set == 0)
9238 errmsg ("missing interface name or sw_if_index");
9241 if (!v6_address_set)
9243 errmsg ("no address set");
9247 /* Construct the API message */
9248 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
9250 mp->sw_if_index = ntohl (sw_if_index);
9251 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9256 /* Wait for a reply, return good/bad news */
9262 api_ip6nd_proxy_add_del (vat_main_t * vam)
9264 unformat_input_t *i = vam->input;
9265 vl_api_ip6nd_proxy_add_del_t *mp;
9266 u32 sw_if_index = ~0;
9267 u8 v6_address_set = 0;
9268 ip6_address_t v6address;
9272 /* Parse args required to build the message */
9273 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9275 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9277 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9279 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9281 if (unformat (i, "del"))
9285 clib_warning ("parse error '%U'", format_unformat_error, i);
9290 if (sw_if_index == ~0)
9292 errmsg ("missing interface name or sw_if_index");
9295 if (!v6_address_set)
9297 errmsg ("no address set");
9301 /* Construct the API message */
9302 M (IP6ND_PROXY_ADD_DEL, mp);
9304 mp->is_del = is_del;
9305 mp->sw_if_index = ntohl (sw_if_index);
9306 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9311 /* Wait for a reply, return good/bad news */
9317 api_ip6nd_proxy_dump (vat_main_t * vam)
9319 vl_api_ip6nd_proxy_dump_t *mp;
9320 vl_api_control_ping_t *mp_ping;
9323 M (IP6ND_PROXY_DUMP, mp);
9327 /* Use a control ping for synchronization */
9328 MPING (CONTROL_PING, mp_ping);
9335 static void vl_api_ip6nd_proxy_details_t_handler
9336 (vl_api_ip6nd_proxy_details_t * mp)
9338 vat_main_t *vam = &vat_main;
9340 print (vam->ofp, "host %U sw_if_index %d",
9341 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
9344 static void vl_api_ip6nd_proxy_details_t_handler_json
9345 (vl_api_ip6nd_proxy_details_t * mp)
9347 vat_main_t *vam = &vat_main;
9348 struct in6_addr ip6;
9349 vat_json_node_t *node = NULL;
9351 if (VAT_JSON_ARRAY != vam->json_tree.type)
9353 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9354 vat_json_init_array (&vam->json_tree);
9356 node = vat_json_array_add (&vam->json_tree);
9358 vat_json_init_object (node);
9359 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9361 clib_memcpy (&ip6, mp->address, sizeof (ip6));
9362 vat_json_object_add_ip6 (node, "host", ip6);
9366 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9368 unformat_input_t *i = vam->input;
9369 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9371 u8 sw_if_index_set = 0;
9372 u32 address_length = 0;
9373 u8 v6_address_set = 0;
9374 ip6_address_t v6address;
9376 u8 no_advertise = 0;
9378 u8 no_autoconfig = 0;
9381 u32 val_lifetime = 0;
9382 u32 pref_lifetime = 0;
9385 /* Parse args required to build the message */
9386 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9388 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9389 sw_if_index_set = 1;
9390 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9391 sw_if_index_set = 1;
9392 else if (unformat (i, "%U/%d",
9393 unformat_ip6_address, &v6address, &address_length))
9395 else if (unformat (i, "val_life %d", &val_lifetime))
9397 else if (unformat (i, "pref_life %d", &pref_lifetime))
9399 else if (unformat (i, "def"))
9401 else if (unformat (i, "noadv"))
9403 else if (unformat (i, "offl"))
9405 else if (unformat (i, "noauto"))
9407 else if (unformat (i, "nolink"))
9409 else if (unformat (i, "isno"))
9413 clib_warning ("parse error '%U'", format_unformat_error, i);
9418 if (sw_if_index_set == 0)
9420 errmsg ("missing interface name or sw_if_index");
9423 if (!v6_address_set)
9425 errmsg ("no address set");
9429 /* Construct the API message */
9430 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9432 mp->sw_if_index = ntohl (sw_if_index);
9433 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9434 mp->address_length = address_length;
9435 mp->use_default = use_default;
9436 mp->no_advertise = no_advertise;
9437 mp->off_link = off_link;
9438 mp->no_autoconfig = no_autoconfig;
9439 mp->no_onlink = no_onlink;
9441 mp->val_lifetime = ntohl (val_lifetime);
9442 mp->pref_lifetime = ntohl (pref_lifetime);
9447 /* Wait for a reply, return good/bad news */
9453 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9455 unformat_input_t *i = vam->input;
9456 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9458 u8 sw_if_index_set = 0;
9463 u8 send_unicast = 0;
9466 u8 default_router = 0;
9467 u32 max_interval = 0;
9468 u32 min_interval = 0;
9470 u32 initial_count = 0;
9471 u32 initial_interval = 0;
9475 /* Parse args required to build the message */
9476 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9478 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9479 sw_if_index_set = 1;
9480 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9481 sw_if_index_set = 1;
9482 else if (unformat (i, "maxint %d", &max_interval))
9484 else if (unformat (i, "minint %d", &min_interval))
9486 else if (unformat (i, "life %d", &lifetime))
9488 else if (unformat (i, "count %d", &initial_count))
9490 else if (unformat (i, "interval %d", &initial_interval))
9492 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9494 else if (unformat (i, "managed"))
9496 else if (unformat (i, "other"))
9498 else if (unformat (i, "ll"))
9500 else if (unformat (i, "send"))
9502 else if (unformat (i, "cease"))
9504 else if (unformat (i, "isno"))
9506 else if (unformat (i, "def"))
9510 clib_warning ("parse error '%U'", format_unformat_error, i);
9515 if (sw_if_index_set == 0)
9517 errmsg ("missing interface name or sw_if_index");
9521 /* Construct the API message */
9522 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9524 mp->sw_if_index = ntohl (sw_if_index);
9525 mp->max_interval = ntohl (max_interval);
9526 mp->min_interval = ntohl (min_interval);
9527 mp->lifetime = ntohl (lifetime);
9528 mp->initial_count = ntohl (initial_count);
9529 mp->initial_interval = ntohl (initial_interval);
9530 mp->suppress = suppress;
9531 mp->managed = managed;
9533 mp->ll_option = ll_option;
9534 mp->send_unicast = send_unicast;
9537 mp->default_router = default_router;
9542 /* Wait for a reply, return good/bad news */
9548 api_set_arp_neighbor_limit (vat_main_t * vam)
9550 unformat_input_t *i = vam->input;
9551 vl_api_set_arp_neighbor_limit_t *mp;
9557 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9559 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9561 else if (unformat (i, "ipv6"))
9565 clib_warning ("parse error '%U'", format_unformat_error, i);
9572 errmsg ("missing limit value");
9576 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9578 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9579 mp->is_ipv6 = is_ipv6;
9587 api_l2_patch_add_del (vat_main_t * vam)
9589 unformat_input_t *i = vam->input;
9590 vl_api_l2_patch_add_del_t *mp;
9592 u8 rx_sw_if_index_set = 0;
9594 u8 tx_sw_if_index_set = 0;
9598 /* Parse args required to build the message */
9599 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9601 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9602 rx_sw_if_index_set = 1;
9603 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9604 tx_sw_if_index_set = 1;
9605 else if (unformat (i, "rx"))
9607 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9609 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9611 rx_sw_if_index_set = 1;
9616 else if (unformat (i, "tx"))
9618 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9620 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9622 tx_sw_if_index_set = 1;
9627 else if (unformat (i, "del"))
9633 if (rx_sw_if_index_set == 0)
9635 errmsg ("missing rx interface name or rx_sw_if_index");
9639 if (tx_sw_if_index_set == 0)
9641 errmsg ("missing tx interface name or tx_sw_if_index");
9645 M (L2_PATCH_ADD_DEL, mp);
9647 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9648 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9649 mp->is_add = is_add;
9657 u8 localsid_addr[16];
9666 api_sr_localsid_add_del (vat_main_t * vam)
9668 unformat_input_t *i = vam->input;
9669 vl_api_sr_localsid_add_del_t *mp;
9672 ip6_address_t localsid;
9676 u32 fib_table = ~(u32) 0;
9677 ip6_address_t next_hop;
9679 bool nexthop_set = 0;
9683 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9685 if (unformat (i, "del"))
9687 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9688 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
9690 else if (unformat (i, "behavior %u", &behavior));
9691 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9692 else if (unformat (i, "fib-table %u", &fib_table));
9693 else if (unformat (i, "end.psp %u", &behavior));
9698 M (SR_LOCALSID_ADD_DEL, mp);
9700 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
9702 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
9703 mp->behavior = behavior;
9704 mp->sw_if_index = ntohl (sw_if_index);
9705 mp->fib_table = ntohl (fib_table);
9706 mp->end_psp = end_psp;
9707 mp->is_del = is_del;
9715 api_ioam_enable (vat_main_t * vam)
9717 unformat_input_t *input = vam->input;
9718 vl_api_ioam_enable_t *mp;
9720 int has_trace_option = 0;
9721 int has_pot_option = 0;
9722 int has_seqno_option = 0;
9723 int has_analyse_option = 0;
9726 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9728 if (unformat (input, "trace"))
9729 has_trace_option = 1;
9730 else if (unformat (input, "pot"))
9732 else if (unformat (input, "seqno"))
9733 has_seqno_option = 1;
9734 else if (unformat (input, "analyse"))
9735 has_analyse_option = 1;
9739 M (IOAM_ENABLE, mp);
9740 mp->id = htons (id);
9741 mp->seqno = has_seqno_option;
9742 mp->analyse = has_analyse_option;
9743 mp->pot_enable = has_pot_option;
9744 mp->trace_enable = has_trace_option;
9753 api_ioam_disable (vat_main_t * vam)
9755 vl_api_ioam_disable_t *mp;
9758 M (IOAM_DISABLE, mp);
9764 #define foreach_tcp_proto_field \
9768 #define foreach_udp_proto_field \
9772 #define foreach_ip4_proto_field \
9784 u16 src_port, dst_port;
9787 #if VPP_API_TEST_BUILTIN == 0
9789 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9791 u8 **maskp = va_arg (*args, u8 **);
9793 u8 found_something = 0;
9796 #define _(a) u8 a=0;
9797 foreach_tcp_proto_field;
9800 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9803 #define _(a) else if (unformat (input, #a)) a=1;
9804 foreach_tcp_proto_field
9810 #define _(a) found_something += a;
9811 foreach_tcp_proto_field;
9814 if (found_something == 0)
9817 vec_validate (mask, sizeof (*tcp) - 1);
9819 tcp = (tcp_header_t *) mask;
9821 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9822 foreach_tcp_proto_field;
9830 unformat_udp_mask (unformat_input_t * input, va_list * args)
9832 u8 **maskp = va_arg (*args, u8 **);
9834 u8 found_something = 0;
9837 #define _(a) u8 a=0;
9838 foreach_udp_proto_field;
9841 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9844 #define _(a) else if (unformat (input, #a)) a=1;
9845 foreach_udp_proto_field
9851 #define _(a) found_something += a;
9852 foreach_udp_proto_field;
9855 if (found_something == 0)
9858 vec_validate (mask, sizeof (*udp) - 1);
9860 udp = (udp_header_t *) mask;
9862 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
9863 foreach_udp_proto_field;
9871 unformat_l4_mask (unformat_input_t * input, va_list * args)
9873 u8 **maskp = va_arg (*args, u8 **);
9874 u16 src_port = 0, dst_port = 0;
9875 tcpudp_header_t *tcpudp;
9877 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9879 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9881 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9883 else if (unformat (input, "src_port"))
9885 else if (unformat (input, "dst_port"))
9891 if (!src_port && !dst_port)
9895 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9897 tcpudp = (tcpudp_header_t *) mask;
9898 tcpudp->src_port = src_port;
9899 tcpudp->dst_port = dst_port;
9907 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9909 u8 **maskp = va_arg (*args, u8 **);
9911 u8 found_something = 0;
9914 #define _(a) u8 a=0;
9915 foreach_ip4_proto_field;
9921 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9923 if (unformat (input, "version"))
9925 else if (unformat (input, "hdr_length"))
9927 else if (unformat (input, "src"))
9929 else if (unformat (input, "dst"))
9931 else if (unformat (input, "proto"))
9934 #define _(a) else if (unformat (input, #a)) a=1;
9935 foreach_ip4_proto_field
9941 #define _(a) found_something += a;
9942 foreach_ip4_proto_field;
9945 if (found_something == 0)
9948 vec_validate (mask, sizeof (*ip) - 1);
9950 ip = (ip4_header_t *) mask;
9952 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9953 foreach_ip4_proto_field;
9956 ip->ip_version_and_header_length = 0;
9959 ip->ip_version_and_header_length |= 0xF0;
9962 ip->ip_version_and_header_length |= 0x0F;
9968 #define foreach_ip6_proto_field \
9976 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9978 u8 **maskp = va_arg (*args, u8 **);
9980 u8 found_something = 0;
9982 u32 ip_version_traffic_class_and_flow_label;
9984 #define _(a) u8 a=0;
9985 foreach_ip6_proto_field;
9988 u8 traffic_class = 0;
9991 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9993 if (unformat (input, "version"))
9995 else if (unformat (input, "traffic-class"))
9997 else if (unformat (input, "flow-label"))
9999 else if (unformat (input, "src"))
10001 else if (unformat (input, "dst"))
10003 else if (unformat (input, "proto"))
10006 #define _(a) else if (unformat (input, #a)) a=1;
10007 foreach_ip6_proto_field
10013 #define _(a) found_something += a;
10014 foreach_ip6_proto_field;
10017 if (found_something == 0)
10020 vec_validate (mask, sizeof (*ip) - 1);
10022 ip = (ip6_header_t *) mask;
10024 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10025 foreach_ip6_proto_field;
10028 ip_version_traffic_class_and_flow_label = 0;
10031 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10034 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10037 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10039 ip->ip_version_traffic_class_and_flow_label =
10040 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10047 unformat_l3_mask (unformat_input_t * input, va_list * args)
10049 u8 **maskp = va_arg (*args, u8 **);
10051 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10053 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10055 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10064 unformat_l2_mask (unformat_input_t * input, va_list * args)
10066 u8 **maskp = va_arg (*args, u8 **);
10073 u8 ignore_tag1 = 0;
10074 u8 ignore_tag2 = 0;
10081 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10083 if (unformat (input, "src"))
10085 else if (unformat (input, "dst"))
10087 else if (unformat (input, "proto"))
10089 else if (unformat (input, "tag1"))
10091 else if (unformat (input, "tag2"))
10093 else if (unformat (input, "ignore-tag1"))
10095 else if (unformat (input, "ignore-tag2"))
10097 else if (unformat (input, "cos1"))
10099 else if (unformat (input, "cos2"))
10101 else if (unformat (input, "dot1q"))
10103 else if (unformat (input, "dot1ad"))
10108 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10109 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10112 if (tag1 || ignore_tag1 || cos1 || dot1q)
10114 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10117 vec_validate (mask, len - 1);
10120 memset (mask, 0xff, 6);
10123 memset (mask + 6, 0xff, 6);
10125 if (tag2 || dot1ad)
10127 /* inner vlan tag */
10136 mask[21] = mask[20] = 0xff;
10157 mask[16] = mask[17] = 0xff;
10167 mask[12] = mask[13] = 0xff;
10174 unformat_classify_mask (unformat_input_t * input, va_list * args)
10176 u8 **maskp = va_arg (*args, u8 **);
10177 u32 *skipp = va_arg (*args, u32 *);
10178 u32 *matchp = va_arg (*args, u32 *);
10186 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10188 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10190 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10192 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10194 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10208 if (mask || l2 || l3 || l4)
10210 if (l2 || l3 || l4)
10212 /* "With a free Ethernet header in every package" */
10214 vec_validate (l2, 13);
10218 vec_append (mask, l3);
10223 vec_append (mask, l4);
10228 /* Scan forward looking for the first significant mask octet */
10229 for (i = 0; i < vec_len (mask); i++)
10233 /* compute (skip, match) params */
10234 *skipp = i / sizeof (u32x4);
10235 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10237 /* Pad mask to an even multiple of the vector size */
10238 while (vec_len (mask) % sizeof (u32x4))
10239 vec_add1 (mask, 0);
10241 match = vec_len (mask) / sizeof (u32x4);
10243 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10245 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10246 if (*tmp || *(tmp + 1))
10251 clib_warning ("BUG: match 0");
10253 _vec_len (mask) = match * sizeof (u32x4);
10263 #endif /* VPP_API_TEST_BUILTIN */
10265 #define foreach_l2_next \
10267 _(ethernet, ETHERNET_INPUT) \
10268 _(ip4, IP4_INPUT) \
10272 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10274 u32 *miss_next_indexp = va_arg (*args, u32 *);
10275 u32 next_index = 0;
10279 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10283 if (unformat (input, "%d", &tmp))
10292 *miss_next_indexp = next_index;
10296 #define foreach_ip_next \
10299 _(rewrite, REWRITE)
10302 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10304 u32 *miss_next_indexp = va_arg (*args, u32 *);
10305 u32 next_index = 0;
10309 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10313 if (unformat (input, "%d", &tmp))
10322 *miss_next_indexp = next_index;
10326 #define foreach_acl_next \
10330 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10332 u32 *miss_next_indexp = va_arg (*args, u32 *);
10333 u32 next_index = 0;
10337 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10341 if (unformat (input, "permit"))
10346 else if (unformat (input, "%d", &tmp))
10355 *miss_next_indexp = next_index;
10360 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10362 u32 *r = va_arg (*args, u32 *);
10364 if (unformat (input, "conform-color"))
10365 *r = POLICE_CONFORM;
10366 else if (unformat (input, "exceed-color"))
10367 *r = POLICE_EXCEED;
10375 api_classify_add_del_table (vat_main_t * vam)
10377 unformat_input_t *i = vam->input;
10378 vl_api_classify_add_del_table_t *mp;
10385 u32 table_index = ~0;
10386 u32 next_table_index = ~0;
10387 u32 miss_next_index = ~0;
10388 u32 memory_size = 32 << 20;
10390 u32 current_data_flag = 0;
10391 int current_data_offset = 0;
10394 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10396 if (unformat (i, "del"))
10398 else if (unformat (i, "del-chain"))
10403 else if (unformat (i, "buckets %d", &nbuckets))
10405 else if (unformat (i, "memory_size %d", &memory_size))
10407 else if (unformat (i, "skip %d", &skip))
10409 else if (unformat (i, "match %d", &match))
10411 else if (unformat (i, "table %d", &table_index))
10413 else if (unformat (i, "mask %U", unformat_classify_mask,
10414 &mask, &skip, &match))
10416 else if (unformat (i, "next-table %d", &next_table_index))
10418 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10421 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10424 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10427 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10429 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10435 if (is_add && mask == 0)
10437 errmsg ("Mask required");
10441 if (is_add && skip == ~0)
10443 errmsg ("skip count required");
10447 if (is_add && match == ~0)
10449 errmsg ("match count required");
10453 if (!is_add && table_index == ~0)
10455 errmsg ("table index required for delete");
10459 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10461 mp->is_add = is_add;
10462 mp->del_chain = del_chain;
10463 mp->table_index = ntohl (table_index);
10464 mp->nbuckets = ntohl (nbuckets);
10465 mp->memory_size = ntohl (memory_size);
10466 mp->skip_n_vectors = ntohl (skip);
10467 mp->match_n_vectors = ntohl (match);
10468 mp->next_table_index = ntohl (next_table_index);
10469 mp->miss_next_index = ntohl (miss_next_index);
10470 mp->current_data_flag = ntohl (current_data_flag);
10471 mp->current_data_offset = ntohl (current_data_offset);
10472 clib_memcpy (mp->mask, mask, vec_len (mask));
10481 #if VPP_API_TEST_BUILTIN == 0
10483 unformat_l4_match (unformat_input_t * input, va_list * args)
10485 u8 **matchp = va_arg (*args, u8 **);
10487 u8 *proto_header = 0;
10493 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10495 if (unformat (input, "src_port %d", &src_port))
10497 else if (unformat (input, "dst_port %d", &dst_port))
10503 h.src_port = clib_host_to_net_u16 (src_port);
10504 h.dst_port = clib_host_to_net_u16 (dst_port);
10505 vec_validate (proto_header, sizeof (h) - 1);
10506 memcpy (proto_header, &h, sizeof (h));
10508 *matchp = proto_header;
10514 unformat_ip4_match (unformat_input_t * input, va_list * args)
10516 u8 **matchp = va_arg (*args, u8 **);
10521 int hdr_length = 0;
10522 u32 hdr_length_val;
10523 int src = 0, dst = 0;
10524 ip4_address_t src_val, dst_val;
10531 int fragment_id = 0;
10532 u32 fragment_id_val;
10538 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10540 if (unformat (input, "version %d", &version_val))
10542 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10544 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10546 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10548 else if (unformat (input, "proto %d", &proto_val))
10550 else if (unformat (input, "tos %d", &tos_val))
10552 else if (unformat (input, "length %d", &length_val))
10554 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10556 else if (unformat (input, "ttl %d", &ttl_val))
10558 else if (unformat (input, "checksum %d", &checksum_val))
10564 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10565 + ttl + checksum == 0)
10569 * Aligned because we use the real comparison functions
10571 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10573 ip = (ip4_header_t *) match;
10575 /* These are realistically matched in practice */
10577 ip->src_address.as_u32 = src_val.as_u32;
10580 ip->dst_address.as_u32 = dst_val.as_u32;
10583 ip->protocol = proto_val;
10586 /* These are not, but they're included for completeness */
10588 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10591 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10597 ip->length = clib_host_to_net_u16 (length_val);
10603 ip->checksum = clib_host_to_net_u16 (checksum_val);
10610 unformat_ip6_match (unformat_input_t * input, va_list * args)
10612 u8 **matchp = va_arg (*args, u8 **);
10617 u8 traffic_class = 0;
10618 u32 traffic_class_val = 0;
10621 int src = 0, dst = 0;
10622 ip6_address_t src_val, dst_val;
10625 int payload_length = 0;
10626 u32 payload_length_val;
10629 u32 ip_version_traffic_class_and_flow_label;
10631 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10633 if (unformat (input, "version %d", &version_val))
10635 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10637 else if (unformat (input, "flow_label %d", &flow_label_val))
10639 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10641 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10643 else if (unformat (input, "proto %d", &proto_val))
10645 else if (unformat (input, "payload_length %d", &payload_length_val))
10646 payload_length = 1;
10647 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10653 if (version + traffic_class + flow_label + src + dst + proto +
10654 payload_length + hop_limit == 0)
10658 * Aligned because we use the real comparison functions
10660 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10662 ip = (ip6_header_t *) match;
10665 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10668 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10671 ip->protocol = proto_val;
10673 ip_version_traffic_class_and_flow_label = 0;
10676 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10679 ip_version_traffic_class_and_flow_label |=
10680 (traffic_class_val & 0xFF) << 20;
10683 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10685 ip->ip_version_traffic_class_and_flow_label =
10686 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10688 if (payload_length)
10689 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10692 ip->hop_limit = hop_limit_val;
10699 unformat_l3_match (unformat_input_t * input, va_list * args)
10701 u8 **matchp = va_arg (*args, u8 **);
10703 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10705 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10707 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10716 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10718 u8 *tagp = va_arg (*args, u8 *);
10721 if (unformat (input, "%d", &tag))
10723 tagp[0] = (tag >> 8) & 0x0F;
10724 tagp[1] = tag & 0xFF;
10732 unformat_l2_match (unformat_input_t * input, va_list * args)
10734 u8 **matchp = va_arg (*args, u8 **);
10747 u8 ignore_tag1 = 0;
10748 u8 ignore_tag2 = 0;
10754 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10756 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10759 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10761 else if (unformat (input, "proto %U",
10762 unformat_ethernet_type_host_byte_order, &proto_val))
10764 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10766 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10768 else if (unformat (input, "ignore-tag1"))
10770 else if (unformat (input, "ignore-tag2"))
10772 else if (unformat (input, "cos1 %d", &cos1_val))
10774 else if (unformat (input, "cos2 %d", &cos2_val))
10779 if ((src + dst + proto + tag1 + tag2 +
10780 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10783 if (tag1 || ignore_tag1 || cos1)
10785 if (tag2 || ignore_tag2 || cos2)
10788 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10791 clib_memcpy (match, dst_val, 6);
10794 clib_memcpy (match + 6, src_val, 6);
10798 /* inner vlan tag */
10799 match[19] = tag2_val[1];
10800 match[18] = tag2_val[0];
10802 match[18] |= (cos2_val & 0x7) << 5;
10805 match[21] = proto_val & 0xff;
10806 match[20] = proto_val >> 8;
10810 match[15] = tag1_val[1];
10811 match[14] = tag1_val[0];
10814 match[14] |= (cos1_val & 0x7) << 5;
10820 match[15] = tag1_val[1];
10821 match[14] = tag1_val[0];
10824 match[17] = proto_val & 0xff;
10825 match[16] = proto_val >> 8;
10828 match[14] |= (cos1_val & 0x7) << 5;
10834 match[18] |= (cos2_val & 0x7) << 5;
10836 match[14] |= (cos1_val & 0x7) << 5;
10839 match[13] = proto_val & 0xff;
10840 match[12] = proto_val >> 8;
10849 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10851 u8 **matchp = va_arg (*args, u8 **);
10852 u32 skip_n_vectors = va_arg (*args, u32);
10853 u32 match_n_vectors = va_arg (*args, u32);
10860 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10862 if (unformat (input, "hex %U", unformat_hex_string, &match))
10864 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10866 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10868 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10882 if (match || l2 || l3 || l4)
10884 if (l2 || l3 || l4)
10886 /* "Win a free Ethernet header in every packet" */
10888 vec_validate_aligned (l2, 13, sizeof (u32x4));
10892 vec_append_aligned (match, l3, sizeof (u32x4));
10897 vec_append_aligned (match, l4, sizeof (u32x4));
10902 /* Make sure the vector is big enough even if key is all 0's */
10903 vec_validate_aligned
10904 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10907 /* Set size, include skipped vectors */
10908 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10919 api_classify_add_del_session (vat_main_t * vam)
10921 unformat_input_t *i = vam->input;
10922 vl_api_classify_add_del_session_t *mp;
10924 u32 table_index = ~0;
10925 u32 hit_next_index = ~0;
10926 u32 opaque_index = ~0;
10929 u32 skip_n_vectors = 0;
10930 u32 match_n_vectors = 0;
10936 * Warning: you have to supply skip_n and match_n
10937 * because the API client cant simply look at the classify
10941 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10943 if (unformat (i, "del"))
10945 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10948 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10951 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10954 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10956 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10958 else if (unformat (i, "opaque-index %d", &opaque_index))
10960 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10962 else if (unformat (i, "match_n %d", &match_n_vectors))
10964 else if (unformat (i, "match %U", api_unformat_classify_match,
10965 &match, skip_n_vectors, match_n_vectors))
10967 else if (unformat (i, "advance %d", &advance))
10969 else if (unformat (i, "table-index %d", &table_index))
10971 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10973 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10975 else if (unformat (i, "action %d", &action))
10977 else if (unformat (i, "metadata %d", &metadata))
10983 if (table_index == ~0)
10985 errmsg ("Table index required");
10989 if (is_add && match == 0)
10991 errmsg ("Match value required");
10995 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10997 mp->is_add = is_add;
10998 mp->table_index = ntohl (table_index);
10999 mp->hit_next_index = ntohl (hit_next_index);
11000 mp->opaque_index = ntohl (opaque_index);
11001 mp->advance = ntohl (advance);
11002 mp->action = action;
11003 mp->metadata = ntohl (metadata);
11004 clib_memcpy (mp->match, match, vec_len (match));
11013 api_classify_set_interface_ip_table (vat_main_t * vam)
11015 unformat_input_t *i = vam->input;
11016 vl_api_classify_set_interface_ip_table_t *mp;
11018 int sw_if_index_set;
11019 u32 table_index = ~0;
11023 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11025 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11026 sw_if_index_set = 1;
11027 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11028 sw_if_index_set = 1;
11029 else if (unformat (i, "table %d", &table_index))
11033 clib_warning ("parse error '%U'", format_unformat_error, i);
11038 if (sw_if_index_set == 0)
11040 errmsg ("missing interface name or sw_if_index");
11045 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11047 mp->sw_if_index = ntohl (sw_if_index);
11048 mp->table_index = ntohl (table_index);
11049 mp->is_ipv6 = is_ipv6;
11057 api_classify_set_interface_l2_tables (vat_main_t * vam)
11059 unformat_input_t *i = vam->input;
11060 vl_api_classify_set_interface_l2_tables_t *mp;
11062 int sw_if_index_set;
11063 u32 ip4_table_index = ~0;
11064 u32 ip6_table_index = ~0;
11065 u32 other_table_index = ~0;
11069 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11071 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11072 sw_if_index_set = 1;
11073 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11074 sw_if_index_set = 1;
11075 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11077 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11079 else if (unformat (i, "other-table %d", &other_table_index))
11081 else if (unformat (i, "is-input %d", &is_input))
11085 clib_warning ("parse error '%U'", format_unformat_error, i);
11090 if (sw_if_index_set == 0)
11092 errmsg ("missing interface name or sw_if_index");
11097 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11099 mp->sw_if_index = ntohl (sw_if_index);
11100 mp->ip4_table_index = ntohl (ip4_table_index);
11101 mp->ip6_table_index = ntohl (ip6_table_index);
11102 mp->other_table_index = ntohl (other_table_index);
11103 mp->is_input = (u8) is_input;
11111 api_set_ipfix_exporter (vat_main_t * vam)
11113 unformat_input_t *i = vam->input;
11114 vl_api_set_ipfix_exporter_t *mp;
11115 ip4_address_t collector_address;
11116 u8 collector_address_set = 0;
11117 u32 collector_port = ~0;
11118 ip4_address_t src_address;
11119 u8 src_address_set = 0;
11122 u32 template_interval = ~0;
11123 u8 udp_checksum = 0;
11126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11128 if (unformat (i, "collector_address %U", unformat_ip4_address,
11129 &collector_address))
11130 collector_address_set = 1;
11131 else if (unformat (i, "collector_port %d", &collector_port))
11133 else if (unformat (i, "src_address %U", unformat_ip4_address,
11135 src_address_set = 1;
11136 else if (unformat (i, "vrf_id %d", &vrf_id))
11138 else if (unformat (i, "path_mtu %d", &path_mtu))
11140 else if (unformat (i, "template_interval %d", &template_interval))
11142 else if (unformat (i, "udp_checksum"))
11148 if (collector_address_set == 0)
11150 errmsg ("collector_address required");
11154 if (src_address_set == 0)
11156 errmsg ("src_address required");
11160 M (SET_IPFIX_EXPORTER, mp);
11162 memcpy (mp->collector_address, collector_address.data,
11163 sizeof (collector_address.data));
11164 mp->collector_port = htons ((u16) collector_port);
11165 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11166 mp->vrf_id = htonl (vrf_id);
11167 mp->path_mtu = htonl (path_mtu);
11168 mp->template_interval = htonl (template_interval);
11169 mp->udp_checksum = udp_checksum;
11177 api_set_ipfix_classify_stream (vat_main_t * vam)
11179 unformat_input_t *i = vam->input;
11180 vl_api_set_ipfix_classify_stream_t *mp;
11182 u32 src_port = UDP_DST_PORT_ipfix;
11185 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11187 if (unformat (i, "domain %d", &domain_id))
11189 else if (unformat (i, "src_port %d", &src_port))
11193 errmsg ("unknown input `%U'", format_unformat_error, i);
11198 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11200 mp->domain_id = htonl (domain_id);
11201 mp->src_port = htons ((u16) src_port);
11209 api_ipfix_classify_table_add_del (vat_main_t * vam)
11211 unformat_input_t *i = vam->input;
11212 vl_api_ipfix_classify_table_add_del_t *mp;
11214 u32 classify_table_index = ~0;
11216 u8 transport_protocol = 255;
11219 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11221 if (unformat (i, "add"))
11223 else if (unformat (i, "del"))
11225 else if (unformat (i, "table %d", &classify_table_index))
11227 else if (unformat (i, "ip4"))
11229 else if (unformat (i, "ip6"))
11231 else if (unformat (i, "tcp"))
11232 transport_protocol = 6;
11233 else if (unformat (i, "udp"))
11234 transport_protocol = 17;
11237 errmsg ("unknown input `%U'", format_unformat_error, i);
11244 errmsg ("expecting: add|del");
11247 if (classify_table_index == ~0)
11249 errmsg ("classifier table not specified");
11252 if (ip_version == 0)
11254 errmsg ("IP version not specified");
11258 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11260 mp->is_add = is_add;
11261 mp->table_id = htonl (classify_table_index);
11262 mp->ip_version = ip_version;
11263 mp->transport_protocol = transport_protocol;
11271 api_get_node_index (vat_main_t * vam)
11273 unformat_input_t *i = vam->input;
11274 vl_api_get_node_index_t *mp;
11278 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11280 if (unformat (i, "node %s", &name))
11287 errmsg ("node name required");
11290 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11292 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11296 M (GET_NODE_INDEX, mp);
11297 clib_memcpy (mp->node_name, name, vec_len (name));
11306 api_get_next_index (vat_main_t * vam)
11308 unformat_input_t *i = vam->input;
11309 vl_api_get_next_index_t *mp;
11310 u8 *node_name = 0, *next_node_name = 0;
11313 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11315 if (unformat (i, "node-name %s", &node_name))
11317 else if (unformat (i, "next-node-name %s", &next_node_name))
11321 if (node_name == 0)
11323 errmsg ("node name required");
11326 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11328 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11332 if (next_node_name == 0)
11334 errmsg ("next node name required");
11337 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11339 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11343 M (GET_NEXT_INDEX, mp);
11344 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11345 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11346 vec_free (node_name);
11347 vec_free (next_node_name);
11355 api_add_node_next (vat_main_t * vam)
11357 unformat_input_t *i = vam->input;
11358 vl_api_add_node_next_t *mp;
11363 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11365 if (unformat (i, "node %s", &name))
11367 else if (unformat (i, "next %s", &next))
11374 errmsg ("node name required");
11377 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11379 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11384 errmsg ("next node required");
11387 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11389 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11393 M (ADD_NODE_NEXT, mp);
11394 clib_memcpy (mp->node_name, name, vec_len (name));
11395 clib_memcpy (mp->next_name, next, vec_len (next));
11405 api_l2tpv3_create_tunnel (vat_main_t * vam)
11407 unformat_input_t *i = vam->input;
11408 ip6_address_t client_address, our_address;
11409 int client_address_set = 0;
11410 int our_address_set = 0;
11411 u32 local_session_id = 0;
11412 u32 remote_session_id = 0;
11413 u64 local_cookie = 0;
11414 u64 remote_cookie = 0;
11415 u8 l2_sublayer_present = 0;
11416 vl_api_l2tpv3_create_tunnel_t *mp;
11419 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11421 if (unformat (i, "client_address %U", unformat_ip6_address,
11423 client_address_set = 1;
11424 else if (unformat (i, "our_address %U", unformat_ip6_address,
11426 our_address_set = 1;
11427 else if (unformat (i, "local_session_id %d", &local_session_id))
11429 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11431 else if (unformat (i, "local_cookie %lld", &local_cookie))
11433 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11435 else if (unformat (i, "l2-sublayer-present"))
11436 l2_sublayer_present = 1;
11441 if (client_address_set == 0)
11443 errmsg ("client_address required");
11447 if (our_address_set == 0)
11449 errmsg ("our_address required");
11453 M (L2TPV3_CREATE_TUNNEL, mp);
11455 clib_memcpy (mp->client_address, client_address.as_u8,
11456 sizeof (mp->client_address));
11458 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11460 mp->local_session_id = ntohl (local_session_id);
11461 mp->remote_session_id = ntohl (remote_session_id);
11462 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11463 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11464 mp->l2_sublayer_present = l2_sublayer_present;
11473 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11475 unformat_input_t *i = vam->input;
11477 u8 sw_if_index_set = 0;
11478 u64 new_local_cookie = 0;
11479 u64 new_remote_cookie = 0;
11480 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11485 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11486 sw_if_index_set = 1;
11487 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11488 sw_if_index_set = 1;
11489 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11491 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11497 if (sw_if_index_set == 0)
11499 errmsg ("missing interface name or sw_if_index");
11503 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11505 mp->sw_if_index = ntohl (sw_if_index);
11506 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11507 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11515 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11517 unformat_input_t *i = vam->input;
11518 vl_api_l2tpv3_interface_enable_disable_t *mp;
11520 u8 sw_if_index_set = 0;
11521 u8 enable_disable = 1;
11524 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11526 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11527 sw_if_index_set = 1;
11528 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11529 sw_if_index_set = 1;
11530 else if (unformat (i, "enable"))
11531 enable_disable = 1;
11532 else if (unformat (i, "disable"))
11533 enable_disable = 0;
11538 if (sw_if_index_set == 0)
11540 errmsg ("missing interface name or sw_if_index");
11544 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11546 mp->sw_if_index = ntohl (sw_if_index);
11547 mp->enable_disable = enable_disable;
11555 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11557 unformat_input_t *i = vam->input;
11558 vl_api_l2tpv3_set_lookup_key_t *mp;
11562 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11564 if (unformat (i, "lookup_v6_src"))
11565 key = L2T_LOOKUP_SRC_ADDRESS;
11566 else if (unformat (i, "lookup_v6_dst"))
11567 key = L2T_LOOKUP_DST_ADDRESS;
11568 else if (unformat (i, "lookup_session_id"))
11569 key = L2T_LOOKUP_SESSION_ID;
11574 if (key == (u8) ~ 0)
11576 errmsg ("l2tp session lookup key unset");
11580 M (L2TPV3_SET_LOOKUP_KEY, mp);
11589 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11590 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11592 vat_main_t *vam = &vat_main;
11594 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11595 format_ip6_address, mp->our_address,
11596 format_ip6_address, mp->client_address,
11597 clib_net_to_host_u32 (mp->sw_if_index));
11600 " local cookies %016llx %016llx remote cookie %016llx",
11601 clib_net_to_host_u64 (mp->local_cookie[0]),
11602 clib_net_to_host_u64 (mp->local_cookie[1]),
11603 clib_net_to_host_u64 (mp->remote_cookie));
11605 print (vam->ofp, " local session-id %d remote session-id %d",
11606 clib_net_to_host_u32 (mp->local_session_id),
11607 clib_net_to_host_u32 (mp->remote_session_id));
11609 print (vam->ofp, " l2 specific sublayer %s\n",
11610 mp->l2_sublayer_present ? "preset" : "absent");
11614 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11615 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11617 vat_main_t *vam = &vat_main;
11618 vat_json_node_t *node = NULL;
11619 struct in6_addr addr;
11621 if (VAT_JSON_ARRAY != vam->json_tree.type)
11623 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11624 vat_json_init_array (&vam->json_tree);
11626 node = vat_json_array_add (&vam->json_tree);
11628 vat_json_init_object (node);
11630 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11631 vat_json_object_add_ip6 (node, "our_address", addr);
11632 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11633 vat_json_object_add_ip6 (node, "client_address", addr);
11635 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11636 vat_json_init_array (lc);
11637 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11638 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11639 vat_json_object_add_uint (node, "remote_cookie",
11640 clib_net_to_host_u64 (mp->remote_cookie));
11642 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11643 vat_json_object_add_uint (node, "local_session_id",
11644 clib_net_to_host_u32 (mp->local_session_id));
11645 vat_json_object_add_uint (node, "remote_session_id",
11646 clib_net_to_host_u32 (mp->remote_session_id));
11647 vat_json_object_add_string_copy (node, "l2_sublayer",
11648 mp->l2_sublayer_present ? (u8 *) "present"
11649 : (u8 *) "absent");
11653 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11655 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11656 vl_api_control_ping_t *mp_ping;
11659 /* Get list of l2tpv3-tunnel interfaces */
11660 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11663 /* Use a control ping for synchronization */
11664 MPING (CONTROL_PING, mp_ping);
11672 static void vl_api_sw_interface_tap_details_t_handler
11673 (vl_api_sw_interface_tap_details_t * mp)
11675 vat_main_t *vam = &vat_main;
11677 print (vam->ofp, "%-16s %d",
11678 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
11681 static void vl_api_sw_interface_tap_details_t_handler_json
11682 (vl_api_sw_interface_tap_details_t * mp)
11684 vat_main_t *vam = &vat_main;
11685 vat_json_node_t *node = NULL;
11687 if (VAT_JSON_ARRAY != vam->json_tree.type)
11689 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11690 vat_json_init_array (&vam->json_tree);
11692 node = vat_json_array_add (&vam->json_tree);
11694 vat_json_init_object (node);
11695 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11696 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11700 api_sw_interface_tap_dump (vat_main_t * vam)
11702 vl_api_sw_interface_tap_dump_t *mp;
11703 vl_api_control_ping_t *mp_ping;
11706 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
11707 /* Get list of tap interfaces */
11708 M (SW_INTERFACE_TAP_DUMP, mp);
11711 /* Use a control ping for synchronization */
11712 MPING (CONTROL_PING, mp_ping);
11719 static uword unformat_vxlan_decap_next
11720 (unformat_input_t * input, va_list * args)
11722 u32 *result = va_arg (*args, u32 *);
11725 if (unformat (input, "l2"))
11726 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11727 else if (unformat (input, "%d", &tmp))
11735 api_vxlan_add_del_tunnel (vat_main_t * vam)
11737 unformat_input_t *line_input = vam->input;
11738 vl_api_vxlan_add_del_tunnel_t *mp;
11739 ip46_address_t src, dst;
11741 u8 ipv4_set = 0, ipv6_set = 0;
11745 u32 mcast_sw_if_index = ~0;
11746 u32 encap_vrf_id = 0;
11747 u32 decap_next_index = ~0;
11751 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11752 memset (&src, 0, sizeof src);
11753 memset (&dst, 0, sizeof dst);
11755 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11757 if (unformat (line_input, "del"))
11760 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11766 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11772 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11778 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11783 else if (unformat (line_input, "group %U %U",
11784 unformat_ip4_address, &dst.ip4,
11785 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11787 grp_set = dst_set = 1;
11790 else if (unformat (line_input, "group %U",
11791 unformat_ip4_address, &dst.ip4))
11793 grp_set = dst_set = 1;
11796 else if (unformat (line_input, "group %U %U",
11797 unformat_ip6_address, &dst.ip6,
11798 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11800 grp_set = dst_set = 1;
11803 else if (unformat (line_input, "group %U",
11804 unformat_ip6_address, &dst.ip6))
11806 grp_set = dst_set = 1;
11810 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11812 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11814 else if (unformat (line_input, "decap-next %U",
11815 unformat_vxlan_decap_next, &decap_next_index))
11817 else if (unformat (line_input, "vni %d", &vni))
11821 errmsg ("parse error '%U'", format_unformat_error, line_input);
11828 errmsg ("tunnel src address not specified");
11833 errmsg ("tunnel dst address not specified");
11837 if (grp_set && !ip46_address_is_multicast (&dst))
11839 errmsg ("tunnel group address not multicast");
11842 if (grp_set && mcast_sw_if_index == ~0)
11844 errmsg ("tunnel nonexistent multicast device");
11847 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11849 errmsg ("tunnel dst address must be unicast");
11854 if (ipv4_set && ipv6_set)
11856 errmsg ("both IPv4 and IPv6 addresses specified");
11860 if ((vni == 0) || (vni >> 24))
11862 errmsg ("vni not specified or out of range");
11866 M (VXLAN_ADD_DEL_TUNNEL, mp);
11870 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
11871 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
11875 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
11876 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
11878 mp->encap_vrf_id = ntohl (encap_vrf_id);
11879 mp->decap_next_index = ntohl (decap_next_index);
11880 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11881 mp->vni = ntohl (vni);
11882 mp->is_add = is_add;
11883 mp->is_ipv6 = ipv6_set;
11890 static void vl_api_vxlan_tunnel_details_t_handler
11891 (vl_api_vxlan_tunnel_details_t * mp)
11893 vat_main_t *vam = &vat_main;
11894 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
11895 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
11897 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
11898 ntohl (mp->sw_if_index),
11899 format_ip46_address, &src, IP46_TYPE_ANY,
11900 format_ip46_address, &dst, IP46_TYPE_ANY,
11901 ntohl (mp->encap_vrf_id),
11902 ntohl (mp->decap_next_index), ntohl (mp->vni),
11903 ntohl (mp->mcast_sw_if_index));
11906 static void vl_api_vxlan_tunnel_details_t_handler_json
11907 (vl_api_vxlan_tunnel_details_t * mp)
11909 vat_main_t *vam = &vat_main;
11910 vat_json_node_t *node = NULL;
11912 if (VAT_JSON_ARRAY != vam->json_tree.type)
11914 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11915 vat_json_init_array (&vam->json_tree);
11917 node = vat_json_array_add (&vam->json_tree);
11919 vat_json_init_object (node);
11920 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11923 struct in6_addr ip6;
11925 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
11926 vat_json_object_add_ip6 (node, "src_address", ip6);
11927 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
11928 vat_json_object_add_ip6 (node, "dst_address", ip6);
11932 struct in_addr ip4;
11934 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
11935 vat_json_object_add_ip4 (node, "src_address", ip4);
11936 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
11937 vat_json_object_add_ip4 (node, "dst_address", ip4);
11939 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11940 vat_json_object_add_uint (node, "decap_next_index",
11941 ntohl (mp->decap_next_index));
11942 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11943 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11944 vat_json_object_add_uint (node, "mcast_sw_if_index",
11945 ntohl (mp->mcast_sw_if_index));
11949 api_vxlan_tunnel_dump (vat_main_t * vam)
11951 unformat_input_t *i = vam->input;
11952 vl_api_vxlan_tunnel_dump_t *mp;
11953 vl_api_control_ping_t *mp_ping;
11955 u8 sw_if_index_set = 0;
11958 /* Parse args required to build the message */
11959 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11961 if (unformat (i, "sw_if_index %d", &sw_if_index))
11962 sw_if_index_set = 1;
11967 if (sw_if_index_set == 0)
11972 if (!vam->json_output)
11974 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
11975 "sw_if_index", "src_address", "dst_address",
11976 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11979 /* Get list of vxlan-tunnel interfaces */
11980 M (VXLAN_TUNNEL_DUMP, mp);
11982 mp->sw_if_index = htonl (sw_if_index);
11986 /* Use a control ping for synchronization */
11987 MPING (CONTROL_PING, mp_ping);
11995 api_gre_add_del_tunnel (vat_main_t * vam)
11997 unformat_input_t *line_input = vam->input;
11998 vl_api_gre_add_del_tunnel_t *mp;
11999 ip4_address_t src4, dst4;
12000 ip6_address_t src6, dst6;
12007 u32 outer_fib_id = 0;
12010 memset (&src4, 0, sizeof src4);
12011 memset (&dst4, 0, sizeof dst4);
12012 memset (&src6, 0, sizeof src6);
12013 memset (&dst6, 0, sizeof dst6);
12015 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12017 if (unformat (line_input, "del"))
12019 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
12024 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
12029 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
12034 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
12039 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12041 else if (unformat (line_input, "teb"))
12045 errmsg ("parse error '%U'", format_unformat_error, line_input);
12052 errmsg ("tunnel src address not specified");
12057 errmsg ("tunnel dst address not specified");
12060 if (ipv4_set && ipv6_set)
12062 errmsg ("both IPv4 and IPv6 addresses specified");
12067 M (GRE_ADD_DEL_TUNNEL, mp);
12071 clib_memcpy (&mp->src_address, &src4, 4);
12072 clib_memcpy (&mp->dst_address, &dst4, 4);
12076 clib_memcpy (&mp->src_address, &src6, 16);
12077 clib_memcpy (&mp->dst_address, &dst6, 16);
12079 mp->outer_fib_id = ntohl (outer_fib_id);
12080 mp->is_add = is_add;
12082 mp->is_ipv6 = ipv6_set;
12089 static void vl_api_gre_tunnel_details_t_handler
12090 (vl_api_gre_tunnel_details_t * mp)
12092 vat_main_t *vam = &vat_main;
12093 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
12094 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
12096 print (vam->ofp, "%11d%24U%24U%6d%14d",
12097 ntohl (mp->sw_if_index),
12098 format_ip46_address, &src, IP46_TYPE_ANY,
12099 format_ip46_address, &dst, IP46_TYPE_ANY,
12100 mp->teb, ntohl (mp->outer_fib_id));
12103 static void vl_api_gre_tunnel_details_t_handler_json
12104 (vl_api_gre_tunnel_details_t * mp)
12106 vat_main_t *vam = &vat_main;
12107 vat_json_node_t *node = NULL;
12108 struct in_addr ip4;
12109 struct in6_addr ip6;
12111 if (VAT_JSON_ARRAY != vam->json_tree.type)
12113 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12114 vat_json_init_array (&vam->json_tree);
12116 node = vat_json_array_add (&vam->json_tree);
12118 vat_json_init_object (node);
12119 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12122 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
12123 vat_json_object_add_ip4 (node, "src_address", ip4);
12124 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
12125 vat_json_object_add_ip4 (node, "dst_address", ip4);
12129 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
12130 vat_json_object_add_ip6 (node, "src_address", ip6);
12131 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
12132 vat_json_object_add_ip6 (node, "dst_address", ip6);
12134 vat_json_object_add_uint (node, "teb", mp->teb);
12135 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
12136 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
12140 api_gre_tunnel_dump (vat_main_t * vam)
12142 unformat_input_t *i = vam->input;
12143 vl_api_gre_tunnel_dump_t *mp;
12144 vl_api_control_ping_t *mp_ping;
12146 u8 sw_if_index_set = 0;
12149 /* Parse args required to build the message */
12150 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12152 if (unformat (i, "sw_if_index %d", &sw_if_index))
12153 sw_if_index_set = 1;
12158 if (sw_if_index_set == 0)
12163 if (!vam->json_output)
12165 print (vam->ofp, "%11s%24s%24s%6s%14s",
12166 "sw_if_index", "src_address", "dst_address", "teb",
12170 /* Get list of gre-tunnel interfaces */
12171 M (GRE_TUNNEL_DUMP, mp);
12173 mp->sw_if_index = htonl (sw_if_index);
12177 /* Use a control ping for synchronization */
12178 MPING (CONTROL_PING, mp_ping);
12186 api_l2_fib_clear_table (vat_main_t * vam)
12188 // unformat_input_t * i = vam->input;
12189 vl_api_l2_fib_clear_table_t *mp;
12192 M (L2_FIB_CLEAR_TABLE, mp);
12200 api_l2_interface_efp_filter (vat_main_t * vam)
12202 unformat_input_t *i = vam->input;
12203 vl_api_l2_interface_efp_filter_t *mp;
12206 u8 sw_if_index_set = 0;
12209 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12211 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12212 sw_if_index_set = 1;
12213 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12214 sw_if_index_set = 1;
12215 else if (unformat (i, "enable"))
12217 else if (unformat (i, "disable"))
12221 clib_warning ("parse error '%U'", format_unformat_error, i);
12226 if (sw_if_index_set == 0)
12228 errmsg ("missing sw_if_index");
12232 M (L2_INTERFACE_EFP_FILTER, mp);
12234 mp->sw_if_index = ntohl (sw_if_index);
12235 mp->enable_disable = enable;
12242 #define foreach_vtr_op \
12243 _("disable", L2_VTR_DISABLED) \
12244 _("push-1", L2_VTR_PUSH_1) \
12245 _("push-2", L2_VTR_PUSH_2) \
12246 _("pop-1", L2_VTR_POP_1) \
12247 _("pop-2", L2_VTR_POP_2) \
12248 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12249 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12250 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12251 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12254 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12256 unformat_input_t *i = vam->input;
12257 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12259 u8 sw_if_index_set = 0;
12262 u32 push_dot1q = 1;
12267 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12269 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12270 sw_if_index_set = 1;
12271 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12272 sw_if_index_set = 1;
12273 else if (unformat (i, "vtr_op %d", &vtr_op))
12275 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12278 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12280 else if (unformat (i, "tag1 %d", &tag1))
12282 else if (unformat (i, "tag2 %d", &tag2))
12286 clib_warning ("parse error '%U'", format_unformat_error, i);
12291 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12293 errmsg ("missing vtr operation or sw_if_index");
12297 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12298 mp->sw_if_index = ntohl (sw_if_index);
12299 mp->vtr_op = ntohl (vtr_op);
12300 mp->push_dot1q = ntohl (push_dot1q);
12301 mp->tag1 = ntohl (tag1);
12302 mp->tag2 = ntohl (tag2);
12310 api_create_vhost_user_if (vat_main_t * vam)
12312 unformat_input_t *i = vam->input;
12313 vl_api_create_vhost_user_if_t *mp;
12316 u8 file_name_set = 0;
12317 u32 custom_dev_instance = ~0;
12319 u8 use_custom_mac = 0;
12323 /* Shut up coverity */
12324 memset (hwaddr, 0, sizeof (hwaddr));
12326 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12328 if (unformat (i, "socket %s", &file_name))
12332 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12334 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12335 use_custom_mac = 1;
12336 else if (unformat (i, "server"))
12338 else if (unformat (i, "tag %s", &tag))
12344 if (file_name_set == 0)
12346 errmsg ("missing socket file name");
12350 if (vec_len (file_name) > 255)
12352 errmsg ("socket file name too long");
12355 vec_add1 (file_name, 0);
12357 M (CREATE_VHOST_USER_IF, mp);
12359 mp->is_server = is_server;
12360 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12361 vec_free (file_name);
12362 if (custom_dev_instance != ~0)
12365 mp->custom_dev_instance = ntohl (custom_dev_instance);
12367 mp->use_custom_mac = use_custom_mac;
12368 clib_memcpy (mp->mac_address, hwaddr, 6);
12370 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12379 api_modify_vhost_user_if (vat_main_t * vam)
12381 unformat_input_t *i = vam->input;
12382 vl_api_modify_vhost_user_if_t *mp;
12385 u8 file_name_set = 0;
12386 u32 custom_dev_instance = ~0;
12387 u8 sw_if_index_set = 0;
12388 u32 sw_if_index = (u32) ~ 0;
12391 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12393 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12394 sw_if_index_set = 1;
12395 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12396 sw_if_index_set = 1;
12397 else if (unformat (i, "socket %s", &file_name))
12401 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12403 else if (unformat (i, "server"))
12409 if (sw_if_index_set == 0)
12411 errmsg ("missing sw_if_index or interface name");
12415 if (file_name_set == 0)
12417 errmsg ("missing socket file name");
12421 if (vec_len (file_name) > 255)
12423 errmsg ("socket file name too long");
12426 vec_add1 (file_name, 0);
12428 M (MODIFY_VHOST_USER_IF, mp);
12430 mp->sw_if_index = ntohl (sw_if_index);
12431 mp->is_server = is_server;
12432 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12433 vec_free (file_name);
12434 if (custom_dev_instance != ~0)
12437 mp->custom_dev_instance = ntohl (custom_dev_instance);
12446 api_delete_vhost_user_if (vat_main_t * vam)
12448 unformat_input_t *i = vam->input;
12449 vl_api_delete_vhost_user_if_t *mp;
12450 u32 sw_if_index = ~0;
12451 u8 sw_if_index_set = 0;
12454 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12456 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12457 sw_if_index_set = 1;
12458 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12459 sw_if_index_set = 1;
12464 if (sw_if_index_set == 0)
12466 errmsg ("missing sw_if_index or interface name");
12471 M (DELETE_VHOST_USER_IF, mp);
12473 mp->sw_if_index = ntohl (sw_if_index);
12480 static void vl_api_sw_interface_vhost_user_details_t_handler
12481 (vl_api_sw_interface_vhost_user_details_t * mp)
12483 vat_main_t *vam = &vat_main;
12485 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12486 (char *) mp->interface_name,
12487 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12488 clib_net_to_host_u64 (mp->features), mp->is_server,
12489 ntohl (mp->num_regions), (char *) mp->sock_filename);
12490 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12493 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12494 (vl_api_sw_interface_vhost_user_details_t * mp)
12496 vat_main_t *vam = &vat_main;
12497 vat_json_node_t *node = NULL;
12499 if (VAT_JSON_ARRAY != vam->json_tree.type)
12501 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12502 vat_json_init_array (&vam->json_tree);
12504 node = vat_json_array_add (&vam->json_tree);
12506 vat_json_init_object (node);
12507 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12508 vat_json_object_add_string_copy (node, "interface_name",
12509 mp->interface_name);
12510 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12511 ntohl (mp->virtio_net_hdr_sz));
12512 vat_json_object_add_uint (node, "features",
12513 clib_net_to_host_u64 (mp->features));
12514 vat_json_object_add_uint (node, "is_server", mp->is_server);
12515 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12516 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12517 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12521 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12523 vl_api_sw_interface_vhost_user_dump_t *mp;
12524 vl_api_control_ping_t *mp_ping;
12527 "Interface name idx hdr_sz features server regions filename");
12529 /* Get list of vhost-user interfaces */
12530 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12533 /* Use a control ping for synchronization */
12534 MPING (CONTROL_PING, mp_ping);
12542 api_show_version (vat_main_t * vam)
12544 vl_api_show_version_t *mp;
12547 M (SHOW_VERSION, mp);
12556 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12558 unformat_input_t *line_input = vam->input;
12559 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12560 ip4_address_t local4, remote4;
12561 ip6_address_t local6, remote6;
12563 u8 ipv4_set = 0, ipv6_set = 0;
12567 u32 mcast_sw_if_index = ~0;
12568 u32 encap_vrf_id = 0;
12569 u32 decap_vrf_id = 0;
12575 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12576 memset (&local4, 0, sizeof local4);
12577 memset (&remote4, 0, sizeof remote4);
12578 memset (&local6, 0, sizeof local6);
12579 memset (&remote6, 0, sizeof remote6);
12581 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12583 if (unformat (line_input, "del"))
12585 else if (unformat (line_input, "local %U",
12586 unformat_ip4_address, &local4))
12591 else if (unformat (line_input, "remote %U",
12592 unformat_ip4_address, &remote4))
12597 else if (unformat (line_input, "local %U",
12598 unformat_ip6_address, &local6))
12603 else if (unformat (line_input, "remote %U",
12604 unformat_ip6_address, &remote6))
12609 else if (unformat (line_input, "group %U %U",
12610 unformat_ip4_address, &remote4,
12611 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12613 grp_set = remote_set = 1;
12616 else if (unformat (line_input, "group %U",
12617 unformat_ip4_address, &remote4))
12619 grp_set = remote_set = 1;
12622 else if (unformat (line_input, "group %U %U",
12623 unformat_ip6_address, &remote6,
12624 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12626 grp_set = remote_set = 1;
12629 else if (unformat (line_input, "group %U",
12630 unformat_ip6_address, &remote6))
12632 grp_set = remote_set = 1;
12636 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12638 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12640 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
12642 else if (unformat (line_input, "vni %d", &vni))
12644 else if (unformat (line_input, "next-ip4"))
12646 else if (unformat (line_input, "next-ip6"))
12648 else if (unformat (line_input, "next-ethernet"))
12650 else if (unformat (line_input, "next-nsh"))
12654 errmsg ("parse error '%U'", format_unformat_error, line_input);
12659 if (local_set == 0)
12661 errmsg ("tunnel local address not specified");
12664 if (remote_set == 0)
12666 errmsg ("tunnel remote address not specified");
12669 if (grp_set && mcast_sw_if_index == ~0)
12671 errmsg ("tunnel nonexistent multicast device");
12674 if (ipv4_set && ipv6_set)
12676 errmsg ("both IPv4 and IPv6 addresses specified");
12682 errmsg ("vni not specified");
12686 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
12691 clib_memcpy (&mp->local, &local6, sizeof (local6));
12692 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
12696 clib_memcpy (&mp->local, &local4, sizeof (local4));
12697 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
12700 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12701 mp->encap_vrf_id = ntohl (encap_vrf_id);
12702 mp->decap_vrf_id = ntohl (decap_vrf_id);
12703 mp->protocol = protocol;
12704 mp->vni = ntohl (vni);
12705 mp->is_add = is_add;
12706 mp->is_ipv6 = ipv6_set;
12713 static void vl_api_vxlan_gpe_tunnel_details_t_handler
12714 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12716 vat_main_t *vam = &vat_main;
12717 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
12718 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
12720 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
12721 ntohl (mp->sw_if_index),
12722 format_ip46_address, &local, IP46_TYPE_ANY,
12723 format_ip46_address, &remote, IP46_TYPE_ANY,
12724 ntohl (mp->vni), mp->protocol,
12725 ntohl (mp->mcast_sw_if_index),
12726 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
12730 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
12731 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12733 vat_main_t *vam = &vat_main;
12734 vat_json_node_t *node = NULL;
12735 struct in_addr ip4;
12736 struct in6_addr ip6;
12738 if (VAT_JSON_ARRAY != vam->json_tree.type)
12740 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12741 vat_json_init_array (&vam->json_tree);
12743 node = vat_json_array_add (&vam->json_tree);
12745 vat_json_init_object (node);
12746 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12749 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
12750 vat_json_object_add_ip6 (node, "local", ip6);
12751 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
12752 vat_json_object_add_ip6 (node, "remote", ip6);
12756 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
12757 vat_json_object_add_ip4 (node, "local", ip4);
12758 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
12759 vat_json_object_add_ip4 (node, "remote", ip4);
12761 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12762 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
12763 vat_json_object_add_uint (node, "mcast_sw_if_index",
12764 ntohl (mp->mcast_sw_if_index));
12765 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12766 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
12767 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12771 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
12773 unformat_input_t *i = vam->input;
12774 vl_api_vxlan_gpe_tunnel_dump_t *mp;
12775 vl_api_control_ping_t *mp_ping;
12777 u8 sw_if_index_set = 0;
12780 /* Parse args required to build the message */
12781 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12783 if (unformat (i, "sw_if_index %d", &sw_if_index))
12784 sw_if_index_set = 1;
12789 if (sw_if_index_set == 0)
12794 if (!vam->json_output)
12796 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
12797 "sw_if_index", "local", "remote", "vni",
12798 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
12801 /* Get list of vxlan-tunnel interfaces */
12802 M (VXLAN_GPE_TUNNEL_DUMP, mp);
12804 mp->sw_if_index = htonl (sw_if_index);
12808 /* Use a control ping for synchronization */
12809 MPING (CONTROL_PING, mp_ping);
12818 format_l2_fib_mac_address (u8 * s, va_list * args)
12820 u8 *a = va_arg (*args, u8 *);
12822 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
12823 a[2], a[3], a[4], a[5], a[6], a[7]);
12826 static void vl_api_l2_fib_table_details_t_handler
12827 (vl_api_l2_fib_table_details_t * mp)
12829 vat_main_t *vam = &vat_main;
12831 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
12833 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
12834 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
12838 static void vl_api_l2_fib_table_details_t_handler_json
12839 (vl_api_l2_fib_table_details_t * mp)
12841 vat_main_t *vam = &vat_main;
12842 vat_json_node_t *node = NULL;
12844 if (VAT_JSON_ARRAY != vam->json_tree.type)
12846 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12847 vat_json_init_array (&vam->json_tree);
12849 node = vat_json_array_add (&vam->json_tree);
12851 vat_json_init_object (node);
12852 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
12853 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
12854 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12855 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
12856 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
12857 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
12861 api_l2_fib_table_dump (vat_main_t * vam)
12863 unformat_input_t *i = vam->input;
12864 vl_api_l2_fib_table_dump_t *mp;
12865 vl_api_control_ping_t *mp_ping;
12870 /* Parse args required to build the message */
12871 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12873 if (unformat (i, "bd_id %d", &bd_id))
12879 if (bd_id_set == 0)
12881 errmsg ("missing bridge domain");
12885 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
12887 /* Get list of l2 fib entries */
12888 M (L2_FIB_TABLE_DUMP, mp);
12890 mp->bd_id = ntohl (bd_id);
12893 /* Use a control ping for synchronization */
12894 MPING (CONTROL_PING, mp_ping);
12903 api_interface_name_renumber (vat_main_t * vam)
12905 unformat_input_t *line_input = vam->input;
12906 vl_api_interface_name_renumber_t *mp;
12907 u32 sw_if_index = ~0;
12908 u32 new_show_dev_instance = ~0;
12911 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12913 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
12916 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12918 else if (unformat (line_input, "new_show_dev_instance %d",
12919 &new_show_dev_instance))
12925 if (sw_if_index == ~0)
12927 errmsg ("missing interface name or sw_if_index");
12931 if (new_show_dev_instance == ~0)
12933 errmsg ("missing new_show_dev_instance");
12937 M (INTERFACE_NAME_RENUMBER, mp);
12939 mp->sw_if_index = ntohl (sw_if_index);
12940 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
12948 api_want_ip4_arp_events (vat_main_t * vam)
12950 unformat_input_t *line_input = vam->input;
12951 vl_api_want_ip4_arp_events_t *mp;
12952 ip4_address_t address;
12953 int address_set = 0;
12954 u32 enable_disable = 1;
12957 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12959 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
12961 else if (unformat (line_input, "del"))
12962 enable_disable = 0;
12967 if (address_set == 0)
12969 errmsg ("missing addresses");
12973 M (WANT_IP4_ARP_EVENTS, mp);
12974 mp->enable_disable = enable_disable;
12975 mp->pid = htonl (getpid ());
12976 mp->address = address.as_u32;
12984 api_want_ip6_nd_events (vat_main_t * vam)
12986 unformat_input_t *line_input = vam->input;
12987 vl_api_want_ip6_nd_events_t *mp;
12988 ip6_address_t address;
12989 int address_set = 0;
12990 u32 enable_disable = 1;
12993 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12995 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
12997 else if (unformat (line_input, "del"))
12998 enable_disable = 0;
13003 if (address_set == 0)
13005 errmsg ("missing addresses");
13009 M (WANT_IP6_ND_EVENTS, mp);
13010 mp->enable_disable = enable_disable;
13011 mp->pid = htonl (getpid ());
13012 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
13020 api_want_l2_macs_events (vat_main_t * vam)
13022 unformat_input_t *line_input = vam->input;
13023 vl_api_want_l2_macs_events_t *mp;
13024 u8 enable_disable = 1;
13025 u32 scan_delay = 0;
13026 u32 max_macs_in_event = 0;
13027 u32 learn_limit = 0;
13030 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13032 if (unformat (line_input, "learn-limit %d", &learn_limit))
13034 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13036 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13038 else if (unformat (line_input, "disable"))
13039 enable_disable = 0;
13044 M (WANT_L2_MACS_EVENTS, mp);
13045 mp->enable_disable = enable_disable;
13046 mp->pid = htonl (getpid ());
13047 mp->learn_limit = htonl (learn_limit);
13048 mp->scan_delay = (u8) scan_delay;
13049 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13056 api_input_acl_set_interface (vat_main_t * vam)
13058 unformat_input_t *i = vam->input;
13059 vl_api_input_acl_set_interface_t *mp;
13061 int sw_if_index_set;
13062 u32 ip4_table_index = ~0;
13063 u32 ip6_table_index = ~0;
13064 u32 l2_table_index = ~0;
13068 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13070 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13071 sw_if_index_set = 1;
13072 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13073 sw_if_index_set = 1;
13074 else if (unformat (i, "del"))
13076 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13078 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13080 else if (unformat (i, "l2-table %d", &l2_table_index))
13084 clib_warning ("parse error '%U'", format_unformat_error, i);
13089 if (sw_if_index_set == 0)
13091 errmsg ("missing interface name or sw_if_index");
13095 M (INPUT_ACL_SET_INTERFACE, mp);
13097 mp->sw_if_index = ntohl (sw_if_index);
13098 mp->ip4_table_index = ntohl (ip4_table_index);
13099 mp->ip6_table_index = ntohl (ip6_table_index);
13100 mp->l2_table_index = ntohl (l2_table_index);
13101 mp->is_add = is_add;
13109 api_ip_address_dump (vat_main_t * vam)
13111 unformat_input_t *i = vam->input;
13112 vl_api_ip_address_dump_t *mp;
13113 vl_api_control_ping_t *mp_ping;
13114 u32 sw_if_index = ~0;
13115 u8 sw_if_index_set = 0;
13120 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13122 if (unformat (i, "sw_if_index %d", &sw_if_index))
13123 sw_if_index_set = 1;
13125 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13126 sw_if_index_set = 1;
13127 else if (unformat (i, "ipv4"))
13129 else if (unformat (i, "ipv6"))
13135 if (ipv4_set && ipv6_set)
13137 errmsg ("ipv4 and ipv6 flags cannot be both set");
13141 if ((!ipv4_set) && (!ipv6_set))
13143 errmsg ("no ipv4 nor ipv6 flag set");
13147 if (sw_if_index_set == 0)
13149 errmsg ("missing interface name or sw_if_index");
13153 vam->current_sw_if_index = sw_if_index;
13154 vam->is_ipv6 = ipv6_set;
13156 M (IP_ADDRESS_DUMP, mp);
13157 mp->sw_if_index = ntohl (sw_if_index);
13158 mp->is_ipv6 = ipv6_set;
13161 /* Use a control ping for synchronization */
13162 MPING (CONTROL_PING, mp_ping);
13170 api_ip_dump (vat_main_t * vam)
13172 vl_api_ip_dump_t *mp;
13173 vl_api_control_ping_t *mp_ping;
13174 unformat_input_t *in = vam->input;
13181 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13183 if (unformat (in, "ipv4"))
13185 else if (unformat (in, "ipv6"))
13191 if (ipv4_set && ipv6_set)
13193 errmsg ("ipv4 and ipv6 flags cannot be both set");
13197 if ((!ipv4_set) && (!ipv6_set))
13199 errmsg ("no ipv4 nor ipv6 flag set");
13203 is_ipv6 = ipv6_set;
13204 vam->is_ipv6 = is_ipv6;
13206 /* free old data */
13207 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13209 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13211 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13214 mp->is_ipv6 = ipv6_set;
13217 /* Use a control ping for synchronization */
13218 MPING (CONTROL_PING, mp_ping);
13226 api_ipsec_spd_add_del (vat_main_t * vam)
13228 unformat_input_t *i = vam->input;
13229 vl_api_ipsec_spd_add_del_t *mp;
13234 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13236 if (unformat (i, "spd_id %d", &spd_id))
13238 else if (unformat (i, "del"))
13242 clib_warning ("parse error '%U'", format_unformat_error, i);
13248 errmsg ("spd_id must be set");
13252 M (IPSEC_SPD_ADD_DEL, mp);
13254 mp->spd_id = ntohl (spd_id);
13255 mp->is_add = is_add;
13263 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13265 unformat_input_t *i = vam->input;
13266 vl_api_ipsec_interface_add_del_spd_t *mp;
13268 u8 sw_if_index_set = 0;
13269 u32 spd_id = (u32) ~ 0;
13273 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13275 if (unformat (i, "del"))
13277 else if (unformat (i, "spd_id %d", &spd_id))
13280 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13281 sw_if_index_set = 1;
13282 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13283 sw_if_index_set = 1;
13286 clib_warning ("parse error '%U'", format_unformat_error, i);
13292 if (spd_id == (u32) ~ 0)
13294 errmsg ("spd_id must be set");
13298 if (sw_if_index_set == 0)
13300 errmsg ("missing interface name or sw_if_index");
13304 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13306 mp->spd_id = ntohl (spd_id);
13307 mp->sw_if_index = ntohl (sw_if_index);
13308 mp->is_add = is_add;
13316 api_ipsec_spd_add_del_entry (vat_main_t * vam)
13318 unformat_input_t *i = vam->input;
13319 vl_api_ipsec_spd_add_del_entry_t *mp;
13320 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
13321 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13323 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13324 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13325 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
13326 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
13329 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
13330 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
13331 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
13332 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
13333 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
13334 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
13336 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13338 if (unformat (i, "del"))
13340 if (unformat (i, "outbound"))
13342 if (unformat (i, "inbound"))
13344 else if (unformat (i, "spd_id %d", &spd_id))
13346 else if (unformat (i, "sa_id %d", &sa_id))
13348 else if (unformat (i, "priority %d", &priority))
13350 else if (unformat (i, "protocol %d", &protocol))
13352 else if (unformat (i, "lport_start %d", &lport_start))
13354 else if (unformat (i, "lport_stop %d", &lport_stop))
13356 else if (unformat (i, "rport_start %d", &rport_start))
13358 else if (unformat (i, "rport_stop %d", &rport_stop))
13362 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
13368 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
13375 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
13381 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
13388 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
13394 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
13401 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
13407 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
13413 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13415 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13417 clib_warning ("unsupported action: 'resolve'");
13423 clib_warning ("parse error '%U'", format_unformat_error, i);
13429 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
13431 mp->spd_id = ntohl (spd_id);
13432 mp->priority = ntohl (priority);
13433 mp->is_outbound = is_outbound;
13435 mp->is_ipv6 = is_ipv6;
13436 if (is_ipv6 || is_ip_any)
13438 clib_memcpy (mp->remote_address_start, &raddr6_start,
13439 sizeof (ip6_address_t));
13440 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
13441 sizeof (ip6_address_t));
13442 clib_memcpy (mp->local_address_start, &laddr6_start,
13443 sizeof (ip6_address_t));
13444 clib_memcpy (mp->local_address_stop, &laddr6_stop,
13445 sizeof (ip6_address_t));
13449 clib_memcpy (mp->remote_address_start, &raddr4_start,
13450 sizeof (ip4_address_t));
13451 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
13452 sizeof (ip4_address_t));
13453 clib_memcpy (mp->local_address_start, &laddr4_start,
13454 sizeof (ip4_address_t));
13455 clib_memcpy (mp->local_address_stop, &laddr4_stop,
13456 sizeof (ip4_address_t));
13458 mp->protocol = (u8) protocol;
13459 mp->local_port_start = ntohs ((u16) lport_start);
13460 mp->local_port_stop = ntohs ((u16) lport_stop);
13461 mp->remote_port_start = ntohs ((u16) rport_start);
13462 mp->remote_port_stop = ntohs ((u16) rport_stop);
13463 mp->policy = (u8) policy;
13464 mp->sa_id = ntohl (sa_id);
13465 mp->is_add = is_add;
13466 mp->is_ip_any = is_ip_any;
13473 api_ipsec_sad_add_del_entry (vat_main_t * vam)
13475 unformat_input_t *i = vam->input;
13476 vl_api_ipsec_sad_add_del_entry_t *mp;
13477 u32 sad_id = 0, spi = 0;
13478 u8 *ck = 0, *ik = 0;
13481 u8 protocol = IPSEC_PROTOCOL_AH;
13482 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
13483 u32 crypto_alg = 0, integ_alg = 0;
13484 ip4_address_t tun_src4;
13485 ip4_address_t tun_dst4;
13486 ip6_address_t tun_src6;
13487 ip6_address_t tun_dst6;
13490 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13492 if (unformat (i, "del"))
13494 else if (unformat (i, "sad_id %d", &sad_id))
13496 else if (unformat (i, "spi %d", &spi))
13498 else if (unformat (i, "esp"))
13499 protocol = IPSEC_PROTOCOL_ESP;
13500 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
13503 is_tunnel_ipv6 = 0;
13505 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
13508 is_tunnel_ipv6 = 0;
13510 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
13513 is_tunnel_ipv6 = 1;
13515 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
13518 is_tunnel_ipv6 = 1;
13522 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13524 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13525 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13527 clib_warning ("unsupported crypto-alg: '%U'",
13528 format_ipsec_crypto_alg, crypto_alg);
13532 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13536 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13538 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13539 integ_alg >= IPSEC_INTEG_N_ALG)
13541 clib_warning ("unsupported integ-alg: '%U'",
13542 format_ipsec_integ_alg, integ_alg);
13546 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13550 clib_warning ("parse error '%U'", format_unformat_error, i);
13556 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
13558 mp->sad_id = ntohl (sad_id);
13559 mp->is_add = is_add;
13560 mp->protocol = protocol;
13561 mp->spi = ntohl (spi);
13562 mp->is_tunnel = is_tunnel;
13563 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
13564 mp->crypto_algorithm = crypto_alg;
13565 mp->integrity_algorithm = integ_alg;
13566 mp->crypto_key_length = vec_len (ck);
13567 mp->integrity_key_length = vec_len (ik);
13569 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13570 mp->crypto_key_length = sizeof (mp->crypto_key);
13572 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13573 mp->integrity_key_length = sizeof (mp->integrity_key);
13576 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13578 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13582 if (is_tunnel_ipv6)
13584 clib_memcpy (mp->tunnel_src_address, &tun_src6,
13585 sizeof (ip6_address_t));
13586 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
13587 sizeof (ip6_address_t));
13591 clib_memcpy (mp->tunnel_src_address, &tun_src4,
13592 sizeof (ip4_address_t));
13593 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
13594 sizeof (ip4_address_t));
13604 api_ipsec_sa_set_key (vat_main_t * vam)
13606 unformat_input_t *i = vam->input;
13607 vl_api_ipsec_sa_set_key_t *mp;
13609 u8 *ck = 0, *ik = 0;
13612 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13614 if (unformat (i, "sa_id %d", &sa_id))
13616 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13618 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13622 clib_warning ("parse error '%U'", format_unformat_error, i);
13627 M (IPSEC_SA_SET_KEY, mp);
13629 mp->sa_id = ntohl (sa_id);
13630 mp->crypto_key_length = vec_len (ck);
13631 mp->integrity_key_length = vec_len (ik);
13633 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13634 mp->crypto_key_length = sizeof (mp->crypto_key);
13636 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13637 mp->integrity_key_length = sizeof (mp->integrity_key);
13640 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13642 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13650 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
13652 unformat_input_t *i = vam->input;
13653 vl_api_ipsec_tunnel_if_add_del_t *mp;
13654 u32 local_spi = 0, remote_spi = 0;
13655 u32 crypto_alg = 0, integ_alg = 0;
13656 u8 *lck = NULL, *rck = NULL;
13657 u8 *lik = NULL, *rik = NULL;
13658 ip4_address_t local_ip = { {0} };
13659 ip4_address_t remote_ip = { {0} };
13662 u8 anti_replay = 0;
13665 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13667 if (unformat (i, "del"))
13669 else if (unformat (i, "esn"))
13671 else if (unformat (i, "anti_replay"))
13673 else if (unformat (i, "local_spi %d", &local_spi))
13675 else if (unformat (i, "remote_spi %d", &remote_spi))
13677 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
13679 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
13681 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
13684 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
13686 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
13688 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
13692 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13694 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13695 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13697 errmsg ("unsupported crypto-alg: '%U'\n",
13698 format_ipsec_crypto_alg, crypto_alg);
13704 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13706 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13707 integ_alg >= IPSEC_INTEG_N_ALG)
13709 errmsg ("unsupported integ-alg: '%U'\n",
13710 format_ipsec_integ_alg, integ_alg);
13716 errmsg ("parse error '%U'\n", format_unformat_error, i);
13721 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
13723 mp->is_add = is_add;
13725 mp->anti_replay = anti_replay;
13727 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
13728 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
13730 mp->local_spi = htonl (local_spi);
13731 mp->remote_spi = htonl (remote_spi);
13732 mp->crypto_alg = (u8) crypto_alg;
13734 mp->local_crypto_key_len = 0;
13737 mp->local_crypto_key_len = vec_len (lck);
13738 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
13739 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
13740 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
13743 mp->remote_crypto_key_len = 0;
13746 mp->remote_crypto_key_len = vec_len (rck);
13747 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
13748 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
13749 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
13752 mp->integ_alg = (u8) integ_alg;
13754 mp->local_integ_key_len = 0;
13757 mp->local_integ_key_len = vec_len (lik);
13758 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
13759 mp->local_integ_key_len = sizeof (mp->local_integ_key);
13760 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
13763 mp->remote_integ_key_len = 0;
13766 mp->remote_integ_key_len = vec_len (rik);
13767 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
13768 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
13769 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
13778 api_ikev2_profile_add_del (vat_main_t * vam)
13780 unformat_input_t *i = vam->input;
13781 vl_api_ikev2_profile_add_del_t *mp;
13786 const char *valid_chars = "a-zA-Z0-9_";
13788 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13790 if (unformat (i, "del"))
13792 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13793 vec_add1 (name, 0);
13796 errmsg ("parse error '%U'", format_unformat_error, i);
13801 if (!vec_len (name))
13803 errmsg ("profile name must be specified");
13807 if (vec_len (name) > 64)
13809 errmsg ("profile name too long");
13813 M (IKEV2_PROFILE_ADD_DEL, mp);
13815 clib_memcpy (mp->name, name, vec_len (name));
13816 mp->is_add = is_add;
13825 api_ikev2_profile_set_auth (vat_main_t * vam)
13827 unformat_input_t *i = vam->input;
13828 vl_api_ikev2_profile_set_auth_t *mp;
13831 u32 auth_method = 0;
13835 const char *valid_chars = "a-zA-Z0-9_";
13837 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13839 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13840 vec_add1 (name, 0);
13841 else if (unformat (i, "auth_method %U",
13842 unformat_ikev2_auth_method, &auth_method))
13844 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
13846 else if (unformat (i, "auth_data %v", &data))
13850 errmsg ("parse error '%U'", format_unformat_error, i);
13855 if (!vec_len (name))
13857 errmsg ("profile name must be specified");
13861 if (vec_len (name) > 64)
13863 errmsg ("profile name too long");
13867 if (!vec_len (data))
13869 errmsg ("auth_data must be specified");
13875 errmsg ("auth_method must be specified");
13879 M (IKEV2_PROFILE_SET_AUTH, mp);
13881 mp->is_hex = is_hex;
13882 mp->auth_method = (u8) auth_method;
13883 mp->data_len = vec_len (data);
13884 clib_memcpy (mp->name, name, vec_len (name));
13885 clib_memcpy (mp->data, data, vec_len (data));
13895 api_ikev2_profile_set_id (vat_main_t * vam)
13897 unformat_input_t *i = vam->input;
13898 vl_api_ikev2_profile_set_id_t *mp;
13906 const char *valid_chars = "a-zA-Z0-9_";
13908 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13910 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13911 vec_add1 (name, 0);
13912 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
13914 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
13916 data = vec_new (u8, 4);
13917 clib_memcpy (data, ip4.as_u8, 4);
13919 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
13921 else if (unformat (i, "id_data %v", &data))
13923 else if (unformat (i, "local"))
13925 else if (unformat (i, "remote"))
13929 errmsg ("parse error '%U'", format_unformat_error, i);
13934 if (!vec_len (name))
13936 errmsg ("profile name must be specified");
13940 if (vec_len (name) > 64)
13942 errmsg ("profile name too long");
13946 if (!vec_len (data))
13948 errmsg ("id_data must be specified");
13954 errmsg ("id_type must be specified");
13958 M (IKEV2_PROFILE_SET_ID, mp);
13960 mp->is_local = is_local;
13961 mp->id_type = (u8) id_type;
13962 mp->data_len = vec_len (data);
13963 clib_memcpy (mp->name, name, vec_len (name));
13964 clib_memcpy (mp->data, data, vec_len (data));
13974 api_ikev2_profile_set_ts (vat_main_t * vam)
13976 unformat_input_t *i = vam->input;
13977 vl_api_ikev2_profile_set_ts_t *mp;
13980 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
13981 ip4_address_t start_addr, end_addr;
13983 const char *valid_chars = "a-zA-Z0-9_";
13986 start_addr.as_u32 = 0;
13987 end_addr.as_u32 = (u32) ~ 0;
13989 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13991 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13992 vec_add1 (name, 0);
13993 else if (unformat (i, "protocol %d", &proto))
13995 else if (unformat (i, "start_port %d", &start_port))
13997 else if (unformat (i, "end_port %d", &end_port))
14000 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
14002 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
14004 else if (unformat (i, "local"))
14006 else if (unformat (i, "remote"))
14010 errmsg ("parse error '%U'", format_unformat_error, i);
14015 if (!vec_len (name))
14017 errmsg ("profile name must be specified");
14021 if (vec_len (name) > 64)
14023 errmsg ("profile name too long");
14027 M (IKEV2_PROFILE_SET_TS, mp);
14029 mp->is_local = is_local;
14030 mp->proto = (u8) proto;
14031 mp->start_port = (u16) start_port;
14032 mp->end_port = (u16) end_port;
14033 mp->start_addr = start_addr.as_u32;
14034 mp->end_addr = end_addr.as_u32;
14035 clib_memcpy (mp->name, name, vec_len (name));
14044 api_ikev2_set_local_key (vat_main_t * vam)
14046 unformat_input_t *i = vam->input;
14047 vl_api_ikev2_set_local_key_t *mp;
14051 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14053 if (unformat (i, "file %v", &file))
14054 vec_add1 (file, 0);
14057 errmsg ("parse error '%U'", format_unformat_error, i);
14062 if (!vec_len (file))
14064 errmsg ("RSA key file must be specified");
14068 if (vec_len (file) > 256)
14070 errmsg ("file name too long");
14074 M (IKEV2_SET_LOCAL_KEY, mp);
14076 clib_memcpy (mp->key_file, file, vec_len (file));
14085 api_ikev2_set_responder (vat_main_t * vam)
14087 unformat_input_t *i = vam->input;
14088 vl_api_ikev2_set_responder_t *mp;
14091 u32 sw_if_index = ~0;
14092 ip4_address_t address;
14094 const char *valid_chars = "a-zA-Z0-9_";
14096 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14099 (i, "%U interface %d address %U", unformat_token, valid_chars,
14100 &name, &sw_if_index, unformat_ip4_address, &address))
14101 vec_add1 (name, 0);
14104 errmsg ("parse error '%U'", format_unformat_error, i);
14109 if (!vec_len (name))
14111 errmsg ("profile name must be specified");
14115 if (vec_len (name) > 64)
14117 errmsg ("profile name too long");
14121 M (IKEV2_SET_RESPONDER, mp);
14123 clib_memcpy (mp->name, name, vec_len (name));
14126 mp->sw_if_index = sw_if_index;
14127 clib_memcpy (mp->address, &address, sizeof (address));
14135 api_ikev2_set_ike_transforms (vat_main_t * vam)
14137 unformat_input_t *i = vam->input;
14138 vl_api_ikev2_set_ike_transforms_t *mp;
14141 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14143 const char *valid_chars = "a-zA-Z0-9_";
14145 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14147 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14148 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14149 vec_add1 (name, 0);
14152 errmsg ("parse error '%U'", format_unformat_error, i);
14157 if (!vec_len (name))
14159 errmsg ("profile name must be specified");
14163 if (vec_len (name) > 64)
14165 errmsg ("profile name too long");
14169 M (IKEV2_SET_IKE_TRANSFORMS, mp);
14171 clib_memcpy (mp->name, name, vec_len (name));
14173 mp->crypto_alg = crypto_alg;
14174 mp->crypto_key_size = crypto_key_size;
14175 mp->integ_alg = integ_alg;
14176 mp->dh_group = dh_group;
14185 api_ikev2_set_esp_transforms (vat_main_t * vam)
14187 unformat_input_t *i = vam->input;
14188 vl_api_ikev2_set_esp_transforms_t *mp;
14191 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14193 const char *valid_chars = "a-zA-Z0-9_";
14195 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14197 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14198 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14199 vec_add1 (name, 0);
14202 errmsg ("parse error '%U'", format_unformat_error, i);
14207 if (!vec_len (name))
14209 errmsg ("profile name must be specified");
14213 if (vec_len (name) > 64)
14215 errmsg ("profile name too long");
14219 M (IKEV2_SET_ESP_TRANSFORMS, mp);
14221 clib_memcpy (mp->name, name, vec_len (name));
14223 mp->crypto_alg = crypto_alg;
14224 mp->crypto_key_size = crypto_key_size;
14225 mp->integ_alg = integ_alg;
14226 mp->dh_group = dh_group;
14234 api_ikev2_set_sa_lifetime (vat_main_t * vam)
14236 unformat_input_t *i = vam->input;
14237 vl_api_ikev2_set_sa_lifetime_t *mp;
14240 u64 lifetime, lifetime_maxdata;
14241 u32 lifetime_jitter, handover;
14243 const char *valid_chars = "a-zA-Z0-9_";
14245 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14247 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
14248 &lifetime, &lifetime_jitter, &handover,
14249 &lifetime_maxdata))
14250 vec_add1 (name, 0);
14253 errmsg ("parse error '%U'", format_unformat_error, i);
14258 if (!vec_len (name))
14260 errmsg ("profile name must be specified");
14264 if (vec_len (name) > 64)
14266 errmsg ("profile name too long");
14270 M (IKEV2_SET_SA_LIFETIME, mp);
14272 clib_memcpy (mp->name, name, vec_len (name));
14274 mp->lifetime = lifetime;
14275 mp->lifetime_jitter = lifetime_jitter;
14276 mp->handover = handover;
14277 mp->lifetime_maxdata = lifetime_maxdata;
14285 api_ikev2_initiate_sa_init (vat_main_t * vam)
14287 unformat_input_t *i = vam->input;
14288 vl_api_ikev2_initiate_sa_init_t *mp;
14292 const char *valid_chars = "a-zA-Z0-9_";
14294 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14296 if (unformat (i, "%U", unformat_token, valid_chars, &name))
14297 vec_add1 (name, 0);
14300 errmsg ("parse error '%U'", format_unformat_error, i);
14305 if (!vec_len (name))
14307 errmsg ("profile name must be specified");
14311 if (vec_len (name) > 64)
14313 errmsg ("profile name too long");
14317 M (IKEV2_INITIATE_SA_INIT, mp);
14319 clib_memcpy (mp->name, name, vec_len (name));
14328 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
14330 unformat_input_t *i = vam->input;
14331 vl_api_ikev2_initiate_del_ike_sa_t *mp;
14336 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14338 if (unformat (i, "%lx", &ispi))
14342 errmsg ("parse error '%U'", format_unformat_error, i);
14347 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
14357 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
14359 unformat_input_t *i = vam->input;
14360 vl_api_ikev2_initiate_del_child_sa_t *mp;
14365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14367 if (unformat (i, "%x", &ispi))
14371 errmsg ("parse error '%U'", format_unformat_error, i);
14376 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
14386 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
14388 unformat_input_t *i = vam->input;
14389 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
14394 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14396 if (unformat (i, "%x", &ispi))
14400 errmsg ("parse error '%U'", format_unformat_error, i);
14405 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
14418 api_map_add_domain (vat_main_t * vam)
14420 unformat_input_t *i = vam->input;
14421 vl_api_map_add_domain_t *mp;
14423 ip4_address_t ip4_prefix;
14424 ip6_address_t ip6_prefix;
14425 ip6_address_t ip6_src;
14426 u32 num_m_args = 0;
14427 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
14428 0, psid_length = 0;
14429 u8 is_translation = 0;
14431 u32 ip6_src_len = 128;
14434 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14436 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
14437 &ip4_prefix, &ip4_prefix_len))
14439 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
14440 &ip6_prefix, &ip6_prefix_len))
14444 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
14447 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
14449 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
14451 else if (unformat (i, "psid-offset %d", &psid_offset))
14453 else if (unformat (i, "psid-len %d", &psid_length))
14455 else if (unformat (i, "mtu %d", &mtu))
14457 else if (unformat (i, "map-t"))
14458 is_translation = 1;
14461 clib_warning ("parse error '%U'", format_unformat_error, i);
14466 if (num_m_args < 3)
14468 errmsg ("mandatory argument(s) missing");
14472 /* Construct the API message */
14473 M (MAP_ADD_DOMAIN, mp);
14475 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
14476 mp->ip4_prefix_len = ip4_prefix_len;
14478 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
14479 mp->ip6_prefix_len = ip6_prefix_len;
14481 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
14482 mp->ip6_src_prefix_len = ip6_src_len;
14484 mp->ea_bits_len = ea_bits_len;
14485 mp->psid_offset = psid_offset;
14486 mp->psid_length = psid_length;
14487 mp->is_translation = is_translation;
14488 mp->mtu = htons (mtu);
14493 /* Wait for a reply, return good/bad news */
14499 api_map_del_domain (vat_main_t * vam)
14501 unformat_input_t *i = vam->input;
14502 vl_api_map_del_domain_t *mp;
14504 u32 num_m_args = 0;
14508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14510 if (unformat (i, "index %d", &index))
14514 clib_warning ("parse error '%U'", format_unformat_error, i);
14519 if (num_m_args != 1)
14521 errmsg ("mandatory argument(s) missing");
14525 /* Construct the API message */
14526 M (MAP_DEL_DOMAIN, mp);
14528 mp->index = ntohl (index);
14533 /* Wait for a reply, return good/bad news */
14539 api_map_add_del_rule (vat_main_t * vam)
14541 unformat_input_t *i = vam->input;
14542 vl_api_map_add_del_rule_t *mp;
14544 ip6_address_t ip6_dst;
14545 u32 num_m_args = 0, index, psid = 0;
14548 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14550 if (unformat (i, "index %d", &index))
14552 else if (unformat (i, "psid %d", &psid))
14554 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
14556 else if (unformat (i, "del"))
14562 clib_warning ("parse error '%U'", format_unformat_error, i);
14567 /* Construct the API message */
14568 M (MAP_ADD_DEL_RULE, mp);
14570 mp->index = ntohl (index);
14571 mp->is_add = is_add;
14572 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
14573 mp->psid = ntohs (psid);
14578 /* Wait for a reply, return good/bad news */
14584 api_map_domain_dump (vat_main_t * vam)
14586 vl_api_map_domain_dump_t *mp;
14587 vl_api_control_ping_t *mp_ping;
14590 /* Construct the API message */
14591 M (MAP_DOMAIN_DUMP, mp);
14596 /* Use a control ping for synchronization */
14597 MPING (CONTROL_PING, mp_ping);
14605 api_map_rule_dump (vat_main_t * vam)
14607 unformat_input_t *i = vam->input;
14608 vl_api_map_rule_dump_t *mp;
14609 vl_api_control_ping_t *mp_ping;
14610 u32 domain_index = ~0;
14613 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14615 if (unformat (i, "index %u", &domain_index))
14621 if (domain_index == ~0)
14623 clib_warning ("parse error: domain index expected");
14627 /* Construct the API message */
14628 M (MAP_RULE_DUMP, mp);
14630 mp->domain_index = htonl (domain_index);
14635 /* Use a control ping for synchronization */
14636 MPING (CONTROL_PING, mp_ping);
14643 static void vl_api_map_add_domain_reply_t_handler
14644 (vl_api_map_add_domain_reply_t * mp)
14646 vat_main_t *vam = &vat_main;
14647 i32 retval = ntohl (mp->retval);
14649 if (vam->async_mode)
14651 vam->async_errors += (retval < 0);
14655 vam->retval = retval;
14656 vam->result_ready = 1;
14660 static void vl_api_map_add_domain_reply_t_handler_json
14661 (vl_api_map_add_domain_reply_t * mp)
14663 vat_main_t *vam = &vat_main;
14664 vat_json_node_t node;
14666 vat_json_init_object (&node);
14667 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
14668 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
14670 vat_json_print (vam->ofp, &node);
14671 vat_json_free (&node);
14673 vam->retval = ntohl (mp->retval);
14674 vam->result_ready = 1;
14678 api_get_first_msg_id (vat_main_t * vam)
14680 vl_api_get_first_msg_id_t *mp;
14681 unformat_input_t *i = vam->input;
14686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14688 if (unformat (i, "client %s", &name))
14696 errmsg ("missing client name");
14699 vec_add1 (name, 0);
14701 if (vec_len (name) > 63)
14703 errmsg ("client name too long");
14707 M (GET_FIRST_MSG_ID, mp);
14708 clib_memcpy (mp->name, name, vec_len (name));
14715 api_cop_interface_enable_disable (vat_main_t * vam)
14717 unformat_input_t *line_input = vam->input;
14718 vl_api_cop_interface_enable_disable_t *mp;
14719 u32 sw_if_index = ~0;
14720 u8 enable_disable = 1;
14723 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14725 if (unformat (line_input, "disable"))
14726 enable_disable = 0;
14727 if (unformat (line_input, "enable"))
14728 enable_disable = 1;
14729 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14730 vam, &sw_if_index))
14732 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14738 if (sw_if_index == ~0)
14740 errmsg ("missing interface name or sw_if_index");
14744 /* Construct the API message */
14745 M (COP_INTERFACE_ENABLE_DISABLE, mp);
14746 mp->sw_if_index = ntohl (sw_if_index);
14747 mp->enable_disable = enable_disable;
14751 /* Wait for the reply */
14757 api_cop_whitelist_enable_disable (vat_main_t * vam)
14759 unformat_input_t *line_input = vam->input;
14760 vl_api_cop_whitelist_enable_disable_t *mp;
14761 u32 sw_if_index = ~0;
14762 u8 ip4 = 0, ip6 = 0, default_cop = 0;
14766 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14768 if (unformat (line_input, "ip4"))
14770 else if (unformat (line_input, "ip6"))
14772 else if (unformat (line_input, "default"))
14774 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14775 vam, &sw_if_index))
14777 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14779 else if (unformat (line_input, "fib-id %d", &fib_id))
14785 if (sw_if_index == ~0)
14787 errmsg ("missing interface name or sw_if_index");
14791 /* Construct the API message */
14792 M (COP_WHITELIST_ENABLE_DISABLE, mp);
14793 mp->sw_if_index = ntohl (sw_if_index);
14794 mp->fib_id = ntohl (fib_id);
14797 mp->default_cop = default_cop;
14801 /* Wait for the reply */
14807 api_get_node_graph (vat_main_t * vam)
14809 vl_api_get_node_graph_t *mp;
14812 M (GET_NODE_GRAPH, mp);
14816 /* Wait for the reply */
14822 /** Used for parsing LISP eids */
14823 typedef CLIB_PACKED(struct{
14824 u8 addr[16]; /**< eid address */
14825 u32 len; /**< prefix length if IP */
14826 u8 type; /**< type of eid */
14831 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14833 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14835 memset (a, 0, sizeof (a[0]));
14837 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
14839 a->type = 0; /* ipv4 type */
14841 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
14843 a->type = 1; /* ipv6 type */
14845 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
14847 a->type = 2; /* mac type */
14849 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
14851 a->type = 3; /* NSH type */
14852 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
14853 nsh->spi = clib_host_to_net_u32 (nsh->spi);
14860 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
14869 lisp_eid_size_vat (u8 type)
14886 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
14888 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
14892 api_one_add_del_locator_set (vat_main_t * vam)
14894 unformat_input_t *input = vam->input;
14895 vl_api_one_add_del_locator_set_t *mp;
14897 u8 *locator_set_name = NULL;
14898 u8 locator_set_name_set = 0;
14899 vl_api_local_locator_t locator, *locators = 0;
14900 u32 sw_if_index, priority, weight;
14904 /* Parse args required to build the message */
14905 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14907 if (unformat (input, "del"))
14911 else if (unformat (input, "locator-set %s", &locator_set_name))
14913 locator_set_name_set = 1;
14915 else if (unformat (input, "sw_if_index %u p %u w %u",
14916 &sw_if_index, &priority, &weight))
14918 locator.sw_if_index = htonl (sw_if_index);
14919 locator.priority = priority;
14920 locator.weight = weight;
14921 vec_add1 (locators, locator);
14925 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14926 &sw_if_index, &priority, &weight))
14928 locator.sw_if_index = htonl (sw_if_index);
14929 locator.priority = priority;
14930 locator.weight = weight;
14931 vec_add1 (locators, locator);
14937 if (locator_set_name_set == 0)
14939 errmsg ("missing locator-set name");
14940 vec_free (locators);
14944 if (vec_len (locator_set_name) > 64)
14946 errmsg ("locator-set name too long");
14947 vec_free (locator_set_name);
14948 vec_free (locators);
14951 vec_add1 (locator_set_name, 0);
14953 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14955 /* Construct the API message */
14956 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14958 mp->is_add = is_add;
14959 clib_memcpy (mp->locator_set_name, locator_set_name,
14960 vec_len (locator_set_name));
14961 vec_free (locator_set_name);
14963 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14965 clib_memcpy (mp->locators, locators, data_len);
14966 vec_free (locators);
14971 /* Wait for a reply... */
14976 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14979 api_one_add_del_locator (vat_main_t * vam)
14981 unformat_input_t *input = vam->input;
14982 vl_api_one_add_del_locator_t *mp;
14983 u32 tmp_if_index = ~0;
14984 u32 sw_if_index = ~0;
14985 u8 sw_if_index_set = 0;
14986 u8 sw_if_index_if_name_set = 0;
14988 u8 priority_set = 0;
14992 u8 *locator_set_name = NULL;
14993 u8 locator_set_name_set = 0;
14996 /* Parse args required to build the message */
14997 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14999 if (unformat (input, "del"))
15003 else if (unformat (input, "locator-set %s", &locator_set_name))
15005 locator_set_name_set = 1;
15007 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15010 sw_if_index_if_name_set = 1;
15011 sw_if_index = tmp_if_index;
15013 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15015 sw_if_index_set = 1;
15016 sw_if_index = tmp_if_index;
15018 else if (unformat (input, "p %d", &priority))
15022 else if (unformat (input, "w %d", &weight))
15030 if (locator_set_name_set == 0)
15032 errmsg ("missing locator-set name");
15036 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15038 errmsg ("missing sw_if_index");
15039 vec_free (locator_set_name);
15043 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15045 errmsg ("cannot use both params interface name and sw_if_index");
15046 vec_free (locator_set_name);
15050 if (priority_set == 0)
15052 errmsg ("missing locator-set priority");
15053 vec_free (locator_set_name);
15057 if (weight_set == 0)
15059 errmsg ("missing locator-set weight");
15060 vec_free (locator_set_name);
15064 if (vec_len (locator_set_name) > 64)
15066 errmsg ("locator-set name too long");
15067 vec_free (locator_set_name);
15070 vec_add1 (locator_set_name, 0);
15072 /* Construct the API message */
15073 M (ONE_ADD_DEL_LOCATOR, mp);
15075 mp->is_add = is_add;
15076 mp->sw_if_index = ntohl (sw_if_index);
15077 mp->priority = priority;
15078 mp->weight = weight;
15079 clib_memcpy (mp->locator_set_name, locator_set_name,
15080 vec_len (locator_set_name));
15081 vec_free (locator_set_name);
15086 /* Wait for a reply... */
15091 #define api_lisp_add_del_locator api_one_add_del_locator
15094 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15096 u32 *key_id = va_arg (*args, u32 *);
15099 if (unformat (input, "%s", &s))
15101 if (!strcmp ((char *) s, "sha1"))
15102 key_id[0] = HMAC_SHA_1_96;
15103 else if (!strcmp ((char *) s, "sha256"))
15104 key_id[0] = HMAC_SHA_256_128;
15107 clib_warning ("invalid key_id: '%s'", s);
15108 key_id[0] = HMAC_NO_KEY;
15119 api_one_add_del_local_eid (vat_main_t * vam)
15121 unformat_input_t *input = vam->input;
15122 vl_api_one_add_del_local_eid_t *mp;
15125 lisp_eid_vat_t _eid, *eid = &_eid;
15126 u8 *locator_set_name = 0;
15127 u8 locator_set_name_set = 0;
15133 /* Parse args required to build the message */
15134 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15136 if (unformat (input, "del"))
15140 else if (unformat (input, "vni %d", &vni))
15144 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15148 else if (unformat (input, "locator-set %s", &locator_set_name))
15150 locator_set_name_set = 1;
15152 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15154 else if (unformat (input, "secret-key %_%v%_", &key))
15160 if (locator_set_name_set == 0)
15162 errmsg ("missing locator-set name");
15168 errmsg ("EID address not set!");
15169 vec_free (locator_set_name);
15173 if (key && (0 == key_id))
15175 errmsg ("invalid key_id!");
15179 if (vec_len (key) > 64)
15181 errmsg ("key too long");
15186 if (vec_len (locator_set_name) > 64)
15188 errmsg ("locator-set name too long");
15189 vec_free (locator_set_name);
15192 vec_add1 (locator_set_name, 0);
15194 /* Construct the API message */
15195 M (ONE_ADD_DEL_LOCAL_EID, mp);
15197 mp->is_add = is_add;
15198 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15199 mp->eid_type = eid->type;
15200 mp->prefix_len = eid->len;
15201 mp->vni = clib_host_to_net_u32 (vni);
15202 mp->key_id = clib_host_to_net_u16 (key_id);
15203 clib_memcpy (mp->locator_set_name, locator_set_name,
15204 vec_len (locator_set_name));
15205 clib_memcpy (mp->key, key, vec_len (key));
15207 vec_free (locator_set_name);
15213 /* Wait for a reply... */
15218 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15221 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15223 u32 dp_table = 0, vni = 0;;
15224 unformat_input_t *input = vam->input;
15225 vl_api_gpe_add_del_fwd_entry_t *mp;
15227 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15228 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15229 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15230 u32 action = ~0, w;
15231 ip4_address_t rmt_rloc4, lcl_rloc4;
15232 ip6_address_t rmt_rloc6, lcl_rloc6;
15233 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15236 memset (&rloc, 0, sizeof (rloc));
15238 /* Parse args required to build the message */
15239 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15241 if (unformat (input, "del"))
15243 else if (unformat (input, "add"))
15245 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15249 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15253 else if (unformat (input, "vrf %d", &dp_table))
15255 else if (unformat (input, "bd %d", &dp_table))
15257 else if (unformat (input, "vni %d", &vni))
15259 else if (unformat (input, "w %d", &w))
15263 errmsg ("No RLOC configured for setting priority/weight!");
15266 curr_rloc->weight = w;
15268 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15269 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15273 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15275 vec_add1 (lcl_locs, rloc);
15277 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15278 vec_add1 (rmt_locs, rloc);
15279 /* weight saved in rmt loc */
15280 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15282 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15283 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15286 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15288 vec_add1 (lcl_locs, rloc);
15290 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15291 vec_add1 (rmt_locs, rloc);
15292 /* weight saved in rmt loc */
15293 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15295 else if (unformat (input, "action %d", &action))
15301 clib_warning ("parse error '%U'", format_unformat_error, input);
15308 errmsg ("remote eid addresses not set");
15312 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15314 errmsg ("eid types don't match");
15318 if (0 == rmt_locs && (u32) ~ 0 == action)
15320 errmsg ("action not set for negative mapping");
15324 /* Construct the API message */
15325 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15326 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15328 mp->is_add = is_add;
15329 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15330 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15331 mp->eid_type = rmt_eid->type;
15332 mp->dp_table = clib_host_to_net_u32 (dp_table);
15333 mp->vni = clib_host_to_net_u32 (vni);
15334 mp->rmt_len = rmt_eid->len;
15335 mp->lcl_len = lcl_eid->len;
15336 mp->action = action;
15338 if (0 != rmt_locs && 0 != lcl_locs)
15340 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15341 clib_memcpy (mp->locs, lcl_locs,
15342 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15344 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15345 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15346 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15348 vec_free (lcl_locs);
15349 vec_free (rmt_locs);
15354 /* Wait for a reply... */
15360 api_one_add_del_map_server (vat_main_t * vam)
15362 unformat_input_t *input = vam->input;
15363 vl_api_one_add_del_map_server_t *mp;
15367 ip4_address_t ipv4;
15368 ip6_address_t ipv6;
15371 /* Parse args required to build the message */
15372 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15374 if (unformat (input, "del"))
15378 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15382 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15390 if (ipv4_set && ipv6_set)
15392 errmsg ("both eid v4 and v6 addresses set");
15396 if (!ipv4_set && !ipv6_set)
15398 errmsg ("eid addresses not set");
15402 /* Construct the API message */
15403 M (ONE_ADD_DEL_MAP_SERVER, mp);
15405 mp->is_add = is_add;
15409 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15414 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15420 /* Wait for a reply... */
15425 #define api_lisp_add_del_map_server api_one_add_del_map_server
15428 api_one_add_del_map_resolver (vat_main_t * vam)
15430 unformat_input_t *input = vam->input;
15431 vl_api_one_add_del_map_resolver_t *mp;
15435 ip4_address_t ipv4;
15436 ip6_address_t ipv6;
15439 /* Parse args required to build the message */
15440 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15442 if (unformat (input, "del"))
15446 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15450 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15458 if (ipv4_set && ipv6_set)
15460 errmsg ("both eid v4 and v6 addresses set");
15464 if (!ipv4_set && !ipv6_set)
15466 errmsg ("eid addresses not set");
15470 /* Construct the API message */
15471 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15473 mp->is_add = is_add;
15477 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15482 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15488 /* Wait for a reply... */
15493 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
15496 api_lisp_gpe_enable_disable (vat_main_t * vam)
15498 unformat_input_t *input = vam->input;
15499 vl_api_gpe_enable_disable_t *mp;
15504 /* Parse args required to build the message */
15505 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15507 if (unformat (input, "enable"))
15512 else if (unformat (input, "disable"))
15523 errmsg ("Value not set");
15527 /* Construct the API message */
15528 M (GPE_ENABLE_DISABLE, mp);
15535 /* Wait for a reply... */
15541 api_one_rloc_probe_enable_disable (vat_main_t * vam)
15543 unformat_input_t *input = vam->input;
15544 vl_api_one_rloc_probe_enable_disable_t *mp;
15549 /* Parse args required to build the message */
15550 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15552 if (unformat (input, "enable"))
15557 else if (unformat (input, "disable"))
15565 errmsg ("Value not set");
15569 /* Construct the API message */
15570 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15572 mp->is_enabled = is_en;
15577 /* Wait for a reply... */
15582 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15585 api_one_map_register_enable_disable (vat_main_t * vam)
15587 unformat_input_t *input = vam->input;
15588 vl_api_one_map_register_enable_disable_t *mp;
15593 /* Parse args required to build the message */
15594 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15596 if (unformat (input, "enable"))
15601 else if (unformat (input, "disable"))
15609 errmsg ("Value not set");
15613 /* Construct the API message */
15614 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15616 mp->is_enabled = is_en;
15621 /* Wait for a reply... */
15626 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15629 api_one_enable_disable (vat_main_t * vam)
15631 unformat_input_t *input = vam->input;
15632 vl_api_one_enable_disable_t *mp;
15637 /* Parse args required to build the message */
15638 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15640 if (unformat (input, "enable"))
15645 else if (unformat (input, "disable"))
15655 errmsg ("Value not set");
15659 /* Construct the API message */
15660 M (ONE_ENABLE_DISABLE, mp);
15667 /* Wait for a reply... */
15672 #define api_lisp_enable_disable api_one_enable_disable
15675 api_show_one_map_register_state (vat_main_t * vam)
15677 vl_api_show_one_map_register_state_t *mp;
15680 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
15685 /* wait for reply */
15690 #define api_show_lisp_map_register_state api_show_one_map_register_state
15693 api_show_one_rloc_probe_state (vat_main_t * vam)
15695 vl_api_show_one_rloc_probe_state_t *mp;
15698 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
15703 /* wait for reply */
15708 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
15711 api_one_add_del_ndp_entry (vat_main_t * vam)
15713 vl_api_one_add_del_ndp_entry_t *mp;
15714 unformat_input_t *input = vam->input;
15719 u8 mac[6] = { 0, };
15720 u8 ip6[16] = { 0, };
15724 /* Parse args required to build the message */
15725 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15727 if (unformat (input, "del"))
15729 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15731 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
15733 else if (unformat (input, "bd %d", &bd))
15737 errmsg ("parse error '%U'", format_unformat_error, input);
15742 if (!bd_set || !ip_set || (!mac_set && is_add))
15744 errmsg ("Missing BD, IP or MAC!");
15748 M (ONE_ADD_DEL_NDP_ENTRY, mp);
15749 mp->is_add = is_add;
15750 clib_memcpy (mp->mac, mac, 6);
15751 mp->bd = clib_host_to_net_u32 (bd);
15752 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
15757 /* wait for reply */
15763 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15765 vl_api_one_add_del_l2_arp_entry_t *mp;
15766 unformat_input_t *input = vam->input;
15771 u8 mac[6] = { 0, };
15772 u32 ip4 = 0, bd = ~0;
15775 /* Parse args required to build the message */
15776 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15778 if (unformat (input, "del"))
15780 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15782 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15784 else if (unformat (input, "bd %d", &bd))
15788 errmsg ("parse error '%U'", format_unformat_error, input);
15793 if (!bd_set || !ip_set || (!mac_set && is_add))
15795 errmsg ("Missing BD, IP or MAC!");
15799 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15800 mp->is_add = is_add;
15801 clib_memcpy (mp->mac, mac, 6);
15802 mp->bd = clib_host_to_net_u32 (bd);
15808 /* wait for reply */
15814 api_one_ndp_bd_get (vat_main_t * vam)
15816 vl_api_one_ndp_bd_get_t *mp;
15819 M (ONE_NDP_BD_GET, mp);
15824 /* wait for reply */
15830 api_one_ndp_entries_get (vat_main_t * vam)
15832 vl_api_one_ndp_entries_get_t *mp;
15833 unformat_input_t *input = vam->input;
15838 /* Parse args required to build the message */
15839 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15841 if (unformat (input, "bd %d", &bd))
15845 errmsg ("parse error '%U'", format_unformat_error, input);
15852 errmsg ("Expected bridge domain!");
15856 M (ONE_NDP_ENTRIES_GET, mp);
15857 mp->bd = clib_host_to_net_u32 (bd);
15862 /* wait for reply */
15868 api_one_l2_arp_bd_get (vat_main_t * vam)
15870 vl_api_one_l2_arp_bd_get_t *mp;
15873 M (ONE_L2_ARP_BD_GET, mp);
15878 /* wait for reply */
15884 api_one_l2_arp_entries_get (vat_main_t * vam)
15886 vl_api_one_l2_arp_entries_get_t *mp;
15887 unformat_input_t *input = vam->input;
15892 /* Parse args required to build the message */
15893 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15895 if (unformat (input, "bd %d", &bd))
15899 errmsg ("parse error '%U'", format_unformat_error, input);
15906 errmsg ("Expected bridge domain!");
15910 M (ONE_L2_ARP_ENTRIES_GET, mp);
15911 mp->bd = clib_host_to_net_u32 (bd);
15916 /* wait for reply */
15922 api_one_stats_enable_disable (vat_main_t * vam)
15924 vl_api_one_stats_enable_disable_t *mp;
15925 unformat_input_t *input = vam->input;
15930 /* Parse args required to build the message */
15931 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15933 if (unformat (input, "enable"))
15938 else if (unformat (input, "disable"))
15948 errmsg ("Value not set");
15952 M (ONE_STATS_ENABLE_DISABLE, mp);
15958 /* wait for reply */
15964 api_show_one_stats_enable_disable (vat_main_t * vam)
15966 vl_api_show_one_stats_enable_disable_t *mp;
15969 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
15974 /* wait for reply */
15980 api_show_one_map_request_mode (vat_main_t * vam)
15982 vl_api_show_one_map_request_mode_t *mp;
15985 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
15990 /* wait for reply */
15995 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
15998 api_one_map_request_mode (vat_main_t * vam)
16000 unformat_input_t *input = vam->input;
16001 vl_api_one_map_request_mode_t *mp;
16005 /* Parse args required to build the message */
16006 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16008 if (unformat (input, "dst-only"))
16010 else if (unformat (input, "src-dst"))
16014 errmsg ("parse error '%U'", format_unformat_error, input);
16019 M (ONE_MAP_REQUEST_MODE, mp);
16026 /* wait for reply */
16031 #define api_lisp_map_request_mode api_one_map_request_mode
16034 * Enable/disable ONE proxy ITR.
16036 * @param vam vpp API test context
16037 * @return return code
16040 api_one_pitr_set_locator_set (vat_main_t * vam)
16042 u8 ls_name_set = 0;
16043 unformat_input_t *input = vam->input;
16044 vl_api_one_pitr_set_locator_set_t *mp;
16049 /* Parse args required to build the message */
16050 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16052 if (unformat (input, "del"))
16054 else if (unformat (input, "locator-set %s", &ls_name))
16058 errmsg ("parse error '%U'", format_unformat_error, input);
16065 errmsg ("locator-set name not set!");
16069 M (ONE_PITR_SET_LOCATOR_SET, mp);
16071 mp->is_add = is_add;
16072 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16073 vec_free (ls_name);
16078 /* wait for reply */
16083 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16086 api_one_nsh_set_locator_set (vat_main_t * vam)
16088 u8 ls_name_set = 0;
16089 unformat_input_t *input = vam->input;
16090 vl_api_one_nsh_set_locator_set_t *mp;
16095 /* Parse args required to build the message */
16096 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16098 if (unformat (input, "del"))
16100 else if (unformat (input, "ls %s", &ls_name))
16104 errmsg ("parse error '%U'", format_unformat_error, input);
16109 if (!ls_name_set && is_add)
16111 errmsg ("locator-set name not set!");
16115 M (ONE_NSH_SET_LOCATOR_SET, mp);
16117 mp->is_add = is_add;
16118 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16119 vec_free (ls_name);
16124 /* wait for reply */
16130 api_show_one_pitr (vat_main_t * vam)
16132 vl_api_show_one_pitr_t *mp;
16135 if (!vam->json_output)
16137 print (vam->ofp, "%=20s", "lisp status:");
16140 M (SHOW_ONE_PITR, mp);
16144 /* Wait for a reply... */
16149 #define api_show_lisp_pitr api_show_one_pitr
16152 api_one_use_petr (vat_main_t * vam)
16154 unformat_input_t *input = vam->input;
16155 vl_api_one_use_petr_t *mp;
16160 memset (&ip, 0, sizeof (ip));
16162 /* Parse args required to build the message */
16163 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16165 if (unformat (input, "disable"))
16168 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16171 ip_addr_version (&ip) = IP4;
16174 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16177 ip_addr_version (&ip) = IP6;
16181 errmsg ("parse error '%U'", format_unformat_error, input);
16186 M (ONE_USE_PETR, mp);
16188 mp->is_add = is_add;
16191 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16193 clib_memcpy (mp->address, &ip, 4);
16195 clib_memcpy (mp->address, &ip, 16);
16201 /* wait for reply */
16206 #define api_lisp_use_petr api_one_use_petr
16209 api_show_one_nsh_mapping (vat_main_t * vam)
16211 vl_api_show_one_use_petr_t *mp;
16214 if (!vam->json_output)
16216 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16219 M (SHOW_ONE_NSH_MAPPING, mp);
16223 /* Wait for a reply... */
16229 api_show_one_use_petr (vat_main_t * vam)
16231 vl_api_show_one_use_petr_t *mp;
16234 if (!vam->json_output)
16236 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16239 M (SHOW_ONE_USE_PETR, mp);
16243 /* Wait for a reply... */
16248 #define api_show_lisp_use_petr api_show_one_use_petr
16251 * Add/delete mapping between vni and vrf
16254 api_one_eid_table_add_del_map (vat_main_t * vam)
16256 unformat_input_t *input = vam->input;
16257 vl_api_one_eid_table_add_del_map_t *mp;
16258 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16259 u32 vni, vrf, bd_index;
16262 /* Parse args required to build the message */
16263 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16265 if (unformat (input, "del"))
16267 else if (unformat (input, "vrf %d", &vrf))
16269 else if (unformat (input, "bd_index %d", &bd_index))
16271 else if (unformat (input, "vni %d", &vni))
16277 if (!vni_set || (!vrf_set && !bd_index_set))
16279 errmsg ("missing arguments!");
16283 if (vrf_set && bd_index_set)
16285 errmsg ("error: both vrf and bd entered!");
16289 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16291 mp->is_add = is_add;
16292 mp->vni = htonl (vni);
16293 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16294 mp->is_l2 = bd_index_set;
16299 /* wait for reply */
16304 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16307 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16309 u32 *action = va_arg (*args, u32 *);
16312 if (unformat (input, "%s", &s))
16314 if (!strcmp ((char *) s, "no-action"))
16316 else if (!strcmp ((char *) s, "natively-forward"))
16318 else if (!strcmp ((char *) s, "send-map-request"))
16320 else if (!strcmp ((char *) s, "drop"))
16324 clib_warning ("invalid action: '%s'", s);
16336 * Add/del remote mapping to/from ONE control plane
16338 * @param vam vpp API test context
16339 * @return return code
16342 api_one_add_del_remote_mapping (vat_main_t * vam)
16344 unformat_input_t *input = vam->input;
16345 vl_api_one_add_del_remote_mapping_t *mp;
16347 lisp_eid_vat_t _eid, *eid = &_eid;
16348 lisp_eid_vat_t _seid, *seid = &_seid;
16349 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16350 u32 action = ~0, p, w, data_len;
16351 ip4_address_t rloc4;
16352 ip6_address_t rloc6;
16353 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16356 memset (&rloc, 0, sizeof (rloc));
16358 /* Parse args required to build the message */
16359 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16361 if (unformat (input, "del-all"))
16365 else if (unformat (input, "del"))
16369 else if (unformat (input, "add"))
16373 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16377 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16381 else if (unformat (input, "vni %d", &vni))
16385 else if (unformat (input, "p %d w %d", &p, &w))
16389 errmsg ("No RLOC configured for setting priority/weight!");
16392 curr_rloc->priority = p;
16393 curr_rloc->weight = w;
16395 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16398 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
16399 vec_add1 (rlocs, rloc);
16400 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16402 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16405 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
16406 vec_add1 (rlocs, rloc);
16407 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16409 else if (unformat (input, "action %U",
16410 unformat_negative_mapping_action, &action))
16416 clib_warning ("parse error '%U'", format_unformat_error, input);
16423 errmsg ("missing params!");
16427 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
16429 errmsg ("no action set for negative map-reply!");
16433 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
16435 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
16436 mp->is_add = is_add;
16437 mp->vni = htonl (vni);
16438 mp->action = (u8) action;
16439 mp->is_src_dst = seid_set;
16440 mp->eid_len = eid->len;
16441 mp->seid_len = seid->len;
16442 mp->del_all = del_all;
16443 mp->eid_type = eid->type;
16444 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16445 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
16447 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
16448 clib_memcpy (mp->rlocs, rlocs, data_len);
16454 /* Wait for a reply... */
16459 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
16462 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
16463 * forwarding entries in data-plane accordingly.
16465 * @param vam vpp API test context
16466 * @return return code
16469 api_one_add_del_adjacency (vat_main_t * vam)
16471 unformat_input_t *input = vam->input;
16472 vl_api_one_add_del_adjacency_t *mp;
16474 ip4_address_t leid4, reid4;
16475 ip6_address_t leid6, reid6;
16476 u8 reid_mac[6] = { 0 };
16477 u8 leid_mac[6] = { 0 };
16478 u8 reid_type, leid_type;
16479 u32 leid_len = 0, reid_len = 0, len;
16483 leid_type = reid_type = (u8) ~ 0;
16485 /* Parse args required to build the message */
16486 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16488 if (unformat (input, "del"))
16492 else if (unformat (input, "add"))
16496 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
16499 reid_type = 0; /* ipv4 */
16502 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
16505 reid_type = 1; /* ipv6 */
16508 else if (unformat (input, "reid %U", unformat_ethernet_address,
16511 reid_type = 2; /* mac */
16513 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
16516 leid_type = 0; /* ipv4 */
16519 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
16522 leid_type = 1; /* ipv6 */
16525 else if (unformat (input, "leid %U", unformat_ethernet_address,
16528 leid_type = 2; /* mac */
16530 else if (unformat (input, "vni %d", &vni))
16536 errmsg ("parse error '%U'", format_unformat_error, input);
16541 if ((u8) ~ 0 == reid_type)
16543 errmsg ("missing params!");
16547 if (leid_type != reid_type)
16549 errmsg ("remote and local EIDs are of different types!");
16553 M (ONE_ADD_DEL_ADJACENCY, mp);
16554 mp->is_add = is_add;
16555 mp->vni = htonl (vni);
16556 mp->leid_len = leid_len;
16557 mp->reid_len = reid_len;
16558 mp->eid_type = reid_type;
16560 switch (mp->eid_type)
16563 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
16564 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
16567 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
16568 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
16571 clib_memcpy (mp->leid, leid_mac, 6);
16572 clib_memcpy (mp->reid, reid_mac, 6);
16575 errmsg ("unknown EID type %d!", mp->eid_type);
16582 /* Wait for a reply... */
16587 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
16590 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
16592 u32 *mode = va_arg (*args, u32 *);
16594 if (unformat (input, "lisp"))
16596 else if (unformat (input, "vxlan"))
16605 api_gpe_get_encap_mode (vat_main_t * vam)
16607 vl_api_gpe_get_encap_mode_t *mp;
16610 /* Construct the API message */
16611 M (GPE_GET_ENCAP_MODE, mp);
16616 /* Wait for a reply... */
16622 api_gpe_set_encap_mode (vat_main_t * vam)
16624 unformat_input_t *input = vam->input;
16625 vl_api_gpe_set_encap_mode_t *mp;
16629 /* Parse args required to build the message */
16630 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16632 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
16638 /* Construct the API message */
16639 M (GPE_SET_ENCAP_MODE, mp);
16646 /* Wait for a reply... */
16652 api_lisp_gpe_add_del_iface (vat_main_t * vam)
16654 unformat_input_t *input = vam->input;
16655 vl_api_gpe_add_del_iface_t *mp;
16656 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
16657 u32 dp_table = 0, vni = 0;
16660 /* Parse args required to build the message */
16661 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16663 if (unformat (input, "up"))
16668 else if (unformat (input, "down"))
16673 else if (unformat (input, "table_id %d", &dp_table))
16677 else if (unformat (input, "bd_id %d", &dp_table))
16682 else if (unformat (input, "vni %d", &vni))
16690 if (action_set == 0)
16692 errmsg ("Action not set");
16695 if (dp_table_set == 0 || vni_set == 0)
16697 errmsg ("vni and dp_table must be set");
16701 /* Construct the API message */
16702 M (GPE_ADD_DEL_IFACE, mp);
16704 mp->is_add = is_add;
16705 mp->dp_table = clib_host_to_net_u32 (dp_table);
16707 mp->vni = clib_host_to_net_u32 (vni);
16712 /* Wait for a reply... */
16718 api_one_map_register_fallback_threshold (vat_main_t * vam)
16720 unformat_input_t *input = vam->input;
16721 vl_api_one_map_register_fallback_threshold_t *mp;
16726 /* Parse args required to build the message */
16727 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16729 if (unformat (input, "%u", &value))
16733 clib_warning ("parse error '%U'", format_unformat_error, input);
16740 errmsg ("fallback threshold value is missing!");
16744 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16745 mp->value = clib_host_to_net_u32 (value);
16750 /* Wait for a reply... */
16756 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
16758 vl_api_show_one_map_register_fallback_threshold_t *mp;
16761 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16766 /* Wait for a reply... */
16772 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
16774 u32 *proto = va_arg (*args, u32 *);
16776 if (unformat (input, "udp"))
16778 else if (unformat (input, "api"))
16787 api_one_set_transport_protocol (vat_main_t * vam)
16789 unformat_input_t *input = vam->input;
16790 vl_api_one_set_transport_protocol_t *mp;
16795 /* Parse args required to build the message */
16796 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16798 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
16802 clib_warning ("parse error '%U'", format_unformat_error, input);
16809 errmsg ("Transport protocol missing!");
16813 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
16814 mp->protocol = (u8) protocol;
16819 /* Wait for a reply... */
16825 api_one_get_transport_protocol (vat_main_t * vam)
16827 vl_api_one_get_transport_protocol_t *mp;
16830 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
16835 /* Wait for a reply... */
16841 api_one_map_register_set_ttl (vat_main_t * vam)
16843 unformat_input_t *input = vam->input;
16844 vl_api_one_map_register_set_ttl_t *mp;
16849 /* Parse args required to build the message */
16850 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16852 if (unformat (input, "%u", &ttl))
16856 clib_warning ("parse error '%U'", format_unformat_error, input);
16863 errmsg ("TTL value missing!");
16867 M (ONE_MAP_REGISTER_SET_TTL, mp);
16868 mp->ttl = clib_host_to_net_u32 (ttl);
16873 /* Wait for a reply... */
16879 api_show_one_map_register_ttl (vat_main_t * vam)
16881 vl_api_show_one_map_register_ttl_t *mp;
16884 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
16889 /* Wait for a reply... */
16895 * Add/del map request itr rlocs from ONE control plane and updates
16897 * @param vam vpp API test context
16898 * @return return code
16901 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
16903 unformat_input_t *input = vam->input;
16904 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
16905 u8 *locator_set_name = 0;
16906 u8 locator_set_name_set = 0;
16910 /* Parse args required to build the message */
16911 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16913 if (unformat (input, "del"))
16917 else if (unformat (input, "%_%v%_", &locator_set_name))
16919 locator_set_name_set = 1;
16923 clib_warning ("parse error '%U'", format_unformat_error, input);
16928 if (is_add && !locator_set_name_set)
16930 errmsg ("itr-rloc is not set!");
16934 if (is_add && vec_len (locator_set_name) > 64)
16936 errmsg ("itr-rloc locator-set name too long");
16937 vec_free (locator_set_name);
16941 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
16942 mp->is_add = is_add;
16945 clib_memcpy (mp->locator_set_name, locator_set_name,
16946 vec_len (locator_set_name));
16950 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
16952 vec_free (locator_set_name);
16957 /* Wait for a reply... */
16962 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
16965 api_one_locator_dump (vat_main_t * vam)
16967 unformat_input_t *input = vam->input;
16968 vl_api_one_locator_dump_t *mp;
16969 vl_api_control_ping_t *mp_ping;
16970 u8 is_index_set = 0, is_name_set = 0;
16975 /* Parse args required to build the message */
16976 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16978 if (unformat (input, "ls_name %_%v%_", &ls_name))
16982 else if (unformat (input, "ls_index %d", &ls_index))
16988 errmsg ("parse error '%U'", format_unformat_error, input);
16993 if (!is_index_set && !is_name_set)
16995 errmsg ("error: expected one of index or name!");
16999 if (is_index_set && is_name_set)
17001 errmsg ("error: only one param expected!");
17005 if (vec_len (ls_name) > 62)
17007 errmsg ("error: locator set name too long!");
17011 if (!vam->json_output)
17013 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17016 M (ONE_LOCATOR_DUMP, mp);
17017 mp->is_index_set = is_index_set;
17020 mp->ls_index = clib_host_to_net_u32 (ls_index);
17023 vec_add1 (ls_name, 0);
17024 strncpy ((char *) mp->ls_name, (char *) ls_name,
17025 sizeof (mp->ls_name) - 1);
17031 /* Use a control ping for synchronization */
17032 MPING (CONTROL_PING, mp_ping);
17035 /* Wait for a reply... */
17040 #define api_lisp_locator_dump api_one_locator_dump
17043 api_one_locator_set_dump (vat_main_t * vam)
17045 vl_api_one_locator_set_dump_t *mp;
17046 vl_api_control_ping_t *mp_ping;
17047 unformat_input_t *input = vam->input;
17051 /* Parse args required to build the message */
17052 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17054 if (unformat (input, "local"))
17058 else if (unformat (input, "remote"))
17064 errmsg ("parse error '%U'", format_unformat_error, input);
17069 if (!vam->json_output)
17071 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17074 M (ONE_LOCATOR_SET_DUMP, mp);
17076 mp->filter = filter;
17081 /* Use a control ping for synchronization */
17082 MPING (CONTROL_PING, mp_ping);
17085 /* Wait for a reply... */
17090 #define api_lisp_locator_set_dump api_one_locator_set_dump
17093 api_one_eid_table_map_dump (vat_main_t * vam)
17097 unformat_input_t *input = vam->input;
17098 vl_api_one_eid_table_map_dump_t *mp;
17099 vl_api_control_ping_t *mp_ping;
17102 /* Parse args required to build the message */
17103 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17105 if (unformat (input, "l2"))
17110 else if (unformat (input, "l3"))
17117 errmsg ("parse error '%U'", format_unformat_error, input);
17124 errmsg ("expected one of 'l2' or 'l3' parameter!");
17128 if (!vam->json_output)
17130 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17133 M (ONE_EID_TABLE_MAP_DUMP, mp);
17139 /* Use a control ping for synchronization */
17140 MPING (CONTROL_PING, mp_ping);
17143 /* Wait for a reply... */
17148 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17151 api_one_eid_table_vni_dump (vat_main_t * vam)
17153 vl_api_one_eid_table_vni_dump_t *mp;
17154 vl_api_control_ping_t *mp_ping;
17157 if (!vam->json_output)
17159 print (vam->ofp, "VNI");
17162 M (ONE_EID_TABLE_VNI_DUMP, mp);
17167 /* Use a control ping for synchronization */
17168 MPING (CONTROL_PING, mp_ping);
17171 /* Wait for a reply... */
17176 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17179 api_one_eid_table_dump (vat_main_t * vam)
17181 unformat_input_t *i = vam->input;
17182 vl_api_one_eid_table_dump_t *mp;
17183 vl_api_control_ping_t *mp_ping;
17184 struct in_addr ip4;
17185 struct in6_addr ip6;
17187 u8 eid_type = ~0, eid_set = 0;
17188 u32 prefix_length = ~0, t, vni = 0;
17191 lisp_nsh_api_t nsh;
17193 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17195 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17201 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17207 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17212 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17217 else if (unformat (i, "vni %d", &t))
17221 else if (unformat (i, "local"))
17225 else if (unformat (i, "remote"))
17231 errmsg ("parse error '%U'", format_unformat_error, i);
17236 if (!vam->json_output)
17238 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17239 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17242 M (ONE_EID_TABLE_DUMP, mp);
17244 mp->filter = filter;
17248 mp->vni = htonl (vni);
17249 mp->eid_type = eid_type;
17253 mp->prefix_length = prefix_length;
17254 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17257 mp->prefix_length = prefix_length;
17258 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17261 clib_memcpy (mp->eid, mac, sizeof (mac));
17264 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17267 errmsg ("unknown EID type %d!", eid_type);
17275 /* Use a control ping for synchronization */
17276 MPING (CONTROL_PING, mp_ping);
17279 /* Wait for a reply... */
17284 #define api_lisp_eid_table_dump api_one_eid_table_dump
17287 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17289 unformat_input_t *i = vam->input;
17290 vl_api_gpe_fwd_entries_get_t *mp;
17295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17297 if (unformat (i, "vni %d", &vni))
17303 errmsg ("parse error '%U'", format_unformat_error, i);
17310 errmsg ("vni not set!");
17314 if (!vam->json_output)
17316 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17320 M (GPE_FWD_ENTRIES_GET, mp);
17321 mp->vni = clib_host_to_net_u32 (vni);
17326 /* Wait for a reply... */
17331 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17332 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17333 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17334 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17335 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17336 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17337 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17338 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17341 api_one_adjacencies_get (vat_main_t * vam)
17343 unformat_input_t *i = vam->input;
17344 vl_api_one_adjacencies_get_t *mp;
17349 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17351 if (unformat (i, "vni %d", &vni))
17357 errmsg ("parse error '%U'", format_unformat_error, i);
17364 errmsg ("vni not set!");
17368 if (!vam->json_output)
17370 print (vam->ofp, "%s %40s", "leid", "reid");
17373 M (ONE_ADJACENCIES_GET, mp);
17374 mp->vni = clib_host_to_net_u32 (vni);
17379 /* Wait for a reply... */
17384 #define api_lisp_adjacencies_get api_one_adjacencies_get
17387 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17389 unformat_input_t *i = vam->input;
17390 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17392 u8 ip_family_set = 0, is_ip4 = 1;
17394 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17396 if (unformat (i, "ip4"))
17401 else if (unformat (i, "ip6"))
17408 errmsg ("parse error '%U'", format_unformat_error, i);
17413 if (!ip_family_set)
17415 errmsg ("ip family not set!");
17419 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
17420 mp->is_ip4 = is_ip4;
17425 /* Wait for a reply... */
17431 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
17433 vl_api_gpe_fwd_entry_vnis_get_t *mp;
17436 if (!vam->json_output)
17438 print (vam->ofp, "VNIs");
17441 M (GPE_FWD_ENTRY_VNIS_GET, mp);
17446 /* Wait for a reply... */
17452 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
17454 unformat_input_t *i = vam->input;
17455 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
17457 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
17458 struct in_addr ip4;
17459 struct in6_addr ip6;
17460 u32 table_id = 0, nh_sw_if_index = ~0;
17462 memset (&ip4, 0, sizeof (ip4));
17463 memset (&ip6, 0, sizeof (ip6));
17465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17467 if (unformat (i, "del"))
17469 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
17470 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17475 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
17476 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17481 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
17485 nh_sw_if_index = ~0;
17487 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
17491 nh_sw_if_index = ~0;
17493 else if (unformat (i, "table %d", &table_id))
17497 errmsg ("parse error '%U'", format_unformat_error, i);
17504 errmsg ("nh addr not set!");
17508 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
17509 mp->is_add = is_add;
17510 mp->table_id = clib_host_to_net_u32 (table_id);
17511 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
17512 mp->is_ip4 = is_ip4;
17514 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
17516 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
17521 /* Wait for a reply... */
17527 api_one_map_server_dump (vat_main_t * vam)
17529 vl_api_one_map_server_dump_t *mp;
17530 vl_api_control_ping_t *mp_ping;
17533 if (!vam->json_output)
17535 print (vam->ofp, "%=20s", "Map server");
17538 M (ONE_MAP_SERVER_DUMP, mp);
17542 /* Use a control ping for synchronization */
17543 MPING (CONTROL_PING, mp_ping);
17546 /* Wait for a reply... */
17551 #define api_lisp_map_server_dump api_one_map_server_dump
17554 api_one_map_resolver_dump (vat_main_t * vam)
17556 vl_api_one_map_resolver_dump_t *mp;
17557 vl_api_control_ping_t *mp_ping;
17560 if (!vam->json_output)
17562 print (vam->ofp, "%=20s", "Map resolver");
17565 M (ONE_MAP_RESOLVER_DUMP, mp);
17569 /* Use a control ping for synchronization */
17570 MPING (CONTROL_PING, mp_ping);
17573 /* Wait for a reply... */
17578 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
17581 api_one_stats_flush (vat_main_t * vam)
17583 vl_api_one_stats_flush_t *mp;
17586 M (ONE_STATS_FLUSH, mp);
17593 api_one_stats_dump (vat_main_t * vam)
17595 vl_api_one_stats_dump_t *mp;
17596 vl_api_control_ping_t *mp_ping;
17599 M (ONE_STATS_DUMP, mp);
17603 /* Use a control ping for synchronization */
17604 MPING (CONTROL_PING, mp_ping);
17607 /* Wait for a reply... */
17613 api_show_one_status (vat_main_t * vam)
17615 vl_api_show_one_status_t *mp;
17618 if (!vam->json_output)
17620 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
17623 M (SHOW_ONE_STATUS, mp);
17626 /* Wait for a reply... */
17631 #define api_show_lisp_status api_show_one_status
17634 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
17636 vl_api_gpe_fwd_entry_path_dump_t *mp;
17637 vl_api_control_ping_t *mp_ping;
17638 unformat_input_t *i = vam->input;
17639 u32 fwd_entry_index = ~0;
17642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17644 if (unformat (i, "index %d", &fwd_entry_index))
17650 if (~0 == fwd_entry_index)
17652 errmsg ("no index specified!");
17656 if (!vam->json_output)
17658 print (vam->ofp, "first line");
17661 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
17665 /* Use a control ping for synchronization */
17666 MPING (CONTROL_PING, mp_ping);
17669 /* Wait for a reply... */
17675 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
17677 vl_api_one_get_map_request_itr_rlocs_t *mp;
17680 if (!vam->json_output)
17682 print (vam->ofp, "%=20s", "itr-rlocs:");
17685 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
17688 /* Wait for a reply... */
17693 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
17696 api_af_packet_create (vat_main_t * vam)
17698 unformat_input_t *i = vam->input;
17699 vl_api_af_packet_create_t *mp;
17700 u8 *host_if_name = 0;
17702 u8 random_hw_addr = 1;
17705 memset (hw_addr, 0, sizeof (hw_addr));
17707 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17709 if (unformat (i, "name %s", &host_if_name))
17710 vec_add1 (host_if_name, 0);
17711 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17712 random_hw_addr = 0;
17717 if (!vec_len (host_if_name))
17719 errmsg ("host-interface name must be specified");
17723 if (vec_len (host_if_name) > 64)
17725 errmsg ("host-interface name too long");
17729 M (AF_PACKET_CREATE, mp);
17731 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17732 clib_memcpy (mp->hw_addr, hw_addr, 6);
17733 mp->use_random_hw_addr = random_hw_addr;
17734 vec_free (host_if_name);
17742 fprintf (vam->ofp ? vam->ofp : stderr,
17743 " new sw_if_index = %d\n", vam->sw_if_index);
17750 api_af_packet_delete (vat_main_t * vam)
17752 unformat_input_t *i = vam->input;
17753 vl_api_af_packet_delete_t *mp;
17754 u8 *host_if_name = 0;
17757 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17759 if (unformat (i, "name %s", &host_if_name))
17760 vec_add1 (host_if_name, 0);
17765 if (!vec_len (host_if_name))
17767 errmsg ("host-interface name must be specified");
17771 if (vec_len (host_if_name) > 64)
17773 errmsg ("host-interface name too long");
17777 M (AF_PACKET_DELETE, mp);
17779 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17780 vec_free (host_if_name);
17788 api_policer_add_del (vat_main_t * vam)
17790 unformat_input_t *i = vam->input;
17791 vl_api_policer_add_del_t *mp;
17801 u8 color_aware = 0;
17802 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
17805 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
17806 conform_action.dscp = 0;
17807 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
17808 exceed_action.dscp = 0;
17809 violate_action.action_type = SSE2_QOS_ACTION_DROP;
17810 violate_action.dscp = 0;
17812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17814 if (unformat (i, "del"))
17816 else if (unformat (i, "name %s", &name))
17817 vec_add1 (name, 0);
17818 else if (unformat (i, "cir %u", &cir))
17820 else if (unformat (i, "eir %u", &eir))
17822 else if (unformat (i, "cb %u", &cb))
17824 else if (unformat (i, "eb %u", &eb))
17826 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
17829 else if (unformat (i, "round_type %U", unformat_policer_round_type,
17832 else if (unformat (i, "type %U", unformat_policer_type, &type))
17834 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
17837 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
17840 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
17843 else if (unformat (i, "color-aware"))
17849 if (!vec_len (name))
17851 errmsg ("policer name must be specified");
17855 if (vec_len (name) > 64)
17857 errmsg ("policer name too long");
17861 M (POLICER_ADD_DEL, mp);
17863 clib_memcpy (mp->name, name, vec_len (name));
17865 mp->is_add = is_add;
17870 mp->rate_type = rate_type;
17871 mp->round_type = round_type;
17873 mp->conform_action_type = conform_action.action_type;
17874 mp->conform_dscp = conform_action.dscp;
17875 mp->exceed_action_type = exceed_action.action_type;
17876 mp->exceed_dscp = exceed_action.dscp;
17877 mp->violate_action_type = violate_action.action_type;
17878 mp->violate_dscp = violate_action.dscp;
17879 mp->color_aware = color_aware;
17887 api_policer_dump (vat_main_t * vam)
17889 unformat_input_t *i = vam->input;
17890 vl_api_policer_dump_t *mp;
17891 vl_api_control_ping_t *mp_ping;
17892 u8 *match_name = 0;
17893 u8 match_name_valid = 0;
17896 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17898 if (unformat (i, "name %s", &match_name))
17900 vec_add1 (match_name, 0);
17901 match_name_valid = 1;
17907 M (POLICER_DUMP, mp);
17908 mp->match_name_valid = match_name_valid;
17909 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
17910 vec_free (match_name);
17914 /* Use a control ping for synchronization */
17915 MPING (CONTROL_PING, mp_ping);
17918 /* Wait for a reply... */
17924 api_policer_classify_set_interface (vat_main_t * vam)
17926 unformat_input_t *i = vam->input;
17927 vl_api_policer_classify_set_interface_t *mp;
17929 int sw_if_index_set;
17930 u32 ip4_table_index = ~0;
17931 u32 ip6_table_index = ~0;
17932 u32 l2_table_index = ~0;
17936 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17938 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17939 sw_if_index_set = 1;
17940 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17941 sw_if_index_set = 1;
17942 else if (unformat (i, "del"))
17944 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17946 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17948 else if (unformat (i, "l2-table %d", &l2_table_index))
17952 clib_warning ("parse error '%U'", format_unformat_error, i);
17957 if (sw_if_index_set == 0)
17959 errmsg ("missing interface name or sw_if_index");
17963 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
17965 mp->sw_if_index = ntohl (sw_if_index);
17966 mp->ip4_table_index = ntohl (ip4_table_index);
17967 mp->ip6_table_index = ntohl (ip6_table_index);
17968 mp->l2_table_index = ntohl (l2_table_index);
17969 mp->is_add = is_add;
17977 api_policer_classify_dump (vat_main_t * vam)
17979 unformat_input_t *i = vam->input;
17980 vl_api_policer_classify_dump_t *mp;
17981 vl_api_control_ping_t *mp_ping;
17982 u8 type = POLICER_CLASSIFY_N_TABLES;
17985 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
17989 errmsg ("classify table type must be specified");
17993 if (!vam->json_output)
17995 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17998 M (POLICER_CLASSIFY_DUMP, mp);
18003 /* Use a control ping for synchronization */
18004 MPING (CONTROL_PING, mp_ping);
18007 /* Wait for a reply... */
18013 api_netmap_create (vat_main_t * vam)
18015 unformat_input_t *i = vam->input;
18016 vl_api_netmap_create_t *mp;
18019 u8 random_hw_addr = 1;
18024 memset (hw_addr, 0, sizeof (hw_addr));
18026 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18028 if (unformat (i, "name %s", &if_name))
18029 vec_add1 (if_name, 0);
18030 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18031 random_hw_addr = 0;
18032 else if (unformat (i, "pipe"))
18034 else if (unformat (i, "master"))
18036 else if (unformat (i, "slave"))
18042 if (!vec_len (if_name))
18044 errmsg ("interface name must be specified");
18048 if (vec_len (if_name) > 64)
18050 errmsg ("interface name too long");
18054 M (NETMAP_CREATE, mp);
18056 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18057 clib_memcpy (mp->hw_addr, hw_addr, 6);
18058 mp->use_random_hw_addr = random_hw_addr;
18059 mp->is_pipe = is_pipe;
18060 mp->is_master = is_master;
18061 vec_free (if_name);
18069 api_netmap_delete (vat_main_t * vam)
18071 unformat_input_t *i = vam->input;
18072 vl_api_netmap_delete_t *mp;
18076 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18078 if (unformat (i, "name %s", &if_name))
18079 vec_add1 (if_name, 0);
18084 if (!vec_len (if_name))
18086 errmsg ("interface name must be specified");
18090 if (vec_len (if_name) > 64)
18092 errmsg ("interface name too long");
18096 M (NETMAP_DELETE, mp);
18098 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18099 vec_free (if_name);
18107 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
18109 if (fp->afi == IP46_TYPE_IP6)
18111 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18112 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18113 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18114 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18115 format_ip6_address, fp->next_hop);
18116 else if (fp->afi == IP46_TYPE_IP4)
18118 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18119 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18120 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18121 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18122 format_ip4_address, fp->next_hop);
18126 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18127 vl_api_fib_path2_t * fp)
18129 struct in_addr ip4;
18130 struct in6_addr ip6;
18132 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18133 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18134 vat_json_object_add_uint (node, "is_local", fp->is_local);
18135 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18136 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18137 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18138 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18139 if (fp->afi == IP46_TYPE_IP4)
18141 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18142 vat_json_object_add_ip4 (node, "next_hop", ip4);
18144 else if (fp->afi == IP46_TYPE_IP6)
18146 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18147 vat_json_object_add_ip6 (node, "next_hop", ip6);
18152 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18154 vat_main_t *vam = &vat_main;
18155 int count = ntohl (mp->mt_count);
18156 vl_api_fib_path2_t *fp;
18159 print (vam->ofp, "[%d]: sw_if_index %d via:",
18160 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
18162 for (i = 0; i < count; i++)
18164 vl_api_mpls_fib_path_print (vam, fp);
18168 print (vam->ofp, "");
18171 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18172 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18175 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18177 vat_main_t *vam = &vat_main;
18178 vat_json_node_t *node = NULL;
18179 int count = ntohl (mp->mt_count);
18180 vl_api_fib_path2_t *fp;
18183 if (VAT_JSON_ARRAY != vam->json_tree.type)
18185 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18186 vat_json_init_array (&vam->json_tree);
18188 node = vat_json_array_add (&vam->json_tree);
18190 vat_json_init_object (node);
18191 vat_json_object_add_uint (node, "tunnel_index",
18192 ntohl (mp->mt_tunnel_index));
18193 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
18195 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
18198 for (i = 0; i < count; i++)
18200 vl_api_mpls_fib_path_json_print (node, fp);
18206 api_mpls_tunnel_dump (vat_main_t * vam)
18208 vl_api_mpls_tunnel_dump_t *mp;
18209 vl_api_control_ping_t *mp_ping;
18213 /* Parse args required to build the message */
18214 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
18216 if (!unformat (vam->input, "tunnel_index %d", &index))
18223 print (vam->ofp, " tunnel_index %d", index);
18225 M (MPLS_TUNNEL_DUMP, mp);
18226 mp->tunnel_index = htonl (index);
18229 /* Use a control ping for synchronization */
18230 MPING (CONTROL_PING, mp_ping);
18237 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
18238 #define vl_api_mpls_fib_details_t_print vl_noop_handler
18242 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
18244 vat_main_t *vam = &vat_main;
18245 int count = ntohl (mp->count);
18246 vl_api_fib_path2_t *fp;
18250 "table-id %d, label %u, ess_bit %u",
18251 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
18253 for (i = 0; i < count; i++)
18255 vl_api_mpls_fib_path_print (vam, fp);
18260 static void vl_api_mpls_fib_details_t_handler_json
18261 (vl_api_mpls_fib_details_t * mp)
18263 vat_main_t *vam = &vat_main;
18264 int count = ntohl (mp->count);
18265 vat_json_node_t *node = NULL;
18266 vl_api_fib_path2_t *fp;
18269 if (VAT_JSON_ARRAY != vam->json_tree.type)
18271 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18272 vat_json_init_array (&vam->json_tree);
18274 node = vat_json_array_add (&vam->json_tree);
18276 vat_json_init_object (node);
18277 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18278 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
18279 vat_json_object_add_uint (node, "label", ntohl (mp->label));
18280 vat_json_object_add_uint (node, "path_count", count);
18282 for (i = 0; i < count; i++)
18284 vl_api_mpls_fib_path_json_print (node, fp);
18290 api_mpls_fib_dump (vat_main_t * vam)
18292 vl_api_mpls_fib_dump_t *mp;
18293 vl_api_control_ping_t *mp_ping;
18296 M (MPLS_FIB_DUMP, mp);
18299 /* Use a control ping for synchronization */
18300 MPING (CONTROL_PING, mp_ping);
18307 #define vl_api_ip_fib_details_t_endian vl_noop_handler
18308 #define vl_api_ip_fib_details_t_print vl_noop_handler
18311 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
18313 vat_main_t *vam = &vat_main;
18314 int count = ntohl (mp->count);
18315 vl_api_fib_path_t *fp;
18319 "table-id %d, prefix %U/%d",
18320 ntohl (mp->table_id), format_ip4_address, mp->address,
18321 mp->address_length);
18323 for (i = 0; i < count; i++)
18325 if (fp->afi == IP46_TYPE_IP6)
18327 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18328 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18329 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18330 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18331 format_ip6_address, fp->next_hop);
18332 else if (fp->afi == IP46_TYPE_IP4)
18334 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18335 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18336 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18337 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18338 format_ip4_address, fp->next_hop);
18343 static void vl_api_ip_fib_details_t_handler_json
18344 (vl_api_ip_fib_details_t * mp)
18346 vat_main_t *vam = &vat_main;
18347 int count = ntohl (mp->count);
18348 vat_json_node_t *node = NULL;
18349 struct in_addr ip4;
18350 struct in6_addr ip6;
18351 vl_api_fib_path_t *fp;
18354 if (VAT_JSON_ARRAY != vam->json_tree.type)
18356 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18357 vat_json_init_array (&vam->json_tree);
18359 node = vat_json_array_add (&vam->json_tree);
18361 vat_json_init_object (node);
18362 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18363 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
18364 vat_json_object_add_ip4 (node, "prefix", ip4);
18365 vat_json_object_add_uint (node, "mask_length", mp->address_length);
18366 vat_json_object_add_uint (node, "path_count", count);
18368 for (i = 0; i < count; i++)
18370 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18371 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18372 vat_json_object_add_uint (node, "is_local", fp->is_local);
18373 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18374 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18375 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18376 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18377 if (fp->afi == IP46_TYPE_IP4)
18379 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18380 vat_json_object_add_ip4 (node, "next_hop", ip4);
18382 else if (fp->afi == IP46_TYPE_IP6)
18384 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18385 vat_json_object_add_ip6 (node, "next_hop", ip6);
18391 api_ip_fib_dump (vat_main_t * vam)
18393 vl_api_ip_fib_dump_t *mp;
18394 vl_api_control_ping_t *mp_ping;
18397 M (IP_FIB_DUMP, mp);
18400 /* Use a control ping for synchronization */
18401 MPING (CONTROL_PING, mp_ping);
18409 api_ip_mfib_dump (vat_main_t * vam)
18411 vl_api_ip_mfib_dump_t *mp;
18412 vl_api_control_ping_t *mp_ping;
18415 M (IP_MFIB_DUMP, mp);
18418 /* Use a control ping for synchronization */
18419 MPING (CONTROL_PING, mp_ping);
18426 static void vl_api_ip_neighbor_details_t_handler
18427 (vl_api_ip_neighbor_details_t * mp)
18429 vat_main_t *vam = &vat_main;
18431 print (vam->ofp, "%c %U %U",
18432 (mp->is_static) ? 'S' : 'D',
18433 format_ethernet_address, &mp->mac_address,
18434 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
18438 static void vl_api_ip_neighbor_details_t_handler_json
18439 (vl_api_ip_neighbor_details_t * mp)
18442 vat_main_t *vam = &vat_main;
18443 vat_json_node_t *node;
18444 struct in_addr ip4;
18445 struct in6_addr ip6;
18447 if (VAT_JSON_ARRAY != vam->json_tree.type)
18449 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18450 vat_json_init_array (&vam->json_tree);
18452 node = vat_json_array_add (&vam->json_tree);
18454 vat_json_init_object (node);
18455 vat_json_object_add_string_copy (node, "flag",
18456 (mp->is_static) ? (u8 *) "static" : (u8 *)
18459 vat_json_object_add_string_copy (node, "link_layer",
18460 format (0, "%U", format_ethernet_address,
18461 &mp->mac_address));
18465 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
18466 vat_json_object_add_ip6 (node, "ip_address", ip6);
18470 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
18471 vat_json_object_add_ip4 (node, "ip_address", ip4);
18476 api_ip_neighbor_dump (vat_main_t * vam)
18478 unformat_input_t *i = vam->input;
18479 vl_api_ip_neighbor_dump_t *mp;
18480 vl_api_control_ping_t *mp_ping;
18482 u32 sw_if_index = ~0;
18485 /* Parse args required to build the message */
18486 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18488 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18490 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18492 else if (unformat (i, "ip6"))
18498 if (sw_if_index == ~0)
18500 errmsg ("missing interface name or sw_if_index");
18504 M (IP_NEIGHBOR_DUMP, mp);
18505 mp->is_ipv6 = (u8) is_ipv6;
18506 mp->sw_if_index = ntohl (sw_if_index);
18509 /* Use a control ping for synchronization */
18510 MPING (CONTROL_PING, mp_ping);
18517 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
18518 #define vl_api_ip6_fib_details_t_print vl_noop_handler
18521 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
18523 vat_main_t *vam = &vat_main;
18524 int count = ntohl (mp->count);
18525 vl_api_fib_path_t *fp;
18529 "table-id %d, prefix %U/%d",
18530 ntohl (mp->table_id), format_ip6_address, mp->address,
18531 mp->address_length);
18533 for (i = 0; i < count; i++)
18535 if (fp->afi == IP46_TYPE_IP6)
18537 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18538 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18539 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18540 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18541 format_ip6_address, fp->next_hop);
18542 else if (fp->afi == IP46_TYPE_IP4)
18544 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18545 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18546 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18547 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18548 format_ip4_address, fp->next_hop);
18553 static void vl_api_ip6_fib_details_t_handler_json
18554 (vl_api_ip6_fib_details_t * mp)
18556 vat_main_t *vam = &vat_main;
18557 int count = ntohl (mp->count);
18558 vat_json_node_t *node = NULL;
18559 struct in_addr ip4;
18560 struct in6_addr ip6;
18561 vl_api_fib_path_t *fp;
18564 if (VAT_JSON_ARRAY != vam->json_tree.type)
18566 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18567 vat_json_init_array (&vam->json_tree);
18569 node = vat_json_array_add (&vam->json_tree);
18571 vat_json_init_object (node);
18572 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18573 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
18574 vat_json_object_add_ip6 (node, "prefix", ip6);
18575 vat_json_object_add_uint (node, "mask_length", mp->address_length);
18576 vat_json_object_add_uint (node, "path_count", count);
18578 for (i = 0; i < count; i++)
18580 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18581 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18582 vat_json_object_add_uint (node, "is_local", fp->is_local);
18583 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18584 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18585 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18586 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18587 if (fp->afi == IP46_TYPE_IP4)
18589 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18590 vat_json_object_add_ip4 (node, "next_hop", ip4);
18592 else if (fp->afi == IP46_TYPE_IP6)
18594 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18595 vat_json_object_add_ip6 (node, "next_hop", ip6);
18601 api_ip6_fib_dump (vat_main_t * vam)
18603 vl_api_ip6_fib_dump_t *mp;
18604 vl_api_control_ping_t *mp_ping;
18607 M (IP6_FIB_DUMP, mp);
18610 /* Use a control ping for synchronization */
18611 MPING (CONTROL_PING, mp_ping);
18619 api_ip6_mfib_dump (vat_main_t * vam)
18621 vl_api_ip6_mfib_dump_t *mp;
18622 vl_api_control_ping_t *mp_ping;
18625 M (IP6_MFIB_DUMP, mp);
18628 /* Use a control ping for synchronization */
18629 MPING (CONTROL_PING, mp_ping);
18637 api_classify_table_ids (vat_main_t * vam)
18639 vl_api_classify_table_ids_t *mp;
18642 /* Construct the API message */
18643 M (CLASSIFY_TABLE_IDS, mp);
18652 api_classify_table_by_interface (vat_main_t * vam)
18654 unformat_input_t *input = vam->input;
18655 vl_api_classify_table_by_interface_t *mp;
18657 u32 sw_if_index = ~0;
18659 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18661 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18663 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18668 if (sw_if_index == ~0)
18670 errmsg ("missing interface name or sw_if_index");
18674 /* Construct the API message */
18675 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
18677 mp->sw_if_index = ntohl (sw_if_index);
18685 api_classify_table_info (vat_main_t * vam)
18687 unformat_input_t *input = vam->input;
18688 vl_api_classify_table_info_t *mp;
18692 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18694 if (unformat (input, "table_id %d", &table_id))
18699 if (table_id == ~0)
18701 errmsg ("missing table id");
18705 /* Construct the API message */
18706 M (CLASSIFY_TABLE_INFO, mp);
18708 mp->table_id = ntohl (table_id);
18716 api_classify_session_dump (vat_main_t * vam)
18718 unformat_input_t *input = vam->input;
18719 vl_api_classify_session_dump_t *mp;
18720 vl_api_control_ping_t *mp_ping;
18724 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18726 if (unformat (input, "table_id %d", &table_id))
18731 if (table_id == ~0)
18733 errmsg ("missing table id");
18737 /* Construct the API message */
18738 M (CLASSIFY_SESSION_DUMP, mp);
18740 mp->table_id = ntohl (table_id);
18743 /* Use a control ping for synchronization */
18744 MPING (CONTROL_PING, mp_ping);
18752 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
18754 vat_main_t *vam = &vat_main;
18756 print (vam->ofp, "collector_address %U, collector_port %d, "
18757 "src_address %U, vrf_id %d, path_mtu %u, "
18758 "template_interval %u, udp_checksum %d",
18759 format_ip4_address, mp->collector_address,
18760 ntohs (mp->collector_port),
18761 format_ip4_address, mp->src_address,
18762 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
18763 ntohl (mp->template_interval), mp->udp_checksum);
18766 vam->result_ready = 1;
18770 vl_api_ipfix_exporter_details_t_handler_json
18771 (vl_api_ipfix_exporter_details_t * mp)
18773 vat_main_t *vam = &vat_main;
18774 vat_json_node_t node;
18775 struct in_addr collector_address;
18776 struct in_addr src_address;
18778 vat_json_init_object (&node);
18779 clib_memcpy (&collector_address, &mp->collector_address,
18780 sizeof (collector_address));
18781 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
18782 vat_json_object_add_uint (&node, "collector_port",
18783 ntohs (mp->collector_port));
18784 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
18785 vat_json_object_add_ip4 (&node, "src_address", src_address);
18786 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
18787 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
18788 vat_json_object_add_uint (&node, "template_interval",
18789 ntohl (mp->template_interval));
18790 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
18792 vat_json_print (vam->ofp, &node);
18793 vat_json_free (&node);
18795 vam->result_ready = 1;
18799 api_ipfix_exporter_dump (vat_main_t * vam)
18801 vl_api_ipfix_exporter_dump_t *mp;
18804 /* Construct the API message */
18805 M (IPFIX_EXPORTER_DUMP, mp);
18814 api_ipfix_classify_stream_dump (vat_main_t * vam)
18816 vl_api_ipfix_classify_stream_dump_t *mp;
18819 /* Construct the API message */
18820 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
18831 vl_api_ipfix_classify_stream_details_t_handler
18832 (vl_api_ipfix_classify_stream_details_t * mp)
18834 vat_main_t *vam = &vat_main;
18835 print (vam->ofp, "domain_id %d, src_port %d",
18836 ntohl (mp->domain_id), ntohs (mp->src_port));
18838 vam->result_ready = 1;
18842 vl_api_ipfix_classify_stream_details_t_handler_json
18843 (vl_api_ipfix_classify_stream_details_t * mp)
18845 vat_main_t *vam = &vat_main;
18846 vat_json_node_t node;
18848 vat_json_init_object (&node);
18849 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
18850 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
18852 vat_json_print (vam->ofp, &node);
18853 vat_json_free (&node);
18855 vam->result_ready = 1;
18859 api_ipfix_classify_table_dump (vat_main_t * vam)
18861 vl_api_ipfix_classify_table_dump_t *mp;
18862 vl_api_control_ping_t *mp_ping;
18865 if (!vam->json_output)
18867 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
18868 "transport_protocol");
18871 /* Construct the API message */
18872 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
18877 /* Use a control ping for synchronization */
18878 MPING (CONTROL_PING, mp_ping);
18886 vl_api_ipfix_classify_table_details_t_handler
18887 (vl_api_ipfix_classify_table_details_t * mp)
18889 vat_main_t *vam = &vat_main;
18890 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
18891 mp->transport_protocol);
18895 vl_api_ipfix_classify_table_details_t_handler_json
18896 (vl_api_ipfix_classify_table_details_t * mp)
18898 vat_json_node_t *node = NULL;
18899 vat_main_t *vam = &vat_main;
18901 if (VAT_JSON_ARRAY != vam->json_tree.type)
18903 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18904 vat_json_init_array (&vam->json_tree);
18907 node = vat_json_array_add (&vam->json_tree);
18908 vat_json_init_object (node);
18910 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
18911 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
18912 vat_json_object_add_uint (node, "transport_protocol",
18913 mp->transport_protocol);
18917 api_sw_interface_span_enable_disable (vat_main_t * vam)
18919 unformat_input_t *i = vam->input;
18920 vl_api_sw_interface_span_enable_disable_t *mp;
18921 u32 src_sw_if_index = ~0;
18922 u32 dst_sw_if_index = ~0;
18927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18930 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
18932 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
18936 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
18938 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
18940 else if (unformat (i, "disable"))
18942 else if (unformat (i, "rx"))
18944 else if (unformat (i, "tx"))
18946 else if (unformat (i, "both"))
18948 else if (unformat (i, "l2"))
18954 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
18956 mp->sw_if_index_from = htonl (src_sw_if_index);
18957 mp->sw_if_index_to = htonl (dst_sw_if_index);
18967 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
18970 vat_main_t *vam = &vat_main;
18971 u8 *sw_if_from_name = 0;
18972 u8 *sw_if_to_name = 0;
18973 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18974 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18975 char *states[] = { "none", "rx", "tx", "both" };
18979 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18981 if ((u32) p->value[0] == sw_if_index_from)
18983 sw_if_from_name = (u8 *)(p->key);
18987 if ((u32) p->value[0] == sw_if_index_to)
18989 sw_if_to_name = (u8 *)(p->key);
18990 if (sw_if_from_name)
18995 print (vam->ofp, "%20s => %20s (%s)",
18996 sw_if_from_name, sw_if_to_name, states[mp->state]);
19000 vl_api_sw_interface_span_details_t_handler_json
19001 (vl_api_sw_interface_span_details_t * mp)
19003 vat_main_t *vam = &vat_main;
19004 vat_json_node_t *node = NULL;
19005 u8 *sw_if_from_name = 0;
19006 u8 *sw_if_to_name = 0;
19007 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19008 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19012 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19014 if ((u32) p->value[0] == sw_if_index_from)
19016 sw_if_from_name = (u8 *)(p->key);
19020 if ((u32) p->value[0] == sw_if_index_to)
19022 sw_if_to_name = (u8 *)(p->key);
19023 if (sw_if_from_name)
19029 if (VAT_JSON_ARRAY != vam->json_tree.type)
19031 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19032 vat_json_init_array (&vam->json_tree);
19034 node = vat_json_array_add (&vam->json_tree);
19036 vat_json_init_object (node);
19037 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19038 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19039 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19040 if (0 != sw_if_to_name)
19042 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19044 vat_json_object_add_uint (node, "state", mp->state);
19048 api_sw_interface_span_dump (vat_main_t * vam)
19050 unformat_input_t *input = vam->input;
19051 vl_api_sw_interface_span_dump_t *mp;
19052 vl_api_control_ping_t *mp_ping;
19056 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19058 if (unformat (input, "l2"))
19064 M (SW_INTERFACE_SPAN_DUMP, mp);
19068 /* Use a control ping for synchronization */
19069 MPING (CONTROL_PING, mp_ping);
19077 api_pg_create_interface (vat_main_t * vam)
19079 unformat_input_t *input = vam->input;
19080 vl_api_pg_create_interface_t *mp;
19084 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19086 if (unformat (input, "if_id %d", &if_id))
19093 errmsg ("missing pg interface index");
19097 /* Construct the API message */
19098 M (PG_CREATE_INTERFACE, mp);
19100 mp->interface_id = ntohl (if_id);
19108 api_pg_capture (vat_main_t * vam)
19110 unformat_input_t *input = vam->input;
19111 vl_api_pg_capture_t *mp;
19116 u8 pcap_file_set = 0;
19119 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19121 if (unformat (input, "if_id %d", &if_id))
19123 else if (unformat (input, "pcap %s", &pcap_file))
19125 else if (unformat (input, "count %d", &count))
19127 else if (unformat (input, "disable"))
19134 errmsg ("missing pg interface index");
19137 if (pcap_file_set > 0)
19139 if (vec_len (pcap_file) > 255)
19141 errmsg ("pcap file name is too long");
19146 u32 name_len = vec_len (pcap_file);
19147 /* Construct the API message */
19148 M (PG_CAPTURE, mp);
19150 mp->interface_id = ntohl (if_id);
19151 mp->is_enabled = enable;
19152 mp->count = ntohl (count);
19153 mp->pcap_name_length = ntohl (name_len);
19154 if (pcap_file_set != 0)
19156 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19158 vec_free (pcap_file);
19166 api_pg_enable_disable (vat_main_t * vam)
19168 unformat_input_t *input = vam->input;
19169 vl_api_pg_enable_disable_t *mp;
19172 u8 stream_name_set = 0;
19173 u8 *stream_name = 0;
19175 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19177 if (unformat (input, "stream %s", &stream_name))
19178 stream_name_set = 1;
19179 else if (unformat (input, "disable"))
19185 if (stream_name_set > 0)
19187 if (vec_len (stream_name) > 255)
19189 errmsg ("stream name too long");
19194 u32 name_len = vec_len (stream_name);
19195 /* Construct the API message */
19196 M (PG_ENABLE_DISABLE, mp);
19198 mp->is_enabled = enable;
19199 if (stream_name_set != 0)
19201 mp->stream_name_length = ntohl (name_len);
19202 clib_memcpy (mp->stream_name, stream_name, name_len);
19204 vec_free (stream_name);
19212 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19214 unformat_input_t *input = vam->input;
19215 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19217 u16 *low_ports = 0;
19218 u16 *high_ports = 0;
19221 ip4_address_t ip4_addr;
19222 ip6_address_t ip6_addr;
19231 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19233 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
19239 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
19244 else if (unformat (input, "vrf %d", &vrf_id))
19246 else if (unformat (input, "del"))
19248 else if (unformat (input, "port %d", &tmp))
19250 if (tmp == 0 || tmp > 65535)
19252 errmsg ("port %d out of range", tmp);
19256 this_hi = this_low + 1;
19257 vec_add1 (low_ports, this_low);
19258 vec_add1 (high_ports, this_hi);
19260 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19262 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19264 errmsg ("incorrect range parameters");
19268 /* Note: in debug CLI +1 is added to high before
19269 passing to real fn that does "the work"
19270 (ip_source_and_port_range_check_add_del).
19271 This fn is a wrapper around the binary API fn a
19272 control plane will call, which expects this increment
19273 to have occurred. Hence letting the binary API control
19274 plane fn do the increment for consistency between VAT
19275 and other control planes.
19278 vec_add1 (low_ports, this_low);
19279 vec_add1 (high_ports, this_hi);
19285 if (prefix_set == 0)
19287 errmsg ("<address>/<mask> not specified");
19293 errmsg ("VRF ID required, not specified");
19300 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19304 if (vec_len (low_ports) == 0)
19306 errmsg ("At least one port or port range required");
19310 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19312 mp->is_add = is_add;
19317 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
19322 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
19325 mp->mask_length = length;
19326 mp->number_of_ranges = vec_len (low_ports);
19328 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19329 vec_free (low_ports);
19331 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
19332 vec_free (high_ports);
19334 mp->vrf_id = ntohl (vrf_id);
19342 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
19344 unformat_input_t *input = vam->input;
19345 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
19346 u32 sw_if_index = ~0;
19348 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
19349 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
19353 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19355 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19357 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19359 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
19361 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
19363 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
19365 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
19367 else if (unformat (input, "del"))
19373 if (sw_if_index == ~0)
19375 errmsg ("Interface required but not specified");
19381 errmsg ("VRF ID required but not specified");
19385 if (tcp_out_vrf_id == 0
19386 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
19389 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19393 /* Construct the API message */
19394 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
19396 mp->sw_if_index = ntohl (sw_if_index);
19397 mp->is_add = is_add;
19398 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
19399 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
19400 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
19401 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
19406 /* Wait for a reply... */
19412 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
19414 unformat_input_t *i = vam->input;
19415 vl_api_ipsec_gre_add_del_tunnel_t *mp;
19416 u32 local_sa_id = 0;
19417 u32 remote_sa_id = 0;
19418 ip4_address_t src_address;
19419 ip4_address_t dst_address;
19423 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19425 if (unformat (i, "local_sa %d", &local_sa_id))
19427 else if (unformat (i, "remote_sa %d", &remote_sa_id))
19429 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
19431 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
19433 else if (unformat (i, "del"))
19437 clib_warning ("parse error '%U'", format_unformat_error, i);
19442 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
19444 mp->local_sa_id = ntohl (local_sa_id);
19445 mp->remote_sa_id = ntohl (remote_sa_id);
19446 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
19447 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
19448 mp->is_add = is_add;
19456 api_punt (vat_main_t * vam)
19458 unformat_input_t *i = vam->input;
19466 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19468 if (unformat (i, "ip %d", &ipv))
19470 else if (unformat (i, "protocol %d", &protocol))
19472 else if (unformat (i, "port %d", &port))
19474 else if (unformat (i, "del"))
19478 clib_warning ("parse error '%U'", format_unformat_error, i);
19485 mp->is_add = (u8) is_add;
19486 mp->ipv = (u8) ipv;
19487 mp->l4_protocol = (u8) protocol;
19488 mp->l4_port = htons ((u16) port);
19495 static void vl_api_ipsec_gre_tunnel_details_t_handler
19496 (vl_api_ipsec_gre_tunnel_details_t * mp)
19498 vat_main_t *vam = &vat_main;
19500 print (vam->ofp, "%11d%15U%15U%14d%14d",
19501 ntohl (mp->sw_if_index),
19502 format_ip4_address, &mp->src_address,
19503 format_ip4_address, &mp->dst_address,
19504 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
19507 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
19508 (vl_api_ipsec_gre_tunnel_details_t * mp)
19510 vat_main_t *vam = &vat_main;
19511 vat_json_node_t *node = NULL;
19512 struct in_addr ip4;
19514 if (VAT_JSON_ARRAY != vam->json_tree.type)
19516 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19517 vat_json_init_array (&vam->json_tree);
19519 node = vat_json_array_add (&vam->json_tree);
19521 vat_json_init_object (node);
19522 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
19523 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
19524 vat_json_object_add_ip4 (node, "src_address", ip4);
19525 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
19526 vat_json_object_add_ip4 (node, "dst_address", ip4);
19527 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
19528 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
19532 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
19534 unformat_input_t *i = vam->input;
19535 vl_api_ipsec_gre_tunnel_dump_t *mp;
19536 vl_api_control_ping_t *mp_ping;
19538 u8 sw_if_index_set = 0;
19541 /* Parse args required to build the message */
19542 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19544 if (unformat (i, "sw_if_index %d", &sw_if_index))
19545 sw_if_index_set = 1;
19550 if (sw_if_index_set == 0)
19555 if (!vam->json_output)
19557 print (vam->ofp, "%11s%15s%15s%14s%14s",
19558 "sw_if_index", "src_address", "dst_address",
19559 "local_sa_id", "remote_sa_id");
19562 /* Get list of gre-tunnel interfaces */
19563 M (IPSEC_GRE_TUNNEL_DUMP, mp);
19565 mp->sw_if_index = htonl (sw_if_index);
19569 /* Use a control ping for synchronization */
19570 MPING (CONTROL_PING, mp_ping);
19578 api_delete_subif (vat_main_t * vam)
19580 unformat_input_t *i = vam->input;
19581 vl_api_delete_subif_t *mp;
19582 u32 sw_if_index = ~0;
19585 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19587 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19589 if (unformat (i, "sw_if_index %d", &sw_if_index))
19595 if (sw_if_index == ~0)
19597 errmsg ("missing sw_if_index");
19601 /* Construct the API message */
19602 M (DELETE_SUBIF, mp);
19603 mp->sw_if_index = ntohl (sw_if_index);
19610 #define foreach_pbb_vtr_op \
19611 _("disable", L2_VTR_DISABLED) \
19612 _("pop", L2_VTR_POP_2) \
19613 _("push", L2_VTR_PUSH_2)
19616 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
19618 unformat_input_t *i = vam->input;
19619 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
19620 u32 sw_if_index = ~0, vtr_op = ~0;
19621 u16 outer_tag = ~0;
19622 u8 dmac[6], smac[6];
19623 u8 dmac_set = 0, smac_set = 0;
19629 /* Shut up coverity */
19630 memset (dmac, 0, sizeof (dmac));
19631 memset (smac, 0, sizeof (smac));
19633 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19635 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19637 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19639 else if (unformat (i, "vtr_op %d", &vtr_op))
19641 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
19644 else if (unformat (i, "translate_pbb_stag"))
19646 if (unformat (i, "%d", &tmp))
19648 vtr_op = L2_VTR_TRANSLATE_2_1;
19654 ("translate_pbb_stag operation requires outer tag definition");
19658 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
19660 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
19662 else if (unformat (i, "sid %d", &sid))
19664 else if (unformat (i, "vlanid %d", &tmp))
19668 clib_warning ("parse error '%U'", format_unformat_error, i);
19673 if ((sw_if_index == ~0) || (vtr_op == ~0))
19675 errmsg ("missing sw_if_index or vtr operation");
19678 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
19679 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
19682 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
19686 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
19687 mp->sw_if_index = ntohl (sw_if_index);
19688 mp->vtr_op = ntohl (vtr_op);
19689 mp->outer_tag = ntohs (outer_tag);
19690 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
19691 clib_memcpy (mp->b_smac, smac, sizeof (smac));
19692 mp->b_vlanid = ntohs (vlanid);
19693 mp->i_sid = ntohl (sid);
19701 api_flow_classify_set_interface (vat_main_t * vam)
19703 unformat_input_t *i = vam->input;
19704 vl_api_flow_classify_set_interface_t *mp;
19706 int sw_if_index_set;
19707 u32 ip4_table_index = ~0;
19708 u32 ip6_table_index = ~0;
19712 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19714 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19715 sw_if_index_set = 1;
19716 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19717 sw_if_index_set = 1;
19718 else if (unformat (i, "del"))
19720 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19722 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19726 clib_warning ("parse error '%U'", format_unformat_error, i);
19731 if (sw_if_index_set == 0)
19733 errmsg ("missing interface name or sw_if_index");
19737 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
19739 mp->sw_if_index = ntohl (sw_if_index);
19740 mp->ip4_table_index = ntohl (ip4_table_index);
19741 mp->ip6_table_index = ntohl (ip6_table_index);
19742 mp->is_add = is_add;
19750 api_flow_classify_dump (vat_main_t * vam)
19752 unformat_input_t *i = vam->input;
19753 vl_api_flow_classify_dump_t *mp;
19754 vl_api_control_ping_t *mp_ping;
19755 u8 type = FLOW_CLASSIFY_N_TABLES;
19758 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
19762 errmsg ("classify table type must be specified");
19766 if (!vam->json_output)
19768 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19771 M (FLOW_CLASSIFY_DUMP, mp);
19776 /* Use a control ping for synchronization */
19777 MPING (CONTROL_PING, mp_ping);
19780 /* Wait for a reply... */
19786 api_feature_enable_disable (vat_main_t * vam)
19788 unformat_input_t *i = vam->input;
19789 vl_api_feature_enable_disable_t *mp;
19791 u8 *feature_name = 0;
19792 u32 sw_if_index = ~0;
19796 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19798 if (unformat (i, "arc_name %s", &arc_name))
19800 else if (unformat (i, "feature_name %s", &feature_name))
19803 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19805 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19807 else if (unformat (i, "disable"))
19815 errmsg ("missing arc name");
19818 if (vec_len (arc_name) > 63)
19820 errmsg ("arc name too long");
19823 if (feature_name == 0)
19825 errmsg ("missing feature name");
19828 if (vec_len (feature_name) > 63)
19830 errmsg ("feature name too long");
19833 if (sw_if_index == ~0)
19835 errmsg ("missing interface name or sw_if_index");
19839 /* Construct the API message */
19840 M (FEATURE_ENABLE_DISABLE, mp);
19841 mp->sw_if_index = ntohl (sw_if_index);
19842 mp->enable = enable;
19843 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
19844 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
19845 vec_free (arc_name);
19846 vec_free (feature_name);
19854 api_sw_interface_tag_add_del (vat_main_t * vam)
19856 unformat_input_t *i = vam->input;
19857 vl_api_sw_interface_tag_add_del_t *mp;
19858 u32 sw_if_index = ~0;
19863 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19865 if (unformat (i, "tag %s", &tag))
19867 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19869 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19871 else if (unformat (i, "del"))
19877 if (sw_if_index == ~0)
19879 errmsg ("missing interface name or sw_if_index");
19883 if (enable && (tag == 0))
19885 errmsg ("no tag specified");
19889 /* Construct the API message */
19890 M (SW_INTERFACE_TAG_ADD_DEL, mp);
19891 mp->sw_if_index = ntohl (sw_if_index);
19892 mp->is_add = enable;
19894 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
19902 static void vl_api_l2_xconnect_details_t_handler
19903 (vl_api_l2_xconnect_details_t * mp)
19905 vat_main_t *vam = &vat_main;
19907 print (vam->ofp, "%15d%15d",
19908 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
19911 static void vl_api_l2_xconnect_details_t_handler_json
19912 (vl_api_l2_xconnect_details_t * mp)
19914 vat_main_t *vam = &vat_main;
19915 vat_json_node_t *node = NULL;
19917 if (VAT_JSON_ARRAY != vam->json_tree.type)
19919 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19920 vat_json_init_array (&vam->json_tree);
19922 node = vat_json_array_add (&vam->json_tree);
19924 vat_json_init_object (node);
19925 vat_json_object_add_uint (node, "rx_sw_if_index",
19926 ntohl (mp->rx_sw_if_index));
19927 vat_json_object_add_uint (node, "tx_sw_if_index",
19928 ntohl (mp->tx_sw_if_index));
19932 api_l2_xconnect_dump (vat_main_t * vam)
19934 vl_api_l2_xconnect_dump_t *mp;
19935 vl_api_control_ping_t *mp_ping;
19938 if (!vam->json_output)
19940 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
19943 M (L2_XCONNECT_DUMP, mp);
19947 /* Use a control ping for synchronization */
19948 MPING (CONTROL_PING, mp_ping);
19956 api_sw_interface_set_mtu (vat_main_t * vam)
19958 unformat_input_t *i = vam->input;
19959 vl_api_sw_interface_set_mtu_t *mp;
19960 u32 sw_if_index = ~0;
19964 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19966 if (unformat (i, "mtu %d", &mtu))
19968 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19970 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19976 if (sw_if_index == ~0)
19978 errmsg ("missing interface name or sw_if_index");
19984 errmsg ("no mtu specified");
19988 /* Construct the API message */
19989 M (SW_INTERFACE_SET_MTU, mp);
19990 mp->sw_if_index = ntohl (sw_if_index);
19991 mp->mtu = ntohs ((u16) mtu);
19999 api_p2p_ethernet_add (vat_main_t * vam)
20001 unformat_input_t *i = vam->input;
20002 vl_api_p2p_ethernet_add_t *mp;
20003 u32 parent_if_index = ~0;
20009 memset (remote_mac, 0, sizeof (remote_mac));
20010 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20012 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20014 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20018 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20020 else if (unformat (i, "sub_id %d", &sub_id))
20024 clib_warning ("parse error '%U'", format_unformat_error, i);
20029 if (parent_if_index == ~0)
20031 errmsg ("missing interface name or sw_if_index");
20036 errmsg ("missing remote mac address");
20041 errmsg ("missing sub-interface id");
20045 M (P2P_ETHERNET_ADD, mp);
20046 mp->parent_if_index = ntohl (parent_if_index);
20047 mp->subif_id = ntohl (sub_id);
20048 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20056 api_p2p_ethernet_del (vat_main_t * vam)
20058 unformat_input_t *i = vam->input;
20059 vl_api_p2p_ethernet_del_t *mp;
20060 u32 parent_if_index = ~0;
20065 memset (remote_mac, 0, sizeof (remote_mac));
20066 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20068 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20070 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20074 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20078 clib_warning ("parse error '%U'", format_unformat_error, i);
20083 if (parent_if_index == ~0)
20085 errmsg ("missing interface name or sw_if_index");
20090 errmsg ("missing remote mac address");
20094 M (P2P_ETHERNET_DEL, mp);
20095 mp->parent_if_index = ntohl (parent_if_index);
20096 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20104 api_lldp_config (vat_main_t * vam)
20106 unformat_input_t *i = vam->input;
20107 vl_api_lldp_config_t *mp;
20109 int tx_interval = 0;
20110 u8 *sys_name = NULL;
20113 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20115 if (unformat (i, "system-name %s", &sys_name))
20117 else if (unformat (i, "tx-hold %d", &tx_hold))
20119 else if (unformat (i, "tx-interval %d", &tx_interval))
20123 clib_warning ("parse error '%U'", format_unformat_error, i);
20128 vec_add1 (sys_name, 0);
20130 M (LLDP_CONFIG, mp);
20131 mp->tx_hold = htonl (tx_hold);
20132 mp->tx_interval = htonl (tx_interval);
20133 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20134 vec_free (sys_name);
20142 api_sw_interface_set_lldp (vat_main_t * vam)
20144 unformat_input_t *i = vam->input;
20145 vl_api_sw_interface_set_lldp_t *mp;
20146 u32 sw_if_index = ~0;
20148 u8 *port_desc = NULL;
20151 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20153 if (unformat (i, "disable"))
20156 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20158 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20160 else if (unformat (i, "port-desc %s", &port_desc))
20166 if (sw_if_index == ~0)
20168 errmsg ("missing interface name or sw_if_index");
20172 /* Construct the API message */
20173 vec_add1 (port_desc, 0);
20174 M (SW_INTERFACE_SET_LLDP, mp);
20175 mp->sw_if_index = ntohl (sw_if_index);
20176 mp->enable = enable;
20177 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20178 vec_free (port_desc);
20186 api_tcp_configure_src_addresses (vat_main_t * vam)
20188 vl_api_tcp_configure_src_addresses_t *mp;
20189 unformat_input_t *i = vam->input;
20190 ip4_address_t v4first, v4last;
20191 ip6_address_t v6first, v6last;
20196 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20198 if (unformat (i, "%U - %U",
20199 unformat_ip4_address, &v4first,
20200 unformat_ip4_address, &v4last))
20204 errmsg ("one range per message (range already set)");
20209 else if (unformat (i, "%U - %U",
20210 unformat_ip6_address, &v6first,
20211 unformat_ip6_address, &v6last))
20215 errmsg ("one range per message (range already set)");
20220 else if (unformat (i, "vrf %d", &vrf_id))
20226 if (range_set == 0)
20228 errmsg ("address range not set");
20232 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20233 mp->vrf_id = ntohl (vrf_id);
20235 if (range_set == 2)
20238 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20239 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20244 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20245 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20253 api_memfd_segment_create (vat_main_t * vam)
20255 unformat_input_t *i = vam->input;
20256 vl_api_memfd_segment_create_t *mp;
20257 u64 size = 64 << 20;
20260 #if VPP_API_TEST_BUILTIN == 1
20261 errmsg ("memfd_segment_create (builtin) not supported");
20265 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20267 if (unformat (i, "size %U", unformat_memory_size, &size))
20273 M (MEMFD_SEGMENT_CREATE, mp);
20274 mp->requested_size = size;
20281 q_or_quit (vat_main_t * vam)
20283 #if VPP_API_TEST_BUILTIN == 0
20284 longjmp (vam->jump_buf, 1);
20286 return 0; /* not so much */
20290 q (vat_main_t * vam)
20292 return q_or_quit (vam);
20296 quit (vat_main_t * vam)
20298 return q_or_quit (vam);
20302 comment (vat_main_t * vam)
20308 cmd_cmp (void *a1, void *a2)
20313 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
20317 help (vat_main_t * vam)
20322 unformat_input_t *i = vam->input;
20325 if (unformat (i, "%s", &name))
20329 vec_add1 (name, 0);
20331 hs = hash_get_mem (vam->help_by_name, name);
20333 print (vam->ofp, "usage: %s %s", name, hs[0]);
20335 print (vam->ofp, "No such msg / command '%s'", name);
20340 print (vam->ofp, "Help is available for the following:");
20343 hash_foreach_pair (p, vam->function_by_name,
20345 vec_add1 (cmds, (u8 *)(p->key));
20349 vec_sort_with_function (cmds, cmd_cmp);
20351 for (j = 0; j < vec_len (cmds); j++)
20352 print (vam->ofp, "%s", cmds[j]);
20359 set (vat_main_t * vam)
20361 u8 *name = 0, *value = 0;
20362 unformat_input_t *i = vam->input;
20364 if (unformat (i, "%s", &name))
20366 /* The input buffer is a vector, not a string. */
20367 value = vec_dup (i->buffer);
20368 vec_delete (value, i->index, 0);
20369 /* Almost certainly has a trailing newline */
20370 if (value[vec_len (value) - 1] == '\n')
20371 value[vec_len (value) - 1] = 0;
20372 /* Make sure it's a proper string, one way or the other */
20373 vec_add1 (value, 0);
20374 (void) clib_macro_set_value (&vam->macro_main,
20375 (char *) name, (char *) value);
20378 errmsg ("usage: set <name> <value>");
20386 unset (vat_main_t * vam)
20390 if (unformat (vam->input, "%s", &name))
20391 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
20392 errmsg ("unset: %s wasn't set", name);
20405 macro_sort_cmp (void *a1, void *a2)
20407 macro_sort_t *s1 = a1;
20408 macro_sort_t *s2 = a2;
20410 return strcmp ((char *) (s1->name), (char *) (s2->name));
20414 dump_macro_table (vat_main_t * vam)
20416 macro_sort_t *sort_me = 0, *sm;
20421 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
20423 vec_add2 (sort_me, sm, 1);
20424 sm->name = (u8 *)(p->key);
20425 sm->value = (u8 *) (p->value[0]);
20429 vec_sort_with_function (sort_me, macro_sort_cmp);
20431 if (vec_len (sort_me))
20432 print (vam->ofp, "%-15s%s", "Name", "Value");
20434 print (vam->ofp, "The macro table is empty...");
20436 for (i = 0; i < vec_len (sort_me); i++)
20437 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
20442 dump_node_table (vat_main_t * vam)
20445 vlib_node_t *node, *next_node;
20447 if (vec_len (vam->graph_nodes) == 0)
20449 print (vam->ofp, "Node table empty, issue get_node_graph...");
20453 for (i = 0; i < vec_len (vam->graph_nodes); i++)
20455 node = vam->graph_nodes[i];
20456 print (vam->ofp, "[%d] %s", i, node->name);
20457 for (j = 0; j < vec_len (node->next_nodes); j++)
20459 if (node->next_nodes[j] != ~0)
20461 next_node = vam->graph_nodes[node->next_nodes[j]];
20462 print (vam->ofp, " [%d] %s", j, next_node->name);
20470 value_sort_cmp (void *a1, void *a2)
20472 name_sort_t *n1 = a1;
20473 name_sort_t *n2 = a2;
20475 if (n1->value < n2->value)
20477 if (n1->value > n2->value)
20484 dump_msg_api_table (vat_main_t * vam)
20486 api_main_t *am = &api_main;
20487 name_sort_t *nses = 0, *ns;
20492 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
20494 vec_add2 (nses, ns, 1);
20495 ns->name = (u8 *)(hp->key);
20496 ns->value = (u32) hp->value[0];
20500 vec_sort_with_function (nses, value_sort_cmp);
20502 for (i = 0; i < vec_len (nses); i++)
20503 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
20509 get_msg_id (vat_main_t * vam)
20514 if (unformat (vam->input, "%s", &name_and_crc))
20516 message_index = vl_api_get_msg_index (name_and_crc);
20517 if (message_index == ~0)
20519 print (vam->ofp, " '%s' not found", name_and_crc);
20522 print (vam->ofp, " '%s' has message index %d",
20523 name_and_crc, message_index);
20526 errmsg ("name_and_crc required...");
20531 search_node_table (vat_main_t * vam)
20533 unformat_input_t *line_input = vam->input;
20536 vlib_node_t *node, *next_node;
20539 if (vam->graph_node_index_by_name == 0)
20541 print (vam->ofp, "Node table empty, issue get_node_graph...");
20545 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20547 if (unformat (line_input, "%s", &node_to_find))
20549 vec_add1 (node_to_find, 0);
20550 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
20553 print (vam->ofp, "%s not found...", node_to_find);
20556 node = vam->graph_nodes[p[0]];
20557 print (vam->ofp, "[%d] %s", p[0], node->name);
20558 for (j = 0; j < vec_len (node->next_nodes); j++)
20560 if (node->next_nodes[j] != ~0)
20562 next_node = vam->graph_nodes[node->next_nodes[j]];
20563 print (vam->ofp, " [%d] %s", j, next_node->name);
20570 clib_warning ("parse error '%U'", format_unformat_error,
20576 vec_free (node_to_find);
20585 script (vat_main_t * vam)
20587 #if (VPP_API_TEST_BUILTIN==0)
20589 char *save_current_file;
20590 unformat_input_t save_input;
20591 jmp_buf save_jump_buf;
20592 u32 save_line_number;
20594 FILE *new_fp, *save_ifp;
20596 if (unformat (vam->input, "%s", &s))
20598 new_fp = fopen ((char *) s, "r");
20601 errmsg ("Couldn't open script file %s", s);
20608 errmsg ("Missing script name");
20612 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
20613 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
20614 save_ifp = vam->ifp;
20615 save_line_number = vam->input_line_number;
20616 save_current_file = (char *) vam->current_file;
20618 vam->input_line_number = 0;
20620 vam->current_file = s;
20623 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
20624 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
20625 vam->ifp = save_ifp;
20626 vam->input_line_number = save_line_number;
20627 vam->current_file = (u8 *) save_current_file;
20632 clib_warning ("use the exec command...");
20638 echo (vat_main_t * vam)
20640 print (vam->ofp, "%v", vam->input->buffer);
20644 /* List of API message constructors, CLI names map to api_xxx */
20645 #define foreach_vpe_api_msg \
20646 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
20647 _(sw_interface_dump,"") \
20648 _(sw_interface_set_flags, \
20649 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
20650 _(sw_interface_add_del_address, \
20651 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
20652 _(sw_interface_set_table, \
20653 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
20654 _(sw_interface_set_mpls_enable, \
20655 "<intfc> | sw_if_index [disable | dis]") \
20656 _(sw_interface_set_vpath, \
20657 "<intfc> | sw_if_index <id> enable | disable") \
20658 _(sw_interface_set_vxlan_bypass, \
20659 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
20660 _(sw_interface_set_l2_xconnect, \
20661 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20662 "enable | disable") \
20663 _(sw_interface_set_l2_bridge, \
20664 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
20665 "[shg <split-horizon-group>] [bvi]\n" \
20666 "enable | disable") \
20667 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
20668 _(bridge_domain_add_del, \
20669 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [mac-age 0-255] [bd-tag <tag>] [del]\n") \
20670 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
20672 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
20673 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
20674 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
20676 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20678 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20680 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
20682 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
20684 "<vpp-if-name> | sw_if_index <id>") \
20685 _(sw_interface_tap_dump, "") \
20686 _(ip_table_add_del, \
20687 "table-id <n> [ipv6]\n") \
20688 _(ip_add_del_route, \
20689 "<addr>/<mask> via <addr> [table-id <n>]\n" \
20690 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
20691 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
20692 "[multipath] [count <n>]") \
20693 _(ip_mroute_add_del, \
20694 "<src> <grp>/<mask> [table-id <n>]\n" \
20695 "[<intfc> | sw_if_index <id>] [local] [del]") \
20696 _(mpls_table_add_del, \
20697 "table-id <n>\n") \
20698 _(mpls_route_add_del, \
20699 "<label> <eos> via <addr> [table-id <n>]\n" \
20700 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
20701 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
20702 "[multipath] [count <n>]") \
20703 _(mpls_ip_bind_unbind, \
20704 "<label> <addr/len>") \
20705 _(mpls_tunnel_add_del, \
20706 " via <addr> [table-id <n>]\n" \
20707 "sw_if_index <id>] [l2] [del]") \
20708 _(proxy_arp_add_del, \
20709 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
20710 _(proxy_arp_intfc_enable_disable, \
20711 "<intfc> | sw_if_index <id> enable | disable") \
20712 _(sw_interface_set_unnumbered, \
20713 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
20714 _(ip_neighbor_add_del, \
20715 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
20716 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
20717 _(reset_vrf, "vrf <id> [ipv6]") \
20718 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
20719 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
20720 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
20721 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
20722 "[outer_vlan_id_any][inner_vlan_id_any]") \
20723 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
20724 _(reset_fib, "vrf <n> [ipv6]") \
20725 _(dhcp_proxy_config, \
20726 "svr <v46-address> src <v46-address>\n" \
20727 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
20728 _(dhcp_proxy_set_vss, \
20729 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
20730 _(dhcp_proxy_dump, "ip6") \
20731 _(dhcp_client_config, \
20732 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
20733 _(set_ip_flow_hash, \
20734 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
20735 _(sw_interface_ip6_enable_disable, \
20736 "<intfc> | sw_if_index <id> enable | disable") \
20737 _(sw_interface_ip6_set_link_local_address, \
20738 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
20739 _(ip6nd_proxy_add_del, \
20740 "<intfc> | sw_if_index <id> <ip6-address>") \
20741 _(ip6nd_proxy_dump, "") \
20742 _(sw_interface_ip6nd_ra_prefix, \
20743 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
20744 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
20745 "[nolink] [isno]") \
20746 _(sw_interface_ip6nd_ra_config, \
20747 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
20748 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
20749 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
20750 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
20751 _(l2_patch_add_del, \
20752 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20753 "enable | disable") \
20754 _(sr_localsid_add_del, \
20755 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
20756 "fib-table <num> (end.psp) sw_if_index <num>") \
20757 _(classify_add_del_table, \
20758 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
20759 " [del] [del-chain] mask <mask-value>\n" \
20760 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
20761 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
20762 _(classify_add_del_session, \
20763 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
20764 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
20765 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
20766 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
20767 _(classify_set_interface_ip_table, \
20768 "<intfc> | sw_if_index <nn> table <nn>") \
20769 _(classify_set_interface_l2_tables, \
20770 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20771 " [other-table <nn>]") \
20772 _(get_node_index, "node <node-name") \
20773 _(add_node_next, "node <node-name> next <next-node-name>") \
20774 _(l2tpv3_create_tunnel, \
20775 "client_address <ip6-addr> our_address <ip6-addr>\n" \
20776 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
20777 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
20778 _(l2tpv3_set_tunnel_cookies, \
20779 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
20780 "[new_remote_cookie <nn>]\n") \
20781 _(l2tpv3_interface_enable_disable, \
20782 "<intfc> | sw_if_index <nn> enable | disable") \
20783 _(l2tpv3_set_lookup_key, \
20784 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
20785 _(sw_if_l2tpv3_tunnel_dump, "") \
20786 _(vxlan_add_del_tunnel, \
20787 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
20788 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20789 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
20790 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20791 _(gre_add_del_tunnel, \
20792 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
20793 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20794 _(l2_fib_clear_table, "") \
20795 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
20796 _(l2_interface_vlan_tag_rewrite, \
20797 "<intfc> | sw_if_index <nn> \n" \
20798 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
20799 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
20800 _(create_vhost_user_if, \
20801 "socket <filename> [server] [renumber <dev_instance>] " \
20802 "[mac <mac_address>]") \
20803 _(modify_vhost_user_if, \
20804 "<intfc> | sw_if_index <nn> socket <filename>\n" \
20805 "[server] [renumber <dev_instance>]") \
20806 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
20807 _(sw_interface_vhost_user_dump, "") \
20808 _(show_version, "") \
20809 _(vxlan_gpe_add_del_tunnel, \
20810 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
20811 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20812 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
20813 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
20814 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20815 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
20816 _(interface_name_renumber, \
20817 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
20818 _(input_acl_set_interface, \
20819 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20820 " [l2-table <nn>] [del]") \
20821 _(want_ip4_arp_events, "address <ip4-address> [del]") \
20822 _(want_ip6_nd_events, "address <ip6-address> [del]") \
20823 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
20824 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
20825 _(ip_dump, "ipv4 | ipv6") \
20826 _(ipsec_spd_add_del, "spd_id <n> [del]") \
20827 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
20829 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
20830 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
20831 " integ_alg <alg> integ_key <hex>") \
20832 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
20833 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
20834 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
20835 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
20836 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
20837 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
20838 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
20839 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
20840 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
20841 _(ikev2_profile_add_del, "name <profile_name> [del]") \
20842 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
20843 "(auth_data 0x<data> | auth_data <data>)") \
20844 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
20845 "(id_data 0x<data> | id_data <data>) (local|remote)") \
20846 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
20847 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
20848 "(local|remote)") \
20849 _(ikev2_set_local_key, "file <absolute_file_path>") \
20850 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
20851 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
20852 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
20853 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
20854 _(ikev2_initiate_sa_init, "<profile_name>") \
20855 _(ikev2_initiate_del_ike_sa, "<ispi>") \
20856 _(ikev2_initiate_del_child_sa, "<ispi>") \
20857 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
20858 _(delete_loopback,"sw_if_index <nn>") \
20859 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
20860 _(map_add_domain, \
20861 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
20862 "ip6-src <ip6addr> " \
20863 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
20864 _(map_del_domain, "index <n>") \
20865 _(map_add_del_rule, \
20866 "index <n> psid <n> dst <ip6addr> [del]") \
20867 _(map_domain_dump, "") \
20868 _(map_rule_dump, "index <map-domain>") \
20869 _(want_interface_events, "enable|disable") \
20870 _(want_stats,"enable|disable") \
20871 _(get_first_msg_id, "client <name>") \
20872 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
20873 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
20874 "fib-id <nn> [ip4][ip6][default]") \
20875 _(get_node_graph, " ") \
20876 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
20877 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
20878 _(ioam_disable, "") \
20879 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
20880 " sw_if_index <sw_if_index> p <priority> " \
20881 "w <weight>] [del]") \
20882 _(one_add_del_locator, "locator-set <locator_name> " \
20883 "iface <intf> | sw_if_index <sw_if_index> " \
20884 "p <priority> w <weight> [del]") \
20885 _(one_add_del_local_eid,"vni <vni> eid " \
20886 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20887 "locator-set <locator_name> [del]" \
20888 "[key-id sha1|sha256 secret-key <secret-key>]")\
20889 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
20890 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
20891 _(one_enable_disable, "enable|disable") \
20892 _(one_map_register_enable_disable, "enable|disable") \
20893 _(one_map_register_fallback_threshold, "<value>") \
20894 _(one_rloc_probe_enable_disable, "enable|disable") \
20895 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20897 "rloc <locator> p <prio> " \
20898 "w <weight> [rloc <loc> ... ] " \
20899 "action <action> [del-all]") \
20900 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20902 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20903 _(one_use_petr, "ip-address> | disable") \
20904 _(one_map_request_mode, "src-dst|dst-only") \
20905 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20906 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20907 _(one_locator_set_dump, "[local | remote]") \
20908 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
20909 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20910 "[local] | [remote]") \
20911 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
20912 _(one_ndp_bd_get, "") \
20913 _(one_ndp_entries_get, "bd <bridge-domain>") \
20914 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
20915 _(one_l2_arp_bd_get, "") \
20916 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
20917 _(one_stats_enable_disable, "enable|disalbe") \
20918 _(show_one_stats_enable_disable, "") \
20919 _(one_eid_table_vni_dump, "") \
20920 _(one_eid_table_map_dump, "l2|l3") \
20921 _(one_map_resolver_dump, "") \
20922 _(one_map_server_dump, "") \
20923 _(one_adjacencies_get, "vni <vni>") \
20924 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
20925 _(show_one_rloc_probe_state, "") \
20926 _(show_one_map_register_state, "") \
20927 _(show_one_status, "") \
20928 _(one_stats_dump, "") \
20929 _(one_stats_flush, "") \
20930 _(one_get_map_request_itr_rlocs, "") \
20931 _(one_map_register_set_ttl, "<ttl>") \
20932 _(one_set_transport_protocol, "udp|api") \
20933 _(one_get_transport_protocol, "") \
20934 _(show_one_nsh_mapping, "") \
20935 _(show_one_pitr, "") \
20936 _(show_one_use_petr, "") \
20937 _(show_one_map_request_mode, "") \
20938 _(show_one_map_register_ttl, "") \
20939 _(show_one_map_register_fallback_threshold, "") \
20940 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
20941 " sw_if_index <sw_if_index> p <priority> " \
20942 "w <weight>] [del]") \
20943 _(lisp_add_del_locator, "locator-set <locator_name> " \
20944 "iface <intf> | sw_if_index <sw_if_index> " \
20945 "p <priority> w <weight> [del]") \
20946 _(lisp_add_del_local_eid,"vni <vni> eid " \
20947 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20948 "locator-set <locator_name> [del]" \
20949 "[key-id sha1|sha256 secret-key <secret-key>]") \
20950 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
20951 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
20952 _(lisp_enable_disable, "enable|disable") \
20953 _(lisp_map_register_enable_disable, "enable|disable") \
20954 _(lisp_rloc_probe_enable_disable, "enable|disable") \
20955 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20957 "rloc <locator> p <prio> " \
20958 "w <weight> [rloc <loc> ... ] " \
20959 "action <action> [del-all]") \
20960 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20962 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20963 _(lisp_use_petr, "<ip-address> | disable") \
20964 _(lisp_map_request_mode, "src-dst|dst-only") \
20965 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20966 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20967 _(lisp_locator_set_dump, "[local | remote]") \
20968 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
20969 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20970 "[local] | [remote]") \
20971 _(lisp_eid_table_vni_dump, "") \
20972 _(lisp_eid_table_map_dump, "l2|l3") \
20973 _(lisp_map_resolver_dump, "") \
20974 _(lisp_map_server_dump, "") \
20975 _(lisp_adjacencies_get, "vni <vni>") \
20976 _(gpe_fwd_entry_vnis_get, "") \
20977 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
20978 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
20979 "[table <table-id>]") \
20980 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
20981 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
20982 _(gpe_set_encap_mode, "lisp|vxlan") \
20983 _(gpe_get_encap_mode, "") \
20984 _(lisp_gpe_add_del_iface, "up|down") \
20985 _(lisp_gpe_enable_disable, "enable|disable") \
20986 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
20987 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
20988 _(show_lisp_rloc_probe_state, "") \
20989 _(show_lisp_map_register_state, "") \
20990 _(show_lisp_status, "") \
20991 _(lisp_get_map_request_itr_rlocs, "") \
20992 _(show_lisp_pitr, "") \
20993 _(show_lisp_use_petr, "") \
20994 _(show_lisp_map_request_mode, "") \
20995 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
20996 _(af_packet_delete, "name <host interface name>") \
20997 _(policer_add_del, "name <policer name> <params> [del]") \
20998 _(policer_dump, "[name <policer name>]") \
20999 _(policer_classify_set_interface, \
21000 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21001 " [l2-table <nn>] [del]") \
21002 _(policer_classify_dump, "type [ip4|ip6|l2]") \
21003 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
21004 "[master|slave]") \
21005 _(netmap_delete, "name <interface name>") \
21006 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
21007 _(mpls_fib_dump, "") \
21008 _(classify_table_ids, "") \
21009 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
21010 _(classify_table_info, "table_id <nn>") \
21011 _(classify_session_dump, "table_id <nn>") \
21012 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
21013 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
21014 "[template_interval <nn>] [udp_checksum]") \
21015 _(ipfix_exporter_dump, "") \
21016 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
21017 _(ipfix_classify_stream_dump, "") \
21018 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
21019 _(ipfix_classify_table_dump, "") \
21020 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
21021 _(sw_interface_span_dump, "[l2]") \
21022 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
21023 _(pg_create_interface, "if_id <nn>") \
21024 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
21025 _(pg_enable_disable, "[stream <id>] disable") \
21026 _(ip_source_and_port_range_check_add_del, \
21027 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
21028 _(ip_source_and_port_range_check_interface_add_del, \
21029 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
21030 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
21031 _(ipsec_gre_add_del_tunnel, \
21032 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
21033 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
21034 _(delete_subif,"<intfc> | sw_if_index <nn>") \
21035 _(l2_interface_pbb_tag_rewrite, \
21036 "<intfc> | sw_if_index <nn> \n" \
21037 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
21038 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
21039 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
21040 _(flow_classify_set_interface, \
21041 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
21042 _(flow_classify_dump, "type [ip4|ip6]") \
21043 _(ip_fib_dump, "") \
21044 _(ip_mfib_dump, "") \
21045 _(ip6_fib_dump, "") \
21046 _(ip6_mfib_dump, "") \
21047 _(feature_enable_disable, "arc_name <arc_name> " \
21048 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
21049 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
21051 _(l2_xconnect_dump, "") \
21052 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
21053 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
21054 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
21055 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
21056 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
21057 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
21058 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>] [disable]") \
21059 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
21060 _(memfd_segment_create,"size <nnn>")
21062 /* List of command functions, CLI names map directly to functions */
21063 #define foreach_cli_function \
21064 _(comment, "usage: comment <ignore-rest-of-line>") \
21065 _(dump_interface_table, "usage: dump_interface_table") \
21066 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
21067 _(dump_ipv4_table, "usage: dump_ipv4_table") \
21068 _(dump_ipv6_table, "usage: dump_ipv6_table") \
21069 _(dump_stats_table, "usage: dump_stats_table") \
21070 _(dump_macro_table, "usage: dump_macro_table ") \
21071 _(dump_node_table, "usage: dump_node_table") \
21072 _(dump_msg_api_table, "usage: dump_msg_api_table") \
21073 _(get_msg_id, "usage: get_msg_id name_and_crc") \
21074 _(echo, "usage: echo <message>") \
21075 _(exec, "usage: exec <vpe-debug-CLI-command>") \
21076 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
21077 _(help, "usage: help") \
21078 _(q, "usage: quit") \
21079 _(quit, "usage: quit") \
21080 _(search_node_table, "usage: search_node_table <name>...") \
21081 _(set, "usage: set <variable-name> <value>") \
21082 _(script, "usage: script <file-name>") \
21083 _(unset, "usage: unset <variable-name>")
21085 static void vl_api_##n##_t_handler_uni \
21086 (vl_api_##n##_t * mp) \
21088 vat_main_t * vam = &vat_main; \
21089 if (vam->json_output) { \
21090 vl_api_##n##_t_handler_json(mp); \
21092 vl_api_##n##_t_handler(mp); \
21095 foreach_vpe_api_reply_msg;
21096 #if VPP_API_TEST_BUILTIN == 0
21097 foreach_standalone_reply_msg;
21102 vat_api_hookup (vat_main_t * vam)
21105 vl_msg_api_set_handlers(VL_API_##N, #n, \
21106 vl_api_##n##_t_handler_uni, \
21108 vl_api_##n##_t_endian, \
21109 vl_api_##n##_t_print, \
21110 sizeof(vl_api_##n##_t), 1);
21111 foreach_vpe_api_reply_msg;
21112 #if VPP_API_TEST_BUILTIN == 0
21113 foreach_standalone_reply_msg;
21117 #if (VPP_API_TEST_BUILTIN==0)
21118 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
21120 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
21122 vam->function_by_name = hash_create_string (0, sizeof (uword));
21124 vam->help_by_name = hash_create_string (0, sizeof (uword));
21127 /* API messages we can send */
21128 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
21129 foreach_vpe_api_msg;
21133 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21134 foreach_vpe_api_msg;
21137 /* CLI functions */
21138 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
21139 foreach_cli_function;
21143 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21144 foreach_cli_function;
21148 #if VPP_API_TEST_BUILTIN
21149 static clib_error_t *
21150 vat_api_hookup_shim (vlib_main_t * vm)
21152 vat_api_hookup (&vat_main);
21156 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
21160 * fd.io coding-style-patch-verification: ON
21163 * eval: (c-set-style "gnu")